Merge "Don't apply ime adjustments/dims if split is not active" into rvc-dev

This commit is contained in:
TreeHugger Robot
2020-03-11 20:55:17 +00:00
committed by Android (Google) Code Review
2 changed files with 35 additions and 15 deletions

View File

@@ -148,6 +148,8 @@ public class Divider extends SystemUI implements DividerView.DividerCallbacks,
* regardless of what has focus. * regardless of what has focus.
*/ */
private boolean mTargetShown = false; private boolean mTargetShown = false;
private float mTargetPrimaryDim = 0.f;
private float mTargetSecondaryDim = 0.f;
// The following are the current (most recent) states set during animation // The following are the current (most recent) states set during animation
/** {@code true} if the secondary split has IME focus. */ /** {@code true} if the secondary split has IME focus. */
@@ -186,8 +188,12 @@ public class Divider extends SystemUI implements DividerView.DividerCallbacks,
@Override @Override
public void onImeStartPositioning(int displayId, int hiddenTop, int shownTop, public void onImeStartPositioning(int displayId, int hiddenTop, int shownTop,
boolean imeShouldShow, SurfaceControl.Transaction t) { boolean imeShouldShow, SurfaceControl.Transaction t) {
if (!inSplitMode()) {
return;
}
final boolean splitIsVisible = !mView.isHidden();
mSecondaryHasFocus = getSecondaryHasFocus(displayId); mSecondaryHasFocus = getSecondaryHasFocus(displayId);
mTargetAdjusted = imeShouldShow && mSecondaryHasFocus mTargetAdjusted = splitIsVisible && imeShouldShow && mSecondaryHasFocus
&& !mSplitLayout.mDisplayLayout.isLandscape(); && !mSplitLayout.mDisplayLayout.isLandscape();
mHiddenTop = hiddenTop; mHiddenTop = hiddenTop;
mShownTop = shownTop; mShownTop = shownTop;
@@ -195,6 +201,10 @@ public class Divider extends SystemUI implements DividerView.DividerCallbacks,
if (mLastAdjustTop < 0) { if (mLastAdjustTop < 0) {
mLastAdjustTop = imeShouldShow ? hiddenTop : shownTop; mLastAdjustTop = imeShouldShow ? hiddenTop : shownTop;
} }
mTargetPrimaryDim = (mSecondaryHasFocus && mTargetShown && splitIsVisible)
? ADJUSTED_NONFOCUS_DIM : 0.f;
mTargetSecondaryDim = (!mSecondaryHasFocus && mTargetShown && splitIsVisible)
? ADJUSTED_NONFOCUS_DIM : 0.f;
if (mAnimation != null || (mImeWasShown && imeShouldShow if (mAnimation != null || (mImeWasShown && imeShouldShow
&& mTargetAdjusted != mAdjusted)) { && mTargetAdjusted != mAdjusted)) {
// We need to animate adjustment independently of the IME position, so // We need to animate adjustment independently of the IME position, so
@@ -202,8 +212,12 @@ public class Divider extends SystemUI implements DividerView.DividerCallbacks,
// different split's editor has gained focus while the IME is still visible. // different split's editor has gained focus while the IME is still visible.
startAsyncAnimation(); startAsyncAnimation();
} }
if (splitIsVisible) {
// If split is hidden, we don't want to trigger any relayouts that would cause the
// divider to show again.
updateImeAdjustState(); updateImeAdjustState();
} }
}
private void updateImeAdjustState() { private void updateImeAdjustState() {
// Reposition the server's secondary split position so that it evaluates // Reposition the server's secondary split position so that it evaluates
@@ -245,7 +259,7 @@ public class Divider extends SystemUI implements DividerView.DividerCallbacks,
@Override @Override
public void onImePositionChanged(int displayId, int imeTop, public void onImePositionChanged(int displayId, int imeTop,
SurfaceControl.Transaction t) { SurfaceControl.Transaction t) {
if (mAnimation != null) { if (mAnimation != null || !inSplitMode()) {
// Not synchronized with IME anymore, so return. // Not synchronized with IME anymore, so return.
return; return;
} }
@@ -257,7 +271,7 @@ public class Divider extends SystemUI implements DividerView.DividerCallbacks,
@Override @Override
public void onImeEndPositioning(int displayId, boolean cancelled, public void onImeEndPositioning(int displayId, boolean cancelled,
SurfaceControl.Transaction t) { SurfaceControl.Transaction t) {
if (mAnimation != null) { if (mAnimation != null || !inSplitMode()) {
// Not synchronized with IME anymore, so return. // Not synchronized with IME anymore, so return.
return; return;
} }
@@ -273,14 +287,10 @@ public class Divider extends SystemUI implements DividerView.DividerCallbacks,
mSplitLayout.mAdjustedSecondary); mSplitLayout.mAdjustedSecondary);
} }
final float invProg = 1.f - progress; final float invProg = 1.f - progress;
final float targetPrimaryDim =
(mSecondaryHasFocus && mTargetShown) ? ADJUSTED_NONFOCUS_DIM : 0.f;
final float targetSecondaryDim =
(!mSecondaryHasFocus && mTargetShown) ? ADJUSTED_NONFOCUS_DIM : 0.f;
mView.setResizeDimLayer(t, true /* primary */, mView.setResizeDimLayer(t, true /* primary */,
mLastPrimaryDim * invProg + progress * targetPrimaryDim); mLastPrimaryDim * invProg + progress * mTargetPrimaryDim);
mView.setResizeDimLayer(t, false /* primary */, mView.setResizeDimLayer(t, false /* primary */,
mLastSecondaryDim * invProg + progress * targetSecondaryDim); mLastSecondaryDim * invProg + progress * mTargetSecondaryDim);
} }
private void onEnd(boolean cancelled, SurfaceControl.Transaction t) { private void onEnd(boolean cancelled, SurfaceControl.Transaction t) {
@@ -289,10 +299,8 @@ public class Divider extends SystemUI implements DividerView.DividerCallbacks,
mAdjusted = mTargetAdjusted; mAdjusted = mTargetAdjusted;
mImeWasShown = mTargetShown; mImeWasShown = mTargetShown;
mLastAdjustTop = mAdjusted ? mShownTop : mHiddenTop; mLastAdjustTop = mAdjusted ? mShownTop : mHiddenTop;
mLastPrimaryDim = mLastPrimaryDim = mTargetPrimaryDim;
(mSecondaryHasFocus && mTargetShown) ? ADJUSTED_NONFOCUS_DIM : 0.f; mLastSecondaryDim = mTargetSecondaryDim;
mLastSecondaryDim =
(!mSecondaryHasFocus && mTargetShown) ? ADJUSTED_NONFOCUS_DIM : 0.f;
} }
} }

View File

@@ -165,6 +165,10 @@ public class DividerView extends FrameLayout implements OnTouchListener,
// The view is removed or in the process of been removed from the system. // The view is removed or in the process of been removed from the system.
private boolean mRemoved; private boolean mRemoved;
// Whether the surface for this view has been hidden regardless of actual visibility. This is
// used interact with keyguard.
private boolean mSurfaceHidden = false;
private final Handler mHandler = new Handler() { private final Handler mHandler = new Handler() {
@Override @Override
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
@@ -414,6 +418,10 @@ public class DividerView extends FrameLayout implements OnTouchListener,
/** Unlike setVisible, this directly hides the surface without changing view visibility. */ /** Unlike setVisible, this directly hides the surface without changing view visibility. */
void setHidden(boolean hidden) { void setHidden(boolean hidden) {
if (mSurfaceHidden == hidden) {
return;
}
mSurfaceHidden = hidden;
post(() -> { post(() -> {
final SurfaceControl sc = getWindowSurfaceControl(); final SurfaceControl sc = getWindowSurfaceControl();
if (sc == null) { if (sc == null) {
@@ -430,6 +438,10 @@ public class DividerView extends FrameLayout implements OnTouchListener,
}); });
} }
boolean isHidden() {
return mSurfaceHidden;
}
public boolean startDragging(boolean animate, boolean touching) { public boolean startDragging(boolean animate, boolean touching) {
cancelFlingAnimation(); cancelFlingAnimation();
if (touching) { if (touching) {
@@ -1071,7 +1083,7 @@ public class DividerView extends FrameLayout implements OnTouchListener,
void setResizeDimLayer(Transaction t, boolean primary, float alpha) { void setResizeDimLayer(Transaction t, boolean primary, float alpha) {
SurfaceControl dim = primary ? mTiles.mPrimaryDim : mTiles.mSecondaryDim; SurfaceControl dim = primary ? mTiles.mPrimaryDim : mTiles.mSecondaryDim;
if (alpha <= 0.f) { if (alpha <= 0.001f) {
t.hide(dim); t.hide(dim);
} else { } else {
t.setAlpha(dim, alpha); t.setAlpha(dim, alpha);