summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2012-06-05 19:14:17 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-06-05 19:14:17 -0700
commiteef4bc08137f2324e2974c282992ff546df99e54 (patch)
tree77fa6f2744a1d2552f649402fe530e68609fede1 /packages
parentf22eb96301aa1c4e0f7ac317daa64a617c21855c (diff)
parent615fd3dff2e369d8b786abcfe41b6da988e41001 (diff)
downloadframeworks_base-eef4bc08137f2324e2974c282992ff546df99e54.zip
frameworks_base-eef4bc08137f2324e2974c282992ff546df99e54.tar.gz
frameworks_base-eef4bc08137f2324e2974c282992ff546df99e54.tar.bz2
am 615fd3df: Merge "Implement new rotation policy." into jb-dev
* commit '615fd3dff2e369d8b786abcfe41b6da988e41001': Implement new rotation policy.
Diffstat (limited to 'packages')
-rw-r--r--packages/SystemUI/res/layout-sw600dp/status_bar_expanded_header.xml75
-rw-r--r--packages/SystemUI/res/layout/status_bar_expanded_header.xml9
-rw-r--r--packages/SystemUI/res/layout/system_bar_settings_view.xml4
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/RotationToggle.java30
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/AutoRotateController.java70
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/tablet/SettingsView.java15
6 files changed, 73 insertions, 130 deletions
diff --git a/packages/SystemUI/res/layout-sw600dp/status_bar_expanded_header.xml b/packages/SystemUI/res/layout-sw600dp/status_bar_expanded_header.xml
deleted file mode 100644
index 9b834d2..0000000
--- a/packages/SystemUI/res/layout-sw600dp/status_bar_expanded_header.xml
+++ /dev/null
@@ -1,75 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-** Copyright 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.
--->
-
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingTop="@dimen/notification_panel_header_padding_top"
- android:background="@drawable/notification_header_bg"
- android:orientation="horizontal"
- android:gravity="center_vertical"
- android:baselineAligned="false"
- >
- <com.android.systemui.statusbar.policy.Clock
- android:id="@+id/clock"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginLeft="8dp"
- android:singleLine="true"
- android:textAppearance="@style/TextAppearance.StatusBar.Expanded.Clock"
- />
-
- <com.android.systemui.statusbar.policy.DateView android:id="@+id/date"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginLeft="8dp"
- android:layout_marginRight="8dp"
- android:textAppearance="@style/TextAppearance.StatusBar.Expanded.Date"
- />
-
- <com.android.systemui.statusbar.RotationToggle android:id="@+id/rotation_lock_button"
- android:layout_width="32dp"
- android:layout_height="32dp"
- android:layout_margin="8dp"
- android:button="@drawable/ic_notify_rotation"
- android:contentDescription="@string/accessibility_rotation_lock_off"
- />
-
- <ImageView android:id="@+id/settings_button"
- android:layout_width="48dp"
- android:layout_height="48dp"
- android:scaleType="center"
- android:src="@drawable/ic_notify_quicksettings"
- android:contentDescription="@string/accessibility_settings_button"
- />
-
- <Space
- android:layout_width="0dp"
- android:layout_height="0dp"
- android:layout_weight="1"
- />
-
- <ImageView android:id="@+id/clear_all_button"
- android:layout_width="48dp"
- android:layout_height="48dp"
- android:scaleType="center"
- android:src="@drawable/ic_notify_clear"
- android:contentDescription="@string/accessibility_clear_all"
- />
-</LinearLayout> \ No newline at end of file
diff --git a/packages/SystemUI/res/layout/status_bar_expanded_header.xml b/packages/SystemUI/res/layout/status_bar_expanded_header.xml
index 893d422..cb4e6a9 100644
--- a/packages/SystemUI/res/layout/status_bar_expanded_header.xml
+++ b/packages/SystemUI/res/layout/status_bar_expanded_header.xml
@@ -43,6 +43,15 @@
android:textAppearance="@style/TextAppearance.StatusBar.Expanded.Date"
/>
+ <com.android.systemui.statusbar.RotationToggle android:id="@+id/rotation_lock_button"
+ android:layout_width="32dp"
+ android:layout_height="32dp"
+ android:layout_margin="8dp"
+ android:button="@drawable/ic_notify_rotation"
+ android:contentDescription="@string/accessibility_rotation_lock_off"
+ android:clickable="true"
+ />
+
<ImageView android:id="@+id/settings_button"
android:layout_width="48dp"
android:layout_height="48dp"
diff --git a/packages/SystemUI/res/layout/system_bar_settings_view.xml b/packages/SystemUI/res/layout/system_bar_settings_view.xml
index 677988d..e1b2a54 100644
--- a/packages/SystemUI/res/layout/system_bar_settings_view.xml
+++ b/packages/SystemUI/res/layout/system_bar_settings_view.xml
@@ -89,7 +89,9 @@
android:layout_marginRight="5dp"
/>
</LinearLayout>
- <View style="@style/StatusBarPanelSettingsPanelSeparator" />
+ <View
+ android:id="@+id/rotate_separator"
+ style="@style/StatusBarPanelSettingsPanelSeparator" />
<!-- Brightness -->
<LinearLayout style="@style/StatusBarPanelSettingsRow" >
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/RotationToggle.java b/packages/SystemUI/src/com/android/systemui/statusbar/RotationToggle.java
index c5a7354..5dd45a4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/RotationToggle.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/RotationToggle.java
@@ -6,25 +6,39 @@ import android.widget.CompoundButton;
import com.android.systemui.statusbar.policy.AutoRotateController;
-public class RotationToggle extends CompoundButton {
- AutoRotateController mRotater;
+public class RotationToggle extends CompoundButton
+ implements AutoRotateController.RotationLockCallbacks {
+ private AutoRotateController mRotater;
public RotationToggle(Context context) {
super(context);
- mRotater = new AutoRotateController(context, this);
- setClickable(true);
}
public RotationToggle(Context context, AttributeSet attrs) {
super(context, attrs);
- mRotater = new AutoRotateController(context, this);
- setClickable(true);
}
public RotationToggle(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
- mRotater = new AutoRotateController(context, this);
- setClickable(true);
}
+ @Override
+ protected void onAttachedToWindow() {
+ super.onAttachedToWindow();
+ mRotater = new AutoRotateController(getContext(), this, this);
+ }
+
+ @Override
+ protected void onDetachedFromWindow() {
+ super.onDetachedFromWindow();
+ if (mRotater != null) {
+ mRotater.release();
+ mRotater = null;
+ }
+ }
+
+ @Override
+ public void setRotationLockControlVisibility(boolean show) {
+ setVisibility(show ? VISIBLE : GONE);
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/AutoRotateController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/AutoRotateController.java
index 3d63781..109395c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/AutoRotateController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/AutoRotateController.java
@@ -16,80 +16,60 @@
package com.android.systemui.statusbar.policy;
-import android.content.ContentResolver;
+import com.android.internal.view.RotationPolicy;
+
import android.content.Context;
-import android.database.ContentObserver;
-import android.os.AsyncTask;
-import android.os.Handler;
-import android.os.RemoteException;
-import android.os.ServiceManager;
-import android.provider.Settings;
-import android.util.Log;
-import android.view.IWindowManager;
import android.widget.CompoundButton;
-public class AutoRotateController implements CompoundButton.OnCheckedChangeListener {
- private static final String TAG = "StatusBar.AutoRotateController";
-
+public final class AutoRotateController implements CompoundButton.OnCheckedChangeListener {
private final Context mContext;
private final CompoundButton mCheckbox;
+ private final RotationLockCallbacks mCallbacks;
private boolean mAutoRotation;
- private ContentObserver mAccelerometerRotationObserver = new ContentObserver(new Handler()) {
+ private final RotationPolicy.RotationPolicyListener mRotationPolicyListener =
+ new RotationPolicy.RotationPolicyListener() {
@Override
- public void onChange(boolean selfChange) {
- updateCheckbox();
+ public void onChange() {
+ updateState();
}
};
- public AutoRotateController(Context context, CompoundButton checkbox) {
+ public AutoRotateController(Context context, CompoundButton checkbox,
+ RotationLockCallbacks callbacks) {
mContext = context;
mCheckbox = checkbox;
- updateCheckbox();
+ mCallbacks = callbacks;
+
mCheckbox.setOnCheckedChangeListener(this);
- mContext.getContentResolver().registerContentObserver(
- Settings.System.getUriFor(Settings.System.ACCELEROMETER_ROTATION), true,
- mAccelerometerRotationObserver);
+ RotationPolicy.registerRotationPolicyListener(context, mRotationPolicyListener);
+ updateState();
}
public void onCheckedChanged(CompoundButton view, boolean checked) {
if (checked != mAutoRotation) {
- setAutoRotation(checked);
+ mAutoRotation = checked;
+ RotationPolicy.setRotationLock(mContext, !checked);
}
}
public void release() {
- mContext.getContentResolver().unregisterContentObserver(mAccelerometerRotationObserver);
+ RotationPolicy.unregisterRotationPolicyListener(mContext,
+ mRotationPolicyListener);
}
- private void updateCheckbox() {
- mAutoRotation = getAutoRotation();
+ private void updateState() {
+ mAutoRotation = !RotationPolicy.isRotationLocked(mContext);
mCheckbox.setChecked(mAutoRotation);
- }
- private boolean getAutoRotation() {
- ContentResolver cr = mContext.getContentResolver();
- return 0 != Settings.System.getInt(cr, Settings.System.ACCELEROMETER_ROTATION, 0);
+ boolean visible = RotationPolicy.isRotationLockToggleVisible(mContext);
+ mCallbacks.setRotationLockControlVisibility(visible);
+ mCheckbox.setEnabled(visible);
}
- private void setAutoRotation(final boolean autorotate) {
- mAutoRotation = autorotate;
- AsyncTask.execute(new Runnable() {
- public void run() {
- try {
- IWindowManager wm = IWindowManager.Stub.asInterface(
- ServiceManager.getService(Context.WINDOW_SERVICE));
- if (autorotate) {
- wm.thawRotation();
- } else {
- wm.freezeRotation(-1);
- }
- } catch (RemoteException exc) {
- Log.w(TAG, "Unable to save auto-rotate setting");
- }
- }
- });
+ public interface RotationLockCallbacks {
+ void setRotationLockControlVisibility(boolean show);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/SettingsView.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/SettingsView.java
index 46ea940..537ff66 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/SettingsView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/SettingsView.java
@@ -43,6 +43,8 @@ public class SettingsView extends LinearLayout implements View.OnClickListener {
AutoRotateController mRotate;
BrightnessController mBrightness;
DoNotDisturbController mDoNotDisturb;
+ View mRotationLockContainer;
+ View mRotationLockSeparator;
public SettingsView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
@@ -61,8 +63,19 @@ public class SettingsView extends LinearLayout implements View.OnClickListener {
mAirplane = new AirplaneModeController(context,
(CompoundButton)findViewById(R.id.airplane_checkbox));
findViewById(R.id.network).setOnClickListener(this);
+
+ mRotationLockContainer = findViewById(R.id.rotate);
+ mRotationLockSeparator = findViewById(R.id.rotate_separator);
mRotate = new AutoRotateController(context,
- (CompoundButton)findViewById(R.id.rotate_checkbox));
+ (CompoundButton)findViewById(R.id.rotate_checkbox),
+ new AutoRotateController.RotationLockCallbacks() {
+ @Override
+ public void setRotationLockControlVisibility(boolean show) {
+ mRotationLockContainer.setVisibility(show ? View.VISIBLE : View.GONE);
+ mRotationLockSeparator.setVisibility(show ? View.VISIBLE : View.GONE);
+ }
+ });
+
mBrightness = new BrightnessController(context,
(ToggleSlider)findViewById(R.id.brightness));
mDoNotDisturb = new DoNotDisturbController(context,