use of android.preference.PreferenceGroup in project PhoneProfiles by henrichg.
the class PreferenceFragment method getAllPreferenceScreen.
private ArrayList<Preference> getAllPreferenceScreen(Preference p, ArrayList<Preference> list) {
if (p instanceof PreferenceCategory || p instanceof PreferenceScreen) {
PreferenceGroup pGroup = (PreferenceGroup) p;
int pCount = pGroup.getPreferenceCount();
if (p instanceof PreferenceScreen) {
list.add(p);
}
for (int i = 0; i < pCount; i++) {
getAllPreferenceScreen(pGroup.getPreference(i), list);
}
}
return list;
}
use of android.preference.PreferenceGroup in project android_packages_apps_Snap by LineageOS.
the class SettingsActivity method filterPreferences.
private void filterPreferences() {
String[] categories = { "photo", "video", "general", "developer" };
Set<String> set = mSettingsManager.getFilteredKeys();
if (!mDeveloperMenuEnabled) {
set.add(SettingsManager.KEY_MONO_PREVIEW);
set.add(SettingsManager.KEY_MONO_ONLY);
set.add(SettingsManager.KEY_CLEARSIGHT);
PreferenceGroup developer = (PreferenceGroup) findPreference("developer");
// it will cause crash.
if (developer != null) {
PreferenceScreen parent = getPreferenceScreen();
parent.removePreference(developer);
}
}
CharSequence[] entries = mSettingsManager.getEntries(SettingsManager.KEY_SCENE_MODE);
List<CharSequence> list = Arrays.asList(entries);
if (mDeveloperMenuEnabled && !list.contains("HDR")) {
Preference p = findPreference("pref_camera2_hdr_key");
if (p != null) {
PreferenceGroup developer = (PreferenceGroup) findPreference("developer");
developer.removePreference(p);
}
}
for (String key : set) {
Preference p = findPreference(key);
if (p == null)
continue;
for (int i = 0; i < categories.length; i++) {
PreferenceGroup group = (PreferenceGroup) findPreference(categories[i]);
if (group.removePreference(p))
break;
}
}
}
use of android.preference.PreferenceGroup in project android_packages_apps_Settings by LineageOS.
the class LanguageSettings method onCreateIMM.
private void onCreateIMM() {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
mInputMethodProperties = imm.getInputMethodList();
mLastInputMethodId = Settings.Secure.getString(getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
PreferenceGroup textCategory = (PreferenceGroup) findPreference("text_category");
int N = (mInputMethodProperties == null ? 0 : mInputMethodProperties.size());
for (int i = 0; i < N; ++i) {
InputMethodInfo property = mInputMethodProperties.get(i);
String prefKey = property.getId();
CharSequence label = property.loadLabel(getPackageManager());
boolean systemIME = isSystemIme(property);
// Don't show the toggle if it's the only keyboard in the system, or it's a system IME.
if (mHaveHardKeyboard || (N > 1 && !systemIME)) {
CheckBoxPreference chkbxPref = new CheckBoxPreference(this);
chkbxPref.setKey(prefKey);
chkbxPref.setTitle(label);
textCategory.addPreference(chkbxPref);
mCheckboxes.add(chkbxPref);
}
// If setting activity is available, add a setting screen entry.
if (null != property.getSettingsActivity()) {
PreferenceScreen prefScreen = new PreferenceScreen(this, null);
String settingsActivity = property.getSettingsActivity();
if (settingsActivity.lastIndexOf("/") < 0) {
settingsActivity = property.getPackageName() + "/" + settingsActivity;
}
prefScreen.setKey(settingsActivity);
prefScreen.setTitle(label);
if (N == 1) {
prefScreen.setSummary(getString(R.string.onscreen_keyboard_settings_summary));
} else {
CharSequence settingsLabel = getResources().getString(R.string.input_methods_settings_label_format, label);
prefScreen.setSummary(settingsLabel);
}
textCategory.addPreference(prefScreen);
}
}
}
use of android.preference.PreferenceGroup in project android_packages_apps_Settings by LineageOS.
the class ApnSettings method fillList.
private void fillList() {
String where = "numeric=\"" + android.os.SystemProperties.get(TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC, "") + "\"";
Cursor cursor = managedQuery(Telephony.Carriers.CONTENT_URI, new String[] { "_id", "name", "apn", "type" }, where, Telephony.Carriers.DEFAULT_SORT_ORDER);
PreferenceGroup apnList = (PreferenceGroup) findPreference("apn_list");
apnList.removeAll();
ArrayList<Preference> mmsApnList = new ArrayList<Preference>();
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);
ApnPreference pref = new ApnPreference(this);
pref.setKey(key);
pref.setTitle(name);
pref.setSummary(apn);
pref.setPersistent(false);
pref.setOnPreferenceChangeListener(this);
boolean selectable = ((type == null) || !type.equals("mms"));
pref.setSelectable(selectable);
if (selectable) {
if ((mSelectedKey != null) && mSelectedKey.equals(key)) {
pref.setChecked();
}
apnList.addPreference(pref);
} else {
mmsApnList.add(pref);
}
cursor.moveToNext();
}
cursor.close();
for (Preference preference : mmsApnList) {
apnList.addPreference(preference);
}
}
use of android.preference.PreferenceGroup in project android_packages_apps_Settings by LineageOS.
the class Settings method onResume.
@Override
protected void onResume() {
super.onResume();
findPreference(KEY_CALL_SETTINGS).setEnabled(!AirplaneModeEnabler.isAirplaneModeOn(this));
Intent intent = new Intent();
intent.setAction("android.intent.action.MAIN");
intent.addCategory("android.intent.category.HOME");
PreferenceGroup parent = (PreferenceGroup) findPreference(KEY_PARENT);
ActivityInfo a = getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY).activityInfo;
if (a != null && a.name.equals("com.android.launcher.Launcher") && (a.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
if (parent.findPreference(KEY_LAUNCHER) == null) {
parent.addPreference(mLauncherSettings);
}
} else {
if (parent.findPreference(KEY_LAUNCHER) != null) {
parent.removePreference(mLauncherSettings);
}
}
}
Aggregations