summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/res/layout/quick_settings_tile_rotation_lock.xml25
-rw-r--r--packages/SystemUI/res/values-sw600dp/config.xml3
-rw-r--r--packages/SystemUI/res/values/config.xml3
-rw-r--r--packages/SystemUI/res/values/strings.xml4
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java33
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java23
6 files changed, 91 insertions, 0 deletions
diff --git a/packages/SystemUI/res/layout/quick_settings_tile_rotation_lock.xml b/packages/SystemUI/res/layout/quick_settings_tile_rotation_lock.xml
new file mode 100644
index 000000000000..4dbf6a016356
--- /dev/null
+++ b/packages/SystemUI/res/layout/quick_settings_tile_rotation_lock.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<TextView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ style="@style/TextAppearance.QuickSettings.TileView"
+ android:id="@+id/rotation_lock_textview"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:gravity="center"
+ android:text="@string/quick_settings_rotation_unlocked_label"
+ /> \ No newline at end of file
diff --git a/packages/SystemUI/res/values-sw600dp/config.xml b/packages/SystemUI/res/values-sw600dp/config.xml
index c52b6ca07df7..209ad11e14d5 100644
--- a/packages/SystemUI/res/values-sw600dp/config.xml
+++ b/packages/SystemUI/res/values-sw600dp/config.xml
@@ -25,4 +25,7 @@
<!-- The number of columns that the top level tiles span in the QuickSettings -->
<integer name="quick_settings_user_time_settings_tile_span">1</integer>
+
+ <!-- Whether rotation lock shows up in quick settings or not -->
+ <bool name="quick_settings_show_rotation_lock">true</bool>
</resources>
diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml
index 734e68cdf5a6..1edc3fce1db7 100644
--- a/packages/SystemUI/res/values/config.xml
+++ b/packages/SystemUI/res/values/config.xml
@@ -87,5 +87,8 @@
<!-- The number of columns that the top level tiles span in the QuickSettings -->
<integer name="quick_settings_user_time_settings_tile_span">1</integer>
+
+ <!-- Whether rotation lock shows up in quick settings or not -->
+ <bool name="quick_settings_show_rotation_lock">false</bool>
</resources>
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index fd1c472f34d4..b65b013a474a 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -411,6 +411,10 @@
<string name="quick_settings_bluetooth_label">Bluetooth</string>
<!-- QuickSettings: Brightness [CHAR LIMIT=NONE] -->
<string name="quick_settings_brightness_label">Brightness</string>
+ <!-- QuickSettings: Rotation Unlocked [CHAR LIMIT=NONE] -->
+ <string name="quick_settings_rotation_unlocked_label">Auto Rotate</string>
+ <!-- QuickSettings: Rotation Locked [CHAR LIMIT=NONE] -->
+ <string name="quick_settings_rotation_locked_label">Rotation Locked</string>
<!-- QuickSettings: IME [CHAR LIMIT=NONE] -->
<string name="quick_settings_ime_label">Input Method</string>
<!-- QuickSettings: Location [CHAR LIMIT=NONE] -->
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 38fd7909a8f8..255ab16872ef 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java
@@ -48,6 +48,7 @@ import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
+import com.android.internal.view.RotationPolicy;
import com.android.systemui.R;
import com.android.systemui.statusbar.phone.QuickSettingsModel.State;
import com.android.systemui.statusbar.phone.QuickSettingsModel.UserState;
@@ -89,6 +90,14 @@ class QuickSettings {
private final ArrayList<QuickSettingsTileView> mDynamicSpannedTiles =
new ArrayList<QuickSettingsTileView>();
+ private final RotationPolicy.RotationPolicyListener mRotationPolicyListener =
+ new RotationPolicy.RotationPolicyListener() {
+ @Override
+ public void onChange() {
+ mModel.onRotationLockChanged();
+ }
+ };
+
public QuickSettings(Context context, QuickSettingsContainerView container) {
mDisplayManager = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
mContext = context;
@@ -125,6 +134,7 @@ class QuickSettings {
bluetoothController.addStateChangedCallback(mModel);
batteryController.addStateChangedCallback(mModel);
locationController.addStateChangedCallback(mModel);
+ RotationPolicy.registerRotationPolicyListener(mContext, mRotationPolicyListener);
}
private void queryForUserInformation() {
@@ -293,6 +303,29 @@ class QuickSettings {
parent.addView(rssiTile);
}
+ // Rotation Lock
+ if (mContext.getResources().getBoolean(R.bool.quick_settings_show_rotation_lock)) {
+ QuickSettingsTileView rotationLockTile = (QuickSettingsTileView)
+ inflater.inflate(R.layout.quick_settings_tile, parent, false);
+ rotationLockTile.setContent(R.layout.quick_settings_tile_rotation_lock, inflater);
+ rotationLockTile.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ boolean locked = RotationPolicy.isRotationLocked(mContext);
+ RotationPolicy.setRotationLock(mContext, !locked);
+ }
+ });
+ mModel.addRotationLockTile(rotationLockTile, new QuickSettingsModel.RefreshCallback() {
+ @Override
+ public void refreshView(QuickSettingsTileView view, State state) {
+ TextView tv = (TextView) view.findViewById(R.id.rotation_lock_textview);
+ tv.setCompoundDrawablesRelativeWithIntrinsicBounds(0, state.iconId, 0, 0);
+ tv.setText(state.label);
+ }
+ });
+ parent.addView(rotationLockTile);
+ }
+
// Battery
QuickSettingsTileView batteryTile = (QuickSettingsTileView)
inflater.inflate(R.layout.quick_settings_tile, parent, false);
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 a6117be0dfe1..cecb1ef45bfe 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java
@@ -36,6 +36,7 @@ import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
import android.view.inputmethod.InputMethodSubtype;
+import com.android.internal.view.RotationPolicy;
import com.android.systemui.R;
import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback;
import com.android.systemui.statusbar.policy.LocationController.LocationGpsStateChangeCallback;
@@ -141,6 +142,10 @@ class QuickSettingsModel implements BluetoothStateChangeCallback,
private RefreshCallback mImeCallback;
private State mImeState = new State();
+ private QuickSettingsTileView mRotationLockTile;
+ private RefreshCallback mRotationLockCallback;
+ private State mRotationLockState = new State();
+
public QuickSettingsModel(Context context) {
mContext = context;
mHandler = new Handler();
@@ -372,4 +377,22 @@ class QuickSettingsModel implements BluetoothStateChangeCallback,
return null;
}
+ // Rotation lock
+ void addRotationLockTile(QuickSettingsTileView view, RefreshCallback cb) {
+ mRotationLockTile = view;
+ mRotationLockCallback = cb;
+ onRotationLockChanged();
+ }
+ void onRotationLockChanged() {
+ boolean locked = RotationPolicy.isRotationLocked(mContext);
+ mRotationLockState.enabled = locked;
+ mRotationLockState.iconId = locked
+ ? R.drawable.ic_qs_rotation_locked
+ : R.drawable.ic_qs_auto_rotate;
+ mRotationLockState.label = locked
+ ? mContext.getString(R.string.quick_settings_rotation_locked_label)
+ : mContext.getString(R.string.quick_settings_rotation_unlocked_label);
+ mRotationLockCallback.refreshView(mRotationLockTile, mRotationLockState);
+ }
+
} \ No newline at end of file