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

Commit 9eb0f18a authored by Miranda Kephart's avatar Miranda Kephart
Browse files

Move screenshot UI to avoid covering nav bar

Bug: 193552343
Fix: 193552343
Test: manual; visual inspection
Change-Id: Idbf632c268cb753079d432cbe197f06e9abaf11d
parent e421c1c2
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
@@ -331,11 +331,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
@@ -414,21 +414,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;
@@ -436,10 +445,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();