diff options
| author | John Spurlock <jspurlock@google.com> | 2013-10-06 19:16:13 -0700 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2013-10-06 19:16:13 -0700 |
| commit | b88ede00ac12fb359b490a5167cd595ebde7e805 (patch) | |
| tree | b768ec8e1a3e1f13d04d2b2e90462f1d07b1188e /core/java/android | |
| parent | 719e486f54b668d13680552f96558ee30d220a00 (diff) | |
| parent | d5102f19653f6b00ce872435c5efb5cb630deed7 (diff) | |
am d5102f19: Merge "Transparent system ui flags -> Translucent WM flags." into klp-dev
* commit 'd5102f19653f6b00ce872435c5efb5cb630deed7':
Transparent system ui flags -> Translucent WM flags.
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/view/View.java | 46 | ||||
| -rw-r--r-- | core/java/android/view/ViewRootImpl.java | 18 | ||||
| -rw-r--r-- | core/java/android/view/WindowManager.java | 55 |
3 files changed, 94 insertions, 25 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index f763d19b2bc6..caeb1d8cfc80 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -2448,24 +2448,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. */ public static final int STATUS_BAR_HIDDEN = SYSTEM_UI_FLAG_LOW_PROFILE; @@ -2626,6 +2608,26 @@ public class View implements Drawable.Callback, KeyEvent.Callback, /** * @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 */ public static final int PUBLIC_STATUS_BAR_VISIBILITY_MASK = 0x0000FFFF; @@ -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; diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 7e3ee5f64057..beb7366ec965 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -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; diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java index 815b97c60657..ea3c9311c4df 100644 --- a/core/java/android/view/WindowManager.java +++ b/core/java/android/view/WindowManager.java @@ -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; } |
