Migrate more places to subsetting launcher
Bug: 73250851 Test: robotests Change-Id: Iaf29df45ddb42fd58f181cb01e10998a97cb7c34
This commit is contained in:
@@ -67,7 +67,6 @@ import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.wfd.WifiDisplaySettings;
|
||||
import com.android.settings.widget.SwitchBar;
|
||||
import com.android.settingslib.core.instrumentation.Instrumentable;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
import com.android.settingslib.core.instrumentation.SharedPreferencesLogger;
|
||||
import com.android.settingslib.development.DevelopmentSettingsEnabler;
|
||||
import com.android.settingslib.drawer.DashboardCategory;
|
||||
@@ -558,36 +557,16 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
/**
|
||||
* Called by a preference panel fragment to finish itself.
|
||||
*
|
||||
* @param caller The fragment that is asking to be finished.
|
||||
* @param resultCode Optional result code to send back to the original
|
||||
* launching fragment.
|
||||
* @param resultData Optional result data to send back to the original
|
||||
* launching fragment.
|
||||
*/
|
||||
public void finishPreferencePanel(Fragment caller, int resultCode, Intent resultData) {
|
||||
public void finishPreferencePanel(int resultCode, Intent resultData) {
|
||||
setResult(resultCode, resultData);
|
||||
finish();
|
||||
}
|
||||
|
||||
/**
|
||||
* Start a new fragment.
|
||||
*
|
||||
* @param fragment The fragment to start
|
||||
* @param push If true, the current fragment will be pushed onto the back stack. If false,
|
||||
* the current fragment will be replaced.
|
||||
*/
|
||||
public void startPreferenceFragment(Fragment fragment, boolean push) {
|
||||
FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
||||
transaction.replace(R.id.main_content, fragment);
|
||||
if (push) {
|
||||
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
|
||||
transaction.addToBackStack(BACK_STACK_PREFS);
|
||||
} else {
|
||||
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
|
||||
}
|
||||
transaction.commitAllowingStateLoss();
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch to a specific Fragment with taking care of validation, Title and BackStack
|
||||
*/
|
||||
|
@@ -388,71 +388,6 @@ public final class Utils extends com.android.settingslib.Utils {
|
||||
.getUsers().size() > 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start a new instance of the activity, showing only the given fragment.
|
||||
* When launched in this mode, the given preference fragment will be instantiated and fill the
|
||||
* entire activity.
|
||||
*
|
||||
* @param context The context.
|
||||
* @param fragmentName The name of the fragment to display.
|
||||
* @param args Optional arguments to supply to the fragment.
|
||||
* @param resultTo Option fragment that should receive the result of the activity launch.
|
||||
* @param resultRequestCode If resultTo is non-null, this is the request code in which
|
||||
* to report the result.
|
||||
* @param titleResId resource id for the String to display for the title of this set
|
||||
* of preferences.
|
||||
* @param title String to display for the title of this set of preferences.
|
||||
* @param metricsCategory The current metricsCategory for logging source when fragment starts
|
||||
*/
|
||||
public static void startWithFragment(Context context, String fragmentName, Bundle args,
|
||||
Fragment resultTo, int resultRequestCode, int titleResId,
|
||||
CharSequence title, int metricsCategory) {
|
||||
startWithFragment(context, fragmentName, args, resultTo, resultRequestCode,
|
||||
null /* titleResPackageName */, titleResId, title, false /* not a shortcut */,
|
||||
metricsCategory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start a new instance of the activity, showing only the given fragment.
|
||||
* When launched in this mode, the given preference fragment will be instantiated and fill the
|
||||
* entire activity.
|
||||
*
|
||||
* @param context The context.
|
||||
* @param fragmentName The name of the fragment to display.
|
||||
* @param args Optional arguments to supply to the fragment.
|
||||
* @param resultTo Option fragment that should receive the result of the activity launch.
|
||||
* @param resultRequestCode If resultTo is non-null, this is the request code in which
|
||||
* to report the result.
|
||||
* @param titleResId resource id for the String to display for the title of this set
|
||||
* of preferences.
|
||||
* @param title String to display for the title of this set of preferences.
|
||||
* @param metricsCategory The current metricsCategory for logging source when fragment starts
|
||||
*/
|
||||
public static void startWithFragment(Context context, String fragmentName, Bundle args,
|
||||
Fragment resultTo, int resultRequestCode, int titleResId,
|
||||
CharSequence title, boolean isShortcut, int metricsCategory) {
|
||||
Intent intent = onBuildStartFragmentIntent(context, fragmentName, args,
|
||||
null /* titleResPackageName */, titleResId, title, isShortcut, metricsCategory);
|
||||
if (resultTo == null) {
|
||||
context.startActivity(intent);
|
||||
} else {
|
||||
resultTo.getActivity().startActivityForResult(intent, resultRequestCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void startWithFragment(Context context, String fragmentName, Bundle args,
|
||||
Fragment resultTo, int resultRequestCode, String titleResPackageName, int titleResId,
|
||||
CharSequence title, boolean isShortcut, int metricsCategory) {
|
||||
Intent intent = onBuildStartFragmentIntent(context, fragmentName, args, titleResPackageName,
|
||||
titleResId, title, isShortcut, metricsCategory);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
if (resultTo == null) {
|
||||
context.startActivity(intent);
|
||||
} else {
|
||||
resultTo.startActivityForResult(intent, resultRequestCode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an Intent to launch a new activity showing the selected fragment.
|
||||
* The implementation constructs an Intent that re-launches the current activity with the
|
||||
|
@@ -30,8 +30,8 @@ import android.support.v7.preference.PreferenceScreen;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settingslib.accounts.AuthenticatorHelper;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
|
||||
@@ -43,7 +43,6 @@ public class AccountSyncPreferenceController extends AbstractPreferenceControlle
|
||||
|
||||
private Account mAccount;
|
||||
private UserHandle mUserHandle;
|
||||
private AuthenticatorHelper mAuthenticatorHelper;
|
||||
private Preference mPreference;
|
||||
|
||||
public AccountSyncPreferenceController(Context context) {
|
||||
@@ -63,8 +62,12 @@ public class AccountSyncPreferenceController extends AbstractPreferenceControlle
|
||||
final Bundle args = new Bundle();
|
||||
args.putParcelable(AccountSyncSettings.ACCOUNT_KEY, mAccount);
|
||||
args.putParcelable(EXTRA_USER, mUserHandle);
|
||||
Utils.startWithFragment(mContext, AccountSyncSettings.class.getName(), args, null, 0,
|
||||
R.string.account_sync_title, null, MetricsProto.MetricsEvent.ACCOUNT);
|
||||
new SubSettingLauncher(mContext)
|
||||
.setDestination(AccountSyncSettings.class.getName())
|
||||
.setArguments(args)
|
||||
.setSourceMetricsCategory( MetricsProto.MetricsEvent.ACCOUNT)
|
||||
.setTitle( R.string.account_sync_title)
|
||||
.launch();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -93,7 +96,6 @@ public class AccountSyncPreferenceController extends AbstractPreferenceControlle
|
||||
public void init(Account account, UserHandle userHandle) {
|
||||
mAccount = account;
|
||||
mUserHandle = userHandle;
|
||||
mAuthenticatorHelper = new AuthenticatorHelper(mContext, mUserHandle, this);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
@@ -161,7 +161,7 @@ public abstract class AppInfoBase extends SettingsPreferenceFragment
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(ManageApplications.APP_CHG, appChanged);
|
||||
SettingsActivity sa = (SettingsActivity)getActivity();
|
||||
sa.finishPreferencePanel(this, Activity.RESULT_OK, intent);
|
||||
sa.finishPreferencePanel(Activity.RESULT_OK, intent);
|
||||
mFinishing = true;
|
||||
}
|
||||
|
||||
|
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the
|
||||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.applications;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.applications.appinfo.DefaultAppShortcutPreferenceControllerBase;
|
||||
|
||||
/**
|
||||
* deprecated in favor of {@link DefaultAppShortcutPreferenceControllerBase}
|
||||
*/
|
||||
@Deprecated
|
||||
public class ShortcutPreference extends Preference {
|
||||
|
||||
private final Class mTarget;
|
||||
private final String mPrefKey;
|
||||
private final int mTitle;
|
||||
|
||||
public ShortcutPreference(Context context, Class target, String prefKey, int prefTitle,
|
||||
int title) {
|
||||
super(context);
|
||||
mTarget = target;
|
||||
mPrefKey = prefKey;
|
||||
mTitle = title;
|
||||
setTitle(prefTitle);
|
||||
setKey(mPrefKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performClick() {
|
||||
super.performClick();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY, mPrefKey);
|
||||
Utils.startWithFragment(getContext(), mTarget.getName(), bundle, null, 0,
|
||||
mTitle, null, MetricsProto.MetricsEvent.VIEW_UNKNOWN);
|
||||
}
|
||||
}
|
@@ -674,7 +674,7 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
||||
final Intent intent = new Intent();
|
||||
intent.putExtra(ManageApplications.APP_CHG, appChanged);
|
||||
final SettingsActivity sa = (SettingsActivity)getActivity();
|
||||
sa.finishPreferencePanel(this, Activity.RESULT_OK, intent);
|
||||
sa.finishPreferencePanel(Activity.RESULT_OK, intent);
|
||||
mFinishing = true;
|
||||
}
|
||||
|
||||
|
@@ -23,9 +23,9 @@ import android.text.TextUtils;
|
||||
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.applications.DefaultAppSettings;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
|
||||
/*
|
||||
* Abstract base controller for the default app shortcut preferences that launches the default app
|
||||
@@ -63,10 +63,14 @@ public abstract class DefaultAppShortcutPreferenceControllerBase extends BasePre
|
||||
@Override
|
||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
||||
if (TextUtils.equals(mPreferenceKey, preference.getKey())) {
|
||||
Bundle bundle = new Bundle();
|
||||
final Bundle bundle = new Bundle();
|
||||
bundle.putString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY, mPreferenceKey);
|
||||
Utils.startWithFragment(mContext, DefaultAppSettings.class.getName(), bundle, null, 0,
|
||||
R.string.configure_apps, null, MetricsProto.MetricsEvent.VIEW_UNKNOWN);
|
||||
new SubSettingLauncher(mContext)
|
||||
.setDestination(DefaultAppSettings.class.getName())
|
||||
.setArguments(bundle)
|
||||
.setTitle(R.string.configure_apps)
|
||||
.setSourceMetricsCategory(MetricsProto.MetricsEvent.VIEW_UNKNOWN)
|
||||
.launch();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@@ -15,11 +15,13 @@
|
||||
*/
|
||||
package com.android.settings.dashboard.conditional;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Icon;
|
||||
import android.os.PowerManager;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.fuelgauge.batterysaver.BatterySaverSettings;
|
||||
|
||||
public class BatterySaverCondition extends Condition {
|
||||
@@ -55,8 +57,12 @@ public class BatterySaverCondition extends Condition {
|
||||
|
||||
@Override
|
||||
public void onPrimaryClick() {
|
||||
Utils.startWithFragment(mManager.getContext(), BatterySaverSettings.class.getName(), null,
|
||||
null, 0, R.string.battery_saver, null, MetricsEvent.DASHBOARD_SUMMARY);
|
||||
new SubSettingLauncher(mManager.getContext())
|
||||
.setDestination(BatterySaverSettings.class.getName())
|
||||
.setSourceMetricsCategory(MetricsEvent.DASHBOARD_SUMMARY)
|
||||
.setTitle(R.string.battery_saver)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
.launch();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -29,7 +29,7 @@ import android.support.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.notification.ZenModeSettings;
|
||||
|
||||
public class DndCondition extends Condition {
|
||||
@@ -103,9 +103,12 @@ public class DndCondition extends Condition {
|
||||
|
||||
@Override
|
||||
public void onPrimaryClick() {
|
||||
Utils.startWithFragment(mManager.getContext(), ZenModeSettings.class.getName(), null,
|
||||
null, 0, R.string.zen_mode_settings_title, null,
|
||||
MetricsEvent.NOTIFICATION_ZEN_MODE);
|
||||
new SubSettingLauncher(mManager.getContext())
|
||||
.setDestination(ZenModeSettings.class.getName())
|
||||
.setSourceMetricsCategory(MetricsEvent.DASHBOARD_SUMMARY)
|
||||
.setTitle(R.string.zen_mode_settings_title)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
.launch();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -29,7 +29,7 @@ import android.os.UserManager;
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.TetherSettings;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||
|
||||
@@ -39,7 +39,7 @@ public class HotspotCondition extends Condition {
|
||||
private final Receiver mReceiver;
|
||||
|
||||
private static final IntentFilter WIFI_AP_STATE_FILTER =
|
||||
new IntentFilter(WifiManager.WIFI_AP_STATE_CHANGED_ACTION);
|
||||
new IntentFilter(WifiManager.WIFI_AP_STATE_CHANGED_ACTION);
|
||||
|
||||
public HotspotCondition(ConditionManager manager) {
|
||||
super(manager);
|
||||
@@ -95,13 +95,17 @@ public class HotspotCondition extends Condition {
|
||||
UserManager.DISALLOW_CONFIG_TETHERING, UserHandle.myUserId())) {
|
||||
return new CharSequence[0];
|
||||
}
|
||||
return new CharSequence[] { context.getString(R.string.condition_turn_off) };
|
||||
return new CharSequence[] {context.getString(R.string.condition_turn_off)};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPrimaryClick() {
|
||||
Utils.startWithFragment(mManager.getContext(), TetherSettings.class.getName(), null, null,
|
||||
0, R.string.tether_settings_title_all, null, MetricsEvent.DASHBOARD_SUMMARY);
|
||||
new SubSettingLauncher(mManager.getContext())
|
||||
.setDestination(TetherSettings.class.getName())
|
||||
.setSourceMetricsCategory(MetricsEvent.DASHBOARD_SUMMARY)
|
||||
.setTitle(R.string.tether_settings_title_all)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
.launch();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -16,12 +16,13 @@
|
||||
|
||||
package com.android.settings.dashboard.conditional;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Icon;
|
||||
|
||||
import com.android.internal.app.ColorDisplayController;
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.display.NightDisplaySettings;
|
||||
|
||||
public final class NightDisplayCondition extends Condition
|
||||
@@ -62,8 +63,12 @@ public final class NightDisplayCondition extends Condition
|
||||
|
||||
@Override
|
||||
public void onPrimaryClick() {
|
||||
Utils.startWithFragment(mManager.getContext(), NightDisplaySettings.class.getName(), null,
|
||||
null, 0, R.string.night_display_title, null, MetricsEvent.DASHBOARD_SUMMARY);
|
||||
new SubSettingLauncher(mManager.getContext())
|
||||
.setDestination(NightDisplaySettings.class.getName())
|
||||
.setSourceMetricsCategory(MetricsEvent.DASHBOARD_SUMMARY)
|
||||
.setTitle(R.string.night_display_title)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
.launch();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -24,10 +24,10 @@ import android.support.v7.preference.PreferenceScreen;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.accounts.AccountDetailDashboardFragment;
|
||||
import com.android.settings.accounts.AccountFeatureProvider;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
|
||||
public class BrandedAccountPreferenceController extends BasePreferenceController {
|
||||
@@ -69,9 +69,13 @@ public class BrandedAccountPreferenceController extends BasePreferenceController
|
||||
android.os.Process.myUserHandle());
|
||||
args.putString(AccountDetailDashboardFragment.KEY_ACCOUNT_TYPE,
|
||||
accountFeatureProvider.getAccountType());
|
||||
Utils.startWithFragment(mContext, AccountDetailDashboardFragment.class.getName(),
|
||||
args, null, 0,
|
||||
R.string.account_sync_title, null, MetricsEvent.ACCOUNT);
|
||||
|
||||
new SubSettingLauncher(mContext)
|
||||
.setDestination(AccountDetailDashboardFragment.class.getName())
|
||||
.setTitle(R.string.account_sync_title)
|
||||
.setArguments(args)
|
||||
.setSourceMetricsCategory(MetricsEvent.DEVICEINFO)
|
||||
.launch();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
@@ -59,7 +59,6 @@ import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
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.core.lifecycle.events.OnResume;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -434,7 +433,7 @@ public class AppButtonsPreferenceController extends AbstractPreferenceController
|
||||
}
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(APP_CHG, appChanged);
|
||||
mActivity.finishPreferencePanel(mFragment, Activity.RESULT_OK, intent);
|
||||
mActivity.finishPreferencePanel(Activity.RESULT_OK, intent);
|
||||
mFinishing = true;
|
||||
}
|
||||
|
||||
|
@@ -67,11 +67,11 @@ import com.android.settings.fuelgauge.anomaly.AnomalyLoader;
|
||||
import com.android.settings.fuelgauge.anomaly.AnomalySummaryPreferenceController;
|
||||
import com.android.settings.fuelgauge.anomaly.AnomalyUtils;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
import com.android.settingslib.utils.PowerUtil;
|
||||
import com.android.settingslib.utils.StringUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -407,8 +407,11 @@ public class PowerUsageSummaryLegacy extends PowerUsageBase implements
|
||||
|
||||
private void performBatteryHeaderClick() {
|
||||
if (mPowerFeatureProvider.isAdvancedUiEnabled()) {
|
||||
Utils.startWithFragment(getContext(), PowerUsageAdvanced.class.getName(), null,
|
||||
null, 0, R.string.advanced_battery_title, null, getMetricsCategory());
|
||||
new SubSettingLauncher(getContext())
|
||||
.setDestination(PowerUsageAdvanced.class.getName())
|
||||
.setSourceMetricsCategory(getMetricsCategory())
|
||||
.setTitle(R.string.advanced_battery_title)
|
||||
.launch();
|
||||
} else {
|
||||
mStatsHelper.storeStatsHistoryInFile(BatteryHistoryDetail.BATTERY_HISTORY_FILE);
|
||||
Bundle args = new Bundle(2);
|
||||
@@ -416,8 +419,12 @@ public class PowerUsageSummaryLegacy extends PowerUsageBase implements
|
||||
BatteryHistoryDetail.BATTERY_HISTORY_FILE);
|
||||
args.putParcelable(BatteryHistoryDetail.EXTRA_BROADCAST,
|
||||
mStatsHelper.getBatteryBroadcast());
|
||||
Utils.startWithFragment(getContext(), BatteryHistoryDetail.class.getName(), args,
|
||||
null, 0, R.string.history_details_title, null, getMetricsCategory());
|
||||
new SubSettingLauncher(getContext())
|
||||
.setDestination(BatteryHistoryDetail.class.getName())
|
||||
.setSourceMetricsCategory(getMetricsCategory())
|
||||
.setArguments(args)
|
||||
.setTitle(R.string.history_details_title)
|
||||
.launch();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -23,17 +23,14 @@ import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.core.InstrumentedFragment;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.core.InstrumentedFragment;
|
||||
import com.android.settings.inputmethod.UserDictionaryAddWordContents.LocaleRenderer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Fragment to add a word/shortcut to the user dictionary.
|
||||
@@ -41,9 +38,7 @@ import java.util.Locale;
|
||||
* As opposed to the UserDictionaryActivity, this is only invoked within Settings
|
||||
* from the UserDictionarySettings.
|
||||
*/
|
||||
public class UserDictionaryAddWordFragment extends InstrumentedFragment
|
||||
implements AdapterView.OnItemSelectedListener,
|
||||
com.android.internal.app.LocalePicker.LocaleSelectionListener {
|
||||
public class UserDictionaryAddWordFragment extends InstrumentedFragment {
|
||||
|
||||
private static final int OPTIONS_MENU_DELETE = Menu.FIRST;
|
||||
|
||||
@@ -136,30 +131,4 @@ public class UserDictionaryAddWordFragment extends InstrumentedFragment
|
||||
mContents.apply(getActivity(), null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemSelected(final AdapterView<?> parent, final View view, final int pos,
|
||||
final long id) {
|
||||
final LocaleRenderer locale = (LocaleRenderer)parent.getItemAtPosition(pos);
|
||||
if (locale.isMoreLanguages()) {
|
||||
SettingsActivity sa = (SettingsActivity)getActivity();
|
||||
sa.startPreferenceFragment(new UserDictionaryLocalePicker(this), true);
|
||||
} else {
|
||||
mContents.updateLocale(locale.getLocaleString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(final AdapterView<?> parent) {
|
||||
// I'm not sure we can come here, but if we do, that's the right thing to do.
|
||||
final Bundle args = getArguments();
|
||||
mContents.updateLocale(args.getString(UserDictionaryAddWordContents.EXTRA_LOCALE));
|
||||
}
|
||||
|
||||
// Called by the locale picker
|
||||
@Override
|
||||
public void onLocaleSelected(final Locale locale) {
|
||||
mContents.updateLocale(locale.toString());
|
||||
getActivity().onBackPressed();
|
||||
}
|
||||
}
|
||||
|
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2012 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.inputmethod;
|
||||
|
||||
public class UserDictionaryLocalePicker extends com.android.internal.app.LocalePicker {
|
||||
public UserDictionaryLocalePicker(final UserDictionaryAddWordFragment parent) {
|
||||
super();
|
||||
setLocaleSelectionListener(parent);
|
||||
}
|
||||
}
|
@@ -21,9 +21,8 @@ import android.support.v7.preference.Preference;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.core.InstrumentedPreferenceFragment;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.localepicker.LocaleListEditor;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
@@ -72,9 +71,11 @@ public class PhoneLanguagePreferenceController extends AbstractPreferenceControl
|
||||
if (!KEY_PHONE_LANGUAGE.equals(preference.getKey())) {
|
||||
return false;
|
||||
}
|
||||
Utils.startWithFragment(mContext, LocaleListEditor.class.getName(), null, null, 0,
|
||||
R.string.pref_title_lang_selection, null,
|
||||
MetricsProto.MetricsEvent.SETTINGS_LANGUAGE_CATEGORY);
|
||||
new SubSettingLauncher(mContext)
|
||||
.setDestination(LocaleListEditor.class.getName())
|
||||
.setSourceMetricsCategory(MetricsProto.MetricsEvent.SETTINGS_LANGUAGE_CATEGORY)
|
||||
.setTitle(R.string.pref_title_lang_selection)
|
||||
.launch();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -20,10 +20,10 @@ import android.content.Context;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.ResetNetwork;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
|
||||
public class NetworkResetActionMenuController {
|
||||
|
||||
@@ -44,9 +44,11 @@ public class NetworkResetActionMenuController {
|
||||
}
|
||||
if (item != null) {
|
||||
item.setOnMenuItemClickListener(target -> {
|
||||
Utils.startWithFragment(mContext, ResetNetwork.class.getName(), null, null,
|
||||
0, R.string.reset_network_title, null,
|
||||
MetricsProto.MetricsEvent.SETTINGS_NETWORK_CATEGORY);
|
||||
new SubSettingLauncher(mContext)
|
||||
.setDestination(ResetNetwork.class.getName())
|
||||
.setSourceMetricsCategory(MetricsEvent.SETTINGS_NETWORK_CATEGORY)
|
||||
.setTitle(R.string.reset_network_title)
|
||||
.launch();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
@@ -1,6 +1,5 @@
|
||||
com.android.settings.deletionhelper.ActivationWarningFragment
|
||||
com.android.settings.applications.appops.AppOpsCategory
|
||||
com.android.settings.inputmethod.UserDictionaryLocalePicker
|
||||
com.android.settings.CustomListPreference$CustomListPreferenceDialogFragment
|
||||
com.android.settings.password.ChooseLockPassword$SaveAndFinishWorker
|
||||
com.android.settings.password.ChooseLockPattern$SaveAndFinishWorker
|
||||
|
@@ -29,6 +29,9 @@ import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.settings.Settings.AccessibilitySettingsActivity;
|
||||
import com.android.settings.core.InstrumentedPreferenceFragment;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Rule;
|
||||
@@ -59,7 +62,12 @@ public class ToggleFeaturePreferenceFragmentTest {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(AccessibilitySettings.EXTRA_SUMMARY, SUMMARY_TEXT);
|
||||
fragment.setArguments(args);
|
||||
mActivityRule.getActivity().startPreferenceFragment(fragment, false);
|
||||
new SubSettingLauncher(mActivityRule.getActivity())
|
||||
.setDestination(MyToggleFeaturePreferenceFragment.class.getName())
|
||||
.setArguments(args)
|
||||
.setSourceMetricsCategory(
|
||||
InstrumentedPreferenceFragment.METRICS_CATEGORY_UNKNOWN)
|
||||
.launch();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -70,7 +78,8 @@ public class ToggleFeaturePreferenceFragmentTest {
|
||||
|
||||
public static class MyToggleFeaturePreferenceFragment extends ToggleFeaturePreferenceFragment {
|
||||
@Override
|
||||
protected void onPreferenceToggled(String preferenceKey, boolean enabled) {}
|
||||
protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
|
Reference in New Issue
Block a user