use of android.support.v7.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.
the class DataPlanUsageSummary method addDataPlanSection.
private void addDataPlanSection(int defaultSubId) {
Context context = getPrefContext();
addPreferencesFromResource(R.xml.data_plan_usage);
PreferenceScreen screen = getPreferenceScreen();
screen.setTitle(context.getString(R.string.data_usage_summary_title));
PreferenceCategory preferenceCategory = (PreferenceCategory) findPreference(KEY_DATA_PLAN_USAGE);
screen.addPreference(preferenceCategory);
Preference dataPlansSyncTimePreference = new Preference(context);
dataPlansSyncTimePreference.setLayoutResource(R.layout.data_plans_sync_time_preference);
dataPlansSyncTimePreference.setTitle(MockDataPlanUsage.SYNC_TIME);
preferenceCategory.addPreference(dataPlansSyncTimePreference);
mDataPlanSummaryPreferenceList = new ArrayList<>(MockDataPlanUsage.DATA_PLAN_USAGES.length);
for (int i = 0; i < MockDataPlanUsage.DATA_PLAN_USAGES.length; i++) {
DataPlanSummaryPreference dataPlanSummaryPreference = new DataPlanSummaryPreference(context);
dataPlanSummaryPreference.setKey(KEY_STATUS_HEADER + (i + 1));
mDataPlanSummaryPreferenceList.add(dataPlanSummaryPreference);
preferenceCategory.addPreference(dataPlanSummaryPreference);
}
Preference preference = new Preference(context);
preference.setLayoutResource(R.layout.manage_data_plans_preference);
preferenceCategory.addPreference(preference);
setPreferenceScreen(screen);
mLimitPreference = findPreference(KEY_LIMIT_SUMMARY);
List<SubscriptionInfo> subscriptions = services.mSubscriptionManager.getActiveSubscriptionInfoList();
if (subscriptions == null || subscriptions.isEmpty()) {
addMobileSection(defaultSubId);
}
for (int i = 0, subscriptionsSize = subscriptions != null ? subscriptions.size() : 0; i < subscriptionsSize; i++) {
SubscriptionInfo subInfo = subscriptions.get(i);
if (subscriptionsSize > 1) {
addMobileSection(subInfo.getSubscriptionId(), subInfo);
} else {
addMobileSection(subInfo.getSubscriptionId());
}
}
}
use of android.support.v7.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.
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));
}
}
}
use of android.support.v7.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.
the class PhysicalKeyboardFragment method onLoadFinishedInternal.
private void onLoadFinishedInternal(final int loaderId, @NonNull final List<Keyboards> keyboardsList) {
if (!mLoaderIDs.remove(loaderId)) {
// Already destroyed loader. Ignore.
return;
}
Collections.sort(keyboardsList);
final PreferenceScreen preferenceScreen = getPreferenceScreen();
preferenceScreen.removeAll();
for (Keyboards keyboards : keyboardsList) {
final PreferenceCategory category = new PreferenceCategory(getPrefContext(), null);
category.setTitle(keyboards.mDeviceInfo.mDeviceName);
category.setOrder(0);
preferenceScreen.addPreference(category);
for (Keyboards.KeyboardInfo info : keyboards.mKeyboardInfoList) {
mTempKeyboardInfoList.clear();
final InputMethodInfo imi = info.mImi;
final InputMethodSubtype imSubtype = info.mImSubtype;
if (imi != null) {
KeyboardInfoPreference pref = new KeyboardInfoPreference(getPrefContext(), info);
pref.setOnPreferenceClickListener(preference -> {
showKeyboardLayoutScreen(keyboards.mDeviceInfo.mDeviceIdentifier, imi, imSubtype);
return true;
});
mTempKeyboardInfoList.add(pref);
Collections.sort(mTempKeyboardInfoList);
}
for (KeyboardInfoPreference pref : mTempKeyboardInfoList) {
category.addPreference(pref);
}
}
}
mTempKeyboardInfoList.clear();
mKeyboardAssistanceCategory.setOrder(1);
preferenceScreen.addPreference(mKeyboardAssistanceCategory);
updateShowVirtualKeyboardSwitch();
}
use of android.support.v7.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.
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 omnirom.
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);
}
Aggregations