use of com.android.settings.core.SubSettingLauncher in project android_packages_apps_Settings by omnirom.
the class ConversationListPreferenceController method getSubSettingLauncher.
SubSettingLauncher getSubSettingLauncher(ConversationChannelWrapper conversation, CharSequence title) {
Bundle channelArgs = new Bundle();
channelArgs.putInt(AppInfoBase.ARG_PACKAGE_UID, conversation.getUid());
channelArgs.putString(AppInfoBase.ARG_PACKAGE_NAME, conversation.getPkg());
channelArgs.putString(Settings.EXTRA_CHANNEL_ID, conversation.getNotificationChannel().getId());
channelArgs.putString(Settings.EXTRA_CONVERSATION_ID, conversation.getNotificationChannel().getConversationId());
return new SubSettingLauncher(mContext).setDestination(ChannelNotificationSettings.class.getName()).setArguments(channelArgs).setExtras(channelArgs).setUserHandle(UserHandle.getUserHandleForUid(conversation.getUid())).setTitleText(title).setSourceMetricsCategory(SettingsEnums.NOTIFICATION_CONVERSATION_LIST_SETTINGS);
}
use of com.android.settings.core.SubSettingLauncher in project android_packages_apps_Settings by omnirom.
the class ZenModeAddBypassingAppsPreferenceController method updateAppList.
@VisibleForTesting
void updateAppList(List<ApplicationsState.AppEntry> apps) {
if (apps == null) {
return;
}
if (mPreferenceCategory == null) {
mPreferenceCategory = new PreferenceCategory(mPrefContext);
mPreferenceCategory.setTitle(R.string.zen_mode_bypassing_apps_add_header);
mPreferenceScreen.addPreference(mPreferenceCategory);
}
List<Preference> appsWithNoBypassingDndNotificationChannels = new ArrayList<>();
for (ApplicationsState.AppEntry entry : apps) {
String pkg = entry.info.packageName;
mApplicationsState.ensureIcon(entry);
final int appChannels = mNotificationBackend.getChannelCount(pkg, entry.info.uid);
final int appChannelsBypassingDnd = mNotificationBackend.getNotificationChannelsBypassingDnd(pkg, entry.info.uid).getList().size();
if (appChannelsBypassingDnd == 0 && appChannels > 0) {
final String key = ZenModeAllBypassingAppsPreferenceController.getKey(pkg);
Preference pref = mPreferenceCategory.findPreference("");
if (pref == null) {
pref = new AppPreference(mPrefContext);
pref.setKey(key);
pref.setOnPreferenceClickListener(preference -> {
Bundle args = new Bundle();
args.putString(AppInfoBase.ARG_PACKAGE_NAME, entry.info.packageName);
args.putInt(AppInfoBase.ARG_PACKAGE_UID, entry.info.uid);
new SubSettingLauncher(mContext).setDestination(AppChannelsBypassingDndSettings.class.getName()).setArguments(args).setResultListener(mHostFragment, 0).setUserHandle(new UserHandle(UserHandle.getUserId(entry.info.uid))).setSourceMetricsCategory(SettingsEnums.NOTIFICATION_ZEN_MODE_OVERRIDING_APP).launch();
return true;
});
}
pref.setTitle(BidiFormatter.getInstance().unicodeWrap(entry.label));
pref.setIcon(entry.icon);
appsWithNoBypassingDndNotificationChannels.add(pref);
}
}
if (appsWithNoBypassingDndNotificationChannels.size() == 0) {
Preference pref = mPreferenceCategory.findPreference(ZenModeAllBypassingAppsPreferenceController.KEY_NO_APPS);
if (pref == null) {
pref = new Preference(mPrefContext);
pref.setKey(ZenModeAllBypassingAppsPreferenceController.KEY_NO_APPS);
pref.setTitle(R.string.zen_mode_bypassing_apps_subtext_none);
}
mPreferenceCategory.addPreference(pref);
}
if (ZenModeAllBypassingAppsPreferenceController.hasAppListChanged(appsWithNoBypassingDndNotificationChannels, mPreferenceCategory)) {
mPreferenceCategory.removeAll();
for (Preference prefToAdd : appsWithNoBypassingDndNotificationChannels) {
mPreferenceCategory.addPreference(prefToAdd);
}
}
}
use of com.android.settings.core.SubSettingLauncher in project android_packages_apps_Settings by omnirom.
the class ChannelListPreferenceController method updateSingleChannelPrefs.
/**
* Update the properties of the channel preference with the values from the channel object.
*/
private void updateSingleChannelPrefs(@NonNull final PrimarySwitchPreference channelPref, @NonNull final NotificationChannel channel, final boolean groupBlocked) {
channelPref.setSwitchEnabled(mAdmin == null && isChannelBlockable(channel) && isChannelConfigurable(channel) && !groupBlocked);
if (channel.getImportance() > IMPORTANCE_LOW) {
channelPref.setIcon(getAlertingIcon());
} else {
channelPref.setIcon(R.drawable.empty_icon);
}
channelPref.setIconSize(PrimarySwitchPreference.ICON_SIZE_SMALL);
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 ? Math.max(channel.getOriginalImportance(), IMPORTANCE_LOW) : IMPORTANCE_NONE;
channel.setImportance(importance);
channel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
PrimarySwitchPreference channelPref1 = (PrimarySwitchPreference) preference;
channelPref1.setIcon(R.drawable.empty_icon);
if (channel.getImportance() > IMPORTANCE_LOW) {
channelPref1.setIcon(getAlertingIcon());
}
mBackend.updateChannel(mAppRow.pkg, mAppRow.uid, channel);
return true;
});
}
use of com.android.settings.core.SubSettingLauncher in project android_packages_apps_Settings by omnirom.
the class WifiSettings method launchNetworkDetailsFragment.
private void launchNetworkDetailsFragment(LongPressWifiEntryPreference pref) {
final WifiEntry wifiEntry = pref.getWifiEntry();
final Context context = getContext();
final CharSequence title = FeatureFlagUtils.isEnabled(context, FeatureFlags.WIFI_DETAILS_DATAUSAGE_HEADER) ? wifiEntry.getTitle() : context.getText(R.string.pref_title_network_details);
final Bundle bundle = new Bundle();
bundle.putString(WifiNetworkDetailsFragment.KEY_CHOSEN_WIFIENTRY_KEY, wifiEntry.getKey());
new SubSettingLauncher(context).setTitleText(title).setDestination(WifiNetworkDetailsFragment.class.getName()).setArguments(bundle).setSourceMetricsCategory(getMetricsCategory()).launch();
}
use of com.android.settings.core.SubSettingLauncher in project android_packages_apps_Settings by omnirom.
the class WifiSettings method launchConfigNewNetworkFragment.
private void launchConfigNewNetworkFragment(WifiEntry wifiEntry) {
final Bundle bundle = new Bundle();
bundle.putString(WifiNetworkDetailsFragment.KEY_CHOSEN_WIFIENTRY_KEY, wifiEntry.getKey());
new SubSettingLauncher(getContext()).setTitleText(wifiEntry.getTitle()).setDestination(ConfigureWifiEntryFragment.class.getName()).setArguments(bundle).setSourceMetricsCategory(getMetricsCategory()).setResultListener(WifiSettings.this, CONFIG_NETWORK_REQUEST).launch();
}
Aggregations