Adding Launcher Mode settings to Launcher settings

Bug: 364711735
Test: NA
Flag: com.android.launcher3.one_grid_specs
Change-Id: Iab688ebdb8449f9258b61f59a0afe97875f82a81
This commit is contained in:
Sebastian Franco
2024-10-02 15:16:37 -07:00
parent d39c31da74
commit 9e4c99befd
11 changed files with 192 additions and 32 deletions
@@ -26,6 +26,7 @@ import static com.android.launcher3.states.RotationHelper.ALLOW_ROTATION_PREFERE
import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
@@ -66,6 +67,8 @@ public class SettingsActivity extends FragmentActivity
@VisibleForTesting
static final String DEVELOPER_OPTIONS_KEY = "pref_developer_options";
public static final String FIXED_LANDSCAPE_MODE = "pref_fixed_landscape_mode";
private static final String NOTIFICATION_DOTS_PREFERENCE_KEY = "pref_icon_badging";
public static final String EXTRA_FRAGMENT_ARGS = ":settings:fragment_args";
@@ -236,7 +239,7 @@ public class SettingsActivity extends FragmentActivity
/**
* Finds the parent preference screen for the given target key.
*
* @param parent the parent preference screen
* @param parent the parent preference screen
* @param targetKey the key of the preference to find
* @return the parent preference screen that contains the target preference
*/
@@ -286,13 +289,11 @@ public class SettingsActivity extends FragmentActivity
* will remove that preference from the list.
*/
protected boolean initPreference(Preference preference) {
DisplayController.Info info = DisplayController.INSTANCE.get(getContext()).getInfo();
switch (preference.getKey()) {
case NOTIFICATION_DOTS_PREFERENCE_KEY:
return BuildConfig.NOTIFICATION_DOTS_ENABLED;
case ALLOW_ROTATION_PREFERENCE_KEY:
DisplayController.Info info =
DisplayController.INSTANCE.get(getContext()).getInfo();
if (info.isTablet(info.realBounds)) {
// Launcher supports rotation by default. No need to show this setting.
return false;
@@ -300,14 +301,29 @@ public class SettingsActivity extends FragmentActivity
// Initialize the UI once
preference.setDefaultValue(RotationHelper.getAllowRotationDefaultValue(info));
return true;
case DEVELOPER_OPTIONS_KEY:
if (IS_STUDIO_BUILD) {
preference.setOrder(0);
}
return mDeveloperOptionsEnabled;
case FIXED_LANDSCAPE_MODE:
if (!Flags.oneGridSpecs()) {
return false;
}
// When the setting changes rotate the screen accordingly to showcase the result
// of the setting
preference.setOnPreferenceChangeListener(
(pref, newValue) -> {
getActivity().setRequestedOrientation(
(boolean) newValue
? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
: ActivityInfo.SCREEN_ORIENTATION_USER
);
return true;
}
);
return !info.isTablet(info.realBounds);
}
return true;
}