use of com.android.settings.UserDictionarySettings in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class InputMethodAndLanguageSettings method updateUserDictionaryPreference.
private void updateUserDictionaryPreference(Preference userDictionaryPreference) {
if (userDictionaryPreference == null) {
return;
}
final Activity activity = getActivity();
final TreeSet<String> localeSet = UserDictionaryList.getUserDictionaryLocalesSet(activity);
if (null == localeSet) {
// The locale list is null if and only if the user dictionary service is
// not present or disabled. In this case we need to remove the preference.
getPreferenceScreen().removePreference(userDictionaryPreference);
} else {
userDictionaryPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference arg0) {
// Redirect to UserDictionarySettings if the user needs only one
// language.
final Bundle extras = new Bundle();
final Class<? extends Fragment> targetFragment;
if (localeSet.size() <= 1) {
if (!localeSet.isEmpty()) {
// If the size of localeList is 0, we don't set the locale
// parameter in the extras. This will be interpreted by the
// UserDictionarySettings class as meaning
// "the current locale". Note that with the current code for
// UserDictionaryList#getUserDictionaryLocalesSet()
// the locale list always has at least one element, since it
// always includes the current locale explicitly.
// @see UserDictionaryList.getUserDictionaryLocalesSet().
extras.putString("locale", localeSet.first());
}
targetFragment = UserDictionarySettings.class;
} else {
targetFragment = UserDictionaryList.class;
}
startFragment(InputMethodAndLanguageSettings.this, targetFragment.getCanonicalName(), -1, -1, extras);
return true;
}
});
}
}
Aggregations