Loading java/src/com/android/inputmethod/compat/CompatUtils.java +5 −3 Original line number Diff line number Diff line Loading @@ -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"); Loading @@ -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; } } Loading @@ -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"); } } Loading java/src/com/android/inputmethod/compat/InputMethodServiceCompatWrapper.java +21 −0 Original line number Diff line number Diff line Loading @@ -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(). Loading Loading @@ -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 Loading java/src/com/android/inputmethod/latin/LatinIME.java +1 −1 Original line number Diff line number Diff line Loading @@ -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); Loading Loading
java/src/com/android/inputmethod/compat/CompatUtils.java +5 −3 Original line number Diff line number Diff line Loading @@ -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"); Loading @@ -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; } } Loading @@ -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"); } } Loading
java/src/com/android/inputmethod/compat/InputMethodServiceCompatWrapper.java +21 −0 Original line number Diff line number Diff line Loading @@ -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(). Loading Loading @@ -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 Loading
java/src/com/android/inputmethod/latin/LatinIME.java +1 −1 Original line number Diff line number Diff line Loading @@ -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); Loading