From 850f51a15635b4d67b5e00e23e52e636eba1cc95 Mon Sep 17 00:00:00 2001 From: Alexander-- Date: Sun, 12 Apr 2020 09:38:16 +0659 Subject: [PATCH] When drawer opens, always place focus at it's start --- .../newpipe/views/FocusAwareDrawerLayout.java | 27 +------------------ 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/views/FocusAwareDrawerLayout.java b/app/src/main/java/org/schabi/newpipe/views/FocusAwareDrawerLayout.java index eed2f5250..0da42fab6 100644 --- a/app/src/main/java/org/schabi/newpipe/views/FocusAwareDrawerLayout.java +++ b/app/src/main/java/org/schabi/newpipe/views/FocusAwareDrawerLayout.java @@ -21,13 +21,10 @@ import android.annotation.SuppressLint; import android.content.Context; import android.graphics.Rect; import android.util.AttributeSet; -import android.view.Gravity; import android.view.View; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.core.view.GravityCompat; -import androidx.core.view.ViewCompat; import androidx.drawerlayout.widget.DrawerLayout; import java.util.ArrayList; @@ -111,28 +108,6 @@ public final class FocusAwareDrawerLayout extends DrawerLayout { public void openDrawer(@NonNull final View drawerView, final boolean animate) { super.openDrawer(drawerView, animate); - LayoutParams params = (LayoutParams) drawerView.getLayoutParams(); - - int gravity = GravityCompat.getAbsoluteGravity( - params.gravity, ViewCompat.getLayoutDirection(this)); - - int direction = 0; - - switch (gravity) { - case Gravity.LEFT: - direction = FOCUS_LEFT; - break; - case Gravity.RIGHT: - direction = FOCUS_RIGHT; - break; - case Gravity.TOP: - direction = FOCUS_UP; - break; - case Gravity.BOTTOM: - direction = FOCUS_DOWN; - break; - } - - drawerView.requestFocus(direction); + drawerView.requestFocus(FOCUS_FORWARD); } }