private static void sendBrailleText( final View view, final String text, final int selectionStart, final int selectionEnd) { AccessibilityNodeInfo info = AccessibilityNodeInfo.obtain(view, VIRTUAL_CURSOR_POSITION); WriteData data = WriteData.forInfo(info); data.setText(text); // Set either the focus blink or the current caret position/selection data.setSelectionStart(selectionStart); data.setSelectionEnd(selectionEnd); sSelfBrailleClient.write(data); }
@JavascriptInterface @SuppressWarnings("unused") public void braille(String jsonString) { try { JSONObject jsonObj = new JSONObject(jsonString); WriteData data = WriteData.forView(mView); data.setText(jsonObj.getString("text")); data.setSelectionStart(jsonObj.getInt("startIndex")); data.setSelectionEnd(jsonObj.getInt("endIndex")); mSelfBrailleClient.write(data); } catch (JSONException ex) { Log.w(TAG, "Error parsing JS JSON object", ex); } }