Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 65225acf authored by Miranda Kephart's avatar Miranda Kephart Committed by Android (Google) Code Review
Browse files

Merge "Fix screenshot UI entrance animation" into rvc-dev

parents e066b2b1 a083d73f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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"
+9 −8
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
    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"
+23 −5
Original line number Diff line number Diff line
@@ -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;
    }