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

Commit 3b9da58a authored by Mariia Sandrikova's avatar Mariia Sandrikova
Browse files

Allow status and navigation bars to be semi-transparent in letterbox mode.

Before this change, opaque bars were drawn over letterboxed activities to prevent showing a transparent bar over them because that can make notification icons or navigation buttons unreadable due to contrast between letterbox background and an activity. For instance, this happens when letterbox background is solid black while activity is white. To imporve UI in this case, semi-transparent bars are now allowed to be drawn over letterboxed activities.

Test: atest SystemUITests + manual letterbox testing
Fix: 175482966
Fix: 170216100
Change-Id: I35e35d01df7d25a5d77eb64af4e6b800f5020487
parent db10b7cb
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import static android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS;
import static android.view.WindowInsetsController.APPEARANCE_LOW_PROFILE_BARS;
import static android.view.WindowInsetsController.APPEARANCE_OPAQUE_NAVIGATION_BARS;
import static android.view.WindowInsetsController.APPEARANCE_OPAQUE_STATUS_BARS;
import static android.view.WindowInsetsController.APPEARANCE_SEMI_TRANSPARENT_NAVIGATION_BARS;
import static android.view.WindowInsetsController.APPEARANCE_SEMI_TRANSPARENT_STATUS_BARS;
import static android.view.WindowInsetsController.BEHAVIOR_DEFAULT;
import static android.view.WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE;

@@ -54,7 +56,15 @@ public class InsetsFlags {
            @ViewDebug.FlagToString(
                    mask = APPEARANCE_LIGHT_NAVIGATION_BARS,
                    equals = APPEARANCE_LIGHT_NAVIGATION_BARS,
                    name = "LIGHT_NAVIGATION_BARS")
                    name = "LIGHT_NAVIGATION_BARS"),
            @ViewDebug.FlagToString(
                    mask = APPEARANCE_SEMI_TRANSPARENT_STATUS_BARS,
                    equals = APPEARANCE_SEMI_TRANSPARENT_STATUS_BARS,
                    name = "SEMI_TRANSPARENT_STATUS_BARS"),
            @ViewDebug.FlagToString(
                    mask = APPEARANCE_SEMI_TRANSPARENT_NAVIGATION_BARS,
                    equals = APPEARANCE_SEMI_TRANSPARENT_NAVIGATION_BARS,
                    name = "SEMI_TRANSPARENT_NAVIGATION_BARS")
    })
    public @Appearance int appearance;

+14 −1
Original line number Diff line number Diff line
@@ -66,6 +66,18 @@ public interface WindowInsetsController {
     */
    int APPEARANCE_LIGHT_NAVIGATION_BARS = 1 << 4;

    /**
     * Makes status bars semi-transparent with dark background and light foreground.
     * @hide
     */
    int APPEARANCE_SEMI_TRANSPARENT_STATUS_BARS = 1 << 5;

    /**
     * Makes navigation bars semi-transparent with dark background and light foreground.
     * @hide
     */
    int APPEARANCE_SEMI_TRANSPARENT_NAVIGATION_BARS = 1 << 6;

    /**
     * Determines the appearance of system bars.
     * @hide
@@ -73,7 +85,8 @@ public interface WindowInsetsController {
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(flag = true, value = {APPEARANCE_OPAQUE_STATUS_BARS, APPEARANCE_OPAQUE_NAVIGATION_BARS,
            APPEARANCE_LOW_PROFILE_BARS, APPEARANCE_LIGHT_STATUS_BARS,
            APPEARANCE_LIGHT_NAVIGATION_BARS})
            APPEARANCE_LIGHT_NAVIGATION_BARS, APPEARANCE_SEMI_TRANSPARENT_STATUS_BARS,
            APPEARANCE_SEMI_TRANSPARENT_NAVIGATION_BARS})
    @interface Appearance {
    }

+3 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
import static android.view.InsetsState.containsType;
import static android.view.WindowInsetsController.APPEARANCE_LOW_PROFILE_BARS;
import static android.view.WindowInsetsController.APPEARANCE_OPAQUE_NAVIGATION_BARS;
import static android.view.WindowInsetsController.APPEARANCE_SEMI_TRANSPARENT_NAVIGATION_BARS;
import static android.view.WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;
@@ -994,6 +995,8 @@ public class NavigationBar implements View.OnAttachStateChangeListener,
            return MODE_LIGHTS_OUT_TRANSPARENT;
        } else if ((appearance & APPEARANCE_OPAQUE_NAVIGATION_BARS) != 0) {
            return MODE_OPAQUE;
        } else if ((appearance & APPEARANCE_SEMI_TRANSPARENT_NAVIGATION_BARS) != 0) {
            return MODE_SEMI_TRANSPARENT;
        } else {
            return MODE_TRANSPARENT;
        }
+3 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import static android.view.InsetsState.ITYPE_STATUS_BAR;
import static android.view.InsetsState.containsType;
import static android.view.WindowInsetsController.APPEARANCE_LOW_PROFILE_BARS;
import static android.view.WindowInsetsController.APPEARANCE_OPAQUE_STATUS_BARS;
import static android.view.WindowInsetsController.APPEARANCE_SEMI_TRANSPARENT_STATUS_BARS;

import static androidx.lifecycle.Lifecycle.State.RESUMED;

@@ -2428,6 +2429,8 @@ public class StatusBar extends SystemUI implements DemoMode,
            return MODE_LIGHTS_OUT_TRANSPARENT;
        } else if ((appearance & APPEARANCE_OPAQUE_STATUS_BARS) != 0) {
            return MODE_OPAQUE;
        } else if ((appearance & APPEARANCE_SEMI_TRANSPARENT_STATUS_BARS) != 0) {
            return MODE_SEMI_TRANSPARENT;
        } else {
            return MODE_TRANSPARENT;
        }
+3 −6
Original line number Diff line number Diff line
@@ -1431,14 +1431,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    }

    /**
     * @return {@code true} if bar shown within a given rectangle is allowed to be transparent
     * @return {@code true} if bar shown within a given rectangle is allowed to be fully transparent
     *     when the current activity is displayed.
     */
    boolean isTransparentBarAllowed(Rect rect) {
        // TODO(b/175482966): Allow status and navigation bars to be semi-transparent black
        // in letterbox mode.
        return mLetterbox == null || mLetterbox.notIntersectsOrFullyContains(rect)
                || mWmService.isLetterboxActivityCornersRounded();
    boolean isFullyTransparentBarAllowed(Rect rect) {
        return mLetterbox == null || mLetterbox.notIntersectsOrFullyContains(rect);
    }

    /**
Loading