use of android.support.v7.preference.PreferenceCategory in project android_packages_apps_Settings by LineageOS.
the class LocationSettings method addLocationServices.
/**
* Add the settings injected by external apps into the "App Settings" category. Hides the
* category if there are no injected settings.
*
* Reloads the settings whenever receives
* {@link SettingInjectorService#ACTION_INJECTED_SETTING_CHANGED}.
*/
private void addLocationServices(Context context, PreferenceScreen root, boolean lockdownOnLocationAccess) {
PreferenceCategory categoryLocationServices = (PreferenceCategory) root.findPreference(KEY_LOCATION_SERVICES);
injector = new SettingsInjector(context);
// If location access is locked down by device policy then we only show injected settings
// for the primary profile.
final Context prefContext = categoryLocationServices.getContext();
final List<Preference> locationServices = injector.getInjectedSettings(prefContext, lockdownOnLocationAccess ? UserHandle.myUserId() : UserHandle.USER_CURRENT);
mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Received settings change intent: " + intent);
}
injector.reloadStatusMessages();
}
};
IntentFilter filter = new IntentFilter();
filter.addAction(SettingInjectorService.ACTION_INJECTED_SETTING_CHANGED);
context.registerReceiver(mReceiver, filter);
if (locationServices.size() > 0) {
addPreferencesSorted(locationServices, categoryLocationServices);
} else {
// If there's no item to display, remove the whole category.
root.removePreference(categoryLocationServices);
}
}
use of android.support.v7.preference.PreferenceCategory in project android_packages_apps_Settings by LineageOS.
the class AppNotificationSettings method updateDependents.
protected void updateDependents(boolean banned) {
for (PreferenceCategory category : mChannelGroups) {
setVisible(category, !banned);
}
if (mDeletedChannels != null) {
setVisible(mDeletedChannels, !banned);
}
setVisible(mBlockedDesc, banned);
setVisible(mBadge, !banned);
if (mShowLegacyChannelConfig) {
setVisible(mImportanceToggle, !banned);
setVisible(mPriority, checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT) || (checkCanBeVisible(NotificationManager.IMPORTANCE_LOW) && mDndVisualEffectsSuppressed));
setVisible(mVisibilityOverride, !banned && checkCanBeVisible(NotificationManager.IMPORTANCE_LOW) && isLockScreenSecure());
}
if (mAppLink != null) {
setVisible(mAppLink, !banned);
}
if (mAppRow.systemApp && !mAppRow.banned) {
setVisible(mBlockBar, false);
}
}
use of android.support.v7.preference.PreferenceCategory in project android_packages_apps_Settings by LineageOS.
the class AppNotificationSettings method populateChannelList.
private void populateChannelList() {
if (!mChannelGroups.isEmpty()) {
// If there's anything in mChannelGroups, we've called populateChannelList twice.
// Clear out existing channels and log.
Log.w(TAG, "Notification channel group posted twice to settings - old size " + mChannelGroups.size() + ", new size " + mChannelGroupList.size());
for (Preference p : mChannelGroups) {
getPreferenceScreen().removePreference(p);
}
}
if (mChannelGroupList.isEmpty()) {
PreferenceCategory groupCategory = new PreferenceCategory(getPrefContext());
groupCategory.setTitle(R.string.notification_channels);
groupCategory.setKey(KEY_GENERAL_CATEGORY);
getPreferenceScreen().addPreference(groupCategory);
mChannelGroups.add(groupCategory);
Preference empty = new Preference(getPrefContext());
empty.setTitle(R.string.no_channels);
empty.setEnabled(false);
groupCategory.addPreference(empty);
} else {
for (NotificationChannelGroup group : mChannelGroupList) {
PreferenceCategory groupCategory = new PreferenceCategory(getPrefContext());
if (group.getId() == null) {
groupCategory.setTitle(mChannelGroupList.size() > 1 ? R.string.notification_channels_other : R.string.notification_channels);
groupCategory.setKey(KEY_GENERAL_CATEGORY);
} else {
groupCategory.setTitle(group.getName());
groupCategory.setKey(group.getId());
}
groupCategory.setOrderingAsAdded(true);
getPreferenceScreen().addPreference(groupCategory);
mChannelGroups.add(groupCategory);
final List<NotificationChannel> channels = group.getChannels();
Collections.sort(channels, mChannelComparator);
int N = channels.size();
for (int i = 0; i < N; i++) {
final NotificationChannel channel = channels.get(i);
populateSingleChannelPrefs(groupCategory, channel);
}
}
int deletedChannelCount = mBackend.getDeletedChannelCount(mAppRow.pkg, mAppRow.uid);
if (deletedChannelCount > 0 && getPreferenceScreen().findPreference(KEY_DELETED) == null) {
mDeletedChannels = new FooterPreference(getPrefContext());
mDeletedChannels.setSelectable(false);
mDeletedChannels.setTitle(getResources().getQuantityString(R.plurals.deleted_channels, deletedChannelCount, deletedChannelCount));
mDeletedChannels.setEnabled(false);
mDeletedChannels.setKey(KEY_DELETED);
mDeletedChannels.setOrder(ORDER_LAST);
getPreferenceScreen().addPreference(mDeletedChannels);
}
}
updateDependents(mAppRow.banned);
}
use of android.support.v7.preference.PreferenceCategory in project android_packages_apps_Settings by LineageOS.
the class AppNotificationSettings method populateSingleChannelPrefs.
private void populateSingleChannelPrefs(PreferenceCategory groupCategory, final NotificationChannel channel) {
MasterSwitchPreference channelPref = new MasterSwitchPreference(getPrefContext());
channelPref.setSwitchEnabled(mSuspendedAppsAdmin == null && isChannelBlockable(mAppRow.systemApp, channel) && isChannelConfigurable(channel));
channelPref.setKey(channel.getId());
channelPref.setTitle(channel.getName());
channelPref.setChecked(channel.getImportance() != IMPORTANCE_NONE);
channelPref.setSummary(getImportanceSummary(channel));
Bundle channelArgs = new Bundle();
channelArgs.putInt(AppInfoBase.ARG_PACKAGE_UID, mUid);
channelArgs.putString(AppInfoBase.ARG_PACKAGE_NAME, mPkg);
channelArgs.putString(Settings.EXTRA_CHANNEL_ID, channel.getId());
Intent channelIntent = Utils.onBuildStartFragmentIntent(getActivity(), ChannelNotificationSettings.class.getName(), channelArgs, null, R.string.notification_channel_title, null, false, getMetricsCategory());
channelPref.setIntent(channelIntent);
channelPref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object o) {
boolean value = (Boolean) o;
int importance = value ? IMPORTANCE_LOW : IMPORTANCE_NONE;
channel.setImportance(importance);
channel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
channelPref.setSummary(getImportanceSummary(channel));
mBackend.updateChannel(mPkg, mUid, channel);
return true;
}
});
groupCategory.addPreference(channelPref);
}
use of android.support.v7.preference.PreferenceCategory in project android_packages_apps_Settings by LineageOS.
the class EnterpriseSetDefaultAppsListPreferenceController method updateUi.
private void updateUi() {
final Context prefContext = mParent.getPreferenceManager().getContext();
final PreferenceScreen screen = mParent.getPreferenceScreen();
if (screen == null) {
return;
}
if (!mEnterprisePrivacyFeatureProvider.isInCompMode() && mUsers.size() == 1) {
createPreferences(prefContext, screen, mApps.get(0));
} else {
for (int i = 0; i < mUsers.size(); i++) {
final UserInfo userInfo = mUsers.get(i);
final PreferenceCategory category = new PreferenceCategory(prefContext);
screen.addPreference(category);
if (userInfo.isManagedProfile()) {
category.setTitle(R.string.managed_device_admin_title);
} else {
category.setTitle(R.string.personal_device_admin_title);
}
category.setOrder(i);
createPreferences(prefContext, category, mApps.get(i));
}
}
}
Aggregations