Migrate more settings to SubSettingsLauncher
Bug: 73250851 Test: robotests Change-Id: I4100bef20e2ed477e4e31c9b7816f1b03f3f2809
This commit is contained in:
@@ -75,7 +75,6 @@ import com.android.settingslib.drawer.SettingsDrawerActivity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class SettingsActivity extends SettingsDrawerActivity
|
||||
implements PreferenceManager.OnPreferenceTreeClickListener,
|
||||
@@ -157,10 +156,6 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
private CharSequence mInitialTitle;
|
||||
private int mInitialTitleResId;
|
||||
|
||||
private static final String[] LIKE_SHORTCUT_INTENT_ACTION_ARRAY = {
|
||||
"android.settings.APPLICATION_DETAILS_SETTINGS"
|
||||
};
|
||||
|
||||
private BroadcastReceiver mDevelopmentSettingsListener;
|
||||
|
||||
private boolean mBatteryPresent = true;
|
||||
@@ -184,12 +179,9 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
private Button mNextButton;
|
||||
|
||||
private boolean mIsShowingDashboard;
|
||||
private boolean mIsShortcut;
|
||||
|
||||
private ViewGroup mContent;
|
||||
|
||||
private MetricsFeatureProvider mMetricsFeatureProvider;
|
||||
|
||||
// Categories
|
||||
private ArrayList<DashboardCategory> mCategories = new ArrayList<>();
|
||||
|
||||
@@ -237,22 +229,6 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
return tag;
|
||||
}
|
||||
|
||||
private static boolean isShortCutIntent(final Intent intent) {
|
||||
Set<String> categories = intent.getCategories();
|
||||
return (categories != null) && categories.contains("com.android.settings.SHORTCUT");
|
||||
}
|
||||
|
||||
private static boolean isLikeShortCutIntent(final Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if (action == null) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < LIKE_SHORTCUT_INTENT_ACTION_ARRAY.length; i++) {
|
||||
if (LIKE_SHORTCUT_INTENT_ACTION_ARRAY[i].equals(action)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedState) {
|
||||
super.onCreate(savedState);
|
||||
@@ -261,7 +237,6 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
final FeatureFactory factory = FeatureFactory.getFactory(this);
|
||||
|
||||
mDashboardFeatureProvider = factory.getDashboardFeatureProvider(this);
|
||||
mMetricsFeatureProvider = factory.getMetricsFeatureProvider();
|
||||
|
||||
// Should happen before any call to getIntent()
|
||||
getMetaData();
|
||||
@@ -274,9 +249,6 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
// Getting Intent properties can only be done after the super.onCreate(...)
|
||||
final String initialFragmentName = intent.getStringExtra(EXTRA_SHOW_FRAGMENT);
|
||||
|
||||
mIsShortcut = isShortCutIntent(intent) || isLikeShortCutIntent(intent) ||
|
||||
intent.getBooleanExtra(EXTRA_SHOW_FRAGMENT_AS_SHORTCUT, false);
|
||||
|
||||
final ComponentName cn = intent.getComponent();
|
||||
final String className = cn.getClassName();
|
||||
|
||||
@@ -583,74 +555,6 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
return intentClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start a new fragment containing a preference panel. If the preferences
|
||||
* are being displayed in multi-pane mode, the given fragment class will
|
||||
* be instantiated and placed in the appropriate pane. If running in
|
||||
* single-pane mode, a new activity will be launched in which to show the
|
||||
* fragment.
|
||||
*
|
||||
* @param fragmentClass Full name of the class implementing the fragment.
|
||||
* @param args Any desired arguments to supply to the fragment.
|
||||
* @param titleRes Optional resource identifier of the title of this
|
||||
* fragment.
|
||||
* @param titleText Optional text of the title of this fragment.
|
||||
* @param resultTo Optional fragment that result data should be sent to.
|
||||
* If non-null, resultTo.onActivityResult() will be called when this
|
||||
* preference panel is done. The launched panel must use
|
||||
* {@link #finishPreferencePanel(Fragment, int, Intent)} when done.
|
||||
* @param resultRequestCode If resultTo is non-null, this is the caller's
|
||||
* request code to be received with the result.
|
||||
*/
|
||||
@Deprecated
|
||||
public void startPreferencePanel(Fragment caller, String fragmentClass, Bundle args,
|
||||
int titleRes, CharSequence titleText, Fragment resultTo, int resultRequestCode) {
|
||||
String title = null;
|
||||
if (titleRes < 0 && titleText != null) {
|
||||
title = titleText.toString();
|
||||
}
|
||||
Utils.startWithFragment(this, fragmentClass, args, resultTo, resultRequestCode,
|
||||
titleRes, title, mIsShortcut, mMetricsFeatureProvider.getMetricsCategory(caller));
|
||||
}
|
||||
|
||||
/**
|
||||
* Start a new fragment in a new activity containing a preference panel for a given user. If the
|
||||
* preferences are being displayed in multi-pane mode, the given fragment class will be
|
||||
* instantiated and placed in the appropriate pane. If running in single-pane mode, a new
|
||||
* activity will be launched in which to show the fragment.
|
||||
*
|
||||
* @param fragmentClass Full name of the class implementing the fragment.
|
||||
* @param args Any desired arguments to supply to the fragment.
|
||||
* @param titleRes Optional resource identifier of the title of this fragment.
|
||||
* @param userHandle The user for which the panel has to be started.
|
||||
*/
|
||||
public void startPreferencePanelAsUser(Fragment caller, String fragmentClass,
|
||||
Bundle args, int titleRes, UserHandle userHandle) {
|
||||
// This is a workaround.
|
||||
//
|
||||
// Calling startWithFragmentAsUser() without specifying FLAG_ACTIVITY_NEW_TASK to the intent
|
||||
// starting the fragment could cause a native stack corruption. See b/17523189. However,
|
||||
// adding that flag and start the preference panel with the same UserHandler will make it
|
||||
// impossible to use back button to return to the previous screen. See b/20042570.
|
||||
//
|
||||
// We work around this issue by adding FLAG_ACTIVITY_NEW_TASK to the intent, while doing
|
||||
// another check here to call startPreferencePanel() instead of startWithFragmentAsUser()
|
||||
// when we're calling it as the same user.
|
||||
if (userHandle.getIdentifier() == UserHandle.myUserId()) {
|
||||
startPreferencePanel(caller, fragmentClass, args, titleRes, null /* titleText */,
|
||||
null, 0);
|
||||
} else {
|
||||
new SubSettingLauncher(this)
|
||||
.setDestination(fragmentClass)
|
||||
.setArguments(args)
|
||||
.setTitle(titleRes)
|
||||
.setIsShortCut(mIsShortcut)
|
||||
.setSourceMetricsCategory(mMetricsFeatureProvider.getMetricsCategory(caller))
|
||||
.setUserHandle(userHandle)
|
||||
.launch();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by a preference panel fragment to finish itself.
|
||||
*
|
||||
|
@@ -16,22 +16,22 @@
|
||||
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.support.v14.preference.PreferenceFragment;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.view.Menu;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.search.actionbar.SearchMenuController;
|
||||
import com.android.settings.support.actionbar.HelpResourceProvider;
|
||||
import com.android.settingslib.core.instrumentation.Instrumentable;
|
||||
|
||||
public class AccessibilitySettingsForSetupWizardActivity extends SettingsActivity {
|
||||
|
||||
private static final String SAVE_KEY_TITLE = "activity_title";
|
||||
|
||||
private boolean mSendExtraWindowStateChanged;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedState) {
|
||||
super.onCreate(savedState);
|
||||
@@ -52,12 +52,6 @@ public class AccessibilitySettingsForSetupWizardActivity extends SettingsActivit
|
||||
setTitle(savedState.getCharSequence(SAVE_KEY_TITLE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mSendExtraWindowStateChanged = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Return true, so we get notified when items in the menu are clicked.
|
||||
@@ -76,28 +70,20 @@ public class AccessibilitySettingsForSetupWizardActivity extends SettingsActivit
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startPreferencePanel(Fragment caller, String fragmentClass, Bundle args,
|
||||
int titleRes, CharSequence titleText, Fragment resultTo, int resultRequestCode) {
|
||||
// Set the title.
|
||||
if (!TextUtils.isEmpty(titleText)) {
|
||||
setTitle(titleText);
|
||||
} else if (titleRes > 0) {
|
||||
setTitle(getString(titleRes));
|
||||
public boolean onPreferenceStartFragment(PreferenceFragment caller, Preference pref) {
|
||||
Bundle args = pref.getExtras();
|
||||
if (args == null) {
|
||||
args = new Bundle();
|
||||
}
|
||||
|
||||
// Start the new Fragment.
|
||||
args.putInt(HelpResourceProvider.HELP_URI_RESOURCE_KEY, 0);
|
||||
args.putBoolean(SearchMenuController.NEED_SEARCH_ICON_IN_ACTION_BAR, false);
|
||||
startPreferenceFragment(Fragment.instantiate(this, fragmentClass, args), true);
|
||||
mSendExtraWindowStateChanged = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachFragment(Fragment fragment) {
|
||||
if (mSendExtraWindowStateChanged) {
|
||||
// Clear accessibility focus and let the screen reader announce the new title.
|
||||
getWindow().getDecorView()
|
||||
.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
|
||||
}
|
||||
new SubSettingLauncher(this)
|
||||
.setDestination(pref.getFragment())
|
||||
.setArguments(args)
|
||||
.setSourceMetricsCategory(caller instanceof Instrumentable
|
||||
? ((Instrumentable) caller).getMetricsCategory()
|
||||
: Instrumentable.METRICS_CATEGORY_UNKNOWN)
|
||||
.launch();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -15,17 +15,16 @@
|
||||
*/
|
||||
package com.android.settings.bluetooth;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.os.UserHandle;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.core.InstrumentedPreferenceFragment;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.widget.MasterSwitchController;
|
||||
import com.android.settings.widget.MasterSwitchPreference;
|
||||
@@ -50,27 +49,22 @@ public class BluetoothMasterSwitchPreferenceController extends AbstractPreferenc
|
||||
private BluetoothEnabler mBluetoothEnabler;
|
||||
private BluetoothSummaryUpdater mSummaryUpdater;
|
||||
private RestrictionUtils mRestrictionUtils;
|
||||
private Fragment mFragment;
|
||||
private SettingsActivity mActivity;
|
||||
private BluetoothFeatureProvider mBluetoothFeatureProvider;
|
||||
private InstrumentedPreferenceFragment mFragment;
|
||||
|
||||
public BluetoothMasterSwitchPreferenceController(Context context,
|
||||
LocalBluetoothManager bluetoothManager, Fragment fragment, SettingsActivity activity) {
|
||||
this(context, bluetoothManager, new RestrictionUtils(), fragment, activity);
|
||||
LocalBluetoothManager bluetoothManager, InstrumentedPreferenceFragment fragment) {
|
||||
this(context, bluetoothManager, new RestrictionUtils(), fragment);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public BluetoothMasterSwitchPreferenceController(Context context,
|
||||
LocalBluetoothManager bluetoothManager, RestrictionUtils restrictionUtils,
|
||||
Fragment fragment, SettingsActivity activity) {
|
||||
InstrumentedPreferenceFragment fragment) {
|
||||
super(context);
|
||||
mBluetoothManager = bluetoothManager;
|
||||
mSummaryUpdater = new BluetoothSummaryUpdater(mContext, this, mBluetoothManager);
|
||||
mRestrictionUtils = restrictionUtils;
|
||||
mFragment = fragment;
|
||||
mActivity = activity;
|
||||
mBluetoothFeatureProvider = FeatureFactory.getFactory(
|
||||
mContext).getBluetoothFeatureProvider(mContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -87,8 +81,11 @@ public class BluetoothMasterSwitchPreferenceController extends AbstractPreferenc
|
||||
@Override
|
||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
||||
if (KEY_TOGGLE_BLUETOOTH.equals(preference.getKey())) {
|
||||
mActivity.startPreferencePanelAsUser(mFragment, BluetoothSettings.class.getName(), null,
|
||||
R.string.bluetooth, new UserHandle(UserHandle.myUserId()));
|
||||
new SubSettingLauncher(mContext)
|
||||
.setDestination(BluetoothSettings.class.getName())
|
||||
.setTitle(R.string.bluetooth)
|
||||
.setSourceMetricsCategory(mFragment.getMetricsCategory())
|
||||
.launch();
|
||||
return true;
|
||||
}
|
||||
return super.handlePreferenceTreeClick(preference);
|
||||
|
@@ -17,13 +17,12 @@
|
||||
package com.android.settings.bluetooth;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v14.preference.PreferenceFragment;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.os.UserHandle;
|
||||
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
|
||||
|
||||
@@ -35,15 +34,12 @@ public class BluetoothPairingPreferenceController extends AbstractPreferenceCont
|
||||
private static final String TAG = "BluetoothPairingPrefCtrl";
|
||||
|
||||
public static final String KEY_PAIRING = "pref_bt_pairing";
|
||||
private PreferenceFragment mFragment;
|
||||
private SettingsActivity mActivity;
|
||||
private DashboardFragment mFragment;
|
||||
private Preference mPreference;
|
||||
|
||||
public BluetoothPairingPreferenceController(Context context, PreferenceFragment fragment,
|
||||
SettingsActivity activity) {
|
||||
public BluetoothPairingPreferenceController(Context context, DashboardFragment fragment) {
|
||||
super(context);
|
||||
mFragment = fragment;
|
||||
mActivity = activity;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -59,9 +55,12 @@ public class BluetoothPairingPreferenceController extends AbstractPreferenceCont
|
||||
@Override
|
||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
||||
if (KEY_PAIRING.equals(preference.getKey())) {
|
||||
mActivity.startPreferencePanelAsUser(mFragment, BluetoothPairingDetail.class.getName(),
|
||||
null, R.string.bluetooth_pairing_page_title,
|
||||
new UserHandle(UserHandle.myUserId()));
|
||||
new SubSettingLauncher(mContext)
|
||||
.setDestination(BluetoothPairingDetail.class.getName())
|
||||
.setTitle(R.string.bluetooth_pairing_page_title)
|
||||
.setSourceMetricsCategory(mFragment.getMetricsCategory())
|
||||
.launch();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -367,8 +367,7 @@ public class BluetoothSettings extends DeviceListPreferenceFragment implements I
|
||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||
final Lifecycle lifecycle = getLifecycle();
|
||||
mDeviceNamePrefController = new BluetoothDeviceNamePreferenceController(context, lifecycle);
|
||||
mPairingPrefController = new BluetoothPairingPreferenceController(context, this,
|
||||
(SettingsActivity) getActivity());
|
||||
mPairingPrefController = new BluetoothPairingPreferenceController(context, this);
|
||||
controllers.add(mDeviceNamePrefController);
|
||||
controllers.add(mPairingPrefController);
|
||||
controllers.add(new BluetoothFilesPreferenceController(context));
|
||||
|
@@ -23,7 +23,6 @@ import android.support.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.bluetooth.BluetoothMasterSwitchPreferenceController;
|
||||
import com.android.settings.bluetooth.Utils;
|
||||
import com.android.settings.connecteddevice.usb.UsbBackend;
|
||||
@@ -31,7 +30,6 @@ import com.android.settings.connecteddevice.usb.UsbModePreferenceController;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.dashboard.SummaryLoader;
|
||||
import com.android.settings.nfc.NfcPreferenceController;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
@@ -85,8 +83,7 @@ public class ConnectedDeviceDashboardFragmentOld extends DashboardFragment {
|
||||
controllers.add(mUsbPrefController);
|
||||
final BluetoothMasterSwitchPreferenceController bluetoothPreferenceController =
|
||||
new BluetoothMasterSwitchPreferenceController(
|
||||
context, Utils.getLocalBtManager(context), this,
|
||||
(SettingsActivity) getActivity());
|
||||
context, Utils.getLocalBtManager(context), this);
|
||||
lifecycle.addObserver(bluetoothPreferenceController);
|
||||
controllers.add(bluetoothPreferenceController);
|
||||
|
||||
|
@@ -30,7 +30,6 @@ import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.support.v14.preference.PreferenceFragment;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
@@ -44,6 +43,8 @@ import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.core.InstrumentedPreferenceFragment;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.fuelgauge.anomaly.Anomaly;
|
||||
import com.android.settings.fuelgauge.anomaly.AnomalyDialogFragment;
|
||||
@@ -74,7 +75,7 @@ public class AdvancedPowerUsageDetail extends DashboardFragment implements
|
||||
LoaderManager.LoaderCallbacks<List<Anomaly>>,
|
||||
BatteryTipPreferenceController.BatteryTipListener {
|
||||
|
||||
public static final String TAG = "AdvancedPowerUsageDetail";
|
||||
public static final String TAG = "AdvancedPowerDetail";
|
||||
public static final String EXTRA_UID = "extra_uid";
|
||||
public static final String EXTRA_PACKAGE_NAME = "extra_package_name";
|
||||
public static final String EXTRA_FOREGROUND_TIME = "extra_foreground_time";
|
||||
@@ -122,9 +123,9 @@ public class AdvancedPowerUsageDetail extends DashboardFragment implements
|
||||
private String mPackageName;
|
||||
|
||||
@VisibleForTesting
|
||||
static void startBatteryDetailPage(SettingsActivity caller, BatteryUtils batteryUtils,
|
||||
PreferenceFragment fragment, BatteryStatsHelper helper, int which, BatteryEntry entry,
|
||||
String usagePercent, List<Anomaly> anomalies) {
|
||||
static void startBatteryDetailPage(Activity caller, BatteryUtils batteryUtils,
|
||||
InstrumentedPreferenceFragment fragment, BatteryStatsHelper helper, int which,
|
||||
BatteryEntry entry, String usagePercent, List<Anomaly> anomalies) {
|
||||
// Initialize mStats if necessary.
|
||||
helper.getStats();
|
||||
|
||||
@@ -157,9 +158,13 @@ public class AdvancedPowerUsageDetail extends DashboardFragment implements
|
||||
args.putInt(EXTRA_POWER_USAGE_AMOUNT, (int) sipper.totalPowerMah);
|
||||
args.putParcelableList(EXTRA_ANOMALY_LIST, anomalies);
|
||||
|
||||
caller.startPreferencePanelAsUser(fragment, AdvancedPowerUsageDetail.class.getName(), args,
|
||||
R.string.battery_details_title,
|
||||
new UserHandle(getUserIdToLaunchAdvancePowerUsageDetail(sipper)));
|
||||
new SubSettingLauncher(caller)
|
||||
.setDestination(AdvancedPowerUsageDetail.class.getName())
|
||||
.setTitle(R.string.battery_details_title)
|
||||
.setArguments(args)
|
||||
.setSourceMetricsCategory(fragment.getMetricsCategory())
|
||||
.setUserHandle(new UserHandle(getUserIdToLaunchAdvancePowerUsageDetail(sipper)))
|
||||
.launch();
|
||||
}
|
||||
|
||||
private static @UserIdInt int getUserIdToLaunchAdvancePowerUsageDetail(BatterySipper bs) {
|
||||
@@ -169,15 +174,15 @@ public class AdvancedPowerUsageDetail extends DashboardFragment implements
|
||||
return UserHandle.getUserId(bs.getUid());
|
||||
}
|
||||
|
||||
public static void startBatteryDetailPage(SettingsActivity caller, PreferenceFragment fragment,
|
||||
BatteryStatsHelper helper, int which, BatteryEntry entry, String usagePercent,
|
||||
List<Anomaly> anomalies) {
|
||||
public static void startBatteryDetailPage(Activity caller,
|
||||
InstrumentedPreferenceFragment fragment, BatteryStatsHelper helper, int which,
|
||||
BatteryEntry entry, String usagePercent, List<Anomaly> anomalies) {
|
||||
startBatteryDetailPage(caller, BatteryUtils.getInstance(caller), fragment, helper, which,
|
||||
entry, usagePercent, anomalies);
|
||||
}
|
||||
|
||||
public static void startBatteryDetailPage(SettingsActivity caller, PreferenceFragment fragment,
|
||||
String packageName) {
|
||||
public static void startBatteryDetailPage(Activity caller,
|
||||
InstrumentedPreferenceFragment fragment, String packageName) {
|
||||
final Bundle args = new Bundle(3);
|
||||
final PackageManager packageManager = caller.getPackageManager();
|
||||
args.putString(EXTRA_PACKAGE_NAME, packageName);
|
||||
@@ -188,8 +193,12 @@ public class AdvancedPowerUsageDetail extends DashboardFragment implements
|
||||
Log.e(TAG, "Cannot find package: " + packageName, e);
|
||||
}
|
||||
|
||||
caller.startPreferencePanelAsUser(fragment, AdvancedPowerUsageDetail.class.getName(), args,
|
||||
R.string.battery_details_title, new UserHandle(UserHandle.myUserId()));
|
||||
new SubSettingLauncher(caller)
|
||||
.setDestination(AdvancedPowerUsageDetail.class.getName())
|
||||
.setTitle(R.string.battery_details_title)
|
||||
.setArguments(args)
|
||||
.setSourceMetricsCategory(fragment.getMetricsCategory())
|
||||
.launch();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -210,7 +219,7 @@ public class AdvancedPowerUsageDetail extends DashboardFragment implements
|
||||
|
||||
mPackageName = getArguments().getString(EXTRA_PACKAGE_NAME);
|
||||
mAnomalySummaryPreferenceController = new AnomalySummaryPreferenceController(
|
||||
(SettingsActivity) getActivity(), this, MetricsEvent.FUELGAUGE_POWER_USAGE_DETAIL);
|
||||
(SettingsActivity) getActivity(), this);
|
||||
mForegroundPreference = findPreference(KEY_PREF_FOREGROUND);
|
||||
mBackgroundPreference = findPreference(KEY_PREF_BACKGROUND);
|
||||
mPowerUsagePreference = findPreference(KEY_PREF_POWER_USAGE);
|
||||
|
@@ -27,7 +27,6 @@ import android.os.Process;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
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;
|
||||
@@ -45,6 +44,7 @@ import com.android.internal.os.PowerProfile;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.core.FeatureFlags;
|
||||
import com.android.settings.core.InstrumentedPreferenceFragment;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.fuelgauge.anomaly.Anomaly;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
@@ -52,8 +52,8 @@ import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
import com.android.settingslib.core.lifecycle.events.OnDestroy;
|
||||
import com.android.settingslib.core.lifecycle.events.OnPause;
|
||||
|
||||
import com.android.settingslib.utils.StringUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -77,7 +77,7 @@ public class BatteryAppListPreferenceController extends AbstractPreferenceContro
|
||||
BatteryUtils mBatteryUtils;
|
||||
private UserManager mUserManager;
|
||||
private SettingsActivity mActivity;
|
||||
private PreferenceFragment mFragment;
|
||||
private InstrumentedPreferenceFragment mFragment;
|
||||
private Context mPrefContext;
|
||||
SparseArray<List<Anomaly>> mAnomalySparseArray;
|
||||
|
||||
@@ -112,7 +112,8 @@ public class BatteryAppListPreferenceController extends AbstractPreferenceContro
|
||||
};
|
||||
|
||||
public BatteryAppListPreferenceController(Context context, String preferenceKey,
|
||||
Lifecycle lifecycle, SettingsActivity activity, PreferenceFragment fragment) {
|
||||
Lifecycle lifecycle, SettingsActivity activity,
|
||||
InstrumentedPreferenceFragment fragment) {
|
||||
super(context);
|
||||
|
||||
if (lifecycle != null) {
|
||||
|
@@ -21,7 +21,6 @@ import android.content.pm.PackageManager;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.support.v14.preference.PreferenceFragment;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceGroup;
|
||||
import android.util.IconDrawableFactory;
|
||||
@@ -31,6 +30,8 @@ import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.core.InstrumentedPreferenceFragment;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.fuelgauge.anomaly.Anomaly;
|
||||
import com.android.settings.fuelgauge.anomaly.AnomalyDialogFragment;
|
||||
@@ -63,12 +64,16 @@ public class PowerUsageAnomalyDetails extends DashboardFragment implements
|
||||
IconDrawableFactory mIconDrawableFactory;
|
||||
|
||||
public static void startBatteryAbnormalPage(SettingsActivity caller,
|
||||
PreferenceFragment fragment, List<Anomaly> anomalies) {
|
||||
InstrumentedPreferenceFragment fragment, List<Anomaly> anomalies) {
|
||||
Bundle args = new Bundle();
|
||||
args.putParcelableList(EXTRA_ANOMALY_LIST, anomalies);
|
||||
|
||||
caller.startPreferencePanelAsUser(fragment, PowerUsageAnomalyDetails.class.getName(), args,
|
||||
R.string.battery_abnormal_details_title, new UserHandle(UserHandle.myUserId()));
|
||||
new SubSettingLauncher(caller)
|
||||
.setDestination(PowerUsageAnomalyDetails.class.getName())
|
||||
.setTitle(R.string.battery_abnormal_details_title)
|
||||
.setArguments(args)
|
||||
.setSourceMetricsCategory(fragment.getMetricsCategory())
|
||||
.launch();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -243,7 +243,7 @@ public class PowerUsageSummaryLegacy extends PowerUsageBase implements
|
||||
KEY_TIME_SINCE_LAST_FULL_CHARGE);
|
||||
mFooterPreferenceMixin.createFooterPreference().setTitle(R.string.battery_footer_summary);
|
||||
mAnomalySummaryPreferenceController = new AnomalySummaryPreferenceController(
|
||||
(SettingsActivity) getActivity(), this, MetricsEvent.FUELGAUGE_POWER_USAGE_SUMMARY);
|
||||
(SettingsActivity) getActivity(), this);
|
||||
mBatteryUtils = BatteryUtils.getInstance(getContext());
|
||||
mAnomalySparseArray = new SparseArray<>();
|
||||
|
||||
|
@@ -20,13 +20,12 @@ package com.android.settings.fuelgauge;
|
||||
import android.app.AppOpsManager;
|
||||
import android.content.Context;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.support.v14.preference.PreferenceFragment;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.core.InstrumentedPreferenceFragment;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -40,7 +39,7 @@ public class RestrictAppPreferenceController extends BasePreferenceController {
|
||||
private AppOpsManager mAppOpsManager;
|
||||
private List<AppOpsManager.PackageOps> mPackageOps;
|
||||
private SettingsActivity mSettingsActivity;
|
||||
private PreferenceFragment mPreferenceFragment;
|
||||
private InstrumentedPreferenceFragment mPreferenceFragment;
|
||||
|
||||
public RestrictAppPreferenceController(Context context) {
|
||||
super(context, KEY_RESTRICT_APP);
|
||||
@@ -48,7 +47,7 @@ public class RestrictAppPreferenceController extends BasePreferenceController {
|
||||
}
|
||||
|
||||
public RestrictAppPreferenceController(SettingsActivity settingsActivity,
|
||||
PreferenceFragment preferenceFragment) {
|
||||
InstrumentedPreferenceFragment preferenceFragment) {
|
||||
this(settingsActivity.getApplicationContext());
|
||||
mSettingsActivity = settingsActivity;
|
||||
mPreferenceFragment = preferenceFragment;
|
||||
|
@@ -22,7 +22,6 @@ import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.support.v14.preference.PreferenceFragment;
|
||||
import android.support.v7.preference.CheckBoxPreference;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceGroup;
|
||||
@@ -33,6 +32,8 @@ import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.core.InstrumentedPreferenceFragment;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.widget.AppCheckBoxPreference;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
@@ -61,13 +62,16 @@ public class RestrictedAppDetails extends DashboardFragment {
|
||||
PackageManager mPackageManager;
|
||||
|
||||
public static void startRestrictedAppDetails(SettingsActivity caller,
|
||||
PreferenceFragment fragment, List<AppOpsManager.PackageOps> packageOpsList) {
|
||||
Bundle args = new Bundle();
|
||||
InstrumentedPreferenceFragment fragment, List<AppOpsManager.PackageOps> packageOpsList) {
|
||||
final Bundle args = new Bundle();
|
||||
args.putParcelableList(EXTRA_PACKAGE_OPS_LIST, packageOpsList);
|
||||
|
||||
caller.startPreferencePanelAsUser(fragment, RestrictedAppDetails.class.getName(), args,
|
||||
R.string.restricted_app_title,
|
||||
new UserHandle(UserHandle.myUserId()));
|
||||
new SubSettingLauncher(caller)
|
||||
.setDestination(RestrictedAppDetails.class.getName())
|
||||
.setArguments(args)
|
||||
.setTitle(R.string.restricted_app_title)
|
||||
.setSourceMetricsCategory(fragment.getMetricsCategory())
|
||||
.launch();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -19,11 +19,11 @@ package com.android.settings.fuelgauge;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.support.v14.preference.PreferenceFragment;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.core.InstrumentedPreferenceFragment;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
@@ -69,7 +69,8 @@ public class SmartBatterySettings extends DashboardFragment {
|
||||
}
|
||||
|
||||
private static List<AbstractPreferenceController> buildPreferenceControllers(
|
||||
Context context, SettingsActivity settingsActivity, PreferenceFragment fragment) {
|
||||
Context context, SettingsActivity settingsActivity,
|
||||
InstrumentedPreferenceFragment fragment) {
|
||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||
controllers.add(new SmartBatteryPreferenceController(context));
|
||||
if (settingsActivity != null && fragment != null) {
|
||||
|
@@ -18,11 +18,11 @@ package com.android.settings.fuelgauge.anomaly;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.support.v14.preference.PreferenceFragment;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.core.InstrumentedPreferenceFragment;
|
||||
import com.android.settings.fuelgauge.BatteryUtils;
|
||||
import com.android.settings.fuelgauge.PowerUsageAnomalyDetails;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class AnomalySummaryPreferenceController {
|
||||
public static final String ANOMALY_KEY = "high_usage";
|
||||
|
||||
private static final int REQUEST_ANOMALY_ACTION = 0;
|
||||
private PreferenceFragment mFragment;
|
||||
private InstrumentedPreferenceFragment mFragment;
|
||||
@VisibleForTesting
|
||||
Preference mAnomalyPreference;
|
||||
@VisibleForTesting
|
||||
@@ -54,11 +54,11 @@ public class AnomalySummaryPreferenceController {
|
||||
private int mMetricsKey;
|
||||
|
||||
public AnomalySummaryPreferenceController(SettingsActivity activity,
|
||||
PreferenceFragment fragment, int metricsKey) {
|
||||
InstrumentedPreferenceFragment fragment) {
|
||||
mFragment = fragment;
|
||||
mSettingsActivity = activity;
|
||||
mAnomalyPreference = mFragment.getPreferenceScreen().findPreference(ANOMALY_KEY);
|
||||
mMetricsKey = metricsKey;
|
||||
mMetricsKey = fragment.getMetricsCategory();
|
||||
mBatteryUtils = BatteryUtils.getInstance(activity.getApplicationContext());
|
||||
hideHighUsagePreference();
|
||||
}
|
||||
|
@@ -17,11 +17,12 @@
|
||||
package com.android.settings.fuelgauge.batterytip.actions;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.os.UserHandle;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.fuelgauge.SmartBatterySettings;
|
||||
import com.android.settingslib.core.instrumentation.Instrumentable;
|
||||
|
||||
public class SmartBatteryAction extends BatteryTipAction {
|
||||
private SettingsActivity mSettingsActivity;
|
||||
@@ -38,9 +39,13 @@ public class SmartBatteryAction extends BatteryTipAction {
|
||||
*/
|
||||
@Override
|
||||
public void handlePositiveAction() {
|
||||
mSettingsActivity.startPreferencePanelAsUser(mFragment,
|
||||
SmartBatterySettings.class.getName(), null /* args */,
|
||||
R.string.smart_battery_manager_title,
|
||||
new UserHandle(UserHandle.myUserId()));
|
||||
new SubSettingLauncher(mSettingsActivity)
|
||||
.setSourceMetricsCategory(mFragment instanceof Instrumentable
|
||||
? ((Instrumentable) mFragment).getMetricsCategory()
|
||||
: Instrumentable.METRICS_CATEGORY_UNKNOWN)
|
||||
.setDestination(SmartBatterySettings.class.getName())
|
||||
.setTitle(R.string.smart_battery_manager_title)
|
||||
.launch();
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -22,8 +22,8 @@ import android.support.v7.preference.PreferenceCategory;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.applications.appinfo.AppInfoDashboardFragment;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.widget.AppPreference;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.location.RecentLocationApps;
|
||||
@@ -57,10 +57,14 @@ public class RecentLocationRequestPreferenceController extends LocationBasePrefe
|
||||
// start new fragment to display extended information
|
||||
final Bundle args = new Bundle();
|
||||
args.putString(AppInfoDashboardFragment.ARG_PACKAGE_NAME, mPackage);
|
||||
((SettingsActivity) mFragment.getActivity()).startPreferencePanelAsUser(
|
||||
mFragment,
|
||||
AppInfoDashboardFragment.class.getName(), args,
|
||||
R.string.application_info_label, mUserHandle);
|
||||
|
||||
new SubSettingLauncher(mFragment.getContext())
|
||||
.setDestination(AppInfoDashboardFragment.class.getName())
|
||||
.setArguments(args)
|
||||
.setTitle(R.string.application_info_label)
|
||||
.setUserHandle(mUserHandle)
|
||||
.setSourceMetricsCategory(mFragment.getMetricsCategory())
|
||||
.launch();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user