OSDN Git Service

SystemUI: Enable three icon switching within QS DND tile
authorMike xdnax <mikecoconut5832@gmail.com>
Fri, 4 Dec 2015 06:34:49 +0000 (01:34 -0500)
committerSteve Kondik <shade@chemlab.org>
Sat, 8 Oct 2016 12:22:42 +0000 (05:22 -0700)
This expands the QS DND tile to use three states instead of two.

Java commits by @nicholaschum

What this does:
- Removes the two states (true/false) clause {? XXX:YYY;} and uses an
switch(mZen) instead for the two cases and the default. If in the
future, we want to add another tile, just add another case.
- Adds two vector drawables originally by Cataclysm dev @atl4ntis,
modified and reformatted - this allows for themers to theme this
resource as well by adding the two new drawables.

PS1: Uses if/elsif/else clause
PS2: Update to use switch(mZen) clause

Change-Id: If34e225bdc81e944a12ffd764a521de934aca3b3

packages/SystemUI/res/drawable/ic_qs_dnd_on_priority.xml [new file with mode: 0644]
packages/SystemUI/res/drawable/stat_sys_dnd_priority.xml [new file with mode: 0644]
packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java
packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java

diff --git a/packages/SystemUI/res/drawable/ic_qs_dnd_on_priority.xml b/packages/SystemUI/res/drawable/ic_qs_dnd_on_priority.xml
new file mode 100644 (file)
index 0000000..76b0361
--- /dev/null
@@ -0,0 +1,25 @@
+<!--
+    Copyright (C) 2015 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.
+-->
+<vector
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="64dp"
+    android:height="64dp"
+    android:viewportWidth="48"
+    android:viewportHeight="48">
+    <path
+        android:fillColor="#FFFFFFFF"
+        android:pathData="M24,4C12.95,4,4,12.95,4,24s8.95,20,20,20s20-8.95,20-20S35.05,4,24,4z M34,26h-8v8h-4v-8h-8v-4h8v-8h4v8h8V26z" />
+</vector>
diff --git a/packages/SystemUI/res/drawable/stat_sys_dnd_priority.xml b/packages/SystemUI/res/drawable/stat_sys_dnd_priority.xml
new file mode 100644 (file)
index 0000000..34d222d
--- /dev/null
@@ -0,0 +1,28 @@
+<!--
+    Copyright (C) 2015 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.
+-->
+<inset xmlns:android="http://schemas.android.com/apk/res/android"
+    android:insetLeft="2.5dp"
+    android:insetRight="2.5dp">
+    <vector
+            android:width="17dp"
+            android:height="17dp"
+            android:viewportHeight="48"
+            android:viewportWidth="48">
+        <path
+            android:fillColor="#FFFFFFFF"
+            android:pathData="M24,4C12.95,4,4,12.95,4,24s8.95,20,20,20s20-8.95,20-20S35.05,4,24,4z M34,26h-8v8h-4v-8h-8v-4h8v-8h4v8h8V26z" />
+    </vector>
+</inset>
index 04cb553..58c1371 100644 (file)
@@ -142,7 +142,7 @@ public class DndTile extends QSTile<QSTile.BooleanState> {
         checkIfRestrictionEnforcedByAdminOnly(state, UserManager.DISALLOW_ADJUST_VOLUME);
         switch (zen) {
             case Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS:
-                state.icon = ResourceIcon.get(R.drawable.ic_qs_dnd_on);
+                state.icon = ResourceIcon.get(R.drawable.ic_qs_dnd_on_priority);
                 state.label = mContext.getString(R.string.quick_settings_dnd_priority_label);
                 state.contentDescription = mContext.getString(
                         R.string.accessibility_quick_settings_dnd_priority_on);
index 904313c..c5e7201 100755 (executable)
@@ -258,8 +258,17 @@ public class PhoneStatusBarPolicy implements Callback, RotationLockController.Ro
 
         if (DndTile.isVisible(mContext) || DndTile.isCombinedIcon(mContext)) {
             zenVisible = mZen != Global.ZEN_MODE_OFF;
-            zenIconId = mZen == Global.ZEN_MODE_NO_INTERRUPTIONS
-                    ? R.drawable.stat_sys_dnd_total_silence : R.drawable.stat_sys_dnd;
+            switch (mZen) {
+                case Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS:
+                    zenIconId = R.drawable.stat_sys_dnd_priority;
+                    break;
+                case Global.ZEN_MODE_NO_INTERRUPTIONS:
+                    zenIconId = R.drawable.stat_sys_dnd_total_silence;
+                    break;
+                default:
+                    zenIconId = R.drawable.stat_sys_dnd;
+                    break;
+            }
             zenDescription = mContext.getString(R.string.quick_settings_dnd_label);
         } else if (mZen == Global.ZEN_MODE_NO_INTERRUPTIONS) {
             zenVisible = true;