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

Commit 036e9fab 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 am: feed5a8d

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

Change-Id: I3c9741d2d29a424e961a64a3e4347395c99cb149
parents 922ddf82 feed5a8d
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        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:paddingVertical="@dimen/screenshot_action_container_padding_vertical"
        android:elevation="1dp"
+1 −2
Original line number Diff line number Diff line
@@ -328,11 +328,10 @@
    <dimen name="global_screenshot_x_scale">80dp</dimen>
    <dimen name="screenshot_bg_protection_height">242dp</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_dismiss_button_tappable_size">48dp</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_padding_vertical">4dp</dimen>
    <dimen name="screenshot_action_container_margin_horizontal">8dp</dimen>
+4 −5
Original line number Diff line number Diff line
@@ -559,8 +559,8 @@ public class ScreenshotController {
            mScreenshotView.reset();
        }

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

        mScreenBitmap = screenshot;

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

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

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