From d9c6f7acb635136d51b748b6d843e6398180c63e Mon Sep 17 00:00:00 2001 From: AioiLight Date: Fri, 3 Apr 2020 05:11:36 +0900 Subject: [PATCH] Block the gesture when touch it from NavigationBar or StatusBar. --- .../newpipe/player/MainVideoPlayer.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java b/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java index 42759a5ed..b3cedc456 100644 --- a/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java @@ -1061,6 +1061,24 @@ public final class MainVideoPlayer extends AppCompatActivity }; } + 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; + } + /////////////////////////////////////////////////////////////////////////// // Getters /////////////////////////////////////////////////////////////////////////// @@ -1171,6 +1189,13 @@ public final class MainVideoPlayer extends AppCompatActivity ", e2.getRaw = [" + movingEvent.getRawX() + ", " + movingEvent.getRawY() + "]" + ", distanceXy = [" + distanceX + ", " + distanceY + "]"); + final boolean isTouchingStatusBar = initialEvent.getY() < playerImpl.getStatusBarHeight(); + final boolean isTouchingNavigationBar = initialEvent.getY() > playerImpl.getRootView().getHeight() - playerImpl.getNavigationBarHeight(); + if (isTouchingStatusBar || isTouchingNavigationBar) + { + return false; + } + final boolean insideThreshold = Math.abs(movingEvent.getY() - initialEvent.getY()) <= MOVEMENT_THRESHOLD; if (!isMoving && (insideThreshold || Math.abs(distanceX) > Math.abs(distanceY)) || playerImpl.getCurrentState() == BasePlayer.STATE_COMPLETED) {