Permalink
Browse files

Add CmCircleBattery to StatusBar options (1/2)

Cyanogenmod Circle Battery implementation
- Done 100% in pure code, wont blow up the framework with countless png resources
- View can be shown with or without percentage as text inside
- Indicator turns holo-red below 15%.
- All sizes are calculated on the fly and should work on all current and
  future screen resolutions. (needs testing)
- All colors are read from the holo-theme, so changes by themers will be obeyed.
- The lower part of the pictures tries to illustrate the charge animation.

Screenshot: http://dl.dropbox.com/u/16186798/cm10/cm-circle-bat-mockup.png

Patchset 2:
- Level >= 95% is treated as 100% (see inline comment)
- paint.setDither(true) should reduce artifacts on 16bit color depth devices
- modified tablet-specific xml. alignment should fit now (not tested yet)
- cleaned up some xml formating derps
- fixed possible crash bug

PS3: 97% seems better than 95% for full circle

Patchset 4+5: lost track of patchsets.

Patchset 6:
The battery fill-up above 97% was a quick shot. In the end,
we show the right percentage in text, but circle fills up, once 97% is
reached. This also solves the issue, that circle with very tiny gap
looks slightly unbalanced.

Also gave in about code formating. Its for the greater good. (I still am
convinced, the whole world is wrong about this :)

Patchset 7:
- Fix derp

Change-Id: I3dfe0b4e69c545cb9bbad2d1461d154618c60e00
  • Loading branch information...
1 parent 2c79d53 commit bc5b61deccfe5f1093b986a6c4466635420e569a @Sven-Dawitz Sven-Dawitz committed with DvTonder Oct 12, 2012
@@ -2449,7 +2449,9 @@ public static void setShowGTalkServiceStatus(ContentResolver cr, boolean flag) {
* Display style of the status bar battery information
* 0: Display the stock battery information
* 1: Display cm battery percentage implementation / dont show stock icon
- * 2: Hide the battery information
+ * 2: Display cm circle battery implementation without percentage
+ * 3: Display cm circle battery implementation with percentage
+ * 4: Hide the battery information
* default: 0
* @hide
*/
@@ -2517,7 +2519,7 @@ public static void setShowGTalkServiceStatus(ContentResolver cr, boolean flag) {
/**
* Boolean value whether to link ringtone and notification volumes
- *
+ *
* @hide
*/
public static final String VOLUME_LINK_NOTIFICATION = "volume_link_notification";
@@ -110,6 +110,16 @@
android:id="@+id/battery"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
+ android:gravity="center_vertical|bottom"
+ android:paddingLeft="4dip"
+ />
+ <com.android.systemui.statusbar.policy.CircleBattery
+ android:id="@+id/circle_battery"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="@style/TextAppearance.StatusBar.Battery"
+ android:singleLine="true"
+ android:gravity="bottom"
android:paddingLeft="4dip"
/>
</LinearLayout>
@@ -144,6 +144,15 @@
android:layout_marginRight="-3dip"
android:gravity="center_vertical|left"
/>
+ <com.android.systemui.statusbar.policy.CircleBattery
+ android:id="@+id/dock_circle_battery"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:singleLine="true"
+ android:paddingLeft="4dip"
+ android:layout_marginRight="-3dip"
+ android:gravity="center_vertical|left"
+ />
<ImageView
android:id="@+id/dock_battery"
android:layout_height="wrap_content"
@@ -153,6 +153,15 @@
android:text="@string/status_bar_settings_settings_button"
/>
+ <com.android.systemui.statusbar.policy.CircleBattery
+ android:id="@+id/panel_circle_battery"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:singleLine="true"
+ android:paddingLeft="6dp"
+ android:layout_gravity="center_vertical"
+ />
+
<ImageView
android:id="@+id/battery"
android:layout_height="wrap_content"
@@ -41,9 +41,18 @@
private ArrayList<ImageView> mIconViews = new ArrayList<ImageView>();
private ArrayList<TextView> mLabelViews = new ArrayList<TextView>();
- private static final int BATTERY_STYLE_NORMAL = 0;
- private static final int BATTERY_STYLE_TEXT = 1;
- private static final int BATTERY_STYLE_GONE = 2;
+ private static final int BATTERY_STYLE_NORMAL = 0;
+ private static final int BATTERY_STYLE_PERCENT = 1;
+ /***
+ * BATTERY_STYLE_CIRCLE* cannot be handled in this controller, since we cannot get views from
+ * statusbar here. Yet it is listed for completion and not to confuse at future updates
+ * See CircleBattery.java for more info
+ *
+ * set to public to be reused by CircleBattery
+ */
+ public static final int BATTERY_STYLE_CIRCLE = 2;
+ public static final int BATTERY_STYLE_CIRCLE_PERCENT = 3;
+ private static final int BATTERY_STYLE_GONE = 4;
private static final int BATTERY_ICON_STYLE_NORMAL = R.drawable.stat_sys_battery;
private static final int BATTERY_ICON_STYLE_CHARGE = R.drawable.stat_sys_battery_charge;
@@ -124,11 +133,11 @@ private void updateBattery() {
int mText = View.GONE;
int mIconStyle = BATTERY_ICON_STYLE_NORMAL;
- if (mBatteryStyle == 0) {
+ if (mBatteryStyle == BATTERY_STYLE_NORMAL) {
mIcon = (View.VISIBLE);
mIconStyle = mBatteryPlugged ? BATTERY_ICON_STYLE_CHARGE
: BATTERY_ICON_STYLE_NORMAL;
- } else if (mBatteryStyle == 1) {
+ } else if (mBatteryStyle == BATTERY_STYLE_PERCENT) {
mIcon = (View.VISIBLE);
mText = (View.VISIBLE);
mIconStyle = mBatteryPlugged ? BATTERY_ICON_STYLE_CHARGE_MIN
Oops, something went wrong.

0 comments on commit bc5b61d

Please sign in to comment.