use of com.android.settings.core.SubSettingLauncher in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DataUsagePreference method getIntent.
@Override
public Intent getIntent() {
final Bundle args = new Bundle();
final SubSettingLauncher launcher;
args.putParcelable(DataUsageList.EXTRA_NETWORK_TEMPLATE, mTemplate);
args.putInt(DataUsageList.EXTRA_SUB_ID, mSubId);
args.putInt(DataUsageList.EXTRA_NETWORK_TYPE, mTemplate.isMatchRuleMobile() ? ConnectivityManager.TYPE_MOBILE : ConnectivityManager.TYPE_WIFI);
launcher = new SubSettingLauncher(getContext()).setArguments(args).setDestination(DataUsageList.class.getName()).setSourceMetricsCategory(SettingsEnums.PAGE_UNKNOWN);
if (mTemplate.isMatchRuleMobile()) {
launcher.setTitleRes(R.string.app_cellular_data_usage);
} else {
launcher.setTitleRes(mTitleRes);
}
return launcher.toIntent();
}
use of com.android.settings.core.SubSettingLauncher in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class RecentNotifyingAppsPreferenceController method displayRecentApps.
private void displayRecentApps(Context prefContext, List<NotifyingApp> recentApps) {
mCategory.setTitle(R.string.recent_notifications);
mDivider.setVisible(true);
mSeeAllPref.setSummary(null);
mSeeAllPref.setIcon(R.drawable.ic_chevron_right_24dp);
// Rebind prefs/avoid adding new prefs if possible. Adding/removing prefs causes jank.
// Build a cached preference pool
final Map<String, NotificationAppPreference> appPreferences = new ArrayMap<>();
int prefCount = mCategory.getPreferenceCount();
for (int i = 0; i < prefCount; i++) {
final Preference pref = mCategory.getPreference(i);
final String key = pref.getKey();
if (!TextUtils.equals(key, KEY_SEE_ALL)) {
appPreferences.put(key, (NotificationAppPreference) pref);
}
}
final int recentAppsCount = recentApps.size();
for (int i = 0; i < recentAppsCount; i++) {
final NotifyingApp app = recentApps.get(i);
// Bind recent apps to existing prefs if possible, or create a new pref.
final String pkgName = app.getPackage();
final ApplicationsState.AppEntry appEntry = mApplicationsState.getEntry(app.getPackage(), app.getUserId());
if (appEntry == null) {
continue;
}
boolean rebindPref = true;
NotificationAppPreference pref = appPreferences.remove(getKey(app.getUserId(), pkgName));
if (pref == null) {
pref = new NotificationAppPreference(prefContext);
rebindPref = false;
}
pref.setKey(getKey(app.getUserId(), pkgName));
pref.setTitle(appEntry.label);
pref.setIcon(mIconDrawableFactory.getBadgedIcon(appEntry.info));
pref.setIconSize(TwoTargetPreference.ICON_SIZE_SMALL);
pref.setSummary(StringUtil.formatRelativeTime(mContext, System.currentTimeMillis() - app.getLastNotified(), true));
pref.setOrder(i);
Bundle args = new Bundle();
args.putString(AppInfoBase.ARG_PACKAGE_NAME, pkgName);
args.putInt(AppInfoBase.ARG_PACKAGE_UID, appEntry.info.uid);
pref.setOnPreferenceClickListener(preference -> {
new SubSettingLauncher(mHost.getActivity()).setDestination(AppNotificationSettings.class.getName()).setTitleRes(R.string.notifications_title).setArguments(args).setUserHandle(new UserHandle(UserHandle.getUserId(appEntry.info.uid))).setSourceMetricsCategory(SettingsEnums.MANAGE_APPLICATIONS_NOTIFICATIONS).launch();
return true;
});
pref.setSwitchEnabled(mNotificationBackend.isBlockable(mContext, appEntry.info));
pref.setOnPreferenceChangeListener((preference, newValue) -> {
boolean blocked = !(Boolean) newValue;
mNotificationBackend.setNotificationsEnabledForPackage(pkgName, appEntry.info.uid, !blocked);
return true;
});
pref.setChecked(!mNotificationBackend.getNotificationsBanned(pkgName, appEntry.info.uid));
if (!rebindPref) {
mCategory.addPreference(pref);
}
}
// Remove unused prefs from pref cache pool
for (Preference unusedPrefs : appPreferences.values()) {
mCategory.removePreference(unusedPrefs);
}
}
use of com.android.settings.core.SubSettingLauncher in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ChannelListPreferenceController method populateSingleChannelPrefs.
protected Preference populateSingleChannelPrefs(PreferenceGroup parent, final NotificationChannel channel, final boolean groupBlocked) {
MasterSwitchPreference channelPref = new MasterSwitchPreference(mContext);
channelPref.setSwitchEnabled(mAdmin == null && isChannelBlockable(channel) && isChannelConfigurable(channel) && !groupBlocked);
channelPref.setIcon(null);
if (channel.getImportance() > IMPORTANCE_LOW) {
channelPref.setIcon(getAlertingIcon());
}
channelPref.setIconSize(MasterSwitchPreference.ICON_SIZE_SMALL);
channelPref.setKey(channel.getId());
channelPref.setTitle(channel.getName());
channelPref.setSummary(NotificationBackend.getSentSummary(mContext, mAppRow.sentByChannel.get(channel.getId()), false));
channelPref.setChecked(channel.getImportance() != IMPORTANCE_NONE);
Bundle channelArgs = new Bundle();
channelArgs.putInt(AppInfoBase.ARG_PACKAGE_UID, mAppRow.uid);
channelArgs.putString(AppInfoBase.ARG_PACKAGE_NAME, mAppRow.pkg);
channelArgs.putString(Settings.EXTRA_CHANNEL_ID, channel.getId());
channelArgs.putBoolean(ARG_FROM_SETTINGS, true);
channelPref.setIntent(new SubSettingLauncher(mContext).setDestination(ChannelNotificationSettings.class.getName()).setArguments(channelArgs).setTitleRes(R.string.notification_channel_title).setSourceMetricsCategory(SettingsEnums.NOTIFICATION_APP_NOTIFICATION).toIntent());
channelPref.setOnPreferenceChangeListener((preference, o) -> {
boolean value = (Boolean) o;
int importance = value ? IMPORTANCE_LOW : IMPORTANCE_NONE;
channel.setImportance(importance);
channel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
MasterSwitchPreference channelPref1 = (MasterSwitchPreference) preference;
channelPref1.setIcon(null);
if (channel.getImportance() > IMPORTANCE_LOW) {
channelPref1.setIcon(getAlertingIcon());
}
toggleBehaviorIconState(channelPref1.getIcon(), importance != IMPORTANCE_NONE);
mBackend.updateChannel(mAppRow.pkg, mAppRow.uid, channel);
return true;
});
if (parent.findPreference(channelPref.getKey()) == null) {
parent.addPreference(channelPref);
}
return channelPref;
}
use of com.android.settings.core.SubSettingLauncher in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class AccessibilitySettingsForSetupWizardActivity method tryLaunchFontSizeSettings.
@VisibleForTesting
void tryLaunchFontSizeSettings() {
if (WizardManagerHelper.isAnySetupWizard(getIntent()) && new ComponentName(getPackageName(), CLASS_NAME_FONT_SIZE_SETTINGS_FOR_SUW).equals(getIntent().getComponent())) {
final Bundle args = new Bundle();
args.putInt(HelpResourceProvider.HELP_URI_RESOURCE_KEY, 0);
args.putBoolean(SearchMenuController.NEED_SEARCH_ICON_IN_ACTION_BAR, false);
final SubSettingLauncher subSettingLauncher = new SubSettingLauncher(this).setDestination(FontSizePreferenceFragmentForSetupWizard.class.getName()).setArguments(args).setSourceMetricsCategory(Instrumentable.METRICS_CATEGORY_UNKNOWN).setExtras(SetupWizardUtils.copyLifecycleExtra(getIntent().getExtras(), new Bundle()));
Log.d(LOG_TAG, "Launch font size settings");
subSettingLauncher.launch();
finish();
}
}
use of com.android.settings.core.SubSettingLauncher in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class OpenBatterySaverAction method handlePositiveAction.
/**
* Handle the action when user clicks positive button
*/
@Override
public void handlePositiveAction(int metricsKey) {
mMetricsFeatureProvider.action(mContext, SettingsEnums.ACTION_TIP_OPEN_BATTERY_SAVER_PAGE, metricsKey);
new SubSettingLauncher(mContext).setDestination(BatterySaverSettings.class.getName()).setSourceMetricsCategory(metricsKey).launch();
}
Aggregations