Merge "Fix shared transition offsets in landscape" into sc-dev am: 3196d0faea
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15189837 Change-Id: Id114e18a0c8a01d71e2538e05e93faeb14a9ec64
This commit is contained in:
@@ -131,4 +131,13 @@
|
|||||||
app:layout_constraintStart_toStartOf="@id/global_screenshot_preview"
|
app:layout_constraintStart_toStartOf="@id/global_screenshot_preview"
|
||||||
app:layout_constraintTop_toTopOf="@id/global_screenshot_preview"
|
app:layout_constraintTop_toTopOf="@id/global_screenshot_preview"
|
||||||
android:elevation="@dimen/screenshot_preview_elevation"/>
|
android:elevation="@dimen/screenshot_preview_elevation"/>
|
||||||
|
<View
|
||||||
|
android:id="@+id/screenshot_transition_view"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:visibility="invisible"
|
||||||
|
app:layout_constraintStart_toStartOf="@id/global_screenshot_preview"
|
||||||
|
app:layout_constraintTop_toTopOf="@id/global_screenshot_preview"
|
||||||
|
app:layout_constraintEnd_toEndOf="@id/global_screenshot_preview"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@id/global_screenshot_preview"/>
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|||||||
@@ -334,11 +334,18 @@ public class LongScreenshotActivity extends Activity {
|
|||||||
| Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
| Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
||||||
|
|
||||||
mTransitionView.setImageBitmap(mOutputBitmap);
|
mTransitionView.setImageBitmap(mOutputBitmap);
|
||||||
mTransitionView.setVisibility(View.VISIBLE);
|
|
||||||
mTransitionView.setTransitionName(
|
mTransitionView.setTransitionName(
|
||||||
ChooserActivity.FIRST_IMAGE_PREVIEW_TRANSITION_NAME);
|
ChooserActivity.FIRST_IMAGE_PREVIEW_TRANSITION_NAME);
|
||||||
// TODO: listen for transition completing instead of finishing onStop
|
// TODO: listen for transition completing instead of finishing onStop
|
||||||
mTransitionStarted = true;
|
mTransitionStarted = true;
|
||||||
|
int[] locationOnScreen = new int[2];
|
||||||
|
mTransitionView.getLocationOnScreen(locationOnScreen);
|
||||||
|
int[] locationInWindow = new int[2];
|
||||||
|
mTransitionView.getLocationInWindow(locationInWindow);
|
||||||
|
int deltaX = locationOnScreen[0] - locationInWindow[0];
|
||||||
|
int deltaY = locationOnScreen[1] - locationInWindow[1];
|
||||||
|
mTransitionView.setX(mTransitionView.getX() - deltaX);
|
||||||
|
mTransitionView.setY(mTransitionView.getY() - deltaY);
|
||||||
startActivity(intent,
|
startActivity(intent,
|
||||||
ActivityOptions.makeSceneTransitionAnimation(this, mTransitionView,
|
ActivityOptions.makeSceneTransitionAnimation(this, mTransitionView,
|
||||||
ChooserActivity.FIRST_IMAGE_PREVIEW_TRANSITION_NAME).toBundle());
|
ChooserActivity.FIRST_IMAGE_PREVIEW_TRANSITION_NAME).toBundle());
|
||||||
|
|||||||
@@ -936,10 +936,12 @@ public class ScreenshotController {
|
|||||||
*/
|
*/
|
||||||
private Supplier<ActionTransition> getActionTransitionSupplier() {
|
private Supplier<ActionTransition> getActionTransitionSupplier() {
|
||||||
return () -> {
|
return () -> {
|
||||||
|
View preview = mScreenshotView.getTransitionView();
|
||||||
|
preview.setX(preview.getX() - mScreenshotView.getStaticLeftMargin());
|
||||||
Pair<ActivityOptions, ExitTransitionCoordinator> transition =
|
Pair<ActivityOptions, ExitTransitionCoordinator> transition =
|
||||||
ActivityOptions.startSharedElementAnimation(
|
ActivityOptions.startSharedElementAnimation(
|
||||||
mWindow, new ScreenshotExitTransitionCallbacksSupplier(true).get(),
|
mWindow, new ScreenshotExitTransitionCallbacksSupplier(true).get(),
|
||||||
null, Pair.create(mScreenshotView.getScreenshotPreview(),
|
null, Pair.create(mScreenshotView.getTransitionView(),
|
||||||
ChooserActivity.FIRST_IMAGE_PREVIEW_TRANSITION_NAME));
|
ChooserActivity.FIRST_IMAGE_PREVIEW_TRANSITION_NAME));
|
||||||
transition.second.startExit();
|
transition.second.startExit();
|
||||||
|
|
||||||
|
|||||||
@@ -137,11 +137,13 @@ public class ScreenshotView extends FrameLayout implements
|
|||||||
private int mNavMode;
|
private int mNavMode;
|
||||||
private boolean mOrientationPortrait;
|
private boolean mOrientationPortrait;
|
||||||
private boolean mDirectionLTR;
|
private boolean mDirectionLTR;
|
||||||
|
private int mStaticLeftMargin;
|
||||||
|
|
||||||
private ScreenshotSelectorView mScreenshotSelectorView;
|
private ScreenshotSelectorView mScreenshotSelectorView;
|
||||||
private ImageView mScrollingScrim;
|
private ImageView mScrollingScrim;
|
||||||
private View mScreenshotStatic;
|
private View mScreenshotStatic;
|
||||||
private ImageView mScreenshotPreview;
|
private ImageView mScreenshotPreview;
|
||||||
|
private View mTransitionView;
|
||||||
private View mScreenshotPreviewBorder;
|
private View mScreenshotPreviewBorder;
|
||||||
private ImageView mScrollablePreview;
|
private ImageView mScrollablePreview;
|
||||||
private ImageView mScreenshotFlash;
|
private ImageView mScreenshotFlash;
|
||||||
@@ -337,6 +339,7 @@ public class ScreenshotView extends FrameLayout implements
|
|||||||
mScrollingScrim = requireNonNull(findViewById(R.id.screenshot_scrolling_scrim));
|
mScrollingScrim = requireNonNull(findViewById(R.id.screenshot_scrolling_scrim));
|
||||||
mScreenshotStatic = requireNonNull(findViewById(R.id.global_screenshot_static));
|
mScreenshotStatic = requireNonNull(findViewById(R.id.global_screenshot_static));
|
||||||
mScreenshotPreview = requireNonNull(findViewById(R.id.global_screenshot_preview));
|
mScreenshotPreview = requireNonNull(findViewById(R.id.global_screenshot_preview));
|
||||||
|
mTransitionView = requireNonNull(findViewById(R.id.screenshot_transition_view));
|
||||||
mScreenshotPreviewBorder = requireNonNull(
|
mScreenshotPreviewBorder = requireNonNull(
|
||||||
findViewById(R.id.global_screenshot_preview_border));
|
findViewById(R.id.global_screenshot_preview_border));
|
||||||
mScreenshotPreview.setClipToOutline(true);
|
mScreenshotPreview.setClipToOutline(true);
|
||||||
@@ -382,8 +385,12 @@ public class ScreenshotView extends FrameLayout implements
|
|||||||
requestFocus();
|
requestFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
View getScreenshotPreview() {
|
View getTransitionView() {
|
||||||
return mScreenshotPreview;
|
return mTransitionView;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getStaticLeftMargin() {
|
||||||
|
return mStaticLeftMargin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -424,6 +431,7 @@ public class ScreenshotView extends FrameLayout implements
|
|||||||
Math.max(cutout.getSafeInsetRight(), waterfall.right), waterfall.bottom);
|
Math.max(cutout.getSafeInsetRight(), waterfall.right), waterfall.bottom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mStaticLeftMargin = p.leftMargin;
|
||||||
mScreenshotStatic.setLayoutParams(p);
|
mScreenshotStatic.setLayoutParams(p);
|
||||||
mScreenshotStatic.requestLayout();
|
mScreenshotStatic.requestLayout();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user