From a907a995c9b2e687e44ea8f3777482c33dac8914 Mon Sep 17 00:00:00 2001 From: Hyunyoung Song Date: Wed, 10 Mar 2021 10:18:03 -0800 Subject: [PATCH] Hide keyboard only when scrolling happens Bug: 179307221 Test: see attached video Change-Id: I9b13c8f62122a6d7bf56a28c830be9a9dbfee52a --- src/com/android/launcher3/ExtendedEditText.java | 7 +++---- .../android/launcher3/allapps/AllAppsContainerView.java | 6 +----- .../android/launcher3/allapps/AllAppsRecyclerView.java | 2 ++ .../launcher3/allapps/AllAppsTransitionController.java | 1 + .../allapps/search/AllAppsSearchBarController.java | 2 +- src/com/android/launcher3/statemanager/StateManager.java | 9 +++++++++ 6 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/com/android/launcher3/ExtendedEditText.java b/src/com/android/launcher3/ExtendedEditText.java index 02c61620fe..c79dabe8cf 100644 --- a/src/com/android/launcher3/ExtendedEditText.java +++ b/src/com/android/launcher3/ExtendedEditText.java @@ -131,10 +131,9 @@ public class ExtendedEditText extends EditText { public void reset() { if (!TextUtils.isEmpty(getText())) { setText(""); - } else { - if (FeatureFlags.ENABLE_DEVICE_SEARCH.get()) { - return; - } + } + if (FeatureFlags.ENABLE_DEVICE_SEARCH.get()) { + return; } if (isFocused()) { View nextFocus = focusSearch(View.FOCUS_DOWN); diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java index 9ede94c43f..67ed99d94c 100644 --- a/src/com/android/launcher3/allapps/AllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java @@ -246,11 +246,7 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo hideInput(); return false; } - boolean shouldScroll = rv.shouldContainerScroll(ev, mLauncher.getDragLayer()); - if (shouldScroll) { - hideInput(); - } - return shouldScroll; + return rv.shouldContainerScroll(ev, mLauncher.getDragLayer()); } @Override diff --git a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java index 179cb778fd..f307a53bc0 100644 --- a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java +++ b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java @@ -31,6 +31,7 @@ import android.util.Log; import android.util.SparseIntArray; import android.view.MotionEvent; import android.view.View; +import android.view.WindowInsets; import androidx.recyclerview.widget.RecyclerView; @@ -188,6 +189,7 @@ public class AllAppsRecyclerView extends BaseRecyclerView { case SCROLL_STATE_DRAGGING: mgr.logger().sendToInteractionJankMonitor( LAUNCHER_ALLAPPS_VERTICAL_SWIPE_BEGIN, this); + getWindowInsetsController().hide(WindowInsets.Type.ime()); break; case SCROLL_STATE_IDLE: mgr.logger().sendToInteractionJankMonitor( diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java index abf63dc0a1..1e6f829886 100644 --- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java +++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java @@ -246,6 +246,7 @@ public class AllAppsTransitionController * TODO: This logic should go in {@link LauncherState} */ private void onProgressAnimationEnd() { + if (FeatureFlags.ENABLE_DEVICE_SEARCH.get()) return; if (Float.compare(mProgress, 1f) == 0) { mAppsView.reset(false /* animate */); } diff --git a/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java b/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java index 3319018218..d3c9993579 100644 --- a/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java +++ b/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java @@ -144,7 +144,7 @@ public class AllAppsSearchBarController @Override public void onFocusChange(View view, boolean hasFocus) { - if (!hasFocus) { + if (!hasFocus && !FeatureFlags.ENABLE_DEVICE_SEARCH.get()) { mInput.hideKeyboard(); } } diff --git a/src/com/android/launcher3/statemanager/StateManager.java b/src/com/android/launcher3/statemanager/StateManager.java index 2b51e97f3f..51767e77e7 100644 --- a/src/com/android/launcher3/statemanager/StateManager.java +++ b/src/com/android/launcher3/statemanager/StateManager.java @@ -77,6 +77,15 @@ public class StateManager> { return mCurrentStableState; } + @Override + public String toString() { + return " StateManager(mLastStableState:" + mLastStableState + + ", mCurrentStableState:" + mCurrentStableState + + ", mState:" + mState + + ", mRestState:" + mRestState + + ", isInTransition:" + (mConfig.currentAnimation != null) + ")"; + } + public void dump(String prefix, PrintWriter writer) { writer.println(prefix + "StateManager:"); writer.println(prefix + "\tmLastStableState:" + mLastStableState);