From 8ab172e8d9c2e926921bb52838c2322142fb3c65 Mon Sep 17 00:00:00 2001 From: John Spurlock Date: Thu, 19 Dec 2013 16:39:23 -0500 Subject: Add rotation-lock to Quick Settings on phones. Make the rotation-lock QS tile available for display on phones. Devices < sw600dp are only allowed to lock rotation to their natural orientation (i.e. portrait on most phones), so tweak the QS tile label to make this clear. e.g. "Locked to Portrait" instead of "Rotation Locked" on portrait phones. Simplify RotationLockController now that the sw600 check is no longer hardcoded in RotationPolicy. Remove redundant sw600dp check in SystemUI, everything driven from the RotationPolicy helper, though SystemUI can still choose not to display the tile at all with a resource config. Clean up some of the docs in RotationPolicy to make clear the subtle distinction between the two ways of locking rotation: - From Accessibility (locks to natural orientation on all devices) - From System UI (locks to natural < sw600dp, else current rotation) Bug:11062710 Change-Id: I5caa4485c9501315da9fed964d6667d3012b43cb --- packages/SystemUI/res/values-sw600dp/config.xml | 3 --- packages/SystemUI/res/values/config.xml | 5 +--- packages/SystemUI/res/values/strings.xml | 4 +++ .../systemui/statusbar/phone/PhoneStatusBar.java | 5 +++- .../systemui/statusbar/phone/QuickSettings.java | 7 ++--- .../statusbar/phone/QuickSettingsModel.java | 10 ++++++- .../statusbar/policy/RotationLockController.java | 31 ++++++++-------------- 7 files changed, 33 insertions(+), 32 deletions(-) (limited to 'packages') diff --git a/packages/SystemUI/res/values-sw600dp/config.xml b/packages/SystemUI/res/values-sw600dp/config.xml index 48a02ab..b77f1e0 100644 --- a/packages/SystemUI/res/values-sw600dp/config.xml +++ b/packages/SystemUI/res/values-sw600dp/config.xml @@ -29,9 +29,6 @@ 1 - - true - false diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml index 3869db3..1dd9300 100644 --- a/packages/SystemUI/res/values/config.xml +++ b/packages/SystemUI/res/values/config.xml @@ -50,7 +50,7 @@ false - + true @@ -84,9 +84,6 @@ 1 - - false - true diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index 5afd55b..94796af 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -464,6 +464,10 @@ Auto Rotate Rotation Locked + + Locked to Portrait + + Locked to Landscape Input Method diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index bbac4ef..b181658 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -534,7 +534,10 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode { mBatteryController = new BatteryController(mContext); mNetworkController = new NetworkController(mContext); mBluetoothController = new BluetoothController(mContext); - mRotationLockController = new RotationLockController(mContext); + if (mContext.getResources().getBoolean(R.bool.config_showRotationLock) + || QuickSettings.DEBUG_GONE_TILES) { + mRotationLockController = new RotationLockController(mContext); + } final SignalClusterView signalCluster = (SignalClusterView)mStatusBarView.findViewById(R.id.signal_cluster); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java index e6fd7d0..4d7ff5e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java @@ -176,7 +176,9 @@ class QuickSettings { bluetoothController.addStateChangedCallback(mModel); batteryController.addStateChangedCallback(mModel); locationController.addSettingsChangedCallback(mModel); - rotationLockController.addRotationLockControllerCallback(mModel); + if (rotationLockController != null) { + rotationLockController.addRotationLockControllerCallback(mModel); + } } private void queryForSslCaCerts() { @@ -503,8 +505,7 @@ class QuickSettings { } // Rotation Lock - if (mContext.getResources().getBoolean(R.bool.quick_settings_show_rotation_lock) - || DEBUG_GONE_TILES) { + if (mRotationLockController != null) { final QuickSettingsBasicTile rotationLockTile = new QuickSettingsBasicTile(mContext); rotationLockTile.setOnClickListener(new View.OnClickListener() { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java index 12e08d0..11cba7b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java @@ -24,6 +24,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.PackageManager; +import android.content.res.Configuration; import android.content.res.Resources; import android.database.ContentObserver; import android.graphics.drawable.Drawable; @@ -409,6 +410,7 @@ class QuickSettingsModel implements BluetoothStateChangeCallback, private State mSslCaCertWarningState = new State(); private RotationLockController mRotationLockController; + private int mRotationLockedLabel; public QuickSettingsModel(Context context) { mContext = context; @@ -919,6 +921,12 @@ class QuickSettingsModel implements BluetoothStateChangeCallback, mRotationLockTile = view; mRotationLockCallback = cb; mRotationLockController = rotationLockController; + final int lockOrientation = mRotationLockController.getRotationLockOrientation(); + mRotationLockedLabel = lockOrientation == Configuration.ORIENTATION_PORTRAIT + ? R.string.quick_settings_rotation_locked_portrait_label + : lockOrientation == Configuration.ORIENTATION_LANDSCAPE + ? R.string.quick_settings_rotation_locked_landscape_label + : R.string.quick_settings_rotation_locked_label; onRotationLockChanged(); } void onRotationLockChanged() { @@ -933,7 +941,7 @@ class QuickSettingsModel implements BluetoothStateChangeCallback, ? R.drawable.ic_qs_rotation_locked : R.drawable.ic_qs_auto_rotate; mRotationLockState.label = rotationLocked - ? mContext.getString(R.string.quick_settings_rotation_locked_label) + ? mContext.getString(mRotationLockedLabel) : mContext.getString(R.string.quick_settings_rotation_unlocked_label); mRotationLockCallback.refreshView(mRotationLockTile, mRotationLockState); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RotationLockController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RotationLockController.java index 6f61ec8..98d205a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RotationLockController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RotationLockController.java @@ -17,6 +17,7 @@ package com.android.systemui.statusbar.policy; import android.content.Context; +import android.content.res.Configuration; import android.os.UserHandle; import com.android.internal.view.RotationPolicy; @@ -42,42 +43,32 @@ public final class RotationLockController { public RotationLockController(Context context) { mContext = context; - notifyChanged(); - if (RotationPolicy.isRotationLockToggleSupported(mContext)) { - RotationPolicy.registerRotationPolicyListener(mContext, - mRotationPolicyListener, UserHandle.USER_ALL); - } + RotationPolicy.registerRotationPolicyListener(mContext, + mRotationPolicyListener, UserHandle.USER_ALL); } public void addRotationLockControllerCallback(RotationLockControllerCallback callback) { mCallbacks.add(callback); } + public int getRotationLockOrientation() { + return RotationPolicy.getRotationLockOrientation(mContext); + } + public boolean isRotationLocked() { - if (RotationPolicy.isRotationLockToggleSupported(mContext)) { - return RotationPolicy.isRotationLocked(mContext); - } - return false; + return RotationPolicy.isRotationLocked(mContext); } public void setRotationLocked(boolean locked) { - if (RotationPolicy.isRotationLockToggleSupported(mContext)) { - RotationPolicy.setRotationLock(mContext, locked); - } + RotationPolicy.setRotationLock(mContext, locked); } public boolean isRotationLockAffordanceVisible() { - if (RotationPolicy.isRotationLockToggleSupported(mContext)) { - return RotationPolicy.isRotationLockToggleVisible(mContext); - } - return false; + return RotationPolicy.isRotationLockToggleVisible(mContext); } public void release() { - if (RotationPolicy.isRotationLockToggleSupported(mContext)) { - RotationPolicy.unregisterRotationPolicyListener(mContext, - mRotationPolicyListener); - } + RotationPolicy.unregisterRotationPolicyListener(mContext, mRotationPolicyListener); } private void notifyChanged() { -- cgit v1.1