diff options
author | Tadashi G. Takaoka <takaoka@google.com> | 2014-07-09 07:25:32 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-07-02 19:52:36 +0000 |
commit | 0244ae05cc0d95b04d115f490ceaba35d99f5273 (patch) | |
tree | 598648f5a1ff2720122e0c8d5714ba9e115553c8 | |
parent | cfe94540d865629ddb6e93c3b27da79f3492868a (diff) | |
parent | d2dd7d33c9206f7aa29abbff48119d0f86ddfc36 (diff) | |
download | packages_apps_Settings-0244ae05cc0d95b04d115f490ceaba35d99f5273.zip packages_apps_Settings-0244ae05cc0d95b04d115f490ceaba35d99f5273.tar.gz packages_apps_Settings-0244ae05cc0d95b04d115f490ceaba35d99f5273.tar.bz2 |
Merge "Add TODO comments to Language & input settings"
10 files changed, 56 insertions, 74 deletions
diff --git a/res/values/styles.xml b/res/values/styles.xml index 6d2fdd7..0f7e652 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -238,11 +238,6 @@ <item name="android:singleLine">true</item> </style> - <style name="InputMethodPreferenceStyle"> - <item name="android:layout">@layout/preference_inputmethod</item> - <item name="android:widgetLayout">@layout/preference_inputmethod_widget</item> - </style> - <style name="TextAppearance.PagerTabs" parent="@android:style/TextAppearance.Material.Small"> <item name="android:textAllCaps">true</item> <item name="android:textStyle">bold</item> diff --git a/src/com/android/settings/inputmethod/CheckBoxAndSettingsPreference.java b/src/com/android/settings/inputmethod/CheckBoxAndSettingsPreference.java index 375bee7..c6208ed 100644 --- a/src/com/android/settings/inputmethod/CheckBoxAndSettingsPreference.java +++ b/src/com/android/settings/inputmethod/CheckBoxAndSettingsPreference.java @@ -29,7 +29,8 @@ import android.view.View.OnClickListener; import android.widget.ImageView; import android.widget.TextView; -public class CheckBoxAndSettingsPreference extends CheckBoxPreference { +// TODO: Make this non-persistent. +class CheckBoxAndSettingsPreference extends CheckBoxPreference { private SettingsPreferenceFragment mFragment; private TextView mTitleText; diff --git a/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java b/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java index 54a5698..0f9ae19 100644 --- a/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java +++ b/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java @@ -70,7 +70,6 @@ import java.util.TreeSet; public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment implements Preference.OnPreferenceChangeListener, InputManager.InputDeviceListener, KeyboardLayoutDialogFragment.OnSetupKeyboardLayoutsListener, Indexable { - private static final String KEY_PHONE_LANGUAGE = "phone_language"; private static final String KEY_CURRENT_INPUT_METHOD = "current_input_method"; private static final String KEY_INPUT_METHOD_SELECTOR = "input_method_selector"; @@ -92,10 +91,8 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment private PreferenceCategory mHardKeyboardCategory; private PreferenceCategory mGameControllerCategory; private Preference mLanguagePref; - private final ArrayList<InputMethodPreference> mInputMethodPreferenceList = - new ArrayList<InputMethodPreference>(); - private final ArrayList<PreferenceScreen> mHardKeyboardPreferenceList = - new ArrayList<PreferenceScreen>(); + private final ArrayList<InputMethodPreference> mInputMethodPreferenceList = new ArrayList<>(); + private final ArrayList<PreferenceScreen> mHardKeyboardPreferenceList = new ArrayList<>(); private InputManager mIm; private InputMethodManager mImm; private boolean mIsOnlyImeSettings; @@ -467,7 +464,7 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment final CharSequence curIme = mInputMethodSettingValues.getCurrentInputMethodName(context); if (!TextUtils.isEmpty(curIme)) { - synchronized(this) { + synchronized (this) { curPref.setSummary(curIme); } } @@ -488,8 +485,7 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment } // Add a check box for enabling/disabling IME - final InputMethodPreference pref = - new InputMethodPreference(this, intent, mImm, imi); + final InputMethodPreference pref = new InputMethodPreference(this, intent, mImm, imi); pref.setKey(imi.getId()); pref.setTitle(label); return pref; @@ -557,8 +553,8 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment } private void showKeyboardLayoutDialog(InputDeviceIdentifier inputDeviceIdentifier) { - KeyboardLayoutDialogFragment fragment = - new KeyboardLayoutDialogFragment(inputDeviceIdentifier); + KeyboardLayoutDialogFragment fragment = new KeyboardLayoutDialogFragment( + inputDeviceIdentifier); fragment.setTargetFragment(this, 0); fragment.show(getActivity().getFragmentManager(), "keyboardLayout"); } @@ -638,7 +634,7 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment new BaseSearchIndexProvider() { @Override public List<SearchIndexableRaw> getRawDataToIndex(Context context, boolean enabled) { - List<SearchIndexableRaw> indexables = new ArrayList<SearchIndexableRaw>(); + List<SearchIndexableRaw> indexables = new ArrayList<>(); Resources resources = context.getResources(); String screenTitle = context.getString(R.string.language_keyboard_settings_title); diff --git a/src/com/android/settings/inputmethod/InputMethodAndSubtypeEnabler.java b/src/com/android/settings/inputmethod/InputMethodAndSubtypeEnabler.java index 3351e63..5a94e35 100644 --- a/src/com/android/settings/inputmethod/InputMethodAndSubtypeEnabler.java +++ b/src/com/android/settings/inputmethod/InputMethodAndSubtypeEnabler.java @@ -40,7 +40,6 @@ import android.view.inputmethod.InputMethodSubtype; import java.text.Collator; import java.util.ArrayList; import java.util.Collections; -import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Locale; @@ -50,9 +49,8 @@ public class InputMethodAndSubtypeEnabler extends SettingsPreferenceFragment { private AlertDialog mDialog = null; private boolean mHaveHardKeyboard; final private HashMap<String, List<Preference>> mInputMethodAndSubtypePrefsMap = - new HashMap<String, List<Preference>>(); - final private HashMap<String, CheckBoxPreference> mSubtypeAutoSelectionCBMap = - new HashMap<String, CheckBoxPreference>(); + new HashMap<>(); + final private HashMap<String, CheckBoxPreference> mSubtypeAutoSelectionCBMap = new HashMap<>(); private InputMethodManager mImm; private List<InputMethodInfo> mInputMethodProperties; private String mInputMethodId; @@ -256,7 +254,7 @@ public class InputMethodAndSubtypeEnabler extends SettingsPreferenceFragment { boolean isAutoSubtype = false; CharSequence autoSubtypeLabel = null; - final ArrayList<Preference> subtypePreferences = new ArrayList<Preference>(); + final ArrayList<Preference> subtypePreferences = new ArrayList<>(); if (subtypeCount > 0) { for (int j = 0; j < subtypeCount; ++j) { final InputMethodSubtype subtype = imi.getSubtypeAt(j); diff --git a/src/com/android/settings/inputmethod/InputMethodAndSubtypeEnablerActivity.java b/src/com/android/settings/inputmethod/InputMethodAndSubtypeEnablerActivity.java index da95b47..b664540 100644 --- a/src/com/android/settings/inputmethod/InputMethodAndSubtypeEnablerActivity.java +++ b/src/com/android/settings/inputmethod/InputMethodAndSubtypeEnablerActivity.java @@ -20,19 +20,19 @@ import android.content.Intent; import com.android.settings.SettingsActivity; public class InputMethodAndSubtypeEnablerActivity extends SettingsActivity { + private static final String FRAGMENT_NAME = InputMethodAndSubtypeEnabler.class.getName(); + @Override public Intent getIntent() { final Intent modIntent = new Intent(super.getIntent()); if (!modIntent.hasExtra(EXTRA_SHOW_FRAGMENT)) { - modIntent.putExtra(EXTRA_SHOW_FRAGMENT, InputMethodAndSubtypeEnabler.class.getName()); + modIntent.putExtra(EXTRA_SHOW_FRAGMENT, FRAGMENT_NAME); } return modIntent; } @Override protected boolean isValidFragment(String fragmentName) { - if (InputMethodAndSubtypeEnabler.class.getName().equals(fragmentName)) return true; - return false; + return FRAGMENT_NAME.equals(fragmentName); } - } diff --git a/src/com/android/settings/inputmethod/InputMethodAndSubtypeUtil.java b/src/com/android/settings/inputmethod/InputMethodAndSubtypeUtil.java index 561302a..bf3a601 100644 --- a/src/com/android/settings/inputmethod/InputMethodAndSubtypeUtil.java +++ b/src/com/android/settings/inputmethod/InputMethodAndSubtypeUtil.java @@ -35,7 +35,8 @@ import java.util.HashSet; import java.util.List; import java.util.Map; -public class InputMethodAndSubtypeUtil { +// TODO: Consolidate this with {@link InputMethodSettingValuesWrapper}. +class InputMethodAndSubtypeUtil { private static final boolean DEBUG = false; static final String TAG = "InputMethdAndSubtypeUtil"; @@ -50,8 +51,8 @@ public class InputMethodAndSubtypeUtil { private static final TextUtils.SimpleStringSplitter sStringInputMethodSubtypeSplitter = new TextUtils.SimpleStringSplitter(INPUT_METHOD_SUBTYPE_SEPARATER); - private static void buildEnabledInputMethodsString( - StringBuilder builder, String imi, HashSet<String> subtypes) { + private static void buildEnabledInputMethodsString(StringBuilder builder, String imi, + HashSet<String> subtypes) { builder.append(imi); // Inputmethod and subtypes are saved in the settings as follows: // ime0;subtype0;subtype1:ime1;subtype0:ime2:ime3;subtype0;subtype1 @@ -60,8 +61,8 @@ public class InputMethodAndSubtypeUtil { } } - public static void buildInputMethodsAndSubtypesString( - StringBuilder builder, HashMap<String, HashSet<String>> imsList) { + private static void buildInputMethodsAndSubtypesString(StringBuilder builder, + HashMap<String, HashSet<String>> imsList) { boolean needsAppendSeparator = false; for (String imi: imsList.keySet()) { if (needsAppendSeparator) { @@ -73,8 +74,8 @@ public class InputMethodAndSubtypeUtil { } } - public static void buildDisabledSystemInputMethods( - StringBuilder builder, HashSet<String> imes) { + private static void buildDisabledSystemInputMethods(StringBuilder builder, + HashSet<String> imes) { boolean needsAppendSeparator = false; for (String ime: imes) { if (needsAppendSeparator) { @@ -108,8 +109,7 @@ public class InputMethodAndSubtypeUtil { ContentResolver resolver) { final String enabledInputMethodsStr = Settings.Secure.getString( resolver, Settings.Secure.ENABLED_INPUT_METHODS); - HashMap<String, HashSet<String>> imsList - = new HashMap<String, HashSet<String>>(); + HashMap<String, HashSet<String>> imsList = new HashMap<>(); if (DEBUG) { Log.d(TAG, "--- Load enabled input methods: " + enabledInputMethodsStr); } @@ -122,7 +122,7 @@ public class InputMethodAndSubtypeUtil { String nextImsStr = sStringInputMethodSplitter.next(); sStringInputMethodSubtypeSplitter.setString(nextImsStr); if (sStringInputMethodSubtypeSplitter.hasNext()) { - HashSet<String> subtypeHashes = new HashSet<String>(); + HashSet<String> subtypeHashes = new HashSet<>(); // The first element is ime id. String imeId = sStringInputMethodSubtypeSplitter.next(); while (sStringInputMethodSubtypeSplitter.hasNext()) { @@ -135,7 +135,7 @@ public class InputMethodAndSubtypeUtil { } private static HashSet<String> getDisabledSystemIMEs(ContentResolver resolver) { - HashSet<String> set = new HashSet<String>(); + HashSet<String> set = new HashSet<>(); String disabledIMEsStr = Settings.Secure.getString( resolver, Settings.Secure.DISABLED_SYSTEM_INPUT_METHODS); if (TextUtils.isEmpty(disabledIMEsStr)) { @@ -148,7 +148,7 @@ public class InputMethodAndSubtypeUtil { return set; } - public static void saveInputMethodSubtypeList(SettingsPreferenceFragment context, + static void saveInputMethodSubtypeList(SettingsPreferenceFragment context, ContentResolver resolver, List<InputMethodInfo> inputMethodInfos, boolean hasHardKeyboard) { String currentInputMethodId = Settings.Secure.getString(resolver, @@ -158,7 +158,6 @@ public class InputMethodAndSubtypeUtil { getEnabledInputMethodsAndSubtypeList(resolver); HashSet<String> disabledSystemIMEs = getDisabledSystemIMEs(resolver); - final int imiCount = inputMethodInfos.size(); boolean needsToResetSelectedSubtype = false; for (InputMethodInfo imi : inputMethodInfos) { final String imiId = imi.getId(); @@ -273,9 +272,8 @@ public class InputMethodAndSubtypeUtil { currentInputMethodId != null ? currentInputMethodId : ""); } - public static void loadInputMethodSubtypeList( - SettingsPreferenceFragment context, ContentResolver resolver, - List<InputMethodInfo> inputMethodInfos, + static void loadInputMethodSubtypeList(SettingsPreferenceFragment context, + ContentResolver resolver, List<InputMethodInfo> inputMethodInfos, final Map<String, List<Preference>> inputMethodPrefsMap) { HashMap<String, HashSet<String>> enabledSubtypes = getEnabledInputMethodsAndSubtypeList(resolver); @@ -298,7 +296,7 @@ public class InputMethodAndSubtypeUtil { updateSubtypesPreferenceChecked(context, inputMethodInfos, enabledSubtypes); } - public static void setSubtypesPreferenceEnabled(SettingsPreferenceFragment context, + static void setSubtypesPreferenceEnabled(SettingsPreferenceFragment context, List<InputMethodInfo> inputMethodProperties, String id, boolean enabled) { PreferenceScreen preferenceScreen = context.getPreferenceScreen(); for (InputMethodInfo imi : inputMethodProperties) { @@ -316,7 +314,7 @@ public class InputMethodAndSubtypeUtil { } } - public static void updateSubtypesPreferenceChecked(SettingsPreferenceFragment context, + private static void updateSubtypesPreferenceChecked(SettingsPreferenceFragment context, List<InputMethodInfo> inputMethodProperties, HashMap<String, HashSet<String>> enabledSubtypes) { PreferenceScreen preferenceScreen = context.getPreferenceScreen(); diff --git a/src/com/android/settings/inputmethod/InputMethodPreference.java b/src/com/android/settings/inputmethod/InputMethodPreference.java index e04f2c7..87a0a77 100644 --- a/src/com/android/settings/inputmethod/InputMethodPreference.java +++ b/src/com/android/settings/inputmethod/InputMethodPreference.java @@ -47,7 +47,8 @@ import android.widget.Toast; import java.text.Collator; import java.util.List; -public class InputMethodPreference extends CheckBoxPreference { +// TODO: Make this non-persistent. +class InputMethodPreference extends CheckBoxPreference { private static final String TAG = InputMethodPreference.class.getSimpleName(); private final SettingsPreferenceFragment mFragment; private final InputMethodInfo mImi; @@ -84,7 +85,7 @@ public class InputMethodPreference extends CheckBoxPreference { public InputMethodPreference(SettingsPreferenceFragment fragment, Intent settingsIntent, InputMethodManager imm, InputMethodInfo imi) { - super(fragment.getActivity(), null, R.style.InputMethodPreferenceStyle); + super(fragment.getActivity()); setLayoutResource(R.layout.preference_inputmethod); setWidgetLayoutResource(R.layout.preference_inputmethod_widget); mFragment = fragment; diff --git a/src/com/android/settings/inputmethod/InputMethodSettingValuesWrapper.java b/src/com/android/settings/inputmethod/InputMethodSettingValuesWrapper.java index ccba143..bf63487 100644 --- a/src/com/android/settings/inputmethod/InputMethodSettingValuesWrapper.java +++ b/src/com/android/settings/inputmethod/InputMethodSettingValuesWrapper.java @@ -39,22 +39,20 @@ import java.util.Locale; * manually on some events when "InputMethodInfo"s and "InputMethodSubtype"s can be * changed. */ -public class InputMethodSettingValuesWrapper { +// TODO: Consolidate this with {@link InputMethodAndSubtypeUtil}. +class InputMethodSettingValuesWrapper { private static final String TAG = InputMethodSettingValuesWrapper.class.getSimpleName(); - private static final Locale ENGLISH_LOCALE = new Locale("en"); private static volatile InputMethodSettingValuesWrapper sInstance; - private final ArrayList<InputMethodInfo> mMethodList = new ArrayList<InputMethodInfo>(); - private final HashMap<String, InputMethodInfo> mMethodMap = - new HashMap<String, InputMethodInfo>(); + private final ArrayList<InputMethodInfo> mMethodList = new ArrayList<>(); + private final HashMap<String, InputMethodInfo> mMethodMap = new HashMap<>(); private final InputMethodSettings mSettings; private final InputMethodManager mImm; - private final HashSet<InputMethodInfo> mAsciiCapableEnabledImis = - new HashSet<InputMethodInfo>(); + private final HashSet<InputMethodInfo> mAsciiCapableEnabledImis = new HashSet<>(); - public static InputMethodSettingValuesWrapper getInstance(Context context) { + static InputMethodSettingValuesWrapper getInstance(Context context) { if (sInstance == null) { - synchronized(TAG) { + synchronized (TAG) { if (sInstance == null) { sInstance = new InputMethodSettingValuesWrapper(context); } @@ -74,14 +72,13 @@ public class InputMethodSettingValuesWrapper { // Ensure singleton private InputMethodSettingValuesWrapper(Context context) { - mSettings = - new InputMethodSettings(context.getResources(), context.getContentResolver(), - mMethodMap, mMethodList, getDefaultCurrentUserId()); + mSettings = new InputMethodSettings(context.getResources(), context.getContentResolver(), + mMethodMap, mMethodList, getDefaultCurrentUserId()); mImm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); refreshAllInputMethodAndSubtypes(); } - public void refreshAllInputMethodAndSubtypes() { + void refreshAllInputMethodAndSubtypes() { synchronized (mMethodMap) { mMethodList.clear(); mMethodMap.clear(); @@ -113,13 +110,13 @@ public class InputMethodSettingValuesWrapper { } } - public List<InputMethodInfo> getInputMethodList() { + List<InputMethodInfo> getInputMethodList() { synchronized (mMethodMap) { return mMethodList; } } - public CharSequence getCurrentInputMethodName(Context context) { + CharSequence getCurrentInputMethodName(Context context) { synchronized (mMethodMap) { final InputMethodInfo imi = mMethodMap.get(mSettings.getSelectedInputMethod()); if (imi == null) { @@ -131,7 +128,7 @@ public class InputMethodSettingValuesWrapper { } } - public boolean isAlwaysCheckedIme(InputMethodInfo imi, Context context) { + boolean isAlwaysCheckedIme(InputMethodInfo imi, Context context) { final boolean isEnabled = isEnabledImi(imi); synchronized (mMethodMap) { if (mSettings.getEnabledInputMethodListLocked().size() <= 1 && isEnabled) { @@ -158,7 +155,7 @@ public class InputMethodSettingValuesWrapper { private int getEnabledValidSystemNonAuxAsciiCapableImeCount(Context context) { int count = 0; final List<InputMethodInfo> enabledImis; - synchronized(mMethodMap) { + synchronized (mMethodMap) { enabledImis = mSettings.getEnabledInputMethodListLocked(); } for (final InputMethodInfo imi : enabledImis) { @@ -174,7 +171,7 @@ public class InputMethodSettingValuesWrapper { private boolean isEnabledImi(InputMethodInfo imi) { final List<InputMethodInfo> enabledImis; - synchronized(mMethodMap) { + synchronized (mMethodMap) { enabledImis = mSettings.getEnabledInputMethodListLocked(); } for (final InputMethodInfo tempImi : enabledImis) { @@ -185,8 +182,7 @@ public class InputMethodSettingValuesWrapper { return false; } - public boolean isValidSystemNonAuxAsciiCapableIme(InputMethodInfo imi, - Context context) { + boolean isValidSystemNonAuxAsciiCapableIme(InputMethodInfo imi, Context context) { if (imi.isAuxiliaryIme()) { return false; } @@ -196,7 +192,7 @@ public class InputMethodSettingValuesWrapper { if (mAsciiCapableEnabledImis.isEmpty()) { Log.w(TAG, "ascii capable subtype enabled imi not found. Fall back to English" + " Keyboard subtype."); - return InputMethodUtils.containsSubtypeOf(imi, ENGLISH_LOCALE.getLanguage(), + return InputMethodUtils.containsSubtypeOf(imi, Locale.ENGLISH.getLanguage(), InputMethodUtils.SUBTYPE_MODE_KEYBOARD); } return mAsciiCapableEnabledImis.contains(imi); diff --git a/src/com/android/settings/inputmethod/SingleSpellCheckerPreference.java b/src/com/android/settings/inputmethod/SingleSpellCheckerPreference.java index bc79b42..2dc90ec 100644 --- a/src/com/android/settings/inputmethod/SingleSpellCheckerPreference.java +++ b/src/com/android/settings/inputmethod/SingleSpellCheckerPreference.java @@ -34,10 +34,10 @@ import android.view.textservice.SpellCheckerSubtype; import android.view.textservice.TextServicesManager; import android.widget.ImageView; import android.widget.RadioButton; -import android.widget.TextView; import android.widget.Toast; -public class SingleSpellCheckerPreference extends Preference { +// TODO: Make this non-persistent. +class SingleSpellCheckerPreference extends Preference { private static final String TAG = SingleSpellCheckerPreference.class.getSimpleName(); private static final boolean DBG = false; @@ -47,8 +47,6 @@ public class SingleSpellCheckerPreference extends Preference { private final Resources mRes; private final TextServicesManager mTsm; private AlertDialog mDialog = null; - private TextView mTitleText; - private TextView mSummaryText; private View mPrefAll; private RadioButton mRadioButton; private View mPrefLeftButton; @@ -88,8 +86,6 @@ public class SingleSpellCheckerPreference extends Preference { onLeftButtonClicked(arg0); } }); - mTitleText = (TextView)view.findViewById(android.R.id.title); - mSummaryText = (TextView)view.findViewById(android.R.id.summary); mSubtypeButton = (ImageView)view.findViewById(R.id.pref_right_button2); mSubtypeButton.setOnClickListener( new OnClickListener() { diff --git a/src/com/android/settings/inputmethod/SpellCheckersPreference.java b/src/com/android/settings/inputmethod/SpellCheckersPreference.java index 9e68604..1482b6c 100644 --- a/src/com/android/settings/inputmethod/SpellCheckersPreference.java +++ b/src/com/android/settings/inputmethod/SpellCheckersPreference.java @@ -20,7 +20,8 @@ import android.content.Context; import android.util.AttributeSet; import android.view.textservice.TextServicesManager; -public class SpellCheckersPreference extends CheckBoxAndSettingsPreference { +// TODO: Make this non-persistent. +class SpellCheckersPreference extends CheckBoxAndSettingsPreference { private TextServicesManager mTsm; public SpellCheckersPreference(Context context) { |