diff --git a/common/src/com/android/inputmethod/latin/common/Constants.java b/common/src/com/android/inputmethod/latin/common/Constants.java index a2d21a826..03abb0fdd 100644 --- a/common/src/com/android/inputmethod/latin/common/Constants.java +++ b/common/src/com/android/inputmethod/latin/common/Constants.java @@ -16,20 +16,12 @@ package com.android.inputmethod.latin.common; -import android.os.Build; - import com.android.inputmethod.annotations.UsedForTesting; import javax.annotation.Nonnull; public final class Constants { - public static final boolean JELLY_BEAN_OR_HIGHER = - Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; - - public static final boolean JELLY_BEAN_MR1_OR_HIGHER = - Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1; - public static final class Color { /** * The alpha value for fully opaque. diff --git a/java/src/com/android/inputmethod/accessibility/AccessibilityUtils.java b/java/src/com/android/inputmethod/accessibility/AccessibilityUtils.java index 48aef4b1d..b0072eebe 100644 --- a/java/src/com/android/inputmethod/accessibility/AccessibilityUtils.java +++ b/java/src/com/android/inputmethod/accessibility/AccessibilityUtils.java @@ -35,7 +35,6 @@ import android.view.inputmethod.EditorInfo; import com.android.inputmethod.compat.SettingsSecureCompatUtils; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.SuggestedWords; -import com.android.inputmethod.latin.common.Constants; import com.android.inputmethod.latin.utils.InputTypeUtils; public final class AccessibilityUtils { @@ -222,7 +221,7 @@ public final class AccessibilityUtils { // Platforms starting at SDK version 16 (Build.VERSION_CODES.JELLY_BEAN) should use // announce events. - if (Constants.JELLY_BEAN_OR_HIGHER) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { event.setEventType(AccessibilityEventCompat.TYPE_ANNOUNCEMENT); } else { event.setEventType(AccessibilityEvent.TYPE_VIEW_FOCUSED); diff --git a/java/src/com/android/inputmethod/compat/InputMethodSubtypeCompatUtils.java b/java/src/com/android/inputmethod/compat/InputMethodSubtypeCompatUtils.java index 853830808..58ad4bd4c 100644 --- a/java/src/com/android/inputmethod/compat/InputMethodSubtypeCompatUtils.java +++ b/java/src/com/android/inputmethod/compat/InputMethodSubtypeCompatUtils.java @@ -38,7 +38,7 @@ public final class InputMethodSubtypeCompatUtils { int.class, int.class, String.class, String.class, String.class, boolean.class, boolean.class, int.class); static { - if (Constants.JELLY_BEAN_MR1_OR_HIGHER) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { if (CONSTRUCTOR_INPUT_METHOD_SUBTYPE == null) { android.util.Log.w(TAG, "Warning!!! Constructor is not defined."); } @@ -59,7 +59,8 @@ public final class InputMethodSubtypeCompatUtils { public static InputMethodSubtype newInputMethodSubtype(int nameId, int iconId, String locale, String mode, String extraValue, boolean isAuxiliary, boolean overridesImplicitlyEnabledSubtype, int id) { - if (CONSTRUCTOR_INPUT_METHOD_SUBTYPE == null || !Constants.JELLY_BEAN_MR1_OR_HIGHER) { + if (CONSTRUCTOR_INPUT_METHOD_SUBTYPE == null + || Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { return new InputMethodSubtype(nameId, iconId, locale, mode, extraValue, isAuxiliary, overridesImplicitlyEnabledSubtype); } diff --git a/java/src/com/android/inputmethod/compat/NotificationCompatUtils.java b/java/src/com/android/inputmethod/compat/NotificationCompatUtils.java index 0646558e4..70ab972c5 100644 --- a/java/src/com/android/inputmethod/compat/NotificationCompatUtils.java +++ b/java/src/com/android/inputmethod/compat/NotificationCompatUtils.java @@ -17,8 +17,7 @@ package com.android.inputmethod.compat; import android.app.Notification; - -import com.android.inputmethod.latin.common.Constants; +import android.os.Build; import java.lang.reflect.Field; import java.lang.reflect.Method; @@ -74,7 +73,7 @@ public class NotificationCompatUtils { @SuppressWarnings("deprecation") public static Notification build(final Notification.Builder builder) { - if (Constants.JELLY_BEAN_OR_HIGHER) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { // #build was added in API level 16, JELLY_BEAN return (Notification) CompatUtils.invoke(builder, null, METHOD_build); } diff --git a/java/src/com/android/inputmethod/latin/RichInputConnection.java b/java/src/com/android/inputmethod/latin/RichInputConnection.java index f020c25eb..0210d7e18 100644 --- a/java/src/com/android/inputmethod/latin/RichInputConnection.java +++ b/java/src/com/android/inputmethod/latin/RichInputConnection.java @@ -899,7 +899,7 @@ public final class RichInputConnection implements PrivateCommandPerformer { * On platforms on which this method is not present, this is a no-op. */ public void maybeMoveTheCursorAroundAndRestoreToWorkaroundABug() { - if (!Constants.JELLY_BEAN_OR_HIGHER) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { if (mExpectedSelStart > 0) { mIC.setSelection(mExpectedSelStart - 1, mExpectedSelStart - 1); } else { diff --git a/java/src/com/android/inputmethod/latin/settings/PreferencesSettingsFragment.java b/java/src/com/android/inputmethod/latin/settings/PreferencesSettingsFragment.java index c5e80f249..d9858e61f 100644 --- a/java/src/com/android/inputmethod/latin/settings/PreferencesSettingsFragment.java +++ b/java/src/com/android/inputmethod/latin/settings/PreferencesSettingsFragment.java @@ -19,13 +19,13 @@ package com.android.inputmethod.latin.settings; import android.content.Context; import android.content.SharedPreferences; import android.content.res.Resources; +import android.os.Build; import android.os.Bundle; import android.preference.Preference; import com.android.inputmethod.latin.AudioAndHapticFeedbackManager; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.RichInputMethodManager; -import com.android.inputmethod.latin.common.Constants; /** * "Preferences" settings sub screen. @@ -39,6 +39,10 @@ import com.android.inputmethod.latin.common.Constants; * - Voice input key */ public final class PreferencesSettingsFragment extends SubScreenFragment { + + private static final boolean VOICE_IME_ENABLED = + Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; + @Override public void onCreate(final Bundle icicle) { super.onCreate(icicle); @@ -73,8 +77,8 @@ public final class PreferencesSettingsFragment extends SubScreenFragment { final Preference voiceInputKeyOption = findPreference(Settings.PREF_VOICE_INPUT_KEY); if (voiceInputKeyOption != null) { RichInputMethodManager.getInstance().refreshSubtypeCaches(); - voiceInputKeyOption.setEnabled(Constants.JELLY_BEAN_OR_HIGHER); - voiceInputKeyOption.setSummary(Constants.JELLY_BEAN_OR_HIGHER + voiceInputKeyOption.setEnabled(VOICE_IME_ENABLED); + voiceInputKeyOption.setSummary(VOICE_IME_ENABLED ? null : getText(R.string.voice_input_disabled_summary)); } } diff --git a/java/src/com/android/inputmethod/latin/settings/SettingsValues.java b/java/src/com/android/inputmethod/latin/settings/SettingsValues.java index e523246f3..6224071ea 100644 --- a/java/src/com/android/inputmethod/latin/settings/SettingsValues.java +++ b/java/src/com/android/inputmethod/latin/settings/SettingsValues.java @@ -21,6 +21,7 @@ import android.content.SharedPreferences; import android.content.pm.PackageInfo; import android.content.res.Configuration; import android.content.res.Resources; +import android.os.Build; import android.util.Log; import android.view.inputmethod.EditorInfo; @@ -28,7 +29,6 @@ import com.android.inputmethod.compat.AppWorkaroundsUtils; import com.android.inputmethod.latin.InputAttributes; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.RichInputMethodManager; -import com.android.inputmethod.latin.common.Constants; import com.android.inputmethod.latin.utils.AsyncResultHolder; import com.android.inputmethod.latin.utils.ResourceUtils; import com.android.inputmethod.latin.utils.TargetPackageInfoGetterTask; @@ -137,7 +137,7 @@ public class SettingsValues { DebugSettings.PREF_SLIDING_KEY_INPUT_PREVIEW, true); mShowsVoiceInputKey = needsToShowVoiceInputKey(prefs, res) && mInputAttributes.mShouldShowVoiceInputKey - && Constants.JELLY_BEAN_OR_HIGHER; + && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; final String autoCorrectionThresholdRawValue = prefs.getString( Settings.PREF_AUTO_CORRECTION_THRESHOLD, res.getString(R.string.auto_correction_threshold_mode_index_modest)); diff --git a/java/src/com/android/inputmethod/latin/userdictionary/UserDictionaryList.java b/java/src/com/android/inputmethod/latin/userdictionary/UserDictionaryList.java index c43463ce7..57347ce8c 100644 --- a/java/src/com/android/inputmethod/latin/userdictionary/UserDictionaryList.java +++ b/java/src/com/android/inputmethod/latin/userdictionary/UserDictionaryList.java @@ -20,6 +20,7 @@ import android.app.Activity; import android.content.Context; import android.content.Intent; import android.database.Cursor; +import android.os.Build; import android.os.Bundle; import android.preference.Preference; import android.preference.PreferenceFragment; @@ -31,7 +32,6 @@ import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodSubtype; import com.android.inputmethod.latin.R; -import com.android.inputmethod.latin.common.Constants; import com.android.inputmethod.latin.common.LocaleUtils; import java.util.List; @@ -75,7 +75,7 @@ public class UserDictionaryList extends PreferenceFragment { } finally { cursor.close(); } - if (!Constants.JELLY_BEAN_OR_HIGHER) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { // For ICS, we need to show "For all languages" in case that the keyboard locale // is different from the system locale localeSet.add(""); diff --git a/tests/src/com/android/inputmethod/compat/LocaleSpanCompatUtilsTests.java b/tests/src/com/android/inputmethod/compat/LocaleSpanCompatUtilsTests.java index d75e61ad1..67e76464b 100644 --- a/tests/src/com/android/inputmethod/compat/LocaleSpanCompatUtilsTests.java +++ b/tests/src/com/android/inputmethod/compat/LocaleSpanCompatUtilsTests.java @@ -17,20 +17,19 @@ package com.android.inputmethod.compat; import android.graphics.Typeface; +import android.os.Build; import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.SmallTest; import android.text.SpannableString; import android.text.Spanned; import android.text.style.StyleSpan; -import com.android.inputmethod.latin.common.Constants; - import java.util.Locale; @SmallTest public class LocaleSpanCompatUtilsTests extends AndroidTestCase { public void testInstantiatable() { - if (!Constants.JELLY_BEAN_MR1_OR_HIGHER) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { // LocaleSpan isn't yet available. return; } diff --git a/tests/src/com/android/inputmethod/keyboard/layout/DevanagariLetterConstants.java b/tests/src/com/android/inputmethod/keyboard/layout/DevanagariLetterConstants.java index 557cc214d..bcf06f085 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/DevanagariLetterConstants.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/DevanagariLetterConstants.java @@ -16,14 +16,15 @@ package com.android.inputmethod.keyboard.layout; -import com.android.inputmethod.latin.common.Constants; +import android.os.Build; /** * This class offers label strings of Devanagari letters that need the dotted circle to draw * its glyph. */ class DevanagariLetterConstants { - private static final boolean NEEDS_DOTTED_CIRCLE = !Constants.JELLY_BEAN_OR_HIGHER; + private static final boolean NEEDS_DOTTED_CIRCLE = + Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN; // U+25CC: "◌" DOTTED CIRCLE private static final String DOTTED_CIRCLE = NEEDS_DOTTED_CIRCLE ? "\u25CC" : "";