Skip to content

Commit

Permalink
Revert "status bar: native battery percentage"
Browse files Browse the repository at this point in the history
This reverts commit c123a0c.
  • Loading branch information
rascarlo committed Nov 26, 2014
1 parent e93689d commit 6fb7fea
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 53 deletions.
6 changes: 0 additions & 6 deletions core/java/android/provider/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -2646,12 +2646,6 @@ public static void setShowGTalkServiceStatusForUser(ContentResolver cr, boolean
*/
public static final String EGG_MODE = "egg_mode";

/**
* Whether to show/hide status bar native battery percentage
* @hide
*/
public static final String STATUS_BAR_NATIVE_BATTERY_PERCENTAGE = "status_bar_native_battery_percentage";

/**
* Volume keys control cursor in text fields (default is 0)
* 0 - Disabled
Expand Down
50 changes: 3 additions & 47 deletions packages/SystemUI/src/com/android/systemui/BatteryMeterView.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,18 @@
package com.android.systemui;

import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.database.ContentObserver;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;
import android.graphics.Typeface;
import android.os.BatteryManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.UserHandle;
import android.provider.Settings;
import android.util.AttributeSet;
import android.view.View;
Expand All @@ -46,7 +42,7 @@ public class BatteryMeterView extends View implements DemoMode,

private static final boolean ENABLE_PERCENT = true;
private static final boolean SINGLE_DIGIT_PERCENT = false;
private static final boolean SHOW_100_PERCENT = true;
private static final boolean SHOW_100_PERCENT = false;

private static final int FULL = 96;

Expand Down Expand Up @@ -79,9 +75,6 @@ public class BatteryMeterView extends View implements DemoMode,

private BatteryController mBatteryController;
private boolean mPowerSaveEnabled;

// status bar native batter percentage
private Context mContext;

private class BatteryTracker extends BroadcastReceiver {
public static final int UNKNOWN_LEVEL = -1;
Expand Down Expand Up @@ -156,33 +149,7 @@ public void run() {
}
}

class SettingsObserver extends ContentObserver {
SettingsObserver(Handler handler) {
super(handler);
}

void observe() {
ContentResolver resolver = mContext.getContentResolver();
resolver.registerContentObserver(Settings.System.getUriFor(
Settings.System.STATUS_BAR_NATIVE_BATTERY_PERCENTAGE), false, this,
UserHandle.USER_ALL);
update();
}

@Override
public void onChange(boolean selfChange) {
update();
}
}

public void update() {
mShowPercent = ENABLE_PERCENT && 0 != Settings.System.getInt(mContext.getContentResolver(),
Settings.System.STATUS_BAR_NATIVE_BATTERY_PERCENTAGE, 0);
postInvalidate();
}

BatteryTracker mTracker = new BatteryTracker();
SettingsObserver mSettingsObserver;

@Override
public void onAttachedToWindow() {
Expand Down Expand Up @@ -218,10 +185,6 @@ public BatteryMeterView(Context context, AttributeSet attrs) {
public BatteryMeterView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);

mContext = context;
mSettingsObserver = new SettingsObserver(new Handler());
mSettingsObserver.observe();

final Resources res = context.getResources();
TypedArray atts = context.obtainStyledAttributes(attrs, R.styleable.BatteryMeterView,
defStyle, 0);
Expand All @@ -239,8 +202,8 @@ public BatteryMeterView(Context context, AttributeSet attrs, int defStyle) {
levels.recycle();
colors.recycle();
atts.recycle();
// mShowPercent = ENABLE_PERCENT && 0 != Settings.System.getInt(
// context.getContentResolver(), "status_bar_show_battery_percent", 0);
mShowPercent = ENABLE_PERCENT && 0 != Settings.System.getInt(
context.getContentResolver(), "status_bar_show_battery_percent", 0);
mWarningString = context.getString(R.string.battery_meter_very_low_overlay_symbol);
mCriticalLevel = mContext.getResources().getInteger(
com.android.internal.R.integer.config_criticalBatteryWarningLevel);
Expand Down Expand Up @@ -481,13 +444,6 @@ public boolean hasOverlappingRendering() {
return false;
}

public void setShowPercentage(boolean show) {
if (ENABLE_PERCENT) {
mShowPercent = show;
postInvalidate();
}
}

private boolean mDemoMode;
private BatteryTracker mDemoTracker = new BatteryTracker();

Expand Down

0 comments on commit 6fb7fea

Please sign in to comment.