Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8d0e8330 authored by Michael W's avatar Michael W Committed by Joey Rizzoli
Browse files

SystemUI: Cleanup BatteryMeter

* Remove unused imports and variables from BatteryMeterView and -Drawable
* Remove some commented stuff about themes

Change-Id: Iab057e510a4478ac1f026f004eef9d6f46e6032f
parent 622656f8
Loading
Loading
Loading
Loading
+1 −47
Original line number Diff line number Diff line
/*
 * Copyright (C) 2015 The Android Open Source Project
 * Copyright (C) 2017 The LineageOS Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -19,7 +20,6 @@ package com.android.systemui;
import android.animation.ArgbEvaluator;
import android.annotation.Nullable;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.content.res.ThemeConfig;
import android.content.res.TypedArray;
@@ -29,20 +29,16 @@ import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Typeface;
import android.graphics.drawable.AnimatedVectorDrawable;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.provider.Settings;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
@@ -56,16 +52,11 @@ import org.cyanogenmod.graphics.drawable.StopMotionVectorDrawable;
public class BatteryMeterDrawable extends Drawable implements
        BatteryController.BatteryStateChangeCallback {

    private static final float ASPECT_RATIO = 9.5f / 14.5f;
    public static final String TAG = BatteryMeterDrawable.class.getSimpleName();
    public static final String SHOW_PERCENT_SETTING = "status_bar_show_battery_percent";

    private static final boolean SINGLE_DIGIT_PERCENT = false;

    private static final int FULL = 96;

    private static final float BOLT_LEVEL_THRESHOLD = 0.3f;  // opaque bolt below this fraction

    // Values for the different battery styles
    public static final int BATTERY_STYLE_PORTRAIT  = 0;
    public static final int BATTERY_STYLE_CIRCLE    = 2;
@@ -78,10 +69,6 @@ public class BatteryMeterDrawable extends Drawable implements
    private final int mIntrinsicHeight;

    private boolean mShowPercent;
    private float mButtonHeightFraction;
    private float mSubpixelSmoothingLeft;
    private float mSubpixelSmoothingRight;
    private float mTextHeight, mWarningTextHeight;
    private int mIconTint = Color.WHITE;
    private float mOldDarkIntensity = 0f;

@@ -89,18 +76,6 @@ public class BatteryMeterDrawable extends Drawable implements
    private int mWidth;
    private String mWarningString;
    private final int mCriticalLevel;
    private int mChargeColor;
    private final Path mBoltPath = new Path();
    private final Path mPlusPath = new Path();

    private final RectF mFrame = new RectF();
    private final RectF mButtonFrame = new RectF();
    private final RectF mBoltFrame = new RectF();
    private final RectF mPlusFrame = new RectF();

    private final Path mShapePath = new Path();
    private final Path mClipPath = new Path();
    private final Path mTextPath = new Path();

    private BatteryController mBatteryController;
    private boolean mPowerSaveEnabled;
@@ -118,9 +93,6 @@ public class BatteryMeterDrawable extends Drawable implements

    private int mLevel = -1;
    private boolean mPluggedIn;
    private boolean mListening;

    private boolean mIsAnimating; // stores charge-animation status to remove callbacks

    private float mTextX, mTextY; // precalculated position for drawText() to appear centered

@@ -164,12 +136,6 @@ public class BatteryMeterDrawable extends Drawable implements
        mWarningString = context.getString(R.string.battery_meter_very_low_overlay_symbol);
        mCriticalLevel = mContext.getResources().getInteger(
                com.android.internal.R.integer.config_criticalBatteryWarningLevel);
        mButtonHeightFraction = context.getResources().getFraction(
                R.fraction.battery_button_height_fraction, 1, 1);
        mSubpixelSmoothingLeft = context.getResources().getFraction(
                R.fraction.battery_subpixel_smoothing_left, 1, 1);
        mSubpixelSmoothingRight = context.getResources().getFraction(
                R.fraction.battery_subpixel_smoothing_right, 1, 1);

        loadBatteryDrawables(res, style);

@@ -224,7 +190,6 @@ public class BatteryMeterDrawable extends Drawable implements
    }

    public void startListening() {
        mListening = true;
        mContext.getContentResolver().registerContentObserver(
                CMSettings.System.getUriFor(CMSettings.System.STATUS_BAR_SHOW_BATTERY_PERCENT),
                false, mSettingObserver);
@@ -233,7 +198,6 @@ public class BatteryMeterDrawable extends Drawable implements
    }

    public void stopListening() {
        mListening = false;
        mContext.getContentResolver().unregisterContentObserver(mSettingObserver);
        mBatteryController.removeStateChangedCallback(this);
    }
@@ -307,7 +271,6 @@ public class BatteryMeterDrawable extends Drawable implements
        mHeight = bottom - top;
        mWidth = right - left;
        mWarningTextPaint.setTextSize(mHeight * 0.75f);
        mWarningTextHeight = -mWarningTextPaint.getFontMetrics().ascent;
    }

    private void updateShowPercent() {
@@ -410,15 +373,6 @@ public class BatteryMeterDrawable extends Drawable implements
                checkBatteryMeterDrawableValid(res, style);
            } catch (BatteryMeterDrawableException e) {
                Log.w(TAG, "Invalid themed battery meter drawable, falling back to system", e);
/*              Disable until the theme engine is brought up
                PackageManager pm = mContext.getPackageManager();
                try {
                    res = pm.getThemedResourcesForApplication(mContext.getPackageName(),
                            ThemeConfig.SYSTEM_DEFAULT);
                } catch (PackageManager.NameNotFoundException nnfe) {
                    // Ignore; this should not happen
                }
*/
            }
        }

+0 −2
Original line number Diff line number Diff line
@@ -19,8 +19,6 @@ import android.content.Context;
import android.content.res.TypedArray;
import android.os.Handler;
import android.util.ArraySet;
import android.os.UserHandle;
import android.provider.Settings;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;