Merge changes I032f7ffc,I384d7af0 into sc-v2-dev am: 94c673c64d

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/15788129

Change-Id: I180913ba70149443ecf04f52e83b72bf177ee734
This commit is contained in:
Tony Wickham
2021-09-09 20:35:51 +00:00
committed by Automerger Merge Worker
2 changed files with 46 additions and 0 deletions
@@ -20,6 +20,7 @@ import static android.content.pm.PackageManager.MATCH_DISABLED_COMPONENTS;
import static android.view.View.GONE; import static android.view.View.GONE;
import static android.view.View.VISIBLE; 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.PLUGIN_CHANGED;
import static com.android.launcher3.uioverrides.plugins.PluginManagerWrapper.pluginEnabledKey; import static com.android.launcher3.uioverrides.plugins.PluginManagerWrapper.pluginEnabledKey;
@@ -29,6 +30,7 @@ import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
import android.net.Uri; import android.net.Uri;
@@ -44,6 +46,7 @@ import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.EditText; import android.widget.EditText;
import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@@ -57,12 +60,15 @@ import androidx.preference.PreferenceViewHolder;
import androidx.preference.SwitchPreference; import androidx.preference.SwitchPreference;
import com.android.launcher3.R; import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.config.FlagTogglerPrefUi; import com.android.launcher3.config.FlagTogglerPrefUi;
import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper; import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper;
import com.android.launcher3.util.OnboardingPrefs;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -104,6 +110,7 @@ public class DeveloperOptionsFragment extends PreferenceFragmentCompat {
initFlags(); initFlags();
loadPluginPrefs(); loadPluginPrefs();
maybeAddSandboxCategory(); maybeAddSandboxCategory();
addOnboardingPrefsCatergory();
if (getActivity() != null) { if (getActivity() != null) {
getActivity().setTitle("Developer Options"); 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(); View listView = getListView();
final int bottomPadding = listView.getPaddingBottom(); final int bottomPadding = listView.getPaddingBottom();
listView.setOnApplyWindowInsetsListener((v, insets) -> { listView.setOnApplyWindowInsetsListener((v, insets) -> {
@@ -355,6 +371,28 @@ public class DeveloperOptionsFragment extends PreferenceFragmentCompat {
sandboxCategory.addPreference(launchSandboxModeTutorialPreference); 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) { private String toName(String action) {
String str = action.replace("com.android.systemui.action.PLUGIN_", "") String str = action.replace("com.android.systemui.action.PLUGIN_", "")
.replace("com.android.launcher3.action.PLUGIN_", ""); .replace("com.android.launcher3.action.PLUGIN_", "");
@@ -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_EDU_SEEN = "launcher.search_edu_seen";
public static final String SEARCH_SNACKBAR_COUNT = "launcher.keyboard_snackbar_count"; public static final String SEARCH_SNACKBAR_COUNT = "launcher.keyboard_snackbar_count";
public static final String TASKBAR_EDU_SEEN = "launcher.taskbar_edu_seen"; 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). * Events that either have happened or have not (booleans).