Merge "Add info string to advanced battery usage page" into oc-dr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
94d0a9c554
@@ -21,6 +21,7 @@ import android.support.annotation.VisibleForTesting;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceViewHolder;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import com.android.internal.os.BatteryStatsHelper;
|
||||
import com.android.settings.R;
|
||||
@@ -32,6 +33,10 @@ import com.android.settings.graph.UsageView;
|
||||
*/
|
||||
public class BatteryHistoryPreference extends Preference {
|
||||
|
||||
private CharSequence mSummary;
|
||||
private TextView mSummaryView;
|
||||
private boolean hideSummary;
|
||||
|
||||
@VisibleForTesting
|
||||
BatteryInfo mBatteryInfo;
|
||||
|
||||
@@ -48,6 +53,20 @@ public class BatteryHistoryPreference extends Preference {
|
||||
}, batteryStats.getStats(), false);
|
||||
}
|
||||
|
||||
public void setBottomSummary(CharSequence text) {
|
||||
mSummary = text;
|
||||
if (mSummaryView != null) {
|
||||
mSummaryView.setText(mSummary);
|
||||
}
|
||||
}
|
||||
|
||||
public void hideBottomSummary() {
|
||||
if (mSummaryView != null) {
|
||||
mSummaryView.setVisibility(View.GONE);
|
||||
}
|
||||
hideSummary = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(PreferenceViewHolder view) {
|
||||
super.onBindViewHolder(view);
|
||||
@@ -56,6 +75,13 @@ public class BatteryHistoryPreference extends Preference {
|
||||
}
|
||||
|
||||
((TextView) view.findViewById(R.id.charge)).setText(mBatteryInfo.batteryPercentString);
|
||||
mSummaryView = (TextView) view.findViewById(R.id.bottom_summary);
|
||||
if (mSummary != null) {
|
||||
mSummaryView.setText(mSummary);
|
||||
}
|
||||
if (hideSummary) {
|
||||
mSummaryView.setVisibility(View.GONE);
|
||||
}
|
||||
UsageView usageView = (UsageView) view.findViewById(R.id.battery_usage);
|
||||
usageView.findViewById(R.id.label_group).setAlpha(.7f);
|
||||
mBatteryInfo.bindHistory(usageView);
|
||||
|
@@ -69,9 +69,9 @@ public class PowerUsageAdvanced extends PowerUsageBase {
|
||||
UsageType.UNACCOUNTED,
|
||||
UsageType.OVERCOUNTED};
|
||||
|
||||
@VisibleForTesting BatteryHistoryPreference mHistPref;
|
||||
@VisibleForTesting PreferenceGroup mUsageListGroup;
|
||||
private BatteryUtils mBatteryUtils;
|
||||
private BatteryHistoryPreference mHistPref;
|
||||
private PreferenceGroup mUsageListGroup;
|
||||
private PowerUsageFeatureProvider mPowerUsageFeatureProvider;
|
||||
private PackageManager mPackageManager;
|
||||
private UserManager mUserManager;
|
||||
@@ -170,6 +170,14 @@ public class PowerUsageAdvanced extends PowerUsageBase {
|
||||
}
|
||||
updatePreference(mHistPref);
|
||||
refreshPowerUsageDataList(mStatsHelper, mUsageListGroup);
|
||||
|
||||
if (mPowerUsageFeatureProvider.isEnhancedBatteryPredictionEnabled(context)) {
|
||||
mHistPref.setBottomSummary(
|
||||
mPowerUsageFeatureProvider.getAdvancedUsageScreenInfoString());
|
||||
} else {
|
||||
mHistPref.hideBottomSummary();
|
||||
}
|
||||
|
||||
BatteryEntry.startRequestQueue();
|
||||
}
|
||||
|
||||
|
@@ -113,4 +113,10 @@ public interface PowerUsageFeatureProvider {
|
||||
* @return A string containing the estimate and a label indicating it is a normal estimate
|
||||
*/
|
||||
String getOldEstimateDebugString(String timeRemaining);
|
||||
|
||||
/**
|
||||
* Returns the string to show in the advanced usage battery page when enhanced estimates are
|
||||
* enabled. This string notifies users that the estimate is using enhanced prediction.
|
||||
*/
|
||||
String getAdvancedUsageScreenInfoString();
|
||||
}
|
||||
|
@@ -132,4 +132,9 @@ public class PowerUsageFeatureProviderImpl implements PowerUsageFeatureProvider
|
||||
public String getOldEstimateDebugString(String timeRemaining) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAdvancedUsageScreenInfoString() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user