Merge "Fix Battery page animation"
This commit is contained in:
committed by
Android (Google) Code Review
commit
34b1e00ca7
@@ -44,16 +44,10 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:minLines="2"
|
||||
android:minLines="3"
|
||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Small"/>
|
||||
android:textColor="?android:attr/textColorPrimary"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/summary2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Small"/>
|
||||
android:textColor="?android:attr/textColorPrimary"/>
|
||||
</LinearLayout>
|
||||
|
||||
<com.android.settings.fuelgauge.BatteryMeterView
|
||||
|
@@ -55,8 +55,6 @@ public class BatteryHeaderPreferenceController extends BasePreferenceController
|
||||
TextView mBatteryPercentText;
|
||||
@VisibleForTesting
|
||||
TextView mSummary1;
|
||||
@VisibleForTesting
|
||||
TextView mSummary2;
|
||||
|
||||
private Activity mActivity;
|
||||
private PreferenceFragmentCompat mHost;
|
||||
@@ -90,7 +88,6 @@ public class BatteryHeaderPreferenceController extends BasePreferenceController
|
||||
.findViewById(R.id.battery_header_icon);
|
||||
mBatteryPercentText = mBatteryLayoutPref.findViewById(R.id.battery_percent);
|
||||
mSummary1 = mBatteryLayoutPref.findViewById(R.id.summary1);
|
||||
mSummary2 = mBatteryLayoutPref.findViewById(R.id.summary2);
|
||||
|
||||
quickUpdateHeaderPreference();
|
||||
}
|
||||
@@ -115,9 +112,6 @@ public class BatteryHeaderPreferenceController extends BasePreferenceController
|
||||
} else {
|
||||
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);
|
||||
|
@@ -19,15 +19,12 @@ package com.android.settings.fuelgauge;
|
||||
import static com.android.settings.fuelgauge.BatteryBroadcastReceiver.BatteryUpdateType;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.database.ContentObserver;
|
||||
import android.net.Uri;
|
||||
import android.os.BatteryStats;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.provider.Settings;
|
||||
import android.provider.Settings.Global;
|
||||
import android.text.format.Formatter;
|
||||
import android.view.Menu;
|
||||
@@ -157,7 +154,6 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList
|
||||
final TextView percentRemaining =
|
||||
mBatteryLayoutPref.findViewById(R.id.battery_percent);
|
||||
final TextView summary1 = mBatteryLayoutPref.findViewById(R.id.summary1);
|
||||
final TextView summary2 = mBatteryLayoutPref.findViewById(R.id.summary2);
|
||||
BatteryInfo oldInfo = batteryInfos.get(0);
|
||||
BatteryInfo newInfo = batteryInfos.get(1);
|
||||
percentRemaining.setText(Utils.formatPercentage(oldInfo.batteryLevel));
|
||||
@@ -165,14 +161,13 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList
|
||||
// set the text to the old estimate (copied from battery info). Note that this
|
||||
// can sometimes say 0 time remaining because battery stats requires the phone
|
||||
// be unplugged for a period of time before being willing ot make an estimate.
|
||||
summary1.setText(mPowerFeatureProvider.getOldEstimateDebugString(
|
||||
final String OldEstimateString = mPowerFeatureProvider.getOldEstimateDebugString(
|
||||
Formatter.formatShortElapsedTime(getContext(),
|
||||
PowerUtil.convertUsToMs(oldInfo.remainingTimeUs))));
|
||||
|
||||
// for this one we can just set the string directly
|
||||
summary2.setText(mPowerFeatureProvider.getEnhancedEstimateDebugString(
|
||||
PowerUtil.convertUsToMs(oldInfo.remainingTimeUs)));
|
||||
final String NewEstimateString = mPowerFeatureProvider.getEnhancedEstimateDebugString(
|
||||
Formatter.formatShortElapsedTime(getContext(),
|
||||
PowerUtil.convertUsToMs(newInfo.remainingTimeUs))));
|
||||
PowerUtil.convertUsToMs(newInfo.remainingTimeUs)));
|
||||
summary1.setText(OldEstimateString + "\n" + NewEstimateString);
|
||||
|
||||
batteryView.setBatteryLevel(oldInfo.batteryLevel);
|
||||
batteryView.setCharging(!oldInfo.discharging);
|
||||
|
@@ -85,7 +85,6 @@ public class BatteryHeaderPreferenceControllerTest {
|
||||
private BatteryMeterView mBatteryMeterView;
|
||||
private TextView mBatteryPercentText;
|
||||
private TextView mSummary;
|
||||
private TextView mSummary2;
|
||||
private LayoutPreference mBatteryLayoutPref;
|
||||
private Intent mBatteryIntent;
|
||||
private LifecycleOwner mLifecycleOwner;
|
||||
@@ -102,7 +101,6 @@ public class BatteryHeaderPreferenceControllerTest {
|
||||
mBatteryPercentText = new TextView(mContext);
|
||||
mSummary = new TextView(mContext);
|
||||
ShadowEntityHeaderController.setUseMock(mEntityHeaderController);
|
||||
mSummary2 = new TextView(mContext);
|
||||
|
||||
mBatteryIntent = new Intent();
|
||||
mBatteryIntent.putExtra(BatteryManager.EXTRA_LEVEL, BATTERY_LEVEL);
|
||||
@@ -126,7 +124,6 @@ public class BatteryHeaderPreferenceControllerTest {
|
||||
mController.mBatteryMeterView = mBatteryMeterView;
|
||||
mController.mBatteryPercentText = mBatteryPercentText;
|
||||
mController.mSummary1 = mSummary;
|
||||
mController.mSummary2 = mSummary2;
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -190,7 +187,6 @@ public class BatteryHeaderPreferenceControllerTest {
|
||||
@Test
|
||||
public void quickUpdateHeaderPreference_onlyUpdateBatteryLevelAndChargingState() {
|
||||
mSummary.setText(BATTERY_STATUS);
|
||||
mSummary2.setText(BATTERY_STATUS);
|
||||
|
||||
mController.quickUpdateHeaderPreference();
|
||||
|
||||
@@ -198,7 +194,6 @@ public class BatteryHeaderPreferenceControllerTest {
|
||||
assertThat(mBatteryMeterView.getCharging()).isTrue();
|
||||
assertThat(mBatteryPercentText.getText().toString()).isEqualTo("60 %");
|
||||
assertThat(mSummary.getText()).isEqualTo(BATTERY_STATUS);
|
||||
assertThat(mSummary2.getText()).isEqualTo(BATTERY_STATUS);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -265,20 +265,17 @@ public class PowerUsageSummaryTest {
|
||||
}
|
||||
}).when(mFeatureFactory.powerUsageFeatureProvider).getEnhancedEstimateDebugString(any());
|
||||
|
||||
doReturn(new TextView(mRealContext)).when(mBatteryLayoutPref).findViewById(R.id.summary2);
|
||||
doReturn(new TextView(mRealContext)).when(mBatteryLayoutPref).findViewById(R.id.summary1);
|
||||
mFragment.onLongClick(new View(mRealContext));
|
||||
TextView summary1 = mFragment.mBatteryLayoutPref.findViewById(R.id.summary1);
|
||||
TextView summary2 = mFragment.mBatteryLayoutPref.findViewById(R.id.summary2);
|
||||
Robolectric.flushBackgroundThreadScheduler();
|
||||
assertThat(summary2.getText().toString()).contains(NEW_ML_EST_SUFFIX);
|
||||
assertThat(summary1.getText().toString()).contains(NEW_ML_EST_SUFFIX);
|
||||
assertThat(summary1.getText().toString()).contains(OLD_EST_SUFFIX);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void debugMode() {
|
||||
doReturn(true).when(mFeatureFactory.powerUsageFeatureProvider).isEstimateDebugEnabled();
|
||||
doReturn(new TextView(mRealContext)).when(mBatteryLayoutPref).findViewById(R.id.summary2);
|
||||
|
||||
mFragment.restartBatteryInfoLoader();
|
||||
ArgumentCaptor<View.OnLongClickListener> listener = ArgumentCaptor.forClass(
|
||||
|
Reference in New Issue
Block a user