diff options
| author | 2014-08-18 16:50:50 -0700 | |
|---|---|---|
| committer | 2014-08-21 14:30:51 -0700 | |
| commit | b89d5cc2c64112a0ff7e66e4dd3bb2114caed935 (patch) | |
| tree | d64461d22263456e851d6e740fab7434c80fe44d | |
| parent | 94f6878bbd98753aa60fd80f5a73b5f198579b04 (diff) | |
Allow Activities to opt into using Overlay for shared elements.
Bug 17001227
Change-Id: Icc49a81357ee69abd2a15a1d1efcead298ab3fb7
| -rw-r--r-- | api/current.txt | 3 | ||||
| -rw-r--r-- | core/java/android/app/ActivityTransitionCoordinator.java | 21 | ||||
| -rw-r--r-- | core/java/android/view/Window.java | 21 | ||||
| -rw-r--r-- | core/res/res/values/attrs.xml | 8 | ||||
| -rw-r--r-- | core/res/res/values/public.xml | 1 | ||||
| -rw-r--r-- | policy/src/com/android/internal/policy/impl/PhoneWindow.java | 15 |
6 files changed, 62 insertions, 7 deletions
diff --git a/api/current.txt b/api/current.txt index fc5a3a06f1fe..aac7fcd393be 100644 --- a/api/current.txt +++ b/api/current.txt @@ -1445,6 +1445,7 @@ package android { field public static final int windowSharedElementExitTransition = 16843834; // 0x101043a field public static final int windowSharedElementReenterTransition = 16843954; // 0x10104b2 field public static final int windowSharedElementReturnTransition = 16843953; // 0x10104b1 + field public static final int windowSharedElementsUseOverlay = 16843964; // 0x10104bc field public static final int windowShowAnimation = 16842934; // 0x10100b6 field public static final int windowShowWallpaper = 16843410; // 0x1010292 field public static final int windowSoftInputMode = 16843307; // 0x101022b @@ -35138,6 +35139,7 @@ package android.view { method public android.transition.Transition getSharedElementExitTransition(); method public android.transition.Transition getSharedElementReenterTransition(); method public android.transition.Transition getSharedElementReturnTransition(); + method public boolean getSharedElementsUseOverlay(); method public abstract int getStatusBarColor(); method public long getTransitionBackgroundFadeDuration(); method public android.transition.TransitionManager getTransitionManager(); @@ -35199,6 +35201,7 @@ package android.view { method public void setSharedElementExitTransition(android.transition.Transition); method public void setSharedElementReenterTransition(android.transition.Transition); method public void setSharedElementReturnTransition(android.transition.Transition); + method public void setSharedElementsUseOverlay(boolean); method public void setSoftInputMode(int); method public abstract void setStatusBarColor(int); method public abstract void setTitle(java.lang.CharSequence); diff --git a/core/java/android/app/ActivityTransitionCoordinator.java b/core/java/android/app/ActivityTransitionCoordinator.java index 7d2f677dbcc8..e4f2b8819982 100644 --- a/core/java/android/app/ActivityTransitionCoordinator.java +++ b/core/java/android/app/ActivityTransitionCoordinator.java @@ -665,6 +665,9 @@ abstract class ActivityTransitionCoordinator extends ResultReceiver { } protected void moveSharedElementsToOverlay() { + if (!mWindow.getSharedElementsUseOverlay()) { + return; + } int numSharedElements = mSharedElements.size(); ViewGroup decor = getDecor(); if (decor != null) { @@ -700,6 +703,17 @@ abstract class ActivityTransitionCoordinator extends ResultReceiver { } protected void moveSharedElementsFromOverlay() { + int numListeners = mGhostViewListeners.size(); + for (int i = 0; i < numListeners; i++) { + GhostViewListeners listener = mGhostViewListeners.get(i); + ViewGroup parent = (ViewGroup) listener.getView().getParent(); + parent.getViewTreeObserver().removeOnPreDrawListener(listener); + } + mGhostViewListeners.clear(); + + if (mWindow == null || !mWindow.getSharedElementsUseOverlay()) { + return; + } ViewGroup decor = getDecor(); if (decor != null) { ViewGroupOverlay overlay = decor.getOverlay(); @@ -709,13 +723,6 @@ abstract class ActivityTransitionCoordinator extends ResultReceiver { GhostView.removeGhost(sharedElement); } } - int numListeners = mGhostViewListeners.size(); - for (int i = 0; i < numListeners; i++) { - GhostViewListeners listener = mGhostViewListeners.get(i); - ViewGroup parent = (ViewGroup) listener.getView().getParent(); - parent.getViewTreeObserver().removeOnPreDrawListener(listener); - } - mGhostViewListeners.clear(); } protected void setGhostVisibility(int visibility) { diff --git a/core/java/android/view/Window.java b/core/java/android/view/Window.java index e7b3152f7635..2c7ea3e58a97 100644 --- a/core/java/android/view/Window.java +++ b/core/java/android/view/Window.java @@ -1662,6 +1662,27 @@ public abstract class Window { public void setTransitionBackgroundFadeDuration(long fadeDurationMillis) { } /** + * Returns <code>true</code> when shared elements should use an Overlay during + * shared element transitions or <code>false</code> when they should animate as + * part of the normal View hierarchy. The default value is true. + * + * @return <code>true</code> when shared elements should use an Overlay during + * shared element transitions or <code>false</code> when they should animate as + * part of the normal View hierarchy. + */ + public boolean getSharedElementsUseOverlay() { return true; } + + /** + * Sets whether or not shared elements should use an Overlay during shared element transitions. + * The default value is true. + * + * @param sharedElementsUseOverlay <code>true</code> indicates that shared elements should + * be transitioned with an Overlay or <code>false</code> + * to transition within the normal View hierarchy. + */ + public void setSharedElementsUseOverlay(boolean sharedElementsUseOverlay) { } + + /** * @return the color of the status bar. */ public abstract int getStatusBarColor(); diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index ed9e83f2dcc3..27b770141da9 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -517,6 +517,10 @@ {@link android.view.Window#setAllowExitTransitionOverlap(boolean)}. --> <attr name="windowAllowExitTransitionOverlap" format="boolean"/> + <!-- Indicates whether or not shared elements should use an overlay + during transitions. The default value is true. --> + <attr name="windowSharedElementsUseOverlay" format="boolean"/> + <!-- Internal layout used internally for window decor --> <attr name="windowActionBarFullscreenDecorLayout" format="reference" /> @@ -1836,6 +1840,10 @@ {@link android.view.Window#setAllowExitTransitionOverlap(boolean)}. --> <attr name="windowAllowExitTransitionOverlap"/> + <!-- Indicates whether or not shared elements should use an overlay + during transitions. The default value is true. --> + <attr name="windowSharedElementsUseOverlay"/> + <!-- Flag indicating whether this Window is responsible for drawing the background for the system bars. If true and the window is not floating, the system bars are drawn with a transparent background and the corresponding areas in this window are filled with the diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index 4f0c5eb92ad0..b3b5ca955136 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -2275,6 +2275,7 @@ <public type="attr" name="outlineProvider" /> <public type="attr" name="ageHint" /> <public type="attr" name="country" /> + <public type="attr" name="windowSharedElementsUseOverlay" /> <public-padding type="dimen" name="l_resource_pad" end="0x01050010" /> diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java index 73358c8166fd..9652ebd7df4a 100644 --- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java @@ -267,6 +267,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { private Boolean mAllowExitTransitionOverlap; private Boolean mAllowEnterTransitionOverlap; private long mBackgroundFadeDurationMillis = -1; + private Boolean mSharedElementsUseOverlay; static class WindowManagerHolder { static final IWindowManager sWindowManager = IWindowManager.Stub.asInterface( @@ -3546,6 +3547,10 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { R.styleable.Window_windowTransitionBackgroundFadeDuration, DEFAULT_BACKGROUND_FADE_DURATION_MS); } + if (mSharedElementsUseOverlay == null) { + mSharedElementsUseOverlay = getWindowStyle().getBoolean( + R.styleable.Window_windowSharedElementsUseOverlay, true); + } } } } @@ -4024,6 +4029,16 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { mBackgroundFadeDurationMillis = fadeDurationMillis; } + @Override + public void setSharedElementsUseOverlay(boolean sharedElementsUseOverlay) { + mSharedElementsUseOverlay = sharedElementsUseOverlay; + } + + @Override + public boolean getSharedElementsUseOverlay() { + return (mSharedElementsUseOverlay == null) ? true : mSharedElementsUseOverlay; + } + private static final class DrawableFeatureState { DrawableFeatureState(int _featureId) { featureId = _featureId; |