Clear static icon and label cache if ui mode is changed
we should clear icon cache if theme is changed between light and dark theme, otherwise we may show incorrect styled icon for applications Bug: 185187729 Test: make SettingsRoboTests Change-Id: Ib06abe5a5345b2ea363a04ecaec886a4765fd8ab
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package com.android.settings.fuelgauge;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
@@ -39,6 +40,7 @@ import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
import com.android.settingslib.core.lifecycle.events.OnCreate;
|
||||
import com.android.settingslib.core.lifecycle.events.OnDestroy;
|
||||
import com.android.settingslib.core.lifecycle.events.OnResume;
|
||||
import com.android.settingslib.core.lifecycle.events.OnSaveInstanceState;
|
||||
import com.android.settingslib.utils.StringUtil;
|
||||
|
||||
@@ -53,7 +55,7 @@ import java.util.Map;
|
||||
/** Controls the update for chart graph and the list items. */
|
||||
public class BatteryChartPreferenceController extends AbstractPreferenceController
|
||||
implements PreferenceControllerMixin, LifecycleObserver, OnCreate, OnDestroy,
|
||||
OnSaveInstanceState, BatteryChartView.OnSelectListener,
|
||||
OnSaveInstanceState, BatteryChartView.OnSelectListener, OnResume,
|
||||
ExpandDividerPreference.OnExpandListener {
|
||||
private static final String TAG = "BatteryChartPreferenceController";
|
||||
/** Desired battery history size for timestamp slots. */
|
||||
@@ -67,6 +69,8 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
|
||||
private static final String KEY_EXPAND_SYSTEM_INFO = "expand_system_info";
|
||||
private static final String KEY_CURRENT_TIME_SLOT = "current_time_slot";
|
||||
|
||||
private static int sUiMode = Configuration.UI_MODE_NIGHT_UNDEFINED;
|
||||
|
||||
@VisibleForTesting
|
||||
Map<Integer, List<BatteryDiffEntry>> mBatteryIndexedMap;
|
||||
|
||||
@@ -124,6 +128,18 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
|
||||
mTrapezoidIndex, mIsExpanded));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
final int currentUiMode =
|
||||
mContext.getResources().getConfiguration().uiMode
|
||||
& Configuration.UI_MODE_NIGHT_MASK;
|
||||
if (sUiMode != currentUiMode) {
|
||||
sUiMode = currentUiMode;
|
||||
BatteryDiffEntry.clearCache();
|
||||
Log.d(TAG, "clear icon and label cache since uiMode is changed");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle savedInstance) {
|
||||
if (savedInstance == null) {
|
||||
|
Reference in New Issue
Block a user