blob: 011df3ec4bb1e933cc2c16d2a4f1ec687a0a7b4c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
/*
********************************************************************************
* Copyright (c) 2012 Samsung Electronics, Inc.
* All rights reserved.
*
* This software is a confidential and proprietary information of Samsung
* Electronics, Inc. ("Confidential Information"). You shall not disclose such
* Confidential Information and shall use it only in accordance with the terms
* of the license agreement you entered into with Samsung Electronics.
********************************************************************************
*/
package us.minak;
import java.util.LinkedList;
import java.util.List;
import android.content.Context;
import android.gesture.Gesture;
import android.gesture.GestureLibrary;
import android.gesture.GestureOverlayView;
import android.gesture.GestureOverlayView.OnGesturePerformedListener;
import android.gesture.Prediction;
import android.graphics.Canvas;
import android.util.AttributeSet;
/**
* Represent a space where drawing gestures are performed.
*/
public class IMEGestureOverlayView extends GestureOverlayView implements OnGesturePerformedListener {
private static final double SCORE_TRESHOLD = 3.0;
private final GestureLibrary mGestureLibrary;
private StringReciever mOnGestureRecognizedListener;
public List<MetaCircle> circles = new LinkedList<MetaCircle>();
public IMEGestureOverlayView(Context context, AttributeSet attrs) {
super(context, attrs);
mGestureLibrary = SettingsUtil.getGestureLibrary(context);
mGestureLibrary.load();
addOnGesturePerformedListener(this);
}
public void setOnGestureRecognizedListener(StringReciever onGestureRecognizedListener) {
mOnGestureRecognizedListener = onGestureRecognizedListener;
}
@Override
public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
final List<Prediction> predictions = mGestureLibrary.recognize(gesture);
Prediction bestPrediction = null;
if (!predictions.isEmpty()) {
bestPrediction = predictions.get(0);
}
if (mOnGestureRecognizedListener != null && bestPrediction != null) {
if (bestPrediction.score > SCORE_TRESHOLD) {
mOnGestureRecognizedListener.putString(bestPrediction.name);
} else {
clear(false);
drawCircles((MetaCircle[]) this.circles.toArray());
}
}
}
public void onDraw(Canvas canvas) {
canvas.getHeight();
}
public void drawCircles (MetaCircle[] circles) {
for (MetaCircle circle : circles) {
//draw circle
;
}
}
}
|