Revert "Add animation for battery asyncLoader."
This reverts commit a3c528f64d
.
Test: Build
Change-Id: Ib50221873e39dee40c5cf8e4b41dcf7aa13f6134
This commit is contained in:
@@ -16,8 +16,6 @@
|
||||
|
||||
package com.android.settings.fuelgauge;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.app.Activity;
|
||||
import android.app.LoaderManager;
|
||||
import android.content.Context;
|
||||
@@ -50,7 +48,6 @@ import android.util.SparseArray;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
@@ -99,10 +96,6 @@ public class PowerUsageSummary extends PowerUsageBase implements
|
||||
private static final String KEY_BATTERY_HEADER = "battery_header";
|
||||
private static final int MAX_ITEMS_TO_LIST = USE_FAKE_DATA ? 30 : 10;
|
||||
private static final int MIN_AVERAGE_POWER_THRESHOLD_MILLI_AMP = 10;
|
||||
private static final int BATTERY_ANIMATION_DURATION_MS_PER_LEVEL = 30;
|
||||
|
||||
@VisibleForTesting
|
||||
static final String ARG_BATTERY_LEVEL = "key_battery_level";
|
||||
|
||||
private static final String KEY_SCREEN_USAGE = "screen_usage";
|
||||
private static final String KEY_TIME_SINCE_LAST_FULL_CHARGE = "last_full_charge";
|
||||
@@ -127,8 +120,6 @@ public class PowerUsageSummary extends PowerUsageBase implements
|
||||
private final FooterPreferenceMixin mFooterPreferenceMixin =
|
||||
new FooterPreferenceMixin(this, getLifecycle());
|
||||
|
||||
@VisibleForTesting
|
||||
int mBatteryLevel;
|
||||
@VisibleForTesting
|
||||
boolean mShowAllApps = false;
|
||||
@VisibleForTesting
|
||||
@@ -216,8 +207,6 @@ public class PowerUsageSummary extends PowerUsageBase implements
|
||||
super.onCreate(icicle);
|
||||
setAnimationAllowed(true);
|
||||
|
||||
mBatteryLevel = getContext().getResources().getInteger(
|
||||
com.android.internal.R.integer.config_criticalBatteryWarningLevel) + 1;
|
||||
mBatteryLayoutPref = (LayoutPreference) findPreference(KEY_BATTERY_HEADER);
|
||||
mAppListGroup = (PreferenceGroup) findPreference(KEY_APP_LIST);
|
||||
mScreenUsagePref = (PowerGaugePreference) findPreference(KEY_SCREEN_USAGE);
|
||||
@@ -233,14 +222,6 @@ public class PowerUsageSummary extends PowerUsageBase implements
|
||||
initializeBatteryEstimateLoader();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
if (savedInstanceState != null) {
|
||||
mBatteryLevel = savedInstanceState.getInt(ARG_BATTERY_LEVEL);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MetricsEvent.FUELGAUGE_POWER_USAGE_SUMMARY;
|
||||
@@ -249,8 +230,6 @@ public class PowerUsageSummary extends PowerUsageBase implements
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
initHeaderPreference();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -268,12 +247,6 @@ public class PowerUsageSummary extends PowerUsageBase implements
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putInt(ARG_BATTERY_LEVEL, mBatteryLevel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceTreeClick(Preference preference) {
|
||||
if (mAnomalySummaryPreferenceController.onPreferenceTreeClick(preference)) {
|
||||
@@ -703,46 +676,15 @@ public class PowerUsageSummary extends PowerUsageBase implements
|
||||
.findViewById(R.id.battery_header_icon);
|
||||
final TextView timeText = (TextView) mBatteryLayoutPref.findViewById(R.id.battery_percent);
|
||||
final TextView summary1 = (TextView) mBatteryLayoutPref.findViewById(R.id.summary1);
|
||||
timeText.setText(Utils.formatPercentage(info.batteryLevel));
|
||||
if (info.remainingLabel == null ) {
|
||||
summary1.setText(info.statusLabel);
|
||||
} else {
|
||||
summary1.setText(info.remainingLabel);
|
||||
}
|
||||
|
||||
batteryView.setBatteryLevel(info.batteryLevel);
|
||||
batteryView.setCharging(!info.discharging);
|
||||
startBatteryHeaderAnimationIfNecessary(batteryView, timeText, mBatteryLevel,
|
||||
info.batteryLevel);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void initHeaderPreference() {
|
||||
final BatteryMeterView batteryView = (BatteryMeterView) mBatteryLayoutPref
|
||||
.findViewById(R.id.battery_header_icon);
|
||||
final TextView timeText = (TextView) mBatteryLayoutPref.findViewById(R.id.battery_percent);
|
||||
|
||||
batteryView.setBatteryLevel(mBatteryLevel);
|
||||
timeText.setText(Utils.formatPercentage(mBatteryLevel));
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void startBatteryHeaderAnimationIfNecessary(BatteryMeterView batteryView, TextView timeTextView,
|
||||
int prevLevel, int currentLevel) {
|
||||
mBatteryLevel = currentLevel;
|
||||
final int diff = Math.abs(prevLevel - currentLevel);
|
||||
if (diff != 0) {
|
||||
final ValueAnimator animator = ValueAnimator.ofInt(prevLevel, currentLevel);
|
||||
animator.setDuration(BATTERY_ANIMATION_DURATION_MS_PER_LEVEL * diff);
|
||||
animator.setInterpolator(AnimationUtils.loadInterpolator(getContext(),
|
||||
android.R.interpolator.fast_out_slow_in));
|
||||
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
final Integer level = (Integer) animation.getAnimatedValue();
|
||||
batteryView.setBatteryLevel(level);
|
||||
timeTextView.setText(Utils.formatPercentage(level));
|
||||
}
|
||||
});
|
||||
animator.start();
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
Reference in New Issue
Block a user