Пример #1
0
 public static void logGesturePoints(String label, GesturePoint[] points) {
   StringBuilder sb = new StringBuilder();
   if (label != null) {
     sb.append(label);
   }
   sb.append('[');
   for (GesturePoint point : points) {
     sb.append(ShorthandUtils.gesturePointToString(point));
     sb.append(", ");
   }
   sb.replace(sb.length() - 2, sb.length(), "]");
   Log.d(TAG, sb.toString());
 }
Пример #2
0
  /** Itt inicializáljuk a beviteli eszközt. */
  @Override
  public void onCreate() {
    super.onCreate();
    mContext = getApplicationContext();

    float drawingAreaHeight = ShorthandUtils.dpToPx(mContext, 250.0f);
    mRecognizer = new Recognizer(mContext, drawingAreaHeight / 3);
    mRecognizer.loadDefaultCharMapping();

    SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    Parameters.initInstance(sharedPrefs);
    mParameters = Parameters.getInstance();
    sharedPrefs.registerOnSharedPreferenceChangeListener(mParameters);
  }
Пример #3
0
  @Override
  public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
    // Log.d(TAG, "Strokes size: " + gesture.getStrokesCount());

    InputConnection ic = getCurrentInputConnection();

    for (GestureStroke stroke : gesture.getStrokes()) {
      GesturePoint[] points = ShorthandUtils.extractGesturePointsFromStroke(stroke);
      String result = mRecognizer.recognize(points);
      if (mParameters.isDebugEnabled()) {
        StenoCanvas canvas = (StenoCanvas) overlay;
        canvas.setDebugPaths(mRecognizer.getDebugPaths());
        canvas.setDebugPoints(points);
      }
      if (result != null && result.length() > 0) {
        ic.commitText(result, 1);
      } else if (mParameters.isPopupsEnabled()) {
        Toast.makeText(mContext, R.string.not_found, Toast.LENGTH_SHORT).show();
      }
    }
  }