use of android.support.v7.preference.PreferenceGroup in project android_packages_apps_Settings by LineageOS.
the class Utils method addAll.
private static void addAll(PreferenceGroup group, List<String> ret) {
if (group == null)
return;
for (int i = 0; i < group.getPreferenceCount(); i++) {
Preference pref = group.getPreference(i);
ret.add(pref.getKey());
if (pref instanceof PreferenceGroup) {
addAll((PreferenceGroup) pref, ret);
}
}
}
use of android.support.v7.preference.PreferenceGroup in project android_packages_apps_Settings by LineageOS.
the class Utils method updatePreferenceToSpecificActivityOrRemove.
/**
* Finds a matching activity for a preference's intent. If a matching
* activity is not found, it will remove the preference.
*
* @param context The context.
* @param parentPreferenceGroup The preference group that contains the
* preference whose intent is being resolved.
* @param preferenceKey The key of the preference whose intent is being
* resolved.
* @param flags 0 or one or more of
* {@link #UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY}
* .
* @return Whether an activity was found. If false, the preference was
* removed.
*/
public static boolean updatePreferenceToSpecificActivityOrRemove(Context context, PreferenceGroup parentPreferenceGroup, String preferenceKey, int flags) {
Preference preference = parentPreferenceGroup.findPreference(preferenceKey);
if (preference == null) {
return false;
}
Intent intent = preference.getIntent();
if (intent != null) {
// Find the activity that is in the system image
PackageManager pm = context.getPackageManager();
List<ResolveInfo> list = pm.queryIntentActivities(intent, 0);
int listSize = list.size();
for (int i = 0; i < listSize; i++) {
ResolveInfo resolveInfo = list.get(i);
if ((resolveInfo.activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
// Replace the intent with this specific activity
preference.setIntent(new Intent().setClassName(resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name));
if ((flags & UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY) != 0) {
// Set the preference title to the activity's label
preference.setTitle(resolveInfo.loadLabel(pm));
}
return true;
}
}
}
// Did not find a matching activity, so remove the preference
parentPreferenceGroup.removePreference(preference);
return false;
}
use of android.support.v7.preference.PreferenceGroup in project android_packages_apps_Settings by LineageOS.
the class EnterpriseSetDefaultAppsListPreferenceController method createPreferences.
private void createPreferences(Context prefContext, PreferenceGroup group, EnumMap<EnterpriseDefaultApps, List<ApplicationInfo>> apps) {
if (group == null) {
return;
}
for (EnterpriseDefaultApps typeOfDefault : EnterpriseDefaultApps.values()) {
final List<ApplicationInfo> appsForCategory = apps.get(typeOfDefault);
if (appsForCategory == null || appsForCategory.isEmpty()) {
continue;
}
final Preference preference = new Preference(prefContext);
preference.setTitle(getTitle(prefContext, typeOfDefault, appsForCategory.size()));
preference.setSummary(buildSummaryString(prefContext, appsForCategory));
preference.setOrder(typeOfDefault.ordinal());
preference.setSelectable(false);
group.addPreference(preference);
}
}
use of android.support.v7.preference.PreferenceGroup in project android_packages_apps_Settings by LineageOS.
the class InactiveApps method init.
private void init() {
PreferenceGroup screen = getPreferenceScreen();
screen.removeAll();
screen.setOrderingAsAdded(false);
final Context context = getActivity();
final PackageManager pm = context.getPackageManager();
final UsageStatsManager usm = context.getSystemService(UsageStatsManager.class);
Intent launcherIntent = new Intent(Intent.ACTION_MAIN);
launcherIntent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> apps = pm.queryIntentActivities(launcherIntent, 0);
for (ResolveInfo app : apps) {
String packageName = app.activityInfo.applicationInfo.packageName;
Preference p = new Preference(getPrefContext());
p.setTitle(app.loadLabel(pm));
p.setIcon(app.loadIcon(pm));
p.setKey(packageName);
updateSummary(p);
p.setOnPreferenceClickListener(this);
screen.addPreference(p);
}
}
use of android.support.v7.preference.PreferenceGroup in project android_packages_apps_Settings by LineageOS.
the class ChannelNotificationSettings method updateDependents.
void updateDependents(boolean banned) {
PreferenceGroup parent;
if (mShowLegacyChannelConfig) {
parent = getPreferenceScreen();
setVisible(mImportanceToggle, checkCanBeVisible(NotificationManager.IMPORTANCE_MIN));
} else {
setVisible(mAdvanced, checkCanBeVisible(NotificationManager.IMPORTANCE_MIN));
setVisible(mImportance, checkCanBeVisible(NotificationManager.IMPORTANCE_MIN));
setVisible(mAdvanced, mLights, checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT) && canPulseLight());
setVisible(mVibrate, checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT));
setVisible(mRingtone, checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT));
parent = mAdvanced;
}
setVisible(parent, mBadge, checkCanBeVisible(NotificationManager.IMPORTANCE_MIN));
setVisible(parent, mPriority, checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT) || (checkCanBeVisible(NotificationManager.IMPORTANCE_LOW) && mDndVisualEffectsSuppressed));
setVisible(parent, mVisibilityOverride, isLockScreenSecure() && checkCanBeVisible(NotificationManager.IMPORTANCE_LOW));
setVisible(mBlockedDesc, mChannel.getImportance() == IMPORTANCE_NONE);
if (mAppLink != null) {
setVisible(mAppLink, checkCanBeVisible(NotificationManager.IMPORTANCE_MIN));
}
if (mFooter != null) {
setVisible(mFooter, checkCanBeVisible(NotificationManager.IMPORTANCE_MIN));
}
}
Aggregations