Merge "Fix screenshot UI entrance animation" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
65225acf1e
@@ -38,6 +38,7 @@
|
||||
android:elevation="1dp"
|
||||
android:fillViewport="true"
|
||||
android:layout_marginHorizontal="@dimen/screenshot_action_container_margin_horizontal"
|
||||
android:layout_marginBottom="@dimen/screenshot_action_container_offset_y"
|
||||
android:gravity="center"
|
||||
android:paddingLeft="@dimen/screenshot_action_container_padding_left"
|
||||
android:paddingRight="@dimen/screenshot_action_container_padding_right"
|
||||
|
||||
@@ -16,14 +16,15 @@
|
||||
-->
|
||||
<com.android.systemui.screenshot.ScreenshotActionChip
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/global_screenshot_action_chip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="@dimen/screenshot_action_chip_margin_right"
|
||||
android:layout_gravity="center"
|
||||
android:paddingVertical="@dimen/screenshot_action_chip_padding_vertical"
|
||||
android:background="@drawable/action_chip_background"
|
||||
android:gravity="center">
|
||||
android:id="@+id/global_screenshot_action_chip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="@dimen/screenshot_action_chip_margin_right"
|
||||
android:layout_gravity="center"
|
||||
android:paddingVertical="@dimen/screenshot_action_chip_padding_vertical"
|
||||
android:background="@drawable/action_chip_background"
|
||||
android:alpha="0"
|
||||
android:gravity="center">
|
||||
<ImageView
|
||||
android:id="@+id/screenshot_action_chip_icon"
|
||||
android:layout_width="@dimen/screenshot_action_chip_icon_size"
|
||||
|
||||
@@ -82,6 +82,7 @@ import com.android.systemui.dagger.qualifiers.Main;
|
||||
import com.android.systemui.shared.system.ActivityManagerWrapper;
|
||||
import com.android.systemui.statusbar.phone.StatusBar;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
@@ -162,6 +163,9 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset
|
||||
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_SCALE_DURATION_MS = 234;
|
||||
private static final long SCREENSHOT_ACTIONS_EXPANSION_DURATION_MS = 400;
|
||||
private static final long SCREENSHOT_ACTIONS_ALPHA_DURATION_MS = 100;
|
||||
private static final float SCREENSHOT_ACTIONS_START_SCALE_X = .7f;
|
||||
private static final float ROUNDED_CORNER_RADIUS = .05f;
|
||||
private static final long SCREENSHOT_CORNER_TIMEOUT_MILLIS = 6000;
|
||||
private static final int MESSAGE_CORNER_TIMEOUT = 2;
|
||||
@@ -263,6 +267,7 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset
|
||||
mScreenshotSelectorView.setFocusableInTouchMode(true);
|
||||
mScreenshotView.setPivotX(0);
|
||||
mScreenshotView.setPivotY(0);
|
||||
mActionsContainer.setPivotX(0);
|
||||
|
||||
// Setup the window that we are going to use
|
||||
mWindowLayoutParams = new WindowManager.LayoutParams(
|
||||
@@ -661,6 +666,8 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
|
||||
ArrayList<ScreenshotActionChip> chips = new ArrayList<>();
|
||||
|
||||
for (Notification.Action smartAction : imageData.smartActions) {
|
||||
ScreenshotActionChip actionChip = (ScreenshotActionChip) inflater.inflate(
|
||||
R.layout.global_screenshot_action_chip, mActionsView, false);
|
||||
@@ -673,6 +680,7 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset
|
||||
mOnCompleteRunnable.run();
|
||||
});
|
||||
mActionsView.addView(actionChip);
|
||||
chips.add(actionChip);
|
||||
}
|
||||
|
||||
ScreenshotActionChip shareChip = (ScreenshotActionChip) inflater.inflate(
|
||||
@@ -685,6 +693,7 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset
|
||||
mOnCompleteRunnable.run();
|
||||
});
|
||||
mActionsView.addView(shareChip);
|
||||
chips.add(shareChip);
|
||||
|
||||
ScreenshotActionChip editChip = (ScreenshotActionChip) inflater.inflate(
|
||||
R.layout.global_screenshot_action_chip, mActionsView, false);
|
||||
@@ -696,6 +705,7 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset
|
||||
mOnCompleteRunnable.run();
|
||||
});
|
||||
mActionsView.addView(editChip);
|
||||
chips.add(editChip);
|
||||
|
||||
mScreenshotView.setOnClickListener(v -> {
|
||||
try {
|
||||
@@ -709,7 +719,6 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset
|
||||
});
|
||||
mScreenshotView.setContentDescription(imageData.editAction.title);
|
||||
|
||||
|
||||
if (DeviceConfig.getBoolean(NAMESPACE_SYSTEMUI, SCREENSHOT_SCROLLING_ENABLED, false)) {
|
||||
ScreenshotActionChip scrollChip = (ScreenshotActionChip) inflater.inflate(
|
||||
R.layout.global_screenshot_action_chip, mActionsView, false);
|
||||
@@ -723,18 +732,27 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset
|
||||
scrollNotImplemented.show();
|
||||
});
|
||||
mActionsView.addView(scrollChip);
|
||||
chips.add(scrollChip);
|
||||
}
|
||||
|
||||
ValueAnimator animator = ValueAnimator.ofFloat(0, 1);
|
||||
mActionsContainer.setY(mDisplayMetrics.heightPixels);
|
||||
animator.setDuration(SCREENSHOT_ACTIONS_EXPANSION_DURATION_MS);
|
||||
float alphaFraction = (float) SCREENSHOT_ACTIONS_ALPHA_DURATION_MS
|
||||
/ SCREENSHOT_ACTIONS_EXPANSION_DURATION_MS;
|
||||
mActionsContainer.setVisibility(VISIBLE);
|
||||
mActionsContainer.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
|
||||
float actionsViewHeight = mActionsContainer.getMeasuredHeight() + mScreenshotHeightPx;
|
||||
mActionsContainer.setAlpha(0);
|
||||
|
||||
animator.addUpdateListener(animation -> {
|
||||
float t = animation.getAnimatedFraction();
|
||||
mBackgroundProtection.setAlpha(t);
|
||||
mActionsContainer.setY(mDisplayMetrics.heightPixels - actionsViewHeight * t);
|
||||
mActionsContainer.setAlpha(t < alphaFraction ? t / alphaFraction : 1);
|
||||
float containerScale = SCREENSHOT_ACTIONS_START_SCALE_X
|
||||
+ (t * (1 - SCREENSHOT_ACTIONS_START_SCALE_X));
|
||||
mActionsContainer.setScaleX(containerScale);
|
||||
for (ScreenshotActionChip chip : chips) {
|
||||
chip.setAlpha(t);
|
||||
chip.setScaleX(1 / containerScale); // invert to keep size of children constant
|
||||
}
|
||||
});
|
||||
return animator;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user