Add BatteryTipDialogFragment.
This DialogFragment handles all the tip related dialogs. This cl makes: 1. All the tips parcelable. 2. Add dialog for HighUsageTip. It also need adapter to populate app list in dialog. 3. Add and update tests Bug: 70570352 Test: RunSettingsRoboTests Change-Id: Ie4c986172cfc73d8746abc7457d966c8600c6145
This commit is contained in:
@@ -18,6 +18,7 @@ package com.android.settings.fuelgauge.batterytip;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.support.v14.preference.PreferenceFragment;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceGroup;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
@@ -34,6 +35,9 @@ import java.util.Map;
|
||||
* Controller in charge of the battery tip group
|
||||
*/
|
||||
public class BatteryTipPreferenceController extends BasePreferenceController {
|
||||
private static final String TAG = "BatteryTipPreferenceController";
|
||||
private static final int REQUEST_ANOMALY_ACTION = 0;
|
||||
|
||||
private BatteryTipListener mBatteryTipListener;
|
||||
private List<BatteryTip> mBatteryTips;
|
||||
private Map<String, BatteryTip> mBatteryTipMap;
|
||||
@@ -41,16 +45,18 @@ public class BatteryTipPreferenceController extends BasePreferenceController {
|
||||
PreferenceGroup mPreferenceGroup;
|
||||
@VisibleForTesting
|
||||
Context mPrefContext;
|
||||
PreferenceFragment mFragment;
|
||||
|
||||
public BatteryTipPreferenceController(Context context, String preferenceKey) {
|
||||
this(context, preferenceKey, null);
|
||||
this(context, preferenceKey, null, null);
|
||||
}
|
||||
|
||||
public BatteryTipPreferenceController(Context context, String preferenceKey,
|
||||
BatteryTipListener batteryTipListener) {
|
||||
PreferenceFragment fragment, BatteryTipListener batteryTipListener) {
|
||||
super(context, preferenceKey);
|
||||
mBatteryTipListener = batteryTipListener;
|
||||
mBatteryTipMap = new HashMap<>();
|
||||
mFragment = fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -96,7 +102,10 @@ public class BatteryTipPreferenceController extends BasePreferenceController {
|
||||
final BatteryTip batteryTip = mBatteryTipMap.get(preference.getKey());
|
||||
if (batteryTip != null) {
|
||||
if (batteryTip.shouldShowDialog()) {
|
||||
// build and show the dialog
|
||||
BatteryTipDialogFragment dialogFragment = BatteryTipDialogFragment.newInstance(
|
||||
batteryTip);
|
||||
dialogFragment.setTargetFragment(mFragment, REQUEST_ANOMALY_ACTION);
|
||||
dialogFragment.show(mFragment.getFragmentManager(), TAG);
|
||||
} else {
|
||||
batteryTip.action();
|
||||
if (mBatteryTipListener != null) {
|
||||
|
||||
Reference in New Issue
Block a user