@Override public boolean onPreferenceChange(Preference preference, Object newValue) { String prefName = preference.getKey(); if (prefName != null && prefName.equals("privacy.masterpassword.enabled")) { showDialog( (Boolean) newValue ? DIALOG_CREATE_MASTER_PASSWORD : DIALOG_REMOVE_MASTER_PASSWORD); return false; } else if (prefName != null && prefName.equals("browser.menu.showCharacterEncoding")) { setCharEncodingState(((String) newValue).equals("true")); } setPreference(prefName, newValue); if (preference instanceof ListPreference) { // We need to find the entry for the new value int newIndex = ((ListPreference) preference).findIndexOfValue((String) newValue); CharSequence newEntry = ((ListPreference) preference).getEntries()[newIndex]; ((ListPreference) preference).setSummary(newEntry); } else if (preference instanceof LinkPreference) { finish(); } else if (preference instanceof FontSizePreference) { final FontSizePreference fontSizePref = (FontSizePreference) preference; fontSizePref.setSummary(fontSizePref.getSavedFontSizeName()); } return true; }