• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.content.res.ColorStateList;
22 import android.os.Parcel;
23 import android.os.Parcelable;
24 
25 import androidx.annotation.VisibleForTesting;
26 
27 import com.android.settings.R;
28 import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
29 
30 /**
31  * Tip to show general summary about battery life
32  */
33 public class SummaryTip extends BatteryTip {
34     private long mAverageTimeMs;
35 
SummaryTip(@tateType int state, long averageTimeMs)36     public SummaryTip(@StateType int state, long averageTimeMs) {
37         super(TipType.SUMMARY, state, true /* showDialog */);
38         mAverageTimeMs = averageTimeMs;
39     }
40 
41     @VisibleForTesting
SummaryTip(Parcel in)42     SummaryTip(Parcel in) {
43         super(in);
44         mAverageTimeMs = in.readLong();
45     }
46 
47     @Override
getTitle(Context context)48     public CharSequence getTitle(Context context) {
49         return context.getString(R.string.battery_tip_summary_title);
50     }
51 
52     @Override
getSummary(Context context)53     public CharSequence getSummary(Context context) {
54         return context.getString(R.string.battery_tip_summary_summary);
55     }
56 
57     @Override
getIconId()58     public int getIconId() {
59         return R.drawable.ic_battery_status_good_24dp;
60     }
61 
62     @Override
getIconTintColorId()63     public int getIconTintColorId() {
64         return R.color.battery_good_color_light;
65     }
66 
67     @Override
updateState(BatteryTip tip)68     public void updateState(BatteryTip tip) {
69         mState = tip.mState;
70     }
71 
72     @Override
writeToParcel(Parcel dest, int flags)73     public void writeToParcel(Parcel dest, int flags) {
74         super.writeToParcel(dest, flags);
75         dest.writeLong(mAverageTimeMs);
76     }
77 
78     @Override
log(Context context, MetricsFeatureProvider metricsFeatureProvider)79     public void log(Context context, MetricsFeatureProvider metricsFeatureProvider) {
80         metricsFeatureProvider.action(context, SettingsEnums.ACTION_SUMMARY_TIP,
81                 mState);
82     }
83 
getAverageTimeMs()84     public long getAverageTimeMs() {
85         return mAverageTimeMs;
86     }
87 
88     public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
89         public BatteryTip createFromParcel(Parcel in) {
90             return new SummaryTip(in);
91         }
92 
93         public BatteryTip[] newArray(int size) {
94             return new SummaryTip[size];
95         }
96     };
97 }
98