Skip to content

Commit

Permalink
Check the Android version before adding the long click fix (#2812)
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo committed Feb 20, 2020
1 parent 1480654 commit dca02fa
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions app/src/common/shared/org/mozilla/vrbrowser/ui/views/UIButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,20 @@ public UIButton(Context context, AttributeSet attrs, int defStyleAttr) {

mBackground = getBackground();

setLongClickable(false);
setOnTouchListener((v, event) -> {
if (event.getAction() == MotionEvent.ACTION_UP) {
long time = event.getEventTime() - event.getDownTime();
if (time > ViewConfiguration.getLongPressTimeout()) {
performClick();
// Android >8 doesn't perform a click when long clicking in ImageViews even if long click is disabled
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
setLongClickable(false);
setOnTouchListener((v, event) -> {
if (event.getAction() == MotionEvent.ACTION_UP) {
long time = event.getEventTime() - event.getDownTime();
if (time > ViewConfiguration.getLongPressTimeout()) {
performClick();
}
}
}

return false;
});
return false;
});
}
}

@TargetApi(Build.VERSION_CODES.O)
Expand Down

0 comments on commit dca02fa

Please sign in to comment.