summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanesh Mondegarian <daneshm90@gmail.com>2013-02-02 00:01:50 -0500
committerDanesh Mondegarian <daneshm90@gmail.com>2013-02-07 16:24:26 -0500
commiteeb11165b6e5443be802b475017cb7aca9d6f213 (patch)
treef42e5632c328422a6ae58b9de375e4ed353e6844
parent43f415aa42d7397820afea7e86091cba4b8fc0b2 (diff)
downloadframeworks_base-eeb11165b6e5443be802b475017cb7aca9d6f213.zip
frameworks_base-eeb11165b6e5443be802b475017cb7aca9d6f213.tar.gz
frameworks_base-eeb11165b6e5443be802b475017cb7aca9d6f213.tar.bz2
QuietHours Tile (1/2)
Allows user to toggle state of quiet hours Part 2 : http://review.cyanogenmod.org/#/c/31302/ Patchset 2 : New drawables courtesy of Björn Lundén 3 : Make multiuser compatible Change-Id: I10f7b7befbf7405e47247d90bfee0f30c3ecd7c9
-rw-r--r--packages/SystemUI/res/drawable-hdpi/ic_qs_quiet_hours_off.pngbin0 -> 3257 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/ic_qs_quiet_hours_on.pngbin0 -> 3271 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/ic_qs_quiet_hours_off.pngbin0 -> 3130 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/ic_qs_quiet_hours_on.pngbin0 -> 3141 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/ic_qs_quiet_hours_off.pngbin0 -> 3436 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/ic_qs_quiet_hours_on.pngbin0 -> 3451 bytes
-rw-r--r--packages/SystemUI/res/values/strings.xml1
-rw-r--r--packages/SystemUI/src/com/android/systemui/quicksettings/QuietHoursTile.java60
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsController.java9
9 files changed, 69 insertions, 1 deletions
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_qs_quiet_hours_off.png b/packages/SystemUI/res/drawable-hdpi/ic_qs_quiet_hours_off.png
new file mode 100644
index 0000000..fc97682
--- /dev/null
+++ b/packages/SystemUI/res/drawable-hdpi/ic_qs_quiet_hours_off.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_qs_quiet_hours_on.png b/packages/SystemUI/res/drawable-hdpi/ic_qs_quiet_hours_on.png
new file mode 100644
index 0000000..36a7075
--- /dev/null
+++ b/packages/SystemUI/res/drawable-hdpi/ic_qs_quiet_hours_on.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_qs_quiet_hours_off.png b/packages/SystemUI/res/drawable-mdpi/ic_qs_quiet_hours_off.png
new file mode 100644
index 0000000..fd7b341
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/ic_qs_quiet_hours_off.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_qs_quiet_hours_on.png b/packages/SystemUI/res/drawable-mdpi/ic_qs_quiet_hours_on.png
new file mode 100644
index 0000000..4b702a7
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/ic_qs_quiet_hours_on.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_qs_quiet_hours_off.png b/packages/SystemUI/res/drawable-xhdpi/ic_qs_quiet_hours_off.png
new file mode 100644
index 0000000..fd7c669
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xhdpi/ic_qs_quiet_hours_off.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_qs_quiet_hours_on.png b/packages/SystemUI/res/drawable-xhdpi/ic_qs_quiet_hours_on.png
new file mode 100644
index 0000000..f722db1
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xhdpi/ic_qs_quiet_hours_on.png
Binary files differ
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 290166c..29a2131 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -554,6 +554,7 @@
<string name="quick_settings_usb_tether_on_label">Tethering</string>
<string name="quick_settings_wifiap">Wi-Fi AP</string>
<string name="quick_settings_wifiap_off">Wi-Fi AP off</string>
+ <string name="quick_settings_quiethours">Quiet hours</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">
diff --git a/packages/SystemUI/src/com/android/systemui/quicksettings/QuietHoursTile.java b/packages/SystemUI/src/com/android/systemui/quicksettings/QuietHoursTile.java
new file mode 100644
index 0000000..b00bcb0
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/quicksettings/QuietHoursTile.java
@@ -0,0 +1,60 @@
+package com.android.systemui.quicksettings;
+
+import android.content.ContentResolver;
+import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.UserHandle;
+import android.provider.Settings;
+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 QuietHoursTile extends QuickSettingsTile {
+
+ private boolean mEnabled;
+
+ public QuietHoursTile(Context context, LayoutInflater inflater,
+ QuickSettingsContainerView container, QuickSettingsController qsc) {
+ super(context, inflater, container, qsc);
+ updateTileState();
+ mOnClick = new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Settings.System.putIntForUser(mContext.getContentResolver(), Settings.System.QUIET_HOURS_ENABLED,
+ mEnabled ? 0 : 1, UserHandle.USER_CURRENT);
+ }
+ };
+ mOnLongClick = new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View v) {
+ Intent intent = new Intent(Intent.ACTION_MAIN);
+ intent.setClassName("com.android.settings", "com.android.settings.Settings$QuietHoursSettingsActivity");
+ startSettingsActivity(intent);
+ return true;
+ }
+ };
+ qsc.registerObservedContent(Settings.System.getUriFor(Settings.System.QUIET_HOURS_ENABLED), this);
+ }
+
+ @Override
+ public void onChangeUri(ContentResolver resolver, Uri uri) {
+ updateTileState();
+ updateQuickSettings();
+ }
+
+ private void updateTileState() {
+ mEnabled = Settings.System.getIntForUser(mContext.getContentResolver(),
+ Settings.System.QUIET_HOURS_ENABLED, 0, UserHandle.USER_CURRENT) == 1;
+ mLabel = mContext.getString(R.string.quick_settings_quiethours);
+ if (mEnabled) {
+ mDrawable = R.drawable.ic_qs_quiet_hours_on;
+ } else {
+ mDrawable = R.drawable.ic_qs_quiet_hours_off;
+ }
+ }
+
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsController.java
index 95d0402..8aed0c3 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsController.java
@@ -34,7 +34,6 @@ import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
-import android.view.ViewGroup;
import com.android.systemui.quicksettings.AirplaneModeTile;
import com.android.systemui.quicksettings.AlarmTile;
@@ -44,6 +43,7 @@ import com.android.systemui.quicksettings.BluetoothTile;
import com.android.systemui.quicksettings.BrightnessTile;
import com.android.systemui.quicksettings.BugReportTile;
import com.android.systemui.quicksettings.NfcTile;
+import com.android.systemui.quicksettings.QuietHoursTile;
import com.android.systemui.quicksettings.ScreenTimeoutTile;
import com.android.systemui.quicksettings.TorchTile;
import com.android.systemui.quicksettings.GPSTile;
@@ -103,6 +103,7 @@ public class QuickSettingsController {
public static final String TILE_PROFILE = "toggleProfile";
public static final String TILE_NFC = "toggleNfc";
public static final String TILE_USBTETHER = "toggleUsbTether";
+ public static final String TILE_QUIETHOURS = "toggleQuietHours";
private static final String TILE_DELIMITER = "|";
private static ArrayList<String> TILES_DEFAULT = new ArrayList<String>();
@@ -156,6 +157,7 @@ public class QuickSettingsController {
public static final int NFC_TILE = 21;
public static final int SCREENTIMEOUT_TILE = 22;
public static final int USBTETHER_TILE = 23;
+ public static final int QUIET_HOURS_TILE = 24;
public static final int USER_TILE = 99;
private InputMethodTile IMETile;
@@ -253,6 +255,8 @@ public class QuickSettingsController {
// Not available yet
} else if (tile.equals(TILE_LTE)) {
// Not available yet
+ } else if (tile.equals(TILE_QUIETHOURS)) {
+ mQuickSettings.add(QUIET_HOURS_TILE);
}
}
@@ -463,6 +467,9 @@ public class QuickSettingsController {
case USBTETHER_TILE:
qs = new UsbTetherTile(mContext, inflater, mContainerView, this);
break;
+ case QUIET_HOURS_TILE:
+ qs = new QuietHoursTile(mContext, inflater, mContainerView, this);
+ break;
}
if (qs != null) {
qs.setupQuickSettingsTile();