Loading AndroidManifest-common.xml +2 −2 Original line number Diff line number Diff line Loading @@ -154,13 +154,13 @@ <!-- The content provider for exposing various launcher grid options. TODO: Enable when all apps columns are correct TODO: Add proper permissions --> <provider android:name="com.android.launcher3.graphics.GridOptionsProvider" android:authorities="${packageName}.grid_control" android:enabled="false" android:exported="true" /> --> <!-- The settings activity. To extend point settings_fragment_name to appropriate fragment class Loading res/xml/launcher_preferences.xml +6 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,12 @@ android:defaultValue="@bool/allow_rotation" android:persistent="true" /> <SwitchPreference android:key="pref_grid_options" android:title="Enable grid options" android:defaultValue="false" android:persistent="true" /> <androidx.preference.PreferenceScreen android:key="pref_developer_options" android:persistent="false" Loading src/com/android/launcher3/Utilities.java +13 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ import android.os.Handler; import android.os.Message; import android.os.PowerManager; import android.os.TransactionTooLargeException; import android.provider.Settings; import android.text.Spannable; import android.text.SpannableString; import android.text.TextUtils; Loading @@ -71,6 +72,7 @@ import com.android.launcher3.icons.LauncherIcons; import com.android.launcher3.shortcuts.DeepShortcutManager; import com.android.launcher3.shortcuts.ShortcutKey; import com.android.launcher3.util.IntArray; import com.android.launcher3.util.PackageManagerHelper; import com.android.launcher3.views.Transposable; import com.android.launcher3.widget.PendingAddShortcutInfo; Loading Loading @@ -133,6 +135,11 @@ public final class Utilities { Build.TYPE.toLowerCase(Locale.ROOT).contains("debug") || Build.TYPE.toLowerCase(Locale.ROOT).equals("eng"); public static boolean isDevelopersOptionsEnabled(Context context) { return Settings.Global.getInt(context.getApplicationContext().getContentResolver(), Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0; } // An intent extra to indicate the horizontal scroll of the wallpaper. public static final String EXTRA_WALLPAPER_OFFSET = "com.android.launcher3.WALLPAPER_OFFSET"; public static final String EXTRA_WALLPAPER_FLAVOR = "com.android.launcher3.WALLPAPER_FLAVOR"; Loading Loading @@ -160,6 +167,12 @@ public final class Utilities { return Log.isLoggable(propertyName, Log.VERBOSE); } public static boolean existsStyleWallpapers(Context context) { ResolveInfo ri = context.getPackageManager().resolveActivity( PackageManagerHelper.getStyleWallpapersIntent(context), 0); return ri != null; } /** * Given a coordinate relative to the descendant, find the coordinate in a parent view's * coordinates. Loading src/com/android/launcher3/config/BaseFlags.java +1 −3 Original line number Diff line number Diff line Loading @@ -58,9 +58,7 @@ abstract class BaseFlags { } public static boolean showFlagTogglerUi(Context context) { return Utilities.IS_DEBUG_DEVICE && Settings.Global.getInt(context.getApplicationContext().getContentResolver(), Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0; return Utilities.IS_DEBUG_DEVICE && Utilities.isDevelopersOptionsEnabled(context); } public static final boolean IS_DOGFOOD_BUILD = false; Loading src/com/android/launcher3/settings/SettingsActivity.java +35 −1 Original line number Diff line number Diff line Loading @@ -24,6 +24,10 @@ import static com.android.launcher3.util.SecureSettingsObserver.newNotificationS import android.app.Activity; import android.app.DialogFragment; import android.app.Fragment; import android.content.ComponentName; import android.content.Context; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.os.Bundle; import android.provider.Settings; import android.text.TextUtils; Loading @@ -32,6 +36,7 @@ import com.android.launcher3.LauncherFiles; import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.graphics.GridOptionsProvider; import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper; import com.android.launcher3.util.SecureSettingsObserver; Loading @@ -47,7 +52,8 @@ import androidx.recyclerview.widget.RecyclerView; * Settings activity for Launcher. Currently implements the following setting: Allow rotation */ public class SettingsActivity extends Activity implements OnPreferenceStartFragmentCallback, OnPreferenceStartScreenCallback { implements OnPreferenceStartFragmentCallback, OnPreferenceStartScreenCallback, SharedPreferences.OnSharedPreferenceChangeListener{ private static final String DEVELOPER_OPTIONS_KEY = "pref_developer_options"; private static final String FLAGS_PREFERENCE_KEY = "flag_toggler"; Loading @@ -61,6 +67,8 @@ public class SettingsActivity extends Activity private static final int DELAY_HIGHLIGHT_DURATION_MILLIS = 600; public static final String SAVE_HIGHLIGHTED_KEY = "android:preference_highlighted"; public static final String GRID_OPTIONS_PREFERENCE_KEY = "pref_grid_options"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Loading @@ -79,6 +87,28 @@ public class SettingsActivity extends Activity .replace(android.R.id.content, f) .commit(); } Utilities.getPrefs(getApplicationContext()).registerOnSharedPreferenceChangeListener(this); } @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (GRID_OPTIONS_PREFERENCE_KEY.equals(key)) { final ComponentName cn = new ComponentName(getApplicationContext(), GridOptionsProvider.class); Context c = getApplicationContext(); int oldValue = c.getPackageManager().getComponentEnabledSetting(cn); int newValue; if (Utilities.getPrefs(c).getBoolean(GRID_OPTIONS_PREFERENCE_KEY, false)) { newValue = PackageManager.COMPONENT_ENABLED_STATE_ENABLED; } else { newValue = PackageManager.COMPONENT_ENABLED_STATE_DISABLED; } if (oldValue != newValue) { c.getPackageManager().setComponentEnabledSetting(cn, newValue, PackageManager.DONT_KILL_APP); } } } private boolean startFragment(String fragment, Bundle args, String key) { Loading Loading @@ -200,6 +230,10 @@ public class SettingsActivity extends Activity // Show if plugins are enabled or flag UI is enabled. return FeatureFlags.showFlagTogglerUi(getContext()) || PluginManagerWrapper.hasPlugins(getContext()); case GRID_OPTIONS_PREFERENCE_KEY: return Utilities.isDevelopersOptionsEnabled(getContext()) && Utilities.IS_DEBUG_DEVICE && Utilities.existsStyleWallpapers(getContext()); } return true; Loading Loading
AndroidManifest-common.xml +2 −2 Original line number Diff line number Diff line Loading @@ -154,13 +154,13 @@ <!-- The content provider for exposing various launcher grid options. TODO: Enable when all apps columns are correct TODO: Add proper permissions --> <provider android:name="com.android.launcher3.graphics.GridOptionsProvider" android:authorities="${packageName}.grid_control" android:enabled="false" android:exported="true" /> --> <!-- The settings activity. To extend point settings_fragment_name to appropriate fragment class Loading
res/xml/launcher_preferences.xml +6 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,12 @@ android:defaultValue="@bool/allow_rotation" android:persistent="true" /> <SwitchPreference android:key="pref_grid_options" android:title="Enable grid options" android:defaultValue="false" android:persistent="true" /> <androidx.preference.PreferenceScreen android:key="pref_developer_options" android:persistent="false" Loading
src/com/android/launcher3/Utilities.java +13 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ import android.os.Handler; import android.os.Message; import android.os.PowerManager; import android.os.TransactionTooLargeException; import android.provider.Settings; import android.text.Spannable; import android.text.SpannableString; import android.text.TextUtils; Loading @@ -71,6 +72,7 @@ import com.android.launcher3.icons.LauncherIcons; import com.android.launcher3.shortcuts.DeepShortcutManager; import com.android.launcher3.shortcuts.ShortcutKey; import com.android.launcher3.util.IntArray; import com.android.launcher3.util.PackageManagerHelper; import com.android.launcher3.views.Transposable; import com.android.launcher3.widget.PendingAddShortcutInfo; Loading Loading @@ -133,6 +135,11 @@ public final class Utilities { Build.TYPE.toLowerCase(Locale.ROOT).contains("debug") || Build.TYPE.toLowerCase(Locale.ROOT).equals("eng"); public static boolean isDevelopersOptionsEnabled(Context context) { return Settings.Global.getInt(context.getApplicationContext().getContentResolver(), Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0; } // An intent extra to indicate the horizontal scroll of the wallpaper. public static final String EXTRA_WALLPAPER_OFFSET = "com.android.launcher3.WALLPAPER_OFFSET"; public static final String EXTRA_WALLPAPER_FLAVOR = "com.android.launcher3.WALLPAPER_FLAVOR"; Loading Loading @@ -160,6 +167,12 @@ public final class Utilities { return Log.isLoggable(propertyName, Log.VERBOSE); } public static boolean existsStyleWallpapers(Context context) { ResolveInfo ri = context.getPackageManager().resolveActivity( PackageManagerHelper.getStyleWallpapersIntent(context), 0); return ri != null; } /** * Given a coordinate relative to the descendant, find the coordinate in a parent view's * coordinates. Loading
src/com/android/launcher3/config/BaseFlags.java +1 −3 Original line number Diff line number Diff line Loading @@ -58,9 +58,7 @@ abstract class BaseFlags { } public static boolean showFlagTogglerUi(Context context) { return Utilities.IS_DEBUG_DEVICE && Settings.Global.getInt(context.getApplicationContext().getContentResolver(), Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0; return Utilities.IS_DEBUG_DEVICE && Utilities.isDevelopersOptionsEnabled(context); } public static final boolean IS_DOGFOOD_BUILD = false; Loading
src/com/android/launcher3/settings/SettingsActivity.java +35 −1 Original line number Diff line number Diff line Loading @@ -24,6 +24,10 @@ import static com.android.launcher3.util.SecureSettingsObserver.newNotificationS import android.app.Activity; import android.app.DialogFragment; import android.app.Fragment; import android.content.ComponentName; import android.content.Context; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.os.Bundle; import android.provider.Settings; import android.text.TextUtils; Loading @@ -32,6 +36,7 @@ import com.android.launcher3.LauncherFiles; import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.graphics.GridOptionsProvider; import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper; import com.android.launcher3.util.SecureSettingsObserver; Loading @@ -47,7 +52,8 @@ import androidx.recyclerview.widget.RecyclerView; * Settings activity for Launcher. Currently implements the following setting: Allow rotation */ public class SettingsActivity extends Activity implements OnPreferenceStartFragmentCallback, OnPreferenceStartScreenCallback { implements OnPreferenceStartFragmentCallback, OnPreferenceStartScreenCallback, SharedPreferences.OnSharedPreferenceChangeListener{ private static final String DEVELOPER_OPTIONS_KEY = "pref_developer_options"; private static final String FLAGS_PREFERENCE_KEY = "flag_toggler"; Loading @@ -61,6 +67,8 @@ public class SettingsActivity extends Activity private static final int DELAY_HIGHLIGHT_DURATION_MILLIS = 600; public static final String SAVE_HIGHLIGHTED_KEY = "android:preference_highlighted"; public static final String GRID_OPTIONS_PREFERENCE_KEY = "pref_grid_options"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Loading @@ -79,6 +87,28 @@ public class SettingsActivity extends Activity .replace(android.R.id.content, f) .commit(); } Utilities.getPrefs(getApplicationContext()).registerOnSharedPreferenceChangeListener(this); } @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (GRID_OPTIONS_PREFERENCE_KEY.equals(key)) { final ComponentName cn = new ComponentName(getApplicationContext(), GridOptionsProvider.class); Context c = getApplicationContext(); int oldValue = c.getPackageManager().getComponentEnabledSetting(cn); int newValue; if (Utilities.getPrefs(c).getBoolean(GRID_OPTIONS_PREFERENCE_KEY, false)) { newValue = PackageManager.COMPONENT_ENABLED_STATE_ENABLED; } else { newValue = PackageManager.COMPONENT_ENABLED_STATE_DISABLED; } if (oldValue != newValue) { c.getPackageManager().setComponentEnabledSetting(cn, newValue, PackageManager.DONT_KILL_APP); } } } private boolean startFragment(String fragment, Bundle args, String key) { Loading Loading @@ -200,6 +230,10 @@ public class SettingsActivity extends Activity // Show if plugins are enabled or flag UI is enabled. return FeatureFlags.showFlagTogglerUi(getContext()) || PluginManagerWrapper.hasPlugins(getContext()); case GRID_OPTIONS_PREFERENCE_KEY: return Utilities.isDevelopersOptionsEnabled(getContext()) && Utilities.IS_DEBUG_DEVICE && Utilities.existsStyleWallpapers(getContext()); } return true; Loading