本文整理汇总了Java中com.googlecode.eyesfree.braille.selfbraille.WriteData类的典型用法代码示例。如果您正苦于以下问题:Java WriteData类的具体用法?Java WriteData怎么用?Java WriteData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WriteData类属于com.googlecode.eyesfree.braille.selfbraille包,在下文中一共展示了WriteData类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: write
import com.googlecode.eyesfree.braille.selfbraille.WriteData; //导入依赖的package包/类
@Override
public void write(IBinder clientToken, WriteData writeData) {
if (clientToken == null) {
LogUtils.log(SelfBrailleService.this, Log.ERROR,
"null client token to write");
return;
}
ServiceUtil serviceUtil = new ServiceUtil(mPackageManager);
if (!serviceUtil.verifyCaller(Binder.getCallingUid())) {
LogUtils.log(SelfBrailleService.this, Log.ERROR,
"non-google signed package try to invoke service, rejected.");
return;
}
if (writeData == null) {
LogUtils.log(SelfBrailleService.this, Log.ERROR,
"null writeData to write");
return;
}
LogUtils.log(SelfBrailleService.this, Log.VERBOSE,
"write %s, %s", writeData.getText(),
writeData.getAccessibilityNodeInfo());
try {
writeData.validate();
} catch (IllegalStateException ex) {
LogUtils.log(SelfBrailleService.this, Log.ERROR,
"Invalid write data: %s", ex);
return;
}
NodeState state = new NodeState();
state.mClientToken = clientToken;
state.mWriteData = writeData;
mHandler.setNodeState(state);
}
示例2: contentForNode
import com.googlecode.eyesfree.braille.selfbraille.WriteData; //导入依赖的package包/类
public DisplayManager.Content contentForNode(
AccessibilityNodeInfoCompat node) {
if (mNodeStates.isEmpty()) {
return null;
}
AccessibilityNodeInfoCompat match =
AccessibilityNodeInfoUtils.getSelfOrMatchingAncestor(
this, node, mFilterHaveNodeState);
if (match == null) {
return null;
}
AccessibilityNodeInfo unwrappedMatch =
(AccessibilityNodeInfo) match.getInfo();
WriteData writeData = mNodeStates.get(unwrappedMatch).mWriteData;
if (writeData == null) {
return null;
}
SpannableStringBuilder sb = new SpannableStringBuilder(
writeData.getText());
// NOTE: it is important to use a node returned by the accessibility
// framework and not a node from a client of this service.
// The rest of BrailleBack will assume that the node we are adding
// here is sealed, supports actions etc.
DisplaySpans.setAccessibilityNode(sb, match);
int selectionStart = writeData.getSelectionStart();
if (selectionStart >= 0) {
int selectionEnd = writeData.getSelectionEnd();
if (selectionEnd < selectionStart) {
selectionEnd = selectionStart;
}
DisplaySpans.addSelection(sb, selectionStart, selectionEnd);
}
return new DisplayManager.Content(sb)
.setFirstNode(match)
.setLastNode(match)
.setPanStrategy(DisplayManager.Content.PAN_CURSOR);
}
示例3: sendBrailleText
import com.googlecode.eyesfree.braille.selfbraille.WriteData; //导入依赖的package包/类
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);
}
示例4: braille
import com.googlecode.eyesfree.braille.selfbraille.WriteData; //导入依赖的package包/类
@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);
}
}