List of usage examples for android.preference PreferenceScreen findPreference
public Preference findPreference(CharSequence key)
From source file:com.ichi2.anki.PreferenceContext.java
/** Initializes the list of custom fonts shown in the preferences. */ private void initializeCustomFontsDialog(PreferenceScreen screen) { ListPreference defaultFontPreference = (ListPreference) screen.findPreference("defaultFont"); if (defaultFontPreference != null) { defaultFontPreference.setEntries(getCustomFonts("System default")); defaultFontPreference.setEntryValues(getCustomFonts("")); }//from w w w. jav a 2 s. c o m ListPreference browserEditorCustomFontsPreference = (ListPreference) screen .findPreference("browserEditorFont"); browserEditorCustomFontsPreference.setEntries(getCustomFonts("System default")); browserEditorCustomFontsPreference.setEntryValues(getCustomFonts("", true)); }
From source file:com.ichi2.anki.PreferenceContext.java
private void initializeLanguageDialog(PreferenceScreen screen) { ListPreference languageSelection = (ListPreference) screen.findPreference(LANGUAGE); if (languageSelection != null) { Map<String, String> items = new TreeMap<>(); for (String localeCode : LanguageUtil.APP_LANGUAGES) { Locale loc = LanguageUtil.getLocale(localeCode); items.put(loc.getDisplayName(), loc.toString()); }/*from ww w . jav a 2 s . c o m*/ CharSequence[] languageDialogLabels = new CharSequence[items.size() + 1]; CharSequence[] languageDialogValues = new CharSequence[items.size() + 1]; languageDialogLabels[0] = getResources().getString(R.string.language_system); languageDialogValues[0] = ""; int i = 1; for (Map.Entry<String, String> e : items.entrySet()) { languageDialogLabels[i] = e.getKey(); languageDialogValues[i] = e.getValue(); i++; } languageSelection.setEntries(languageDialogLabels); languageSelection.setEntryValues(languageDialogValues); } }
From source file:com.ichi2.anki.PreferenceContext.java
private void removeUnnecessaryAdvancedPrefs(PreferenceScreen screen) { PreferenceCategory plugins = (PreferenceCategory) screen.findPreference("category_plugins"); // Disable the emoji/kana buttons to scroll preference if those keys don't exist if (!CompatHelper.hasKanaAndEmojiKeys()) { CheckBoxPreference emojiScrolling = (CheckBoxPreference) screen.findPreference("scrolling_buttons"); if (emojiScrolling != null && plugins != null) { plugins.removePreference(emojiScrolling); }/* w w w . ja v a 2s. co m*/ } // Disable the double scroll preference if no scrolling keys if (!CompatHelper.hasScrollKeys() && !CompatHelper.hasKanaAndEmojiKeys()) { CheckBoxPreference doubleScrolling = (CheckBoxPreference) screen.findPreference("double_scrolling"); if (doubleScrolling != null && plugins != null) { plugins.removePreference(doubleScrolling); } } PreferenceCategory workarounds = (PreferenceCategory) screen.findPreference("category_workarounds"); if (workarounds != null) { CheckBoxPreference writeAnswersDisable = (CheckBoxPreference) screen .findPreference("writeAnswersDisable"); CheckBoxPreference useInputTag = (CheckBoxPreference) screen.findPreference("useInputTag"); CheckBoxPreference inputWorkaround = (CheckBoxPreference) screen.findPreference("inputWorkaround"); CheckBoxPreference longclickWorkaround = (CheckBoxPreference) screen .findPreference("textSelectionLongclickWorkaround"); CheckBoxPreference fixHebrewText = (CheckBoxPreference) screen.findPreference("fixHebrewText"); CheckBoxPreference safeDisplayMode = (CheckBoxPreference) screen.findPreference("safeDisplay"); CompatHelper.removeHiddenPreferences(this.getApplicationContext()); if (CompatHelper.isHoneycomb()) { workarounds.removePreference(longclickWorkaround); } if (CompatHelper.getSdkVersion() >= 13) { workarounds.removePreference(safeDisplayMode); } if (CompatHelper.getSdkVersion() >= 15) { workarounds.removePreference(writeAnswersDisable); workarounds.removePreference(inputWorkaround); } else { // For older Androids we never use the input tag anyway. workarounds.removePreference(useInputTag); } if (CompatHelper.getSdkVersion() >= 16) { workarounds.removePreference(fixHebrewText); } } }
From source file:net.sf.aria2.MainActivity.java
public void init(PreferenceScreen screen) { sericeMoniker = new Intent(getApplicationContext(), Aria2Service.class); pref = (TwoStatePreference) screen.findPreference(getString(R.string.service_enable_pref)); }
From source file:com.ichi2.anki.PreferenceContext.java
/** * Code which is run when a SharedPreference change has been detected * @param prefs instance of SharedPreferences * @param key key in prefs which is being updated * @param listener PreferenceActivity of PreferenceFragment which is hosting the preference *//*from w w w . j a va2s. c o m*/ private void updatePreference(SharedPreferences prefs, String key, PreferenceContext listener) { try { PreferenceScreen screen = listener.getPreferenceScreen(); Preference pref = screen.findPreference(key); // Handle special cases switch (key) { case "timeoutAnswer": { CheckBoxPreference keepScreenOn = (CheckBoxPreference) screen.findPreference("keepScreenOn"); keepScreenOn.setChecked(((CheckBoxPreference) pref).isChecked()); break; } case LANGUAGE: closePreferences(); break; case "convertFenText": if (((CheckBoxPreference) pref).isChecked()) { ChessFilter.install(Hooks.getInstance(getApplicationContext())); } else { ChessFilter.uninstall(Hooks.getInstance(getApplicationContext())); } break; case "fixHebrewText": if (((CheckBoxPreference) pref).isChecked()) { HebrewFixFilter.install(Hooks.getInstance(getApplicationContext())); showDialog(DIALOG_HEBREW_FONT); } else { HebrewFixFilter.uninstall(Hooks.getInstance(getApplicationContext())); } break; case "showProgress": getCol().getConf().put("dueCounts", ((CheckBoxPreference) pref).isChecked()); getCol().setMod(); break; case "showEstimates": getCol().getConf().put("estTimes", ((CheckBoxPreference) pref).isChecked()); getCol().setMod(); break; case "newSpread": getCol().getConf().put("newSpread", Integer.parseInt(((ListPreference) pref).getValue())); getCol().setMod(); break; case "timeLimit": getCol().getConf().put("timeLim", ((NumberRangePreference) pref).getValue() * 60); getCol().setMod(); break; case "learnCutoff": getCol().getConf().put("collapseTime", ((NumberRangePreference) pref).getValue() * 60); getCol().setMod(); break; case "useCurrent": getCol().getConf().put("addToCur", ((ListPreference) pref).getValue().equals("0")); getCol().setMod(); break; case "dayOffset": { int hours = ((SeekBarPreference) pref).getValue(); Timestamp crtTime = new Timestamp(getCol().getCrt() * 1000); Calendar date = GregorianCalendar.getInstance(); date.setTimeInMillis(crtTime.getTime()); date.set(Calendar.HOUR_OF_DAY, hours); getCol().setCrt(date.getTimeInMillis() / 1000); getCol().setMod(); break; } case "minimumCardsDueForNotification": { ListPreference listpref = (ListPreference) screen.findPreference("minimumCardsDueForNotification"); if (listpref != null) { updateNotificationPreference(listpref); } break; } case "reportErrorMode": { String value = prefs.getString("reportErrorMode", ""); AnkiDroidApp.getInstance().setAcraReportingMode(value); break; } case "syncAccount": { SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(getBaseContext()); String username = preferences.getString("username", ""); Preference syncAccount = screen.findPreference("syncAccount"); if (syncAccount != null) { if (TextUtils.isEmpty(username)) { syncAccount.setSummary(R.string.sync_account_summ_logged_out); } else { syncAccount.setSummary(getString(R.string.sync_account_summ_logged_in, username)); } } break; } case "providerEnabled": { ComponentName providerName = new ComponentName(this, "com.ichi2.anki.provider.CardContentProvider"); PackageManager pm = getPackageManager(); int state; if (((CheckBoxPreference) pref).isChecked()) { state = PackageManager.COMPONENT_ENABLED_STATE_ENABLED; Timber.i("AnkiDroid ContentProvider enabled by user"); } else { state = PackageManager.COMPONENT_ENABLED_STATE_DISABLED; Timber.i("AnkiDroid ContentProvider disabled by user"); } pm.setComponentEnabledSetting(providerName, state, PackageManager.DONT_KILL_APP); break; } } // Update the summary text to reflect new value updateSummary(pref); } catch (BadTokenException e) { Timber.e(e, "Preferences: BadTokenException on showDialog"); } catch (NumberFormatException | JSONException e) { throw new RuntimeException(); } }
From source file:com.nextgis.firereporter.SettingsSupport.java
public SettingsSupport(Context context, PreferenceScreen screen) { this.screen = screen; this.context = context; // Load the preferences from an XML resource //addPreferencesFromResource(R.xml.preferences); mSendDataIntervalPref = (ListPreference) screen.findPreference(SettingsActivity.KEY_PREF_INTERVAL); if (mSendDataIntervalPref != null) { int index = mSendDataIntervalPref.findIndexOfValue(mSendDataIntervalPref.getValue()); if (index >= 0) { mSendDataIntervalPref.setSummary(mSendDataIntervalPref.getEntries()[index]); } else {//from w w w. j ava 2 s.c om mSendDataIntervalPref.setSummary((String) mSendDataIntervalPref.getValue()); } } mSaveBattPref = (CheckBoxPreference) screen.findPreference(SettingsActivity.KEY_PREF_SERVICE_BATT_SAVE); if (mSaveBattPref != null) mSaveBattPref.setSummary(mSaveBattPref.isChecked() ? R.string.stOn : R.string.stOff); mNotifyLEDPref = (CheckBoxPreference) screen.findPreference(SettingsActivity.KEY_PREF_NOTIFY_LED); if (mNotifyLEDPref != null) mNotifyLEDPref.setSummary(mNotifyLEDPref.isChecked() ? R.string.stOn : R.string.stOff); mPlaySoundPref = (CheckBoxPreference) screen.findPreference(SettingsActivity.KEY_PREF_NOTIFY_SOUND); if (mPlaySoundPref != null) mPlaySoundPref.setSummary(mPlaySoundPref.isChecked() ? R.string.stOn : R.string.stOff); mVibroPref = (CheckBoxPreference) screen.findPreference(SettingsActivity.KEY_PREF_NOTIFY_VIBRO); if (mVibroPref != null) mVibroPref.setSummary(mVibroPref.isChecked() ? R.string.stOn : R.string.stOff); mRowCountPref = (EditTextPreference) screen.findPreference(SettingsActivity.KEY_PREF_ROW_COUNT); if (mRowCountPref != null) mRowCountPref.setSummary((String) mRowCountPref.getText()); mFireSearchRadiusPref = (EditTextPreference) screen .findPreference(SettingsActivity.KEY_PREF_FIRE_SEARCH_RADIUS); if (mFireSearchRadiusPref != null) mFireSearchRadiusPref .setSummary((String) mFireSearchRadiusPref.getText() + " " + context.getString(R.string.km)); mDayIntervalPref = (ListPreference) screen.findPreference(SettingsActivity.KEY_PREF_SEARCH_DAY_INTERVAL); if (mDayIntervalPref != null) { int index = mDayIntervalPref.findIndexOfValue(mDayIntervalPref.getValue()); if (index >= 0) { mDayIntervalPref.setSummary(mDayIntervalPref.getEntries()[index]); } else { mDayIntervalPref.setSummary((String) mDayIntervalPref.getValue()); } } mSearchCurrentDatePref = (CheckBoxPreference) screen .findPreference(SettingsActivity.KEY_PREF_SEARCH_CURR_DAY); if (mSearchCurrentDatePref != null) mSearchCurrentDatePref.setSummary(mSearchCurrentDatePref.isChecked() ? R.string.stSearchCurrentDayOn : R.string.stSearchCurrentDayOff); mNasaServerPref = (EditTextPreference) screen.findPreference(SettingsActivity.KEY_PREF_SRV_NASA); if (mNasaServerPref != null) mNasaServerPref.setSummary((String) mNasaServerPref.getText()); mNasaServerUserPref = (EditTextPreference) screen.findPreference(SettingsActivity.KEY_PREF_SRV_NASA_USER); if (mNasaServerUserPref != null) mNasaServerUserPref.setSummary((String) mNasaServerUserPref.getText()); mUserServerPref = (EditTextPreference) screen.findPreference(SettingsActivity.KEY_PREF_SRV_USER); if (mUserServerPref != null) mUserServerPref.setSummary((String) mUserServerPref.getText()); mUserServerUserPref = (EditTextPreference) screen.findPreference(SettingsActivity.KEY_PREF_SRV_USER_USER); if (mUserServerUserPref != null) mUserServerUserPref.setSummary((String) mUserServerUserPref.getText()); mScanServerUserPref = (EditTextPreference) screen.findPreference(SettingsActivity.KEY_PREF_SRV_SCAN_USER); if (mScanServerUserPref != null) mScanServerUserPref.setSummary((String) mScanServerUserPref.getText()); mNasaServerPassPref = (EditTextPreference) screen.findPreference(SettingsActivity.KEY_PREF_SRV_NASA_PASS); mUserServerPassPref = (EditTextPreference) screen.findPreference(SettingsActivity.KEY_PREF_SRV_USER_PASS); mScanServerPassPref = (EditTextPreference) screen.findPreference(SettingsActivity.KEY_PREF_SRV_SCAN_PASS); final Preference checkNasaConnPref = (Preference) screen .findPreference(SettingsActivity.KEY_PREF_SRV_NASA_CHECK_CONN); final Preference checkUserConnPref = (Preference) screen .findPreference(SettingsActivity.KEY_PREF_SRV_USER_CHECK_CONN); final Preference checkScanConnPref = (Preference) screen .findPreference(SettingsActivity.KEY_PREF_SRV_SCAN_CHECK_CONN); mReturnHandler = new Handler() { @SuppressLint("NewApi") public void handleMessage(Message msg) { Bundle resultData = msg.getData(); boolean bHaveErr = resultData.getBoolean(GetFiresService.ERROR); int nType = resultData.getInt(GetFiresService.SOURCE); if (bHaveErr) { Toast.makeText(SettingsSupport.this.context, resultData.getString(GetFiresService.ERR_MSG), Toast.LENGTH_LONG).show(); if (nType == 1) {//user checkUserConnPref.setSummary(R.string.stConnectionFailed); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) checkUserConnPref.setIcon(R.drawable.ic_alerts_and_states_error); } else if (nType == 2) {//nasa checkNasaConnPref.setSummary(R.string.stConnectionFailed); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) checkNasaConnPref.setIcon(R.drawable.ic_alerts_and_states_error); } else if (nType == 3) {//scanex checkScanConnPref.setSummary(R.string.stConnectionFailed); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) checkScanConnPref.setIcon(R.drawable.ic_alerts_and_states_error); } } else { String sData = resultData.getString(GetFiresService.JSON); if (nType == 1) {//user JSONObject jsonMainObject; try { jsonMainObject = new JSONObject(sData); if (jsonMainObject.getBoolean("error")) { String sMsg = jsonMainObject.getString("msg"); Toast.makeText(SettingsSupport.this.context, sMsg, Toast.LENGTH_LONG).show(); checkUserConnPref.setSummary(R.string.stConnectionFailed); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) checkUserConnPref.setIcon(R.drawable.ic_alerts_and_states_error); } else { checkUserConnPref.setSummary(R.string.stConnectionSucceeded); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) checkUserConnPref.setIcon(R.drawable.ic_navigation_accept); } } catch (JSONException e) { Toast.makeText(SettingsSupport.this.context, e.toString(), Toast.LENGTH_LONG).show(); e.printStackTrace(); checkUserConnPref.setSummary(R.string.sCheckDBConnSummary); } } else if (nType == 2) {//nasa JSONObject jsonMainObject; try { jsonMainObject = new JSONObject(sData); if (jsonMainObject.getBoolean("error")) { String sMsg = jsonMainObject.getString("msg"); Toast.makeText(SettingsSupport.this.context, sMsg, Toast.LENGTH_LONG).show(); checkNasaConnPref.setSummary(R.string.stConnectionFailed); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) checkNasaConnPref.setIcon(R.drawable.ic_alerts_and_states_error); } else { checkNasaConnPref.setSummary(R.string.stConnectionSucceeded); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) checkNasaConnPref.setIcon(R.drawable.ic_navigation_accept); } } catch (JSONException e) { Toast.makeText(SettingsSupport.this.context, e.toString(), Toast.LENGTH_LONG).show(); e.printStackTrace(); checkNasaConnPref.setSummary(R.string.sCheckDBConnSummary); } } else if (nType == 3) {//scanex if (sData.length() == 0) { String sMsg = "Connect failed"; Toast.makeText(SettingsSupport.this.context, sMsg, Toast.LENGTH_LONG).show(); checkScanConnPref.setSummary(R.string.stConnectionFailed); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) checkScanConnPref.setIcon(R.drawable.ic_alerts_and_states_error); } else { checkScanConnPref.setSummary(R.string.stConnectionSucceeded); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) checkScanConnPref.setIcon(R.drawable.ic_navigation_accept); new HttpGetter(SettingsSupport.this.context, 4, SettingsSupport.this.context.getString(R.string.stChecking), mReturnHandler, true).execute( "http://fires.kosmosnimki.ru/SAPI/Account/Get/?CallBackName=" + GetFiresService.USER_ID, sData); } } else if (nType == 4) {//scanex detailes try { String sSubData = GetFiresService.removeJsonT(sData); JSONObject rootobj = new JSONObject(sSubData); String sStatus = rootobj.getString("Status"); if (sStatus.equals("OK")) { JSONObject resobj = rootobj.getJSONObject("Result"); String sName = ""; if (!resobj.isNull("FullName")) sName = resobj.getString("FullName"); String sPhone = ""; if (!resobj.isNull("Phone")) sPhone = resobj.getString("Phone"); //add properties if (sPhone.length() > 0) { Preference PhonePref = new Preference(SettingsSupport.this.context); PhonePref.setTitle(R.string.stScanexServerUserPhone); PhonePref.setSummary(sPhone); PhonePref.setOrder(2); SettingsSupport.this.screen.addPreference(PhonePref); } if (sName.length() > 0) { Preference NamePref = new Preference(SettingsSupport.this.context); NamePref.setTitle(R.string.stScanexServerUserFullName); NamePref.setSummary(sName); NamePref.setOrder(2); SettingsSupport.this.screen.addPreference(NamePref); } } else { Toast.makeText(SettingsSupport.this.context, rootobj.getString("ErrorInfo"), Toast.LENGTH_LONG).show(); } } catch (JSONException e) { Toast.makeText(SettingsSupport.this.context, e.toString(), Toast.LENGTH_LONG).show(); e.printStackTrace(); } } } }; }; if (checkNasaConnPref != null) checkNasaConnPref.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { String sURL = mNasaServerPref.getText() + "?function=test_conn_nasa&user=" + mNasaServerUserPref.getText() + "&pass=" + mNasaServerPassPref.getText(); new HttpGetter(SettingsSupport.this.context, 2, SettingsSupport.this.context.getString(R.string.stChecking), mReturnHandler, true) .execute(sURL); return true; } }); if (checkUserConnPref != null) checkUserConnPref.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { String sURL = mUserServerPref.getText() + "?function=test_conn_user&user=" + mUserServerUserPref.getText() + "&pass=" + mUserServerPassPref.getText(); new HttpGetter(SettingsSupport.this.context, 1, SettingsSupport.this.context.getString(R.string.stChecking), mReturnHandler, true) .execute(sURL); return true; } }); if (checkScanConnPref != null) checkScanConnPref.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { //String sURL = mUserServerPref.getText() + "?function=test_conn_nasa&user=" + mUserServerUserPref.getText() + "&pass=" + mUserServerPassPref.getText(); new ScanexHttpLogin(SettingsSupport.this.context, 3, SettingsSupport.this.context.getString(R.string.stChecking), mReturnHandler, true) .execute(mScanServerUserPref.getText(), mScanServerPassPref.getText()); return true; } }); }
From source file:com.zhengde163.netguard.ActivitySettings.java
@Override protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); final PreferenceScreen screen = getPreferenceScreen(); final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); // Handle auto enable Preference pref_auto_enable = screen.findPreference("auto_enable"); pref_auto_enable.setTitle(getString(R.string.setting_auto, prefs.getString("auto_enable", "0"))); // Handle screen delay Preference pref_screen_delay = screen.findPreference("screen_delay"); pref_screen_delay.setTitle(getString(R.string.setting_delay, prefs.getString("screen_delay", "0"))); }
From source file:nz.Intelx.DroidNetLogin.DroidNetLoginActivity.java
@Override public void onPreferenceAttached(PreferenceScreen root, int xmlId) { if (root == null) return; //for whatever reason in very rare cases this is null updatePreference(root.getSharedPreferences()); //registering the listeners to the preference screen root.findPreference("login_preference").setOnPreferenceChangeListener(this); root.findPreference("debug_preference").setOnPreferenceChangeListener(this); root.findPreference("proxy_preference").setOnPreferenceChangeListener(this); root.findPreference("manual_login").setOnPreferenceClickListener(this); root.findPreference("manual_logout").setOnPreferenceClickListener(this); root.findPreference("manual_startProxy").setOnPreferenceClickListener(this); root.findPreference("manual_stopProxy").setOnPreferenceClickListener(this); //match summary for Login list preference to selected preference ListPreference login_preference = (ListPreference) root.findPreference("login_preference"); CharSequence Login_Summary = login_preference.getEntry(); login_preference.setSummary(Login_Summary); }
From source file:com.ichi2.anki.PreferenceContext.java
private void initSubscreen(String action, PreferenceContext listener) { PreferenceScreen screen; switch (action) { case "com.ichi2.anki.prefs.general": listener.addPreferencesFromResource(R.xml.preferences_general); screen = listener.getPreferenceScreen(); // Build languages initializeLanguageDialog(screen); break;//from w ww . j a v a 2s. com case "com.ichi2.anki.prefs.reviewing": listener.addPreferencesFromResource(R.xml.preferences_reviewing); screen = listener.getPreferenceScreen(); // Show error toast if the user tries to disable answer button without gestures on ListPreference fullscreenPreference = (ListPreference) screen.findPreference("fullscreenMode"); fullscreenPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, final Object newValue) { SharedPreferences prefs = AnkiDroidApp.getSharedPrefs(Preferences.this); if (prefs.getBoolean("gestures", false) || !newValue.equals("2")) { return true; } else { Toast.makeText(getApplicationContext(), R.string.full_screen_error_gestures, Toast.LENGTH_LONG).show(); return false; } } }); break; case "com.ichi2.anki.prefs.fonts": listener.addPreferencesFromResource(R.xml.preferences_fonts); screen = listener.getPreferenceScreen(); initializeCustomFontsDialog(screen); break; case "com.ichi2.anki.prefs.gestures": listener.addPreferencesFromResource(R.xml.preferences_gestures); break; case "com.ichi2.anki.prefs.advanced": listener.addPreferencesFromResource(R.xml.preferences_advanced); screen = listener.getPreferenceScreen(); // Check that input is valid before committing change in the collection path EditTextPreference collectionPathPreference = (EditTextPreference) screen.findPreference("deckPath"); collectionPathPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, final Object newValue) { final String newPath = (String) newValue; try { CollectionHelper.initializeAnkiDroidDirectory(newPath); return true; } catch (StorageAccessException e) { Timber.e(e, "Could not initialize directory: %s", newPath); Toast.makeText(getApplicationContext(), R.string.dialog_collection_path_not_dir, Toast.LENGTH_LONG).show(); return false; } } }); // Force full sync option Preference fullSyncPreference = screen.findPreference("force_full_sync"); fullSyncPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { // TODO: Could be useful to show the full confirmation dialog getCol().modSchemaNoCheck(); getCol().setMod(); Toast.makeText(getApplicationContext(), android.R.string.ok, Toast.LENGTH_SHORT).show(); return true; } }); // Workaround preferences removeUnnecessaryAdvancedPrefs(screen); break; } }
From source file:eu.faircode.netguard.ActivitySettings.java
private void updateTechnicalInfo() { PreferenceScreen screen = getPreferenceScreen(); Preference pref_technical_info = screen.findPreference("technical_info"); Preference pref_technical_network = screen.findPreference("technical_network"); pref_technical_info.setSummary(Util.getGeneralInfo(this)); pref_technical_network.setSummary(Util.getNetworkInfo(this)); }