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

Commit e4dfd1ac authored by Michał Brzeziński's avatar Michał Brzeziński Committed by Android (Google) Code Review
Browse files

Merge "Removing focusability from all scrims in shade" into main

parents b7ef601b 9b77017a
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@
        android:id="@+id/scrim_behind"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:importantForAccessibility="no"
        sysui:ignoreRightInset="true"
    />

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

@@ -78,7 +76,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
@@ -396,9 +396,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();
@@ -509,12 +506,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
@@ -1185,14 +1185,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
@@ -1262,14 +1259,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(