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

Commit 49a22e82 authored by Alan Viverette's avatar Alan Viverette
Browse files

Add window elevation for dialogs, clean up surface insets API

BUG: 13211941
Change-Id: I9d605d0b2fb24f9bf8e73fbecd520b6b52ae5751
parent 28c49c9d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1368,6 +1368,7 @@ package android {
    field public static final int windowContentTransitions = 16843794; // 0x1010412
    field public static final int windowDisablePreview = 16843298; // 0x1010222
    field public static final int windowDrawsSystemBarBackgrounds = 16843858; // 0x1010452
    field public static final int windowElevation = 16843922; // 0x1010492
    field public static final int windowEnableSplitTouch = 16843543; // 0x1010317
    field public static final int windowEnterAnimation = 16842932; // 0x10100b4
    field public static final int windowEnterTransition = 16843833; // 0x1010439
+9 −4
Original line number Diff line number Diff line
@@ -461,6 +461,11 @@ public final class ViewRootImpl implements ViewParent,
                    }
                }

                // Compute surface insets required to draw at specified Z value.
                // TODO: Use real shadow insets for a constant max Z.
                final int surfaceInset = (int) Math.ceil(view.getZ() * 2);
                attrs.surfaceInsets.set(surfaceInset, surfaceInset, surfaceInset, surfaceInset);

                CompatibilityInfo compatibilityInfo = mDisplayAdjustments.getCompatibilityInfo();
                mTranslator = compatibilityInfo.getTranslator();
                mDisplayAdjustments.setActivityToken(attrs.token);
@@ -1713,8 +1718,8 @@ public final class ViewRootImpl implements ViewParent,
                if (hwInitialized ||
                        mWidth != mAttachInfo.mHardwareRenderer.getWidth() ||
                        mHeight != mAttachInfo.mHardwareRenderer.getHeight()) {
                    final Rect shadowInsets = params != null ? params.shadowInsets : null;
                    mAttachInfo.mHardwareRenderer.setup(mWidth, mHeight, shadowInsets);
                    final Rect surfaceInsets = params != null ? params.surfaceInsets : null;
                    mAttachInfo.mHardwareRenderer.setup(mWidth, mHeight, surfaceInsets);
                    if (!hwInitialized) {
                        mAttachInfo.mHardwareRenderer.invalidate(mSurface);
                        mFullRedrawNeeded = true;
@@ -2371,7 +2376,7 @@ public final class ViewRootImpl implements ViewParent,
        }

        final WindowManager.LayoutParams params = mWindowAttributes;
        final Rect surfaceInsets = params != null ? params.shadowInsets : null;
        final Rect surfaceInsets = params != null ? params.surfaceInsets : null;
        boolean animating = mScroller != null && mScroller.computeScrollOffset();
        final int curScrollY;
        if (animating) {
@@ -3155,7 +3160,7 @@ public final class ViewRootImpl implements ViewParent,
                            mFullRedrawNeeded = true;
                            try {
                                final WindowManager.LayoutParams lp = mWindowAttributes;
                                final Rect surfaceInsets = lp != null ? lp.shadowInsets : null;
                                final Rect surfaceInsets = lp != null ? lp.surfaceInsets : null;
                                mAttachInfo.mHardwareRenderer.initializeIfNeeded(
                                        mWidth, mHeight, mSurface, surfaceInsets);
                            } catch (OutOfResourcesException e) {
+15 −12
Original line number Diff line number Diff line
@@ -1298,7 +1298,7 @@ public interface WindowManager extends ViewManager {
         *
         * @hide
         */
        public Rect shadowInsets = new Rect();
        public Rect surfaceInsets = new Rect();
    
        /**
         * The desired bitmap format.  May be one of the constants in
@@ -1580,10 +1580,10 @@ public interface WindowManager extends ViewManager {
            out.writeInt(hasSystemUiListeners ? 1 : 0);
            out.writeInt(inputFeatures);
            out.writeLong(userActivityTimeout);
            out.writeInt(shadowInsets.left);
            out.writeInt(shadowInsets.top);
            out.writeInt(shadowInsets.right);
            out.writeInt(shadowInsets.bottom);
            out.writeInt(surfaceInsets.left);
            out.writeInt(surfaceInsets.top);
            out.writeInt(surfaceInsets.right);
            out.writeInt(surfaceInsets.bottom);
        }
        
        public static final Parcelable.Creator<LayoutParams> CREATOR
@@ -1626,7 +1626,10 @@ public interface WindowManager extends ViewManager {
            hasSystemUiListeners = in.readInt() != 0;
            inputFeatures = in.readInt();
            userActivityTimeout = in.readLong();
            shadowInsets.set(in.readInt(), in.readInt(), in.readInt(), in.readInt());
            surfaceInsets.left = in.readInt();
            surfaceInsets.top = in.readInt();
            surfaceInsets.right = in.readInt();
            surfaceInsets.bottom = in.readInt();
        }
    
        @SuppressWarnings({"PointlessBitwiseExpression"})
@@ -1658,7 +1661,7 @@ public interface WindowManager extends ViewManager {
        /** {@hide} */
        public static final int TRANSLUCENT_FLAGS_CHANGED = 1<<19;
        /** {@hide} */
        public static final int SHADOW_INSETS_CHANGED = 1<<20;
        public static final int SURFACE_INSETS_CHANGED = 1<<20;
        /** {@hide} */
        public static final int EVERYTHING_CHANGED = 0xffffffff;

@@ -1794,9 +1797,9 @@ public interface WindowManager extends ViewManager {
                changes |= USER_ACTIVITY_TIMEOUT_CHANGED;
            }

            if (!shadowInsets.equals(o.shadowInsets)) {
                shadowInsets.set(o.shadowInsets);
                changes |= SHADOW_INSETS_CHANGED;
            if (!surfaceInsets.equals(o.surfaceInsets)) {
                surfaceInsets.set(o.surfaceInsets);
                changes |= SURFACE_INSETS_CHANGED;
            }

            return changes;
@@ -1898,8 +1901,8 @@ public interface WindowManager extends ViewManager {
            if (userActivityTimeout >= 0) {
                sb.append(" userActivityTimeout=").append(userActivityTimeout);
            }
            if (!shadowInsets.equals(Insets.NONE)) {
                sb.append(" shadowInsets=").append(shadowInsets);
            if (!surfaceInsets.equals(Insets.NONE)) {
                sb.append(" surfaceInsets=").append(surfaceInsets);
            }
            sb.append('}');
            return sb.toString();
+0 −4
Original line number Diff line number Diff line
@@ -1096,10 +1096,6 @@ public class PopupWindow {
        p.softInputMode = mSoftInputMode;
        p.setTitle("PopupWindow:" + Integer.toHexString(hashCode()));

        // TODO: Use real shadow insets once that algorithm is finalized.
        final int shadowInset = (int) Math.ceil(mElevation * 2);
        p.shadowInsets.set(shadowInset, shadowInset, shadowInset, shadowInset);

        return p;
    }

+1 −7
Original line number Diff line number Diff line
@@ -20,13 +20,7 @@
    android:id="@+id/parentPanel"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:background="@drawable/dialog_background_material"
    android:translationZ="@dimen/floating_window_z"
    android:layout_marginLeft="@dimen/floating_window_margin_left"
    android:layout_marginTop="@dimen/floating_window_margin_top"
    android:layout_marginRight="@dimen/floating_window_margin_right"
    android:layout_marginBottom="@dimen/floating_window_margin_bottom">
    android:orientation="vertical">

    <LinearLayout android:id="@+id/topPanel"
        android:layout_width="match_parent"
Loading