Merge "Added support for resizing background color for an app window"
This commit is contained in:
committed by
Android (Google) Code Review
commit
645e8a9ae8
@@ -1420,6 +1420,7 @@ package android {
|
||||
field public static final int windowNoTitle = 16842838; // 0x1010056
|
||||
field public static final int windowOverscan = 16843727; // 0x10103cf
|
||||
field public static final int windowReenterTransition = 16843951; // 0x10104af
|
||||
field public static final int windowResizingBackground = 16844035; // 0x1010503
|
||||
field public static final int windowReturnTransition = 16843950; // 0x10104ae
|
||||
field public static final int windowSharedElementEnterTransition = 16843833; // 0x1010439
|
||||
field public static final int windowSharedElementExitTransition = 16843834; // 0x101043a
|
||||
|
||||
@@ -1516,6 +1516,7 @@ package android {
|
||||
field public static final int windowNoTitle = 16842838; // 0x1010056
|
||||
field public static final int windowOverscan = 16843727; // 0x10103cf
|
||||
field public static final int windowReenterTransition = 16843951; // 0x10104af
|
||||
field public static final int windowResizingBackground = 16844035; // 0x1010503
|
||||
field public static final int windowReturnTransition = 16843950; // 0x10104ae
|
||||
field public static final int windowSharedElementEnterTransition = 16843833; // 0x1010439
|
||||
field public static final int windowSharedElementExitTransition = 16843834; // 0x101043a
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.android.internal.policy;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.WindowManager;
|
||||
import android.view.WindowManagerImpl;
|
||||
@@ -30,6 +31,7 @@ import android.view.WindowManagerImpl;
|
||||
class DecorContext extends ContextThemeWrapper {
|
||||
private PhoneWindow mPhoneWindow;
|
||||
private WindowManager mWindowManager;
|
||||
private TypedArray mWindowStyle;
|
||||
|
||||
public DecorContext(Context context) {
|
||||
super(context, null);
|
||||
@@ -52,4 +54,13 @@ class DecorContext extends ContextThemeWrapper {
|
||||
}
|
||||
return super.getSystemService(name);
|
||||
}
|
||||
|
||||
public TypedArray getWindowStyle() {
|
||||
synchronized (this) {
|
||||
if (mWindowStyle == null) {
|
||||
mWindowStyle = obtainStyledAttributes(com.android.internal.R.styleable.Window);
|
||||
}
|
||||
return mWindowStyle;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.android.internal.policy;
|
||||
import static android.app.ActivityManager.FIRST_DYNAMIC_STACK_ID;
|
||||
import static android.app.ActivityManager.FREEFORM_WORKSPACE_STACK_ID;
|
||||
import static android.app.ActivityManager.FULLSCREEN_WORKSPACE_STACK_ID;
|
||||
import static android.app.ActivityManager.HOME_STACK_ID;
|
||||
import static android.app.ActivityManager.INVALID_STACK_ID;
|
||||
import static android.view.View.MeasureSpec.AT_MOST;
|
||||
import static android.view.View.MeasureSpec.EXACTLY;
|
||||
@@ -32,8 +31,7 @@ import android.animation.Animator;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.app.ActivityManagerNative;
|
||||
import android.app.SearchManager;
|
||||
import android.content.ContextWrapper;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Build;
|
||||
import android.os.UserHandle;
|
||||
|
||||
@@ -4228,7 +4226,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
|
||||
}
|
||||
}
|
||||
nonClientDecorView.setPhoneWindow(this, hasNonClientDecor(mWorkspaceId),
|
||||
nonClientDecorHasShadow(mWorkspaceId));
|
||||
nonClientDecorHasShadow(mWorkspaceId), getResizingBackgroundDrawable(),
|
||||
mDecor.getContext().getDrawable(R.drawable.non_client_decor_title_focused));
|
||||
}
|
||||
// Tell the decor if it has a visible non client decor.
|
||||
mDecor.enableNonClientDecor(nonClientDecorView != null && hasNonClientDecor(mWorkspaceId));
|
||||
@@ -5409,7 +5408,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
|
||||
* @param workspaceId The Id of the workspace which contains this window.
|
||||
* @Return Returns true if the window should show a non client decor.
|
||||
**/
|
||||
private boolean hasNonClientDecor(int workspaceId) {
|
||||
private static boolean hasNonClientDecor(int workspaceId) {
|
||||
return workspaceId == FREEFORM_WORKSPACE_STACK_ID;
|
||||
}
|
||||
|
||||
@@ -5432,4 +5431,44 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the color used to fill areas the app has not rendered content to yet when the user
|
||||
* is resizing the window of an activity in multi-window mode.
|
||||
* */
|
||||
private Drawable getResizingBackgroundDrawable() {
|
||||
final Context context = mDecor.getContext();
|
||||
final TypedArray windowStyle;
|
||||
if (context instanceof DecorContext) {
|
||||
windowStyle = ((DecorContext) context).getWindowStyle();
|
||||
} else {
|
||||
windowStyle = getWindowStyle();
|
||||
}
|
||||
final int resourceId =
|
||||
windowStyle.getResourceId(R.styleable.Window_windowResizingBackground, 0);
|
||||
if (resourceId != 0) {
|
||||
return context.getDrawable(resourceId);
|
||||
}
|
||||
|
||||
// The app didn't set a resizing background color. In this case we try to use the app's
|
||||
// background drawable for the resizing background.
|
||||
if (mBackgroundResource != 0) {
|
||||
final Drawable drawable = context.getDrawable(mBackgroundResource);
|
||||
if (drawable != null) {
|
||||
return drawable;
|
||||
}
|
||||
}
|
||||
|
||||
// The app background drawable isn't currently set. This might be because the app cleared
|
||||
// it. In this case we try to use the app's background fallback drawable.
|
||||
if (mBackgroundFallbackResource != 0) {
|
||||
final Drawable fallbackDrawable = context.getDrawable(mBackgroundFallbackResource);
|
||||
if (fallbackDrawable != null) {
|
||||
return fallbackDrawable;
|
||||
}
|
||||
}
|
||||
|
||||
return new ColorDrawable(context.getResources().getInteger(
|
||||
com.android.internal.R.integer.config_windowResizingBackgroundColorARGB));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.android.internal.widget;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Looper;
|
||||
import android.os.RemoteException;
|
||||
import android.util.AttributeSet;
|
||||
@@ -52,7 +53,7 @@ import com.android.internal.policy.PhoneWindow;
|
||||
* <li>The resize handles which allow to resize the window.</li>
|
||||
* </ul>
|
||||
* After creating the view, the function
|
||||
* {@link #setPhoneWindow(PhoneWindow owner, boolean windowHasShadow)} needs to be called to make
|
||||
* {@link #setPhoneWindow} needs to be called to make
|
||||
* the connection to it's owning PhoneWindow.
|
||||
* Note: At this time the application can change various attributes of the DecorView which
|
||||
* will break things (in settle/unexpected ways):
|
||||
@@ -97,6 +98,9 @@ public class NonClientDecorView extends LinearLayout
|
||||
// The resize frame renderer.
|
||||
private ResizeFrameThread mFrameRendererThread = null;
|
||||
|
||||
private Drawable mResizingBackgroundDrawable;
|
||||
private Drawable mCaptionBackgroundDrawable;
|
||||
|
||||
public NonClientDecorView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
@@ -133,10 +137,13 @@ public class NonClientDecorView extends LinearLayout
|
||||
}
|
||||
}
|
||||
|
||||
public void setPhoneWindow(PhoneWindow owner, boolean showDecor, boolean windowHasShadow) {
|
||||
public void setPhoneWindow(PhoneWindow owner, boolean showDecor, boolean windowHasShadow,
|
||||
Drawable resizingBackgroundDrawable, Drawable captionBackgroundDrawableDrawable) {
|
||||
mOwner = owner;
|
||||
mWindowHasShadow = windowHasShadow;
|
||||
mShowDecor = showDecor;
|
||||
mResizingBackgroundDrawable = resizingBackgroundDrawable;
|
||||
mCaptionBackgroundDrawable = captionBackgroundDrawableDrawable;
|
||||
updateCaptionVisibility();
|
||||
if (mWindowHasShadow) {
|
||||
initializeElevation();
|
||||
@@ -624,7 +631,8 @@ public class NonClientDecorView extends LinearLayout
|
||||
// barely show while the entire screen is moving.
|
||||
mFrameNode.setLeftTopRightBottom(left, top, left + width, top + mLastCaptionHeight);
|
||||
DisplayListCanvas canvas = mFrameNode.start(width, height);
|
||||
canvas.drawColor(Color.BLACK);
|
||||
mCaptionBackgroundDrawable.setBounds(0, 0, left + width, top + mLastCaptionHeight);
|
||||
mCaptionBackgroundDrawable.draw(canvas);
|
||||
mFrameNode.end(canvas);
|
||||
|
||||
mBackdropNode.setLeftTopRightBottom(left, top + mLastCaptionHeight, left + width,
|
||||
@@ -632,9 +640,8 @@ public class NonClientDecorView extends LinearLayout
|
||||
|
||||
// The backdrop: clear everything with the background. Clipping is done elsewhere.
|
||||
canvas = mBackdropNode.start(width, height - mLastCaptionHeight);
|
||||
// TODO(skuhne): mOwner.getDecorView().mBackgroundFallback.draw(..) - or similar.
|
||||
// Note: This might not work (calculator for example uses a transparent background).
|
||||
canvas.drawColor(0xff808080);
|
||||
mResizingBackgroundDrawable.setBounds(0, 0, left + width, top + height);
|
||||
mResizingBackgroundDrawable.draw(canvas);
|
||||
mBackdropNode.end(canvas);
|
||||
|
||||
// We need to render both rendered nodes explicitly.
|
||||
|
||||
@@ -325,6 +325,12 @@
|
||||
has been set to null. This protects against seeing visual garbage in the
|
||||
surface when the app has not drawn any content into this area. -->
|
||||
<attr name="windowBackgroundFallback" format="reference" />
|
||||
<!-- Drawable used to fill in areas the app has not rendered content to yet when the user is
|
||||
resizing the window of an activity that has {@link android.R.attr#resizeableActivity}
|
||||
set for multi-window mode. If unset, the system will try to use windowBackground if
|
||||
set, then windowBackgroundFallback if set. Otherwise, the system default resizing
|
||||
background color -->
|
||||
<attr name="windowResizingBackground" format="reference" />
|
||||
<!-- Drawable to use as a frame around the window. -->
|
||||
<attr name="windowFrame" format="reference" />
|
||||
<!-- Flag indicating whether there should be no title on this window. -->
|
||||
@@ -1841,6 +1847,7 @@ i
|
||||
<declare-styleable name="Window">
|
||||
<attr name="windowBackground" />
|
||||
<attr name="windowBackgroundFallback" />
|
||||
<attr name="windowResizingBackground" />
|
||||
<attr name="windowContentOverlay" />
|
||||
<attr name="windowFrame" />
|
||||
<attr name="windowNoTitle" />
|
||||
|
||||
@@ -2349,6 +2349,9 @@
|
||||
is non-interactive. -->
|
||||
<bool name="config_cameraDoubleTapPowerGestureEnabled">true</bool>
|
||||
|
||||
<!-- Default background color to use when resizing a window if the app didn't specify one. -->
|
||||
<integer name="config_windowResizingBackgroundColorARGB">0xFF808080</integer>
|
||||
|
||||
<!-- Name of the component to handle network policy notifications. If present,
|
||||
disables NetworkPolicyManagerService's presentation of data-usage notifications. -->
|
||||
<string translatable="false" name="config_networkPolicyNotificationComponent"></string>
|
||||
|
||||
@@ -2677,6 +2677,7 @@
|
||||
<public type="attr" name="level" />
|
||||
<public type="attr" name="contextPopupMenuStyle" />
|
||||
<public type="attr" name="textAppearancePopupMenuHeader" />
|
||||
<public type="attr" name="windowResizingBackground" />
|
||||
|
||||
<public type="style" name="Theme.Material.DayNight" />
|
||||
<public type="style" name="Theme.Material.DayNight.DarkActionBar" />
|
||||
|
||||
@@ -1956,6 +1956,7 @@
|
||||
<java-symbol type="id" name="close_window" />
|
||||
<java-symbol type="layout" name="non_client_decor_light" />
|
||||
<java-symbol type="layout" name="non_client_decor_dark" />
|
||||
<java-symbol type="drawable" name="non_client_decor_title_focused" />
|
||||
|
||||
<!-- From TelephonyProvider -->
|
||||
<java-symbol type="xml" name="apns" />
|
||||
@@ -2330,4 +2331,6 @@
|
||||
<java-symbol type="drawable" name="platlogo_m" />
|
||||
|
||||
<java-symbol type="string" name="config_iccHotswapPromptForRestartDialogComponent" />
|
||||
|
||||
<java-symbol type="integer" name="config_windowResizingBackgroundColorARGB" />
|
||||
</resources>
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
<style name="RecentsTheme.Wallpaper">
|
||||
<!-- Wallpaper -->
|
||||
<item name="android:windowBackground">@color/transparent</item>
|
||||
<item name="android:windowResizingBackground">@color/transparent</item>
|
||||
<item name="android:colorBackgroundCacheHint">@null</item>
|
||||
<item name="android:windowShowWallpaper">true</item>
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user