summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArasthel <angel.arasthel@gmail.com>2012-11-25 02:08:40 +0100
committerArasthel <angel.arasthel@gmail.com>2012-12-06 23:37:02 +0100
commit601043088119e445a231ccf54f9f9851cec9fe93 (patch)
tree5bc9440187f8f9bdd5d914a0fd1ac504ecef9809
parent9b35cd5321b4cc2110f4b8dcb20601cc92c852c2 (diff)
downloadframeworks_base-601043088119e445a231ccf54f9f9851cec9fe93.zip
frameworks_base-601043088119e445a231ccf54f9f9851cec9fe93.tar.gz
frameworks_base-601043088119e445a231ccf54f9f9851cec9fe93.tar.bz2
Modified Quicksettings to act just like Power Widget. Fixed Power Widget Sleep toggle with the help of Danesh M and David van Tonder
The code for QuickSettings has been rewritten using quicksettings.QuickSettings and QuickSettingsController classes. Patch set 1-15: Original commits Patch set 16: Re-arrange button order Patch set 17-20: Rewritten toggles Change-Id: I7dcdca925970d816671e60ee01f393d71ce36581
-rw-r--r--packages/SystemUI/res/drawable-hdpi/ic_qs_gps_off.pngbin0 -> 1093 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/ic_qs_gps_on.pngbin0 -> 1974 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/ic_qs_lock_screen_off.pngbin0 -> 1309 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/ic_qs_lock_screen_on.pngbin0 -> 1387 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/ic_qs_ring_off.pngbin0 -> 1401 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/ic_qs_ring_on.pngbin0 -> 1796 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/ic_qs_ring_vibrate_on.pngbin0 -> 1902 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/ic_qs_sleep.pngbin0 -> 1687 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/ic_qs_vibrate_off.pngbin0 -> 2166 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/ic_qs_vibrate_on.pngbin0 -> 1309 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/ic_qs_gps_off.pngbin0 -> 750 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/ic_qs_gps_on.pngbin0 -> 1268 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/ic_qs_lock_screen_off.pngbin0 -> 1196 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/ic_qs_lock_screen_on.pngbin0 -> 1273 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/ic_qs_ring_off.pngbin0 -> 989 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/ic_qs_ring_on.pngbin0 -> 1408 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/ic_qs_ring_vibrate_on.pngbin0 -> 1471 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/ic_qs_sleep.pngbin0 -> 1483 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/ic_qs_vibrate_off.pngbin0 -> 1704 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/ic_qs_vibrate_on.pngbin0 -> 905 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/ic_qs_gps_off.pngbin0 -> 1497 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/ic_qs_gps_on.pngbin0 -> 2878 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/ic_qs_lock_screen_off.pngbin0 -> 1413 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/ic_qs_lock_screen_on.pngbin0 -> 1519 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/ic_qs_ring_off.pngbin0 -> 1854 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/ic_qs_ring_on.pngbin0 -> 2271 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/ic_qs_ring_vibrate_on.pngbin0 -> 2455 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/ic_qs_sleep.pngbin0 -> 1847 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/ic_qs_vibrate_off.pngbin0 -> 2769 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/ic_qs_vibrate_on.pngbin0 -> 1840 bytes
-rw-r--r--packages/SystemUI/res/layout/quick_settings_tile_generic.xml24
-rw-r--r--packages/SystemUI/res/values-es/strings.xml12
-rw-r--r--packages/SystemUI/res/values/strings.xml16
-rw-r--r--packages/SystemUI/src/com/android/systemui/quicksettings/AirplaneModeTile.java83
-rw-r--r--packages/SystemUI/src/com/android/systemui/quicksettings/AlarmTile.java93
-rw-r--r--packages/SystemUI/src/com/android/systemui/quicksettings/AutoRotateTile.java92
-rw-r--r--packages/SystemUI/src/com/android/systemui/quicksettings/BatteryTile.java85
-rw-r--r--packages/SystemUI/src/com/android/systemui/quicksettings/BluetoothTile.java112
-rw-r--r--packages/SystemUI/src/com/android/systemui/quicksettings/BrightnessTile.java152
-rw-r--r--packages/SystemUI/src/com/android/systemui/quicksettings/BugReportTile.java120
-rw-r--r--packages/SystemUI/src/com/android/systemui/quicksettings/GPSTile.java99
-rw-r--r--packages/SystemUI/src/com/android/systemui/quicksettings/InputMethodTile.java133
-rw-r--r--packages/SystemUI/src/com/android/systemui/quicksettings/MobileNetworkTile.java140
-rw-r--r--packages/SystemUI/src/com/android/systemui/quicksettings/MobileNetworkTypeTile.java174
-rw-r--r--packages/SystemUI/src/com/android/systemui/quicksettings/PreferencesTile.java29
-rw-r--r--packages/SystemUI/src/com/android/systemui/quicksettings/QuickSettingsTile.java93
-rw-r--r--packages/SystemUI/src/com/android/systemui/quicksettings/RingerModeTile.java70
-rw-r--r--packages/SystemUI/src/com/android/systemui/quicksettings/RingerVibrationModeTile.java99
-rw-r--r--packages/SystemUI/src/com/android/systemui/quicksettings/SleepScreenTile.java41
-rw-r--r--packages/SystemUI/src/com/android/systemui/quicksettings/ToggleLockscreenTile.java81
-rw-r--r--packages/SystemUI/src/com/android/systemui/quicksettings/UserTile.java179
-rw-r--r--packages/SystemUI/src/com/android/systemui/quicksettings/VibrationModeTile.java101
-rw-r--r--packages/SystemUI/src/com/android/systemui/quicksettings/WiFiDisplayTile.java69
-rw-r--r--packages/SystemUI/src/com/android/systemui/quicksettings/WiFiTile.java78
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java117
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java1
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsContainerView.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsController.java205
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsTileView.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/SettingsPanelView.java14
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/powerwidget/LockScreenButton.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/powerwidget/SleepButton.java8
63 files changed, 2471 insertions, 71 deletions
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_qs_gps_off.png b/packages/SystemUI/res/drawable-hdpi/ic_qs_gps_off.png
new file mode 100644
index 0000000..cd3c61e
--- /dev/null
+++ b/packages/SystemUI/res/drawable-hdpi/ic_qs_gps_off.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_qs_gps_on.png b/packages/SystemUI/res/drawable-hdpi/ic_qs_gps_on.png
new file mode 100644
index 0000000..5138b70
--- /dev/null
+++ b/packages/SystemUI/res/drawable-hdpi/ic_qs_gps_on.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_qs_lock_screen_off.png b/packages/SystemUI/res/drawable-hdpi/ic_qs_lock_screen_off.png
new file mode 100644
index 0000000..01fa6a5
--- /dev/null
+++ b/packages/SystemUI/res/drawable-hdpi/ic_qs_lock_screen_off.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_qs_lock_screen_on.png b/packages/SystemUI/res/drawable-hdpi/ic_qs_lock_screen_on.png
new file mode 100644
index 0000000..b579033
--- /dev/null
+++ b/packages/SystemUI/res/drawable-hdpi/ic_qs_lock_screen_on.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_qs_ring_off.png b/packages/SystemUI/res/drawable-hdpi/ic_qs_ring_off.png
new file mode 100644
index 0000000..78b2e8a
--- /dev/null
+++ b/packages/SystemUI/res/drawable-hdpi/ic_qs_ring_off.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_qs_ring_on.png b/packages/SystemUI/res/drawable-hdpi/ic_qs_ring_on.png
new file mode 100644
index 0000000..4eb5d38
--- /dev/null
+++ b/packages/SystemUI/res/drawable-hdpi/ic_qs_ring_on.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_qs_ring_vibrate_on.png b/packages/SystemUI/res/drawable-hdpi/ic_qs_ring_vibrate_on.png
new file mode 100644
index 0000000..e7ff566
--- /dev/null
+++ b/packages/SystemUI/res/drawable-hdpi/ic_qs_ring_vibrate_on.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_qs_sleep.png b/packages/SystemUI/res/drawable-hdpi/ic_qs_sleep.png
new file mode 100644
index 0000000..7252a12
--- /dev/null
+++ b/packages/SystemUI/res/drawable-hdpi/ic_qs_sleep.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_qs_vibrate_off.png b/packages/SystemUI/res/drawable-hdpi/ic_qs_vibrate_off.png
new file mode 100644
index 0000000..87b119a
--- /dev/null
+++ b/packages/SystemUI/res/drawable-hdpi/ic_qs_vibrate_off.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_qs_vibrate_on.png b/packages/SystemUI/res/drawable-hdpi/ic_qs_vibrate_on.png
new file mode 100644
index 0000000..4199106
--- /dev/null
+++ b/packages/SystemUI/res/drawable-hdpi/ic_qs_vibrate_on.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_qs_gps_off.png b/packages/SystemUI/res/drawable-mdpi/ic_qs_gps_off.png
new file mode 100644
index 0000000..6442720
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/ic_qs_gps_off.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_qs_gps_on.png b/packages/SystemUI/res/drawable-mdpi/ic_qs_gps_on.png
new file mode 100644
index 0000000..9e98ad9
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/ic_qs_gps_on.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_qs_lock_screen_off.png b/packages/SystemUI/res/drawable-mdpi/ic_qs_lock_screen_off.png
new file mode 100644
index 0000000..16d973b
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/ic_qs_lock_screen_off.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_qs_lock_screen_on.png b/packages/SystemUI/res/drawable-mdpi/ic_qs_lock_screen_on.png
new file mode 100644
index 0000000..7ba6d3d
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/ic_qs_lock_screen_on.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_qs_ring_off.png b/packages/SystemUI/res/drawable-mdpi/ic_qs_ring_off.png
new file mode 100644
index 0000000..e727fa2
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/ic_qs_ring_off.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_qs_ring_on.png b/packages/SystemUI/res/drawable-mdpi/ic_qs_ring_on.png
new file mode 100644
index 0000000..bc93785
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/ic_qs_ring_on.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_qs_ring_vibrate_on.png b/packages/SystemUI/res/drawable-mdpi/ic_qs_ring_vibrate_on.png
new file mode 100644
index 0000000..0714ff3
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/ic_qs_ring_vibrate_on.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_qs_sleep.png b/packages/SystemUI/res/drawable-mdpi/ic_qs_sleep.png
new file mode 100644
index 0000000..eb3aaed
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/ic_qs_sleep.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_qs_vibrate_off.png b/packages/SystemUI/res/drawable-mdpi/ic_qs_vibrate_off.png
new file mode 100644
index 0000000..9ac387e
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/ic_qs_vibrate_off.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_qs_vibrate_on.png b/packages/SystemUI/res/drawable-mdpi/ic_qs_vibrate_on.png
new file mode 100644
index 0000000..2d99b76
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/ic_qs_vibrate_on.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_qs_gps_off.png b/packages/SystemUI/res/drawable-xhdpi/ic_qs_gps_off.png
new file mode 100644
index 0000000..0548274
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xhdpi/ic_qs_gps_off.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_qs_gps_on.png b/packages/SystemUI/res/drawable-xhdpi/ic_qs_gps_on.png
new file mode 100644
index 0000000..d1d9768
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xhdpi/ic_qs_gps_on.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_qs_lock_screen_off.png b/packages/SystemUI/res/drawable-xhdpi/ic_qs_lock_screen_off.png
new file mode 100644
index 0000000..aa6bfdd
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xhdpi/ic_qs_lock_screen_off.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_qs_lock_screen_on.png b/packages/SystemUI/res/drawable-xhdpi/ic_qs_lock_screen_on.png
new file mode 100644
index 0000000..f272d3f
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xhdpi/ic_qs_lock_screen_on.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_qs_ring_off.png b/packages/SystemUI/res/drawable-xhdpi/ic_qs_ring_off.png
new file mode 100644
index 0000000..70526c6
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xhdpi/ic_qs_ring_off.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_qs_ring_on.png b/packages/SystemUI/res/drawable-xhdpi/ic_qs_ring_on.png
new file mode 100644
index 0000000..5e9413a
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xhdpi/ic_qs_ring_on.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_qs_ring_vibrate_on.png b/packages/SystemUI/res/drawable-xhdpi/ic_qs_ring_vibrate_on.png
new file mode 100644
index 0000000..2d66704
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xhdpi/ic_qs_ring_vibrate_on.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_qs_sleep.png b/packages/SystemUI/res/drawable-xhdpi/ic_qs_sleep.png
new file mode 100644
index 0000000..562ee34
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xhdpi/ic_qs_sleep.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_qs_vibrate_off.png b/packages/SystemUI/res/drawable-xhdpi/ic_qs_vibrate_off.png
new file mode 100644
index 0000000..cb443a6
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xhdpi/ic_qs_vibrate_off.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_qs_vibrate_on.png b/packages/SystemUI/res/drawable-xhdpi/ic_qs_vibrate_on.png
new file mode 100644
index 0000000..122c708
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xhdpi/ic_qs_vibrate_on.png
Binary files differ
diff --git a/packages/SystemUI/res/layout/quick_settings_tile_generic.xml b/packages/SystemUI/res/layout/quick_settings_tile_generic.xml
new file mode 100644
index 0000000..374660d
--- /dev/null
+++ b/packages/SystemUI/res/layout/quick_settings_tile_generic.xml
@@ -0,0 +1,24 @@
+<?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/tile_textview"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:gravity="center"
+ /> \ No newline at end of file
diff --git a/packages/SystemUI/res/values-es/strings.xml b/packages/SystemUI/res/values-es/strings.xml
index 19de9b6..dea3f23 100644
--- a/packages/SystemUI/res/values-es/strings.xml
+++ b/packages/SystemUI/res/values-es/strings.xml
@@ -203,4 +203,16 @@
<string name="quick_settings_brightness_dialog_auto_brightness_label" msgid="5064982743784071218">"AUTO"</string>
<string name="status_bar_help_title" msgid="1199237744086469217">"Las notificaciones aparecen aquí"</string>
<string name="status_bar_help_text" msgid="7874607155052076323">"Desliza el dedo hacia abajo para acceder al contenido."\n"Vuelve a deslizar el dedo hacia abajo para acceder a los controles del sistema."</string>
+
+ <string name="quick_settings_screen_sleep">Bloquear</string>
+ <string name="quick_settings_ringer_on">Sonido ON</string>
+ <string name="quick_settings_ringer_off">Sonido OFF</string>
+ <string name="quick_settings_vibration_on">Vibración ON</string>
+ <string name="quick_settings_vibration_off">Vibración OFF</string>
+ <string name="quick_settings_label_enabled">ON</string>
+ <string name="quick_settings_label_disabled">OFF</string>
+ <string name="quick_settings_ringer_normal">Sonido</string>
+ <string name="quick_settings_lockscreen">Pantalla Bloqueo</string>
+ <string name="quick_settings_network_type">Red móvil</string>
+ <string name="quick_settings_report_bug">Informar de error</string>
</resources>
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index a2cbf0c..67de09d 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -395,6 +395,9 @@
<!-- Content description of the alarm tile in quick settings (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_quick_settings_alarm">Alarm set for <xliff:g id="time" example="Wed 3:30 PM">%s</xliff:g>.</string>
+ <string name="accessibility_quick_settings_ringer">Sound <xliff:g id="state" example="Off">%s</xliff:g>.</string>
+ <string name="accessibility_quick_settings_vibration">Vibration <xliff:g id="state" example="Off">%s</xliff:g>.</string>
+
<!-- Title of dialog shown when 2G-3G data usage has exceeded limit and has been disabled. [CHAR LIMIT=48] -->
<string name="data_usage_disabled_dialog_3g_title">2G-3G data disabled</string>
<!-- Title of dialog shown when 4G data usage has exceeded limit and has been disabled. [CHAR LIMIT=48] -->
@@ -518,6 +521,19 @@
<string name="status_bar_help_text">Access them anytime by swiping down.\nSwipe down again for system controls.</string>
<string name="powerwidget_screen_timeout_toast">Screen timeout set to: %1$d %2$s</string>
+ <string name="quick_settings_gps">GPS</string>
+ <string name="quick_settings_screen_sleep">Go to sleep</string>
+ <string name="quick_settings_ringer_on">Sound on</string>
+ <string name="quick_settings_ringer_off">Sound off</string>
+ <string name="quick_settings_vibration_on">Vibration on</string>
+ <string name="quick_settings_vibration_off">Vibration off</string>
+ <string name="quick_settings_label_enabled">On</string>
+ <string name="quick_settings_label_disabled">Off</string>
+ <string name="quick_settings_ringer_normal">Sound</string>
+ <string name="quick_settings_lockscreen">Lock Screen</string>
+ <string name="quick_settings_network_type">Network Type</string>
+ <string name="quick_settings_report_bug">Report Bug</string>
+
<!-- Text to display next to the minimal graphical battery meter. [CHAR LIMIT=3] -->
<string name="status_bar_settings_battery_meter_min_format" translatable="false">
<xliff:g id="number">%d</xliff:g>
diff --git a/packages/SystemUI/src/com/android/systemui/quicksettings/AirplaneModeTile.java b/packages/SystemUI/src/com/android/systemui/quicksettings/AirplaneModeTile.java
new file mode 100644
index 0000000..91033c2
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/quicksettings/AirplaneModeTile.java
@@ -0,0 +1,83 @@
+package com.android.systemui.quicksettings;
+
+import android.content.Context;
+import android.content.Intent;
+import android.provider.Settings;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnLongClickListener;
+
+import com.android.systemui.R;
+import com.android.systemui.statusbar.phone.QuickSettingsController;
+import com.android.systemui.statusbar.phone.PhoneStatusBar;
+import com.android.systemui.statusbar.phone.QuickSettingsContainerView;
+import com.android.systemui.statusbar.policy.NetworkController;
+import com.android.systemui.statusbar.policy.NetworkController.NetworkSignalChangedCallback;
+
+public class AirplaneModeTile extends QuickSettingsTile implements NetworkSignalChangedCallback{
+
+ private boolean enabled = false;
+
+ public AirplaneModeTile(Context context, LayoutInflater inflater,
+ QuickSettingsContainerView container, QuickSettingsController qsc) {
+ super(context, inflater, container, qsc);
+
+ mLabel = mContext.getString(R.string.quick_settings_airplane_mode_label);
+
+ onClick = new View.OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ // Change the system setting
+ Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON,
+ !enabled ? 1 : 0);
+
+ // Post the intent
+ Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
+ intent.putExtra("state", !enabled);
+ mContext.sendBroadcast(intent);
+ }
+ };
+ onLongClick = new OnLongClickListener() {
+
+ @Override
+ public boolean onLongClick(View v) {
+ startSettingsActivity(android.provider.Settings.ACTION_WIRELESS_SETTINGS);
+ return true;
+ }
+ };
+ }
+
+ @Override
+ void onPostCreate() {
+ NetworkController controller = new NetworkController(mContext);
+ controller.addNetworkSignalChangedCallback(this);
+ super.onPostCreate();
+ }
+
+ @Override
+ public void onWifiSignalChanged(boolean enabled, int wifiSignalIconId,
+ String wifitSignalContentDescriptionId, String description) {
+ }
+
+ @Override
+ public void onMobileDataSignalChanged(boolean enabled,
+ int mobileSignalIconId, String mobileSignalContentDescriptionId,
+ int dataTypeIconId, String dataTypeContentDescriptionId,
+ String description) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void onAirplaneModeChanged(boolean enabled) {
+ this.enabled = enabled;
+ if(enabled){
+ mDrawable = R.drawable.ic_qs_airplane_on;
+ }else{
+ mDrawable = R.drawable.ic_qs_airplane_off;
+ }
+ updateQuickSettings();
+ }
+
+}
diff --git a/packages/SystemUI/src/com/android/systemui/quicksettings/AlarmTile.java b/packages/SystemUI/src/com/android/systemui/quicksettings/AlarmTile.java
new file mode 100644
index 0000000..d59777f
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/quicksettings/AlarmTile.java
@@ -0,0 +1,93 @@
+package com.android.systemui.quicksettings;
+
+import android.content.BroadcastReceiver;
+import android.content.ComponentName;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.database.ContentObserver;
+import android.os.Handler;
+import android.provider.Settings;
+import android.view.LayoutInflater;
+import android.view.View;
+
+import com.android.systemui.R;
+import com.android.systemui.statusbar.phone.QuickSettingsController;
+import com.android.systemui.statusbar.phone.QuickSettingsContainerView;
+
+public class AlarmTile extends QuickSettingsTile{
+
+ private boolean enabled = false;
+
+ public AlarmTile(Context context, LayoutInflater inflater,
+ QuickSettingsContainerView container,
+ QuickSettingsController qsc, Handler handler) {
+ super(context, inflater, container, qsc);
+
+ NextAlarmObserver observer = new NextAlarmObserver(handler);
+ observer.startObserving();
+
+ mDrawable = R.drawable.ic_qs_alarm_on;
+ String nextAlarmTime = Settings.System.getString(mContext.getContentResolver(), Settings.System.NEXT_ALARM_FORMATTED);
+ if(nextAlarmTime != null){
+ mLabel = nextAlarmTime;
+ }
+
+ onClick = new View.OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ Intent intent = new Intent();
+ intent.setComponent(new ComponentName(
+ "com.android.deskclock",
+ "com.android.deskclock.AlarmClock"));
+ startSettingsActivity(intent);
+ }
+ };
+ mBroadcastReceiver = new BroadcastReceiver() {
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ onAlarmChanged(intent);
+ }
+ };
+
+ mIntentFilter = new IntentFilter(Intent.ACTION_ALARM_CHANGED);
+ }
+
+ void onAlarmChanged(Intent intent) {
+ enabled = intent.getBooleanExtra("alarmSet", false);
+ updateQuickSettings();
+ }
+
+ void onNextAlarmChanged() {
+ mLabel = Settings.System.getString(mContext.getContentResolver(),
+ Settings.System.NEXT_ALARM_FORMATTED);
+ updateQuickSettings();
+ }
+
+ /** ContentObserver to determine the next alarm */
+ private class NextAlarmObserver extends ContentObserver {
+ public NextAlarmObserver(Handler handler) {
+ super(handler);
+ }
+
+ @Override public void onChange(boolean selfChange) {
+ onNextAlarmChanged();
+ }
+
+ public void startObserving() {
+ final ContentResolver cr = mContext.getContentResolver();
+ cr.registerContentObserver(
+ Settings.System.getUriFor(Settings.System.NEXT_ALARM_FORMATTED), false, this);
+ }
+ }
+
+ @Override
+ void updateQuickSettings() {
+ mTile.setVisibility(enabled ? View.VISIBLE : View.GONE);
+ super.updateQuickSettings();
+ }
+
+}
diff --git a/packages/SystemUI/src/com/android/systemui/quicksettings/AutoRotateTile.java b/packages/SystemUI/src/com/android/systemui/quicksettings/AutoRotateTile.java
new file mode 100644
index 0000000..6471e01
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/quicksettings/AutoRotateTile.java
@@ -0,0 +1,92 @@
+package com.android.systemui.quicksettings;
+
+import android.content.Context;
+import android.database.ContentObserver;
+import android.net.Uri;
+import android.os.Handler;
+import android.provider.Settings;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.View.OnLongClickListener;
+
+import com.android.internal.view.RotationPolicy;
+import com.android.systemui.R;
+import com.android.systemui.statusbar.phone.QuickSettingsController;
+import com.android.systemui.statusbar.phone.QuickSettingsContainerView;
+
+public class AutoRotateTile extends QuickSettingsTile {
+
+ private boolean enabled = false;
+ private ContentObserver mContentObserver;
+ private static final String TAG = "AutoRotateButton";
+
+ public AutoRotateTile(Context context, LayoutInflater inflater,
+ QuickSettingsContainerView container, QuickSettingsController qsc, Handler handler) {
+ super(context, inflater, container, qsc);
+
+ mContentObserver = new AutoRotationObserver(handler);
+
+ onClick = new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ RotationPolicy.setRotationLock(mContext, !enabled);
+ }
+ };
+
+ onLongClick = new OnLongClickListener() {
+
+ @Override
+ public boolean onLongClick(View v) {
+ startSettingsActivity(Settings.ACTION_DISPLAY_SETTINGS);
+ return true;
+ }
+ };
+ }
+
+ void applyAutoRotationChanges() {
+ if(enabled){
+ mDrawable = R.drawable.ic_qs_rotation_locked;
+ mLabel = mContext.getString(R.string.quick_settings_rotation_locked_label);
+ }else{
+ mDrawable = R.drawable.ic_qs_auto_rotate;
+ mLabel = mContext.getString(R.string.quick_settings_rotation_unlocked_label);
+ }
+ updateQuickSettings();
+ }
+
+ @Override
+ void onPostCreate() {
+ applyAutoRotationChanges();
+ super.onPostCreate();
+ }
+
+ private class AutoRotationObserver extends ContentObserver {
+
+ public AutoRotationObserver(Handler handler) {
+ super(handler);
+ observe();
+ }
+
+ public void observe() {
+ mContext.getContentResolver().registerContentObserver(Settings.System.getUriFor(Settings.System.ACCELEROMETER_ROTATION),
+ false, this);
+ }
+
+ @Override
+ public void onChange(boolean selfChange, Uri uri) {
+ if(uri.equals(Settings.System.getUriFor(Settings.System.ACCELEROMETER_ROTATION))){
+ enabled = Settings.System.getInt(mContext.getContentResolver(), Settings.System.ACCELEROMETER_ROTATION, 0) != 1;
+ applyAutoRotationChanges();
+ }
+ super.onChange(selfChange, uri);
+ }
+
+ public void unObserve() {
+ mContext.getContentResolver().unregisterContentObserver(this);
+ }
+
+ }
+
+}
diff --git a/packages/SystemUI/src/com/android/systemui/quicksettings/BatteryTile.java b/packages/SystemUI/src/com/android/systemui/quicksettings/BatteryTile.java
new file mode 100644
index 0000000..f42b208
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/quicksettings/BatteryTile.java
@@ -0,0 +1,85 @@
+package com.android.systemui.quicksettings;
+
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.LevelListDrawable;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.android.systemui.R;
+import com.android.systemui.statusbar.phone.QuickSettingsContainerView;
+import com.android.systemui.statusbar.phone.QuickSettingsController;
+import com.android.systemui.statusbar.policy.BatteryController;
+import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback;
+
+public class BatteryTile extends QuickSettingsTile implements BatteryStateChangeCallback{
+
+ private boolean charging = false;
+ private int batteryLevel = 0;
+ private Drawable batteryIcon;
+
+ private LevelListDrawable batteryLevels;
+ private LevelListDrawable chargingBatteryLevels;
+
+ public BatteryTile(Context context, LayoutInflater inflater,
+ QuickSettingsContainerView container, QuickSettingsController qsc) {
+ super(context, inflater, container, qsc);
+
+ mTileLayout = R.layout.quick_settings_tile_battery;
+ batteryLevels = (LevelListDrawable) mContext.getResources().getDrawable(R.drawable.qs_sys_battery);
+ chargingBatteryLevels = (LevelListDrawable) mContext.getResources().getDrawable(R.drawable.qs_sys_battery_charging);
+
+ BatteryController controller = new BatteryController(mContext);
+ controller.addStateChangedCallback(this);
+
+ onClick = new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ startSettingsActivity(Intent.ACTION_POWER_USAGE_SUMMARY);
+ }
+ };
+ }
+
+ @Override
+ void onPostCreate() {
+ applyBatteryChanges();
+ super.onPostCreate();
+ }
+
+ @Override
+ public void onBatteryLevelChanged(int level, boolean pluggedIn) {
+ batteryLevel = level;
+ charging = pluggedIn;
+ applyBatteryChanges();
+ }
+
+ void applyBatteryChanges() {
+ batteryIcon = charging
+ ? chargingBatteryLevels :
+ batteryLevels;
+ if(batteryLevel == 100) {
+ mLabel = mContext.getString(R.string.quick_settings_battery_charged_label);
+ }else{
+ mLabel = charging
+ ? mContext.getString(R.string.quick_settings_battery_charging_label,
+ batteryLevel)
+ : mContext.getString(R.string.status_bar_settings_battery_meter_format,
+ batteryLevel);
+
+ }
+ updateQuickSettings();
+ }
+
+ @Override
+ void updateQuickSettings() {
+ TextView tv = (TextView) mTile.findViewById(R.id.battery_textview);
+ tv.setText(mLabel);
+ ImageView iv = (ImageView) mTile.findViewById(R.id.battery_image);
+ iv.setImageDrawable(batteryIcon);
+ iv.setImageLevel(batteryLevel);
+ }
+
+}
diff --git a/packages/SystemUI/src/com/android/systemui/quicksettings/BluetoothTile.java b/packages/SystemUI/src/com/android/systemui/quicksettings/BluetoothTile.java
new file mode 100644
index 0000000..9b5f237
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/quicksettings/BluetoothTile.java
@@ -0,0 +1,112 @@
+package com.android.systemui.quicksettings;
+
+import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothAdapter.BluetoothStateChangeCallback;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.View.OnLongClickListener;
+
+import com.android.systemui.R;
+import com.android.systemui.statusbar.phone.QuickSettingsContainerView;
+import com.android.systemui.statusbar.phone.QuickSettingsController;
+import com.android.systemui.statusbar.policy.BluetoothController;
+
+public class BluetoothTile extends QuickSettingsTile implements BluetoothStateChangeCallback{
+
+ private boolean enabled = false;
+ private boolean connected = false;
+ private BluetoothAdapter mBluetoothAdapter;
+
+ public BluetoothTile(Context context, LayoutInflater inflater,
+ QuickSettingsContainerView container, QuickSettingsController qsc) {
+ super(context, inflater, container, qsc);
+ mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
+ enabled = mBluetoothAdapter.isEnabled();
+ connected = mBluetoothAdapter.getConnectionState() == BluetoothAdapter.STATE_CONNECTED;
+
+ onClick = new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ if(enabled){
+ mBluetoothAdapter.disable();
+ }else{
+ mBluetoothAdapter.enable();
+ }
+ }
+ };
+
+ onLongClick = new OnLongClickListener() {
+
+ @Override
+ public boolean onLongClick(View v) {
+ startSettingsActivity(android.provider.Settings.ACTION_BLUETOOTH_SETTINGS);
+ return true;
+ }
+ };
+
+ mBroadcastReceiver = new BroadcastReceiver() {
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if(intent.getAction().equals(BluetoothAdapter.ACTION_STATE_CHANGED)){
+ int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE,
+ BluetoothAdapter.ERROR);
+ enabled = (state == BluetoothAdapter.STATE_ON);
+ }
+
+ if(intent.getAction().equals(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED)){
+ int state = intent.getIntExtra(BluetoothAdapter.EXTRA_CONNECTION_STATE,
+ BluetoothAdapter.STATE_DISCONNECTED);
+ connected = (state == BluetoothAdapter.STATE_CONNECTED);
+ }
+ applyBluetoothChanges();
+ }
+ };
+
+ mIntentFilter = new IntentFilter();
+ mIntentFilter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED);
+ mIntentFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
+ }
+
+ void checkBluetoothState() {
+ enabled = mBluetoothAdapter.getState() == BluetoothAdapter.STATE_ON;
+ connected = mBluetoothAdapter.getConnectionState() == BluetoothAdapter.STATE_CONNECTED;
+ }
+
+ private void applyBluetoothChanges(){
+ if(enabled){
+ if(connected){
+ mDrawable = R.drawable.ic_qs_bluetooth_on;
+ }else{
+ mDrawable = R.drawable.ic_qs_bluetooth_not_connected;
+ }
+ mLabel = mContext.getString(R.string.quick_settings_bluetooth_label);
+ }else{
+ mDrawable = R.drawable.ic_qs_bluetooth_off;
+ mLabel = mContext.getString(R.string.quick_settings_bluetooth_off_label);
+ }
+ updateQuickSettings();
+ }
+
+ @Override
+ void onPostCreate() {
+ BluetoothController controller = new BluetoothController(mContext);
+ controller.addStateChangedCallback(this);
+ checkBluetoothState();
+ applyBluetoothChanges();
+ super.onPostCreate();
+ }
+
+ @Override
+ public void onBluetoothStateChange(boolean on) {
+ this.enabled = on;
+ applyBluetoothChanges();
+ }
+
+}
diff --git a/packages/SystemUI/src/com/android/systemui/quicksettings/BrightnessTile.java b/packages/SystemUI/src/com/android/systemui/quicksettings/BrightnessTile.java
new file mode 100644
index 0000000..16032df
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/quicksettings/BrightnessTile.java
@@ -0,0 +1,152 @@
+package com.android.systemui.quicksettings;
+
+import android.app.Dialog;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.database.ContentObserver;
+import android.os.Handler;
+import android.os.RemoteException;
+import android.provider.Settings;
+import android.provider.Settings.SettingNotFoundException;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.Window;
+import android.view.WindowManager;
+import android.view.WindowManagerGlobal;
+import android.widget.ImageView;
+
+import com.android.systemui.R;
+import com.android.systemui.statusbar.phone.QuickSettingsController;
+import com.android.systemui.statusbar.phone.QuickSettingsContainerView;
+import com.android.systemui.statusbar.policy.BrightnessController;
+import com.android.systemui.statusbar.policy.BrightnessController.BrightnessStateChangeCallback;
+import com.android.systemui.statusbar.policy.ToggleSlider;
+
+public class BrightnessTile extends QuickSettingsTile implements BrightnessStateChangeCallback {
+
+ private final int mBrightnessDialogLongTimeout;
+ private final int mBrightnessDialogShortTimeout;
+ private Dialog mBrightnessDialog;
+ private BrightnessController mBrightnessController;
+ private final Handler mHandler;
+ private final BrightnessObserver mBrightnessObserver;
+ private boolean autoBrightness = true;
+
+ public BrightnessTile(Context context, LayoutInflater inflater,
+ QuickSettingsContainerView container, final QuickSettingsController qsc, Handler handler) {
+ super(context, inflater, container, qsc);
+
+ mHandler = handler;
+
+ mBrightnessDialogLongTimeout = mContext.getResources().getInteger(R.integer.quick_settings_brightness_dialog_long_timeout);
+ mBrightnessDialogShortTimeout = mContext.getResources().getInteger(R.integer.quick_settings_brightness_dialog_short_timeout);
+
+ mBrightnessObserver = new BrightnessObserver(mHandler);
+
+ onClick = new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ qsc.mBar.collapseAllPanels(true);
+ showBrightnessDialog();
+ }
+ };
+
+ onBrightnessLevelChanged();
+ }
+
+ private void showBrightnessDialog() {
+ if (mBrightnessDialog == null) {
+ mBrightnessDialog = new Dialog(mContext);
+ mBrightnessDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
+ mBrightnessDialog.setContentView(R.layout.quick_settings_brightness_dialog);
+ mBrightnessDialog.setCanceledOnTouchOutside(true);
+
+ mBrightnessController = new BrightnessController(mContext,
+ (ImageView) mBrightnessDialog.findViewById(R.id.brightness_icon),
+ (ToggleSlider) mBrightnessDialog.findViewById(R.id.brightness_slider));
+ mBrightnessDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
+ @Override
+ public void onDismiss(DialogInterface dialog) {
+ mBrightnessController = null;
+ }
+ });
+
+ mBrightnessDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
+ mBrightnessDialog.getWindow().getAttributes().privateFlags |=
+ WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS;
+ mBrightnessDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
+ }
+ if (!mBrightnessDialog.isShowing()) {
+ try {
+ WindowManagerGlobal.getWindowManagerService().dismissKeyguard();
+ } catch (RemoteException e) {
+ }
+ mBrightnessDialog.show();
+ dismissBrightnessDialog(mBrightnessDialogLongTimeout);
+ }
+ }
+
+ private void dismissBrightnessDialog(int timeout) {
+ if (mBrightnessDialog != null) {
+ mHandler.postDelayed(mDismissBrightnessDialogRunnable, timeout);
+ }
+ }
+
+ private final Runnable mDismissBrightnessDialogRunnable = new Runnable() {
+ @Override
+ public void run() {
+ if (mBrightnessDialog != null && mBrightnessDialog.isShowing()) {
+ mBrightnessDialog.dismiss();
+ }
+ };
+ };
+
+ @Override
+ public void onBrightnessLevelChanged() {
+ int mode;
+ try {
+ mode = Settings.System.getIntForUser(mContext.getContentResolver(),
+ Settings.System.SCREEN_BRIGHTNESS_MODE,
+ Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
+ autoBrightness =
+ (mode == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
+ mDrawable = autoBrightness
+ ? R.drawable.ic_qs_brightness_auto_on
+ : R.drawable.ic_qs_brightness_auto_off;
+ mLabel = mContext.getString(R.string.quick_settings_brightness_label);
+ } catch (SettingNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ if(mTile != null){
+ updateQuickSettings();
+ }
+ }
+
+ private class BrightnessObserver extends ContentObserver {
+ public BrightnessObserver(Handler handler) {
+ super(handler);
+ startObserving();
+ }
+
+ @Override
+ public void onChange(boolean selfChange) {
+ onBrightnessLevelChanged();
+ }
+
+ public void startObserving() {
+ final ContentResolver cr = mContext.getContentResolver();
+ cr.unregisterContentObserver(this);
+ cr.registerContentObserver(
+ Settings.System.getUriFor(Settings.System.SCREEN_BRIGHTNESS_MODE),
+ false, this);
+ cr.registerContentObserver(
+ Settings.System.getUriFor(Settings.System.SCREEN_BRIGHTNESS),
+ false, this);
+ }
+ }
+
+}
diff --git a/packages/SystemUI/src/com/android/systemui/quicksettings/BugReportTile.java b/packages/SystemUI/src/com/android/systemui/quicksettings/BugReportTile.java
new file mode 100644
index 0000000..7db66e3
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/quicksettings/BugReportTile.java
@@ -0,0 +1,120 @@
+package com.android.systemui.quicksettings;
+
+import android.app.ActivityManagerNative;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.DialogInterface.OnClickListener;
+import android.database.ContentObserver;
+import android.os.Handler;
+import android.os.RemoteException;
+import android.provider.Settings;
+import android.provider.Settings.SettingNotFoundException;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.WindowManager;
+import android.view.WindowManagerGlobal;
+
+import com.android.systemui.R;
+import com.android.systemui.statusbar.phone.QuickSettingsContainerView;
+import com.android.systemui.statusbar.phone.QuickSettingsController;
+
+public class BugReportTile extends QuickSettingsTile{
+
+ private boolean enabled = false;
+ private final Handler mHandler;
+
+ public BugReportTile(Context context, LayoutInflater inflater,
+ QuickSettingsContainerView container,
+ QuickSettingsController qsc, Handler handler) {
+ super(context, inflater, container, qsc);
+
+ mHandler = handler;
+ mLabel = mContext.getString(R.string.quick_settings_report_bug);
+ mDrawable = com.android.internal.R.drawable.stat_sys_adb;
+
+ try {
+ enabled = (Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.BUGREPORT_IN_POWER_MENU) != 0);
+ } catch (SettingNotFoundException e) {
+ }
+
+ BugreportObserver observer = new BugreportObserver(mHandler);
+ observer.startObserving();
+
+ onClick = new View.OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ mQsc.mBar.collapseAllPanels(true);
+ showBugreportDialog();
+ }
+ };
+ }
+
+ private class BugreportObserver extends ContentObserver {
+ public BugreportObserver(Handler handler) {
+ super(handler);
+ }
+
+ @Override public void onChange(boolean selfChange) {
+ onBugreportChanged();
+ }
+
+ public void startObserving() {
+ final ContentResolver cr = mContext.getContentResolver();
+ cr.registerContentObserver(
+ Settings.Secure.getUriFor(Settings.Secure.BUGREPORT_IN_POWER_MENU), false, this);
+ }
+ }
+
+ public void onBugreportChanged() {
+ final ContentResolver cr = mContext.getContentResolver();
+ try {
+ enabled = (Settings.Secure.getInt(cr, Settings.Secure.BUGREPORT_IN_POWER_MENU) != 0);
+ } catch (SettingNotFoundException e) {
+ }
+ updateQuickSettings();
+ }
+
+ @Override
+ void updateQuickSettings() {
+ mTile.setVisibility(enabled ? View.VISIBLE : View.GONE);
+ super.updateQuickSettings();
+ }
+
+ private void showBugreportDialog() {
+ final AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
+ builder.setPositiveButton(com.android.internal.R.string.report, new OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ if (which == DialogInterface.BUTTON_POSITIVE) {
+ // Add a little delay before executing, to give the
+ // dialog a chance to go away before it takes a
+ // screenshot.
+ mHandler.postDelayed(new Runnable() {
+ @Override public void run() {
+ try {
+ ActivityManagerNative.getDefault()
+ .requestBugReport();
+ } catch (RemoteException e) {
+ }
+ }
+ }, 500);
+ }
+ }
+ });
+ builder.setMessage(com.android.internal.R.string.bugreport_message);
+ builder.setTitle(com.android.internal.R.string.bugreport_title);
+ builder.setCancelable(true);
+ final Dialog dialog = builder.create();
+ dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
+ try {
+ WindowManagerGlobal.getWindowManagerService().dismissKeyguard();
+ } catch (RemoteException e) {
+ }
+ dialog.show();
+ }
+
+}
diff --git a/packages/SystemUI/src/com/android/systemui/quicksettings/GPSTile.java b/packages/SystemUI/src/com/android/systemui/quicksettings/GPSTile.java
new file mode 100644
index 0000000..0f934aa
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/quicksettings/GPSTile.java
@@ -0,0 +1,99 @@
+package com.android.systemui.quicksettings;
+
+import android.content.BroadcastReceiver;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.location.LocationManager;
+import android.provider.Settings;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.View.OnLongClickListener;
+
+import com.android.systemui.R;
+import com.android.systemui.statusbar.phone.QuickSettingsController;
+import com.android.systemui.statusbar.phone.QuickSettingsContainerView;
+import com.android.systemui.statusbar.policy.LocationController;
+import com.android.systemui.statusbar.policy.LocationController.LocationGpsStateChangeCallback;
+
+
+public class GPSTile extends QuickSettingsTile implements LocationGpsStateChangeCallback {
+
+ private boolean enabled = false;
+ private boolean working = false;
+
+ ContentResolver mContentResolver;
+
+ public GPSTile(Context context, LayoutInflater inflater,
+ QuickSettingsContainerView container, QuickSettingsController qsc) {
+ super(context, inflater, container, qsc);
+
+ mContentResolver = mContext.getContentResolver();
+ LocationController controller = new LocationController(mContext);
+ controller.addStateChangedCallback(this);
+
+ mLabel = mContext.getString(R.string.quick_settings_gps);
+ enabled = Settings.Secure.isLocationProviderEnabled(mContentResolver, LocationManager.GPS_PROVIDER);
+
+ onClick = new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ Settings.Secure.setLocationProviderEnabled(mContentResolver, LocationManager.GPS_PROVIDER, !enabled);
+ }
+ };
+
+ onLongClick = new OnLongClickListener() {
+
+ @Override
+ public boolean onLongClick(View v) {
+ startSettingsActivity(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
+ return true;
+ }
+ };
+
+ mBroadcastReceiver = new BroadcastReceiver() {
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ enabled = Settings.Secure.isLocationProviderEnabled(mContentResolver, LocationManager.GPS_PROVIDER);
+ mLabel = mContext.getString(R.string.quick_settings_gps);
+ applyGPSChanges();
+ }
+ };
+
+ mIntentFilter = new IntentFilter(LocationManager.PROVIDERS_CHANGED_ACTION);
+ }
+
+ @Override
+ void onPostCreate() {
+ applyGPSChanges();
+ super.onPostCreate();
+ }
+
+ void applyGPSChanges(){
+ if(enabled && working){
+ mDrawable = R.drawable.ic_qs_location;
+ }else if(enabled){
+ mDrawable = R.drawable.ic_qs_gps_on;
+ }else{
+ mDrawable = R.drawable.ic_qs_gps_off;
+ }
+ updateQuickSettings();
+ }
+
+ @Override
+ public void onLocationGpsStateChanged(boolean inUse, String description) {
+ working = inUse;
+ if(description != null){
+ mLabel = description;
+ }else{
+ mLabel = mContext.getString(R.string.quick_settings_gps);
+ }
+ applyGPSChanges();
+
+ }
+
+}
diff --git a/packages/SystemUI/src/com/android/systemui/quicksettings/InputMethodTile.java b/packages/SystemUI/src/com/android/systemui/quicksettings/InputMethodTile.java
new file mode 100644
index 0000000..0ab45fc
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/quicksettings/InputMethodTile.java
@@ -0,0 +1,133 @@
+package com.android.systemui.quicksettings;
+
+import java.util.List;
+
+import android.app.PendingIntent;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.provider.Settings;
+import android.text.TextUtils;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.inputmethod.InputMethodInfo;
+import android.view.inputmethod.InputMethodManager;
+import android.view.inputmethod.InputMethodSubtype;
+import android.widget.TextView;
+
+import com.android.systemui.R;
+import com.android.systemui.statusbar.phone.QuickSettingsContainerView;
+import com.android.systemui.statusbar.phone.QuickSettingsController;
+
+public class InputMethodTile extends QuickSettingsTile {
+
+ private boolean showTile = false;
+ private static final String TAG_TRY_SUPPRESSING_IME_SWITCHER = "TrySuppressingImeSwitcher";
+
+ public InputMethodTile(Context context, LayoutInflater inflater,
+ QuickSettingsContainerView container, QuickSettingsController qsc) {
+ super(context, inflater, container, qsc);
+
+ mDrawable = R.drawable.ic_qs_ime;
+
+ onClick = new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ try {
+ mQsc.mBar.collapseAllPanels(true);
+ Intent intent = new Intent(Settings.ACTION_SHOW_INPUT_METHOD_PICKER);
+ PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0);
+ pendingIntent.send();
+ } catch (Exception e) {}
+ }
+ };
+
+ }
+
+ public void toggleVisibility(boolean show) {
+ InputMethodManager imm =
+ (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
+ List<InputMethodInfo> imis = imm.getInputMethodList();
+
+ showTile = (show && needsToShowImeSwitchOngoingNotification(imm));
+ mLabel = getCurrentInputMethodName(mContext, mContext.getContentResolver(),
+ imm, imis, mContext.getPackageManager());
+ updateQuickSettings();
+ }
+
+ private static String getCurrentInputMethodName(Context context, ContentResolver resolver,
+ InputMethodManager imm, List<InputMethodInfo> imis, PackageManager pm) {
+ if (resolver == null || imis == null) return null;
+ final String currentInputMethodId = Settings.Secure.getString(resolver,
+ Settings.Secure.DEFAULT_INPUT_METHOD);
+ if (TextUtils.isEmpty(currentInputMethodId)) return null;
+ for (InputMethodInfo imi : imis) {
+ if (currentInputMethodId.equals(imi.getId())) {
+ final InputMethodSubtype subtype = imm.getCurrentInputMethodSubtype();
+ final CharSequence summary = subtype != null
+ ? subtype.getDisplayName(context, imi.getPackageName(),
+ imi.getServiceInfo().applicationInfo)
+ : context.getString(R.string.quick_settings_ime_label);
+ return summary.toString();
+ }
+ }
+ return null;
+ }
+
+ private boolean needsToShowImeSwitchOngoingNotification(InputMethodManager imm) {
+ List<InputMethodInfo> imis = imm.getEnabledInputMethodList();
+ final int N = imis.size();
+ if (N > 2) return true;
+ if (N < 1) return false;
+ int nonAuxCount = 0;
+ int auxCount = 0;
+ InputMethodSubtype nonAuxSubtype = null;
+ InputMethodSubtype auxSubtype = null;
+ for(int i = 0; i < N; ++i) {
+ final InputMethodInfo imi = imis.get(i);
+ final List<InputMethodSubtype> subtypes = imm.getEnabledInputMethodSubtypeList(imi,
+ true);
+ final int subtypeCount = subtypes.size();
+ if (subtypeCount == 0) {
+ ++nonAuxCount;
+ } else {
+ for (int j = 0; j < subtypeCount; ++j) {
+ final InputMethodSubtype subtype = subtypes.get(j);
+ if (!subtype.isAuxiliary()) {
+ ++nonAuxCount;
+ nonAuxSubtype = subtype;
+ } else {
+ ++auxCount;
+ auxSubtype = subtype;
+ }
+ }
+ }
+ }
+ if (nonAuxCount > 1 || auxCount > 1) {
+ return true;
+ } else if (nonAuxCount == 1 && auxCount == 1) {
+ if (nonAuxSubtype != null && auxSubtype != null
+ && (nonAuxSubtype.getLocale().equals(auxSubtype.getLocale())
+ || auxSubtype.overridesImplicitlyEnabledSubtype()
+ || nonAuxSubtype.overridesImplicitlyEnabledSubtype())
+ && nonAuxSubtype.containsExtraValueKey(TAG_TRY_SUPPRESSING_IME_SWITCHER)) {
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ void updateQuickSettings() {
+ TextView tv = (TextView) mTile.findViewById(R.id.tile_textview);
+ tv.setText(mLabel);
+ tv.setCompoundDrawablesWithIntrinsicBounds(0, mDrawable, 0, 0);
+ mTile.setVisibility(showTile ? View.VISIBLE : View.GONE);
+ super.updateQuickSettings();
+ }
+
+}
diff --git a/packages/SystemUI/src/com/android/systemui/quicksettings/MobileNetworkTile.java b/packages/SystemUI/src/com/android/systemui/quicksettings/MobileNetworkTile.java
new file mode 100644
index 0000000..d882b9e
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/quicksettings/MobileNetworkTile.java
@@ -0,0 +1,140 @@
+package com.android.systemui.quicksettings;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.res.Resources;
+import android.net.ConnectivityManager;
+import android.telephony.TelephonyManager;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnLongClickListener;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.android.systemui.R;
+import com.android.systemui.statusbar.phone.QuickSettingsController;
+import com.android.systemui.statusbar.phone.QuickSettingsContainerView;
+import com.android.systemui.statusbar.policy.NetworkController;
+import com.android.systemui.statusbar.policy.NetworkController.NetworkSignalChangedCallback;
+
+public class MobileNetworkTile extends QuickSettingsTile implements NetworkSignalChangedCallback{
+
+ private int mDataTypeIconId;
+ private String dataContentDescription;
+ private String signalContentDescription;
+ private boolean wifiOn = false;
+
+ public MobileNetworkTile(Context context, LayoutInflater inflater,
+ QuickSettingsContainerView container, QuickSettingsController qsc) {
+ super(context, inflater, container, qsc);
+ mTileLayout = R.layout.quick_settings_tile_rssi;
+ onClick = new View.OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ TelephonyManager tm = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
+ ConnectivityManager conMan = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
+ if(tm.getDataState() == TelephonyManager.DATA_DISCONNECTED){
+ conMan.setMobileDataEnabled(true);
+ }else{
+ conMan.setMobileDataEnabled(false);
+ }
+ }
+ };
+ onLongClick = new OnLongClickListener() {
+
+ @Override
+ public boolean onLongClick(View v) {
+ Intent intent = new Intent();
+ intent.setComponent(new ComponentName(
+ "com.android.settings",
+ "com.android.settings.Settings$DataUsageSummaryActivity"));
+ startSettingsActivity(intent);
+ return true;
+ }
+ };
+ }
+
+ @Override
+ void onPostCreate() {
+ NetworkController controller = new NetworkController(mContext);
+ controller.addNetworkSignalChangedCallback(this);
+ super.onPostCreate();
+ }
+
+ @Override
+ public void onWifiSignalChanged(boolean enabled, int wifiSignalIconId,
+ String wifitSignalContentDescriptionId, String description) {
+ wifiOn = enabled;
+
+ }
+
+ @Override
+ public void onMobileDataSignalChanged(boolean enabled,
+ int mobileSignalIconId, String mobileSignalContentDescriptionId,
+ int dataTypeIconId, String dataTypeContentDescriptionId,
+ String description) {
+ if (deviceSupportsTelephony()) {
+ // TODO: If view is in awaiting state, disable
+ Resources r = mContext.getResources();
+ mDrawable = enabled && (mobileSignalIconId > 0)
+ ? mobileSignalIconId
+ : R.drawable.ic_qs_signal_no_signal;
+ signalContentDescription = enabled && (mobileSignalIconId > 0)
+ ? signalContentDescription
+ : r.getString(R.string.accessibility_no_signal);
+ mDataTypeIconId = enabled && (dataTypeIconId > 0) && !wifiOn
+ ? dataTypeIconId
+ : 0;
+ dataContentDescription = enabled && (dataTypeIconId > 0) && !wifiOn
+ ? dataContentDescription
+ : r.getString(R.string.accessibility_no_data);
+ mLabel = enabled
+ ? removeTrailingPeriod(description)
+ : r.getString(R.string.quick_settings_rssi_emergency_only);
+ updateQuickSettings();
+ }
+ }
+
+ @Override
+ public void onAirplaneModeChanged(boolean enabled) {
+ // TODO Auto-generated method stub
+
+ }
+
+ boolean deviceSupportsTelephony() {
+ PackageManager pm = mContext.getPackageManager();
+ return pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY);
+ }
+
+ @Override
+ void updateQuickSettings() {
+ TextView tv = (TextView) mTile.findViewById(R.id.rssi_textview);
+ ImageView iv = (ImageView) mTile.findViewById(R.id.rssi_image);
+ ImageView iov = (ImageView) mTile.findViewById(R.id.rssi_overlay_image);
+ iv.setImageResource(mDrawable);
+ if (mDataTypeIconId > 0) {
+ iov.setImageResource(mDataTypeIconId);
+ } else {
+ iov.setImageDrawable(null);
+ }
+ tv.setText(mLabel);
+ mTile.setContentDescription(mContext.getResources().getString(
+ R.string.accessibility_quick_settings_mobile,
+ signalContentDescription, dataContentDescription,
+ mLabel));
+ }
+
+ // Remove the period from the network name
+ public static String removeTrailingPeriod(String string) {
+ if (string == null) return null;
+ final int length = string.length();
+ if (string.endsWith(".")) {
+ string.substring(0, length - 1);
+ }
+ return string;
+ }
+
+}
diff --git a/packages/SystemUI/src/com/android/systemui/quicksettings/MobileNetworkTypeTile.java b/packages/SystemUI/src/com/android/systemui/quicksettings/MobileNetworkTypeTile.java
new file mode 100644
index 0000000..67a1b22
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/quicksettings/MobileNetworkTypeTile.java
@@ -0,0 +1,174 @@
+package com.android.systemui.quicksettings;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.provider.Settings;
+import android.provider.Settings.SettingNotFoundException;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+
+import com.android.internal.telephony.Phone;
+import com.android.systemui.R;
+import com.android.systemui.statusbar.phone.QuickSettingsController;
+import com.android.systemui.statusbar.phone.QuickSettingsContainerView;
+
+/*
+ * This Quicksettings works as the toggle in Power Widget, so it's not functional on CM10.1
+ *
+ * This must be fixed before adding it to the quicksettings panel
+ */
+
+public class MobileNetworkTypeTile extends QuickSettingsTile {
+
+ private static final String TAG = "NetworkModeQuickSettings";
+
+ // retrieved from Phone.apk
+ public static final String ACTION_NETWORK_MODE_CHANGED = "com.android.internal.telephony.NETWORK_MODE_CHANGED";
+ public static final String ACTION_REQUEST_NETWORK_MODE = "com.android.internal.telephony.REQUEST_NETWORK_MODE";
+ public static final String ACTION_MODIFY_NETWORK_MODE = "com.android.internal.telephony.MODIFY_NETWORK_MODE";
+ public static final String EXTRA_NETWORK_MODE = "networkMode";
+
+ private static final int NO_NETWORK_MODE_YET = -99;
+ private static final int NETWORK_MODE_UNKNOWN = -100;
+
+ private static final int CM_MODE_3G2G = 0;
+ private static final int CM_MODE_3GONLY = 1;
+ private static final int CM_MODE_BOTH = 2;
+
+ private static final int ONLY_2G = 0;
+ private static final int BOTH_3G_2G = 1;
+ private static final int STATE_INTERMEDIATE = 2;
+
+ private int mMode = NO_NETWORK_MODE_YET;
+ private int mIntendedMode = NO_NETWORK_MODE_YET;
+ private final int mInternalState = STATE_INTERMEDIATE;
+
+ private final int mState;
+
+
+ public MobileNetworkTypeTile(Context context,
+ LayoutInflater inflater, QuickSettingsContainerView container,
+ QuickSettingsController qsc) {
+ super(context, inflater, container, qsc);
+
+
+ mMode = get2G3G(context);
+ mState = networkModeToState(context);
+
+ switch (mState) {
+ case ONLY_2G:
+ mDrawable = R.drawable.stat_2g3g_off;
+ break;
+ case BOTH_3G_2G:
+ if (mMode == Phone.NT_MODE_WCDMA_ONLY) {
+ mDrawable = R.drawable.stat_3g_on;
+ } else {
+ mDrawable = R.drawable.stat_2g3g_on;
+ }
+ break;
+ }
+
+ mLabel = mContext.getString(R.string.quick_settings_network_type);
+
+ onClick = new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ int currentMode = getCurrentCMMode(mContext);
+
+ Intent intent = new Intent(ACTION_MODIFY_NETWORK_MODE);
+ switch (mMode) {
+ case Phone.NT_MODE_WCDMA_PREF:
+ case Phone.NT_MODE_GSM_UMTS:
+ intent.putExtra(EXTRA_NETWORK_MODE, Phone.NT_MODE_GSM_ONLY);
+ mIntendedMode = Phone.NT_MODE_GSM_ONLY;
+ break;
+ case Phone.NT_MODE_WCDMA_ONLY:
+ if (currentMode == CM_MODE_3GONLY) {
+ intent.putExtra(EXTRA_NETWORK_MODE, Phone.NT_MODE_GSM_ONLY);
+ mIntendedMode = Phone.NT_MODE_GSM_ONLY;
+ } else {
+ intent.putExtra(EXTRA_NETWORK_MODE, Phone.NT_MODE_WCDMA_PREF);
+ mIntendedMode = Phone.NT_MODE_WCDMA_PREF;
+ }
+ break;
+ case Phone.NT_MODE_GSM_ONLY:
+ if (currentMode == CM_MODE_3GONLY || currentMode == CM_MODE_BOTH) {
+ intent.putExtra(EXTRA_NETWORK_MODE, Phone.NT_MODE_WCDMA_ONLY);
+ mIntendedMode = Phone.NT_MODE_WCDMA_ONLY;
+ } else {
+ intent.putExtra(EXTRA_NETWORK_MODE, Phone.NT_MODE_WCDMA_PREF);
+ mIntendedMode = Phone.NT_MODE_WCDMA_PREF;
+ }
+ break;
+ }
+
+ mMode = NETWORK_MODE_UNKNOWN;
+ mContext.sendBroadcast(intent);
+ }
+ };
+
+ mBroadcastReceiver = new BroadcastReceiver() {
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ int mode = intent.getIntExtra(EXTRA_NETWORK_MODE, 0);
+ switch(mode){
+ case Phone.NT_MODE_WCDMA_PREF:
+ case Phone.NT_MODE_GSM_UMTS:
+ mDrawable = R.drawable.stat_2g3g_on;
+ break;
+ case Phone.NT_MODE_WCDMA_ONLY:
+ mDrawable = R.drawable.stat_3g_on;
+ break;
+ case Phone.NT_MODE_GSM_ONLY:
+ mDrawable = R.drawable.stat_2g3g_off;
+ }
+ updateQuickSettings();
+ }
+ };
+
+ mIntentFilter = new IntentFilter(ACTION_MODIFY_NETWORK_MODE);
+ }
+
+ private static int get2G3G(Context context) {
+ int state = 99;
+ try {
+ state = Settings.Secure.getInt(context.getContentResolver(),
+ Settings.Global.PREFERRED_NETWORK_MODE);
+ } catch (SettingNotFoundException e) {
+ }
+ return state;
+ }
+
+ private int networkModeToState(Context context) {
+
+ switch (mMode) {
+ case Phone.NT_MODE_WCDMA_PREF:
+ case Phone.NT_MODE_WCDMA_ONLY:
+ case Phone.NT_MODE_GSM_UMTS:
+ return BOTH_3G_2G;
+ case Phone.NT_MODE_GSM_ONLY:
+ return ONLY_2G;
+ case Phone.NT_MODE_CDMA:
+ case Phone.NT_MODE_CDMA_NO_EVDO:
+ case Phone.NT_MODE_EVDO_NO_CDMA:
+ case Phone.NT_MODE_GLOBAL:
+ // need to check wtf is going on
+ Log.d(TAG, "Unexpected network mode (" + mMode + ")");
+ return ONLY_2G;
+ }
+ return STATE_INTERMEDIATE;
+ }
+
+ private static int getCurrentCMMode(Context context) {
+ return Settings.System.getInt(context.getContentResolver(),
+ Settings.System.EXPANDED_NETWORK_MODE,
+ CM_MODE_3G2G);
+ }
+
+}
diff --git a/packages/SystemUI/src/com/android/systemui/quicksettings/PreferencesTile.java b/packages/SystemUI/src/com/android/systemui/quicksettings/PreferencesTile.java
new file mode 100644
index 0000000..804e01c
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/quicksettings/PreferencesTile.java
@@ -0,0 +1,29 @@
+package com.android.systemui.quicksettings;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+
+import com.android.systemui.R;
+import com.android.systemui.statusbar.phone.QuickSettingsContainerView;
+import com.android.systemui.statusbar.phone.QuickSettingsController;
+
+public class PreferencesTile extends QuickSettingsTile{
+
+ public PreferencesTile(Context context, LayoutInflater inflater,
+ QuickSettingsContainerView container, QuickSettingsController qsc) {
+ super(context, inflater, container, qsc);
+
+ mDrawable = R.drawable.ic_qs_settings;
+ mLabel = mContext.getString(R.string.quick_settings_settings_label);
+
+ onClick = new View.OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ startSettingsActivity(android.provider.Settings.ACTION_SETTINGS);
+ }
+ };
+ }
+
+}
diff --git a/packages/SystemUI/src/com/android/systemui/quicksettings/QuickSettingsTile.java b/packages/SystemUI/src/com/android/systemui/quicksettings/QuickSettingsTile.java
new file mode 100644
index 0000000..7d64521
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/quicksettings/QuickSettingsTile.java
@@ -0,0 +1,93 @@
+package com.android.systemui.quicksettings;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.UserHandle;
+import android.view.LayoutInflater;
+import android.view.View.OnClickListener;
+import android.view.View.OnLongClickListener;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import com.android.systemui.R;
+import com.android.systemui.statusbar.phone.QuickSettingsController;
+import com.android.systemui.statusbar.phone.PhoneStatusBar;
+import com.android.systemui.statusbar.phone.QuickSettingsContainerView;
+import com.android.systemui.statusbar.phone.QuickSettingsTileView;
+
+public class QuickSettingsTile {
+
+ protected final Context mContext;
+ protected final ViewGroup mContainerView;
+ protected final LayoutInflater mInflater;
+ protected QuickSettingsTileView mTile;
+ protected OnClickListener onClick;
+ protected OnLongClickListener onLongClick;
+ protected int mTileLayout;
+ protected BroadcastReceiver mBroadcastReceiver;
+ protected IntentFilter mIntentFilter;
+ protected int mDrawable;
+ protected String mLabel;
+ protected PhoneStatusBar mStatusbarService;
+ protected QuickSettingsController mQsc;
+
+ public QuickSettingsTile(Context context, LayoutInflater inflater, QuickSettingsContainerView container, QuickSettingsController qsc) {
+ mContext = context;
+ mContainerView = container;
+ mInflater = inflater;
+ mDrawable = R.drawable.ic_notifications;
+ mLabel = mContext.getString(R.string.quick_settings_label_enabled);
+ mStatusbarService = qsc.mStatusBarService;
+ mQsc = qsc;
+ mTileLayout = R.layout.quick_settings_tile_generic;
+ }
+
+ public void setupQuickSettingsTile(){
+ createQuickSettings();
+ onPostCreate();
+ registerQuickSettingsReceiver();
+ updateQuickSettings();
+ mTile.setOnClickListener(onClick);
+ mTile.setOnLongClickListener(onLongClick);
+ }
+
+ void createQuickSettings(){
+ mTile = (QuickSettingsTileView) mInflater.inflate(R.layout.quick_settings_tile, mContainerView, false);
+ mTile.setContent(mTileLayout, mInflater);
+ mContainerView.addView(mTile);
+ }
+
+ private void registerQuickSettingsReceiver() {
+ if(mBroadcastReceiver != null && mIntentFilter != null){
+ mContext.registerReceiver(mBroadcastReceiver, mIntentFilter);
+ }
+ }
+
+ void onPostCreate(){
+
+ }
+
+ void updateQuickSettings(){
+ TextView tv = (TextView) mTile.findViewById(R.id.tile_textview);
+ tv.setCompoundDrawablesWithIntrinsicBounds(0, mDrawable, 0, 0);
+ tv.setText(mLabel);
+ }
+
+ void startSettingsActivity(String action){
+ Intent intent = new Intent(action);
+ startSettingsActivity(intent);
+ }
+
+ void startSettingsActivity(Intent intent) {
+ startSettingsActivity(intent, true);
+ }
+
+ private void startSettingsActivity(Intent intent, boolean onlyProvisioned) {
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ mContext.startActivityAsUser(intent, new UserHandle(UserHandle.USER_CURRENT));
+ mStatusbarService.animateCollapsePanels();
+ }
+
+}
diff --git a/packages/SystemUI/src/com/android/systemui/quicksettings/RingerModeTile.java b/packages/SystemUI/src/com/android/systemui/quicksettings/RingerModeTile.java
new file mode 100644
index 0000000..77d7084
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/quicksettings/RingerModeTile.java
@@ -0,0 +1,70 @@
+package com.android.systemui.quicksettings;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.media.AudioManager;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnLongClickListener;
+
+import com.android.systemui.R;
+import com.android.systemui.statusbar.phone.QuickSettingsController;
+import com.android.systemui.statusbar.phone.QuickSettingsContainerView;
+
+public class RingerModeTile extends QuickSettingsTile {
+
+ private AudioManager mAudioManager;
+
+ public RingerModeTile(Context context, LayoutInflater inflater,
+ QuickSettingsContainerView container, QuickSettingsController qsc) {
+ super(context, inflater, container, qsc);
+
+ mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
+
+ onClick = new View.OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ if(mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_NORMAL){
+ if(mAudioManager.getVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER) == AudioManager.VIBRATE_SETTING_ON){
+ mAudioManager.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
+ }else{
+ mAudioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
+ }
+ }else{
+ mAudioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
+ }
+ }
+ };
+
+ onLongClick = new OnLongClickListener() {
+
+ @Override
+ public boolean onLongClick(View v) {
+ startSettingsActivity(android.provider.Settings.ACTION_SOUND_SETTINGS);
+ return true;
+ }
+ };
+
+ mBroadcastReceiver = new BroadcastReceiver() {
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if(mAudioManager.isSilentMode()){
+ mDrawable = R.drawable.ic_qs_ring_off;
+ mLabel = mContext.getString(R.string.quick_settings_ringer_off);
+ }else{
+ mDrawable = R.drawable.ic_qs_ring_on;
+ mLabel = mContext.getString(R.string.quick_settings_ringer_on);
+ }
+ updateQuickSettings();
+ }
+ };
+
+ mIntentFilter = new IntentFilter();
+ mIntentFilter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
+ }
+
+}
diff --git a/packages/SystemUI/src/com/android/systemui/quicksettings/RingerVibrationModeTile.java b/packages/SystemUI/src/com/android/systemui/quicksettings/RingerVibrationModeTile.java
new file mode 100644
index 0000000..b648f9d
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/quicksettings/RingerVibrationModeTile.java
@@ -0,0 +1,99 @@
+package com.android.systemui.quicksettings;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.media.AudioManager;
+import android.os.Vibrator;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnLongClickListener;
+
+import com.android.systemui.R;
+import com.android.systemui.statusbar.phone.QuickSettingsController;
+import com.android.systemui.statusbar.phone.QuickSettingsContainerView;
+
+public class RingerVibrationModeTile extends QuickSettingsTile {
+
+ private AudioManager mAudioManager;
+
+ public RingerVibrationModeTile(Context context, LayoutInflater inflater,
+ QuickSettingsContainerView container, QuickSettingsController qsc) {
+ super(context, inflater, container, qsc);
+
+ mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
+
+ onClick = new View.OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ Vibrator vibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
+ boolean vibrate = mAudioManager.getVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER) == AudioManager.VIBRATE_SETTING_ON;
+ if(mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_NORMAL && vibrate){
+ // Switch to Silent
+ mAudioManager.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, AudioManager.VIBRATE_SETTING_OFF);
+ mAudioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
+ }else if(mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_NORMAL){
+ // Switch to Sound + Vibration
+ vibrator.vibrate(300);
+ mAudioManager.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, AudioManager.VIBRATE_SETTING_ON);
+ mAudioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
+ Intent i = new Intent(VibrationModeTile.VIBRATION_STATE_CHANGED);
+ mContext.sendBroadcast(i);
+ }else if(mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT){
+ // Switch to Vibration
+ vibrator.vibrate(300);
+ mAudioManager.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
+ mAudioManager.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, AudioManager.VIBRATE_SETTING_ON);
+ Intent i = new Intent(VibrationModeTile.VIBRATION_STATE_CHANGED);
+ mContext.sendBroadcast(i);
+ }else if(mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE){
+ // Switch to Sound
+ mAudioManager.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, AudioManager.VIBRATE_SETTING_OFF);
+ mAudioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
+ }
+ applyVibrationChanges();
+ }
+ };
+
+ onLongClick = new OnLongClickListener() {
+
+ @Override
+ public boolean onLongClick(View v) {
+ startSettingsActivity(android.provider.Settings.ACTION_SOUND_SETTINGS);
+ return true;
+ }
+ };
+
+ mBroadcastReceiver = new BroadcastReceiver() {
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ applyVibrationChanges();
+ }
+ };
+
+ mIntentFilter = new IntentFilter();
+ mIntentFilter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
+ mIntentFilter.addAction(VibrationModeTile.VIBRATION_STATE_CHANGED);
+ }
+
+ private void applyVibrationChanges(){
+ boolean vibrate = mAudioManager.getVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER) == AudioManager.VIBRATE_SETTING_ON;
+ mLabel = mContext.getString(R.string.quick_settings_ringer_normal);
+ if(mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_NORMAL && vibrate){
+ //Sound + Vibrate
+ mDrawable = R.drawable.ic_qs_ring_vibrate_on;
+ }else if(mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_NORMAL){
+ //Sound
+ mDrawable = R.drawable.ic_qs_ring_on;
+ }else if(mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT){
+ mDrawable = R.drawable.ic_qs_ring_off;
+ }else{
+ mDrawable = R.drawable.ic_qs_vibrate_on;
+ }
+ updateQuickSettings();
+ }
+
+}
diff --git a/packages/SystemUI/src/com/android/systemui/quicksettings/SleepScreenTile.java b/packages/SystemUI/src/com/android/systemui/quicksettings/SleepScreenTile.java
new file mode 100644
index 0000000..97e6201
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/quicksettings/SleepScreenTile.java
@@ -0,0 +1,41 @@
+package com.android.systemui.quicksettings;
+
+import android.content.Context;
+import android.os.PowerManager;
+import android.os.SystemClock;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.View.OnLongClickListener;
+
+import com.android.systemui.R;
+import com.android.systemui.statusbar.phone.QuickSettingsController;
+import com.android.systemui.statusbar.phone.QuickSettingsContainerView;
+
+public class SleepScreenTile extends QuickSettingsTile {
+
+ private PowerManager pm;
+
+ public SleepScreenTile(Context context, LayoutInflater inflater,
+ QuickSettingsContainerView container, QuickSettingsController qsc) {
+ super(context, inflater, container, qsc);
+ mDrawable = R.drawable.ic_qs_sleep;
+ mLabel = mContext.getString(R.string.quick_settings_screen_sleep);
+ pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
+ onClick = new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ pm.goToSleep(SystemClock.uptimeMillis());
+ }
+ };
+ onLongClick = new OnLongClickListener() {
+
+ @Override
+ public boolean onLongClick(View v) {
+ startSettingsActivity("android.settings.DISPLAY_SETTINGS");
+ return true;
+ }
+ };
+ }
+
+}
diff --git a/packages/SystemUI/src/com/android/systemui/quicksettings/ToggleLockscreenTile.java b/packages/SystemUI/src/com/android/systemui/quicksettings/ToggleLockscreenTile.java
new file mode 100644
index 0000000..6a429da
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/quicksettings/ToggleLockscreenTile.java
@@ -0,0 +1,81 @@
+package com.android.systemui.quicksettings;
+
+import android.app.KeyguardManager;
+import android.app.KeyguardManager.KeyguardLock;
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.View.OnLongClickListener;
+
+import com.android.systemui.R;
+import com.android.systemui.statusbar.phone.QuickSettingsController;
+import com.android.systemui.statusbar.phone.QuickSettingsContainerView;
+import com.android.systemui.statusbar.powerwidget.PowerButton;
+
+public class ToggleLockscreenTile extends QuickSettingsTile {
+
+ private KeyguardLock mLock = null;
+ private static final String KEY_DISABLED = "lockscreen_disabled";
+
+ private final KeyguardManager mKeyguardManager;
+ private boolean mDisabledLockscreen = false;
+ private SharedPreferences sp;
+
+ public ToggleLockscreenTile(Context context,
+ LayoutInflater inflater, QuickSettingsContainerView container, QuickSettingsController qsc) {
+ super(context, inflater, container, qsc);
+
+ mLabel = mContext.getString(R.string.quick_settings_lockscreen);
+
+ mKeyguardManager = (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE);
+
+ onClick = new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ mDisabledLockscreen = !mDisabledLockscreen;
+
+ sp = mContext.getSharedPreferences("PowerButton-" + PowerButton.BUTTON_LOCKSCREEN, Context.MODE_PRIVATE);
+ SharedPreferences.Editor editor = sp.edit();
+ editor.putBoolean(KEY_DISABLED, mDisabledLockscreen);
+ editor.apply();
+
+ applyLockscreenChanges();
+ }
+ };
+
+ onLongClick = new OnLongClickListener() {
+
+ @Override
+ public boolean onLongClick(View v) {
+ startSettingsActivity("android.settings.SECURITY_SETTINGS");
+ return true;
+ }
+ };
+ }
+
+ @Override
+ void onPostCreate() {
+ applyLockscreenChanges();
+ super.onPostCreate();
+ }
+
+ void applyLockscreenChanges() {
+ if (mLock == null) {
+ KeyguardManager keyguardManager = (KeyguardManager)
+ mContext.getSystemService(Context.KEYGUARD_SERVICE);
+ mLock = keyguardManager.newKeyguardLock("PowerWidget");
+ }
+ if (mDisabledLockscreen) {
+ mDrawable = R.drawable.ic_qs_lock_screen_off;
+ mLock.disableKeyguard();
+ } else {
+ mDrawable = R.drawable.ic_qs_lock_screen_on;
+ mLock.reenableKeyguard();
+ }
+ updateQuickSettings();
+ }
+
+}
diff --git a/packages/SystemUI/src/com/android/systemui/quicksettings/UserTile.java b/packages/SystemUI/src/com/android/systemui/quicksettings/UserTile.java
new file mode 100644
index 0000000..64bd922
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/quicksettings/UserTile.java
@@ -0,0 +1,179 @@
+package com.android.systemui.quicksettings;
+
+import android.app.ActivityManagerNative;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.pm.UserInfo;
+import android.database.Cursor;
+import android.graphics.Bitmap;
+import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.Drawable;
+import android.os.AsyncTask;
+import android.os.RemoteException;
+import android.os.UserHandle;
+import android.os.UserManager;
+import android.provider.ContactsContract;
+import android.provider.ContactsContract.CommonDataKinds.Phone;
+import android.provider.ContactsContract.Profile;
+import android.util.Log;
+import android.util.Pair;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.WindowManagerGlobal;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.android.internal.widget.LockPatternUtils;
+import com.android.systemui.R;
+import com.android.systemui.statusbar.phone.QuickSettingsContainerView;
+import com.android.systemui.statusbar.phone.QuickSettingsController;
+
+public class UserTile extends QuickSettingsTile {
+
+ private static final String TAG = "UserTile";
+ private Drawable userAvatar;
+ private AsyncTask<Void, Void, Pair<String, Drawable>> mUserInfoTask;
+
+ public UserTile(Context context, LayoutInflater inflater,
+ QuickSettingsContainerView container, QuickSettingsController qsc) {
+ super(context, inflater, container, qsc);
+
+ mTileLayout = R.layout.quick_settings_tile_user;
+
+ onClick = new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ mQsc.mBar.collapseAllPanels(true);
+ final UserManager um =
+ (UserManager) mContext.getSystemService(Context.USER_SERVICE);
+ if (um.getUsers(true).size() > 1) {
+ try {
+ WindowManagerGlobal.getWindowManagerService().lockNow(
+ LockPatternUtils.USER_SWITCH_LOCK_OPTIONS);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Couldn't show user switcher", e);
+ }
+ } else {
+ Intent intent = ContactsContract.QuickContact.composeQuickContactsIntent(
+ mContext, v, ContactsContract.Profile.CONTENT_URI,
+ ContactsContract.QuickContact.MODE_LARGE, null);
+ mContext.startActivityAsUser(intent, new UserHandle(UserHandle.USER_CURRENT));
+ }
+ }
+ };
+
+ mBroadcastReceiver = new BroadcastReceiver() {
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ queryForUserInformation();
+ }
+ };
+
+ mIntentFilter = new IntentFilter();
+ mIntentFilter.addAction(Intent.ACTION_USER_SWITCHED);
+ mIntentFilter.addAction(ContactsContract.Intents.ACTION_PROFILE_CHANGED);
+ }
+
+ @Override
+ void onPostCreate() {
+ queryForUserInformation();
+ super.onPostCreate();
+ }
+
+ @Override
+ void updateQuickSettings() {
+ ImageView iv = (ImageView) mTile.findViewById(R.id.user_imageview);
+ TextView tv = (TextView) mTile.findViewById(R.id.user_textview);
+ tv.setText(mLabel);
+ iv.setImageDrawable(userAvatar);
+ }
+
+ private void queryForUserInformation() {
+ Context currentUserContext = null;
+ UserInfo userInfo = null;
+ try {
+ userInfo = ActivityManagerNative.getDefault().getCurrentUser();
+ currentUserContext = mContext.createPackageContextAsUser("android", 0,
+ new UserHandle(userInfo.id));
+ } catch (NameNotFoundException e) {
+ Log.e(TAG, "Couldn't create user context", e);
+ throw new RuntimeException(e);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Couldn't get user info", e);
+ }
+ final int userId = userInfo.id;
+ final String userName = userInfo.name;
+
+ final Context context = currentUserContext;
+ mUserInfoTask = new AsyncTask<Void, Void, Pair<String, Drawable>>() {
+ @Override
+ protected Pair<String, Drawable> doInBackground(Void... params) {
+ try {
+ // The system needs some time to change the picture, if we try to load it when we receive the broadcast, we will load the old one
+ Thread.sleep(50);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ final UserManager um =
+ (UserManager) mContext.getSystemService(Context.USER_SERVICE);
+
+ // Fall back to the UserManager nickname if we can't read the name from the local
+ // profile below.
+ String name = userName;
+ Drawable avatar = null;
+ Bitmap rawAvatar = um.getUserIcon(userId);
+ if (rawAvatar != null) {
+ avatar = new BitmapDrawable(mContext.getResources(), rawAvatar);
+ } else {
+ avatar = mContext.getResources().getDrawable(R.drawable.ic_qs_default_user);
+ }
+
+ // If it's a single-user device, get the profile name, since the nickname is not
+ // usually valid
+ if (um.getUsers().size() <= 1) {
+ // Try and read the display name from the local profile
+ final Cursor cursor = context.getContentResolver().query(
+ Profile.CONTENT_URI, new String[] {Phone._ID, Phone.DISPLAY_NAME},
+ null, null, null);
+ if (cursor != null) {
+ try {
+ if (cursor.moveToFirst()) {
+ name = cursor.getString(cursor.getColumnIndex(Phone.DISPLAY_NAME));
+ }
+ } finally {
+ cursor.close();
+ }
+ }
+ }
+ return new Pair<String, Drawable>(name, avatar);
+ }
+
+ @Override
+ protected void onPostExecute(Pair<String, Drawable> result) {
+ super.onPostExecute(result);
+ setUserTileInfo(result.first, result.second);
+ mUserInfoTask = null;
+ }
+ };
+ mUserInfoTask.execute();
+ }
+
+ void setUserTileInfo(String name, Drawable avatar) {
+ mLabel = name;
+ userAvatar = avatar;
+ updateQuickSettings();
+ }
+
+ void reloadUserInfo() {
+ if (mUserInfoTask != null) {
+ mUserInfoTask.cancel(false);
+ mUserInfoTask = null;
+ }
+ }
+
+}
diff --git a/packages/SystemUI/src/com/android/systemui/quicksettings/VibrationModeTile.java b/packages/SystemUI/src/com/android/systemui/quicksettings/VibrationModeTile.java
new file mode 100644
index 0000000..0eba739
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/quicksettings/VibrationModeTile.java
@@ -0,0 +1,101 @@
+package com.android.systemui.quicksettings;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.media.AudioManager;
+import android.os.Vibrator;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnLongClickListener;
+
+import com.android.systemui.R;
+import com.android.systemui.statusbar.phone.QuickSettingsController;
+import com.android.systemui.statusbar.phone.QuickSettingsContainerView;
+
+public class VibrationModeTile extends QuickSettingsTile {
+
+ private AudioManager mAudioManager;
+ public final static String VIBRATION_STATE_CHANGED = "com.android.systemui.quicksettings.VIBRATION_STATE_CHANGED";
+
+ public VibrationModeTile(Context context, LayoutInflater inflater,
+ QuickSettingsContainerView container, QuickSettingsController qsc) {
+ super(context, inflater, container, qsc);
+
+ mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
+
+ onClick = new View.OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
+ Vibrator vibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
+ if(mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE){
+ //Vibrate -> Silent
+ mAudioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
+ mAudioManager.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, AudioManager.VIBRATE_SETTING_OFF);
+ }else if(mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT){
+ //Silent -> Vibrate
+ vibrator.vibrate(300);
+ mAudioManager.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
+ mAudioManager.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, AudioManager.VIBRATE_SETTING_ON);
+ Intent i = new Intent(VIBRATION_STATE_CHANGED);
+ mContext.sendBroadcast(i);
+ }else if(mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_NORMAL){
+ if(mAudioManager.getVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER) == AudioManager.VIBRATE_SETTING_ON){
+ //Sound + Vibrate -> Sound
+ mAudioManager.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, AudioManager.VIBRATE_SETTING_OFF);
+ }else{
+ //Sound -> Sound + Vibrate
+ vibrator.vibrate(300);
+ Intent i = new Intent(VIBRATION_STATE_CHANGED);
+ mContext.sendBroadcast(i);
+ mAudioManager.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, AudioManager.VIBRATE_SETTING_ON);
+ }
+ applyVibrationChanges();
+ }
+ }
+ };
+
+ onLongClick = new OnLongClickListener() {
+
+ @Override
+ public boolean onLongClick(View v) {
+ startSettingsActivity(android.provider.Settings.ACTION_SOUND_SETTINGS);
+ return true;
+ }
+ };
+
+ mBroadcastReceiver = new BroadcastReceiver() {
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ applyVibrationChanges();
+ }
+ };
+
+ mIntentFilter = new IntentFilter();
+ mIntentFilter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
+ mIntentFilter.addAction(VIBRATION_STATE_CHANGED);
+ }
+
+ private void applyVibrationChanges(){
+ int vibrateSetting = mAudioManager.getVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER);
+ if(mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_NORMAL && vibrateSetting == AudioManager.VIBRATE_SETTING_ON){
+ //Sound + vibrate
+ mDrawable = R.drawable.ic_qs_vibrate_on;
+ mLabel = mContext.getString(R.string.quick_settings_vibration_on);
+ }else if(mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE){
+ //Vibrate
+ mDrawable = R.drawable.ic_qs_vibrate_on;
+ mLabel = mContext.getString(R.string.quick_settings_vibration_on);
+ }else{
+ //No vibration
+ mDrawable = R.drawable.ic_qs_vibrate_off;
+ mLabel = mContext.getString(R.string.quick_settings_vibration_off);
+ }
+ updateQuickSettings();
+ }
+
+}
diff --git a/packages/SystemUI/src/com/android/systemui/quicksettings/WiFiDisplayTile.java b/packages/SystemUI/src/com/android/systemui/quicksettings/WiFiDisplayTile.java
new file mode 100644
index 0000000..c72bf93
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/quicksettings/WiFiDisplayTile.java
@@ -0,0 +1,69 @@
+package com.android.systemui.quicksettings;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.hardware.display.DisplayManager;
+import android.hardware.display.WifiDisplayStatus;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+
+import com.android.systemui.R;
+import com.android.systemui.statusbar.phone.QuickSettingsController;
+import com.android.systemui.statusbar.phone.QuickSettingsContainerView;
+
+public class WiFiDisplayTile extends QuickSettingsTile{
+
+ private boolean enabled = false;
+ private boolean connected = false;
+
+ public WiFiDisplayTile(Context context, LayoutInflater inflater,
+ QuickSettingsContainerView container,
+ QuickSettingsController qsc) {
+ super(context, inflater, container, qsc);
+
+ onClick = new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ startSettingsActivity(android.provider.Settings.ACTION_WIFI_DISPLAY_SETTINGS);
+ }
+ };
+
+ mBroadcastReceiver = new BroadcastReceiver() {
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ WifiDisplayStatus status = (WifiDisplayStatus)intent.getParcelableExtra(DisplayManager.EXTRA_WIFI_DISPLAY_STATUS);
+ enabled = status.getFeatureState() == WifiDisplayStatus.FEATURE_STATE_ON;
+ connected = status.getActiveDisplay() != null;
+ applyWiFiDisplayChanges();
+ }
+ };
+
+ mIntentFilter = new IntentFilter(DisplayManager.ACTION_WIFI_DISPLAY_STATUS_CHANGED);
+
+ applyWiFiDisplayChanges();
+ }
+
+ private void applyWiFiDisplayChanges() {
+ if(enabled && connected) {
+ mLabel = mContext.getString(R.string.quick_settings_wifi_display_label);
+ mDrawable = R.drawable.ic_qs_remote_display_connected;
+ }else{
+ mLabel = mContext.getString(R.string.quick_settings_wifi_display_no_connection_label);
+ mDrawable = R.drawable.ic_qs_remote_display;
+ }
+ if(mTile != null) {
+ updateQuickSettings();
+ }
+ }
+
+ @Override
+ void updateQuickSettings() {
+ mTile.setVisibility(enabled ? View.VISIBLE : View.GONE);
+ super.updateQuickSettings();
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/quicksettings/WiFiTile.java b/packages/SystemUI/src/com/android/systemui/quicksettings/WiFiTile.java
new file mode 100644
index 0000000..adc5b25
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/quicksettings/WiFiTile.java
@@ -0,0 +1,78 @@
+package com.android.systemui.quicksettings;
+
+import android.content.Context;
+import android.net.wifi.WifiManager;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnLongClickListener;
+
+import com.android.systemui.R;
+import com.android.systemui.statusbar.phone.QuickSettingsContainerView;
+import com.android.systemui.statusbar.phone.QuickSettingsController;
+import com.android.systemui.statusbar.policy.NetworkController;
+import com.android.systemui.statusbar.policy.NetworkController.NetworkSignalChangedCallback;
+
+public class WiFiTile extends QuickSettingsTile implements NetworkSignalChangedCallback{
+
+ public WiFiTile(Context context, LayoutInflater inflater,
+ QuickSettingsContainerView container, QuickSettingsController qsc) {
+ super(context, inflater, container, qsc);
+ onClick = new View.OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ WifiManager wfm = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
+ wfm.setWifiEnabled(!wfm.isWifiEnabled());
+ }
+ };
+ onLongClick = new OnLongClickListener() {
+
+ @Override
+ public boolean onLongClick(View v) {
+ startSettingsActivity(android.provider.Settings.ACTION_WIFI_SETTINGS);
+ return true;
+ }
+ };
+ }
+
+ @Override
+ void onPostCreate() {
+ NetworkController controller = new NetworkController(mContext);
+ controller.addNetworkSignalChangedCallback(this);
+ super.onPostCreate();
+ }
+
+ @Override
+ public void onWifiSignalChanged(boolean enabled, int wifiSignalIconId,
+ String wifitSignalContentDescriptionId, String description) {
+ boolean wifiConnected = enabled && (wifiSignalIconId > 0) && (description != null);
+ boolean wifiNotConnected = (wifiSignalIconId > 0) && (description == null);
+ if (wifiConnected) {
+ mDrawable = wifiSignalIconId;
+ mLabel = description.substring(1, description.length()-1);
+ } else if (wifiNotConnected) {
+ mDrawable = R.drawable.ic_qs_wifi_0;
+ mLabel = mContext.getString(R.string.quick_settings_wifi_label);
+ } else {
+ mDrawable = R.drawable.ic_qs_wifi_no_network;
+ mLabel = mContext.getString(R.string.quick_settings_wifi_off_label);
+ }
+ updateQuickSettings();
+ }
+
+ @Override
+ public void onMobileDataSignalChanged(boolean enabled,
+ int mobileSignalIconId, String mobileSignalContentDescriptionId,
+ int dataTypeIconId, String dataTypeContentDescriptionId,
+ String description) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void onAirplaneModeChanged(boolean enabled) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
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 125e070..74b0cf8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -16,6 +16,10 @@
package com.android.systemui.statusbar.phone;
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
@@ -73,16 +77,12 @@ import android.view.animation.AnimationUtils;
import android.view.animation.DecelerateInterpolator;
import android.widget.FrameLayout;
import android.widget.ImageView;
-import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import com.android.internal.statusbar.StatusBarIcon;
import com.android.internal.statusbar.StatusBarNotification;
-
-import com.android.systemui.statusbar.powerwidget.PowerWidget;
-
import com.android.systemui.R;
import com.android.systemui.statusbar.BaseStatusBar;
import com.android.systemui.statusbar.CommandQueue;
@@ -100,10 +100,7 @@ import com.android.systemui.statusbar.policy.NetworkController;
import com.android.systemui.statusbar.policy.NotificationRowLayout;
import com.android.systemui.statusbar.policy.OnSizeChangedListener;
import com.android.systemui.statusbar.policy.Prefs;
-
-import java.io.FileDescriptor;
-import java.io.PrintWriter;
-import java.util.ArrayList;
+import com.android.systemui.statusbar.powerwidget.PowerWidget;
public class PhoneStatusBar extends BaseStatusBar {
static final String TAG = "PhoneStatusBar";
@@ -149,7 +146,7 @@ public class PhoneStatusBar extends BaseStatusBar {
private float mExpandAccelPx; // classic value: 2000px/s/s
private float mCollapseAccelPx; // classic value: 2000px/s/s (will be negated to collapse "up")
- private float mFlingGestureMaxOutputVelocityPx; // how fast can it really go? (should be a little
+ private float mFlingGestureMaxOutputVelocityPx; // how fast can it really go? (should be a little
// faster than mSelfCollapseVelocityPx)
PhoneStatusBarPolicy mIconPolicy;
@@ -176,11 +173,11 @@ public class PhoneStatusBar extends BaseStatusBar {
// viewgroup containing the normal contents of the statusbar
LinearLayout mStatusBarContents;
-
+
// right-hand icons
LinearLayout mSystemIconArea;
-
- // left-hand icons
+
+ // left-hand icons
LinearLayout mStatusIcons;
// the icons themselves
IconMerger mNotificationIcons;
@@ -198,7 +195,7 @@ public class PhoneStatusBar extends BaseStatusBar {
TextView mNotificationPanelDebugText;
// settings
- QuickSettings mQS;
+ QuickSettingsController mQS;
boolean mHasSettingsPanel, mHasFlipSettings;
SettingsPanelView mSettingsPanel;
View mFlipSettingsView;
@@ -207,7 +204,7 @@ public class PhoneStatusBar extends BaseStatusBar {
// top bar
View mNotificationPanelHeader;
- View mDateTimeView;
+ View mDateTimeView;
View mClearButton;
ImageView mSettingsButton, mNotificationButton;
@@ -292,7 +289,7 @@ public class PhoneStatusBar extends BaseStatusBar {
// XXX: gesture research
private final GestureRecorder mGestureRec = DEBUG_GESTURES
- ? new GestureRecorder("/sdcard/statusbar_gestures.dat")
+ ? new GestureRecorder("/sdcard/statusbar_gestures.dat")
: null;
private int mNavigationIconHints = 0;
@@ -309,7 +306,7 @@ public class PhoneStatusBar extends BaseStatusBar {
// ensure quick settings is disabled until the current user makes it through the setup wizard
private boolean mUserSetup = false;
- private ContentObserver mUserSetupObserver = new ContentObserver(new Handler()) {
+ private final ContentObserver mUserSetupObserver = new ContentObserver(new Handler()) {
@Override
public void onChange(boolean selfChange) {
final boolean userSetup = 0 != Settings.Secure.getIntForUser(
@@ -386,7 +383,7 @@ public class PhoneStatusBar extends BaseStatusBar {
mStatusBarView = (PhoneStatusBarView) mStatusBarWindow.findViewById(R.id.status_bar);
mStatusBarView.setBar(this);
-
+
PanelHolder holder = (PanelHolder) mStatusBarWindow.findViewById(R.id.panel_holder);
mStatusBarView.setPanelHolder(holder);
@@ -515,6 +512,7 @@ public class PhoneStatusBar extends BaseStatusBar {
// Load the Power widget views and set the listeners
mPowerWidget = (PowerWidget)mStatusBarWindow.findViewById(R.id.exp_power_stat);
mPowerWidget.setGlobalButtonOnClickListener(new View.OnClickListener() {
+ @Override
public void onClick(View v) {
if(Settings.System.getInt(mContext.getContentResolver(),
Settings.System.EXPANDED_HIDE_ONCHANGE, 0) == 1) {
@@ -523,6 +521,7 @@ public class PhoneStatusBar extends BaseStatusBar {
}
});
mPowerWidget.setGlobalButtonOnLongClickListener(new View.OnLongClickListener() {
+ @Override
public boolean onLongClick(View v) {
animateCollapsePanels();
return true;
@@ -556,6 +555,7 @@ public class PhoneStatusBar extends BaseStatusBar {
if (mEmergencyCallLabel != null) {
mNetworkController.addEmergencyLabelView(mEmergencyCallLabel);
mEmergencyCallLabel.setOnClickListener(new View.OnClickListener() {
+ @Override
public void onClick(View v) { }});
mEmergencyCallLabel.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
@@ -621,7 +621,7 @@ public class PhoneStatusBar extends BaseStatusBar {
mSettingsContainer = (QuickSettingsContainerView)
mStatusBarWindow.findViewById(R.id.quick_settings_container);
if (mSettingsContainer != null) {
- mQS = new QuickSettings(mContext, mSettingsContainer);
+ mQS = new QuickSettingsController(mContext, mSettingsContainer, this);
if (!mNotificationPanelIsFullScreenWidth) {
mSettingsContainer.setSystemUiVisibility(
View.STATUS_BAR_DISABLE_NOTIFICATION_TICKER
@@ -632,14 +632,13 @@ public class PhoneStatusBar extends BaseStatusBar {
}
mQS.setService(this);
mQS.setBar(mStatusBarView);
- mQS.setup(mNetworkController, mBluetoothController, mBatteryController,
- mLocationController);
+ mQS.setupQuickSettings();
} else {
mQS = null; // fly away, be free
}
}
- mClingShown = ! (DEBUG_CLINGS
+ mClingShown = ! (DEBUG_CLINGS
|| !Prefs.read(mContext).getBoolean(Prefs.SHOWN_QUICK_SETTINGS_HELP, false));
if (!ENABLE_NOTIFICATION_PANEL_CLING || ActivityManager.isRunningInTestHarness()) {
@@ -769,14 +768,16 @@ public class PhoneStatusBar extends BaseStatusBar {
return mNaturalBarHeight;
}
- private View.OnClickListener mRecentsClickListener = new View.OnClickListener() {
+ private final View.OnClickListener mRecentsClickListener = new View.OnClickListener() {
+ @Override
public void onClick(View v) {
toggleRecentApps();
}
};
private int mShowSearchHoldoff = 0;
- private Runnable mShowSearchPanel = new Runnable() {
+ private final Runnable mShowSearchPanel = new Runnable() {
+ @Override
public void run() {
showSearchPanel();
awakenDreams();
@@ -784,6 +785,7 @@ public class PhoneStatusBar extends BaseStatusBar {
};
View.OnTouchListener mHomeSearchActionListener = new View.OnTouchListener() {
+ @Override
public boolean onTouch(View v, MotionEvent event) {
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
@@ -894,6 +896,7 @@ public class PhoneStatusBar extends BaseStatusBar {
mWindowManager.addView(mIntruderAlertView, lp);
}
+ @Override
public void addIcon(String slot, int index, int viewIndex, StatusBarIcon icon) {
if (SPEW) Slog.d(TAG, "addIcon slot=" + slot + " index=" + index + " viewIndex=" + viewIndex
+ " icon=" + icon);
@@ -903,6 +906,7 @@ public class PhoneStatusBar extends BaseStatusBar {
mPowerWidget.updateAllButtons();
}
+ @Override
public void updateIcon(String slot, int index, int viewIndex,
StatusBarIcon old, StatusBarIcon icon) {
if (SPEW) Slog.d(TAG, "updateIcon slot=" + slot + " index=" + index + " viewIndex=" + viewIndex
@@ -911,11 +915,13 @@ public class PhoneStatusBar extends BaseStatusBar {
view.set(icon);
}
+ @Override
public void removeIcon(String slot, int index, int viewIndex) {
if (SPEW) Slog.d(TAG, "removeIcon slot=" + slot + " index=" + index + " viewIndex=" + viewIndex);
mStatusIcons.removeViewAt(viewIndex);
}
+ @Override
public void addNotification(IBinder key, StatusBarNotification notification) {
if (DEBUG) Slog.d(TAG, "addNotification score=" + notification.score);
StatusBarIconView iconView = addNotificationViews(key, notification);
@@ -991,6 +997,7 @@ public class PhoneStatusBar extends BaseStatusBar {
updateExpandedViewPos(EXPANDED_LEAVE_ALONE);
}
+ @Override
public void removeNotification(IBinder key) {
StatusBarNotification old = removeNotificationViews(key);
if (SPEW) Slog.d(TAG, "removeNotification key=" + key + " old=" + old);
@@ -1108,7 +1115,7 @@ public class PhoneStatusBar extends BaseStatusBar {
protected void updateCarrierLabelVisibility(boolean force) {
if (!mShowCarrierInPanel) return;
- // The idea here is to only show the carrier label when there is enough room to see it,
+ // The idea here is to only show the carrier label when there is enough room to see it,
// i.e. when there aren't enough notifications to fill the panel.
if (DEBUG) {
Slog.d(TAG, String.format("pileh=%d scrollh=%d carrierh=%d",
@@ -1120,7 +1127,7 @@ public class PhoneStatusBar extends BaseStatusBar {
!(emergencyCallsShownElsewhere && mNetworkController.isEmergencyOnly())
&& mPile.getHeight() < (mNotificationPanel.getHeight() - mCarrierLabelHeight - mNotificationHeaderHeight)
&& mScrollView.getVisibility() == View.VISIBLE;
-
+
if (force || mCarrierLabelVisible != makeVisible) {
mCarrierLabelVisible = makeVisible;
if (DEBUG) {
@@ -1159,8 +1166,8 @@ public class PhoneStatusBar extends BaseStatusBar {
+ " any=" + any + " clearable=" + clearable);
}
- if (mHasFlipSettings
- && mFlipSettingsView != null
+ if (mHasFlipSettings
+ && mFlipSettingsView != null
&& mFlipSettingsView.getVisibility() == View.VISIBLE
&& mScrollView.getVisibility() != View.VISIBLE) {
// the flip settings panel is unequivocally showing; we should not be shown
@@ -1229,6 +1236,7 @@ public class PhoneStatusBar extends BaseStatusBar {
/**
* State is one or more of the DISABLE constants from StatusBarManager.
*/
+ @Override
public void disable(int state) {
final int old = mDisabled;
final int diff = state ^ old;
@@ -1349,6 +1357,7 @@ public class PhoneStatusBar extends BaseStatusBar {
* All changes to the status bar and notifications funnel through here and are batched.
*/
private class H extends BaseStatusBar.H {
+ @Override
public void handleMessage(Message m) {
super.handleMessage(m);
switch (m.what) {
@@ -1377,6 +1386,7 @@ public class PhoneStatusBar extends BaseStatusBar {
}
View.OnFocusChangeListener mFocusChangeListener = new View.OnFocusChangeListener() {
+ @Override
public void onFocusChange(View v, boolean hasFocus) {
// Because 'v' is a ViewGroup, all its children will be (un)selected
// too, which allows marqueeing to work.
@@ -1420,6 +1430,7 @@ public class PhoneStatusBar extends BaseStatusBar {
animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE);
}
+ @Override
public void animateCollapsePanels(int flags) {
if (SPEW) {
Slog.d(TAG, "animateCollapse():"
@@ -1477,7 +1488,7 @@ public class PhoneStatusBar extends BaseStatusBar {
a.setStartDelay(d);
return a;
}
-
+
public Animator start(Animator a) {
a.start();
return a;
@@ -1544,6 +1555,7 @@ public class PhoneStatusBar extends BaseStatusBar {
mClearButton.setAlpha(0f);
setAreThereNotifications(); // this will show/hide the button as necessary
mNotificationPanel.postDelayed(new Runnable() {
+ @Override
public void run() {
updateCarrierLabelVisibility(false);
}
@@ -1601,7 +1613,7 @@ public class PhoneStatusBar extends BaseStatusBar {
interpolator(mAccelerateInterpolator,
ObjectAnimator.ofFloat(mScrollView, View.SCALE_X, 1f, 0f)
)
- .setDuration(FLIP_DURATION_OUT),
+ .setDuration(FLIP_DURATION_OUT),
mScrollView, View.INVISIBLE));
mSettingsButtonAnim = start(
setVisibilityWhenDone(
@@ -1619,6 +1631,7 @@ public class PhoneStatusBar extends BaseStatusBar {
.setDuration(FLIP_DURATION),
mClearButton, View.INVISIBLE));
mNotificationPanel.postDelayed(new Runnable() {
+ @Override
public void run() {
updateCarrierLabelVisibility(false);
}
@@ -1640,7 +1653,8 @@ public class PhoneStatusBar extends BaseStatusBar {
}
void makeExpandedInvisibleSoon() {
- mHandler.postDelayed(new Runnable() { public void run() { makeExpandedInvisible(); }}, 50);
+ mHandler.postDelayed(new Runnable() { @Override
+ public void run() { makeExpandedInvisible(); }}, 50);
}
void makeExpandedInvisible() {
@@ -1701,13 +1715,13 @@ public class PhoneStatusBar extends BaseStatusBar {
/**
* Enables or disables layers on the children of the notifications pile.
- *
+ *
* When layers are enabled, this method attempts to enable layers for the minimal
* number of children. Only children visible when the notification area is fully
* expanded will receive a layer. The technique used in this method might cause
* more children than necessary to get a layer (at most one extra child with the
* current UI.)
- *
+ *
* @param layerType {@link View#LAYER_TYPE_NONE} or {@link View#LAYER_TYPE_HARDWARE}
*/
private void setPileLayers(int layerType) {
@@ -1720,7 +1734,7 @@ public class PhoneStatusBar extends BaseStatusBar {
}
break;
case View.LAYER_TYPE_HARDWARE:
- final int[] location = new int[2];
+ final int[] location = new int[2];
mNotificationPanel.getLocationInWindow(location);
final int left = location[0];
@@ -1822,9 +1836,9 @@ public class PhoneStatusBar extends BaseStatusBar {
// Cling (first-run help) handling.
// The cling is supposed to show the first time you drag, or even tap, the status bar.
- // It should show the notification panel, then fade in after half a second, giving you
+ // It should show the notification panel, then fade in after half a second, giving you
// an explanation of what just happened, as well as teach you how to access quick
- // settings (another drag). The user can dismiss the cling by clicking OK or by
+ // settings (another drag). The user can dismiss the cling by clicking OK or by
// dragging quick settings into view.
final int act = event.getActionMasked();
if (mSuppressStatusBarDrags) {
@@ -1943,6 +1957,7 @@ public class PhoneStatusBar extends BaseStatusBar {
}
}
+ @Override
public void topAppWindowChanged(boolean showMenu) {
if (DEBUG) {
Slog.d(TAG, (showMenu?"showing":"hiding") + " the MENU button");
@@ -2015,6 +2030,7 @@ public class PhoneStatusBar extends BaseStatusBar {
mTickingDoneListener));
}
+ @Override
public void tickerHalting() {
mStatusBarContents.setVisibility(View.VISIBLE);
mTickerView.setVisibility(View.GONE);
@@ -2024,11 +2040,14 @@ public class PhoneStatusBar extends BaseStatusBar {
}
Animation.AnimationListener mTickingDoneListener = new Animation.AnimationListener() {;
+ @Override
public void onAnimationEnd(Animation animation) {
mTicking = false;
}
+ @Override
public void onAnimationRepeat(Animation animation) {
}
+ @Override
public void onAnimationStart(Animation animation) {
}
};
@@ -2046,6 +2065,7 @@ public class PhoneStatusBar extends BaseStatusBar {
+ ") " + v.getWidth() + "x" + v.getHeight() + "]";
}
+ @Override
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
synchronized (mQueueLock) {
pw.println("Current Status Bar state:");
@@ -2053,9 +2073,9 @@ public class PhoneStatusBar extends BaseStatusBar {
+ ", mTrackingPosition=" + mTrackingPosition);
pw.println(" mTicking=" + mTicking);
pw.println(" mTracking=" + mTracking);
- pw.println(" mNotificationPanel=" +
- ((mNotificationPanel == null)
- ? "null"
+ pw.println(" mNotificationPanel=" +
+ ((mNotificationPanel == null)
+ ? "null"
: (mNotificationPanel + " params=" + mNotificationPanel.getLayoutParams().debug(""))));
pw.println(" mAnimating=" + mAnimating
+ ", mAnimY=" + mAnimY + ", mAnimVel=" + mAnimVel
@@ -2102,6 +2122,7 @@ public class PhoneStatusBar extends BaseStatusBar {
pw.println("see the logcat for a dump of the views we have created.");
// must happen on ui thread
mHandler.post(new Runnable() {
+ @Override
public void run() {
mStatusBarView.getLocationOnScreen(mAbsPos);
Slog.d(TAG, "mStatusBarView: ----- (" + mAbsPos[0] + "," + mAbsPos[1]
@@ -2201,12 +2222,13 @@ public class PhoneStatusBar extends BaseStatusBar {
void updateDisplaySize() {
mDisplay.getMetrics(mDisplayMetrics);
if (DEBUG_GESTURES) {
- mGestureRec.tag("display",
+ mGestureRec.tag("display",
String.format("%dx%d", mDisplayMetrics.widthPixels, mDisplayMetrics.heightPixels));
}
}
- private View.OnClickListener mClearButtonListener = new View.OnClickListener() {
+ private final View.OnClickListener mClearButtonListener = new View.OnClickListener() {
+ @Override
public void onClick(View v) {
synchronized (mNotificationData) {
// animate-swipe all dismissable notifications, then animate the shade closed
@@ -2295,7 +2317,8 @@ public class PhoneStatusBar extends BaseStatusBar {
animateCollapsePanels();
}
- private View.OnClickListener mSettingsButtonListener = new View.OnClickListener() {
+ private final View.OnClickListener mSettingsButtonListener = new View.OnClickListener() {
+ @Override
public void onClick(View v) {
if (mHasSettingsPanel) {
animateExpandSettingsPanel();
@@ -2306,20 +2329,23 @@ public class PhoneStatusBar extends BaseStatusBar {
}
};
- private View.OnClickListener mClockClickListener = new View.OnClickListener() {
+ private final View.OnClickListener mClockClickListener = new View.OnClickListener() {
+ @Override
public void onClick(View v) {
startActivityDismissingKeyguard(
new Intent(Intent.ACTION_QUICK_CLOCK), true); // have fun, everyone
}
};
- private View.OnClickListener mNotificationButtonListener = new View.OnClickListener() {
+ private final View.OnClickListener mNotificationButtonListener = new View.OnClickListener() {
+ @Override
public void onClick(View v) {
animateExpandNotificationsPanel();
}
};
- private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
+ private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
+ @Override
public void onReceive(Context context, Intent intent) {
if (DEBUG) Slog.v(TAG, "onReceive: " + intent);
String action = intent.getAction();
@@ -2382,6 +2408,7 @@ public class PhoneStatusBar extends BaseStatusBar {
mIntruderAlertView.setVisibility(vis ? View.VISIBLE : View.GONE);
}
+ @Override
public void dismissIntruder() {
if (mCurrentlyIntrudingNotification == null) return;
@@ -2553,6 +2580,7 @@ public class PhoneStatusBar extends BaseStatusBar {
}
Runnable mStartTracing = new Runnable() {
+ @Override
public void run() {
vibrate();
SystemClock.sleep(250);
@@ -2563,6 +2591,7 @@ public class PhoneStatusBar extends BaseStatusBar {
};
Runnable mStopTracing = new Runnable() {
+ @Override
public void run() {
android.os.Debug.stopMethodTracing();
Slog.d(TAG, "stopTracing");
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 51df316..4fb732a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java
@@ -747,6 +747,7 @@ class QuickSettings {
}
private Runnable mDismissBrightnessDialogRunnable = new Runnable() {
+ @Override
public void run() {
if (mBrightnessDialog != null && mBrightnessDialog.isShowing()) {
mBrightnessDialog.dismiss();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsContainerView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsContainerView.java
index 4e8339e..2a8608e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsContainerView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsContainerView.java
@@ -29,7 +29,7 @@ import com.android.systemui.R;
/**
*
*/
-class QuickSettingsContainerView extends FrameLayout {
+public class QuickSettingsContainerView extends FrameLayout {
// The number of columns in the QuickSettings grid
private int mNumColumns;
@@ -108,11 +108,11 @@ class QuickSettingsContainerView extends FrameLayout {
int cursor = 0;
for (int i = 0; i < N; ++i) {
QuickSettingsTileView v = (QuickSettingsTileView) getChildAt(i);
- ViewGroup.LayoutParams lp = (ViewGroup.LayoutParams) v.getLayoutParams();
+ ViewGroup.LayoutParams lp = v.getLayoutParams();
if (v.getVisibility() != GONE) {
int col = cursor % mNumColumns;
int colSpan = v.getColumnSpan();
- int row = (int) (cursor / mNumColumns);
+ int row = cursor / mNumColumns;
// Push the item to the next row if it can't fit on this one
if ((col + colSpan) > mNumColumns) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsController.java
new file mode 100644
index 0000000..e629367
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsController.java
@@ -0,0 +1,205 @@
+package com.android.systemui.statusbar.phone;
+
+import java.util.ArrayList;
+
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.os.Handler;
+import android.view.LayoutInflater;
+import android.view.ViewGroup;
+
+import com.android.systemui.quicksettings.AirplaneModeTile;
+import com.android.systemui.quicksettings.AlarmTile;
+import com.android.systemui.quicksettings.AutoRotateTile;
+import com.android.systemui.quicksettings.BatteryTile;
+import com.android.systemui.quicksettings.BluetoothTile;
+import com.android.systemui.quicksettings.BrightnessTile;
+import com.android.systemui.quicksettings.BugReportTile;
+import com.android.systemui.quicksettings.GPSTile;
+import com.android.systemui.quicksettings.InputMethodTile;
+import com.android.systemui.quicksettings.MobileNetworkTile;
+import com.android.systemui.quicksettings.MobileNetworkTypeTile;
+import com.android.systemui.quicksettings.PreferencesTile;
+import com.android.systemui.quicksettings.QuickSettingsTile;
+import com.android.systemui.quicksettings.RingerModeTile;
+import com.android.systemui.quicksettings.RingerVibrationModeTile;
+import com.android.systemui.quicksettings.SleepScreenTile;
+import com.android.systemui.quicksettings.ToggleLockscreenTile;
+import com.android.systemui.quicksettings.UserTile;
+import com.android.systemui.quicksettings.VibrationModeTile;
+import com.android.systemui.quicksettings.WiFiDisplayTile;
+import com.android.systemui.quicksettings.WiFiTile;
+
+public class QuickSettingsController {
+
+ private final Context mContext;
+ public PanelBar mBar;
+ private final ViewGroup mContainerView;
+ private final Handler mHandler;
+ private final ArrayList<Integer> quicksettings;
+ public PhoneStatusBar mStatusBarService;
+
+ // Constants
+
+ public static final int WIFI_TILE = 0;
+ public static final int MOBILE_NETWORK_TILE = 1;
+ public static final int AIRPLANE_MODE_TILE = 2;
+ public static final int BLUETOOTH_TILE = 3;
+ public static final int SOUND_TILE = 4;
+ public static final int VIBRATION_TILE = 5;
+ public static final int SOUND_VIBRATION_TILE = 6;
+ public static final int SLEEP_TILE = 7;
+ public static final int TOGGLE_LOCKSCREEN_TILE = 8;
+ public static final int GPS_TILE = 9;
+ public static final int AUTO_ROTATION_TILE = 10;
+ public static final int BRIGHTNESS_TILE = 11;
+ public static final int MOBILE_NETWORK_TYPE_TILE = 12;
+ public static final int PREFERENCES_TILE = 13;
+ public static final int BATTERY_TILE = 14;
+ public static final int IME_TILE = 15;
+
+ public static final int ALARM_TILE = 16;
+ public static final int BUG_REPORT_TILE = 17;
+ public static final int WIFI_DISPLAY_TILE = 18;
+
+ public static final int USER_TILE = 99;
+
+ private InputMethodTile IMETile;
+
+ public QuickSettingsController(Context context, QuickSettingsContainerView container, PhoneStatusBar statusBarService) {
+ mContext = context;
+ mContainerView = container;
+ mHandler = new Handler();
+ quicksettings = new ArrayList<Integer>();
+ quicksettings.add(USER_TILE);
+ quicksettings.add(BRIGHTNESS_TILE);
+ quicksettings.add(SOUND_VIBRATION_TILE);
+ quicksettings.add(WIFI_TILE);
+ if(deviceSupportsTelephony()) {
+ quicksettings.add(MOBILE_NETWORK_TILE);
+ }
+ quicksettings.add(BLUETOOTH_TILE);
+ quicksettings.add(BATTERY_TILE);
+ quicksettings.add(AIRPLANE_MODE_TILE);
+ quicksettings.add(PREFERENCES_TILE);
+ quicksettings.add(AUTO_ROTATION_TILE);
+ quicksettings.add(SLEEP_TILE);
+ /*
+ * These toggles are disabled but functional
+ * quicksettings.add(SOUND_TILE);
+ * quicksettings.add(VIBRATION_TILE);
+ */
+ quicksettings.add(GPS_TILE);
+ quicksettings.add(TOGGLE_LOCKSCREEN_TILE);
+
+ // This toggle is still not working:
+ // quicksettings.add(MOBILE_NETWORK_TYPE_TILE);
+
+ // Temporary tiles. These toggles must be the last ones added to the view, as they will show only when they are needed
+ quicksettings.add(ALARM_TILE);
+ quicksettings.add(BUG_REPORT_TILE);
+ quicksettings.add(WIFI_DISPLAY_TILE);
+ quicksettings.add(IME_TILE);
+ mStatusBarService = statusBarService;
+ }
+
+ void setupQuickSettings(){
+ LayoutInflater inflater = LayoutInflater.from(mContext);
+ addQuickSettings(inflater);
+ }
+
+ boolean deviceSupportsTelephony() {
+ PackageManager pm = mContext.getPackageManager();
+ return pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY);
+ }
+
+ void setBar(PanelBar bar) {
+ mBar = bar;
+ }
+
+ void addQuickSettings(LayoutInflater inflater){
+ for(Integer entry: quicksettings){
+ QuickSettingsTile qs = null;
+ switch(entry){
+ case WIFI_TILE:
+ qs = new WiFiTile(mContext, inflater, (QuickSettingsContainerView) mContainerView, this);
+ break;
+ case MOBILE_NETWORK_TILE:
+ qs = new MobileNetworkTile(mContext, inflater, (QuickSettingsContainerView) mContainerView, this);
+ break;
+ case AIRPLANE_MODE_TILE:
+ qs = new AirplaneModeTile(mContext, inflater, (QuickSettingsContainerView) mContainerView, this);
+ break;
+ case BLUETOOTH_TILE:
+ qs = new BluetoothTile(mContext, inflater, (QuickSettingsContainerView) mContainerView, this);
+ break;
+ case SOUND_TILE:
+ qs = new RingerModeTile(mContext, inflater, (QuickSettingsContainerView) mContainerView, this);
+ break;
+ case VIBRATION_TILE:
+ qs = new VibrationModeTile(mContext, inflater, (QuickSettingsContainerView) mContainerView, this);
+ break;
+ case SOUND_VIBRATION_TILE:
+ qs = new RingerVibrationModeTile(mContext, inflater, (QuickSettingsContainerView) mContainerView, this);
+ break;
+ case SLEEP_TILE:
+ qs = new SleepScreenTile(mContext, inflater, (QuickSettingsContainerView) mContainerView, this);
+ break;
+ case TOGGLE_LOCKSCREEN_TILE:
+ qs = new ToggleLockscreenTile(mContext, inflater, (QuickSettingsContainerView) mContainerView, this);
+ break;
+ case GPS_TILE:
+ qs = new GPSTile(mContext, inflater, (QuickSettingsContainerView) mContainerView, this);
+ break;
+ case AUTO_ROTATION_TILE:
+ qs = new AutoRotateTile(mContext, inflater, (QuickSettingsContainerView) mContainerView, this, mHandler);
+ break;
+ case BRIGHTNESS_TILE:
+ qs = new BrightnessTile(mContext, inflater, (QuickSettingsContainerView) mContainerView, this, mHandler);
+ break;
+ case MOBILE_NETWORK_TYPE_TILE:
+ qs = new MobileNetworkTypeTile(mContext, inflater, (QuickSettingsContainerView) mContainerView, this);
+ break;
+ case ALARM_TILE:
+ qs = new AlarmTile(mContext, inflater, (QuickSettingsContainerView) mContainerView, this, mHandler);
+ break;
+ case BUG_REPORT_TILE:
+ qs = new BugReportTile(mContext, inflater, (QuickSettingsContainerView) mContainerView, this, mHandler);
+ break;
+ case WIFI_DISPLAY_TILE:
+ qs = new WiFiDisplayTile(mContext, inflater, (QuickSettingsContainerView) mContainerView, this);
+ break;
+ case PREFERENCES_TILE:
+ qs = new PreferencesTile(mContext, inflater, (QuickSettingsContainerView) mContainerView, this);
+ break;
+ case BATTERY_TILE:
+ qs = new BatteryTile(mContext, inflater, (QuickSettingsContainerView) mContainerView, this);
+ break;
+ case IME_TILE:
+ IMETile = new InputMethodTile(mContext, inflater, (QuickSettingsContainerView) mContainerView, this);
+ qs = IMETile;
+ break;
+ case USER_TILE:
+ qs = new UserTile(mContext, inflater, (QuickSettingsContainerView) mContainerView, this);
+ break;
+ }
+ if(qs != null){
+ qs.setupQuickSettingsTile();
+ }
+ }
+ }
+
+ public void setService(PhoneStatusBar phoneStatusBar) {
+ mStatusBarService = phoneStatusBar;
+ }
+
+ public void setImeWindowStatus(boolean visible){
+ IMETile.toggleVisibility(visible);
+ }
+
+ public void updateResources() {
+ // TODO Auto-generated method stub
+
+ }
+
+}
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 4513dcb..4db5019 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java
@@ -16,7 +16,8 @@
package com.android.systemui.statusbar.phone;
-import android.app.ActivityManager;
+import java.util.List;
+
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothAdapter.BluetoothStateChangeCallback;
import android.content.BroadcastReceiver;
@@ -30,7 +31,6 @@ import android.database.ContentObserver;
import android.graphics.drawable.Drawable;
import android.hardware.display.WifiDisplayStatus;
import android.os.Handler;
-import android.os.UserHandle;
import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
import android.text.TextUtils;
@@ -47,8 +47,6 @@ import com.android.systemui.statusbar.policy.CurrentUserTracker;
import com.android.systemui.statusbar.policy.LocationController.LocationGpsStateChangeCallback;
import com.android.systemui.statusbar.policy.NetworkController.NetworkSignalChangedCallback;
-import java.util.List;
-
class QuickSettingsModel implements BluetoothStateChangeCallback,
NetworkSignalChangedCallback,
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsTileView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsTileView.java
index 8f5cde6..65c5ae4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsTileView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsTileView.java
@@ -24,10 +24,10 @@ import android.widget.FrameLayout;
/**
*
*/
-class QuickSettingsTileView extends FrameLayout {
+public class QuickSettingsTileView extends FrameLayout {
private int mColSpan;
- private int mRowSpan;
+ private final int mRowSpan;
private int mCellWidth;
public QuickSettingsTileView(Context context, AttributeSet attrs) {
@@ -45,7 +45,7 @@ class QuickSettingsTileView extends FrameLayout {
return mColSpan;
}
- void setContent(int layoutId, LayoutInflater inflater) {
+ public void setContent(int layoutId, LayoutInflater inflater) {
inflater.inflate(layoutId, this);
}
} \ No newline at end of file
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/SettingsPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/SettingsPanelView.java
index a58eb22..e240937 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/SettingsPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/SettingsPanelView.java
@@ -16,19 +16,14 @@
package com.android.systemui.statusbar.phone;
-import android.animation.LayoutTransition;
import android.content.Context;
-import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
-import android.view.LayoutInflater;
import android.view.View;
-import android.view.ViewGroup;
import com.android.systemui.R;
-import com.android.systemui.statusbar.BaseStatusBar;
import com.android.systemui.statusbar.GestureRecorder;
import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.statusbar.policy.BluetoothController;
@@ -37,7 +32,7 @@ import com.android.systemui.statusbar.policy.NetworkController;
public class SettingsPanelView extends PanelView {
- private QuickSettings mQS;
+ private QuickSettingsController mQS;
private QuickSettingsContainerView mQSContainer;
Drawable mHandleBar;
@@ -61,8 +56,8 @@ public class SettingsPanelView extends PanelView {
setContentDescription(resources.getString(R.string.accessibility_desc_quick_settings));
}
-
- public void setQuickSettings(QuickSettings qs) {
+
+ public void setQuickSettings(QuickSettingsController qs) {
mQS = qs;
}
@@ -84,8 +79,7 @@ public class SettingsPanelView extends PanelView {
public void setup(NetworkController networkController, BluetoothController bluetoothController,
BatteryController batteryController, LocationController locationController) {
if (mQS != null) {
- mQS.setup(networkController, bluetoothController, batteryController,
- locationController);
+ mQS.setupQuickSettings();
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/powerwidget/LockScreenButton.java b/packages/SystemUI/src/com/android/systemui/statusbar/powerwidget/LockScreenButton.java
index 0a1959f..2c7a8f3 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/powerwidget/LockScreenButton.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/powerwidget/LockScreenButton.java
@@ -1,7 +1,5 @@
package com.android.systemui.statusbar.powerwidget;
-import com.android.systemui.R;
-
import android.app.KeyguardManager;
import android.app.KeyguardManager.KeyguardLock;
import android.content.Context;
@@ -9,6 +7,8 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.view.View;
+import com.android.systemui.R;
+
public class LockScreenButton extends PowerButton {
private static final String KEY_DISABLED = "lockscreen_disabled";
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/powerwidget/SleepButton.java b/packages/SystemUI/src/com/android/systemui/statusbar/powerwidget/SleepButton.java
index 65f3963..e137de5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/powerwidget/SleepButton.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/powerwidget/SleepButton.java
@@ -1,14 +1,12 @@
package com.android.systemui.statusbar.powerwidget;
-import com.android.systemui.R;
-
-import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
-import android.provider.Settings;
import android.os.PowerManager;
import android.os.SystemClock;
+import com.android.systemui.R;
+
public class SleepButton extends PowerButton {
public SleepButton() { mType = BUTTON_SLEEP; }
@@ -22,7 +20,7 @@ public class SleepButton extends PowerButton {
protected void toggleState(Context context) {
PowerManager pm = (PowerManager)
context.getSystemService(Context.POWER_SERVICE);
- pm.goToSleep(SystemClock.uptimeMillis() + 1);
+ pm.goToSleep(SystemClock.uptimeMillis());
}
@Override