diff options
3 files changed, 21 insertions, 26 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIWindowManagerAbstract.java b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIWindowManagerAbstract.java index bdf9d513f298..7014fcc0e874 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIWindowManagerAbstract.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIWindowManagerAbstract.java @@ -140,11 +140,8 @@ public abstract class CompatUIWindowManagerAbstract extends WindowlessWindowMana /** * Whether the layout is eligible to be shown according to the internal state of the subclass. - * Returns true by default if subclass doesn't override this method. */ - protected boolean eligibleToShowLayout() { - return true; - } + protected abstract boolean eligibleToShowLayout(); @Override public void setConfiguration(Configuration configuration) { @@ -214,8 +211,7 @@ public abstract class CompatUIWindowManagerAbstract extends WindowlessWindowMana boolean layoutDirectionUpdated = mTaskConfig.getLayoutDirection() != prevTaskConfig.getLayoutDirection(); if (boundsUpdated || layoutDirectionUpdated) { - // Reposition the UI surfaces. - updateSurfacePosition(); + updateSurface(); } if (layout != null && layoutDirectionUpdated) { @@ -226,7 +222,6 @@ public abstract class CompatUIWindowManagerAbstract extends WindowlessWindowMana return true; } - /** * Updates the visibility of the layout. * @@ -253,8 +248,7 @@ public abstract class CompatUIWindowManagerAbstract extends WindowlessWindowMana displayLayout.getStableBounds(curStableBounds); mDisplayLayout = displayLayout; if (!prevStableBounds.equals(curStableBounds)) { - // Stable bounds changed, update UI surface positions. - updateSurfacePosition(); + updateSurface(); mStableBounds.set(curStableBounds); } } @@ -304,6 +298,14 @@ public abstract class CompatUIWindowManagerAbstract extends WindowlessWindowMana } /** + * Updates the surface following a change in the task bounds, display layout stable bounds, + * or the layout direction. + */ + protected void updateSurface() { + updateSurfacePosition(); + } + + /** * Updates the position of the surface with respect to the task bounds and display layout * stable bounds. */ diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterboxedu/LetterboxEduDialogLayout.java b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterboxedu/LetterboxEduDialogLayout.java index b22b829eebd8..bc1d19bfcec2 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterboxedu/LetterboxEduDialogLayout.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterboxedu/LetterboxEduDialogLayout.java @@ -36,8 +36,6 @@ class LetterboxEduDialogLayout extends FrameLayout { // The alpha of a background is a number between 0 (fully transparent) to 255 (fully opaque). // 204 is simply 255 * 0.8. static final int BACKGROUND_DIM_ALPHA = 204; - - private LetterboxEduWindowManager mWindowManager; private View mDialogContainer; private Drawable mBackgroundDim; @@ -58,10 +56,6 @@ class LetterboxEduDialogLayout extends FrameLayout { super(context, attrs, defStyleAttr, defStyleRes); } - void inject(LetterboxEduWindowManager windowManager) { - mWindowManager = windowManager; - } - View getDialogContainer() { return mDialogContainer; } @@ -70,13 +64,6 @@ class LetterboxEduDialogLayout extends FrameLayout { return mBackgroundDim; } - @Override - protected void onLayout(boolean changed, int left, int top, int right, int bottom) { - super.onLayout(changed, left, top, right, bottom); - // Need to relayout after visibility changes since they affect size. - mWindowManager.relayout(); - } - /** * Register a callback for the dismiss button and background dim. * diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterboxedu/LetterboxEduWindowManager.java b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterboxedu/LetterboxEduWindowManager.java index d5aefb1a7e5c..c461ebcb55ea 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterboxedu/LetterboxEduWindowManager.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterboxedu/LetterboxEduWindowManager.java @@ -103,7 +103,6 @@ public class LetterboxEduWindowManager extends CompatUIWindowManagerAbstract { protected View createLayout() { setSeenLetterboxEducation(); mLayout = inflateLayout(); - mLayout.inject(this); mAnimationController.startEnterAnimation(mLayout, /* endCallback= */ this::setDismissOnClickListener); @@ -145,15 +144,22 @@ public class LetterboxEduWindowManager extends CompatUIWindowManagerAbstract { } @Override + protected void updateSurface() { + // We need to relayout because the layout dimensions depend on the task bounds. + relayout(); + } + + @Override protected void updateSurfacePosition(Rect taskBounds, Rect stableBounds) { - updateSurfacePosition(/* positionX= */ taskBounds.left, /* positionY= */ taskBounds.top); + // Nothing to do, since the position of the surface is fixed to the top left corner (0,0) + // of the task (parent surface), which is the default position of a surface. } @Override protected WindowManager.LayoutParams getWindowLayoutParams() { final Rect taskBounds = mTaskConfig.windowConfiguration.getBounds(); - return getWindowLayoutParams(/* width= */ taskBounds.right - taskBounds.left, - /* height= */ taskBounds.bottom - taskBounds.top); + return getWindowLayoutParams(/* width= */ taskBounds.width(), /* height= */ + taskBounds.height()); } private boolean getHasSeenLetterboxEducation() { |