Add ability to see both battery estimates on long press

If the enhanced estimate is being used in battery settings
it is now possible to long press on the text to have it display
both instead of the string that is normally used.

Adds another loader to enable this since it needs both the old
and the new estimates simultaneously.

Feature is hidden behind a feature flag that only googlers will
have enabled.

Test: robotests
Bug: 38399275
Change-Id: I5caf26513baada27efd50ddb0e72d3868da47150
This commit is contained in:
Salvador Martinez
2017-05-22 17:26:39 -07:00
parent fe23da579d
commit f4727ea07f
10 changed files with 229 additions and 24 deletions

View File

@@ -48,7 +48,9 @@ public class BatteryHeaderPreferenceController extends PreferenceController
@VisibleForTesting
TextView mTimeText;
@VisibleForTesting
TextView mSummary;
TextView mSummary1;
@VisibleForTesting
TextView mSummary2;
private final Activity mActivity;
private final PreferenceFragment mHost;
@@ -73,8 +75,9 @@ public class BatteryHeaderPreferenceController extends PreferenceController
mBatteryLayoutPref = (LayoutPreference) screen.findPreference(KEY_BATTERY_HEADER);
mBatteryMeterView = (BatteryMeterView) mBatteryLayoutPref
.findViewById(R.id.battery_header_icon);
mTimeText = (TextView) mBatteryLayoutPref.findViewById(R.id.battery_percent);
mSummary = (TextView) mBatteryLayoutPref.findViewById(R.id.summary1);
mTimeText = mBatteryLayoutPref.findViewById(R.id.battery_percent);
mSummary1 = mBatteryLayoutPref.findViewById(R.id.summary1);
mSummary2 = mBatteryLayoutPref.findViewById(R.id.summary2);
Intent batteryBroadcast = mContext.registerReceiver(null,
new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
@@ -105,10 +108,13 @@ public class BatteryHeaderPreferenceController extends PreferenceController
public void updateHeaderPreference(BatteryInfo info) {
mTimeText.setText(Utils.formatPercentage(info.batteryLevel));
if (info.remainingLabel == null) {
mSummary.setText(info.statusLabel);
mSummary1.setText(info.statusLabel);
} else {
mSummary.setText(info.remainingLabel);
mSummary1.setText(info.remainingLabel);
}
// Clear this just to be sure we don't get UI jank on re-entering this view from another
// activity.
mSummary2.setText("");
mBatteryMeterView.setBatteryLevel(info.batteryLevel);
mBatteryMeterView.setCharging(!info.discharging);