diff options
author | Pawit Pornkitprasan <p.pawit@gmail.com> | 2013-03-28 08:46:14 +0700 |
---|---|---|
committer | Pawit Pornkitprasan <p.pawit@gmail.com> | 2013-03-28 19:23:44 +0700 |
commit | fbffefc3e45912959db9ff828ff1f8f523b7a8e6 (patch) | |
tree | 6c9869ee70d483f3c82ca1cb3830e8bf6ea4a4ce /src/com/android/settings/cyanogenmod | |
parent | 27692ae1c919770057e3f68c1e640d80d65219f4 (diff) | |
download | packages_apps_settings-fbffefc3e45912959db9ff828ff1f8f523b7a8e6.zip packages_apps_settings-fbffefc3e45912959db9ff828ff1f8f523b7a8e6.tar.gz packages_apps_settings-fbffefc3e45912959db9ff828ff1f8f523b7a8e6.tar.bz2 |
Settings: use checkbox for expanded desktop setting for devices without navbar
On those devices, there are only two settings an a checkbox would fit better.
Change-Id: I394736dacf7765f7fdda47d6d743d7479bd4de7e
Diffstat (limited to 'src/com/android/settings/cyanogenmod')
-rw-r--r-- | src/com/android/settings/cyanogenmod/PowerMenu.java | 44 |
1 files changed, 30 insertions, 14 deletions
diff --git a/src/com/android/settings/cyanogenmod/PowerMenu.java b/src/com/android/settings/cyanogenmod/PowerMenu.java index 44a195c..ba6627b 100644 --- a/src/com/android/settings/cyanogenmod/PowerMenu.java +++ b/src/com/android/settings/cyanogenmod/PowerMenu.java @@ -40,6 +40,7 @@ public class PowerMenu extends SettingsPreferenceFragment implements private static final String KEY_REBOOT = "power_menu_reboot"; private static final String KEY_SCREENSHOT = "power_menu_screenshot"; private static final String KEY_EXPANDED_DESKTOP = "power_menu_expanded_desktop"; + private static final String KEY_EXPANDED_DESKTOP_NO_NAVBAR = "power_menu_expanded_desktop_no_navbar"; private static final String KEY_PROFILES = "power_menu_profiles"; private static final String KEY_AIRPLANE = "power_menu_airplane"; private static final String KEY_USER = "power_menu_user"; @@ -47,7 +48,8 @@ public class PowerMenu extends SettingsPreferenceFragment implements private CheckBoxPreference mRebootPref; private CheckBoxPreference mScreenshotPref; - ListPreference mExpandedDesktopPref; + private ListPreference mExpandedDesktopPref; + private CheckBoxPreference mExpandedDesktopNoNavbarPref; private CheckBoxPreference mProfilesPref; private CheckBoxPreference mAirplanePref; private CheckBoxPreference mUserPref; @@ -69,16 +71,21 @@ public class PowerMenu extends SettingsPreferenceFragment implements PreferenceScreen prefSet = getPreferenceScreen(); mExpandedDesktopPref = (ListPreference) prefSet.findPreference(KEY_EXPANDED_DESKTOP); - mExpandedDesktopPref.setOnPreferenceChangeListener(this); + mExpandedDesktopNoNavbarPref = (CheckBoxPreference) findPreference(KEY_EXPANDED_DESKTOP_NO_NAVBAR); int expandedDesktopValue = Settings.System.getInt(getContentResolver(), Settings.System.EXPANDED_DESKTOP_STYLE, 0); - mExpandedDesktopPref.setValue(String.valueOf(expandedDesktopValue)); - updateExpandedDesktopSummary(expandedDesktopValue); // Hide no-op "Status bar visible" mode on devices without navbar try { - if (!WindowManagerGlobal.getWindowManagerService().hasNavigationBar()) { - mExpandedDesktopPref.setEntries(R.array.expanded_desktop_entries_no_navbar); - mExpandedDesktopPref.setEntryValues(R.array.expanded_desktop_values_no_navbar); + if (WindowManagerGlobal.getWindowManagerService().hasNavigationBar()) { + mExpandedDesktopPref.setOnPreferenceChangeListener(this); + mExpandedDesktopPref.setValue(String.valueOf(expandedDesktopValue)); + updateExpandedDesktop(expandedDesktopValue); + + prefSet.removePreference(mExpandedDesktopNoNavbarPref); + } else { + mExpandedDesktopNoNavbarPref.setChecked(expandedDesktopValue > 0); + + prefSet.removePreference(mExpandedDesktopPref); } } catch (RemoteException e) { Log.e(TAG, "Error getting navigation bar status"); @@ -115,9 +122,7 @@ public class PowerMenu extends SettingsPreferenceFragment implements public boolean onPreferenceChange(Preference preference, Object newValue) { if (preference == mExpandedDesktopPref) { int expandedDesktopValue = Integer.valueOf((String) newValue); - Settings.System.putInt(getContentResolver(), - Settings.System.EXPANDED_DESKTOP_STYLE, expandedDesktopValue); - updateExpandedDesktopSummary(expandedDesktopValue); + updateExpandedDesktop(expandedDesktopValue); return true; } return false; @@ -132,6 +137,9 @@ public class PowerMenu extends SettingsPreferenceFragment implements Settings.System.putInt(getContentResolver(), Settings.System.POWER_MENU_SCREENSHOT_ENABLED, value ? 1 : 0); + } else if (preference == mExpandedDesktopNoNavbarPref) { + value = mExpandedDesktopNoNavbarPref.isChecked(); + updateExpandedDesktop(value ? 2 : 0); } else if (preference == mRebootPref) { value = mRebootPref.isChecked(); Settings.System.putInt(getContentResolver(), @@ -164,25 +172,33 @@ public class PowerMenu extends SettingsPreferenceFragment implements return true; } - private void updateExpandedDesktopSummary(int value) { + private void updateExpandedDesktop(int value) { Resources res = getResources(); + int summary = -1; + + Settings.System.putInt(getContentResolver(), + Settings.System.EXPANDED_DESKTOP_STYLE, value); if (value == 0) { // Expanded desktop deactivated Settings.System.putInt(getContentResolver(), Settings.System.POWER_MENU_EXPANDED_DESKTOP_ENABLED, 0); - mExpandedDesktopPref.setSummary(res.getString(R.string.expanded_desktop_disabled)); + summary = R.string.expanded_desktop_disabled; // Disable expanded desktop if enabled Settings.System.putInt(getContentResolver(), Settings.System.EXPANDED_DESKTOP_STATE, 0); } else if (value == 1) { Settings.System.putInt(getContentResolver(), Settings.System.POWER_MENU_EXPANDED_DESKTOP_ENABLED, 1); - mExpandedDesktopPref.setSummary(res.getString(R.string.expanded_desktop_status_bar)); + summary = R.string.expanded_desktop_status_bar; } else if (value == 2) { Settings.System.putInt(getContentResolver(), Settings.System.POWER_MENU_EXPANDED_DESKTOP_ENABLED, 1); - mExpandedDesktopPref.setSummary(res.getString(R.string.expanded_desktop_no_status_bar)); + summary = R.string.expanded_desktop_no_status_bar; + } + + if (mExpandedDesktopPref != null && summary != -1) { + mExpandedDesktopPref.setSummary(res.getString(summary)); } } } |