コード例 #1
0
  private void notifySelectionChange(int start, int end) {

    final InputMethodManager imm = getInputMethodManager();
    final View v = getView();
    final Editable editable = getEditable();
    if (imm == null || v == null || editable == null) {
      return;
    }
    imm.updateSelection(
        v, start, end, getComposingSpanStart(editable), getComposingSpanEnd(editable));
  }
コード例 #2
0
  public void notifySelectionChange(InputMethodManager imm, int start, int end) {
    if (!mBatchMode) {
      final Editable content = getEditable();

      start = clampContentIndex(content, start);
      end = clampContentIndex(content, end);

      clampSelection();
      int a = Selection.getSelectionStart(content);
      int b = Selection.getSelectionEnd(content);

      if (start != a || end != b) {
        if (DEBUG) {
          Log.d(
              LOGTAG,
              String.format(
                  ". . . notifySelectionChange: current editable selection: [%d, %d]", a, b));
        }

        super.setSelection(start, end);

        // Check if the selection is inside composing span
        int ca = getComposingSpanStart(content);
        int cb = getComposingSpanEnd(content);
        if (cb < ca) {
          int tmp = ca;
          ca = cb;
          cb = tmp;
        }
        if (start < ca || start > cb || end < ca || end > cb) {
          if (DEBUG) Log.d(LOGTAG, ". . . notifySelectionChange: removeComposingSpans");
          removeComposingSpans(content);
        }
      }
    }

    if (imm != null && imm.isFullscreenMode()) {
      View v = GeckoApp.mAppContext.getLayerController().getView();
      imm.updateSelection(v, start, end, -1, -1);
    }
  }