diff options
Diffstat (limited to 'java/src/com/android/inputmethod/compat')
3 files changed, 5 insertions, 53 deletions
diff --git a/java/src/com/android/inputmethod/compat/InputMethodSubtypeCompatUtils.java b/java/src/com/android/inputmethod/compat/InputMethodSubtypeCompatUtils.java index 58ad4bd4c..853830808 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 (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { + if (Constants.JELLY_BEAN_MR1_OR_HIGHER) { if (CONSTRUCTOR_INPUT_METHOD_SUBTYPE == null) { android.util.Log.w(TAG, "Warning!!! Constructor is not defined."); } @@ -59,8 +59,7 @@ 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 - || Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { + if (CONSTRUCTOR_INPUT_METHOD_SUBTYPE == null || !Constants.JELLY_BEAN_MR1_OR_HIGHER) { 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 70ab972c5..0646558e4 100644 --- a/java/src/com/android/inputmethod/compat/NotificationCompatUtils.java +++ b/java/src/com/android/inputmethod/compat/NotificationCompatUtils.java @@ -17,7 +17,8 @@ package com.android.inputmethod.compat; import android.app.Notification; -import android.os.Build; + +import com.android.inputmethod.latin.common.Constants; import java.lang.reflect.Field; import java.lang.reflect.Method; @@ -73,7 +74,7 @@ public class NotificationCompatUtils { @SuppressWarnings("deprecation") public static Notification build(final Notification.Builder builder) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + if (Constants.JELLY_BEAN_OR_HIGHER) { // #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/compat/UserDictionaryCompatUtils.java b/java/src/com/android/inputmethod/compat/UserDictionaryCompatUtils.java deleted file mode 100644 index b78c357ab..000000000 --- a/java/src/com/android/inputmethod/compat/UserDictionaryCompatUtils.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.inputmethod.compat; - -import android.annotation.TargetApi; -import android.content.Context; -import android.os.Build; -import android.provider.UserDictionary; - -import java.util.Locale; - -public final class UserDictionaryCompatUtils { - @SuppressWarnings("deprecation") - public static void addWord(final Context context, final String word, - final int freq, final String shortcut, final Locale locale) { - if (BuildCompatUtils.EFFECTIVE_SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - addWordWithShortcut(context, word, freq, shortcut, locale); - return; - } - // Fall back to the pre-JellyBean method. - final Locale currentLocale = context.getResources().getConfiguration().locale; - final int localeType = currentLocale.equals(locale) - ? UserDictionary.Words.LOCALE_TYPE_CURRENT : UserDictionary.Words.LOCALE_TYPE_ALL; - UserDictionary.Words.addWord(context, word, freq, localeType); - } - - // {@link UserDictionary.Words#addWord(Context,String,int,String,Locale)} was introduced - // in API level 16 (Build.VERSION_CODES.JELLY_BEAN). - @TargetApi(Build.VERSION_CODES.JELLY_BEAN) - private static void addWordWithShortcut(final Context context, final String word, - final int freq, final String shortcut, final Locale locale) { - UserDictionary.Words.addWord(context, word, freq, shortcut, locale); - } -} |