Handle requestFocus for ENABLE_DEVICE_SEARCH
Bug: 161594550
Change-Id: Ic99c04f1235e48e90b64df86e3739f8e14bc648f
diff --git a/src/com/android/launcher3/allapps/AllAppsInsetTransitionController.java b/src/com/android/launcher3/allapps/AllAppsInsetTransitionController.java
index 5af9113..d7af5f1 100644
--- a/src/com/android/launcher3/allapps/AllAppsInsetTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsInsetTransitionController.java
@@ -58,6 +58,17 @@
mApps = appsView;
}
+ public void hide() {
+ if (!BuildCompat.isAtLeastR()) return;
+
+ WindowInsets insets = mApps.getRootWindowInsets();
+ if (insets == null) return;
+
+ if (insets.isVisible(WindowInsets.Type.ime())) {
+ mApps.getWindowInsetsController().hide(WindowInsets.Type.ime());
+ }
+ }
+
/**
* Initializes member variables and requests for the {@link WindowInsetsAnimationController}
* object.
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index 5b00631..2b816a0 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -37,6 +37,7 @@
import android.util.FloatProperty;
import android.view.View;
import android.view.animation.Interpolator;
+import android.widget.EditText;
import androidx.core.os.BuildCompat;
@@ -267,8 +268,16 @@
}
if (FeatureFlags.ENABLE_DEVICE_SEARCH.get() && BuildCompat.isAtLeastR()) {
mInsetController.onAnimationEnd(mProgress);
+ if (Float.compare(mProgress, 0f) == 0) {
+ EditText editText = mAppsView.getSearchUiManager().getEditText();
+ if (editText != null) {
+ editText.requestFocus();
+ }
+ }
if (Float.compare(mProgress, 1f) == 0) {
- mAppsView.getSearchUiManager().setTextSearchEnabled(true).requestFocus();
+ // Called when home gesture closes all apps container.
+ // TODO: should make the controller hide synchronously
+ mInsetController.hide();
}
}
}
diff --git a/src/com/android/launcher3/allapps/SearchUiManager.java b/src/com/android/launcher3/allapps/SearchUiManager.java
index 7d5363f..aa056a0 100644
--- a/src/com/android/launcher3/allapps/SearchUiManager.java
+++ b/src/com/android/launcher3/allapps/SearchUiManager.java
@@ -66,12 +66,8 @@
}
/**
- * Called to control how the search UI result should be handled.
- *
- * @param isEnabled when {@code true}, the search is all handled inside AOSP
- * and is not overlayable.
- * @return the searchbox edit text object
+ * @return the edit text object
*/
@Nullable
- EditText setTextSearchEnabled(boolean isEnabled);
+ EditText getEditText();
}
diff --git a/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java b/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java
index 356c52c..2e89c89 100644
--- a/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java
+++ b/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java
@@ -216,7 +216,7 @@
}
@Override
- public EditText setTextSearchEnabled(boolean isEnabled) {
+ public EditText getEditText() {
return this;
}
}