From 534bd2205b2051baeee6b1fa3e71a3b4e8ce4d3e Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Wed, 8 Sep 2021 13:46:56 -0700 Subject: [PATCH] Add ability to start DeveloperOptionsFragment with filter pre-applied Repurposing EXTRA_FRAGMENT_ARG_KEY to set an initial filter. Test: adb shell 'am start -n com.google.android.apps.nexuslauncher/com.android.launcher3.settings.SettingsActivity --es ":settings:fragment" "com.android.launcher3.settings.DeveloperOptionsFragment" --es ":settings:fragment_args_key" "Education"' Bug: 199299382 Change-Id: I032f7ffc373daed51c8d381f3cacf722fb3fb198 --- .../launcher3/settings/DeveloperOptionsFragment.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/com/android/launcher3/settings/DeveloperOptionsFragment.java b/src/com/android/launcher3/settings/DeveloperOptionsFragment.java index f098b002b5..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; @@ -159,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) -> {