Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9b77017a authored by Michal Brzezinski's avatar Michal Brzezinski
Browse files

Removing focusability from all scrims in shade

This caused unnecessary catching focus when user opens shade and presses Tab key. Only 3rd press would actually show focus on the first actionable element (QS).
I don't think there's any use case when (a11y) focus would be useful on scrims as they are just coloring background and serve different roles depending on shade state.

Fixes: 311165439
Test: With keyboard connected, open shade, press Tab once and see focus immediately going to QS
Change-Id: Id2fb700f6799d2a6f8d0ea5fc56391cec342be6a
parent 6d617f78
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -48,7 +48,6 @@
        android:id="@+id/scrim_behind"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:importantForAccessibility="no"
        sysui:ignoreRightInset="true"
    />

@@ -56,7 +55,6 @@
        android:id="@+id/scrim_notifications"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:importantForAccessibility="no"
        sysui:ignoreRightInset="true"
    />

@@ -89,7 +87,6 @@
        android:id="@+id/scrim_in_front"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:importantForAccessibility="no"
        sysui:ignoreRightInset="true"
    />

+2 −0
Original line number Diff line number Diff line
@@ -86,6 +86,8 @@ public class ScrimView extends View {
    public ScrimView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);

        setFocusable(false);
        setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
        mDrawable = new ScrimDrawable();
        mDrawable.setCallback(this);
        mColors = new ColorExtractor.GradientColors();
+0 −9
Original line number Diff line number Diff line
@@ -389,9 +389,6 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
            states[i].setDefaultScrimAlpha(mDefaultScrimAlpha);
        }

        mScrimBehind.setDefaultFocusHighlightEnabled(false);
        mNotificationsScrim.setDefaultFocusHighlightEnabled(false);
        mScrimInFront.setDefaultFocusHighlightEnabled(false);
        mTransparentScrimBackground = notificationsScrim.getResources()
                .getBoolean(R.bool.notification_scrim_transparent);
        updateScrims();
@@ -495,12 +492,6 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump

        applyState();

        // Scrim might acquire focus when user is navigating with a D-pad or a keyboard.
        // We need to disable focus otherwise AOD would end up with a gray overlay.
        mScrimInFront.setFocusable(!state.isLowPowerState());
        mScrimBehind.setFocusable(!state.isLowPowerState());
        mNotificationsScrim.setFocusable(!state.isLowPowerState());

        mScrimInFront.setBlendWithMainColor(state.shouldBlendWithMainColor());

        // Cancel blanking transitions that were pending before we requested a new state
+5 −16
Original line number Diff line number Diff line
@@ -1178,14 +1178,11 @@ public class ScrimControllerTest extends SysuiTestCase {
    }

    @Test
    public void testScrimFocus() {
        mScrimController.transitionTo(ScrimState.AOD);
        assertFalse("Should not be focusable on AOD", mScrimBehind.isFocusable());
        assertFalse("Should not be focusable on AOD", mScrimInFront.isFocusable());

        mScrimController.transitionTo(ScrimState.KEYGUARD);
        Assert.assertTrue("Should be focusable on keyguard", mScrimBehind.isFocusable());
        Assert.assertTrue("Should be focusable on keyguard", mScrimInFront.isFocusable());
    public void testScrimsAreNotFocusable() {
        assertFalse("Behind scrim should not be focusable", mScrimBehind.isFocusable());
        assertFalse("Front scrim should not be focusable", mScrimInFront.isFocusable());
        assertFalse("Notifications scrim should not be focusable",
                mNotificationsScrim.isFocusable());
    }

    @Test
@@ -1255,14 +1252,6 @@ public class ScrimControllerTest extends SysuiTestCase {
                ScrimState.AOD.getAnimateChange());
    }

    @Test
    public void testViewsDontHaveFocusHighlight() {
        assertFalse("Scrim shouldn't have focus highlight",
                mScrimInFront.getDefaultFocusHighlightEnabled());
        assertFalse("Scrim shouldn't have focus highlight",
                mScrimBehind.getDefaultFocusHighlightEnabled());
    }

    @Test
    public void testIsLowPowerMode() {
        HashSet<ScrimState> lowPowerModeStates = new HashSet<>(Arrays.asList(