diff options
| author | 2015-12-08 11:43:43 -0800 | |
|---|---|---|
| committer | 2015-12-15 09:01:45 -0800 | |
| commit | eb6722c0bc87dd5419df1eb92268b824c2d29b50 (patch) | |
| tree | ec65ccd344ed51132149c6379a860d4c24022e8f | |
| parent | db35f84f741d347947bcba8710e38e69a708e994 (diff) | |
Fixed bug with caption not showing for some apps that handle config changes
We currently decide when to show the decor caption onConfigurationChanged
However, if the app handles configuration changes or the threshold isn't
big enough for the configuration change to be reported to the app, we don't
display the caption in some cases when transitioning from fullscreen mode
to freeform mode.
We now also use the onMultiWindowModeChanged call to also determine if
the caption should be visible.
Change-Id: I237437f04ad90f904912ebac0253245f547b0e3e
| -rw-r--r-- | core/java/android/app/Activity.java | 4 | ||||
| -rw-r--r-- | core/java/android/view/Window.java | 6 | ||||
| -rw-r--r-- | core/java/com/android/internal/policy/DecorView.java | 32 | ||||
| -rw-r--r-- | core/java/com/android/internal/policy/PhoneWindow.java | 7 |
4 files changed, 39 insertions, 10 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 93c6bef5630e..ef84ab05c2b2 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -1733,9 +1733,13 @@ public class Activity extends ContextThemeWrapper * * @param multiWindowMode True if the activity is in multi-window mode. */ + @CallSuper public void onMultiWindowModeChanged(boolean multiWindowMode) { if (DEBUG_LIFECYCLE) Slog.v(TAG, "onMultiWindowModeChanged " + this + ": " + multiWindowMode); + if (mWindow != null) { + mWindow.onMultiWindowModeChanged(); + } } /** diff --git a/core/java/android/view/Window.java b/core/java/android/view/Window.java index 53490b4e15e3..d7a98abdb271 100644 --- a/core/java/android/view/Window.java +++ b/core/java/android/view/Window.java @@ -2106,4 +2106,10 @@ public abstract class Window { * to better match your application. */ public abstract void setResizingCaptionDrawable(Drawable drawable); + + /** + * Called when the activity changes from fullscreen mode to multi-window mode and visa-versa. + * @hide + */ + public abstract void onMultiWindowModeChanged(); } diff --git a/core/java/com/android/internal/policy/DecorView.java b/core/java/com/android/internal/policy/DecorView.java index e40556446a39..447c2139cbf7 100644 --- a/core/java/com/android/internal/policy/DecorView.java +++ b/core/java/com/android/internal/policy/DecorView.java @@ -67,6 +67,7 @@ import android.view.animation.Interpolator; import android.widget.FrameLayout; import android.widget.PopupWindow; +import static android.app.ActivityManager.StackId; import static android.app.ActivityManager.StackId.FULLSCREEN_WORKSPACE_STACK_ID; import static android.app.ActivityManager.StackId.INVALID_STACK_ID; import static android.view.View.MeasureSpec.AT_MOST; @@ -1188,7 +1189,7 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind invalidate(); int opacity = PixelFormat.OPAQUE; - if (ActivityManager.StackId.hasWindowShadow(mStackId)) { + if (StackId.hasWindowShadow(mStackId)) { // If the window has a shadow, it must be translucent. opacity = PixelFormat.TRANSLUCENT; } else{ @@ -1571,13 +1572,25 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind void onConfigurationChanged() { int workspaceId = getStackId(); - if (mDecorCaptionView != null) { - if (mStackId != workspaceId) { - mStackId = workspaceId; + if (mStackId != workspaceId) { + mStackId = workspaceId; + if (mDecorCaptionView == null && StackId.hasWindowDecor(mStackId)) { + // Configuration now requires a caption. + final LayoutInflater inflater = mWindow.getLayoutInflater(); + mDecorCaptionView = createDecorCaptionView(inflater); + if (mDecorCaptionView != null) { + if (mDecorCaptionView.getParent() == null) { + addView(mDecorCaptionView, 0, + new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT)); + } + removeView(mContentRoot); + mDecorCaptionView.addView(mContentRoot, + new ViewGroup.MarginLayoutParams(MATCH_PARENT, MATCH_PARENT)); + } + } else if (mDecorCaptionView != null) { // We might have to change the kind of surface before we do anything else. - mDecorCaptionView.onConfigurationChanged( - ActivityManager.StackId.hasWindowDecor(mStackId)); - enableCaption(ActivityManager.StackId.hasWindowDecor(workspaceId)); + mDecorCaptionView.onConfigurationChanged(StackId.hasWindowDecor(mStackId)); + enableCaption(StackId.hasWindowDecor(workspaceId)); } } initializeElevation(); @@ -1630,8 +1643,7 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind final boolean isApplication = attrs.type == TYPE_BASE_APPLICATION || attrs.type == TYPE_APPLICATION; // Only a non floating application window on one of the allowed workspaces can get a caption - if (!mWindow.isFloating() && isApplication - && ActivityManager.StackId.hasWindowDecor(mStackId)) { + if (!mWindow.isFloating() && isApplication && StackId.hasWindowDecor(mStackId)) { // Dependent on the brightness of the used title we either use the // dark or the light button frame. if (decorCaptionView == null) { @@ -1854,7 +1866,7 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind final boolean wasAdjustedForStack = mElevationAdjustedForStack; // Do not use a shadow when we are in resizing mode (mBackdropFrameRenderer not null) // since the shadow is bound to the content size and not the target size. - if (ActivityManager.StackId.hasWindowShadow(mStackId) && !isResizing()) { + if (StackId.hasWindowShadow(mStackId) && !isResizing()) { elevation = hasWindowFocus() ? DECOR_SHADOW_FOCUSED_HEIGHT_IN_DIP : DECOR_SHADOW_UNFOCUSED_HEIGHT_IN_DIP; // TODO(skuhne): Remove this if clause once b/22668382 got fixed. diff --git a/core/java/com/android/internal/policy/PhoneWindow.java b/core/java/com/android/internal/policy/PhoneWindow.java index 86bd7824fc4d..8853527eda89 100644 --- a/core/java/com/android/internal/policy/PhoneWindow.java +++ b/core/java/com/android/internal/policy/PhoneWindow.java @@ -662,6 +662,13 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { } } + @Override + public void onMultiWindowModeChanged() { + if (mDecor != null) { + mDecor.onConfigurationChanged(); + } + } + private static void clearMenuViews(PanelFeatureState st) { // This can be called on config changes, so we should make sure // the views will be reconstructed based on the new orientation, etc. |