From af5bb30141ce792828f46c21dd5382b3ddd8f909 Mon Sep 17 00:00:00 2001 From: Andy Wickham Date: Wed, 17 May 2023 14:13:44 -0700 Subject: [PATCH] Add developer option to tweak All Apps from Overview threshold. Ability to move threshold from shift 1.05 to 5.0. Saved as an int from 105 to 500. Shift 1.0 is where Overview rests; using this value exactly causes a slight glitch while settling. Demo (slightly outdated min value and flavor text): https://drive.google.com/file/d/1PaS4MjFM1P9ZHQ-400tXUbDz_-z8qYtC/view?usp=drive_link&resourcekey=0-ZX-ofW4AzN0-Qjqo4OmU-g Bug: 281717218 Test: Manual Flag: ENABLE_ALL_APPS_FROM_OVERVIEW Change-Id: I5acfb46f9df16e9d3091a7822c449301bc6067f9 --- .../flags/DeveloperOptionsFragment.java | 32 +++++++++++++++++++ .../android/quickstep/AbsSwipeUpHandler.java | 8 ++--- .../AnimatorControllerWithResistance.java | 6 ++-- .../android/launcher3/LauncherAppState.java | 1 + src/com/android/launcher3/LauncherPrefs.kt | 3 ++ 5 files changed, 44 insertions(+), 6 deletions(-) diff --git a/quickstep/src/com/android/launcher3/uioverrides/flags/DeveloperOptionsFragment.java b/quickstep/src/com/android/launcher3/uioverrides/flags/DeveloperOptionsFragment.java index b901a87753..a76eb437de 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/flags/DeveloperOptionsFragment.java +++ b/quickstep/src/com/android/launcher3/uioverrides/flags/DeveloperOptionsFragment.java @@ -23,6 +23,7 @@ import static android.content.pm.PackageManager.MATCH_DISABLED_COMPONENTS; import static android.view.View.GONE; import static android.view.View.VISIBLE; +import static com.android.launcher3.LauncherPrefs.ALL_APPS_OVERVIEW_THRESHOLD; import static com.android.launcher3.settings.SettingsActivity.EXTRA_FRAGMENT_ARG_KEY; import static com.android.launcher3.uioverrides.plugins.PluginManagerWrapper.PLUGIN_CHANGED; import static com.android.launcher3.uioverrides.plugins.PluginManagerWrapper.pluginEnabledKey; @@ -59,6 +60,7 @@ import androidx.preference.PreferenceFragmentCompat; import androidx.preference.PreferenceGroup; import androidx.preference.PreferenceScreen; import androidx.preference.PreferenceViewHolder; +import androidx.preference.SeekBarPreference; import androidx.preference.SwitchPreference; import com.android.launcher3.LauncherPrefs; @@ -106,6 +108,9 @@ public class DeveloperOptionsFragment extends PreferenceFragmentCompat { loadPluginPrefs(); maybeAddSandboxCategory(); addOnboardingPrefsCatergory(); + if (FeatureFlags.ENABLE_ALL_APPS_FROM_OVERVIEW.get()) { + addAllAppsFromOverviewCatergory(); + } if (getActivity() != null) { getActivity().setTitle("Developer Options"); @@ -393,6 +398,33 @@ public class DeveloperOptionsFragment extends PreferenceFragmentCompat { } } + private void addAllAppsFromOverviewCatergory() { + PreferenceCategory category = newCategory("All Apps from Overview Config"); + + SeekBarPreference thresholdPref = new SeekBarPreference(getContext()); + thresholdPref.setTitle("Threshold to open All Apps from Overview"); + thresholdPref.setSingleLineTitle(false); + + // These values are 100x swipe up shift value (100 = where overview sits). + thresholdPref.setMax(500); + thresholdPref.setMin(105); + thresholdPref.setUpdatesContinuously(true); + thresholdPref.setIconSpaceReserved(false); + // Don't directly save to shared prefs, use LauncherPrefs instead. + thresholdPref.setPersistent(false); + thresholdPref.setOnPreferenceChangeListener((preference, newValue) -> { + LauncherPrefs.get(getContext()).put(ALL_APPS_OVERVIEW_THRESHOLD, newValue); + preference.setSummary(String.valueOf((int) newValue / 100f)); + return true; + }); + int value = LauncherPrefs.get(getContext()).get(ALL_APPS_OVERVIEW_THRESHOLD); + thresholdPref.setValue(value); + // For some reason the initial value is not triggering the summary update, so call manually. + thresholdPref.getOnPreferenceChangeListener().onPreferenceChange(thresholdPref, value); + + category.addPreference(thresholdPref); + } + private String toName(String action) { String str = action.replace("com.android.systemui.action.PLUGIN_", "") .replace("com.android.launcher3.action.PLUGIN_", ""); diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index f3689a9bbe..cb5c4dc4d5 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -23,6 +23,7 @@ import static android.widget.Toast.LENGTH_SHORT; import static com.android.launcher3.BaseActivity.INVISIBLE_BY_STATE_HANDLER; import static com.android.launcher3.BaseActivity.STATE_HANDLER_INVISIBILITY_FLAGS; +import static com.android.launcher3.LauncherPrefs.ALL_APPS_OVERVIEW_THRESHOLD; import static com.android.launcher3.PagedView.INVALID_PAGE; import static com.android.launcher3.anim.Interpolators.ACCEL_DEACCEL; import static com.android.launcher3.anim.Interpolators.DEACCEL; @@ -94,6 +95,7 @@ import androidx.annotation.UiThread; import com.android.internal.util.LatencyTracker; import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.DeviceProfile; +import com.android.launcher3.LauncherPrefs; import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.anim.AnimationSuccessListener; @@ -163,9 +165,6 @@ public abstract class AbsSwipeUpHandler, private static final ArrayList STATE_NAMES = new ArrayList<>(); - /** Shift distance to transition to All Apps if ENABLE_ALL_APPS_FROM_OVERVIEW. */ - public static final float ALL_APPS_SHIFT_THRESHOLD = 2f; - protected final BaseActivityInterface mActivityInterface; protected final InputConsumerProxy mInputConsumerProxy; protected final ActivityInitListener mActivityInitListener; @@ -864,7 +863,8 @@ public abstract class AbsSwipeUpHandler, @UiThread @Override public void onCurrentShiftUpdated() { - setIsInAllAppsRegion(mCurrentShift.value >= ALL_APPS_SHIFT_THRESHOLD); + float threshold = LauncherPrefs.get(mContext).get(ALL_APPS_OVERVIEW_THRESHOLD) / 100f; + setIsInAllAppsRegion(mCurrentShift.value >= threshold); updateSysUiFlags(mCurrentShift.value); applyScrollAndTransform(); diff --git a/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java b/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java index a92ab2a417..6f927d3faf 100644 --- a/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java +++ b/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java @@ -15,9 +15,9 @@ */ package com.android.quickstep.util; +import static com.android.launcher3.LauncherPrefs.ALL_APPS_OVERVIEW_THRESHOLD; import static com.android.launcher3.anim.Interpolators.DEACCEL; import static com.android.launcher3.anim.Interpolators.LINEAR; -import static com.android.quickstep.AbsSwipeUpHandler.ALL_APPS_SHIFT_THRESHOLD; import static com.android.quickstep.views.RecentsView.RECENTS_SCALE_PROPERTY; import static com.android.quickstep.views.RecentsView.TASK_SECONDARY_TRANSLATION; @@ -34,6 +34,7 @@ import androidx.annotation.Nullable; import com.android.launcher3.DeviceProfile; import com.android.launcher3.Launcher; +import com.android.launcher3.LauncherPrefs; import com.android.launcher3.LauncherState; import com.android.launcher3.Utilities; import com.android.launcher3.anim.AnimatorPlaybackController; @@ -188,7 +189,8 @@ public class AnimatorControllerWithResistance { recentsOrientedState.getOrientationHandler()); float dragLengthFactor = (float) dp.heightPx / transitionDragLength; // -1s are because 0-1 is reserved for the normal transition. - return (ALL_APPS_SHIFT_THRESHOLD - 1) / (dragLengthFactor - 1); + float threshold = LauncherPrefs.get(context).get(ALL_APPS_OVERVIEW_THRESHOLD) / 100f; + return (threshold - 1) / (dragLengthFactor - 1); } /** diff --git a/src/com/android/launcher3/LauncherAppState.java b/src/com/android/launcher3/LauncherAppState.java index cc1c0f599c..4b7aeeb898 100644 --- a/src/com/android/launcher3/LauncherAppState.java +++ b/src/com/android/launcher3/LauncherAppState.java @@ -62,6 +62,7 @@ public class LauncherAppState implements SafeCloseable { public static final String ACTION_FORCE_ROLOAD = "force-reload-launcher"; public static final String KEY_ICON_STATE = "pref_icon_shape_path"; + public static final String KEY_ALL_APPS_OVERVIEW_THRESHOLD = "pref_all_apps_overview_threshold"; // We do not need any synchronization for this variable as its only written on UI thread. public static final MainThreadInitializedObject INSTANCE = diff --git a/src/com/android/launcher3/LauncherPrefs.kt b/src/com/android/launcher3/LauncherPrefs.kt index c98df1b099..177f8834d1 100644 --- a/src/com/android/launcher3/LauncherPrefs.kt +++ b/src/com/android/launcher3/LauncherPrefs.kt @@ -275,6 +275,9 @@ class LauncherPrefs(private val encryptedContext: Context) { const val TASKBAR_PINNING_KEY = "TASKBAR_PINNING_KEY" @JvmField val ICON_STATE = nonRestorableItem(LauncherAppState.KEY_ICON_STATE, "", true) + @JvmField + val ALL_APPS_OVERVIEW_THRESHOLD = + nonRestorableItem(LauncherAppState.KEY_ALL_APPS_OVERVIEW_THRESHOLD, 200, true) @JvmField val THEMED_ICONS = backedUpItem(Themes.KEY_THEMED_ICONS, false, true) @JvmField val PROMISE_ICON_IDS = backedUpItem(InstallSessionHelper.PROMISE_ICON_IDS, "") @JvmField val WORK_EDU_STEP = backedUpItem(WorkProfileManager.KEY_WORK_EDU_STEP, 0)