diff options
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)); } } } |