diff options
author | Jorge Ruesga <jorge@ruesga.com> | 2013-03-18 00:38:17 +0100 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2013-04-03 16:11:33 -0700 |
commit | 8a96d5d16b83a31572e9f891eb6c0a10451d4127 (patch) | |
tree | cfd8eb9c9594ee2e4748a5f6fa68a6baf3f79707 | |
parent | 2e939f9d49bc6855bac2eb650f4cbf55f5bdf477 (diff) | |
download | frameworks_base-8a96d5d16b83a31572e9f891eb6c0a10451d4127.zip frameworks_base-8a96d5d16b83a31572e9f891eb6c0a10451d4127.tar.gz frameworks_base-8a96d5d16b83a31572e9f891eb6c0a10451d4127.tar.bz2 |
QS: Add dock battery tile (1/2)
Add a dinamic tile for devices with dock battery
Patchset 2: New icon set
Rebased
Change-Id: I5e0e84da0b0f248fa9eb568c5d506b00cf3998b0
Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
61 files changed, 287 insertions, 23 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index bfffddd..99252e1 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -2581,6 +2581,13 @@ public final class Settings { * * @hide */ + public static final String QS_DYNAMIC_DOCK_BATTERY = "qs_dyanmic_dock_battery"; + + /** + * Quick Settings Panel Dynamic Tiles + * + * @hide + */ public static final String QS_DYNAMIC_WIFI = "qs_dyanmic_wifi"; /** diff --git a/core/java/com/android/internal/util/cm/QSUtils.java b/core/java/com/android/internal/util/cm/QSUtils.java index 49dc566..ab819b0 100644 --- a/core/java/com/android/internal/util/cm/QSUtils.java +++ b/core/java/com/android/internal/util/cm/QSUtils.java @@ -51,4 +51,9 @@ public class QSUtils { final TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE); return (tm.getLteOnCdmaMode() == PhoneConstants.LTE_ON_CDMA_TRUE) || tm.getLteOnGsmMode() != 0; } + + public static boolean deviceSupportsDockBattery(Context ctx) { + Resources res = ctx.getResources(); + return res.getBoolean(com.android.internal.R.bool.config_hasDockBattery); + } } diff --git a/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_0.png b/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_0.png Binary files differnew file mode 100644 index 0000000..74a8776 --- /dev/null +++ b/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_0.png diff --git a/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_100.png b/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_100.png Binary files differnew file mode 100644 index 0000000..858138c --- /dev/null +++ b/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_100.png diff --git a/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_15.png b/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_15.png Binary files differnew file mode 100644 index 0000000..a0e07cf --- /dev/null +++ b/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_15.png diff --git a/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_28.png b/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_28.png Binary files differnew file mode 100644 index 0000000..30f9107 --- /dev/null +++ b/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_28.png diff --git a/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_43.png b/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_43.png Binary files differnew file mode 100644 index 0000000..a2c5472 --- /dev/null +++ b/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_43.png diff --git a/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_57.png b/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_57.png Binary files differnew file mode 100644 index 0000000..f18e1c5 --- /dev/null +++ b/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_57.png diff --git a/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_71.png b/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_71.png Binary files differnew file mode 100644 index 0000000..1af3c87 --- /dev/null +++ b/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_71.png diff --git a/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_85.png b/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_85.png Binary files differnew file mode 100644 index 0000000..bc37c3c --- /dev/null +++ b/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_85.png diff --git a/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_charge_0.png b/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_charge_0.png Binary files differnew file mode 100644 index 0000000..5c4dc2d --- /dev/null +++ b/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_charge_0.png diff --git a/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_charge_100.png b/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_charge_100.png Binary files differnew file mode 100644 index 0000000..86e30b7 --- /dev/null +++ b/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_charge_100.png diff --git a/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_charge_15.png b/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_charge_15.png Binary files differnew file mode 100644 index 0000000..eb569cd --- /dev/null +++ b/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_charge_15.png diff --git a/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_charge_28.png b/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_charge_28.png Binary files differnew file mode 100644 index 0000000..2d9e1ab --- /dev/null +++ b/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_charge_28.png diff --git a/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_charge_43.png b/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_charge_43.png Binary files differnew file mode 100644 index 0000000..53fccf8 --- /dev/null +++ b/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_charge_43.png diff --git a/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_charge_57.png b/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_charge_57.png Binary files differnew file mode 100644 index 0000000..924affc --- /dev/null +++ b/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_charge_57.png diff --git a/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_charge_71.png b/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_charge_71.png Binary files differnew file mode 100644 index 0000000..a73d87b --- /dev/null +++ b/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_charge_71.png diff --git a/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_charge_85.png b/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_charge_85.png Binary files differnew file mode 100644 index 0000000..1215044 --- /dev/null +++ b/packages/SystemUI/res/drawable-hdpi/ic_qs_dock_battery_charge_85.png diff --git a/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_0.png b/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_0.png Binary files differnew file mode 100644 index 0000000..591d9b7 --- /dev/null +++ b/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_0.png diff --git a/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_100.png b/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_100.png Binary files differnew file mode 100644 index 0000000..fb60fb0 --- /dev/null +++ b/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_100.png diff --git a/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_15.png b/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_15.png Binary files differnew file mode 100644 index 0000000..968db1b --- /dev/null +++ b/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_15.png diff --git a/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_28.png b/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_28.png Binary files differnew file mode 100644 index 0000000..69628bd --- /dev/null +++ b/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_28.png diff --git a/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_43.png b/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_43.png Binary files differnew file mode 100644 index 0000000..2292bbf --- /dev/null +++ b/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_43.png diff --git a/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_57.png b/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_57.png Binary files differnew file mode 100644 index 0000000..cce2da8 --- /dev/null +++ b/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_57.png diff --git a/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_71.png b/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_71.png Binary files differnew file mode 100644 index 0000000..3698678 --- /dev/null +++ b/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_71.png diff --git a/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_85.png b/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_85.png Binary files differnew file mode 100644 index 0000000..7ce1754 --- /dev/null +++ b/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_85.png diff --git a/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_charge_0.png b/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_charge_0.png Binary files differnew file mode 100644 index 0000000..d92fbec --- /dev/null +++ b/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_charge_0.png diff --git a/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_charge_100.png b/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_charge_100.png Binary files differnew file mode 100644 index 0000000..f877e29 --- /dev/null +++ b/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_charge_100.png diff --git a/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_charge_15.png b/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_charge_15.png Binary files differnew file mode 100644 index 0000000..4670568 --- /dev/null +++ b/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_charge_15.png diff --git a/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_charge_28.png b/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_charge_28.png Binary files differnew file mode 100644 index 0000000..96849c0 --- /dev/null +++ b/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_charge_28.png diff --git a/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_charge_43.png b/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_charge_43.png Binary files differnew file mode 100644 index 0000000..54c2ab4 --- /dev/null +++ b/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_charge_43.png diff --git a/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_charge_57.png b/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_charge_57.png Binary files differnew file mode 100644 index 0000000..14bbc70 --- /dev/null +++ b/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_charge_57.png diff --git a/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_charge_71.png b/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_charge_71.png Binary files differnew file mode 100644 index 0000000..562b7a8 --- /dev/null +++ b/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_charge_71.png diff --git a/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_charge_85.png b/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_charge_85.png Binary files differnew file mode 100644 index 0000000..8da987b --- /dev/null +++ b/packages/SystemUI/res/drawable-mdpi/ic_qs_dock_battery_charge_85.png diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_0.png b/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_0.png Binary files differnew file mode 100644 index 0000000..e4b6d5c --- /dev/null +++ b/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_0.png diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_100.png b/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_100.png Binary files differnew file mode 100644 index 0000000..ff31be6 --- /dev/null +++ b/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_100.png diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_15.png b/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_15.png Binary files differnew file mode 100644 index 0000000..cd178d3 --- /dev/null +++ b/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_15.png diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_28.png b/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_28.png Binary files differnew file mode 100644 index 0000000..b07091ae --- /dev/null +++ b/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_28.png diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_43.png b/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_43.png Binary files differnew file mode 100644 index 0000000..cf5f887 --- /dev/null +++ b/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_43.png diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_57.png b/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_57.png Binary files differnew file mode 100644 index 0000000..70bd649 --- /dev/null +++ b/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_57.png diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_71.png b/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_71.png Binary files differnew file mode 100644 index 0000000..246d9a3 --- /dev/null +++ b/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_71.png diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_85.png b/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_85.png Binary files differnew file mode 100644 index 0000000..3a22620 --- /dev/null +++ b/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_85.png diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_charge_0.png b/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_charge_0.png Binary files differnew file mode 100644 index 0000000..614fe29 --- /dev/null +++ b/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_charge_0.png diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_charge_100.png b/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_charge_100.png Binary files differnew file mode 100644 index 0000000..cad730f --- /dev/null +++ b/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_charge_100.png diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_charge_15.png b/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_charge_15.png Binary files differnew file mode 100644 index 0000000..3bbd0e7 --- /dev/null +++ b/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_charge_15.png diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_charge_28.png b/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_charge_28.png Binary files differnew file mode 100644 index 0000000..b2a0a4c --- /dev/null +++ b/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_charge_28.png diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_charge_43.png b/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_charge_43.png Binary files differnew file mode 100644 index 0000000..bfd4298 --- /dev/null +++ b/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_charge_43.png diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_charge_57.png b/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_charge_57.png Binary files differnew file mode 100644 index 0000000..7d8a3fb --- /dev/null +++ b/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_charge_57.png diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_charge_71.png b/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_charge_71.png Binary files differnew file mode 100644 index 0000000..64bba5c --- /dev/null +++ b/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_charge_71.png diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_charge_85.png b/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_charge_85.png Binary files differnew file mode 100644 index 0000000..a8aefc2 --- /dev/null +++ b/packages/SystemUI/res/drawable-xhdpi/ic_qs_dock_battery_charge_85.png diff --git a/packages/SystemUI/res/drawable/qs_sys_dock_battery.xml b/packages/SystemUI/res/drawable/qs_sys_dock_battery.xml new file mode 100644 index 0000000..e717383 --- /dev/null +++ b/packages/SystemUI/res/drawable/qs_sys_dock_battery.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** Copyright 2011, 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. +*/ +--> + +<level-list xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:maxLevel="4" android:drawable="@drawable/ic_qs_dock_battery_0" /> + <item android:maxLevel="15" android:drawable="@drawable/ic_qs_dock_battery_15" /> + <item android:maxLevel="35" android:drawable="@drawable/ic_qs_dock_battery_28" /> + <item android:maxLevel="49" android:drawable="@drawable/ic_qs_dock_battery_43" /> + <item android:maxLevel="60" android:drawable="@drawable/ic_qs_dock_battery_57" /> + <item android:maxLevel="75" android:drawable="@drawable/ic_qs_dock_battery_71" /> + <item android:maxLevel="90" android:drawable="@drawable/ic_qs_dock_battery_85" /> + <item android:maxLevel="100" android:drawable="@drawable/ic_qs_dock_battery_100" /> +</level-list> diff --git a/packages/SystemUI/res/drawable/qs_sys_dock_battery_charging.xml b/packages/SystemUI/res/drawable/qs_sys_dock_battery_charging.xml new file mode 100644 index 0000000..b471b36 --- /dev/null +++ b/packages/SystemUI/res/drawable/qs_sys_dock_battery_charging.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** Copyright 2011, 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. +*/ +--> + +<level-list xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:maxLevel="4" android:drawable="@drawable/ic_qs_dock_battery_charge_0" /> + <item android:maxLevel="15" android:drawable="@drawable/ic_qs_dock_battery_charge_15" /> + <item android:maxLevel="35" android:drawable="@drawable/ic_qs_dock_battery_charge_28" /> + <item android:maxLevel="49" android:drawable="@drawable/ic_qs_dock_battery_charge_43" /> + <item android:maxLevel="60" android:drawable="@drawable/ic_qs_dock_battery_charge_57" /> + <item android:maxLevel="75" android:drawable="@drawable/ic_qs_dock_battery_charge_71" /> + <item android:maxLevel="90" android:drawable="@drawable/ic_qs_dock_battery_charge_85" /> + <item android:maxLevel="100" android:drawable="@drawable/ic_qs_dock_battery_charge_100" /> +</level-list> diff --git a/packages/SystemUI/res/layout/quick_settings_tile_dock_battery.xml b/packages/SystemUI/res/layout/quick_settings_tile_dock_battery.xml new file mode 100644 index 0000000..dae3831 --- /dev/null +++ b/packages/SystemUI/res/layout/quick_settings_tile_dock_battery.xml @@ -0,0 +1,37 @@ +<?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. +--> +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:orientation="vertical"> + <ImageView + android:id="@+id/dock_battery_image" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:paddingBottom="10dp" + /> + <TextView + style="@style/TextAppearance.QuickSettings.TileView" + android:id="@+id/dock_battery_textview" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:gravity="center" + /> +</LinearLayout>
\ No newline at end of file diff --git a/packages/SystemUI/src/com/android/systemui/quicksettings/BatteryTile.java b/packages/SystemUI/src/com/android/systemui/quicksettings/BatteryTile.java index 3c3e206..06aad14 100644 --- a/packages/SystemUI/src/com/android/systemui/quicksettings/BatteryTile.java +++ b/packages/SystemUI/src/com/android/systemui/quicksettings/BatteryTile.java @@ -41,7 +41,7 @@ public class BatteryTile extends QuickSettingsTile implements BatteryStateChange @Override void onPostCreate() { updateTile(); - BatteryController controller = new BatteryController(mContext); + BatteryController controller = new BatteryController(mContext, false); controller.addStateChangedCallback(this); super.onPostCreate(); } diff --git a/packages/SystemUI/src/com/android/systemui/quicksettings/DockBatteryTile.java b/packages/SystemUI/src/com/android/systemui/quicksettings/DockBatteryTile.java new file mode 100644 index 0000000..9367fcb --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/quicksettings/DockBatteryTile.java @@ -0,0 +1,91 @@ +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.DockBatteryController; +import com.android.systemui.statusbar.policy.DockBatteryController.DockBatteryStateChangeCallback; + +public class DockBatteryTile extends QuickSettingsTile implements DockBatteryStateChangeCallback { + + private boolean mPresent = false; + private boolean mCharging = false; + private int mDockBatteryLevel = 0; + private Drawable mDockBatteryIcon; + + private LevelListDrawable mDockBatteryLevels; + private LevelListDrawable mChargingDockBatteryLevels; + + public DockBatteryTile(Context context, LayoutInflater inflater, + QuickSettingsContainerView container, QuickSettingsController qsc) { + super(context, inflater, container, qsc); + + mTileLayout = R.layout.quick_settings_tile_dock_battery; + + mOnClick = new View.OnClickListener() { + @Override + public void onClick(View v) { + startSettingsActivity(Intent.ACTION_POWER_USAGE_SUMMARY); + } + }; + } + + @Override + void onPostCreate() { + updateTile(); + DockBatteryController controller = new DockBatteryController(mContext); + controller.addStateChangedCallback(this); + super.onPostCreate(); + } + + @Override + public void onDockBatteryLevelChanged(int level, boolean present, boolean pluggedIn) { + mDockBatteryLevel = level; + mCharging = pluggedIn; + mPresent = present; + updateResources(); + } + + @Override + public void updateResources() { + updateTile(); + super.updateResources(); + } + + private synchronized void updateTile() { + mTile.setVisibility(mPresent ? View.VISIBLE : View.GONE); + mDockBatteryLevels = (LevelListDrawable) mContext.getResources().getDrawable(R.drawable.qs_sys_dock_battery); + mChargingDockBatteryLevels = (LevelListDrawable) mContext.getResources().getDrawable(R.drawable.qs_sys_dock_battery_charging); + mDockBatteryIcon = mCharging + ? mChargingDockBatteryLevels : + mDockBatteryLevels; + if(mDockBatteryLevel == 100) { + mLabel = mContext.getString(R.string.quick_settings_battery_charged_label); + }else{ + mLabel = mCharging + ? mContext.getString(R.string.quick_settings_battery_charging_label, + mDockBatteryLevel) + : mContext.getString(R.string.status_bar_settings_battery_meter_format, + mDockBatteryLevel); + } + } + + @Override + void updateQuickSettings() { + TextView tv = (TextView) mTile.findViewById(R.id.dock_battery_textview); + tv.setText(mLabel); + ImageView iv = (ImageView) mTile.findViewById(R.id.dock_battery_image); + iv.setImageDrawable(mDockBatteryIcon); + iv.setImageLevel(mDockBatteryLevel); + } + +} 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 ee5bae0..a620f61 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -2960,6 +2960,10 @@ public class PhoneStatusBar extends BaseStatusBar { false, this); cr.registerContentObserver( + Settings.System.getUriFor(Settings.System.QS_DYNAMIC_DOCK_BATTERY), + false, this); + + cr.registerContentObserver( Settings.System.getUriFor(Settings.System.QS_DYNAMIC_IME), false, this); 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 782af23..16d087f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsController.java @@ -43,6 +43,7 @@ import static com.android.internal.util.cm.QSConstants.TILE_WIFI; import static com.android.internal.util.cm.QSConstants.TILE_WIFIAP; import static com.android.internal.util.cm.QSConstants.TILE_WIMAX; import static com.android.internal.util.cm.QSUtils.deviceSupportsBluetooth; +import static com.android.internal.util.cm.QSUtils.deviceSupportsDockBattery; import static com.android.internal.util.cm.QSUtils.deviceSupportsImeSwitcher; import static com.android.internal.util.cm.QSUtils.deviceSupportsTelephony; import static com.android.internal.util.cm.QSUtils.deviceSupportsUsbTether; @@ -69,6 +70,7 @@ 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.DockBatteryTile; import com.android.systemui.quicksettings.GPSTile; import com.android.systemui.quicksettings.InputMethodTile; import com.android.systemui.quicksettings.LteTile; @@ -159,6 +161,7 @@ public class QuickSettingsController { Log.i(TAG, "Tiles list: " + tiles); // Split out the tile names and add to the list + boolean dockBatteryLoaded = false; for (String tile : tiles.split("\\|")) { QuickSettingsTile qs = null; if (tile.equals(TILE_USER)) { @@ -215,6 +218,12 @@ public class QuickSettingsController { if (qs != null) { qs.setupQuickSettingsTile(); mQuickSettingsTiles.add(qs); + + // Add dock battery beside main battery when possible + if (qs instanceof BatteryTile) { + loadDockBatteryTile(resolver, inflater); + dockBatteryLoaded = true; + } } } @@ -231,6 +240,9 @@ public class QuickSettingsController { qs.setupQuickSettingsTile(); mQuickSettingsTiles.add(qs); } + if (!dockBatteryLoaded) { + loadDockBatteryTile(resolver, inflater); + } if (Settings.System.getInt(resolver, Settings.System.QS_DYNAMIC_WIFI, 1) == 1) { QuickSettingsTile qs = new WiFiDisplayTile(mContext, inflater, mContainerView, this); qs.setupQuickSettingsTile(); @@ -248,6 +260,14 @@ public class QuickSettingsController { } } + private void loadDockBatteryTile(final ContentResolver resolver, final LayoutInflater inflater) { + if (deviceSupportsDockBattery(mContext) && Settings.System.getInt(resolver, Settings.System.QS_DYNAMIC_DOCK_BATTERY, 1) == 1) { + QuickSettingsTile qs = new DockBatteryTile(mContext, inflater, mContainerView, this); + qs.setupQuickSettingsTile(); + mQuickSettingsTiles.add(qs); + } + } + protected void setupQuickSettings() { mQuickSettingsTiles.clear(); mContainerView.removeAllViews(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BatteryController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BatteryController.java index 95fede4..a2b425b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BatteryController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BatteryController.java @@ -63,6 +63,8 @@ public class BatteryController extends BroadcastReceiver { Handler mHandler; + private final boolean mUiController; + class SettingsObserver extends ContentObserver { SettingsObserver(Handler handler) { super(handler); @@ -87,12 +89,19 @@ public class BatteryController extends BroadcastReceiver { } public BatteryController(Context context) { + this(context, true); + } + + public BatteryController(Context context, boolean ui) { mContext = context; mHandler = new Handler(); + mUiController = ui; - SettingsObserver settingsObserver = new SettingsObserver(mHandler); - settingsObserver.observe(); - updateSettings(); + if (mUiController) { + SettingsObserver settingsObserver = new SettingsObserver(mHandler); + settingsObserver.observe(); + updateSettings(); + } IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_BATTERY_CHANGED); @@ -145,14 +154,18 @@ public class BatteryController extends BroadcastReceiver { return true; } - private boolean isBatteryStatusUnknown() { + protected boolean isBatteryStatusUnknown() { return getBatteryStatus() == BatteryManager.BATTERY_STATUS_UNKNOWN; } - private boolean isBatteryStatusCharging() { + protected boolean isBatteryStatusCharging() { return getBatteryStatus() == BatteryManager.BATTERY_STATUS_CHARGING; } + protected boolean isUiController() { + return mUiController; + } + public void onReceive(Context context, Intent intent) { final String action = intent.getAction(); if (action.equals(Intent.ACTION_BATTERY_CHANGED)) { @@ -161,23 +174,27 @@ public class BatteryController extends BroadcastReceiver { mBatteryStatus = intent.getIntExtra(BatteryManager.EXTRA_STATUS, BatteryManager.BATTERY_STATUS_UNKNOWN); updateViews(level); - updateBattery(); + if (mUiController) { + updateBattery(); + } } } protected void updateViews(int level) { - int N = mIconViews.size(); - for (int i=0; i<N; i++) { - ImageView v = mIconViews.get(i); - v.setImageLevel(level); - v.setContentDescription(mContext.getString(R.string.accessibility_battery_level, - level)); - } - N = mLabelViews.size(); - for (int i=0; i<N; i++) { - TextView v = mLabelViews.get(i); - v.setText(mContext.getString(BATTERY_TEXT_STYLE_MIN, - level)); + if (mUiController) { + int N = mIconViews.size(); + for (int i=0; i<N; i++) { + ImageView v = mIconViews.get(i); + v.setImageLevel(level); + v.setContentDescription(mContext.getString(R.string.accessibility_battery_level, + level)); + } + N = mLabelViews.size(); + for (int i=0; i<N; i++) { + TextView v = mLabelViews.get(i); + v.setText(mContext.getString(BATTERY_TEXT_STYLE_MIN, + level)); + } } for (BatteryStateChangeCallback cb : mChangeCallbacks) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BrightnessController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BrightnessController.java index e18b28a..769e5b2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BrightnessController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BrightnessController.java @@ -30,8 +30,6 @@ import android.view.IWindowManager; import android.widget.CompoundButton; import android.widget.ImageView; -import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback; - import java.util.ArrayList; public class BrightnessController implements ToggleSlider.Listener { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/DockBatteryController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/DockBatteryController.java index fae6572..83639ee 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/DockBatteryController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/DockBatteryController.java @@ -22,6 +22,8 @@ import android.os.BatteryManager; import com.android.systemui.R; +import java.util.ArrayList; + public class DockBatteryController extends BatteryController { private static final String TAG = "StatusBar.DockBatteryController"; @@ -30,7 +32,11 @@ public class DockBatteryController extends BatteryController { private boolean mBatteryPresent = false; public DockBatteryController(Context context) { - super(context); + this(context, true); + } + + public DockBatteryController(Context context, boolean ui) { + super(context, ui); } @Override @@ -49,6 +55,28 @@ public class DockBatteryController extends BatteryController { } @Override + protected void updateViews(int level) { + if (isUiController()) { + super.updateViews(level); + } + + for (DockBatteryStateChangeCallback cb : mChangeCallbacks) { + cb.onDockBatteryLevelChanged(level, isBatteryPresent(), isBatteryStatusCharging()); + } + } + + private ArrayList<DockBatteryStateChangeCallback> mChangeCallbacks = + new ArrayList<DockBatteryStateChangeCallback>(); + + public interface DockBatteryStateChangeCallback { + public void onDockBatteryLevelChanged(int level, boolean present, boolean pluggedIn); + } + + public void addStateChangedCallback(DockBatteryStateChangeCallback cb) { + mChangeCallbacks.add(cb); + } + + @Override public int getIconStyleUnknown() { return R.drawable.stat_sys_kb_battery_unknown; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/LocationController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/LocationController.java index 776cf36..5db0934 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/LocationController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/LocationController.java @@ -37,7 +37,6 @@ import android.app.INotificationManager; import com.android.internal.statusbar.StatusBarNotification; import com.android.systemui.R; -import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback; public class LocationController extends BroadcastReceiver { private static final String TAG = "StatusBar.LocationController"; |