summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/us/minak/IMEView.java37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/us/minak/IMEView.java b/src/us/minak/IMEView.java
index 724d69d..7cdf4fd 100644
--- a/src/us/minak/IMEView.java
+++ b/src/us/minak/IMEView.java
@@ -13,11 +13,14 @@
package us.minak;
import java.util.LinkedList;
+import java.util.List;
import java.util.Locale;
import java.util.Queue;
import android.content.Context;
+import android.graphics.Color;
import android.util.AttributeSet;
+import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
@@ -32,6 +35,27 @@ public class IMEView extends RelativeLayout {
private ShiftState mShiftState = ShiftState.OFF;
private final Queue<Character> mSymbolsQueue = new LinkedList<Character>();
+ private float x;
+ private float y;
+ private boolean ongoingGesture = false;
+
+ public boolean setTouchLocation(float x, float y) {
+ if (!ongoingGesture) {
+ this.x = x;
+ this.y = y;
+ return true;
+ }
+ return false;
+ }
+
+ public void setState(boolean state) {
+ ongoingGesture = state;
+ }
+
+ public boolean getState() {
+ return ongoingGesture;
+ }
+
private enum ShiftState {
OFF, ON, CAPS_LOCK
};
@@ -61,6 +85,11 @@ public class IMEView extends RelativeLayout {
final Button spaceButton = (Button) findViewById(R.id.space_btn);
spaceButton.setOnClickListener(mButtonClickListener);
spaceButton.setOnLongClickListener(mButtonLongClickListener);
+
+ //dynamic MetaCircle adding stuff here. replace null with Shift or Ctrl or Meta or Alt or Hyper or whatever.
+ drawingSpaceView.circles.add(new MetaCircle((float)50.0, (float)50.0, (float)20.0, Color.RED, new MetaExpression(null)));
+ drawingSpaceView.circles.add(new MetaCircle((float)70.0, (float)70.0, (float)20.0, Color.RED, new MetaExpression(null)));
+ drawingSpaceView.circles.add(new MetaCircle((float)50.0, (float)30.0, (float)20.0, Color.RED, new MetaExpression(null)));
}
public void setOnCharacterEnteredListener(StringReciever onCharacterEnteredListener) {
@@ -119,6 +148,13 @@ public class IMEView extends RelativeLayout {
}
};
+ private final OnTouchListener mOnTouchListener = new OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ return setTouchLocation(event.getX(), event.getY());
+ }
+ };
+
/**
* Changes shift state to the next one (OFF -> ON -> CAPS LOCK).
*/
@@ -148,6 +184,7 @@ public class IMEView extends RelativeLayout {
* The character to enter
*/
private void enterCharacter(String character) {
+ //for each circle in circles check to see if the touch was in the circle and apply the meta-key
switch (mShiftState) {
case OFF:
mOnCharacterEnteredListener.putString(character);