Autofill sample: Fixed CustomVirtualView preCondition and improved dump.
Bug: 38182790
Test: manual
Change-Id: Ic6c23c12ed333470403457cdac9ed8e89d1d5cf8
diff --git a/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/CommonUtil.java b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/CommonUtil.java
index 1c00dd7..84b5a97 100644
--- a/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/CommonUtil.java
+++ b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/CommonUtil.java
@@ -104,12 +104,10 @@
private static void dumpNode(String prefix, ViewNode node) {
StringBuilder builder = new StringBuilder();
- String[] hints = node.getAutofillHints();
builder.append(prefix)
.append("autoFillId: ").append(node.getAutofillId())
.append("\tidEntry: ").append(node.getIdEntry())
.append("\tid: ").append(node.getId())
- .append("\thints: ").append(hints == null ? "N/A" : Arrays.toString(hints))
.append("\tclassName: ").append(node.getClassName())
.append('\n');
@@ -117,7 +115,8 @@
.append("focused: ").append(node.isFocused())
.append("\tvisibility").append(node.getVisibility())
.append("\tchecked: ").append(node.isChecked())
- .append("\tURL: ").append(node.getWebDomain())
+ .append("\twebDomain: ").append(node.getWebDomain())
+ .append("\thint: ").append(node.getHint())
.append('\n');
HtmlInfo htmlInfo = node.getHtmlInfo();
@@ -129,11 +128,13 @@
.append('\n');
}
+ String[] afHints = node.getAutofillHints();
CharSequence[] options = node.getAutofillOptions();
builder.append(prefix).append("afType: ").append(getTypeAsString(node.getAutofillType()))
.append("\tafValue:")
.append(getAutofillValueAndTypeAsString(node.getAutofillValue()))
.append("\tafOptions:").append(options == null ? "N/A" : Arrays.toString(options))
+ .append("\tafHints: ").append(afHints == null ? "N/A" : Arrays.toString(afHints))
.append("\tinputType:").append(node.getInputType())
.append('\n');
diff --git a/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/app/CustomVirtualView.java b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/app/CustomVirtualView.java
index df616f9..13d59ea 100644
--- a/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/app/CustomVirtualView.java
+++ b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/app/CustomVirtualView.java
@@ -287,7 +287,7 @@
*/
public Partition addPartition(String name) {
Preconditions.checkNotNull(name, "Name cannot be null.");
- Preconditions.checkArgument(mPartitionsByName.containsKey(name),
+ Preconditions.checkArgument(!mPartitionsByName.containsKey(name),
"Partition with such name already exists.");
Partition partition = new Partition(name);
mPartitionsByName.put(name, partition);