use of android.gesture.Gesture in project android_frameworks_base by ResurrectionRemix.
the class GestureAnywhereView method onGestureEnded.
@Override
public void onGestureEnded(GestureOverlayView overlay, MotionEvent event) {
Gesture gesture = overlay.getGesture();
List<Prediction> predictions = mStore.recognize(gesture);
for (Prediction prediction : predictions) {
if (prediction.score >= 2.0) {
switchToState(State.Closing);
String uri = prediction.name.substring(prediction.name.indexOf('|') + 1);
launchShortcut(uri);
break;
}
}
}
use of android.gesture.Gesture in project platform_frameworks_base by android.
the class AccessibilityGestureDetector method recognizeGesture.
private boolean recognizeGesture(MotionEvent event, int policyFlags) {
Gesture gesture = new Gesture();
gesture.addStroke(new GestureStroke(mStrokeBuffer));
ArrayList<Prediction> predictions = mGestureLibrary.recognize(gesture);
if (!predictions.isEmpty()) {
Prediction bestPrediction = predictions.get(0);
if (bestPrediction.score >= MIN_PREDICTION_SCORE) {
if (DEBUG) {
Slog.i(LOG_TAG, "gesture: " + bestPrediction.name + " score: " + bestPrediction.score);
}
try {
final int gestureId = Integer.parseInt(bestPrediction.name);
return mListener.onGestureCompleted(gestureId);
} catch (NumberFormatException nfe) {
Slog.w(LOG_TAG, "Non numeric gesture id:" + bestPrediction.name);
}
}
}
return mListener.onGestureCancelled(event, policyFlags);
}
use of android.gesture.Gesture in project AnyMemo by helloworld1.
the class GestureSelectionDialogFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.gesture_selection_dialog, container, false);
gestureList = (ListView) v.findViewById(R.id.gesture_list);
enableGestureCheckbox = (CheckBox) v.findViewById(R.id.enable_gestures);
enableGestureCheckbox.setChecked(option.getGestureEnabled());
enableGestureCheckbox.setOnCheckedChangeListener(enableGestureCheckboxChangeListener);
gestureAdapter = new GesturesAdapter(mActivity);
gestureList.setAdapter(gestureAdapter);
GestureLibrary gestureLibrary = GestureLibraries.fromRawResource(mActivity, R.raw.gestures);
gestureLibrary.load();
for (String gestureEntry : gestureLibrary.getGestureEntries()) {
for (Gesture gesture : gestureLibrary.getGestures(gestureEntry)) {
NamedGesture namedGesture = new NamedGesture();
namedGesture.name = gestureEntry;
namedGesture.gesture = gesture;
// do not want to use.
if (gestureNameDescriptionMap.containsKey(gestureEntry)) {
gestureAdapter.add(namedGesture);
}
}
}
setStyle(0, STYLE_NO_TITLE);
Rect displayRectangle = new Rect();
Window window = mActivity.getWindow();
window.getDecorView().getWindowVisibleDisplayFrame(displayRectangle);
v.setMinimumWidth((int) (displayRectangle.width() * 0.9f));
return v;
}
use of android.gesture.Gesture in project android_frameworks_base by DirtyUnicorns.
the class AccessibilityGestureDetector method recognizeGesture.
private boolean recognizeGesture(MotionEvent event, int policyFlags) {
Gesture gesture = new Gesture();
gesture.addStroke(new GestureStroke(mStrokeBuffer));
ArrayList<Prediction> predictions = mGestureLibrary.recognize(gesture);
if (!predictions.isEmpty()) {
Prediction bestPrediction = predictions.get(0);
if (bestPrediction.score >= MIN_PREDICTION_SCORE) {
if (DEBUG) {
Slog.i(LOG_TAG, "gesture: " + bestPrediction.name + " score: " + bestPrediction.score);
}
try {
final int gestureId = Integer.parseInt(bestPrediction.name);
return mListener.onGestureCompleted(gestureId);
} catch (NumberFormatException nfe) {
Slog.w(LOG_TAG, "Non numeric gesture id:" + bestPrediction.name);
}
}
}
return mListener.onGestureCancelled(event, policyFlags);
}
use of android.gesture.Gesture in project android_frameworks_base by AOSPA.
the class AccessibilityGestureDetector method recognizeGesture.
private boolean recognizeGesture(MotionEvent event, int policyFlags) {
Gesture gesture = new Gesture();
gesture.addStroke(new GestureStroke(mStrokeBuffer));
ArrayList<Prediction> predictions = mGestureLibrary.recognize(gesture);
if (!predictions.isEmpty()) {
Prediction bestPrediction = predictions.get(0);
if (bestPrediction.score >= MIN_PREDICTION_SCORE) {
if (DEBUG) {
Slog.i(LOG_TAG, "gesture: " + bestPrediction.name + " score: " + bestPrediction.score);
}
try {
final int gestureId = Integer.parseInt(bestPrediction.name);
return mListener.onGestureCompleted(gestureId);
} catch (NumberFormatException nfe) {
Slog.w(LOG_TAG, "Non numeric gesture id:" + bestPrediction.name);
}
}
}
return mListener.onGestureCancelled(event, policyFlags);
}
Aggregations