1 /* 2 * Copyright (C) 2017 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.batterytip.tips; 18 19 import android.app.settings.SettingsEnums; 20 import android.content.Context; 21 import android.os.Parcel; 22 import android.os.Parcelable; 23 24 import com.android.settings.R; 25 import com.android.settingslib.core.instrumentation.MetricsFeatureProvider; 26 27 /** 28 * Tip to show current battery level is low or remaining time is less than a certain period 29 */ 30 public class LowBatteryTip extends EarlyWarningTip { 31 LowBatteryTip(@tateType int state, boolean powerSaveModeOn)32 public LowBatteryTip(@StateType int state, boolean powerSaveModeOn) { 33 super(state, powerSaveModeOn); 34 mType = TipType.LOW_BATTERY; 35 } 36 LowBatteryTip(Parcel in)37 public LowBatteryTip(Parcel in) { 38 super(in); 39 } 40 41 @Override getTitle(Context context)42 public CharSequence getTitle(Context context) { 43 return context.getString(R.string.battery_tip_low_battery_title); 44 } 45 46 @Override getSummary(Context context)47 public CharSequence getSummary(Context context) { 48 return context.getString(R.string.battery_tip_low_battery_summary); 49 } 50 51 @Override writeToParcel(Parcel dest, int flags)52 public void writeToParcel(Parcel dest, int flags) { 53 super.writeToParcel(dest, flags); 54 } 55 56 @Override log(Context context, MetricsFeatureProvider metricsFeatureProvider)57 public void log(Context context, MetricsFeatureProvider metricsFeatureProvider) { 58 metricsFeatureProvider.action(context, SettingsEnums.ACTION_LOW_BATTERY_TIP, 59 mState); 60 } 61 62 public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { 63 public BatteryTip createFromParcel(Parcel in) { 64 return new LowBatteryTip(in); 65 } 66 67 public BatteryTip[] newArray(int size) { 68 return new LowBatteryTip[size]; 69 } 70 }; 71 72 } 73