Revert "Remove "Personal dictionary" link from settings."
This reverts commit 76de0a8f52
.
Bug 21881199.
Change-Id: I53f42a1e8f25d214de97264f4d25813bc637cafa
main
parent
94b4ffa17a
commit
764a18cd92
|
@ -19,6 +19,11 @@
|
|||
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
|
||||
android:title="@string/settings_screen_correction"
|
||||
android:key="screen_correction">
|
||||
<PreferenceScreen
|
||||
android:key="edit_personal_dictionary"
|
||||
android:title="@string/edit_personal_dictionary">
|
||||
<intent android:action="android.settings.USER_DICTIONARY_SETTINGS" />
|
||||
</PreferenceScreen>
|
||||
<PreferenceScreen
|
||||
android:key="configure_dictionaries_key"
|
||||
android:title="@string/configure_dictionaries_title">
|
||||
|
|
|
@ -16,20 +16,27 @@
|
|||
|
||||
package com.android.inputmethod.latin.settings;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.Preference;
|
||||
|
||||
import com.android.inputmethod.dictionarypack.DictionarySettingsActivity;
|
||||
import com.android.inputmethod.latin.R;
|
||||
import com.android.inputmethod.latin.userdictionary.UserDictionaryList;
|
||||
import com.android.inputmethod.latin.userdictionary.UserDictionarySettings;
|
||||
|
||||
import java.util.TreeSet;
|
||||
|
||||
/**
|
||||
* "Text correction" settings sub screen.
|
||||
*
|
||||
* This settings sub screen handles the following text correction preferences.
|
||||
* - Personal dictionary
|
||||
* - Add-on dictionaries
|
||||
* - Block offensive words
|
||||
* - Auto-correction
|
||||
|
@ -59,5 +66,39 @@ public final class CorrectionSettingsFragment extends SubScreenFragment {
|
|||
if (0 >= number) {
|
||||
removePreference(Settings.PREF_CONFIGURE_DICTIONARIES_KEY);
|
||||
}
|
||||
|
||||
final Preference editPersonalDictionary =
|
||||
findPreference(Settings.PREF_EDIT_PERSONAL_DICTIONARY);
|
||||
final Intent editPersonalDictionaryIntent = editPersonalDictionary.getIntent();
|
||||
final ResolveInfo ri = USE_INTERNAL_PERSONAL_DICTIONARY_SETTINGS ? null
|
||||
: pm.resolveActivity(
|
||||
editPersonalDictionaryIntent, PackageManager.MATCH_DEFAULT_ONLY);
|
||||
if (ri == null) {
|
||||
overwriteUserDictionaryPreference(editPersonalDictionary);
|
||||
}
|
||||
}
|
||||
|
||||
private void overwriteUserDictionaryPreference(final Preference userDictionaryPreference) {
|
||||
final Activity activity = getActivity();
|
||||
final TreeSet<String> localeList = UserDictionaryList.getUserDictionaryLocalesSet(activity);
|
||||
if (null == localeList) {
|
||||
// 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 if (localeList.size() <= 1) {
|
||||
userDictionaryPreference.setFragment(UserDictionarySettings.class.getName());
|
||||
// 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().
|
||||
if (localeList.size() == 1) {
|
||||
final String locale = (String)localeList.toArray()[0];
|
||||
userDictionaryPreference.getExtras().putString("locale", locale);
|
||||
}
|
||||
} else {
|
||||
userDictionaryPreference.setFragment(UserDictionaryList.class.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,6 +56,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
|
|||
// PREF_VOICE_MODE_OBSOLETE is obsolete. Use PREF_VOICE_INPUT_KEY instead.
|
||||
public static final String PREF_VOICE_MODE_OBSOLETE = "voice_mode";
|
||||
public static final String PREF_VOICE_INPUT_KEY = "pref_voice_input_key";
|
||||
public static final String PREF_EDIT_PERSONAL_DICTIONARY = "edit_personal_dictionary";
|
||||
public static final String PREF_CONFIGURE_DICTIONARIES_KEY = "configure_dictionaries_key";
|
||||
// PREF_AUTO_CORRECTION_THRESHOLD_OBSOLETE is obsolete. Use PREF_AUTO_CORRECTION instead.
|
||||
public static final String PREF_AUTO_CORRECTION_THRESHOLD_OBSOLETE =
|
||||
|
|
Loading…
Reference in New Issue