summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI
diff options
context:
space:
mode:
authorDaniel Sandler <dsandler@google.com>2010-08-17 00:41:00 -0400
committerDaniel Sandler <dsandler@google.com>2010-11-04 16:55:29 -0400
commitb73617de462579f7c12c25a4c2747c576f00f6a2 (patch)
tree1f070d8a32c97062feca491ed9675af8d7c874dc /packages/SystemUI
parent1ab022b8c8b063d95a591bf40109986c5b1bbb11 (diff)
downloadframeworks_base-b73617de462579f7c12c25a4c2747c576f00f6a2.zip
frameworks_base-b73617de462579f7c12c25a4c2747c576f00f6a2.tar.gz
frameworks_base-b73617de462579f7c12c25a4c2747c576f00f6a2.tar.bz2
Rotation lock.
IWindowManager now supports two new methods, freezeRotation() and thawRotation(), that allow a caller to temporarily stash the device's current rotation as the default rotation (when no other constraints are present). The system bar uses this to implement a user-accessible rotation lock by calling freezeRotation() and then turning off accelerometer-based display rotation; unless overridden by an app, the display will continue to appear in the frozen rotation until the rotation is unlocked by the user (either via the rotation lock icon in the system bar or by checking "rotate screen automatically" in Settings). Bug: 2949639 Change-Id: Icd21c169d1053719590e72401f229424b254622f
Diffstat (limited to 'packages/SystemUI')
-rw-r--r--packages/SystemUI/res/drawable-land-mdpi/ic_sysbar_rotate_off.png (renamed from packages/SystemUI/res/drawable-mdpi/ic_sysbar_rotate_off_lanscape.png)bin595 -> 595 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/ic_sysbar_rotate_off.pngbin0 -> 548 bytes
-rw-r--r--packages/SystemUI/res/drawable-port-mdpi/ic_sysbar_rotate_off.png (renamed from packages/SystemUI/res/drawable-mdpi/ic_sysbar_rotate_off_portrait.png)bin616 -> 616 bytes
-rw-r--r--packages/SystemUI/res/values-land/strings.xml23
-rw-r--r--packages/SystemUI/res/values-port/strings.xml23
-rw-r--r--packages/SystemUI/res/values/strings.xml6
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/tablet/SystemPanel.java53
7 files changed, 104 insertions, 1 deletions
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_rotate_off_lanscape.png b/packages/SystemUI/res/drawable-land-mdpi/ic_sysbar_rotate_off.png
index adaadf7..adaadf7 100644
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_rotate_off_lanscape.png
+++ b/packages/SystemUI/res/drawable-land-mdpi/ic_sysbar_rotate_off.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_rotate_off.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_rotate_off.png
new file mode 100644
index 0000000..9e6793a
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_rotate_off.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_rotate_off_portrait.png b/packages/SystemUI/res/drawable-port-mdpi/ic_sysbar_rotate_off.png
index fdc0ac7..fdc0ac7 100644
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_rotate_off_portrait.png
+++ b/packages/SystemUI/res/drawable-port-mdpi/ic_sysbar_rotate_off.png
Binary files differ
diff --git a/packages/SystemUI/res/values-land/strings.xml b/packages/SystemUI/res/values-land/strings.xml
new file mode 100644
index 0000000..e05e36b
--- /dev/null
+++ b/packages/SystemUI/res/values-land/strings.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/**
+ * Copyright (c) 2010, 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.
+ */
+-->
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <!-- Rotation lock toast text: shown when rotation lock is turned on in landscape orientation.
+ -->
+ <string name="toast_rotation_locked">Screen is now locked in landscape orientation.</string>
+</resources>
diff --git a/packages/SystemUI/res/values-port/strings.xml b/packages/SystemUI/res/values-port/strings.xml
new file mode 100644
index 0000000..d3ab67b
--- /dev/null
+++ b/packages/SystemUI/res/values-port/strings.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/**
+ * Copyright (c) 2010, 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.
+ */
+-->
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <!-- Rotation lock toast text: shown when rotation lock is turned on in portrait orientation.
+ -->
+ <string name="toast_rotation_locked">Screen is now locked in portrait orientation.</string>
+</resources>
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 701aa9f..f34dc22 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -84,5 +84,11 @@
-->
<string name="recent_tasks_empty">No recent applications.</string>
+ <!-- Rotation lock toast text: shown when rotation lock is turned off (and the screen will
+ auto-rotate based on the accelerometer). -->
+ <string name="toast_rotation_free">Screen will rotate automatically.</string>
+ <!-- Rotation lock toast text: shown when rotation lock is turned on and the orientation is
+ undefined. -->
+ <string name="toast_rotation_locked">Screen rotation is now locked.</string>
</resources>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/SystemPanel.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/SystemPanel.java
index a0f5be6..b4a9d76 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/SystemPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/SystemPanel.java
@@ -55,6 +55,7 @@ import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.view.IWindowManager;
import android.view.WindowManager;
import android.view.WindowManagerImpl;
import android.widget.Button;
@@ -74,6 +75,8 @@ import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.telephony.cdma.EriInfo;
import com.android.internal.telephony.cdma.TtyIntent;
+import com.android.server.WindowManagerService;
+
import com.android.systemui.statusbar.*;
import com.android.systemui.R;
@@ -102,6 +105,8 @@ public class SystemPanel extends LinearLayout implements StatusBarPanel {
private TextView mBatteryText;
private TextView mSignalText;
+ private final IWindowManager mWM;
+
private final AudioManager mAudioManager;
private final WifiManager mWifiManager;
private final TelephonyManager mPhone;
@@ -397,6 +402,11 @@ public class SystemPanel extends LinearLayout implements StatusBarPanel {
public SystemPanel(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
+ // our mighty overlord
+ mWM = IWindowManager.Stub.asInterface(
+ ServiceManager.getService("window"));
+
+
// get notified of phone state changes
TelephonyManager telephonyManager =
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
@@ -437,6 +447,7 @@ public class SystemPanel extends LinearLayout implements StatusBarPanel {
});
mSoundButton = (ImageButton)findViewById(R.id.sound);
+ mSoundButton.setAlpha(getSilentMode() ? 0x7F : 0xFF);
mSoundButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
setSilentMode(!getSilentMode());
@@ -444,9 +455,22 @@ public class SystemPanel extends LinearLayout implements StatusBarPanel {
}
});
mOrientationButton = (ImageButton)findViewById(R.id.orientation);
+ mOrientationButton.setImageResource(
+ getAutoRotate()
+ ? R.drawable.ic_sysbar_rotate_on
+ : R.drawable.ic_sysbar_rotate_off);
mOrientationButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
- Toast.makeText(getContext(), "Orientation control not implemented; please adjust neck angle.", Toast.LENGTH_SHORT).show();
+ setAutoRotate(!getAutoRotate());
+ mOrientationButton.setImageResource(
+ getAutoRotate()
+ ? R.drawable.ic_sysbar_rotate_on
+ : R.drawable.ic_sysbar_rotate_off);
+ Toast.makeText(getContext(),
+ getAutoRotate()
+ ? R.string.toast_rotation_free
+ : R.string.toast_rotation_locked,
+ Toast.LENGTH_SHORT).show();
}
});
@@ -709,4 +733,31 @@ public class SystemPanel extends LinearLayout implements StatusBarPanel {
? R.drawable.sysbar_toggle_bg_on
: R.drawable.sysbar_toggle_bg_off);
}
+
+ void setAutoRotate(boolean rot) {
+ try {
+ ContentResolver cr = getContext().getContentResolver();
+ if (rot) {
+ mWM.thawRotation();
+ } else {
+ mWM.freezeRotation();
+ }
+ } catch (android.os.RemoteException exc) {
+ }
+ }
+
+ boolean getAutoRotate() {
+ ContentResolver cr = getContext().getContentResolver();
+ return 1 == Settings.System.getInt(cr,
+ Settings.System.ACCELEROMETER_ROTATION,
+ 1);
+ }
+
+ int getDisplayRotation() {
+ try {
+ return mWM.getRotation();
+ } catch (android.os.RemoteException exc) {
+ return 0;
+ }
+ }
}