public void refreshSettings() { int lockscreenTargets = Settings.System.getInt(getContentResolver(), Settings.System.LOCKSCREEN_LAYOUT, 2); PreferenceGroup targetGroup = (PreferenceGroup) findPreference("lockscreen_targets"); targetGroup.removeAll(); // quad only uses first 4, but we make the system think there's 6 for the alternate layout // so only show 4 if (lockscreenTargets == 6) { Settings.System.putString( getContentResolver(), Settings.System.LOCKSCREEN_CUSTOM_APP_ACTIVITIES[4], "**null**"); Settings.System.putString( getContentResolver(), Settings.System.LOCKSCREEN_CUSTOM_APP_ACTIVITIES[5], "**null**"); lockscreenTargets = 4; } for (int i = 0; i < lockscreenTargets; i++) { ListPreference p = new ListPreference(getActivity()); String dialogTitle = String.format(getResources().getString(R.string.custom_app_n_dialog_title), i + 1); ; p.setDialogTitle(dialogTitle); p.setEntries(R.array.lockscreen_choice_entries); p.setEntryValues(R.array.lockscreen_choice_values); String title = String.format(getResources().getString(R.string.custom_app_n), i + 1); p.setTitle(title); p.setKey("lockscreen_target_" + i); p.setSummary(getProperSummary(i)); p.setOnPreferenceChangeListener(this); targetGroup.addPreference(p); } }
private void setPrefSubtypes(String prefSubtypes, Context context) { final PreferenceGroup group = getPreferenceScreen(); group.removeAll(); final InputMethodSubtype[] subtypesArray = AdditionalSubtype.createAdditionalSubtypesArray(prefSubtypes); for (final InputMethodSubtype subtype : subtypesArray) { final SubtypePreference pref = new SubtypePreference(context, subtype, mSubtypeProxy); group.addPreference(pref); } }
private void fillList(int simId) { String where = getFillListQuery(); Xlog.e(TAG, "fillList where: " + where); if (mUri == null) { Xlog.e(TAG, "fillList, mUri null !"); finish(); return; } Cursor cursor = getContentResolver() .query( mUri, new String[] {"_id", "name", "apn", "type", "sourcetype"}, where, null, null); PreferenceGroup apnList = (PreferenceGroup) findPreference("apn_list"); apnList.removeAll(); ArrayList<Preference> mmsApnList = new ArrayList<Preference>(); boolean keySetChecked = false; mSelectedKey = getSelectedApnKey(); Xlog.d(TAG, "fillList : mSelectedKey = " + mSelectedKey); cursor.moveToFirst(); while (!cursor.isAfterLast()) { String type = cursor.getString(TYPES_INDEX); if (mIsTetherApn && !TETHER_TYPE.equals(type)) { cursor.moveToNext(); continue; } String name = cursor.getString(NAME_INDEX); String apn = cursor.getString(APN_INDEX); String key = cursor.getString(ID_INDEX); int sourcetype = cursor.getInt(SOURCE_TYPE_INDEX); if ("cmmail".equals(apn) && sourcetype == 0) { cursor.moveToNext(); continue; } if (RCSE_TYPE.equals(type) && mRcseExt != null) { if (!mRcseExt.isRcseOnlyApnEnabled()) { cursor.moveToNext(); Xlog.d(TAG, "Vodafone not matched"); continue; } else { Xlog.d(TAG, "Vodafone matched"); } } ApnPreference pref = new ApnPreference(this); pref.setSimId(simId); // set pre sim id info to the ApnEditor pref.setKey(key); pref.setTitle(name); pref.setSummary(apn); pref.setPersistent(false); pref.setSourceType(sourcetype); pref.setOnPreferenceChangeListener(this); boolean isEditable = mExt.isAllowEditPresetApn(type, apn, mNumeric); pref.setApnEditable((sourcetype != 0) || isEditable); // All tether apn will be selectable for otthers , mms will not be selectable. boolean selectable = true; if (TETHER_TYPE.equals(type)) { selectable = mIsTetherApn; } else { selectable = !"mms".equals(type); } pref.setSelectable(selectable); if (selectable) { if ((mSelectedKey != null) && mSelectedKey.equals(key)) { pref.setChecked(); keySetChecked = true; Xlog.d(TAG, "apn key: " + key + " set."); } apnList.addPreference(pref); Xlog.i(TAG, "key: " + key + " added!"); } else { mmsApnList.add(pref); } cursor.moveToNext(); } cursor.close(); mSelectableApnCount = apnList.getPreferenceCount(); // if no key selected, choose the 1st one. if (!keySetChecked && mSelectableApnCount > 0) { int[] sourceTypeArray = new int[mSelectableApnCount]; for (int i = 0; i < mSelectableApnCount; i++) { sourceTypeArray[i] = ((ApnPreference) apnList.getPreference(i)).getSourceType(); } ApnPreference apnPref = (ApnPreference) mExt.getApnPref(apnList, mSelectableApnCount, sourceTypeArray); if (apnPref != null) { setSelectedApnKey(apnPref.getKey()); apnPref.setChecked(); Xlog.i(TAG, "Key does not match.Set key: " + apnPref.getKey() + "."); } } if (!mIsTetherApn) { for (Preference preference : mmsApnList) { apnList.addPreference(preference); } } getPreferenceScreen().setEnabled(getScreenEnableState()); }