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