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

Commit d32ce863 authored by Mark Renouf's avatar Mark Renouf
Browse files

Simplify UI and animation choreography a bit

A number of changes to improve the robustness of the
startup/reset/dismiss process of the screenshot UI.

Brief summary:

Use visibility=invisible always for preview image
Wait for pre-draw to start animation
Apply initial config to "interesting changes" tracker
Rename: mOnCompleteAction -> mOnDismissedAction
Rease more resources earlier at shutdown
Remove some uneccessary main thread deferrals
resetScreenshotView -> finishDismiss
Resolve some cases where reset is called multiple times on exit
Update window token usage and apply to scroll capture at window attach
Simplified animation parameters, coordinate systems, etc.

Bug: 174509231
Bug: 174682382
Test: manual; take a screenshot, dismiss, share, edit, swipe away
Test: manual; open overview, tap screenshot

Change-Id: I3b84da3592970ac5c2a5eb34326eabaef003993f
Merged-In: I3b84da3592970ac5c2a5eb34326eabaef003993f
parent a8cf862d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@
    android:layout_marginBottom="@dimen/screenshot_offset_y"
    android:scaleType="fitEnd"
    android:elevation="@dimen/screenshot_preview_elevation"
    android:visibility="gone"
    android:visibility="invisible"
    android:background="@drawable/screenshot_rounded_corners"
    android:adjustViewBounds="true"
    android:contentDescription="@string/screenshot_edit_label"
+177 −132

File changed.

Preview size limit exceeded, changes collapsed.

+16 −12
Original line number Diff line number Diff line
@@ -316,21 +316,21 @@ public class ScreenshotView extends FrameLayout implements
        mScreenshotSelectorView.requestFocus();
    }

    void prepareForAnimation(Bitmap bitmap, Insets screenInsets) {
    void setScreenshot(Bitmap bitmap, Insets screenInsets) {
        mScreenshotPreview.setImageDrawable(createScreenDrawable(mResources, bitmap, screenInsets));
        // make static preview invisible (from gone) so we can query its location on screen
        mScreenshotPreview.setVisibility(View.INVISIBLE);
    }

    AnimatorSet createScreenshotDropInAnimation(Rect bounds, boolean showFlash) {
        mScreenshotPreview.setLayerType(View.LAYER_TYPE_HARDWARE, null);
        mScreenshotPreview.buildLayer();
        if (DEBUG_ANIM) {
            Log.d(TAG, "createAnim: bounds=" + bounds + " showFlash=" + showFlash);
        }

        Rect previewBounds = new Rect();
        mScreenshotPreview.getBoundsOnScreen(previewBounds);
        int[] previewLocation = new int[2];
        mScreenshotPreview.getLocationInWindow(previewLocation);
        Rect targetPosition = new Rect();
        mScreenshotPreview.getHitRect(targetPosition);

        // ratio of preview width, end vs. start size
        float cornerScale =
                mCornerSizeX / (mOrientationPortrait ? bounds.width() : bounds.height());
        final float currentScale = 1 / cornerScale;
@@ -358,8 +358,13 @@ public class ScreenshotView extends FrameLayout implements

        // animate from the current location, to the static preview location
        final PointF startPos = new PointF(bounds.centerX(), bounds.centerY());
        final PointF finalPos = new PointF(previewLocation[0] + previewBounds.width() / 2f,
                previewLocation[1] + previewBounds.height() / 2f);
        final PointF finalPos = new PointF(targetPosition.exactCenterX(),
                targetPosition.exactCenterY());

        if (DEBUG_ANIM) {
            Log.d(TAG, "toCorner: startPos=" + startPos);
            Log.d(TAG, "toCorner: finalPos=" + finalPos);
        }

        ValueAnimator toCorner = ValueAnimator.ofFloat(0, 1);
        toCorner.setDuration(SCREENSHOT_TO_CORNER_Y_DURATION_MS);
@@ -427,7 +432,7 @@ public class ScreenshotView extends FrameLayout implements
            @Override
            public void onAnimationEnd(Animator animation) {
                if (DEBUG_ANIM) {
                    Log.d(TAG, "drop-in animation completed");
                    Log.d(TAG, "drop-in animation ended");
                }
                mDismissButton.setOnClickListener(view -> {
                    if (DEBUG_INPUT) {
@@ -653,13 +658,12 @@ public class ScreenshotView extends FrameLayout implements
        getViewTreeObserver().removeOnComputeInternalInsetsListener(this);
        // Clear any references to the bitmap
        mScreenshotPreview.setImageDrawable(null);
        mScreenshotPreview.setVisibility(View.INVISIBLE);
        mPendingSharedTransition = false;
        mActionsContainerBackground.setVisibility(View.GONE);
        mActionsContainer.setVisibility(View.GONE);
        mBackgroundProtection.setAlpha(0f);
        mDismissButton.setVisibility(View.GONE);
        mScreenshotPreview.setVisibility(View.GONE);
        mScreenshotPreview.setLayerType(View.LAYER_TYPE_NONE, null);
        mScreenshotStatic.setTranslationX(0);
        mScreenshotPreview.setTranslationY(0);
        mScreenshotPreview.setContentDescription(
+1 −1
Original line number Diff line number Diff line
@@ -72,7 +72,7 @@ public class ScrollCaptureController {
     *
     * @param after action to take after the flow is complete
     */
    public void run(final Runnable after) {
    public void start(final Runnable after) {
        mCaptureTime = ZonedDateTime.now();
        mRequestId = UUID.randomUUID();
        mConnection.start((session) -> startCapture(session, after));
+51 −17

File changed.

Preview size limit exceeded, changes collapsed.