Fix master build.

For some reason, we can't import android.os package in our Constants.

Change-Id: I357ed72d13c5039a83c6e2489cdf5ef74d0ffea8
main
Dan Zivkovic 2015-02-11 13:32:13 -08:00
parent 12d80ebead
commit 5254c01d4c
10 changed files with 23 additions and 28 deletions

View File

@ -16,20 +16,12 @@
package com.android.inputmethod.latin.common; package com.android.inputmethod.latin.common;
import android.os.Build;
import com.android.inputmethod.annotations.UsedForTesting; import com.android.inputmethod.annotations.UsedForTesting;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
public final class Constants { 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 { public static final class Color {
/** /**
* The alpha value for fully opaque. * The alpha value for fully opaque.

View File

@ -35,7 +35,6 @@ import android.view.inputmethod.EditorInfo;
import com.android.inputmethod.compat.SettingsSecureCompatUtils; import com.android.inputmethod.compat.SettingsSecureCompatUtils;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.SuggestedWords; import com.android.inputmethod.latin.SuggestedWords;
import com.android.inputmethod.latin.common.Constants;
import com.android.inputmethod.latin.utils.InputTypeUtils; import com.android.inputmethod.latin.utils.InputTypeUtils;
public final class AccessibilityUtils { 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 // Platforms starting at SDK version 16 (Build.VERSION_CODES.JELLY_BEAN) should use
// announce events. // announce events.
if (Constants.JELLY_BEAN_OR_HIGHER) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
event.setEventType(AccessibilityEventCompat.TYPE_ANNOUNCEMENT); event.setEventType(AccessibilityEventCompat.TYPE_ANNOUNCEMENT);
} else { } else {
event.setEventType(AccessibilityEvent.TYPE_VIEW_FOCUSED); event.setEventType(AccessibilityEvent.TYPE_VIEW_FOCUSED);

View File

@ -38,7 +38,7 @@ public final class InputMethodSubtypeCompatUtils {
int.class, int.class, String.class, String.class, String.class, boolean.class, int.class, int.class, String.class, String.class, String.class, boolean.class,
boolean.class, int.class); boolean.class, int.class);
static { 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) { if (CONSTRUCTOR_INPUT_METHOD_SUBTYPE == null) {
android.util.Log.w(TAG, "Warning!!! Constructor is not defined."); 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, public static InputMethodSubtype newInputMethodSubtype(int nameId, int iconId, String locale,
String mode, String extraValue, boolean isAuxiliary, String mode, String extraValue, boolean isAuxiliary,
boolean overridesImplicitlyEnabledSubtype, int id) { 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, return new InputMethodSubtype(nameId, iconId, locale, mode, extraValue, isAuxiliary,
overridesImplicitlyEnabledSubtype); overridesImplicitlyEnabledSubtype);
} }

View File

@ -17,8 +17,7 @@
package com.android.inputmethod.compat; package com.android.inputmethod.compat;
import android.app.Notification; import android.app.Notification;
import android.os.Build;
import com.android.inputmethod.latin.common.Constants;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -74,7 +73,7 @@ public class NotificationCompatUtils {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static Notification build(final Notification.Builder builder) { 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 // #build was added in API level 16, JELLY_BEAN
return (Notification) CompatUtils.invoke(builder, null, METHOD_build); return (Notification) CompatUtils.invoke(builder, null, METHOD_build);
} }

View File

@ -899,7 +899,7 @@ public final class RichInputConnection implements PrivateCommandPerformer {
* On platforms on which this method is not present, this is a no-op. * On platforms on which this method is not present, this is a no-op.
*/ */
public void maybeMoveTheCursorAroundAndRestoreToWorkaroundABug() { public void maybeMoveTheCursorAroundAndRestoreToWorkaroundABug() {
if (!Constants.JELLY_BEAN_OR_HIGHER) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
if (mExpectedSelStart > 0) { if (mExpectedSelStart > 0) {
mIC.setSelection(mExpectedSelStart - 1, mExpectedSelStart - 1); mIC.setSelection(mExpectedSelStart - 1, mExpectedSelStart - 1);
} else { } else {

View File

@ -19,13 +19,13 @@ package com.android.inputmethod.latin.settings;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Resources; import android.content.res.Resources;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.preference.Preference; import android.preference.Preference;
import com.android.inputmethod.latin.AudioAndHapticFeedbackManager; import com.android.inputmethod.latin.AudioAndHapticFeedbackManager;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.RichInputMethodManager; import com.android.inputmethod.latin.RichInputMethodManager;
import com.android.inputmethod.latin.common.Constants;
/** /**
* "Preferences" settings sub screen. * "Preferences" settings sub screen.
@ -39,6 +39,10 @@ import com.android.inputmethod.latin.common.Constants;
* - Voice input key * - Voice input key
*/ */
public final class PreferencesSettingsFragment extends SubScreenFragment { public final class PreferencesSettingsFragment extends SubScreenFragment {
private static final boolean VOICE_IME_ENABLED =
Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
@Override @Override
public void onCreate(final Bundle icicle) { public void onCreate(final Bundle icicle) {
super.onCreate(icicle); super.onCreate(icicle);
@ -73,8 +77,8 @@ public final class PreferencesSettingsFragment extends SubScreenFragment {
final Preference voiceInputKeyOption = findPreference(Settings.PREF_VOICE_INPUT_KEY); final Preference voiceInputKeyOption = findPreference(Settings.PREF_VOICE_INPUT_KEY);
if (voiceInputKeyOption != null) { if (voiceInputKeyOption != null) {
RichInputMethodManager.getInstance().refreshSubtypeCaches(); RichInputMethodManager.getInstance().refreshSubtypeCaches();
voiceInputKeyOption.setEnabled(Constants.JELLY_BEAN_OR_HIGHER); voiceInputKeyOption.setEnabled(VOICE_IME_ENABLED);
voiceInputKeyOption.setSummary(Constants.JELLY_BEAN_OR_HIGHER voiceInputKeyOption.setSummary(VOICE_IME_ENABLED
? null : getText(R.string.voice_input_disabled_summary)); ? null : getText(R.string.voice_input_disabled_summary));
} }
} }

View File

@ -21,6 +21,7 @@ import android.content.SharedPreferences;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.content.res.Resources; import android.content.res.Resources;
import android.os.Build;
import android.util.Log; import android.util.Log;
import android.view.inputmethod.EditorInfo; 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.InputAttributes;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.RichInputMethodManager; 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.AsyncResultHolder;
import com.android.inputmethod.latin.utils.ResourceUtils; import com.android.inputmethod.latin.utils.ResourceUtils;
import com.android.inputmethod.latin.utils.TargetPackageInfoGetterTask; import com.android.inputmethod.latin.utils.TargetPackageInfoGetterTask;
@ -137,7 +137,7 @@ public class SettingsValues {
DebugSettings.PREF_SLIDING_KEY_INPUT_PREVIEW, true); DebugSettings.PREF_SLIDING_KEY_INPUT_PREVIEW, true);
mShowsVoiceInputKey = needsToShowVoiceInputKey(prefs, res) mShowsVoiceInputKey = needsToShowVoiceInputKey(prefs, res)
&& mInputAttributes.mShouldShowVoiceInputKey && mInputAttributes.mShouldShowVoiceInputKey
&& Constants.JELLY_BEAN_OR_HIGHER; && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
final String autoCorrectionThresholdRawValue = prefs.getString( final String autoCorrectionThresholdRawValue = prefs.getString(
Settings.PREF_AUTO_CORRECTION_THRESHOLD, Settings.PREF_AUTO_CORRECTION_THRESHOLD,
res.getString(R.string.auto_correction_threshold_mode_index_modest)); res.getString(R.string.auto_correction_threshold_mode_index_modest));

View File

@ -20,6 +20,7 @@ import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.database.Cursor; import android.database.Cursor;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.preference.Preference; import android.preference.Preference;
import android.preference.PreferenceFragment; import android.preference.PreferenceFragment;
@ -31,7 +32,6 @@ import android.view.inputmethod.InputMethodManager;
import android.view.inputmethod.InputMethodSubtype; import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.common.Constants;
import com.android.inputmethod.latin.common.LocaleUtils; import com.android.inputmethod.latin.common.LocaleUtils;
import java.util.List; import java.util.List;
@ -75,7 +75,7 @@ public class UserDictionaryList extends PreferenceFragment {
} finally { } finally {
cursor.close(); 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 // For ICS, we need to show "For all languages" in case that the keyboard locale
// is different from the system locale // is different from the system locale
localeSet.add(""); localeSet.add("");

View File

@ -17,20 +17,19 @@
package com.android.inputmethod.compat; package com.android.inputmethod.compat;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.os.Build;
import android.test.AndroidTestCase; import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest; import android.test.suitebuilder.annotation.SmallTest;
import android.text.SpannableString; import android.text.SpannableString;
import android.text.Spanned; import android.text.Spanned;
import android.text.style.StyleSpan; import android.text.style.StyleSpan;
import com.android.inputmethod.latin.common.Constants;
import java.util.Locale; import java.util.Locale;
@SmallTest @SmallTest
public class LocaleSpanCompatUtilsTests extends AndroidTestCase { public class LocaleSpanCompatUtilsTests extends AndroidTestCase {
public void testInstantiatable() { 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. // LocaleSpan isn't yet available.
return; return;
} }

View File

@ -16,14 +16,15 @@
package com.android.inputmethod.keyboard.layout; 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 * This class offers label strings of Devanagari letters that need the dotted circle to draw
* its glyph. * its glyph.
*/ */
class DevanagariLetterConstants { 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 // U+25CC: "◌" DOTTED CIRCLE
private static final String DOTTED_CIRCLE = NEEDS_DOTTED_CIRCLE ? "\u25CC" : ""; private static final String DOTTED_CIRCLE = NEEDS_DOTTED_CIRCLE ? "\u25CC" : "";