Merge "Move screenshot UI to avoid covering nav bar" into sc-qpr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
7fd08a9f57
@@ -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"
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user