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

Commit feed5a8d authored by Miranda Kephart's avatar Miranda Kephart Committed by Automerger Merge Worker
Browse files

Merge "Move screenshot UI to avoid covering nav bar" into sc-qpr1-dev am: 7fd08a9f

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15541659

Change-Id: I33b64976fc05d9049e30d9bdbd346e465faed8e9
parents 477b8b4e 7fd08a9f
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -36,7 +36,6 @@
        android:layout_width="0dp"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="@dimen/screenshot_action_container_margin_horizontal"
        android:layout_marginEnd="@dimen/screenshot_action_container_margin_horizontal"
        android:layout_marginBottom="@dimen/screenshot_action_container_offset_y"
        android:paddingEnd="@dimen/screenshot_action_container_padding_right"
        android:paddingEnd="@dimen/screenshot_action_container_padding_right"
        android:paddingVertical="@dimen/screenshot_action_container_padding_vertical"
        android:paddingVertical="@dimen/screenshot_action_container_padding_vertical"
        android:elevation="1dp"
        android:elevation="1dp"
+1 −2
Original line number Original line Diff line number Diff line
@@ -328,11 +328,10 @@
    <dimen name="global_screenshot_x_scale">80dp</dimen>
    <dimen name="global_screenshot_x_scale">80dp</dimen>
    <dimen name="screenshot_bg_protection_height">242dp</dimen>
    <dimen name="screenshot_bg_protection_height">242dp</dimen>
    <dimen name="screenshot_preview_elevation">4dp</dimen>
    <dimen name="screenshot_preview_elevation">4dp</dimen>
    <dimen name="screenshot_offset_y">24dp</dimen>
    <dimen name="screenshot_offset_y">8dp</dimen>
    <dimen name="screenshot_offset_x">16dp</dimen>
    <dimen name="screenshot_offset_x">16dp</dimen>
    <dimen name="screenshot_dismiss_button_tappable_size">48dp</dimen>
    <dimen name="screenshot_dismiss_button_tappable_size">48dp</dimen>
    <dimen name="screenshot_dismiss_button_margin">8dp</dimen>
    <dimen name="screenshot_dismiss_button_margin">8dp</dimen>
    <dimen name="screenshot_action_container_offset_y">16dp</dimen>
    <dimen name="screenshot_action_container_corner_radius">18dp</dimen>
    <dimen name="screenshot_action_container_corner_radius">18dp</dimen>
    <dimen name="screenshot_action_container_padding_vertical">4dp</dimen>
    <dimen name="screenshot_action_container_padding_vertical">4dp</dimen>
    <dimen name="screenshot_action_container_margin_horizontal">8dp</dimen>
    <dimen name="screenshot_action_container_margin_horizontal">8dp</dimen>
+4 −5
Original line number Original line Diff line number Diff line
@@ -559,8 +559,8 @@ public class ScreenshotController {
            mScreenshotView.reset();
            mScreenshotView.reset();
        }
        }


        mScreenshotView.updateOrientation(mWindowManager.getCurrentWindowMetrics()
        mScreenshotView.updateOrientation(
                .getWindowInsets().getDisplayCutout());
                mWindowManager.getCurrentWindowMetrics().getWindowInsets());


        mScreenBitmap = screenshot;
        mScreenBitmap = screenshot;


@@ -594,9 +594,8 @@ public class ScreenshotController {
                            // Delay scroll capture eval a bit to allow the underlying activity
                            // Delay scroll capture eval a bit to allow the underlying activity
                            // to set up in the new orientation.
                            // to set up in the new orientation.
                            mScreenshotHandler.postDelayed(this::requestScrollCapture, 150);
                            mScreenshotHandler.postDelayed(this::requestScrollCapture, 150);
                            mScreenshotView.updateDisplayCutoutMargins(
                            mScreenshotView.updateInsets(
                                    mWindowManager.getCurrentWindowMetrics().getWindowInsets()
                                    mWindowManager.getCurrentWindowMetrics().getWindowInsets());
                                            .getDisplayCutout());
                            // screenshot animation calculations won't be valid anymore, so just end
                            // screenshot animation calculations won't be valid anymore, so just end
                            if (mScreenshotAnimation != null && mScreenshotAnimation.isRunning()) {
                            if (mScreenshotAnimation != null && mScreenshotAnimation.isRunning()) {
                                mScreenshotAnimation.end();
                                mScreenshotAnimation.end();
+17 −8
Original line number Original line Diff line number Diff line
@@ -416,21 +416,30 @@ public class ScreenshotView extends FrameLayout implements
        mScreenshotPreview.setImageDrawable(createScreenDrawable(mResources, bitmap, screenInsets));
        mScreenshotPreview.setImageDrawable(createScreenDrawable(mResources, bitmap, screenInsets));
    }
    }


    void updateDisplayCutoutMargins(DisplayCutout cutout) {
    void updateInsets(WindowInsets insets) {
        int orientation = mContext.getResources().getConfiguration().orientation;
        int orientation = mContext.getResources().getConfiguration().orientation;
        mOrientationPortrait = (orientation == ORIENTATION_PORTRAIT);
        mOrientationPortrait = (orientation == ORIENTATION_PORTRAIT);
        FrameLayout.LayoutParams p =
        FrameLayout.LayoutParams p =
                (FrameLayout.LayoutParams) mScreenshotStatic.getLayoutParams();
                (FrameLayout.LayoutParams) mScreenshotStatic.getLayoutParams();
        DisplayCutout cutout = insets.getDisplayCutout();
        Insets navBarInsets = insets.getInsets(WindowInsets.Type.navigationBars());
        if (cutout == null) {
        if (cutout == null) {
            p.setMargins(0, 0, 0, 0);
            p.setMargins(0, 0, 0, navBarInsets.bottom);
        } else {
        } else {
            Insets waterfall = cutout.getWaterfallInsets();
            Insets waterfall = cutout.getWaterfallInsets();
            if (mOrientationPortrait) {
            if (mOrientationPortrait) {
                p.setMargins(waterfall.left, Math.max(cutout.getSafeInsetTop(), waterfall.top),
                p.setMargins(
                        waterfall.right, Math.max(cutout.getSafeInsetBottom(), waterfall.bottom));
                        waterfall.left,
                        Math.max(cutout.getSafeInsetTop(), waterfall.top),
                        waterfall.right,
                        Math.max(cutout.getSafeInsetBottom(),
                                Math.max(navBarInsets.bottom, waterfall.bottom)));
            } else {
            } else {
                p.setMargins(Math.max(cutout.getSafeInsetLeft(), waterfall.left), waterfall.top,
                p.setMargins(
                        Math.max(cutout.getSafeInsetRight(), waterfall.right), waterfall.bottom);
                        Math.max(cutout.getSafeInsetLeft(), waterfall.left),
                        waterfall.top,
                        Math.max(cutout.getSafeInsetRight(), waterfall.right),
                        Math.max(navBarInsets.bottom, waterfall.bottom));
            }
            }
        }
        }
        mStaticLeftMargin = p.leftMargin;
        mStaticLeftMargin = p.leftMargin;
@@ -438,10 +447,10 @@ public class ScreenshotView extends FrameLayout implements
        mScreenshotStatic.requestLayout();
        mScreenshotStatic.requestLayout();
    }
    }


    void updateOrientation(DisplayCutout cutout) {
    void updateOrientation(WindowInsets insets) {
        int orientation = mContext.getResources().getConfiguration().orientation;
        int orientation = mContext.getResources().getConfiguration().orientation;
        mOrientationPortrait = (orientation == ORIENTATION_PORTRAIT);
        mOrientationPortrait = (orientation == ORIENTATION_PORTRAIT);
        updateDisplayCutoutMargins(cutout);
        updateInsets(insets);
        int screenshotFixedSize =
        int screenshotFixedSize =
                mContext.getResources().getDimensionPixelSize(R.dimen.global_screenshot_x_scale);
                mContext.getResources().getDimensionPixelSize(R.dimen.global_screenshot_x_scale);
        ViewGroup.LayoutParams params = mScreenshotPreview.getLayoutParams();
        ViewGroup.LayoutParams params = mScreenshotPreview.getLayoutParams();