Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f000bdc6 authored by satok's avatar satok Committed by Android (Google) Code Review
Browse files

Merge "Moved a functionality of setting touchableRegion to InputMethodServiceCompatWrapper."

parents 1ddf2a18 24119dfd
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.content.Intent;
import android.text.TextUtils;
import android.util.Log;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
@@ -77,6 +78,18 @@ public class CompatUtils {
        }
    }

    public static Field getField(Class<?> targetClass, String name) {
        try {
            return targetClass.getField(name);
        } catch (SecurityException e) {
            // ignore
            return null;
        } catch (NoSuchFieldException e) {
            // ignore
            return null;
        }
    }

    public static Object invoke(
            Object receiver, Object defaultValue, Method method, Object... args) {
        if (receiver == null || method == null) return defaultValue;
@@ -94,6 +107,28 @@ public class CompatUtils {
        }
    }

    public static Object getFieldValue(Object receiver, Object defaultValue, Field field) {
        if (receiver == null || field == null) return defaultValue;
        try {
            return field.get(receiver);
        } catch (IllegalArgumentException e) {
            return defaultValue;
        } catch (IllegalAccessException e) {
            return defaultValue;
        }
    }

    public static void setFieldValue(Object receiver, Field field, Object value) {
        if (receiver == null || field == null) return;
        try {
            field.set(receiver, value);
        } catch (IllegalArgumentException e) {
            // ignore
        } catch (IllegalAccessException e) {
            // ignore
        }
    }

    public static List<InputMethodSubtypeCompatWrapper> copyInputMethodSubtypeListToWrapper(
            Object listObject) {
        if (!(listObject instanceof List<?>)) return null;
+6 −0
Original line number Diff line number Diff line
@@ -62,4 +62,10 @@ public class InputMethodServiceCompatWrapper extends InputMethodService {
        SubtypeSwitcher.getInstance().updateSubtype(
                new InputMethodSubtypeCompatWrapper(subtype));
    }

    protected static void setTouchableRegionCompat(InputMethodService.Insets outInsets,
            int x, int y, int width, int height) {
        outInsets.touchableInsets = InputMethodService.Insets.TOUCHABLE_INSETS_REGION;
        outInsets.touchableRegion.set(x, y, width, height);
    }
}
+1 −2
Original line number Diff line number Diff line
@@ -914,8 +914,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
            if (DEBUG) {
                Log.d(TAG, "Touchable region " + x + ", " + y + ", " + width + ", " + height);
            }
            outInsets.touchableInsets = InputMethodService.Insets.TOUCHABLE_INSETS_REGION;
            outInsets.touchableRegion.set(x, y, width, height);
            setTouchableRegionCompat(outInsets, x, y, width, height);
        }
    }