Skip to content
Snippets Groups Projects
Commit 02d4f227 authored by Tom Natan's avatar Tom Natan Committed by Android (Google) Code Review
Browse files

Merge "[12/n] Letterbox Education: relayout but don't update surface position when bounds change."

parents 2936a50e 3bb6ce2b
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
}
......@@ -303,6 +297,14 @@ public abstract class CompatUIWindowManagerAbstract extends WindowlessWindowMana
updateSurfacePosition();
}
/**
* 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.
......
......@@ -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.
*
......
......@@ -103,7 +103,6 @@ public class LetterboxEduWindowManager extends CompatUIWindowManagerAbstract {
protected View createLayout() {
setSeenLetterboxEducation();
mLayout = inflateLayout();
mLayout.inject(this);
mAnimationController.startEnterAnimation(mLayout, /* endCallback= */
this::setDismissOnClickListener);
......@@ -144,16 +143,23 @@ public class LetterboxEduWindowManager extends CompatUIWindowManagerAbstract {
return super.updateCompatInfo(taskInfo, taskListener, canShow);
}
@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() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment