From 9ffaee3110a324a18af21ff1bb6f5f10e3231288 Mon Sep 17 00:00:00 2001 From: Samuel Fufa Date: Mon, 22 Feb 2021 09:09:17 -0600 Subject: [PATCH] Break up nasa search results + replace IME feature flag launcher setting Test: Manual Bug: 178638266 Change-Id: Id013cd247cfa2b33cdf62ee3239ad1bacc35b5da --- .../allapps/AllAppsTransitionController.java | 26 +++++++++++++------ .../launcher3/config/FeatureFlags.java | 3 --- .../AbstractStateChangeTouchController.java | 1 - 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java index a4e1f271fb..dc58c99c99 100644 --- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java +++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java @@ -33,6 +33,7 @@ import static com.android.launcher3.util.SystemUiController.UI_STATE_ALLAPPS; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; +import android.content.SharedPreferences; import android.util.FloatProperty; import android.view.View; import android.view.animation.Interpolator; @@ -63,7 +64,7 @@ import com.android.launcher3.views.ScrimView; * closer to top or closer to the page indicator. */ public class AllAppsTransitionController implements StateHandler, - OnDeviceProfileChangeListener { + OnDeviceProfileChangeListener, SharedPreferences.OnSharedPreferenceChangeListener { public static final FloatProperty ALL_APPS_PROGRESS = new FloatProperty("allAppsProgress") { @@ -80,6 +81,7 @@ public class AllAppsTransitionController implements StateHandler, }; private static final int APPS_VIEW_ALPHA_CHANNEL_INDEX = 0; + private static final String PREF_KEY_SHOW_SEARCH_IME = "pref_search_show_ime"; private AllAppsContainerView mAppsView; private ScrimView mScrimView; @@ -98,6 +100,7 @@ public class AllAppsTransitionController implements StateHandler, private float mScrollRangeDelta = 0; private AllAppsInsetTransitionController mInsetController; + private boolean mSearchImeEnabled; public AllAppsTransitionController(Launcher l) { mLauncher = l; @@ -106,6 +109,9 @@ public class AllAppsTransitionController implements StateHandler, mIsVerticalLayout = mLauncher.getDeviceProfile().isVerticalBarLayout(); mLauncher.addOnDeviceProfileChangeListener(this); + + onSharedPreferenceChanged(mLauncher.getSharedPrefs(), PREF_KEY_SHOW_SEARCH_IME); + mLauncher.getSharedPrefs().registerOnSharedPreferenceChangeListener(this); } public float getShiftRange() { @@ -142,8 +148,7 @@ public class AllAppsTransitionController implements StateHandler, float shiftCurrent = progress * mShiftRange; mAppsView.setTranslationY(shiftCurrent); - if (FeatureFlags.ENABLE_DEVICE_SEARCH.get() - && !FeatureFlags.DISABLE_INITIAL_IME_IN_ALLAPPS.get()) { + if (FeatureFlags.ENABLE_DEVICE_SEARCH.get() && mSearchImeEnabled) { mInsetController.setProgress(progress); } } @@ -234,9 +239,7 @@ public class AllAppsTransitionController implements StateHandler, public void setupViews(AllAppsContainerView appsView, ScrimView scrimView) { mAppsView = appsView; mScrimView = scrimView; - if (FeatureFlags.ENABLE_DEVICE_SEARCH.get() - && !FeatureFlags.DISABLE_INITIAL_IME_IN_ALLAPPS.get() - && BuildCompat.isAtLeastR()) { + if (FeatureFlags.ENABLE_DEVICE_SEARCH.get() && BuildCompat.isAtLeastR()) { mInsetController = new AllAppsInsetTransitionController(mShiftRange, mAppsView); mLauncher.getSystemUiController().updateUiState(UI_STATE_ALLAPPS, View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN @@ -264,8 +267,8 @@ public class AllAppsTransitionController implements StateHandler, if (Float.compare(mProgress, 1f) == 0) { mAppsView.reset(false /* animate */); } - if (FeatureFlags.ENABLE_DEVICE_SEARCH.get() - && !FeatureFlags.DISABLE_INITIAL_IME_IN_ALLAPPS.get() && BuildCompat.isAtLeastR()) { + if (FeatureFlags.ENABLE_DEVICE_SEARCH.get() && mSearchImeEnabled + && BuildCompat.isAtLeastR()) { mInsetController.onAnimationEnd(mProgress); if (Float.compare(mProgress, 0f) == 0) { EditText editText = mAppsView.getSearchUiManager().getEditText(); @@ -276,4 +279,11 @@ public class AllAppsTransitionController implements StateHandler, // TODO: should make the controller hide synchronously } } + + @Override + public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String s) { + if (s.equals(PREF_KEY_SHOW_SEARCH_IME)) { + mSearchImeEnabled = sharedPreferences.getBoolean(s, true); + } + } } diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java index 556aff61c3..ef7bdf41ca 100644 --- a/src/com/android/launcher3/config/FeatureFlags.java +++ b/src/com/android/launcher3/config/FeatureFlags.java @@ -95,9 +95,6 @@ public final class FeatureFlags { public static final BooleanFlag ENABLE_DEVICE_SEARCH = new DeviceFlag( "ENABLE_DEVICE_SEARCH", false, "Allows on device search in all apps"); - public static final BooleanFlag DISABLE_INITIAL_IME_IN_ALLAPPS = getDebugFlag( - "DISABLE_INITIAL_IME_IN_ALLAPPS", false, "Disable default IME state in all apps"); - public static final BooleanFlag FOLDER_NAME_SUGGEST = new DeviceFlag( "FOLDER_NAME_SUGGEST", true, "Suggests folder names instead of blank text."); diff --git a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java index 25ecea5f9f..64a3b5e239 100644 --- a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java +++ b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java @@ -262,7 +262,6 @@ public abstract class AbstractStateChangeTouchController mFlingBlockCheck.unblockFling(); // Must be called after all the animation controllers have been paused if (FeatureFlags.ENABLE_DEVICE_SEARCH.get() - && !FeatureFlags.DISABLE_INITIAL_IME_IN_ALLAPPS.get() && BuildCompat.isAtLeastR() && (mToState == ALL_APPS || mToState == NORMAL)) { mLauncher.getAllAppsController().getInsetController().onDragStart(