Merge "Hide the IME using InputMethodManagerInternal, because doing it that way actually works." into rvc-dev am: 88e88190eb am: 644d1add13

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11948939

Change-Id: I397b60e0ccb776d7b34789fd8c7cd8fe15cae45b
This commit is contained in:
Josh Tsuji
2020-06-24 03:04:16 +00:00
committed by Automerger Merge Worker
6 changed files with 54 additions and 27 deletions

View File

@@ -46,7 +46,8 @@ import java.lang.annotation.Retention;
SoftInputShowHideReason.HIDE_SETTINGS_ON_CHANGE, SoftInputShowHideReason.HIDE_SETTINGS_ON_CHANGE,
SoftInputShowHideReason.HIDE_POWER_BUTTON_GO_HOME, SoftInputShowHideReason.HIDE_POWER_BUTTON_GO_HOME,
SoftInputShowHideReason.HIDE_DOCKED_STACK_ATTACHED, SoftInputShowHideReason.HIDE_DOCKED_STACK_ATTACHED,
SoftInputShowHideReason.HIDE_RECENTS_ANIMATION}) SoftInputShowHideReason.HIDE_RECENTS_ANIMATION,
SoftInputShowHideReason.HIDE_BUBBLES})
public @interface SoftInputShowHideReason { public @interface SoftInputShowHideReason {
/** Show soft input by {@link android.view.inputmethod.InputMethodManager#showSoftInput}. */ /** Show soft input by {@link android.view.inputmethod.InputMethodManager#showSoftInput}. */
int SHOW_SOFT_INPUT = 0; int SHOW_SOFT_INPUT = 0;
@@ -140,4 +141,10 @@ public @interface SoftInputShowHideReason {
* intercept touch from app window. * intercept touch from app window.
*/ */
int HIDE_RECENTS_ANIMATION = 18; int HIDE_RECENTS_ANIMATION = 18;
/**
* Hide soft input when {@link com.android.systemui.bubbles.BubbleController} is expanding,
* switching, or collapsing Bubbles.
*/
int HIDE_BUBBLES = 19;
} }

View File

@@ -79,6 +79,7 @@ interface IStatusBarService
void onNotificationSettingsViewed(String key); void onNotificationSettingsViewed(String key);
void onNotificationBubbleChanged(String key, boolean isBubble, int flags); void onNotificationBubbleChanged(String key, boolean isBubble, int flags);
void onBubbleNotificationSuppressionChanged(String key, boolean isSuppressed); void onBubbleNotificationSuppressionChanged(String key, boolean isSuppressed);
void hideCurrentInputMethodForBubbles();
void grantInlineReplyUriPermission(String key, in Uri uri, in UserHandle user, String packageName); void grantInlineReplyUriPermission(String key, in Uri uri, in UserHandle user, String packageName);
void clearInlineReplyUriPermissions(String key); void clearInlineReplyUriPermissions(String key);

View File

@@ -483,12 +483,13 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
} }
/** /**
* Dispatches a back press into the expanded Bubble's ActivityView if its IME is visible, * Hides the current input method, wherever it may be focused, via InputMethodManagerInternal.
* causing it to hide.
*/ */
public void hideImeFromExpandedBubble() { public void hideCurrentInputMethod() {
if (mStackView != null) { try {
mStackView.hideImeFromExpandedBubble(); mBarService.hideCurrentInputMethodForBubbles();
} catch (RemoteException e) {
e.printStackTrace();
} }
} }
@@ -693,8 +694,8 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
if (mStackView == null) { if (mStackView == null) {
mStackView = new BubbleStackView( mStackView = new BubbleStackView(
mContext, mBubbleData, mSurfaceSynchronizer, mFloatingContentCoordinator, mContext, mBubbleData, mSurfaceSynchronizer, mFloatingContentCoordinator,
mSysUiState, this::onAllBubblesAnimatedOut, mSysUiState, this::onAllBubblesAnimatedOut, this::onImeVisibilityChanged,
this::onImeVisibilityChanged); this::hideCurrentInputMethod);
mStackView.addView(mBubbleScrim); mStackView.addView(mBubbleScrim);
if (mExpandListener != null) { if (mExpandListener != null) {
mStackView.setExpandListener(mExpandListener); mStackView.setExpandListener(mExpandListener);
@@ -1589,7 +1590,11 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
@Override @Override
public void onBackPressedOnTaskRoot(RunningTaskInfo taskInfo) { public void onBackPressedOnTaskRoot(RunningTaskInfo taskInfo) {
if (mStackView != null && taskInfo.displayId == getExpandedDisplayId(mContext)) { if (mStackView != null && taskInfo.displayId == getExpandedDisplayId(mContext)) {
mBubbleData.setExpanded(false); if (mImeVisible) {
hideCurrentInputMethod();
} else {
mBubbleData.setExpanded(false);
}
} }
} }

View File

@@ -466,7 +466,6 @@ public class BubbleExpandedView extends LinearLayout {
@Override @Override
protected void onDetachedFromWindow() { protected void onDetachedFromWindow() {
super.onDetachedFromWindow(); super.onDetachedFromWindow();
hideImeIfVisible();
mKeyboardVisible = false; mKeyboardVisible = false;
mNeedsNewHeight = false; mNeedsNewHeight = false;
if (mActivityView != null) { if (mActivityView != null) {

View File

@@ -383,6 +383,11 @@ public class BubbleStackView extends FrameLayout
*/ */
public final Consumer<Boolean> mOnImeVisibilityChanged; public final Consumer<Boolean> mOnImeVisibilityChanged;
/**
* Callback to run to ask BubbleController to hide the current IME.
*/
private final Runnable mHideCurrentInputMethodCallback;
/** /**
* The currently magnetized object, which is being dragged and will be attracted to the magnetic * The currently magnetized object, which is being dragged and will be attracted to the magnetic
* dismiss target. * dismiss target.
@@ -560,7 +565,7 @@ public class BubbleStackView extends FrameLayout
mMagneticTarget, mMagneticTarget,
mIndividualBubbleMagnetListener); mIndividualBubbleMagnetListener);
hideImeFromExpandedBubble(); hideCurrentInputMethod();
// Save the magnetized individual bubble so we can dispatch touch events to it. // Save the magnetized individual bubble so we can dispatch touch events to it.
mMagnetizedObject = mExpandedAnimationController.getMagnetizedBubbleDraggingOut(); mMagnetizedObject = mExpandedAnimationController.getMagnetizedBubbleDraggingOut();
@@ -732,7 +737,8 @@ public class BubbleStackView extends FrameLayout
FloatingContentCoordinator floatingContentCoordinator, FloatingContentCoordinator floatingContentCoordinator,
SysUiState sysUiState, SysUiState sysUiState,
Runnable allBubblesAnimatedOutAction, Runnable allBubblesAnimatedOutAction,
Consumer<Boolean> onImeVisibilityChanged) { Consumer<Boolean> onImeVisibilityChanged,
Runnable hideCurrentInputMethodCallback) {
super(context); super(context);
mBubbleData = data; mBubbleData = data;
@@ -868,6 +874,7 @@ public class BubbleStackView extends FrameLayout
setUpOverflow(); setUpOverflow();
mOnImeVisibilityChanged = onImeVisibilityChanged; mOnImeVisibilityChanged = onImeVisibilityChanged;
mHideCurrentInputMethodCallback = hideCurrentInputMethodCallback;
setOnApplyWindowInsetsListener((View view, WindowInsets insets) -> { setOnApplyWindowInsetsListener((View view, WindowInsets insets) -> {
onImeVisibilityChanged.accept(insets.getInsets(WindowInsets.Type.ime()).bottom > 0); onImeVisibilityChanged.accept(insets.getInsets(WindowInsets.Type.ime()).bottom > 0);
@@ -1593,6 +1600,8 @@ public class BubbleStackView extends FrameLayout
updatePointerPosition(); updatePointerPosition();
if (mIsExpanded) { if (mIsExpanded) {
hideCurrentInputMethod();
// Make the container of the expanded view transparent before removing the expanded view // Make the container of the expanded view transparent before removing the expanded view
// from it. Otherwise a punch hole created by {@link android.view.SurfaceView} in the // from it. Otherwise a punch hole created by {@link android.view.SurfaceView} in the
// expanded view becomes visible on the screen. See b/126856255 // expanded view becomes visible on the screen. See b/126856255
@@ -1601,11 +1610,6 @@ public class BubbleStackView extends FrameLayout
if (previouslySelected != null) { if (previouslySelected != null) {
previouslySelected.setContentVisibility(false); previouslySelected.setContentVisibility(false);
} }
if (previouslySelected != null && previouslySelected.getExpandedView() != null) {
// Hide the currently expanded bubble's IME if it's visible before switching
// to a new bubble.
previouslySelected.getExpandedView().hideImeIfVisible();
}
updateExpandedBubble(); updateExpandedBubble();
requestUpdate(); requestUpdate();
@@ -1633,6 +1637,8 @@ public class BubbleStackView extends FrameLayout
return; return;
} }
hideCurrentInputMethod();
mSysUiState mSysUiState
.setFlag(QuickStepContract.SYSUI_STATE_BUBBLES_EXPANDED, shouldExpand) .setFlag(QuickStepContract.SYSUI_STATE_BUBBLES_EXPANDED, shouldExpand)
.commitUpdate(mContext.getDisplayId()); .commitUpdate(mContext.getDisplayId());
@@ -1816,12 +1822,12 @@ public class BubbleStackView extends FrameLayout
} }
} }
void hideImeFromExpandedBubble() { /**
if (mExpandedBubble != null && mExpandedBubble.getExpandedView() != null) { * Asks the BubbleController to hide the IME from anywhere, whether it's focused on Bubbles or
// Hide the currently expanded bubble's IME if it's visible before switching to a new * not.
// bubble. */
mExpandedBubble.getExpandedView().hideImeIfVisible(); void hideCurrentInputMethod() {
} mHideCurrentInputMethodCallback.run();
} }
private void beforeExpandedViewAnimation() { private void beforeExpandedViewAnimation() {
@@ -1938,10 +1944,6 @@ public class BubbleStackView extends FrameLayout
mAnimatingOutSurfaceContainer.setScaleX(0f); mAnimatingOutSurfaceContainer.setScaleX(0f);
mAnimatingOutSurfaceContainer.setScaleY(0f); mAnimatingOutSurfaceContainer.setScaleY(0f);
if (mExpandedBubble != null && mExpandedBubble.getExpandedView() != null) {
mExpandedBubble.getExpandedView().hideImeIfVisible();
}
// Let the expanded animation controller know that it shouldn't animate child adds/reorders // Let the expanded animation controller know that it shouldn't animate child adds/reorders
// since we're about to animate collapsed. // since we're about to animate collapsed.
mExpandedAnimationController.notifyPreparingToCollapse(); mExpandedAnimationController.notifyPreparingToCollapse();

View File

@@ -52,6 +52,7 @@ import android.view.WindowInsetsController.Appearance;
import com.android.internal.R; import com.android.internal.R;
import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.GuardedBy;
import com.android.internal.inputmethod.SoftInputShowHideReason;
import com.android.internal.statusbar.IStatusBar; import com.android.internal.statusbar.IStatusBar;
import com.android.internal.statusbar.IStatusBarService; import com.android.internal.statusbar.IStatusBarService;
import com.android.internal.statusbar.NotificationVisibility; import com.android.internal.statusbar.NotificationVisibility;
@@ -61,6 +62,7 @@ import com.android.internal.util.DumpUtils;
import com.android.internal.view.AppearanceRegion; import com.android.internal.view.AppearanceRegion;
import com.android.server.LocalServices; import com.android.server.LocalServices;
import com.android.server.UiThread; import com.android.server.UiThread;
import com.android.server.inputmethod.InputMethodManagerInternal;
import com.android.server.notification.NotificationDelegate; import com.android.server.notification.NotificationDelegate;
import com.android.server.policy.GlobalActionsProvider; import com.android.server.policy.GlobalActionsProvider;
import com.android.server.power.ShutdownThread; import com.android.server.power.ShutdownThread;
@@ -1401,6 +1403,17 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
} }
} }
@Override
public void hideCurrentInputMethodForBubbles() {
final long token = Binder.clearCallingIdentity();
try {
InputMethodManagerInternal.get().hideCurrentInputMethod(
SoftInputShowHideReason.HIDE_BUBBLES);
} finally {
Binder.restoreCallingIdentity(token);
}
}
@Override @Override
public void grantInlineReplyUriPermission(String key, Uri uri, UserHandle user, public void grantInlineReplyUriPermission(String key, Uri uri, UserHandle user,
String packageName) { String packageName) {