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

Commit 5435a30a authored by Alan Viverette's avatar Alan Viverette
Browse files

Add transition support to PopupWindow

Allows framework-added windows to manually specify surface insets, which
enables us to wrap the popup window's elevated content view with a root
view, which in turn allows us to use the Transition API for popup window
transitions.

Fixes a bug where the root view's render node forced clipping.

Bug: 13211166
Change-Id: I303dfa55a052cdf5d3b1485422529123e3cc867a
parent 783f2869
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -38390,6 +38390,8 @@ package android.widget {
    method public void setClippingEnabled(boolean);
    method public void setContentView(android.view.View);
    method public void setElevation(float);
    method public void setEnterTransition(android.transition.Transition);
    method public void setExitTransition(android.transition.Transition);
    method public void setFocusable(boolean);
    method public void setHeight(int);
    method public void setIgnoreCheekPress();
+2 −0
Original line number Diff line number Diff line
@@ -40885,6 +40885,8 @@ package android.widget {
    method public void setClippingEnabled(boolean);
    method public void setContentView(android.view.View);
    method public void setElevation(float);
    method public void setEnterTransition(android.transition.Transition);
    method public void setExitTransition(android.transition.Transition);
    method public void setFocusable(boolean);
    method public void setHeight(int);
    method public void setIgnoreCheekPress();
+3 −4
Original line number Diff line number Diff line
@@ -14889,10 +14889,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    void setDisplayListProperties(RenderNode renderNode) {
        if (renderNode != null) {
            renderNode.setHasOverlappingRendering(hasOverlappingRendering());
            if (mParent instanceof ViewGroup) {
                renderNode.setClipToBounds(
                        (((ViewGroup) mParent).mGroupFlags & ViewGroup.FLAG_CLIP_CHILDREN) != 0);
            }
            renderNode.setClipToBounds(mParent instanceof ViewGroup
                    && ((ViewGroup) mParent).getClipChildren());
            float alpha = 1;
            if (mParent instanceof ViewGroup && (((ViewGroup) mParent).mGroupFlags &
                    ViewGroup.FLAG_SUPPORT_STATIC_TRANSFORMATIONS) != 0) {
+6 −2
Original line number Diff line number Diff line
@@ -472,8 +472,10 @@ 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.
                if (!attrs.hasManualSurfaceInsets) {
                    final int surfaceInset = (int) Math.ceil(view.getZ() * 2);
                    attrs.surfaceInsets.set(surfaceInset, surfaceInset, surfaceInset, surfaceInset);
                }

                CompatibilityInfo compatibilityInfo = mDisplayAdjustments.getCompatibilityInfo();
                mTranslator = compatibilityInfo.getTranslator();
@@ -760,6 +762,7 @@ public final class ViewRootImpl implements ViewParent,
            final int oldInsetRight = mWindowAttributes.surfaceInsets.right;
            final int oldInsetBottom = mWindowAttributes.surfaceInsets.bottom;
            final int oldSoftInputMode = mWindowAttributes.softInputMode;
            final boolean oldHasManualSurfaceInsets = mWindowAttributes.hasManualSurfaceInsets;

            // Keep track of the actual window flags supplied by the client.
            mClientWindowLayoutFlags = attrs.flags;
@@ -786,6 +789,7 @@ public final class ViewRootImpl implements ViewParent,
            // Restore old surface insets.
            mWindowAttributes.surfaceInsets.set(
                    oldInsetLeft, oldInsetTop, oldInsetRight, oldInsetBottom);
            mWindowAttributes.hasManualSurfaceInsets = oldHasManualSurfaceInsets;

            applyKeepScreenOnFlag(mWindowAttributes);

+21 −1
Original line number Diff line number Diff line
@@ -1333,6 +1333,16 @@ public interface WindowManager extends ViewManager {
         */
        public final Rect surfaceInsets = new Rect();

        /**
         * Whether the surface insets have been manually set. When set to
         * {@code false}, the view root will automatically determine the
         * appropriate surface insets.
         *
         * @see #surfaceInsets
         * @hide
         */
        public boolean hasManualSurfaceInsets;
    
        /**
         * The desired bitmap format.  May be one of the constants in
         * {@link android.graphics.PixelFormat}.  Default is OPAQUE.
@@ -1628,6 +1638,7 @@ public interface WindowManager extends ViewManager {
            out.writeInt(surfaceInsets.top);
            out.writeInt(surfaceInsets.right);
            out.writeInt(surfaceInsets.bottom);
            out.writeInt(hasManualSurfaceInsets ? 1 : 0);
            out.writeInt(needsMenuKey);
        }

@@ -1676,6 +1687,7 @@ public interface WindowManager extends ViewManager {
            surfaceInsets.top = in.readInt();
            surfaceInsets.right = in.readInt();
            surfaceInsets.bottom = in.readInt();
            hasManualSurfaceInsets = in.readInt() != 0;
            needsMenuKey = in.readInt();
        }

@@ -1858,6 +1870,11 @@ public interface WindowManager extends ViewManager {
                changes |= SURFACE_INSETS_CHANGED;
            }

            if (hasManualSurfaceInsets != o.hasManualSurfaceInsets) {
                hasManualSurfaceInsets = o.hasManualSurfaceInsets;
                changes |= SURFACE_INSETS_CHANGED;
            }

            if (needsMenuKey != o.needsMenuKey) {
                needsMenuKey = o.needsMenuKey;
                changes |= NEEDS_MENU_KEY_CHANGED;
@@ -1966,8 +1983,11 @@ public interface WindowManager extends ViewManager {
            if (userActivityTimeout >= 0) {
                sb.append(" userActivityTimeout=").append(userActivityTimeout);
            }
            if (!surfaceInsets.equals(Insets.NONE)) {
            if (!surfaceInsets.equals(Insets.NONE) || hasManualSurfaceInsets) {
                sb.append(" surfaceInsets=").append(surfaceInsets);
                if (hasManualSurfaceInsets) {
                    sb.append(" (manual)");
                }
            }
            if (needsMenuKey != NEEDS_MENU_UNSET) {
                sb.append(" needsMenuKey=");
Loading