From 42d03f38e3cccad38a1e3000e180662b378343c3 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 7 May 2014 04:05:40 -0400 Subject: Get the modifier keys working --- AndroidManifest.xml | 2 +- src/us/minak/IMEGestureOverlayView.java | 31 ++++++++++++++++++++++++++----- src/us/minak/IMEModifier.java | 4 +++- src/us/minak/IMEModifiers.java | 6 +++--- 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 79290e8..05ee7c0 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -5,7 +5,7 @@ android:versionName="1.0" > SCORE_TRESHOLD) { - ic.commitText(bestPrediction.name, 1); + for (KeyEvent keyEvent : charMap.getEvents(bestPrediction.name.toCharArray())) + sendKeyEvent(keyEvent); } else { clear(false); } } for (IMEModifier modifier : modifiers.getSelection()) { - ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, modifier.keycode)); + sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, modifier.keycode)); } } modifiers.clearSelection(); + meta = 0; invalidate(); x = y = -1; } @@ -76,10 +96,11 @@ public class IMEGestureOverlayView extends GestureOverlayView implements OnGestu modifiers.setSelectionPoint(x, y); invalidate(); - InputConnection ic = icGetter.getCurrentInputConnection(); + ic = icGetter.getCurrentInputConnection(); if (ic != null) { for (IMEModifier modifier : modifiers.getSelection()) { - ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, modifier.keycode)); + sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, modifier.keycode)); + meta |= modifier.metamask; } return true; } diff --git a/src/us/minak/IMEModifier.java b/src/us/minak/IMEModifier.java index a3ea3fc..50dc6d3 100644 --- a/src/us/minak/IMEModifier.java +++ b/src/us/minak/IMEModifier.java @@ -3,9 +3,11 @@ package us.minak; public class IMEModifier { public final String name; public final int keycode; + public final int metamask; - public IMEModifier(String name, int keycode) { + public IMEModifier(String name, int keycode, int metamask) { this.name = name; this.keycode = keycode; + this.metamask = metamask; } } diff --git a/src/us/minak/IMEModifiers.java b/src/us/minak/IMEModifiers.java index 645ae4a..2766c76 100644 --- a/src/us/minak/IMEModifiers.java +++ b/src/us/minak/IMEModifiers.java @@ -10,9 +10,9 @@ import java.util.List; public class IMEModifiers { // FIXME: hard-coded configuration private final IMEModifier[] modifiers = { - new IMEModifier("Shift", KeyEvent.KEYCODE_SHIFT_LEFT), - new IMEModifier("Ctrl" , KeyEvent.KEYCODE_CTRL_LEFT ), - new IMEModifier("Alt" , KeyEvent.KEYCODE_ALT_LEFT )}; + new IMEModifier("Shift", KeyEvent.KEYCODE_SHIFT_LEFT, KeyEvent.META_SHIFT_ON), + new IMEModifier("Ctrl" , KeyEvent.KEYCODE_CTRL_LEFT , KeyEvent.META_CTRL_ON ), + new IMEModifier("Alt" , KeyEvent.KEYCODE_ALT_LEFT , KeyEvent.META_ALT_ON )}; // Static drawing resources private final Paint colorPaint = new Paint(Paint.ANTI_ALIAS_FLAG); -- cgit v1.2.3-54-g00ecf