use of android.preference.Preference in project android_packages_inputmethods_LatinIME by CyanogenMod.
the class SettingsFragment method onCreate.
@Override
public void onCreate(final Bundle icicle) {
super.onCreate(icicle);
setHasOptionsMenu(true);
setInputMethodSettingsCategoryTitle(R.string.language_selection_title);
setSubtypeEnablerTitle(R.string.select_language);
addPreferencesFromResource(R.xml.prefs);
final PreferenceScreen preferenceScreen = getPreferenceScreen();
preferenceScreen.setTitle(ApplicationUtils.getActivityTitleResId(getActivity(), SettingsActivity.class));
if (!ProductionFlags.ENABLE_ACCOUNT_SIGN_IN) {
final Preference accountsPreference = findPreference(Settings.SCREEN_ACCOUNTS);
preferenceScreen.removePreference(accountsPreference);
}
if (!JniUtils.mHaveGestureLib) {
final Preference gesturePreference = findPreference(Settings.SCREEN_GESTURE);
preferenceScreen.removePreference(gesturePreference);
}
}
use of android.preference.Preference in project android_packages_inputmethods_LatinIME by CyanogenMod.
the class DictionarySettingsFragment method refreshInterface.
void refreshInterface() {
final Activity activity = getActivity();
if (null == activity)
return;
final PreferenceGroup prefScreen = getPreferenceScreen();
final Collection<? extends Preference> prefList = createInstalledDictSettingsCollection(mClientId);
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
// TODO: display this somewhere
// if (0 != lastUpdate) mUpdateNowPreference.setSummary(updateNowSummary);
refreshNetworkState();
removeAnyDictSettings(prefScreen);
int i = 0;
for (Preference preference : prefList) {
preference.setOrder(i++);
prefScreen.addPreference(preference);
}
}
});
}
use of android.preference.Preference in project android_packages_inputmethods_LatinIME by CyanogenMod.
the class DictionarySettingsFragment method findWordListPreference.
private WordListPreference findWordListPreference(final String id) {
final PreferenceGroup prefScreen = getPreferenceScreen();
if (null == prefScreen) {
Log.e(TAG, "Could not find the preference group");
return null;
}
for (int i = prefScreen.getPreferenceCount() - 1; i >= 0; --i) {
final Preference pref = prefScreen.getPreference(i);
if (pref instanceof WordListPreference) {
final WordListPreference wlPref = (WordListPreference) pref;
if (id.equals(wlPref.mWordlistId)) {
return wlPref;
}
}
}
Log.e(TAG, "Could not find the preference for a word list id " + id);
return null;
}
use of android.preference.Preference in project AndroidChromium by JackyAndroid.
the class SingleCategoryPreferences method onPreferenceChange.
// OnPreferenceChangeListener:
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (READ_WRITE_TOGGLE_KEY.equals(preference.getKey())) {
if (mCategory.isManaged())
return false;
if (mCategory.showAutoplaySites()) {
PrefServiceBridge.getInstance().setAutoplayEnabled((boolean) newValue);
} else if (mCategory.showBackgroundSyncSites()) {
PrefServiceBridge.getInstance().setBackgroundSyncEnabled((boolean) newValue);
} else if (mCategory.showCameraSites()) {
PrefServiceBridge.getInstance().setCameraEnabled((boolean) newValue);
} else if (mCategory.showCookiesSites()) {
PrefServiceBridge.getInstance().setAllowCookiesEnabled((boolean) newValue);
updateThirdPartyCookiesCheckBox();
} else if (mCategory.showFullscreenSites()) {
PrefServiceBridge.getInstance().setFullscreenAllowed((boolean) newValue);
} else if (mCategory.showGeolocationSites()) {
PrefServiceBridge.getInstance().setAllowLocationEnabled((boolean) newValue);
} else if (mCategory.showJavaScriptSites()) {
PrefServiceBridge.getInstance().setJavaScriptEnabled((boolean) newValue);
} else if (mCategory.showMicrophoneSites()) {
PrefServiceBridge.getInstance().setMicEnabled((boolean) newValue);
} else if (mCategory.showNotificationsSites()) {
PrefServiceBridge.getInstance().setNotificationsEnabled((boolean) newValue);
updateNotificationsVibrateCheckBox();
} else if (mCategory.showPopupSites()) {
PrefServiceBridge.getInstance().setAllowPopupsEnabled((boolean) newValue);
} else if (mCategory.showProtectedMediaSites()) {
PrefServiceBridge.getInstance().setProtectedMediaIdentifierEnabled((boolean) newValue);
}
// Categories that support adding exceptions also manage the 'Add site' preference.
if (mCategory.showAutoplaySites() || mCategory.showBackgroundSyncSites() || mCategory.showJavaScriptSites()) {
if ((boolean) newValue) {
Preference addException = getPreferenceScreen().findPreference(ADD_EXCEPTION_KEY);
if (addException != null) {
// Can be null in testing.
getPreferenceScreen().removePreference(addException);
}
} else {
getPreferenceScreen().addPreference(new AddExceptionPreference(getActivity(), ADD_EXCEPTION_KEY, getAddExceptionDialogMessage(), this));
}
}
ChromeSwitchPreference globalToggle = (ChromeSwitchPreference) getPreferenceScreen().findPreference(READ_WRITE_TOGGLE_KEY);
updateAllowedHeader(mAllowedSiteCount, !globalToggle.isChecked());
getInfoForOrigins();
} else if (THIRD_PARTY_COOKIES_TOGGLE_KEY.equals(preference.getKey())) {
PrefServiceBridge.getInstance().setBlockThirdPartyCookiesEnabled(!((boolean) newValue));
} else if (NOTIFICATIONS_VIBRATE_TOGGLE_KEY.equals(preference.getKey())) {
PrefServiceBridge.getInstance().setNotificationsVibrateEnabled((boolean) newValue);
}
return true;
}
use of android.preference.Preference in project AndroidChromium by JackyAndroid.
the class SingleCategoryPreferences method updateThirdPartyCookiesCheckBox.
private void updateThirdPartyCookiesCheckBox() {
ChromeBaseCheckBoxPreference thirdPartyCookiesPref = (ChromeBaseCheckBoxPreference) getPreferenceScreen().findPreference(THIRD_PARTY_COOKIES_TOGGLE_KEY);
thirdPartyCookiesPref.setEnabled(PrefServiceBridge.getInstance().isAcceptCookiesEnabled());
thirdPartyCookiesPref.setManagedPreferenceDelegate(new ManagedPreferenceDelegate() {
@Override
public boolean isPreferenceControlledByPolicy(Preference preference) {
return PrefServiceBridge.getInstance().isBlockThirdPartyCookiesManaged();
}
});
}
Aggregations