diff options
-rw-r--r-- | res/values/cm_strings.xml | 1 | ||||
-rw-r--r-- | res/xml/display_rotation.xml | 6 | ||||
-rw-r--r-- | src/com/android/settings/DisplaySettings.java | 24 | ||||
-rw-r--r-- | src/com/android/settings/cyanogenmod/DisplayRotation.java | 24 |
4 files changed, 39 insertions, 16 deletions
diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml index 182849a..cc507c3 100644 --- a/res/values/cm_strings.xml +++ b/res/values/cm_strings.xml @@ -399,6 +399,7 @@ <string name="display_rotation_title">Rotation</string> <string name="display_rotation_disabled">Disabled</string> <string name="display_rotation_unit">degrees</string> + <string name="display_lockscreen_rotation_title">Rotate lock screen</string> <string name="display_rotation_category_title">Rotation modes</string> <string name="display_rotation_0_title">0 degrees</string> <string name="display_rotation_90_title">90 degrees</string> diff --git a/res/xml/display_rotation.xml b/res/xml/display_rotation.xml index 86b9e9f..c21de2e 100644 --- a/res/xml/display_rotation.xml +++ b/res/xml/display_rotation.xml @@ -21,13 +21,15 @@ <CheckBoxPreference android:key="accelerometer" android:title="@string/accelerometer_title" /> - <CheckBoxPreference android:key="swap_volume_buttons" android:title="@string/swap_volume_buttons_title" android:summary="@string/swap_volume_buttons_summary" android:dependency="accelerometer" /> - + <CheckBoxPreference + android:key="lockscreen_rotation" + android:title="@string/display_lockscreen_rotation_title" + android:dependency="accelerometer" /> <PreferenceCategory android:key="display_rotation_category" android:title="@string/display_rotation_category_title" /> diff --git a/src/com/android/settings/DisplaySettings.java b/src/com/android/settings/DisplaySettings.java index 2e9085a..ed60b84 100644 --- a/src/com/android/settings/DisplaySettings.java +++ b/src/com/android/settings/DisplaySettings.java @@ -61,6 +61,7 @@ public class DisplaySettings extends SettingsPreferenceFragment implements private static final String KEY_SCREEN_SAVER = "screensaver"; private static final String KEY_WIFI_DISPLAY = "wifi_display"; private static final String KEY_DISPLAY_ROTATION = "display_rotation"; + private static final String KEY_LOCKSCREEN_ROTATION = "lockscreen_rotation"; private static final String KEY_WAKEUP_CATEGORY = "category_wakeup_options"; private static final String KEY_HOME_WAKE = "pref_home_wake"; private static final String KEY_VOLUME_WAKE = "pref_volume_wake"; @@ -111,16 +112,25 @@ public class DisplaySettings extends SettingsPreferenceFragment implements public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ContentResolver resolver = getActivity().getContentResolver(); + Resources res = getResources(); addPreferencesFromResource(R.xml.display_settings); mDisplayRotationPreference = (PreferenceScreen) findPreference(KEY_DISPLAY_ROTATION); + final CheckBoxPreference lockScreenRotation = + (CheckBoxPreference) findPreference(KEY_LOCKSCREEN_ROTATION); + if (lockScreenRotation != null) { + if (!res.getBoolean(com.android.internal.R.bool.config_enableLockScreenRotation)) { + getPreferenceScreen().removePreference(lockScreenRotation); + } + } + mScreenSaverPreference = findPreference(KEY_SCREEN_SAVER); - if (mScreenSaverPreference != null - && getResources().getBoolean( - com.android.internal.R.bool.config_dreamsSupported) == false) { - getPreferenceScreen().removePreference(mScreenSaverPreference); + if (mScreenSaverPreference != null) { + if (!res.getBoolean(com.android.internal.R.bool.config_dreamsSupported)) { + getPreferenceScreen().removePreference(mScreenSaverPreference); + } } mScreenTimeoutPreference = (ListPreference) findPreference(KEY_SCREEN_TIMEOUT); @@ -153,7 +163,7 @@ public class DisplaySettings extends SettingsPreferenceFragment implements // Home button wake mHomeWake = (CheckBoxPreference) findPreference(KEY_HOME_WAKE); if (mHomeWake != null) { - if (!getResources().getBoolean(R.bool.config_show_homeWake)) { + if (!res.getBoolean(R.bool.config_show_homeWake)) { wakeupCategory.removePreference(mHomeWake); } else { mHomeWake.setChecked(Settings.System.getInt(resolver, @@ -165,7 +175,7 @@ public class DisplaySettings extends SettingsPreferenceFragment implements // Volume rocker wake mVolumeWake = (CheckBoxPreference) findPreference(KEY_VOLUME_WAKE); if (mVolumeWake != null) { - if (!getResources().getBoolean(R.bool.config_show_volumeRockerWake) + if (!res.getBoolean(R.bool.config_show_volumeRockerWake) || !Utils.hasVolumeRocker(getActivity())) { wakeupCategory.removePreference(mVolumeWake); } else { @@ -181,7 +191,7 @@ public class DisplaySettings extends SettingsPreferenceFragment implements } mScreenOffAnimation = (CheckBoxPreference) findPreference(KEY_SCREEN_OFF_ANIMATION); - if (getResources().getBoolean(com.android.internal.R.bool.config_screenOffAnimation)) { + if (res.getBoolean(com.android.internal.R.bool.config_screenOffAnimation)) { mScreenOffAnimation.setChecked(Settings.System.getInt(resolver, Settings.System.SCREEN_OFF_ANIMATION, 1) == 1); } else { diff --git a/src/com/android/settings/cyanogenmod/DisplayRotation.java b/src/com/android/settings/cyanogenmod/DisplayRotation.java index 15b4137..b11c2fb 100644 --- a/src/com/android/settings/cyanogenmod/DisplayRotation.java +++ b/src/com/android/settings/cyanogenmod/DisplayRotation.java @@ -35,6 +35,7 @@ public class DisplayRotation extends SettingsPreferenceFragment implements OnPre private static final String TAG = "DisplayRotation"; private static final String KEY_ACCELEROMETER = "accelerometer"; + private static final String LOCKSCREEN_ROTATION = "lockscreen_rotation"; private static final String ROTATION_0_PREF = "display_rotation_0"; private static final String ROTATION_90_PREF = "display_rotation_90"; private static final String ROTATION_180_PREF = "display_rotation_180"; @@ -42,6 +43,7 @@ public class DisplayRotation extends SettingsPreferenceFragment implements OnPre private static final String KEY_SWAP_VOLUME_BUTTONS = "swap_volume_buttons"; private CheckBoxPreference mAccelerometer; + private CheckBoxPreference mLockScreenRotationPref; private CheckBoxPreference mRotation0Pref; private CheckBoxPreference mRotation90Pref; private CheckBoxPreference mRotation180Pref; @@ -74,6 +76,7 @@ public class DisplayRotation extends SettingsPreferenceFragment implements OnPre mAccelerometer = (CheckBoxPreference) findPreference(KEY_ACCELEROMETER); mAccelerometer.setPersistent(false); + mLockScreenRotationPref = (CheckBoxPreference) prefSet.findPreference(LOCKSCREEN_ROTATION); mRotation0Pref = (CheckBoxPreference) prefSet.findPreference(ROTATION_0_PREF); mRotation90Pref = (CheckBoxPreference) prefSet.findPreference(ROTATION_90_PREF); mRotation180Pref = (CheckBoxPreference) prefSet.findPreference(ROTATION_180_PREF); @@ -99,6 +102,11 @@ public class DisplayRotation extends SettingsPreferenceFragment implements OnPre } } + if (mLockScreenRotationPref != null) { + mLockScreenRotationPref.setChecked(Settings.System.getInt(getContentResolver(), + Settings.System.LOCKSCREEN_ROTATION, 0) != 0); + } + if (hasRotationLock) { // Disable accelerometer checkbox, but leave others enabled mAccelerometer.setEnabled(false); @@ -159,16 +167,18 @@ public class DisplayRotation extends SettingsPreferenceFragment implements OnPre mode |= ROTATION_0_MODE; mRotation0Pref.setChecked(true); } - Settings.System.putInt(getActivity().getApplicationContext().getContentResolver(), + Settings.System.putInt(getActivity().getContentResolver(), Settings.System.ACCELEROMETER_ROTATION_ANGLES, mode); return true; + } else if (preference == mLockScreenRotationPref) { + boolean value = mLockScreenRotationPref.isChecked(); + Settings.System.putInt(getActivity().getContentResolver(), + Settings.System.LOCKSCREEN_ROTATION, value ? 1 : 0); + return true; } else if (preference == mSwapVolumeButtons) { - Context context = getActivity().getApplicationContext(); - Settings.System.putInt(context.getContentResolver(), - Settings.System.SWAP_VOLUME_KEYS_ON_ROTATION, - mSwapVolumeButtons.isChecked() - ? (Utils.isTablet(context) ? 2 : 1) - : 0); + int value = mSwapVolumeButtons.isChecked() ? (Utils.isTablet(getActivity()) ? 2 : 1) : 0; + Settings.System.putInt(getActivity().getContentResolver(), + Settings.System.SWAP_VOLUME_KEYS_ON_ROTATION, value); } return super.onPreferenceTreeClick(preferenceScreen, preference); |