diff --git a/packages/SystemUI/res/layout-land/global_screenshot_preview.xml b/packages/SystemUI/res/layout-land/global_screenshot_preview.xml
deleted file mode 100644
index 93664da997175..0000000000000
--- a/packages/SystemUI/res/layout-land/global_screenshot_preview.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java
index 7c2d4768fe8ff..1f9221c2956f4 100644
--- a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java
+++ b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java
@@ -401,9 +401,6 @@ public class ScreenshotController {
if (DEBUG_UI) {
Log.d(TAG, "reloadAssets()");
}
- if (mScreenshotView != null && mScreenshotView.isAttachedToWindow()) {
- mWindow.clearContentView(); // Is there a simpler way to say "remove screenshotView?"
- }
// respect the display cutout in landscape (since we'd otherwise overlap) but not portrait
int orientation = mContext.getResources().getConfiguration().orientation;
@@ -497,6 +494,17 @@ public class ScreenshotController {
saveScreenshot(screenshot, finisher, screenRect, Insets.NONE, true);
}
+ private void updateDisplayCutout() {
+ // respect the display cutout in landscape (since we'd otherwise overlap) but not portrait
+ int orientation = mContext.getResources().getConfiguration().orientation;
+ mWindowLayoutParams.setFitInsetsTypes(
+ orientation == ORIENTATION_PORTRAIT ? 0 : WindowInsets.Type.displayCutout());
+ final View decorView = mWindow.peekDecorView();
+ if (decorView != null && decorView.isAttachedToWindow()) {
+ mWindowManager.updateViewLayout(decorView, mWindowLayoutParams);
+ }
+ }
+
private void saveScreenshot(Bitmap screenshot, Consumer finisher, Rect screenRect,
Insets screenInsets, boolean showFlash) {
if (mAccessibilityManager.isEnabled()) {
@@ -507,12 +515,6 @@ public class ScreenshotController {
mAccessibilityManager.sendAccessibilityEvent(event);
}
- if (mConfigChanges.applyNewConfig(mContext.getResources())) {
- if (DEBUG_UI) {
- Log.d(TAG, "saveScreenshot: reloading assets");
- }
- reloadAssets();
- }
if (mScreenshotView.isAttachedToWindow()) {
// if we didn't already dismiss for another reason
@@ -526,6 +528,9 @@ public class ScreenshotController {
mScreenshotView.reset();
}
+ int orientation = mContext.getResources().getConfiguration().orientation;
+ mScreenshotView.updateOrientation(orientation == ORIENTATION_PORTRAIT);
+
mScreenBitmap = screenshot;
if (!isUserSetupComplete()) {
@@ -556,6 +561,12 @@ public class ScreenshotController {
mLastScrollCaptureRequest = mScrollCaptureClient.request(DEFAULT_DISPLAY);
mLastScrollCaptureRequest.addListener(() ->
onScrollCaptureResponseReady(mLastScrollCaptureRequest), mMainExecutor);
+ mWindow.peekDecorView().getViewRootImpl().setActivityConfigCallback(
+ (overrideConfig, newDisplayId) -> {
+ if (mConfigChanges.applyNewConfig(mContext.getResources())) {
+ updateDisplayCutout();
+ }
+ });
});
attachWindow();
diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotView.java b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotView.java
index 70b11337db934..71a152dd961e7 100644
--- a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotView.java
+++ b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotView.java
@@ -60,6 +60,7 @@ import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.TouchDelegate;
import android.view.View;
+import android.view.ViewGroup;
import android.view.ViewOutlineProvider;
import android.view.ViewTreeObserver;
import android.view.WindowInsets;
@@ -350,6 +351,23 @@ public class ScreenshotView extends FrameLayout implements
mScreenshotPreview.setImageDrawable(createScreenDrawable(mResources, bitmap, screenInsets));
}
+ void updateOrientation(boolean portrait) {
+ mOrientationPortrait = portrait;
+ int screenshotFixedSize =
+ mContext.getResources().getDimensionPixelSize(R.dimen.global_screenshot_x_scale);
+ ViewGroup.LayoutParams params = mScreenshotPreview.getLayoutParams();
+ if (portrait) {
+ params.width = screenshotFixedSize;
+ params.height = LayoutParams.WRAP_CONTENT;
+ mScreenshotPreview.setScaleType(ImageView.ScaleType.FIT_START);
+ } else {
+ params.width = LayoutParams.WRAP_CONTENT;
+ params.height = screenshotFixedSize;
+ mScreenshotPreview.setScaleType(ImageView.ScaleType.FIT_END);
+ }
+ mScreenshotPreview.setLayoutParams(params);
+ }
+
AnimatorSet createScreenshotDropInAnimation(Rect bounds, boolean showFlash) {
if (DEBUG_ANIM) {
Log.d(TAG, "createAnim: bounds=" + bounds + " showFlash=" + showFlash);