Skip to content

Commit

Permalink
Merge pull request #3337 from AioiLight/blocking-gesture-when-touch-f…
Browse files Browse the repository at this point in the history
…rom-navbar

Block the gesture when touch it from NavigationBar or StatusBar.
  • Loading branch information
TobiGr authored May 9, 2020
2 parents 9cf76a9 + 0abd2bc commit b3eadb5
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -1325,6 +1325,13 @@ public boolean onScroll(final MotionEvent initialEvent, final MotionEvent moving
return false;
}

final boolean isTouchingStatusBar = initialEvent.getY() < getStatusBarHeight();
final boolean isTouchingNavigationBar = initialEvent.getY()
> playerImpl.getRootView().getHeight() - getNavigationBarHeight();
if (isTouchingStatusBar || isTouchingNavigationBar) {
return false;
}

// if (DEBUG) {
// Log.d(TAG, "MainVideoPlayer.onScroll = " +
// "e1.getRaw = [" + initialEvent.getRawX() + ", "
Expand Down Expand Up @@ -1413,6 +1420,22 @@ public boolean onScroll(final MotionEvent initialEvent, final MotionEvent moving
return true;
}

private int getNavigationBarHeight() {
int resId = getResources().getIdentifier("navigation_bar_height", "dimen", "android");
if (resId > 0) {
return getResources().getDimensionPixelSize(resId);
}
return 0;
}

private int getStatusBarHeight() {
int resId = getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resId > 0) {
return getResources().getDimensionPixelSize(resId);
}
return 0;
}

private void onScrollEnd() {
if (DEBUG) {
Log.d(TAG, "onScrollEnd() called");
Expand Down

0 comments on commit b3eadb5

Please sign in to comment.