summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorLaszlo David <laszlo.david@gmail.com>2013-02-16 01:23:12 +0100
committerLászló Dávid <laszlo.david@gmail.com>2013-03-24 08:04:49 +0100
commit7d0a8e3019352e1a2f1147b23abc7989bf695243 (patch)
tree29c9ab98c6f31a78f01e71f969a50d43e99ea928 /media
parent4baf37a1cd78ef7c9d8293004777af420c0d1dc7 (diff)
downloadframeworks_base-7d0a8e3019352e1a2f1147b23abc7989bf695243.zip
frameworks_base-7d0a8e3019352e1a2f1147b23abc7989bf695243.tar.gz
frameworks_base-7d0a8e3019352e1a2f1147b23abc7989bf695243.tar.bz2
Swap volume buttons when the screen is rotated (1/2)
See: http://review.cyanogenmod.org/#/c/14530/ Patch Set 8: Invert the orientation interpretations on tablets Change-Id: I201febc2827e6fbd347cb0e3f8d3347ad1bc487b
Diffstat (limited to 'media')
-rw-r--r--media/java/android/media/AudioManager.java38
1 files changed, 27 insertions, 11 deletions
diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java
index f55a0bb..ac2588d 100644
--- a/media/java/android/media/AudioManager.java
+++ b/media/java/android/media/AudioManager.java
@@ -36,7 +36,9 @@ import android.os.ServiceManager;
import android.provider.Settings;
import android.util.Log;
import android.view.KeyEvent;
+import android.view.Surface;
import android.view.VolumePanel;
+import android.view.WindowManager;
import java.util.HashMap;
@@ -54,6 +56,7 @@ public class AudioManager {
private final boolean mUseVolumeKeySounds;
private static String TAG = "AudioManager";
private final ProfileManager mProfileManager;
+ private final WindowManager mWindowManager;
/**
* Broadcast intent, a hint for applications that audio is about to become
@@ -426,6 +429,7 @@ public class AudioManager {
mUseVolumeKeySounds = mContext.getResources().getBoolean(
com.android.internal.R.bool.config_useVolumeKeySounds);
mProfileManager = (ProfileManager) context.getSystemService(Context.PROFILE_SERVICE);
+ mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
}
private static IAudioService getService()
@@ -476,21 +480,33 @@ public class AudioManager {
* Adjust the volume in on key down since it is more
* responsive to the user.
*/
+ int direction;
+ int swapKeys = Settings.System.getInt(mContext.getContentResolver(),
+ Settings.System.SWAP_VOLUME_KEYS_ON_ROTATION, 0);
+ int rotation = mWindowManager.getDefaultDisplay().getRotation();
+ if (swapKeys == 1 // phone or hybrid
+ && (rotation == Surface.ROTATION_90
+ || rotation == Surface.ROTATION_180)) {
+ direction = keyCode == KeyEvent.KEYCODE_VOLUME_UP
+ ? ADJUST_LOWER
+ : ADJUST_RAISE;
+ } else if (swapKeys == 2 // tablet
+ && (rotation == Surface.ROTATION_180
+ || rotation == Surface.ROTATION_270)) {
+ direction = keyCode == KeyEvent.KEYCODE_VOLUME_UP
+ ? ADJUST_LOWER
+ : ADJUST_RAISE;
+ } else {
+ direction = keyCode == KeyEvent.KEYCODE_VOLUME_UP
+ ? ADJUST_RAISE
+ : ADJUST_LOWER;
+ }
int flags = FLAG_SHOW_UI | FLAG_VIBRATE;
if (mUseMasterVolume) {
- adjustMasterVolume(
- keyCode == KeyEvent.KEYCODE_VOLUME_UP
- ? ADJUST_RAISE
- : ADJUST_LOWER,
- flags);
+ adjustMasterVolume(direction, flags);
} else {
- adjustSuggestedStreamVolume(
- keyCode == KeyEvent.KEYCODE_VOLUME_UP
- ? ADJUST_RAISE
- : ADJUST_LOWER,
- stream,
- flags);
+ adjustSuggestedStreamVolume(direction, stream, flags);
}
break;
case KeyEvent.KEYCODE_VOLUME_MUTE: