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

Commit 5bcd3189 authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Updated support for drawing background drawable when resizing

f3a62fbc added support for drawing
the background draweable when resizing an activity window.
However, after some additional discussion we decided that
R.styleable.Window_windowResizingBackground and
R.integer.config_windowResizingBackgroundColorARGB are not needed.
We use R.styleable.Window_windowBackground for the background
drawable and fallback to using R.styleable.Window_windowBackgroundFallback
which is now public if the first isn't set.

Bug: 24534744
Change-Id: Ia0507e25a1893ea941d259f1d4e88ce500dda154
parent ebb173e3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1395,6 +1395,7 @@ package android {
    field public static final int windowAllowReturnTransitionOverlap = 16843835; // 0x101043b
    field public static final int windowAnimationStyle = 16842926; // 0x10100ae
    field public static final int windowBackground = 16842836; // 0x1010054
    field public static final int windowBackgroundFallback = 16844035; // 0x1010503
    field public static final int windowClipToOutline = 16843947; // 0x10104ab
    field public static final int windowCloseOnTouchOutside = 16843611; // 0x101035b
    field public static final int windowContentOverlay = 16842841; // 0x1010059
@@ -1420,7 +1421,6 @@ 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
+1 −1
Original line number Diff line number Diff line
@@ -1491,6 +1491,7 @@ package android {
    field public static final int windowAllowReturnTransitionOverlap = 16843835; // 0x101043b
    field public static final int windowAnimationStyle = 16842926; // 0x10100ae
    field public static final int windowBackground = 16842836; // 0x1010054
    field public static final int windowBackgroundFallback = 16844035; // 0x1010503
    field public static final int windowClipToOutline = 16843947; // 0x10104ab
    field public static final int windowCloseOnTouchOutside = 16843611; // 0x101035b
    field public static final int windowContentOverlay = 16842841; // 0x1010059
@@ -1516,7 +1517,6 @@ 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
+0 −11
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
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;
@@ -31,7 +30,6 @@ import android.view.WindowManagerImpl;
class DecorContext extends ContextThemeWrapper {
    private PhoneWindow mPhoneWindow;
    private WindowManager mWindowManager;
    private TypedArray mWindowStyle;

    public DecorContext(Context context) {
        super(context, null);
@@ -54,13 +52,4 @@ 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;
        }
    }
}
+4 −18
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@ import android.animation.Animator;
import android.animation.ObjectAnimator;
import android.app.ActivityManagerNative;
import android.app.SearchManager;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.os.UserHandle;

@@ -5438,20 +5437,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
     * */
    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) {
@@ -5459,8 +5445,6 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
            }
        }

        // 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) {
@@ -5468,7 +5452,9 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
            }
        }

        return new ColorDrawable(context.getResources().getInteger(
                com.android.internal.R.integer.config_windowResizingBackgroundColorARGB));
        // We shouldn't really get here as the background fallback should be always available since
        // it is defaulted by the system.
        Log.w(TAG, "Failed to find background drawable for PhoneWindow=" + this);
        return null;
    }
}
+3 −8
Original line number Diff line number Diff line
@@ -323,14 +323,10 @@
        <attr name="windowBackground" format="reference" />
        <!-- Drawable to draw selectively within the inset areas when the windowBackground
             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. -->
             surface when the app has not drawn any content into this area. One example is
             when the user is resizing a window of an activity that has
             {@link android.R.attr#resizeableActivity} set for multi-window mode. -->
        <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. -->
@@ -1850,7 +1846,6 @@ i
    <declare-styleable name="Window">
        <attr name="windowBackground" />
        <attr name="windowBackgroundFallback" />
        <attr name="windowResizingBackground" />
        <attr name="windowContentOverlay" />
        <attr name="windowFrame" />
        <attr name="windowNoTitle" />
Loading