Loading core/java/com/android/internal/app/ChooserActivity.java +131 −75 Original line number Diff line number Diff line Loading @@ -300,6 +300,8 @@ public class ChooserActivity extends ResolverActivity implements @VisibleForTesting protected ChooserMultiProfilePagerAdapter mChooserMultiProfilePagerAdapter; private final EnterTransitionAnimationDelegate mEnterTransitionAnimationDelegate = new EnterTransitionAnimationDelegate(); private boolean mRemoveSharedElements = false; Loading Loading @@ -383,7 +385,7 @@ public class ChooserActivity extends ResolverActivity implements // transition animation. getWindow().setWindowAnimations(0); } startPostponedEnterTransition(); mEnterTransitionAnimationDelegate.markImagePreviewReady(); return true; } }); Loading Loading @@ -431,7 +433,7 @@ public class ChooserActivity extends ResolverActivity implements mHideParentOnFail = false; } mRemoveSharedElements = true; startPostponedEnterTransition(); mEnterTransitionAnimationDelegate.markImagePreviewReady(); } } Loading Loading @@ -724,7 +726,7 @@ public class ChooserActivity extends ResolverActivity implements mRemoveSharedElements = false; } }); postponeEnterTransition(); mEnterTransitionAnimationDelegate.postponeTransition(); } @Override Loading Loading @@ -1242,6 +1244,9 @@ public class ChooserActivity extends ResolverActivity implements if (layout != null) { adjustPreviewWidth(getResources().getConfiguration().orientation, layout); } if (previewType != CONTENT_PREVIEW_IMAGE) { mEnterTransitionAnimationDelegate.markImagePreviewReady(); } return layout; } Loading Loading @@ -2514,6 +2519,15 @@ public class ChooserActivity extends ResolverActivity implements if (mResolverDrawerLayout == null || gridAdapter == null) { return; } int offset = calculateDrawerOffset(top, bottom, recyclerView, gridAdapter); mResolverDrawerLayout.setCollapsibleHeightReserved(offset); mEnterTransitionAnimationDelegate.markOffsetCalculated(); }); } } private int calculateDrawerOffset( int top, int bottom, RecyclerView recyclerView, ChooserGridAdapter gridAdapter) { final int bottomInset = mSystemWindowInsets != null ? mSystemWindowInsets.bottom : 0; Loading @@ -2534,8 +2548,7 @@ public class ChooserActivity extends ResolverActivity implements if (rowsToShow == 0 && !shouldShowStickyContentPreview()) { offset += getResources().getDimensionPixelSize( R.dimen.chooser_max_collapsed_height); mResolverDrawerLayout.setCollapsibleHeightReserved(offset); return; return offset; } View stickyContentPreview = findViewById(R.id.content_preview_container); Loading Loading @@ -2593,9 +2606,7 @@ public class ChooserActivity extends ResolverActivity implements } } mResolverDrawerLayout.setCollapsibleHeightReserved(Math.min(offset, bottom - top)); }); } return Math.min(offset, bottom - top); } /** Loading Loading @@ -3930,6 +3941,51 @@ public class ChooserActivity extends ResolverActivity implements } } /** * A helper class to track app's readiness for the scene transition animation. * The app is ready when both the image is laid out and the drawer offset is calculated. */ private class EnterTransitionAnimationDelegate implements View.OnLayoutChangeListener { private boolean mPreviewReady = false; private boolean mOffsetCalculated = false; void postponeTransition() { postponeEnterTransition(); } void markImagePreviewReady() { if (!mPreviewReady) { mPreviewReady = true; maybeStartListenForLayout(); } } void markOffsetCalculated() { if (!mOffsetCalculated) { mOffsetCalculated = true; maybeStartListenForLayout(); } } private void maybeStartListenForLayout() { if (mPreviewReady && mOffsetCalculated && mResolverDrawerLayout != null) { if (mResolverDrawerLayout.isInLayout()) { startPostponedEnterTransition(); } else { mResolverDrawerLayout.addOnLayoutChangeListener(this); mResolverDrawerLayout.requestLayout(); } } } @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { v.removeOnLayoutChangeListener(this); startPostponedEnterTransition(); } } @Override protected void maybeLogProfileChange() { getChooserActivityLogger().logShareheetProfileChanged(); Loading Loading
core/java/com/android/internal/app/ChooserActivity.java +131 −75 Original line number Diff line number Diff line Loading @@ -300,6 +300,8 @@ public class ChooserActivity extends ResolverActivity implements @VisibleForTesting protected ChooserMultiProfilePagerAdapter mChooserMultiProfilePagerAdapter; private final EnterTransitionAnimationDelegate mEnterTransitionAnimationDelegate = new EnterTransitionAnimationDelegate(); private boolean mRemoveSharedElements = false; Loading Loading @@ -383,7 +385,7 @@ public class ChooserActivity extends ResolverActivity implements // transition animation. getWindow().setWindowAnimations(0); } startPostponedEnterTransition(); mEnterTransitionAnimationDelegate.markImagePreviewReady(); return true; } }); Loading Loading @@ -431,7 +433,7 @@ public class ChooserActivity extends ResolverActivity implements mHideParentOnFail = false; } mRemoveSharedElements = true; startPostponedEnterTransition(); mEnterTransitionAnimationDelegate.markImagePreviewReady(); } } Loading Loading @@ -724,7 +726,7 @@ public class ChooserActivity extends ResolverActivity implements mRemoveSharedElements = false; } }); postponeEnterTransition(); mEnterTransitionAnimationDelegate.postponeTransition(); } @Override Loading Loading @@ -1242,6 +1244,9 @@ public class ChooserActivity extends ResolverActivity implements if (layout != null) { adjustPreviewWidth(getResources().getConfiguration().orientation, layout); } if (previewType != CONTENT_PREVIEW_IMAGE) { mEnterTransitionAnimationDelegate.markImagePreviewReady(); } return layout; } Loading Loading @@ -2514,6 +2519,15 @@ public class ChooserActivity extends ResolverActivity implements if (mResolverDrawerLayout == null || gridAdapter == null) { return; } int offset = calculateDrawerOffset(top, bottom, recyclerView, gridAdapter); mResolverDrawerLayout.setCollapsibleHeightReserved(offset); mEnterTransitionAnimationDelegate.markOffsetCalculated(); }); } } private int calculateDrawerOffset( int top, int bottom, RecyclerView recyclerView, ChooserGridAdapter gridAdapter) { final int bottomInset = mSystemWindowInsets != null ? mSystemWindowInsets.bottom : 0; Loading @@ -2534,8 +2548,7 @@ public class ChooserActivity extends ResolverActivity implements if (rowsToShow == 0 && !shouldShowStickyContentPreview()) { offset += getResources().getDimensionPixelSize( R.dimen.chooser_max_collapsed_height); mResolverDrawerLayout.setCollapsibleHeightReserved(offset); return; return offset; } View stickyContentPreview = findViewById(R.id.content_preview_container); Loading Loading @@ -2593,9 +2606,7 @@ public class ChooserActivity extends ResolverActivity implements } } mResolverDrawerLayout.setCollapsibleHeightReserved(Math.min(offset, bottom - top)); }); } return Math.min(offset, bottom - top); } /** Loading Loading @@ -3930,6 +3941,51 @@ public class ChooserActivity extends ResolverActivity implements } } /** * A helper class to track app's readiness for the scene transition animation. * The app is ready when both the image is laid out and the drawer offset is calculated. */ private class EnterTransitionAnimationDelegate implements View.OnLayoutChangeListener { private boolean mPreviewReady = false; private boolean mOffsetCalculated = false; void postponeTransition() { postponeEnterTransition(); } void markImagePreviewReady() { if (!mPreviewReady) { mPreviewReady = true; maybeStartListenForLayout(); } } void markOffsetCalculated() { if (!mOffsetCalculated) { mOffsetCalculated = true; maybeStartListenForLayout(); } } private void maybeStartListenForLayout() { if (mPreviewReady && mOffsetCalculated && mResolverDrawerLayout != null) { if (mResolverDrawerLayout.isInLayout()) { startPostponedEnterTransition(); } else { mResolverDrawerLayout.addOnLayoutChangeListener(this); mResolverDrawerLayout.requestLayout(); } } } @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { v.removeOnLayoutChangeListener(this); startPostponedEnterTransition(); } } @Override protected void maybeLogProfileChange() { getChooserActivityLogger().logShareheetProfileChanged(); Loading