1 /* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.settings.fuelgauge; 18 19 import android.content.Context; 20 import android.graphics.PorterDuff; 21 import android.graphics.PorterDuffColorFilter; 22 23 import com.android.settingslib.Utils; 24 import com.android.settingslib.graph.BatteryMeterDrawableBase; 25 26 /** 27 * Drawable that shows a static battery saver icon - a full battery symbol and a plus sign. 28 */ 29 public class BatterySaverDrawable extends BatteryMeterDrawableBase { 30 31 private static final int MAX_BATTERY = 100; 32 BatterySaverDrawable(Context context, int frameColor)33 public BatterySaverDrawable(Context context, int frameColor) { 34 super(context, frameColor); 35 // Show as full so it's always uniform color 36 setBatteryLevel(MAX_BATTERY); 37 setPowerSave(true); 38 setCharging(false); 39 setPowerSaveAsColorError(false); 40 final int tintColor = Utils.getColorAttrDefaultColor(context, android.R.attr.colorAccent); 41 setColorFilter(new PorterDuffColorFilter(tintColor, PorterDuff.Mode.SRC_IN)); 42 } 43 } 44