Merge "Add support for floating IME to split-screen" into rvc-dev
This commit is contained in:
@@ -56,12 +56,14 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
|
|||||||
|
|
||||||
private static final boolean DEBUG = false;
|
private static final boolean DEBUG = false;
|
||||||
|
|
||||||
|
// NOTE: All these constants came from InsetsController.
|
||||||
public static final int ANIMATION_DURATION_SHOW_MS = 275;
|
public static final int ANIMATION_DURATION_SHOW_MS = 275;
|
||||||
public static final int ANIMATION_DURATION_HIDE_MS = 340;
|
public static final int ANIMATION_DURATION_HIDE_MS = 340;
|
||||||
public static final Interpolator INTERPOLATOR = new PathInterpolator(0.4f, 0f, 0.2f, 1f);
|
public static final Interpolator INTERPOLATOR = new PathInterpolator(0.4f, 0f, 0.2f, 1f);
|
||||||
private static final int DIRECTION_NONE = 0;
|
private static final int DIRECTION_NONE = 0;
|
||||||
private static final int DIRECTION_SHOW = 1;
|
private static final int DIRECTION_SHOW = 1;
|
||||||
private static final int DIRECTION_HIDE = 2;
|
private static final int DIRECTION_HIDE = 2;
|
||||||
|
private static final int FLOATING_IME_BOTTOM_INSET = -80;
|
||||||
|
|
||||||
SystemWindows mSystemWindows;
|
SystemWindows mSystemWindows;
|
||||||
final Handler mHandler;
|
final Handler mHandler;
|
||||||
@@ -271,8 +273,16 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
|
|||||||
}
|
}
|
||||||
// Set frame, but only if the new frame isn't empty -- this maintains continuity
|
// Set frame, but only if the new frame isn't empty -- this maintains continuity
|
||||||
final Rect newFrame = imeSource.getFrame();
|
final Rect newFrame = imeSource.getFrame();
|
||||||
if (newFrame.height() != 0) {
|
|
||||||
mImeFrame.set(newFrame);
|
mImeFrame.set(newFrame);
|
||||||
|
final boolean isFloating = newFrame.height() == 0;
|
||||||
|
if (isFloating) {
|
||||||
|
// This is likely a "floating" or "expanded" IME, so to get animations, just
|
||||||
|
// pretend the ime has some size just below the screen.
|
||||||
|
mImeFrame.set(newFrame);
|
||||||
|
final int floatingInset = (int) (
|
||||||
|
mSystemWindows.mDisplayController.getDisplayLayout(mDisplayId).density()
|
||||||
|
* FLOATING_IME_BOTTOM_INSET);
|
||||||
|
mImeFrame.bottom -= floatingInset;
|
||||||
}
|
}
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Slog.d(TAG, "Run startAnim show:" + show + " was:"
|
Slog.d(TAG, "Run startAnim show:" + show + " was:"
|
||||||
@@ -316,6 +326,8 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
|
|||||||
SurfaceControl.Transaction t = mTransactionPool.acquire();
|
SurfaceControl.Transaction t = mTransactionPool.acquire();
|
||||||
float value = (float) animation.getAnimatedValue();
|
float value = (float) animation.getAnimatedValue();
|
||||||
t.setPosition(mImeSourceControl.getLeash(), x, value);
|
t.setPosition(mImeSourceControl.getLeash(), x, value);
|
||||||
|
final float alpha = isFloating ? (value - hiddenY) / (shownY - hiddenY) : 1.f;
|
||||||
|
t.setAlpha(mImeSourceControl.getLeash(), alpha);
|
||||||
dispatchPositionChanged(mDisplayId, imeTop(value), t);
|
dispatchPositionChanged(mDisplayId, imeTop(value), t);
|
||||||
t.apply();
|
t.apply();
|
||||||
mTransactionPool.release(t);
|
mTransactionPool.release(t);
|
||||||
@@ -327,6 +339,8 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
|
|||||||
public void onAnimationStart(Animator animation) {
|
public void onAnimationStart(Animator animation) {
|
||||||
SurfaceControl.Transaction t = mTransactionPool.acquire();
|
SurfaceControl.Transaction t = mTransactionPool.acquire();
|
||||||
t.setPosition(mImeSourceControl.getLeash(), x, startY);
|
t.setPosition(mImeSourceControl.getLeash(), x, startY);
|
||||||
|
final float alpha = isFloating ? (startY - hiddenY) / (shownY - hiddenY) : 1.f;
|
||||||
|
t.setAlpha(mImeSourceControl.getLeash(), alpha);
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Slog.d(TAG, "onAnimationStart d:" + mDisplayId + " top:"
|
Slog.d(TAG, "onAnimationStart d:" + mDisplayId + " top:"
|
||||||
+ imeTop(hiddenY) + "->" + imeTop(shownY)
|
+ imeTop(hiddenY) + "->" + imeTop(shownY)
|
||||||
@@ -351,6 +365,7 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
|
|||||||
SurfaceControl.Transaction t = mTransactionPool.acquire();
|
SurfaceControl.Transaction t = mTransactionPool.acquire();
|
||||||
if (!mCancelled) {
|
if (!mCancelled) {
|
||||||
t.setPosition(mImeSourceControl.getLeash(), x, endY);
|
t.setPosition(mImeSourceControl.getLeash(), x, endY);
|
||||||
|
t.setAlpha(mImeSourceControl.getLeash(), 1.f);
|
||||||
}
|
}
|
||||||
dispatchEndPositioning(mDisplayId, mCancelled, t);
|
dispatchEndPositioning(mDisplayId, mCancelled, t);
|
||||||
if (mAnimationDirection == DIRECTION_HIDE && !mCancelled) {
|
if (mAnimationDirection == DIRECTION_HIDE && !mCancelled) {
|
||||||
|
|||||||
Reference in New Issue
Block a user