Merge "Support WIC.show(IME) from Activity#onCreate" into rvc-dev am: 104919428d am: 6fcb222882 am: 2d7bc73c46
Change-Id: Idb0b2b9fbdb00f3d44b5e1c0f440e8fabbbee9e1
This commit is contained in:
@@ -49,7 +49,7 @@ public final class ImeInsetsSourceConsumer extends InsetsSourceConsumer {
|
|||||||
* Tracks whether we have an outstanding request from the IME to show, but weren't able to
|
* Tracks whether we have an outstanding request from the IME to show, but weren't able to
|
||||||
* execute it because we didn't have control yet.
|
* execute it because we didn't have control yet.
|
||||||
*/
|
*/
|
||||||
private boolean mImeRequestedShow;
|
private boolean mIsRequestedVisibleAwaitingControl;
|
||||||
|
|
||||||
public ImeInsetsSourceConsumer(
|
public ImeInsetsSourceConsumer(
|
||||||
InsetsState state, Supplier<Transaction> transactionSupplier,
|
InsetsState state, Supplier<Transaction> transactionSupplier,
|
||||||
@@ -88,15 +88,7 @@ public final class ImeInsetsSourceConsumer extends InsetsSourceConsumer {
|
|||||||
public void onWindowFocusLost() {
|
public void onWindowFocusLost() {
|
||||||
super.onWindowFocusLost();
|
super.onWindowFocusLost();
|
||||||
getImm().unregisterImeConsumer(this);
|
getImm().unregisterImeConsumer(this);
|
||||||
mImeRequestedShow = false;
|
mIsRequestedVisibleAwaitingControl = false;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void show(boolean fromIme) {
|
|
||||||
super.show(fromIme);
|
|
||||||
if (fromIme) {
|
|
||||||
mImeRequestedShow = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -119,11 +111,14 @@ public final class ImeInsetsSourceConsumer extends InsetsSourceConsumer {
|
|||||||
// TODO: ResultReceiver for IME.
|
// TODO: ResultReceiver for IME.
|
||||||
// TODO: Set mShowOnNextImeRender to automatically show IME and guard it with a flag.
|
// TODO: Set mShowOnNextImeRender to automatically show IME and guard it with a flag.
|
||||||
|
|
||||||
|
if (getControl() == null) {
|
||||||
|
// If control is null, schedule to show IME when control is available.
|
||||||
|
mIsRequestedVisibleAwaitingControl = true;
|
||||||
|
}
|
||||||
// If we had a request before to show from IME (tracked with mImeRequestedShow), reaching
|
// If we had a request before to show from IME (tracked with mImeRequestedShow), reaching
|
||||||
// this code here means that we now got control, so we can start the animation immediately.
|
// this code here means that we now got control, so we can start the animation immediately.
|
||||||
// If client window is trying to control IME and IME is already visible, it is immediate.
|
// If client window is trying to control IME and IME is already visible, it is immediate.
|
||||||
if (fromIme || mImeRequestedShow || mState.getSource(getType()).isVisible()) {
|
if (fromIme || mState.getSource(getType()).isVisible()) {
|
||||||
mImeRequestedShow = false;
|
|
||||||
return ShowResult.SHOW_IMMEDIATELY;
|
return ShowResult.SHOW_IMMEDIATELY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,11 +143,19 @@ public final class ImeInsetsSourceConsumer extends InsetsSourceConsumer {
|
|||||||
public void setControl(@Nullable InsetsSourceControl control, int[] showTypes,
|
public void setControl(@Nullable InsetsSourceControl control, int[] showTypes,
|
||||||
int[] hideTypes) {
|
int[] hideTypes) {
|
||||||
super.setControl(control, showTypes, hideTypes);
|
super.setControl(control, showTypes, hideTypes);
|
||||||
if (control == null) {
|
if (control == getControl()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (control == null && !mIsRequestedVisibleAwaitingControl) {
|
||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isRequestedVisibleAwaitingControl() {
|
||||||
|
return mIsRequestedVisibleAwaitingControl;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isDummyOrEmptyEditor(EditorInfo info) {
|
private boolean isDummyOrEmptyEditor(EditorInfo info) {
|
||||||
// TODO(b/123044812): Handle dummy input gracefully in IME Insets API
|
// TODO(b/123044812): Handle dummy input gracefully in IME Insets API
|
||||||
return info == null || (info.fieldId <= 0 && info.inputType <= 0);
|
return info == null || (info.fieldId <= 0 && info.inputType <= 0);
|
||||||
|
|||||||
@@ -107,8 +107,8 @@ public class InsetsSourceConsumer {
|
|||||||
} else {
|
} else {
|
||||||
// We are gaining control, and need to run an animation since previous state
|
// We are gaining control, and need to run an animation since previous state
|
||||||
// didn't match
|
// didn't match
|
||||||
if (mRequestedVisible != mState.getSource(mType).isVisible()) {
|
if (isRequestedVisibleAwaitingControl() != mState.getSource(mType).isVisible()) {
|
||||||
if (mRequestedVisible) {
|
if (isRequestedVisibleAwaitingControl()) {
|
||||||
showTypes[0] |= toPublicType(getType());
|
showTypes[0] |= toPublicType(getType());
|
||||||
} else {
|
} else {
|
||||||
hideTypes[0] |= toPublicType(getType());
|
hideTypes[0] |= toPublicType(getType());
|
||||||
@@ -138,6 +138,16 @@ public class InsetsSourceConsumer {
|
|||||||
return mSourceControl;
|
return mSourceControl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if the consumer will be shown after control is available.
|
||||||
|
* Note: for system bars this method is same as {@link #isRequestedVisible()}.
|
||||||
|
*
|
||||||
|
* @return {@code true} if consumer has a pending show.
|
||||||
|
*/
|
||||||
|
protected boolean isRequestedVisibleAwaitingControl() {
|
||||||
|
return isRequestedVisible();
|
||||||
|
}
|
||||||
|
|
||||||
int getType() {
|
int getType() {
|
||||||
return mType;
|
return mType;
|
||||||
}
|
}
|
||||||
@@ -263,7 +273,7 @@ public class InsetsSourceConsumer {
|
|||||||
* Sets requested visibility from the client, regardless of whether we are able to control it at
|
* Sets requested visibility from the client, regardless of whether we are able to control it at
|
||||||
* the moment.
|
* the moment.
|
||||||
*/
|
*/
|
||||||
private void setRequestedVisible(boolean requestedVisible) {
|
protected void setRequestedVisible(boolean requestedVisible) {
|
||||||
mRequestedVisible = requestedVisible;
|
mRequestedVisible = requestedVisible;
|
||||||
if (applyLocalVisibilityOverride()) {
|
if (applyLocalVisibilityOverride()) {
|
||||||
mController.notifyVisibilityChanged();
|
mController.notifyVisibilityChanged();
|
||||||
|
|||||||
Reference in New Issue
Block a user