Merge "Fix Chooser enter transition animation" into tm-dev
This commit is contained in:
@@ -300,6 +300,8 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected ChooserMultiProfilePagerAdapter mChooserMultiProfilePagerAdapter;
|
protected ChooserMultiProfilePagerAdapter mChooserMultiProfilePagerAdapter;
|
||||||
|
private final EnterTransitionAnimationDelegate mEnterTransitionAnimationDelegate =
|
||||||
|
new EnterTransitionAnimationDelegate();
|
||||||
|
|
||||||
private boolean mRemoveSharedElements = false;
|
private boolean mRemoveSharedElements = false;
|
||||||
|
|
||||||
@@ -383,7 +385,7 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
// transition animation.
|
// transition animation.
|
||||||
getWindow().setWindowAnimations(0);
|
getWindow().setWindowAnimations(0);
|
||||||
}
|
}
|
||||||
startPostponedEnterTransition();
|
mEnterTransitionAnimationDelegate.markImagePreviewReady();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -431,7 +433,7 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
mHideParentOnFail = false;
|
mHideParentOnFail = false;
|
||||||
}
|
}
|
||||||
mRemoveSharedElements = true;
|
mRemoveSharedElements = true;
|
||||||
startPostponedEnterTransition();
|
mEnterTransitionAnimationDelegate.markImagePreviewReady();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -724,7 +726,7 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
mRemoveSharedElements = false;
|
mRemoveSharedElements = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
postponeEnterTransition();
|
mEnterTransitionAnimationDelegate.postponeTransition();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1242,6 +1244,9 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
if (layout != null) {
|
if (layout != null) {
|
||||||
adjustPreviewWidth(getResources().getConfiguration().orientation, layout);
|
adjustPreviewWidth(getResources().getConfiguration().orientation, layout);
|
||||||
}
|
}
|
||||||
|
if (previewType != CONTENT_PREVIEW_IMAGE) {
|
||||||
|
mEnterTransitionAnimationDelegate.markImagePreviewReady();
|
||||||
|
}
|
||||||
|
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
@@ -2514,6 +2519,15 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
if (mResolverDrawerLayout == null || gridAdapter == null) {
|
if (mResolverDrawerLayout == null || gridAdapter == null) {
|
||||||
return;
|
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
|
final int bottomInset = mSystemWindowInsets != null
|
||||||
? mSystemWindowInsets.bottom : 0;
|
? mSystemWindowInsets.bottom : 0;
|
||||||
@@ -2534,8 +2548,7 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
if (rowsToShow == 0 && !shouldShowStickyContentPreview()) {
|
if (rowsToShow == 0 && !shouldShowStickyContentPreview()) {
|
||||||
offset += getResources().getDimensionPixelSize(
|
offset += getResources().getDimensionPixelSize(
|
||||||
R.dimen.chooser_max_collapsed_height);
|
R.dimen.chooser_max_collapsed_height);
|
||||||
mResolverDrawerLayout.setCollapsibleHeightReserved(offset);
|
return offset;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
View stickyContentPreview = findViewById(R.id.content_preview_container);
|
View stickyContentPreview = findViewById(R.id.content_preview_container);
|
||||||
@@ -2593,9 +2606,7 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mResolverDrawerLayout.setCollapsibleHeightReserved(Math.min(offset, bottom - top));
|
return Math.min(offset, bottom - top);
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -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
|
@Override
|
||||||
protected void maybeLogProfileChange() {
|
protected void maybeLogProfileChange() {
|
||||||
getChooserActivityLogger().logShareheetProfileChanged();
|
getChooserActivityLogger().logShareheetProfileChanged();
|
||||||
|
|||||||
Reference in New Issue
Block a user