use of android.support.v7.preference.PreferenceGroup in project android_packages_apps_Settings by SudaMod.
the class ApnSettings method fillList.
private void fillList() {
final TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
final int subId = mSubscriptionInfo != null ? mSubscriptionInfo.getSubscriptionId() : SubscriptionManager.INVALID_SUBSCRIPTION_ID;
final String mccmnc = mSubscriptionInfo == null ? "" : tm.getSimOperator(subId);
Log.d(TAG, "mccmnc = " + mccmnc);
StringBuilder where = new StringBuilder("numeric=\"" + mccmnc + "\" AND NOT (type='ia' AND (apn=\"\" OR apn IS NULL)) AND user_visible!=0");
if (mHideImsApn) {
where.append(" AND NOT (type='ims')");
}
Cursor cursor = getContentResolver().query(Telephony.Carriers.CONTENT_URI, new String[] { "_id", "name", "apn", "type", "mvno_type", "mvno_match_data" }, where.toString(), null, Telephony.Carriers.DEFAULT_SORT_ORDER);
if (cursor != null) {
IccRecords r = null;
if (mUiccController != null && mSubscriptionInfo != null) {
r = mUiccController.getIccRecords(SubscriptionManager.getPhoneId(subId), UiccController.APP_FAM_3GPP);
}
PreferenceGroup apnList = (PreferenceGroup) findPreference("apn_list");
apnList.removeAll();
ArrayList<ApnPreference> mnoApnList = new ArrayList<ApnPreference>();
ArrayList<ApnPreference> mvnoApnList = new ArrayList<ApnPreference>();
ArrayList<ApnPreference> mnoMmsApnList = new ArrayList<ApnPreference>();
ArrayList<ApnPreference> mvnoMmsApnList = new ArrayList<ApnPreference>();
mSelectedKey = getSelectedApnKey();
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
String name = cursor.getString(NAME_INDEX);
String apn = cursor.getString(APN_INDEX);
String key = cursor.getString(ID_INDEX);
String type = cursor.getString(TYPES_INDEX);
String mvnoType = cursor.getString(MVNO_TYPE_INDEX);
String mvnoMatchData = cursor.getString(MVNO_MATCH_DATA_INDEX);
ApnPreference pref = new ApnPreference(getPrefContext());
pref.setKey(key);
pref.setTitle(name);
pref.setSummary(apn);
pref.setPersistent(false);
pref.setOnPreferenceChangeListener(this);
pref.setSubId(subId);
boolean selectable = ((type == null) || !type.equals("mms"));
pref.setSelectable(selectable);
if (selectable) {
if ((mSelectedKey != null) && mSelectedKey.equals(key)) {
pref.setChecked();
}
addApnToList(pref, mnoApnList, mvnoApnList, r, mvnoType, mvnoMatchData);
} else {
addApnToList(pref, mnoMmsApnList, mvnoMmsApnList, r, mvnoType, mvnoMatchData);
}
cursor.moveToNext();
}
cursor.close();
if (!mvnoApnList.isEmpty()) {
mnoApnList = mvnoApnList;
mnoMmsApnList = mvnoMmsApnList;
// Also save the mvno info
}
for (Preference preference : mnoApnList) {
apnList.addPreference(preference);
}
for (Preference preference : mnoMmsApnList) {
apnList.addPreference(preference);
}
}
}
use of android.support.v7.preference.PreferenceGroup in project android_packages_apps_Settings by SudaMod.
the class ManageDomainUrls method onRebuildComplete.
@Override
public void onRebuildComplete(ArrayList<AppEntry> apps) {
if (getContext() == null) {
return;
}
final boolean disableWebActions = Global.getInt(getContext().getContentResolver(), Global.ENABLE_EPHEMERAL_FEATURE, 1) == 0;
if (disableWebActions) {
mDomainAppList = getPreferenceScreen();
} else {
final PreferenceGroup preferenceScreen = getPreferenceScreen();
if (preferenceScreen.getPreferenceCount() == 0) {
// add preferences
final PreferenceCategory webActionCategory = new PreferenceCategory(getPrefContext());
webActionCategory.setTitle(R.string.web_action_section_title);
preferenceScreen.addPreference(webActionCategory);
// toggle to enable / disable Web Actions [aka Instant Apps]
mWebAction = new SwitchPreference(getPrefContext());
mWebAction.setTitle(R.string.web_action_enable_title);
mWebAction.setSummary(R.string.web_action_enable_summary);
mWebAction.setChecked(Settings.Secure.getInt(getContentResolver(), Settings.Secure.INSTANT_APPS_ENABLED, 1) != 0);
mWebAction.setOnPreferenceChangeListener(this);
webActionCategory.addPreference(mWebAction);
// Determine whether we should show the instant apps account chooser setting
ComponentName instantAppSettingsComponent = getActivity().getPackageManager().getInstantAppResolverSettingsComponent();
Intent instantAppSettingsIntent = null;
if (instantAppSettingsComponent != null) {
instantAppSettingsIntent = new Intent().setComponent(instantAppSettingsComponent);
}
if (instantAppSettingsIntent != null) {
final Intent launchIntent = instantAppSettingsIntent;
// TODO: Make this button actually launch the account chooser.
mInstantAppAccountPreference = new Preference(getPrefContext());
mInstantAppAccountPreference.setTitle(R.string.instant_apps_settings);
mInstantAppAccountPreference.setOnPreferenceClickListener(pref -> {
startActivity(launchIntent);
return true;
});
webActionCategory.addPreference(mInstantAppAccountPreference);
}
// list to manage link handling per app
mDomainAppList = new PreferenceCategory(getPrefContext());
mDomainAppList.setTitle(R.string.domain_url_section_title);
preferenceScreen.addPreference(mDomainAppList);
}
}
rebuildAppList(mDomainAppList, apps);
}
use of android.support.v7.preference.PreferenceGroup in project android_packages_apps_CMParts by LineageOS.
the class SettingsPreferenceFragment method cacheRemoveAllPrefs.
protected void cacheRemoveAllPrefs(PreferenceGroup group) {
mPreferenceCache = new ArrayMap<String, Preference>();
final int N = group.getPreferenceCount();
for (int i = 0; i < N; i++) {
Preference p = group.getPreference(i);
if (TextUtils.isEmpty(p.getKey())) {
continue;
}
mPreferenceCache.put(p.getKey(), p);
}
}
use of android.support.v7.preference.PreferenceGroup in project android_packages_apps_CMParts by LineageOS.
the class AppGroupConfig method updatePackages.
private void updatePackages() {
PreferenceScreen prefSet = getPreferenceScreen();
// Add the General section
PreferenceGroup generalPrefs = (PreferenceGroup) prefSet.findPreference("general_section");
if (generalPrefs != null) {
generalPrefs.removeAll();
// Name preference
mNamePreference = new NamePreference(getActivity(), mNotificationGroup.getName());
mNamePreference.setOnPreferenceChangeListener(this);
generalPrefs.addPreference(mNamePreference);
}
PreferenceGroup applicationsList = (PreferenceGroup) prefSet.findPreference("applications_list");
if (applicationsList != null) {
applicationsList.removeAll();
for (String pkg : mNotificationGroup.getPackages()) {
Preference pref = new Preference(getActivity());
try {
PackageInfo group = mPackageManager.getPackageInfo(pkg, 0);
pref.setKey(group.packageName);
pref.setTitle(group.applicationInfo.loadLabel(mPackageManager));
Drawable icon = group.applicationInfo.loadIcon(mPackageManager);
pref.setIcon(icon);
pref.setSelectable(true);
pref.setPersistent(false);
applicationsList.addPreference(pref);
} catch (NameNotFoundException e) {
e.printStackTrace();
}
}
}
}
use of android.support.v7.preference.PreferenceGroup in project android_packages_apps_Settings by DirtyUnicorns.
the class PowerUsageAdvancedTest method testPrefs_shouldNotBeSelectable.
@Test
public void testPrefs_shouldNotBeSelectable() {
PreferenceManager pm = new PreferenceManager(mShadowContext);
when(mPowerUsageAdvanced.getPreferenceManager()).thenReturn(pm);
PreferenceGroup prefGroup = spy(new PreferenceCategory(mShadowContext));
when(prefGroup.getPreferenceManager()).thenReturn(pm);
mPowerUsageAdvanced.refreshPowerUsageDataList(mBatteryStatsHelper, prefGroup);
assertThat(prefGroup.getPreferenceCount()).isAtLeast(1);
for (int i = 0, count = prefGroup.getPreferenceCount(); i < count; i++) {
PowerGaugePreference pref = (PowerGaugePreference) prefGroup.getPreference(i);
assertThat(pref.isSelectable()).isFalse();
}
}
Aggregations