use of android.support.v7.preference.PreferenceGroup in project android_packages_apps_Settings by LineageOS.
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_Settings by LineageOS.
the class ProgressiveDisclosureMixin method findPreference.
/**
* Finds preference by key, either from screen or from collapsed list.
*/
public Preference findPreference(PreferenceScreen screen, CharSequence key) {
Preference preference = screen.findPreference(key);
if (preference != null) {
return preference;
}
for (int i = 0; i < mCollapsedPrefs.size(); i++) {
final Preference pref = mCollapsedPrefs.get(i);
if (TextUtils.equals(key, pref.getKey())) {
return pref;
}
if (pref instanceof PreferenceGroup) {
final Preference returnedPreference = ((PreferenceGroup) pref).findPreference(key);
if (returnedPreference != null) {
return returnedPreference;
}
}
}
Log.d(TAG, "Cannot find preference with key " + key);
return null;
}
use of android.support.v7.preference.PreferenceGroup in project android_packages_apps_Settings by LineageOS.
the class PrivateVolumeSettings method addCategory.
private PreferenceCategory addCategory(PreferenceGroup group, CharSequence title) {
PreferenceCategory category;
if (mHeaderPoolIndex < mHeaderPreferencePool.size()) {
category = mHeaderPreferencePool.get(mHeaderPoolIndex);
} else {
category = new PreferenceCategory(getPrefContext());
mHeaderPreferencePool.add(category);
}
category.setTitle(title);
category.removeAll();
addPreference(group, category);
++mHeaderPoolIndex;
return category;
}
use of android.support.v7.preference.PreferenceGroup in project android_packages_apps_Settings by LineageOS.
the class SecondaryUserController method displayPreference.
@Override
public void displayPreference(PreferenceScreen screen) {
if (mStoragePreference == null) {
mStoragePreference = new StorageItemPreference(screen.getContext());
PreferenceGroup group = (PreferenceGroup) screen.findPreference(TARGET_PREFERENCE_GROUP_KEY);
mStoragePreference.setTitle(mUser.name);
mStoragePreference.setKey(PREFERENCE_KEY_BASE + mUser.id);
if (mSize != SIZE_NOT_SET) {
mStoragePreference.setStorageSize(mSize, mTotalSizeBytes);
}
group.setVisible(true);
group.addPreference(mStoragePreference);
maybeSetIcon();
}
}
use of android.support.v7.preference.PreferenceGroup in project android_packages_apps_Settings by LineageOS.
the class VpnSettings method setShownPreferences.
@VisibleForTesting
@UiThread
public void setShownPreferences(final Collection<Preference> updates) {
mLegacyVpnPreferences.values().retainAll(updates);
mAppPreferences.values().retainAll(updates);
// Change {@param updates} in-place to only contain new preferences that were not already
// added to the preference screen.
final PreferenceGroup vpnGroup = getPreferenceScreen();
for (int i = vpnGroup.getPreferenceCount() - 1; i >= 0; i--) {
Preference p = vpnGroup.getPreference(i);
if (updates.contains(p)) {
updates.remove(p);
} else {
vpnGroup.removePreference(p);
}
}
// Show any new preferences on the screen
for (Preference pref : updates) {
vpnGroup.addPreference(pref);
}
}
Aggregations