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); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle(R.string.settings_title); addPreferencesFromResource(R.xml.preferences); findPreference("enableVirtualKeypad").setDefaultValue(getDefaultVirtualKeypadEnabled(this)); PreferenceGroup group = (PreferenceGroup) findPreference("gameKeyBindings"); int[] defaultKeys = getDefaultKeys(this); for (int i = 0; i < keyPrefKeys.length; i++) { GameKeyPreference pref = new GameKeyPreference(this); pref.setKey(keyPrefKeys[i]); pref.setTitle(keyDisplayNames[i]); pref.setDefaultValue(defaultKeys[i]); group.addPreference(pref); } findPreference("apuEnabled").setOnPreferenceChangeListener(this); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(MARKET_SEARCH_URI + getPackageName())); findPreference("appAbout").setIntent(intent); intent = new Intent(Intent.ACTION_WEB_SEARCH); intent.putExtra(SearchManager.QUERY, getResources().getString(R.string.search_roms_keyword)); findPreference("searchRoms").setIntent(intent); setListSummary("scalingMode", "stretch"); }
@Override public void initPreferences(Activity activity, PreferenceGroup preferenceGroup) { for (final String url : urlsToTest) { Preference preference = new Preference(activity); preference.setTitle(url); preference.setSummary(url); preference.setOnPreferenceClickListener( new OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { NotificationBuilder builder = new NotificationBuilder("notificationFromBundle"); builder.setTicker("Sample Ticker"); builder.setContentTitle("Sample Content Title"); builder.setContentText(url); builder.setSingleTopUrl(url); builder.setSmallIcon(AbstractApplication.get().getNotificationIconResId()); builder.setWhen(DateUtils.nowMillis()); NotificationUtils.sendNotification(IdGenerator.getIntId(), builder); return true; } }); preferenceGroup.addPreference(preference); } }
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); } }
@Override public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException { if (localName.equalsIgnoreCase(MAP)) { if (mRendererInfo != null) { if (attributes.getValue(ID).equalsIgnoreCase(mMapId)) { mRendererInfo.ID = attributes.getValue(ID); mRendererInfo.NAME = attributes.getValue(NAME); mRendererInfo.BASEURL = attributes.getValue(BASEURL); mRendererInfo.ZOOM_MINLEVEL = Integer.parseInt(attributes.getValue(ZOOM_MINLEVEL)); mRendererInfo.ZOOM_MAXLEVEL = Integer.parseInt(attributes.getValue(ZOOM_MAXLEVEL)); mRendererInfo.IMAGE_FILENAMEENDING = attributes.getValue(IMAGE_FILENAMEENDING); mRendererInfo.MAPTILE_SIZEPX = Integer.parseInt(attributes.getValue(MAPTILE_SIZEPX)); mRendererInfo.URL_BUILDER_TYPE = Integer.parseInt(attributes.getValue(URL_BUILDER_TYPE)); mRendererInfo.TILE_SOURCE_TYPE = Integer.parseInt(attributes.getValue(TILE_SOURCE_TYPE)); mRendererInfo.PROJECTION = Integer.parseInt(attributes.getValue(PROJECTION)); mRendererInfo.YANDEX_TRAFFIC_ON = Integer.parseInt(attributes.getValue(YANDEX_TRAFFIC_ON)); mRendererInfo.LAYER = false; if (attributes.getIndex(LAYER) > -1) mRendererInfo.LAYER = Boolean.parseBoolean(attributes.getValue(LAYER)); mRendererInfo.CACHE = ""; if (attributes.getIndex(CACHE) > -1) mRendererInfo.CACHE = attributes.getValue(CACHE); } } else if (mSubmenu != null) { final int i = attributes.getIndex(LAYER); if (mSharedPreferences.getBoolean( MainPreferences.PREF_PREDEFMAPS_ + attributes.getValue(ID), true) && (i == -1 || !attributes.getValue(LAYER).equalsIgnoreCase(TRUE))) { final MenuItem item = mSubmenu.add(attributes.getValue(NAME)); item.setTitleCondensed(attributes.getValue(ID)); } } else if (mPrefMapsgroup != null) { final int i = attributes.getIndex(LAYER); if (i == -1 || !attributes.getValue(LAYER).equalsIgnoreCase(TRUE)) { CheckBoxPreference pref = new CheckBoxPreference(mPrefActivity); pref.setKey(MainPreferences.PREF_PREDEFMAPS_ + attributes.getValue(ID)); pref.setTitle(attributes.getValue(NAME)); pref.setSummary(attributes.getValue(DESCR)); // [email protected] this does set the pref on the pref page to not checked, but // cancels out any effect of behavior (they still show up, and checking them changes // nothing) pref.setDefaultValue(true); mPrefMapsgroup.addPreference(pref); } } } super.startElement(uri, localName, name, attributes); }
@Override public void onResume() { super.onResume(); // Check KeyStore here, so others do not need to deal with it. if (!mKeyStore.isUnlocked()) { if (!mUnlocking) { // Let us unlock KeyStore. See you later! Credentials.getInstance().unlock(getActivity()); } else { // We already tried, but it is still not working! finishFragment(); } mUnlocking = !mUnlocking; return; } // Now KeyStore is always unlocked. Reset the flag. mUnlocking = false; // Currently we are the only user of profiles in KeyStore. // Assuming KeyStore and KeyGuard do the right thing, we can // safely cache profiles in the memory. if (mPreferences.size() == 0) { PreferenceGroup group = getPreferenceScreen(); final Context context = getActivity(); final List<VpnProfile> profiles = loadVpnProfiles(mKeyStore); for (VpnProfile profile : profiles) { final VpnPreference pref = new VpnPreference(context, profile); pref.setOnPreferenceClickListener(this); mPreferences.put(profile.key, pref); group.addPreference(pref); } } // Show the dialog if there is one. if (mDialog != null) { mDialog.setOnDismissListener(this); mDialog.show(); } // Start monitoring. if (mUpdater == null) { mUpdater = new Handler(this); } mUpdater.sendEmptyMessage(0); // Register for context menu. Hmmm, getListView() is hidden? registerForContextMenu(getListView()); }
@Override public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) { Context context = preferenceGroup.getContext(); addPasswordPreference(preferenceGroup); if (canHttps()) { CheckBoxPreference httpsPref = new CheckBoxPreference(context); httpsPref.setTitle(R.string.pref_use_https); httpsPref.setSummary(R.string.pref_use_https_summary); httpsPref.setKey(getSharedKey(PREF_KEY_USE_HTTPS)); httpsPref.setDefaultValue(useHttpsDefaultValue()); preferenceGroup.addPreference(httpsPref); addUnsafeSslPreference(preferenceGroup, getSharedKey(PREF_KEY_USE_HTTPS)); } addProxyPreferences(preferenceGroup); }
@Override public void onSavePressed(SubtypePreference subtypePref) { final InputMethodSubtype subtype = subtypePref.getSubtype(); if (!subtypePref.hasBeenModified()) { return; } if (findDuplicatedSubtype(subtype) == null) { ImfUtils.setAdditionalInputMethodSubtypes(getActivity(), getSubtypes()); return; } // Saved subtype is duplicated. final PreferenceGroup group = getPreferenceScreen(); group.removePreference(subtypePref); subtypePref.revert(); group.addPreference(subtypePref); showSubtypeAlreadyExistsToast(subtype); }
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()); }
void addOption(ZLBooleanOption option, String resourceKey) { ZLBooleanPreference preference = new ZLBooleanPreference(ZLPreferenceActivity.this, option, Resource, resourceKey); myGroup.addPreference(preference); myPreferences.add(preference); }
void addPreference(ZLPreference preference) { myGroup.addPreference((Preference) preference); myPreferences.add(preference); }
Screen createPreferenceScreen(String resourceKey) { Screen screen = new Screen(Resource, resourceKey); myGroup.addPreference(screen.myScreen); return screen; }
public void addPplPrf(PreferenceGroup prefGroup) { if (prefGroup instanceof PreferenceGroup) { prefGroup.addPreference(mPreference); } }