From 53c0088d578be0b3581e4c85f7d2d76e374c4627 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Wed, 16 Jul 2014 12:08:00 -0700 Subject: [PATCH] Use SwitchPreference for spell checker setting This is a follow up of I1f7214c689. Bug: 15781377 Change-Id: I7289b8b724e086da80ab3849cc567560c1a8502d --- .../latin/settings/TwoStatePreferenceHelper.java | 4 ++-- .../spellcheck/SpellCheckerSettingsFragment.java | 16 +++++----------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/settings/TwoStatePreferenceHelper.java b/java/src/com/android/inputmethod/latin/settings/TwoStatePreferenceHelper.java index edfcc9922..07a871ca0 100644 --- a/java/src/com/android/inputmethod/latin/settings/TwoStatePreferenceHelper.java +++ b/java/src/com/android/inputmethod/latin/settings/TwoStatePreferenceHelper.java @@ -24,14 +24,14 @@ import android.preference.SwitchPreference; import java.util.ArrayList; -class TwoStatePreferenceHelper { +public class TwoStatePreferenceHelper { private static final String EMPTY_TEXT = ""; private TwoStatePreferenceHelper() { // This utility class is not publicly instantiable. } - static void replaceCheckBoxPreferencesBySwitchPreferences(final PreferenceGroup group) { + public static void replaceCheckBoxPreferencesBySwitchPreferences(final PreferenceGroup group) { // The keyboard settings keeps using a CheckBoxPreference on KitKat or previous. if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) { return; diff --git a/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerSettingsFragment.java b/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerSettingsFragment.java index 186dafd29..6850e9b58 100644 --- a/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerSettingsFragment.java +++ b/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerSettingsFragment.java @@ -21,26 +21,20 @@ import android.preference.PreferenceFragment; import android.preference.PreferenceScreen; import com.android.inputmethod.latin.R; +import com.android.inputmethod.latin.settings.TwoStatePreferenceHelper; import com.android.inputmethod.latin.utils.ApplicationUtils; /** * Preference screen. */ public final class SpellCheckerSettingsFragment extends PreferenceFragment { - /** - * Empty constructor for fragment generation. - */ - public SpellCheckerSettingsFragment() { - } - @Override - public void onActivityCreated(Bundle savedInstanceState) { + public void onActivityCreated(final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); addPreferencesFromResource(R.xml.spell_checker_settings); final PreferenceScreen preferenceScreen = getPreferenceScreen(); - if (preferenceScreen != null) { - preferenceScreen.setTitle(ApplicationUtils.getActivityTitleResId( - getActivity(), SpellCheckerSettingsActivity.class)); - } + preferenceScreen.setTitle(ApplicationUtils.getActivityTitleResId( + getActivity(), SpellCheckerSettingsActivity.class)); + TwoStatePreferenceHelper.replaceCheckBoxPreferencesBySwitchPreferences(preferenceScreen); } }