diff options
-rw-r--r-- | src/com/android/launcher3/settings/DeveloperOptionsFragment.java | 38 | ||||
-rw-r--r-- | src/com/android/launcher3/util/OnboardingPrefs.java | 8 |
2 files changed, 46 insertions, 0 deletions
diff --git a/src/com/android/launcher3/settings/DeveloperOptionsFragment.java b/src/com/android/launcher3/settings/DeveloperOptionsFragment.java index 4d63218785..b06b8a10bf 100644 --- a/src/com/android/launcher3/settings/DeveloperOptionsFragment.java +++ b/src/com/android/launcher3/settings/DeveloperOptionsFragment.java @@ -20,6 +20,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.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; @@ -29,6 +30,7 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; +import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.net.Uri; @@ -44,6 +46,7 @@ import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.widget.EditText; +import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -57,12 +60,15 @@ import androidx.preference.PreferenceViewHolder; import androidx.preference.SwitchPreference; import com.android.launcher3.R; +import com.android.launcher3.Utilities; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.config.FlagTogglerPrefUi; import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper; +import com.android.launcher3.util.OnboardingPrefs; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.stream.Collectors; @@ -104,6 +110,7 @@ public class DeveloperOptionsFragment extends PreferenceFragmentCompat { initFlags(); loadPluginPrefs(); maybeAddSandboxCategory(); + addOnboardingPrefsCatergory(); if (getActivity() != null) { getActivity().setTitle("Developer Options"); @@ -153,6 +160,15 @@ public class DeveloperOptionsFragment extends PreferenceFragmentCompat { } }); + if (getArguments() != null) { + String filter = getArguments().getString(EXTRA_FRAGMENT_ARG_KEY); + // Normally EXTRA_FRAGMENT_ARG_KEY is used to highlight the preference with the given + // key. This is a slight variation where we instead filter by the human-readable titles. + if (filter != null) { + filterBox.setText(filter); + } + } + View listView = getListView(); final int bottomPadding = listView.getPaddingBottom(); listView.setOnApplyWindowInsetsListener((v, insets) -> { @@ -355,6 +371,28 @@ public class DeveloperOptionsFragment extends PreferenceFragmentCompat { sandboxCategory.addPreference(launchSandboxModeTutorialPreference); } + private void addOnboardingPrefsCatergory() { + PreferenceCategory onboardingCategory = newCategory("Onboarding Flows"); + onboardingCategory.setSummary("Reset these if you want to see the education again."); + for (Map.Entry<String, String[]> titleAndKeys : OnboardingPrefs.ALL_PREF_KEYS.entrySet()) { + String title = titleAndKeys.getKey(); + String[] keys = titleAndKeys.getValue(); + Preference onboardingPref = new Preference(getContext()); + onboardingPref.setTitle(title); + onboardingPref.setSummary("Tap to reset"); + onboardingPref.setOnPreferenceClickListener(preference -> { + SharedPreferences.Editor sharedPrefsEdit = Utilities.getPrefs(getContext()).edit(); + for (String key : keys) { + sharedPrefsEdit.remove(key); + } + sharedPrefsEdit.apply(); + Toast.makeText(getContext(), "Reset " + title, Toast.LENGTH_SHORT).show(); + return true; + }); + onboardingCategory.addPreference(onboardingPref); + } + } + private String toName(String action) { String str = action.replace("com.android.systemui.action.PLUGIN_", "") .replace("com.android.launcher3.action.PLUGIN_", ""); diff --git a/src/com/android/launcher3/util/OnboardingPrefs.java b/src/com/android/launcher3/util/OnboardingPrefs.java index cf1467ade4..5ba0d30256 100644 --- a/src/com/android/launcher3/util/OnboardingPrefs.java +++ b/src/com/android/launcher3/util/OnboardingPrefs.java @@ -39,6 +39,14 @@ public class OnboardingPrefs<T extends Launcher> { public static final String SEARCH_EDU_SEEN = "launcher.search_edu_seen"; public static final String SEARCH_SNACKBAR_COUNT = "launcher.keyboard_snackbar_count"; public static final String TASKBAR_EDU_SEEN = "launcher.taskbar_edu_seen"; + // When adding a new key, add it here as well, to be able to reset it from Developer Options. + public static final Map<String, String[]> ALL_PREF_KEYS = Map.of( + "All Apps Bounce", new String[] { HOME_BOUNCE_SEEN, HOME_BOUNCE_COUNT }, + "Hybrid Hotseat Education", new String[] { HOTSEAT_DISCOVERY_TIP_COUNT, + HOTSEAT_LONGPRESS_TIP_SEEN }, + "Search Education", new String[] { SEARCH_EDU_SEEN, SEARCH_SNACKBAR_COUNT }, + "Taskbar Education", new String[] { TASKBAR_EDU_SEEN } + ); /** * Events that either have happened or have not (booleans). |