diff --git a/java/src/com/android/inputmethod/compat/CompatUtils.java b/java/src/com/android/inputmethod/compat/CompatUtils.java index 8bf59091f18b1c50dbcf604698ee2f43b106eb2b..07db4a1bb927756a42390cd731303ba566d08b44 100644 --- a/java/src/com/android/inputmethod/compat/CompatUtils.java +++ b/java/src/com/android/inputmethod/compat/CompatUtils.java @@ -96,7 +96,7 @@ public class CompatUtils { try { return method.invoke(receiver, args); } catch (IllegalArgumentException e) { - Log.e(TAG, "Exception in invoke: IllegalArgmentException"); + Log.e(TAG, "Exception in invoke: IllegalArgumentException"); return defaultValue; } catch (IllegalAccessException e) { Log.e(TAG, "Exception in invoke: IllegalAccessException"); @@ -112,8 +112,10 @@ public class CompatUtils { try { return field.get(receiver); } catch (IllegalArgumentException e) { + Log.e(TAG, "Exception in getFieldValue: IllegalArgumentException"); return defaultValue; } catch (IllegalAccessException e) { + Log.e(TAG, "Exception in getFieldValue: IllegalAccessException"); return defaultValue; } } @@ -123,9 +125,9 @@ public class CompatUtils { try { field.set(receiver, value); } catch (IllegalArgumentException e) { - // ignore + Log.e(TAG, "Exception in setFieldValue: IllegalArgumentException"); } catch (IllegalAccessException e) { - // ignore + Log.e(TAG, "Exception in setFieldValue: IllegalAccessException"); } } diff --git a/java/src/com/android/inputmethod/compat/InputMethodServiceCompatWrapper.java b/java/src/com/android/inputmethod/compat/InputMethodServiceCompatWrapper.java index 606322af7e049b980003b5452794234279815e78..e02aac70457d8bb391fd19445239ff025c283d6f 100644 --- a/java/src/com/android/inputmethod/compat/InputMethodServiceCompatWrapper.java +++ b/java/src/com/android/inputmethod/compat/InputMethodServiceCompatWrapper.java @@ -19,9 +19,20 @@ package com.android.inputmethod.compat; import com.android.inputmethod.latin.SubtypeSwitcher; import android.inputmethodservice.InputMethodService; +import android.view.View; import android.view.inputmethod.InputMethodSubtype; +import android.widget.HorizontalScrollView; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; public class InputMethodServiceCompatWrapper extends InputMethodService { + private static final Method METHOD_HorizontalScrollView_setOverScrollMode = + CompatUtils.getMethod(HorizontalScrollView.class, "setOverScrollMode", int.class); + private static final Field FIELD_View_OVER_SCROLL_NEVER = + CompatUtils.getField(View.class, "OVER_SCROLL_NEVER"); + private static final Integer View_OVER_SCROLL_NEVER = + (Integer)CompatUtils.getFieldValue(null, null, FIELD_View_OVER_SCROLL_NEVER); // CAN_HANDLE_ON_CURRENT_INPUT_METHOD_SUBTYPE_CHANGED needs to be false if the API level is 10 // or previous. Note that InputMethodSubtype was added in the API level 11. // For the API level 11 or later, LatinIME should override onCurrentInputMethodSubtypeChanged(). @@ -55,6 +66,16 @@ public class InputMethodServiceCompatWrapper extends InputMethodService { } } + protected static void setOverScrollModeNever(HorizontalScrollView scrollView) { + if (View_OVER_SCROLL_NEVER != null) { + CompatUtils.invoke(scrollView, null, METHOD_HorizontalScrollView_setOverScrollMode, + View_OVER_SCROLL_NEVER); + } + } + + ////////////////////////////////////// + // Functions using API v11 or later // + ////////////////////////////////////// @Override public void onCurrentInputMethodSubtypeChanged(InputMethodSubtype subtype) { // Do nothing when the API level is 10 or previous diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index fa2290cc1ccddbe2bddb3285681f1f767d49c920..05169dd9bd2785c948b61ab5c18cf35ca75e4fd0 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -530,7 +530,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar if (container.getPaddingRight() != 0) { HorizontalScrollView scrollView = (HorizontalScrollView) container.findViewById(R.id.candidates_scroll_view); - scrollView.setOverScrollMode(View.OVER_SCROLL_NEVER); + setOverScrollModeNever(scrollView); container.setGravity(Gravity.CENTER_HORIZONTAL); } mCandidateView = (CandidateView) container.findViewById(R.id.candidates);