From b9f9d69f678d5bdb948d293ebc308adf804430f8 Mon Sep 17 00:00:00 2001 From: Hyunyoung Song Date: Wed, 19 Aug 2020 00:58:34 -0700 Subject: [PATCH] Hide IME when scrolling happens on all apps screen/scroller Bug: 161594550 TL;DR;; - draging an item closes the IME - clearing a searchbox to empty string has no effect on IME Change-Id: Ic3a91d1b22434dcb78347dd8b12b5ceab14eb928 --- .../android/launcher3/ExtendedEditText.java | 5 +++++ .../allapps/AllAppsContainerView.java | 21 +++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/com/android/launcher3/ExtendedEditText.java b/src/com/android/launcher3/ExtendedEditText.java index d64967b75e..02c61620fe 100644 --- a/src/com/android/launcher3/ExtendedEditText.java +++ b/src/com/android/launcher3/ExtendedEditText.java @@ -24,6 +24,7 @@ import android.view.View; import android.view.inputmethod.InputMethodManager; import android.widget.EditText; +import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.util.UiThreadHelper; @@ -130,6 +131,10 @@ public class ExtendedEditText extends EditText { public void reset() { if (!TextUtils.isEmpty(getText())) { setText(""); + } else { + 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 af3722a1f8..21ee494542 100644 --- a/src/com/android/launcher3/allapps/AllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java @@ -42,6 +42,7 @@ import android.view.WindowInsets; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.StringRes; +import androidx.core.os.BuildCompat; import androidx.recyclerview.widget.DefaultItemAnimator; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -108,7 +109,7 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo private final MultiValueAlpha mMultiValueAlpha; - Rect mInsets = new Rect(); + private Rect mInsets = new Rect(); public AllAppsContainerView(Context context) { this(context, null); @@ -204,6 +205,17 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo mAH[AdapterHolder.WORK].applyPadding(); } + private void hideInput() { + if (!BuildCompat.isAtLeastR() || !FeatureFlags.ENABLE_DEVICE_SEARCH.get()) return; + + WindowInsets insets = getRootWindowInsets(); + if (insets == null) return; + + if (insets.isVisible(WindowInsets.Type.ime())) { + getWindowInsetsController().hide(WindowInsets.Type.ime()); + } + } + /** * Returns whether the view itself will handle the touch event or not. */ @@ -219,9 +231,14 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo } if (rv.getScrollbar().getThumbOffsetY() >= 0 && mLauncher.getDragLayer().isEventOverView(rv.getScrollbar(), ev)) { + hideInput(); return false; } - return rv.shouldContainerScroll(ev, mLauncher.getDragLayer()); + boolean shouldScroll = rv.shouldContainerScroll(ev, mLauncher.getDragLayer()); + if (shouldScroll) { + hideInput(); + } + return shouldScroll; } @Override