summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuke Shumaker <shumakl@purdue.edu>2014-05-06 22:22:00 -0400
committerLuke Shumaker <shumakl@purdue.edu>2014-05-06 22:22:00 -0400
commit44fa9b5b07062c165192a50fea4301e57d3424ba (patch)
treed265d0bcda45ef980e88092b83bfc46098c9e19f /src
parent2b66c7acedf133bb000a34a3881cc3b88f7afa83 (diff)
parent100d98e3ff6798ce2e2a8f1f97b8b24de1e20168 (diff)
Merge branch 'master' of github.com:AndrewMurrell/minak
Conflicts: src/us/minak/IMEGestureOverlayView.java src/us/minak/IMEService.java src/us/minak/IMEView.java
Diffstat (limited to 'src')
-rw-r--r--src/us/minak/IMEGestureOverlayView.java9
-rw-r--r--src/us/minak/IMEService.java14
-rw-r--r--src/us/minak/IMEView.java39
-rw-r--r--src/us/minak/MetaCircle.java29
-rw-r--r--src/us/minak/MetaExpression.java24
5 files changed, 106 insertions, 9 deletions
diff --git a/src/us/minak/IMEGestureOverlayView.java b/src/us/minak/IMEGestureOverlayView.java
index 0676968..7e8867d 100644
--- a/src/us/minak/IMEGestureOverlayView.java
+++ b/src/us/minak/IMEGestureOverlayView.java
@@ -12,6 +12,7 @@
package us.minak;
+import java.util.LinkedList;
import java.util.List;
import android.content.Context;
@@ -21,7 +22,6 @@ import android.gesture.GestureOverlayView;
import android.gesture.GestureOverlayView.OnGesturePerformedListener;
import android.gesture.Prediction;
import android.graphics.Canvas;
-import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
@@ -32,6 +32,8 @@ public class IMEGestureOverlayView extends GestureOverlayView implements OnGestu
private static final double SCORE_TRESHOLD = 3.0;
private final GestureLibrary mGestureLibrary;
private StringReciever mOnGestureRecognizedListener;
+ public List<MetaCircle> circles = new LinkedList<MetaCircle>();
+ private final Paint mPaint = new Paint();
public IMEGestureOverlayView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -61,6 +63,9 @@ public class IMEGestureOverlayView extends GestureOverlayView implements OnGestu
}
public void onDraw(Canvas canvas) {
- // TODO: put things here
+ for (MetaCircle circle : circles) {
+ mPaint.setColor(circle.color);
+ canvas.drawCircle(circle.x, circle.y, circle.radius, mPaint);
+ }
}
}
diff --git a/src/us/minak/IMEService.java b/src/us/minak/IMEService.java
index 587135c..a0a9ece 100644
--- a/src/us/minak/IMEService.java
+++ b/src/us/minak/IMEService.java
@@ -22,27 +22,27 @@ import android.view.inputmethod.EditorInfo;
* Represent the application input service.
*/
public class IMEService extends InputMethodService {
- private IMEView mPenboardView;
+ private IMEView mIMEView;
@Override
public View onCreateInputView() {
- final IMEView penboardView = (IMEView) getLayoutInflater().inflate(R.layout.ime, null);
+ final IMEView minakView = (IMEView) getLayoutInflater().inflate(R.layout.ime, null);
- penboardView.setOnCharacterEnteredListener(new StringReciever() {
+ minakView.setOnCharacterEnteredListener(new StringReciever() {
@Override
public void putString(String character) {
getCurrentInputConnection().commitText(character, 1);
}
});
- mPenboardView = penboardView;
- return penboardView;
+ mIMEView = minakView;
+ return minakView;
}
@Override
public void onStartInput(EditorInfo attribute, boolean restarting) {
- if (mPenboardView != null) {
- final Queue<Character> symbolsQueue = mPenboardView.getSymbolsQueue();
+ if (mIMEView != null) {
+ final Queue<Character> symbolsQueue = mIMEView.getSymbolsQueue();
while (!symbolsQueue.isEmpty()) {
final Character character = symbolsQueue.poll();
getCurrentInputConnection().commitText(String.valueOf(character), 1);
diff --git a/src/us/minak/IMEView.java b/src/us/minak/IMEView.java
index 99e36cd..2cf7921 100644
--- a/src/us/minak/IMEView.java
+++ b/src/us/minak/IMEView.java
@@ -13,10 +13,16 @@
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;
/**
@@ -26,6 +32,27 @@ public class IMEView extends RelativeLayout {
private StringReciever mOnCharacterEnteredListener;
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;
+ }
+
public IMEView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@@ -39,6 +66,11 @@ public class IMEView extends RelativeLayout {
enterCharacter(character);
}
});
+
+ //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) {
@@ -49,6 +81,13 @@ public class IMEView extends RelativeLayout {
return mSymbolsQueue;
}
+ private final OnTouchListener mOnTouchListener = new OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ return setTouchLocation(event.getX(), event.getY());
+ }
+ };
+
/**
* Passes the given character to the input service.
*
diff --git a/src/us/minak/MetaCircle.java b/src/us/minak/MetaCircle.java
new file mode 100644
index 0000000..908842a
--- /dev/null
+++ b/src/us/minak/MetaCircle.java
@@ -0,0 +1,29 @@
+package us.minak;
+
+/*
+ * Not sure if this should be drawable or what.
+ *
+ */
+public class MetaCircle {
+ public MetaExpression metaExpr;
+ public float x;
+ public float y;
+ public float radius;
+ public int color;
+ public boolean expanded;
+ public int expansion; //the level of expansion (if multiple circles are expanded, this decides precidence)
+
+ MetaCircle(float x, float y, float radius, int color, MetaExpression metaExpr) {
+ this.metaExpr = metaExpr;
+ this.x = x;
+ this.y = y;
+ this.radius = radius;
+ this.color = color;
+ this.expanded = false;
+ this.expansion = 0;
+ }
+
+ public boolean containsPoint(float x, float y) {
+ return Math.pow(x - this.x, 2) + Math.pow(y - this.y, 2) < Math.pow(this.radius, 2) ? true : false;
+ }
+}
diff --git a/src/us/minak/MetaExpression.java b/src/us/minak/MetaExpression.java
new file mode 100644
index 0000000..4398c42
--- /dev/null
+++ b/src/us/minak/MetaExpression.java
@@ -0,0 +1,24 @@
+package us.minak;
+
+public class MetaExpression {
+ public enum State {
+ ON, OFF, LOCK
+ }
+
+ public State state;
+ private String value;
+
+ public String getValue() {
+ //however we want to do return this
+ return this.value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ MetaExpression(String value) {
+ this.value = value;
+ this.state = State.OFF;
+ }
+}