Add option to reset Onboarding Flows in Developer Options
Test: Go to Developer Options, reset Hybrid Hotseat Education, then long press on a predicted hotseat item and ensure edu toast appears
Bug: 199299382
Change-Id: I384d7af08fc8b842bc3a1333b9f8017cca3680e6
diff --git a/src/com/android/launcher3/settings/DeveloperOptionsFragment.java b/src/com/android/launcher3/settings/DeveloperOptionsFragment.java
index 4d63218..f098b00 100644
--- a/src/com/android/launcher3/settings/DeveloperOptionsFragment.java
+++ b/src/com/android/launcher3/settings/DeveloperOptionsFragment.java
@@ -29,6 +29,7 @@
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 +45,7 @@
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 +59,15 @@
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 +109,7 @@
initFlags();
loadPluginPrefs();
maybeAddSandboxCategory();
+ addOnboardingPrefsCatergory();
if (getActivity() != null) {
getActivity().setTitle("Developer Options");
@@ -355,6 +361,28 @@
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 cf1467a..5ba0d30 100644
--- a/src/com/android/launcher3/util/OnboardingPrefs.java
+++ b/src/com/android/launcher3/util/OnboardingPrefs.java
@@ -39,6 +39,14 @@
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).