Merge "Animate screenshot dismiss button appearance" into rvc-dev am: 0d3440f4f9
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11811380 Change-Id: Icde7057d7b71cc9c53ca76cdcd9d83fac24b7d76
This commit is contained in:
@@ -48,4 +48,18 @@
|
|||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:pointerIcon="crosshair"/>
|
android:pointerIcon="crosshair"/>
|
||||||
<include layout="@layout/global_screenshot_static"/>
|
<include layout="@layout/global_screenshot_static"/>
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/global_screenshot_dismiss_button"
|
||||||
|
android:layout_width="@dimen/screenshot_dismiss_button_tappable_size"
|
||||||
|
android:layout_height="@dimen/screenshot_dismiss_button_tappable_size"
|
||||||
|
android:elevation="7dp"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:contentDescription="@string/screenshot_dismiss_ui_description">
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/global_screenshot_dismiss_image"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_margin="@dimen/screenshot_dismiss_button_margin"
|
||||||
|
android:src="@drawable/screenshot_cancel"/>
|
||||||
|
</FrameLayout>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|||||||
@@ -54,22 +54,4 @@
|
|||||||
android:layout_height="wrap_content"/>
|
android:layout_height="wrap_content"/>
|
||||||
</HorizontalScrollView>
|
</HorizontalScrollView>
|
||||||
<include layout="@layout/global_screenshot_preview"/>
|
<include layout="@layout/global_screenshot_preview"/>
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/global_screenshot_dismiss_button"
|
|
||||||
android:layout_width="@dimen/screenshot_dismiss_button_tappable_size"
|
|
||||||
android:layout_height="@dimen/screenshot_dismiss_button_tappable_size"
|
|
||||||
android:elevation="7dp"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:contentDescription="@string/screenshot_dismiss_ui_description"
|
|
||||||
app:layout_constraintStart_toEndOf="@+id/global_screenshot_preview"
|
|
||||||
app:layout_constraintEnd_toEndOf="@+id/global_screenshot_preview"
|
|
||||||
app:layout_constraintTop_toTopOf="@+id/global_screenshot_preview"
|
|
||||||
app:layout_constraintBottom_toTopOf="@+id/global_screenshot_preview">
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/global_screenshot_dismiss_image"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_margin="@dimen/screenshot_dismiss_button_margin"
|
|
||||||
android:src="@drawable/screenshot_cancel"/>
|
|
||||||
</FrameLayout>
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|||||||
@@ -173,6 +173,8 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset
|
|||||||
|
|
||||||
private static final long SCREENSHOT_FLASH_IN_DURATION_MS = 133;
|
private static final long SCREENSHOT_FLASH_IN_DURATION_MS = 133;
|
||||||
private static final long SCREENSHOT_FLASH_OUT_DURATION_MS = 217;
|
private static final long SCREENSHOT_FLASH_OUT_DURATION_MS = 217;
|
||||||
|
// delay before starting to fade in dismiss button
|
||||||
|
private static final long SCREENSHOT_TO_CORNER_DISMISS_DELAY_MS = 200;
|
||||||
private static final long SCREENSHOT_TO_CORNER_X_DURATION_MS = 234;
|
private static final long SCREENSHOT_TO_CORNER_X_DURATION_MS = 234;
|
||||||
private static final long SCREENSHOT_TO_CORNER_Y_DURATION_MS = 500;
|
private static final long SCREENSHOT_TO_CORNER_Y_DURATION_MS = 500;
|
||||||
private static final long SCREENSHOT_TO_CORNER_SCALE_DURATION_MS = 234;
|
private static final long SCREENSHOT_TO_CORNER_SCALE_DURATION_MS = 234;
|
||||||
@@ -772,6 +774,9 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset
|
|||||||
mScreenshotAnimatedView.setScaleX(currentScale);
|
mScreenshotAnimatedView.setScaleX(currentScale);
|
||||||
mScreenshotAnimatedView.setScaleY(currentScale);
|
mScreenshotAnimatedView.setScaleY(currentScale);
|
||||||
|
|
||||||
|
mDismissButton.setAlpha(0);
|
||||||
|
mDismissButton.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
AnimatorSet dropInAnimation = new AnimatorSet();
|
AnimatorSet dropInAnimation = new AnimatorSet();
|
||||||
ValueAnimator flashInAnimator = ValueAnimator.ofFloat(0, 1);
|
ValueAnimator flashInAnimator = ValueAnimator.ofFloat(0, 1);
|
||||||
flashInAnimator.setDuration(SCREENSHOT_FLASH_IN_DURATION_MS);
|
flashInAnimator.setDuration(SCREENSHOT_FLASH_IN_DURATION_MS);
|
||||||
@@ -793,6 +798,8 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset
|
|||||||
toCorner.setDuration(SCREENSHOT_TO_CORNER_Y_DURATION_MS);
|
toCorner.setDuration(SCREENSHOT_TO_CORNER_Y_DURATION_MS);
|
||||||
float xPositionPct =
|
float xPositionPct =
|
||||||
SCREENSHOT_TO_CORNER_X_DURATION_MS / (float) SCREENSHOT_TO_CORNER_Y_DURATION_MS;
|
SCREENSHOT_TO_CORNER_X_DURATION_MS / (float) SCREENSHOT_TO_CORNER_Y_DURATION_MS;
|
||||||
|
float dismissPct =
|
||||||
|
SCREENSHOT_TO_CORNER_DISMISS_DELAY_MS / (float) SCREENSHOT_TO_CORNER_Y_DURATION_MS;
|
||||||
float scalePct =
|
float scalePct =
|
||||||
SCREENSHOT_TO_CORNER_SCALE_DURATION_MS / (float) SCREENSHOT_TO_CORNER_Y_DURATION_MS;
|
SCREENSHOT_TO_CORNER_SCALE_DURATION_MS / (float) SCREENSHOT_TO_CORNER_Y_DURATION_MS;
|
||||||
toCorner.addUpdateListener(animation -> {
|
toCorner.addUpdateListener(animation -> {
|
||||||
@@ -820,6 +827,19 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset
|
|||||||
float yCenter = MathUtils.lerp(
|
float yCenter = MathUtils.lerp(
|
||||||
startPos.y, finalPos.y, mFastOutSlowIn.getInterpolation(t));
|
startPos.y, finalPos.y, mFastOutSlowIn.getInterpolation(t));
|
||||||
mScreenshotAnimatedView.setY(yCenter - bounds.height() * currentScaleY / 2f);
|
mScreenshotAnimatedView.setY(yCenter - bounds.height() * currentScaleY / 2f);
|
||||||
|
|
||||||
|
if (t >= dismissPct) {
|
||||||
|
mDismissButton.setAlpha((t - dismissPct) / (1 - dismissPct));
|
||||||
|
float currentX = mScreenshotAnimatedView.getX();
|
||||||
|
float currentY = mScreenshotAnimatedView.getY();
|
||||||
|
mDismissButton.setY(currentY - mDismissButton.getHeight() / 2f);
|
||||||
|
if (mDirectionLTR) {
|
||||||
|
mDismissButton.setX(currentX
|
||||||
|
+ bounds.width() * currentScaleX - mDismissButton.getWidth() / 2f);
|
||||||
|
} else {
|
||||||
|
mDismissButton.setX(currentX - mDismissButton.getWidth() / 2f);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
toCorner.addListener(new AnimatorListenerAdapter() {
|
toCorner.addListener(new AnimatorListenerAdapter() {
|
||||||
@@ -844,13 +864,20 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset
|
|||||||
@Override
|
@Override
|
||||||
public void onAnimationEnd(Animator animation) {
|
public void onAnimationEnd(Animator animation) {
|
||||||
super.onAnimationEnd(animation);
|
super.onAnimationEnd(animation);
|
||||||
|
mDismissButton.setAlpha(1);
|
||||||
|
float dismissOffset = mDismissButton.getWidth() / 2f;
|
||||||
|
float finalDismissX = mDirectionLTR
|
||||||
|
? finalPos.x - dismissOffset + bounds.width() * cornerScale / 2f
|
||||||
|
: finalPos.x - dismissOffset - bounds.width() * cornerScale / 2f;
|
||||||
|
mDismissButton.setX(finalDismissX);
|
||||||
|
mDismissButton.setY(
|
||||||
|
finalPos.y - dismissOffset - bounds.height() * cornerScale / 2f);
|
||||||
mScreenshotAnimatedView.setScaleX(1);
|
mScreenshotAnimatedView.setScaleX(1);
|
||||||
mScreenshotAnimatedView.setScaleY(1);
|
mScreenshotAnimatedView.setScaleY(1);
|
||||||
mScreenshotAnimatedView.setX(finalPos.x - bounds.width() * cornerScale / 2f);
|
mScreenshotAnimatedView.setX(finalPos.x - bounds.width() * cornerScale / 2f);
|
||||||
mScreenshotAnimatedView.setY(finalPos.y - bounds.height() * cornerScale / 2f);
|
mScreenshotAnimatedView.setY(finalPos.y - bounds.height() * cornerScale / 2f);
|
||||||
mScreenshotAnimatedView.setVisibility(View.GONE);
|
mScreenshotAnimatedView.setVisibility(View.GONE);
|
||||||
mScreenshotPreview.setVisibility(View.VISIBLE);
|
mScreenshotPreview.setVisibility(View.VISIBLE);
|
||||||
mDismissButton.setVisibility(View.VISIBLE);
|
|
||||||
mScreenshotLayout.forceLayout();
|
mScreenshotLayout.forceLayout();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user