Search in sources :

Example 1 with Gesture

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;
        }
    }
}
Also used : Gesture(android.gesture.Gesture) Prediction(android.gesture.Prediction)

Example 2 with Gesture

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);
}
Also used : Gesture(android.gesture.Gesture) Prediction(android.gesture.Prediction) GestureStroke(android.gesture.GestureStroke) GesturePoint(android.gesture.GesturePoint)

Example 3 with Gesture

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;
}
Also used : Window(android.view.Window) Rect(android.graphics.Rect) GestureLibrary(android.gesture.GestureLibrary) Gesture(android.gesture.Gesture) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView)

Example 4 with Gesture

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);
}
Also used : Gesture(android.gesture.Gesture) Prediction(android.gesture.Prediction) GestureStroke(android.gesture.GestureStroke) GesturePoint(android.gesture.GesturePoint)

Example 5 with Gesture

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);
}
Also used : Gesture(android.gesture.Gesture) Prediction(android.gesture.Prediction) GestureStroke(android.gesture.GestureStroke) GesturePoint(android.gesture.GesturePoint)

Aggregations

Gesture (android.gesture.Gesture)7 Prediction (android.gesture.Prediction)6 GesturePoint (android.gesture.GesturePoint)5 GestureStroke (android.gesture.GestureStroke)5 GestureLibrary (android.gesture.GestureLibrary)1 Rect (android.graphics.Rect)1 View (android.view.View)1 Window (android.view.Window)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1