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

Commit bd957406 authored by John Spurlock's avatar John Spurlock
Browse files

Transparent system ui flags -> Translucent WM flags.

Migrate View.SYSTEM_UI_FLAG_TRANSPARENT_(STATUS/NAVIGATION) to
WindowManager.LayoutParams.FLAG_TRANSLUCENT_(STATUS|NAVIGATION).

Add associated public attrs for both new window flags:
  windowTranslucentStatus
  windowTranslucentNavigation

Introduce convenient four new themes that set translucent decor:
  Theme.Holo.NoActionBar.TranslucentDecor
  Theme.Holo.Light.NoActionBar.TranslucentDecor
  Theme.DeviceDefault.NoActionBar.TranslucentDecor
  Theme.DeviceDefault.Light.NoActionBar.TranslucentDecor

Update PhoneWindowManager mechanism to plumb these values back to
SystemUI to drive bar mode state.

The new translucent flags come from the top fullscreen window, not
the focused window, so translucency does not change when opening
dialogs.

Imply some window-level system-ui visibility if one or both of these
new flags are present, specifically:
  FLAG_TRANSLUCENT_STATUS implies LAYOUT_STABLE, LAYOUT_FULLSCREEN
  FLAG_TRANSLUCENT_NAVIGATION implies LAYOUT STABLE, LAYOUT_HIDE_NAV

Rename all associated variable & resource names to use the term
translucent instead of transparent. (Retain the term semi-transparent
for the transient bar style).

Recents activity allowed to inherit translucent decor state via the
new PRIVATE_FLAG_INHERIT_TRANSLUCENT_DECOR.  Compensating changes
to use the full screen area more appropriately.

Update keyguard to use new WM flags.

Update docs and various api artifacts.

Sanity-check fixes:
 - Toasts and alerts given stable layout.
 - Suppress nu-gradient when in transient (hidey) mode.
 - New translucent flags use top-fullscreen window, dialogs don't clear.

Bug:10674960
Bug:11062108
Bug:10987178
Bug:10786445
Bug:10781433
Change-Id: If667a55bea4cf5e008549524b9899197fab55ebe
parent fd65373d
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -1226,6 +1226,8 @@ package android {
    field public static final int windowTitleBackgroundStyle = 16842844; // 0x101005c
    field public static final int windowTitleSize = 16842842; // 0x101005a
    field public static final int windowTitleStyle = 16842843; // 0x101005b
    field public static final int windowTranslucentNavigation = 16843760; // 0x10103f0
    field public static final int windowTranslucentStatus = 16843759; // 0x10103ef
    field public static final int writePermission = 16842760; // 0x1010008
    field public static final int x = 16842924; // 0x10100ac
    field public static final int xlargeScreens = 16843455; // 0x10102bf
@@ -1758,10 +1760,12 @@ package android {
    field public static final int Theme_DeviceDefault_Light_NoActionBar = 16974124; // 0x103012c
    field public static final int Theme_DeviceDefault_Light_NoActionBar_Fullscreen = 16974125; // 0x103012d
    field public static final int Theme_DeviceDefault_Light_NoActionBar_Overscan = 16974304; // 0x10301e0
    field public static final int Theme_DeviceDefault_Light_NoActionBar_TranslucentDecor = 16974308; // 0x10301e4
    field public static final int Theme_DeviceDefault_Light_Panel = 16974139; // 0x103013b
    field public static final int Theme_DeviceDefault_NoActionBar = 16974121; // 0x1030129
    field public static final int Theme_DeviceDefault_NoActionBar_Fullscreen = 16974122; // 0x103012a
    field public static final int Theme_DeviceDefault_NoActionBar_Overscan = 16974303; // 0x10301df
    field public static final int Theme_DeviceDefault_NoActionBar_TranslucentDecor = 16974307; // 0x10301e3
    field public static final int Theme_DeviceDefault_Panel = 16974138; // 0x103013a
    field public static final int Theme_DeviceDefault_Wallpaper = 16974140; // 0x103013c
    field public static final int Theme_DeviceDefault_Wallpaper_NoTitleBar = 16974141; // 0x103013d
@@ -1785,10 +1789,12 @@ package android {
    field public static final int Theme_Holo_Light_NoActionBar = 16974064; // 0x10300f0
    field public static final int Theme_Holo_Light_NoActionBar_Fullscreen = 16974065; // 0x10300f1
    field public static final int Theme_Holo_Light_NoActionBar_Overscan = 16974302; // 0x10301de
    field public static final int Theme_Holo_Light_NoActionBar_TranslucentDecor = 16974306; // 0x10301e2
    field public static final int Theme_Holo_Light_Panel = 16973948; // 0x103007c
    field public static final int Theme_Holo_NoActionBar = 16973932; // 0x103006c
    field public static final int Theme_Holo_NoActionBar_Fullscreen = 16973933; // 0x103006d
    field public static final int Theme_Holo_NoActionBar_Overscan = 16974301; // 0x10301dd
    field public static final int Theme_Holo_NoActionBar_TranslucentDecor = 16974305; // 0x10301e1
    field public static final int Theme_Holo_Panel = 16973947; // 0x103007b
    field public static final int Theme_Holo_Wallpaper = 16973949; // 0x103007d
    field public static final int Theme_Holo_Wallpaper_NoTitleBar = 16973950; // 0x103007e
@@ -28395,8 +28401,6 @@ package android.view {
    field public static final int SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION = 512; // 0x200
    field public static final int SYSTEM_UI_FLAG_LAYOUT_STABLE = 256; // 0x100
    field public static final int SYSTEM_UI_FLAG_LOW_PROFILE = 1; // 0x1
    field public static final int SYSTEM_UI_FLAG_TRANSPARENT_NAVIGATION = 8192; // 0x2000
    field public static final int SYSTEM_UI_FLAG_TRANSPARENT_STATUS = 4096; // 0x1000
    field public static final int SYSTEM_UI_FLAG_VISIBLE = 0; // 0x0
    field public static final int SYSTEM_UI_LAYOUT_FLAGS = 1536; // 0x600
    field public static final int TEXT_ALIGNMENT_CENTER = 4; // 0x4
@@ -29132,6 +29136,8 @@ package android.view {
    field public static final int FLAG_SHOW_WHEN_LOCKED = 524288; // 0x80000
    field public static final int FLAG_SPLIT_TOUCH = 8388608; // 0x800000
    field public static final int FLAG_TOUCHABLE_WHEN_WAKING = 64; // 0x40
    field public static final int FLAG_TRANSLUCENT_NAVIGATION = 134217728; // 0x8000000
    field public static final int FLAG_TRANSLUCENT_STATUS = 67108864; // 0x4000000
    field public static final int FLAG_TURN_SCREEN_ON = 2097152; // 0x200000
    field public static final int FLAG_WATCH_OUTSIDE_TOUCH = 262144; // 0x40000
    field public static final int FORMAT_CHANGED = 8; // 0x8
+22 −24
Original line number Diff line number Diff line
@@ -2447,24 +2447,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     */
    public static final int SYSTEM_UI_FLAG_IMMERSIVE = 0x00000800;
    /**
     * Flag for {@link #setSystemUiVisibility(int)}: View would like the status bar to have
     * transparency.
     *
     * <p>The transparency request may be denied if the bar is in another mode with a specific
     * style, like {@link #SYSTEM_UI_FLAG_IMMERSIVE immersive mode}.
     */
    public static final int SYSTEM_UI_FLAG_TRANSPARENT_STATUS = 0x00001000;
    /**
     * Flag for {@link #setSystemUiVisibility(int)}: View would like the navigation bar to have
     * transparency.
     *
     * <p>The transparency request may be denied if the bar is in another mode with a specific
     * style, like {@link #SYSTEM_UI_FLAG_IMMERSIVE immersive mode}.
     */
    public static final int SYSTEM_UI_FLAG_TRANSPARENT_NAVIGATION = 0x00002000;
    /**
     * @deprecated Use {@link #SYSTEM_UI_FLAG_LOW_PROFILE} instead.
     */
@@ -2624,6 +2606,26 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     */
    public static final int NAVIGATION_BAR_UNHIDE = 0x20000000;
    /**
     * @hide
     *
     * NOTE: This flag may only be used in subtreeSystemUiVisibility. It is masked
     * out of the public fields to keep the undefined bits out of the developer's way.
     *
     * Flag to specify that the status bar is displayed in translucent mode.
     */
    public static final int STATUS_BAR_TRANSLUCENT = 0x40000000;
    /**
     * @hide
     *
     * NOTE: This flag may only be used in subtreeSystemUiVisibility. It is masked
     * out of the public fields to keep the undefined bits out of the developer's way.
     *
     * Flag to specify that the navigation bar is displayed in translucent mode.
     */
    public static final int NAVIGATION_BAR_TRANSLUCENT = 0x80000000;
    /**
     * @hide
     */
@@ -16934,9 +16936,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * @param visibility  Bitwise-or of flags {@link #SYSTEM_UI_FLAG_LOW_PROFILE},
     * {@link #SYSTEM_UI_FLAG_HIDE_NAVIGATION}, {@link #SYSTEM_UI_FLAG_FULLSCREEN},
     * {@link #SYSTEM_UI_FLAG_LAYOUT_STABLE}, {@link #SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION},
     * {@link #SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN}, {@link #SYSTEM_UI_FLAG_IMMERSIVE},
     * {@link #SYSTEM_UI_FLAG_TRANSPARENT_STATUS},
     * and {@link #SYSTEM_UI_FLAG_TRANSPARENT_NAVIGATION}.
     * {@link #SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN}, and {@link #SYSTEM_UI_FLAG_IMMERSIVE}.
     */
    public void setSystemUiVisibility(int visibility) {
        if (visibility != mSystemUiVisibility) {
@@ -16952,9 +16952,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * @return  Bitwise-or of flags {@link #SYSTEM_UI_FLAG_LOW_PROFILE},
     * {@link #SYSTEM_UI_FLAG_HIDE_NAVIGATION}, {@link #SYSTEM_UI_FLAG_FULLSCREEN},
     * {@link #SYSTEM_UI_FLAG_LAYOUT_STABLE}, {@link #SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION},
     * {@link #SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN}, {@link #SYSTEM_UI_FLAG_IMMERSIVE},
     * {@link #SYSTEM_UI_FLAG_TRANSPARENT_STATUS},
     * and {@link #SYSTEM_UI_FLAG_TRANSPARENT_NAVIGATION}.
     * {@link #SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN}, and {@link #SYSTEM_UI_FLAG_IMMERSIVE}.
     */
    public int getSystemUiVisibility() {
        return mSystemUiVisibility;
+18 −0
Original line number Diff line number Diff line
@@ -754,6 +754,11 @@ public final class ViewRootImpl implements ViewParent,
            attrs.systemUiVisibility = mWindowAttributes.systemUiVisibility;
            attrs.subtreeSystemUiVisibility = mWindowAttributes.subtreeSystemUiVisibility;
            mWindowAttributesChangesFlag = mWindowAttributes.copyFrom(attrs);
            if ((mWindowAttributesChangesFlag
                    & WindowManager.LayoutParams.TRANSLUCENT_FLAGS_CHANGED) != 0) {
                // Recompute system ui visibility.
                mAttachInfo.mRecomputeGlobalAttributes = true;
            }
            if (mWindowAttributes.packageName == null) {
                mWindowAttributes.packageName = mBasePackageName;
            }
@@ -1026,6 +1031,7 @@ public final class ViewRootImpl implements ViewParent,
            mView.dispatchCollectViewAttributes(attachInfo, 0);
            attachInfo.mSystemUiVisibility &= ~attachInfo.mDisabledSystemUiVisibility;
            WindowManager.LayoutParams params = mWindowAttributes;
            attachInfo.mSystemUiVisibility |= getImpliedSystemUiVisibility(params);
            if (attachInfo.mKeepScreenOn != oldScreenOn
                    || attachInfo.mSystemUiVisibility != params.subtreeSystemUiVisibility
                    || attachInfo.mHasSystemUiListeners != params.hasSystemUiListeners) {
@@ -1039,6 +1045,18 @@ public final class ViewRootImpl implements ViewParent,
        return false;
    }

    private int getImpliedSystemUiVisibility(WindowManager.LayoutParams params) {
        int vis = 0;
        // Translucent decor window flags imply stable system ui visibility.
        if ((params.flags & WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS) != 0) {
            vis |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
        }
        if ((params.flags & WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION) != 0) {
            vis |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
        }
        return vis;
    }

    private boolean measureHierarchy(final View host, final WindowManager.LayoutParams lp,
            final Resources res, final int desiredWindowWidth, final int desiredWindowHeight) {
        int childWidthMeasureSpec;
+54 −1
Original line number Diff line number Diff line
@@ -838,6 +838,44 @@ public interface WindowManager extends ViewManager {
         */
        public static final int FLAG_LAYOUT_IN_OVERSCAN = 0x02000000;

        /**
         * Window flag: request a translucent status bar with minimal system-provided
         * background protection.
         *
         * <p>This flag can be controlled in your theme through the
         * {@link android.R.attr#windowTranslucentStatus} attribute; this attribute
         * is automatically set for you in the standard translucent decor themes
         * such as
         * {@link android.R.style#Theme_Holo_NoActionBar_TranslucentDecor},
         * {@link android.R.style#Theme_Holo_Light_NoActionBar_TranslucentDecor},
         * {@link android.R.style#Theme_DeviceDefault_NoActionBar_TranslucentDecor}, and
         * {@link android.R.style#Theme_DeviceDefault_Light_NoActionBar_TranslucentDecor}.</p>
         *
         * <p>When this flag is enabled for a window, it automatically sets
         * the system UI visibility flags {@link View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and
         * {@link View#SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN}.</p>
         */
        public static final int FLAG_TRANSLUCENT_STATUS = 0x04000000;

        /**
         * Window flag: request a translucent navigation bar with minimal system-provided
         * background protection.
         *
         * <p>This flag can be controlled in your theme through the
         * {@link android.R.attr#windowTranslucentNavigation} attribute; this attribute
         * is automatically set for you in the standard translucent decor themes
         * such as
         * {@link android.R.style#Theme_Holo_NoActionBar_TranslucentDecor},
         * {@link android.R.style#Theme_Holo_Light_NoActionBar_TranslucentDecor},
         * {@link android.R.style#Theme_DeviceDefault_NoActionBar_TranslucentDecor}, and
         * {@link android.R.style#Theme_DeviceDefault_Light_NoActionBar_TranslucentDecor}.</p>
         *
         * <p>When this flag is enabled for a window, it automatically sets
         * the system UI visibility flags {@link View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and
         * {@link View#SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION}.</p>
         */
        public static final int FLAG_TRANSLUCENT_NAVIGATION = 0x08000000;

        // ----- HIDDEN FLAGS.
        // These start at the high bit and go down.

@@ -956,7 +994,11 @@ public interface WindowManager extends ViewManager {
            @ViewDebug.FlagToString(mask = FLAG_HARDWARE_ACCELERATED, equals = FLAG_HARDWARE_ACCELERATED,
                    name = "FLAG_HARDWARE_ACCELERATED"),
            @ViewDebug.FlagToString(mask = FLAG_LOCAL_FOCUS_MODE, equals = FLAG_LOCAL_FOCUS_MODE,
                    name = "FLAG_LOCAL_FOCUS_MODE")
                    name = "FLAG_LOCAL_FOCUS_MODE"),
            @ViewDebug.FlagToString(mask = FLAG_TRANSLUCENT_STATUS, equals = FLAG_TRANSLUCENT_STATUS,
                    name = "FLAG_TRANSLUCENT_STATUS"),
            @ViewDebug.FlagToString(mask = FLAG_TRANSLUCENT_NAVIGATION, equals = FLAG_TRANSLUCENT_NAVIGATION,
                    name = "FLAG_TRANSLUCENT_NAVIGATION")
        })
        public int flags;

@@ -1046,6 +1088,11 @@ public interface WindowManager extends ViewManager {
         * {@hide} */
        public static final int PRIVATE_FLAG_SYSTEM_ERROR = 0x00000100;

        /** Window flag: maintain the previous transparent decor state when this window
         * becomes top-most.
         * {@hide} */
        public static final int PRIVATE_FLAG_INHERIT_TRANSLUCENT_DECOR = 0x00000200;

        /**
         * Control flags that are private to the platform.
         * @hide
@@ -1576,6 +1623,8 @@ public interface WindowManager extends ViewManager {
        /** {@hide} */
        public static final int USER_ACTIVITY_TIMEOUT_CHANGED = 1<<18;
        /** {@hide} */
        public static final int TRANSLUCENT_FLAGS_CHANGED = 1<<19;
        /** {@hide} */
        public static final int EVERYTHING_CHANGED = 0xffffffff;

        // internal buffer to backup/restore parameters under compatibility mode.
@@ -1621,6 +1670,10 @@ public interface WindowManager extends ViewManager {
                changes |= TYPE_CHANGED;
            }
            if (flags != o.flags) {
                final int diff = flags ^ o.flags;
                if ((diff & (FLAG_TRANSLUCENT_STATUS | FLAG_TRANSLUCENT_NAVIGATION)) != 0) {
                    changes |= TRANSLUCENT_FLAGS_CHANGED;
                }
                flags = o.flags;
                changes |= FLAGS_CHANGED;
            }
+10 −0
Original line number Diff line number Diff line
@@ -439,6 +439,14 @@
             or later. -->
        <attr name="windowCloseOnTouchOutside" format="boolean" />

        <!-- Flag indicating whether this window requests a translucent status bar.  Corresponds
             to {@link android.view.WindowManager.LayoutParams#FLAG_TRANSLUCENT_STATUS}. -->
        <attr name="windowTranslucentStatus" format="boolean" />

        <!-- Flag indicating whether this window requests a translucent navigation bar.  Corresponds
             to {@link android.view.WindowManager.LayoutParams#FLAG_TRANSLUCENT_NAVIGATION}. -->
        <attr name="windowTranslucentNavigation" format="boolean" />

        <!-- ============ -->
        <!-- Alert Dialog styles -->
        <!-- ============ -->
@@ -1594,6 +1602,8 @@
        <attr name="windowSplitActionBar" />
        <attr name="windowEnableSplitTouch" />
        <attr name="windowCloseOnTouchOutside" />
        <attr name="windowTranslucentStatus" />
        <attr name="windowTranslucentNavigation" />
        <!-- The minimum width the window is allowed to be, along the major
             axis of the screen.  That is, when in landscape.  Can be either
             an absolute dimension or a fraction of the screen size in that
Loading