summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <shumakl@purdue.edu>2014-05-04 22:07:10 -0400
committerLuke Shumaker <shumakl@purdue.edu>2014-05-04 22:07:10 -0400
commit37683365975b33d2f666949b4d423f193e76feb9 (patch)
tree4554d07082b9d657f6113f16be41f7599794b181
parent26f5555afebb8c277a0b50cb1f73e7c57d629b30 (diff)
parenta1a170d693c55141d2a1bf02c7892c587b766251 (diff)
Merge remote-tracking branch 'origin/davis' into lukeshu
-rw-r--r--.settings/org.eclipse.jdt.core.prefs4
-rw-r--r--res/layout/ime.xml3
-rw-r--r--src/us/minak/IMEService.java7
-rw-r--r--src/us/minak/IMEView.java23
-rw-r--r--src/us/minak/SketchpadView.java~50
5 files changed, 85 insertions, 2 deletions
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..b080d2d
--- /dev/null
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,4 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/res/layout/ime.xml b/res/layout/ime.xml
index 510d40a..c5e78ef 100644
--- a/res/layout/ime.xml
+++ b/res/layout/ime.xml
@@ -15,6 +15,7 @@
android:gestureStrokeAngleThreshold="0.0"
android:gestureStrokeLengthThreshold="0.0"
android:gestureStrokeSquarenessThreshold="0.0"
- android:gestureStrokeType="multiple" />
+ android:gestureStrokeType="multiple">
+ </us.minak.DrawingSpaceView>
</us.minak.IMEView>
diff --git a/src/us/minak/IMEService.java b/src/us/minak/IMEService.java
index ba09656..6064be9 100644
--- a/src/us/minak/IMEService.java
+++ b/src/us/minak/IMEService.java
@@ -18,7 +18,12 @@ public class IMEService extends InputMethodService {
public View onCreateInputView() {
final IMEView view = (IMEView) getLayoutInflater().inflate(R.layout.ime, null);
- // TODO: there probably needs to be more stuff here
+ view.setOnCharacterEnteredListener(new OnCharacterEnteredListener() {
+ @Override
+ public void characterEntered(String character) {
+ getCurrentInputConnection().commitText(character, 1);
+ }
+ });
this.imeView = view;
return view;
diff --git a/src/us/minak/IMEView.java b/src/us/minak/IMEView.java
index 89d6d0a..d341ae5 100644
--- a/src/us/minak/IMEView.java
+++ b/src/us/minak/IMEView.java
@@ -5,7 +5,30 @@ import android.util.AttributeSet;
import android.widget.RelativeLayout;
public class IMEView extends RelativeLayout{
+ private final Context mContext;
+ private OnCharacterEnteredListener mOnCharacterEnteredListener;
public IMEView(Context context, AttributeSet attrs) {
super(context, attrs);
+ mContext = context;
+ }
+
+ @Override
+ protected void onFinishInflate() {
+ DrawingSpaceView drawingSpaceView = (DrawingSpaceView) findViewById(R.id.drawing_space);
+ drawingSpaceView.setOnGestureRecognizedListener(new OnGestureRecognizedListener() {
+ @Override
+ public void gestureRecognized(String character) {
+ enterCharacter(character);
+ }
+
+ });
+ }
+
+ public void setOnCharacterEnteredListener(OnCharacterEnteredListener onCharacterEnteredListener) {
+ mOnCharacterEnteredListener = onCharacterEnteredListener;
+ }
+
+ private void enterCharacter(String character) {
+ mOnCharacterEnteredListener.characterEntered(character);
}
}
diff --git a/src/us/minak/SketchpadView.java~ b/src/us/minak/SketchpadView.java~
new file mode 100644
index 0000000..55d69fd
--- /dev/null
+++ b/src/us/minak/SketchpadView.java~
@@ -0,0 +1,50 @@
+import java.util.List;
+
+import android.gesture.Gesture;
+import android.gesture.GestureLibraries;
+import android.gesture.GestureLibrary;
+import android.gesture.GestureOverlayView;
+import android.gesture.GestureOverlayView.OnGesturePerformedListener;
+import android.gesture.Prediction;
+
+public class SketchpadView extends GestureOverlayView implements OnGesturePerformedListener{
+ //Setting score thresh hold
+ private static final double score_threshold = 3.0;
+ //loads gesture library
+ private final GestureLibrary gestureLib;
+ //used to capture drawn gestures
+ private onGestureRecognizedListener gestureRecognizer;
+
+ public SketchpadView (){
+ //not sure what to add here
+ }
+
+ public void setOnGestureRecognizedListener(OnGestureRecognizedListener onGestureRecognizedListener) {
+ gestureRecognizer = onGestureRecognizedListener;
+ }
+
+ @Override
+ public void onGesturePerformed(GestureOverlayView view, Gesture gesture){
+ //create list of predicted characters to be entered
+ List<Prediction> predictions = gestureLib.recognize(gesture);
+ Prediction bestPrediction = null;
+ //if we have a prediction
+ if(!predictions.isEmpty()){
+ //I believe that this just blidnly adds a predicted character without any checks
+ //we need to see if there is a way to actual get the best prediction
+ //if this lists them based on the best, then fuck me and ignore this/delete this
+ bestPrediction = predictions.get(0);
+ }
+ //if we have a gesture and a decent prediction
+ if(gestureRecognizer != null && bestPrediction != null){
+ //if the prediction is good enough
+ if(bestPrediction.score > score_threshold){
+ //we recognize it
+ gestureRecognizer.gestureRecognized(bestPrediction.name);
+ }else{
+ //why?
+ clear(false);
+ }
+ }
+ }
+}