summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/cyanogenmod/DisplayRotation.java
diff options
context:
space:
mode:
authorLaszlo David <laszlo.david@gmail.com>2013-02-19 22:37:03 +0100
committerLászló Dávid <laszlo.david@gmail.com>2013-03-24 07:48:47 +0100
commit381611b6d59a32ce01a5594f1d4b528e16a88257 (patch)
tree64a1a0618d21a66a63a29037531162c4fc264a90 /src/com/android/settings/cyanogenmod/DisplayRotation.java
parentd63b6d400a0bbd05cc59a8bad6cd07c98ec19386 (diff)
downloadpackages_apps_settings-381611b6d59a32ce01a5594f1d4b528e16a88257.zip
packages_apps_settings-381611b6d59a32ce01a5594f1d4b528e16a88257.tar.gz
packages_apps_settings-381611b6d59a32ce01a5594f1d4b528e16a88257.tar.bz2
Swap volume buttons when the screen is rotated (2/2)
Patch Set 7: Hide option if device not supported Patch Set 8: Fix string derp introduced on ps7 Patch Set 9: Invert the orientation interpretations on tablets Change-Id: Ie2166a4d50050e7a60933251bfc8cda97c42d419
Diffstat (limited to 'src/com/android/settings/cyanogenmod/DisplayRotation.java')
-rw-r--r--src/com/android/settings/cyanogenmod/DisplayRotation.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/com/android/settings/cyanogenmod/DisplayRotation.java b/src/com/android/settings/cyanogenmod/DisplayRotation.java
index 92a3f29..940169d 100644
--- a/src/com/android/settings/cyanogenmod/DisplayRotation.java
+++ b/src/com/android/settings/cyanogenmod/DisplayRotation.java
@@ -16,6 +16,7 @@
package com.android.settings.cyanogenmod;
+import android.content.Context;
import android.database.ContentObserver;
import android.os.Bundle;
import android.os.Handler;
@@ -28,6 +29,7 @@ import android.provider.Settings;
import com.android.internal.view.RotationPolicy;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.Utils;
public class DisplayRotation extends SettingsPreferenceFragment implements OnPreferenceChangeListener {
private static final String TAG = "DisplayRotation";
@@ -37,12 +39,14 @@ public class DisplayRotation extends SettingsPreferenceFragment implements OnPre
private static final String ROTATION_90_PREF = "display_rotation_90";
private static final String ROTATION_180_PREF = "display_rotation_180";
private static final String ROTATION_270_PREF = "display_rotation_270";
+ private static final String KEY_SWAP_VOLUME_BUTTONS = "swap_volume_buttons";
private CheckBoxPreference mAccelerometer;
private CheckBoxPreference mRotation0Pref;
private CheckBoxPreference mRotation90Pref;
private CheckBoxPreference mRotation180Pref;
private CheckBoxPreference mRotation270Pref;
+ private CheckBoxPreference mSwapVolumeButtons;
public static final int ROTATION_0_MODE = 1;
public static final int ROTATION_90_MODE = 2;
@@ -86,6 +90,17 @@ public class DisplayRotation extends SettingsPreferenceFragment implements OnPre
mRotation90Pref.setChecked((mode & ROTATION_90_MODE) != 0);
mRotation180Pref.setChecked((mode & ROTATION_180_MODE) != 0);
mRotation270Pref.setChecked((mode & ROTATION_270_MODE) != 0);
+
+ mSwapVolumeButtons = (CheckBoxPreference) prefSet.findPreference(KEY_SWAP_VOLUME_BUTTONS);
+ if (mSwapVolumeButtons != null) {
+ if (!Utils.hasVolumeRocker(getActivity())) {
+ prefSet.removePreference(mSwapVolumeButtons);
+ } else {
+ int swapVolumeKeys = Settings.System.getInt(getContentResolver(),
+ Settings.System.SWAP_VOLUME_KEYS_ON_ROTATION, 0);
+ mSwapVolumeButtons.setChecked(swapVolumeKeys > 0);
+ }
+ }
}
@Override
@@ -140,6 +155,13 @@ public class DisplayRotation extends SettingsPreferenceFragment implements OnPre
Settings.System.putInt(getActivity().getApplicationContext().getContentResolver(),
Settings.System.ACCELEROMETER_ROTATION_ANGLES, mode);
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);
}
return super.onPreferenceTreeClick(preferenceScreen, preference);