fix(automator): click always return true if the widget with text exists

This commit is contained in:
hyb1996
2018-04-13 22:55:08 +08:00
parent a00bd293b3
commit 34fb18cba3
2 changed files with 5 additions and 6 deletions

View File

@@ -46,14 +46,14 @@ public class ActionFactory {
return new SearchTargetAction(action, new FilterAction.EditableFilter(index)) { return new SearchTargetAction(action, new FilterAction.EditableFilter(index)) {
@Override @Override
protected void performAction(UiObject node) { protected boolean performAction(UiObject node) {
Bundle args = new Bundle(); Bundle args = new Bundle();
if (action == AccessibilityNodeInfo.ACTION_SET_TEXT) { if (action == AccessibilityNodeInfo.ACTION_SET_TEXT) {
args.putCharSequence(AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE, text); args.putCharSequence(AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE, text);
} else { } else {
args.putCharSequence(AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE, node.text() + text); args.putCharSequence(AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE, node.text() + text);
} }
node.performAction(AccessibilityNodeInfo.ACTION_SET_TEXT, args); return node.performAction(AccessibilityNodeInfo.ACTION_SET_TEXT, args);
} }
}; };
} }

View File

@@ -25,16 +25,15 @@ public abstract class SearchTargetAction extends FilterAction {
boolean performed = false; boolean performed = false;
for (UiObject node : nodes) { for (UiObject node : nodes) {
node = searchTarget(node); node = searchTarget(node);
if (node != null) { if (node != null && performAction(node)) {
performAction(node);
performed = true; performed = true;
} }
} }
return performed; return performed;
} }
protected void performAction(UiObject node) { protected boolean performAction(UiObject node) {
node.performAction(mAction); return node.performAction(mAction);
} }
public int getAction() { public int getAction() {