Autofill sample: added icons, fixed an auth bug, added more comments.

* Added icons for autofill popups.
* Fixed RTE in the service due to autofill being enabled on the autofill login page.
* Added more comments to other unrelated functions.
* Added helper functions for ensuring only supported hints are supported.
* Added string resources.
* Changed some method/variable names to match newish class names.

Bug: 38182790
Test: manual
Change-Id: I1874c7be12ee1b50f5cc94542561d00820ba1874
diff --git a/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/AuthActivity.java b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/AuthActivity.java
index 30591c0..c365cc3 100644
--- a/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/AuthActivity.java
+++ b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/AuthActivity.java
@@ -130,7 +130,7 @@
         int saveTypes = autofillFields.getSaveType();
         mReplyIntent = new Intent();
         HashMap<String, FilledAutofillFieldCollection> clientFormDataMap =
-                SharedPrefsAutofillRepository.getInstance(this).getClientFormData
+                SharedPrefsAutofillRepository.getInstance(this).getFilledAutofillFieldCollection
                         (autofillFields.getFocusedHints(), autofillFields.getAllHints());
         if (forResponse) {
             setResponseIntent(AutofillHelper.newResponse
diff --git a/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/AutofillFieldMetadata.java b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/AutofillFieldMetadata.java
index b4cf899..8f83c22 100644
--- a/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/AutofillFieldMetadata.java
+++ b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/AutofillFieldMetadata.java
@@ -38,7 +38,7 @@
         mAutofillType = view.getAutofillType();
         mAutofillOptions = view.getAutofillOptions();
         mFocused = view.isFocused();
-        setHints(view.getAutofillHints());
+        setHints(AutofillHelper.filterForSupportedHints(view.getAutofillHints()));
     }
 
     public String[] getHints() {
diff --git a/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/AutofillHelper.java b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/AutofillHelper.java
index afb1d85..f5d43e4 100644
--- a/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/AutofillHelper.java
+++ b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/AutofillHelper.java
@@ -20,6 +20,7 @@
 import android.service.autofill.Dataset;
 import android.service.autofill.FillResponse;
 import android.service.autofill.SaveInfo;
+import android.support.annotation.DrawableRes;
 import android.util.Log;
 import android.view.View;
 import android.view.autofill.AutofillId;
@@ -28,6 +29,7 @@
 import com.example.android.autofillframework.R;
 import com.example.android.autofillframework.multidatasetservice.model.FilledAutofillFieldCollection;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Set;
 
@@ -46,11 +48,17 @@
             AutofillFieldMetadataCollection autofillFields, FilledAutofillFieldCollection filledAutofillFieldCollection, boolean datasetAuth) {
         String datasetName = filledAutofillFieldCollection.getDatasetName();
         if (datasetName != null) {
-            Dataset.Builder datasetBuilder = new Dataset.Builder
-                    (newRemoteViews(context.getPackageName(), datasetName));
+            Dataset.Builder datasetBuilder;
             if (datasetAuth) {
+                datasetBuilder = new Dataset.Builder
+                        (newRemoteViews(context.getPackageName(), datasetName,
+                                R.drawable.ic_lock_black_24dp));
                 IntentSender sender = AuthActivity.getAuthIntentSenderForDataset(context, datasetName);
                 datasetBuilder.setAuthentication(sender);
+            } else {
+                datasetBuilder = new Dataset.Builder
+                        (newRemoteViews(context.getPackageName(), datasetName,
+                                R.drawable.ic_person_black_24dp));
             }
             boolean setValueAtLeastOnce = filledAutofillFieldCollection.applyToFields(autofillFields, datasetBuilder);
             if (setValueAtLeastOnce) {
@@ -60,9 +68,11 @@
         return null;
     }
 
-    public static RemoteViews newRemoteViews(String packageName, String remoteViewsText) {
+    public static RemoteViews newRemoteViews(String packageName, String remoteViewsText,
+            @DrawableRes int drawableId) {
         RemoteViews presentation = new RemoteViews(packageName, R.layout.multidataset_service_list_item);
-        presentation.setTextViewText(R.id.text1, remoteViewsText);
+        presentation.setTextViewText(R.id.text, remoteViewsText);
+        presentation.setImageViewResource(R.id.icon, drawableId);
         return presentation;
     }
 
@@ -97,6 +107,16 @@
         }
     }
 
+    public static String[] filterForSupportedHints(String[] hints) {
+        ArrayList<String> supportedHints = new ArrayList<>(hints.length);
+        for (int i = 0; i < hints.length; i++) {
+            if (AutofillHelper.isValidHint(hints[i])) {
+                supportedHints.add(hints[i]);
+            }
+        }
+        return supportedHints.toArray(new String[supportedHints.size()]);
+    }
+
     public static boolean isValidHint(String hint) {
         switch (hint) {
             case View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE:
diff --git a/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/MyAutofillService.java b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/MyAutofillService.java
index 494a8bf..db63050 100644
--- a/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/MyAutofillService.java
+++ b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/MyAutofillService.java
@@ -27,6 +27,7 @@
 import android.service.autofill.SaveCallback;
 import android.service.autofill.SaveRequest;
 import android.util.Log;
+import android.view.autofill.AutofillId;
 import android.widget.RemoteViews;
 
 import com.example.android.autofillframework.R;
@@ -50,13 +51,6 @@
         final Bundle data = request.getClientState();
         Log.d(TAG, "onFillRequest(): data=" + bundleToString(data));
 
-        // Temporary hack for disabling autofill for components in this autofill service.
-        // i.e. we don't want to autofill components in AuthActivity.
-        if (structure.getActivityComponent().toShortString()
-                .contains("com.example.android.autofillframework.service")) {
-            callback.onSuccess(null);
-            return;
-        }
         cancellationSignal.setOnCancelListener(new CancellationSignal.OnCancelListener() {
             @Override
             public void onCancel() {
@@ -70,19 +64,21 @@
         FillResponse.Builder responseBuilder = new FillResponse.Builder();
         // Check user's settings for authenticating Responses and Datasets.
         boolean responseAuth = MyPreferences.getInstance(this).isResponseAuth();
+        AutofillId[] autofillIds = autofillFields.getAutofillIds();
         if (responseAuth) {
             // If the entire Autofill Response is authenticated, AuthActivity is used
             // to generate Response.
             IntentSender sender = AuthActivity.getAuthIntentSenderForResponse(this);
             RemoteViews presentation = AutofillHelper
-                    .newRemoteViews(getPackageName(), getString(R.string.autofill_sign_in_prompt));
+                    .newRemoteViews(getPackageName(), getString(R.string.autofill_sign_in_prompt),
+                            R.drawable.ic_lock_black_24dp);
             responseBuilder
-                    .setAuthentication(autofillFields.getAutofillIds(), sender, presentation);
+                    .setAuthentication(autofillIds, sender, presentation);
             callback.onSuccess(responseBuilder.build());
         } else {
             boolean datasetAuth = MyPreferences.getInstance(this).isDatasetAuth();
             HashMap<String, FilledAutofillFieldCollection> clientFormDataMap =
-                    SharedPrefsAutofillRepository.getInstance(this).getClientFormData
+                    SharedPrefsAutofillRepository.getInstance(this).getFilledAutofillFieldCollection
                             (autofillFields.getFocusedHints(), autofillFields.getAllHints());
             FillResponse response = AutofillHelper.newResponse
                     (this, datasetAuth, autofillFields, clientFormDataMap);
@@ -99,7 +95,7 @@
         StructureParser parser = new StructureParser(structure);
         parser.parseForSave();
         FilledAutofillFieldCollection filledAutofillFieldCollection = parser.getClientFormData();
-        SharedPrefsAutofillRepository.getInstance(this).saveClientFormData(filledAutofillFieldCollection);
+        SharedPrefsAutofillRepository.getInstance(this).saveFilledAutofillFieldCollection(filledAutofillFieldCollection);
     }
 
     @Override
diff --git a/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/StructureParser.java b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/StructureParser.java
index e290881..5016e5b 100644
--- a/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/StructureParser.java
+++ b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/StructureParser.java
@@ -20,8 +20,8 @@
 import android.app.assist.AssistStructure.WindowNode;
 import android.util.Log;
 
-import com.example.android.autofillframework.multidatasetservice.model.FilledAutofillFieldCollection;
 import com.example.android.autofillframework.multidatasetservice.model.FilledAutofillField;
+import com.example.android.autofillframework.multidatasetservice.model.FilledAutofillFieldCollection;
 
 import static com.example.android.autofillframework.CommonUtil.TAG;
 
@@ -64,12 +64,11 @@
 
     private void parseLocked(boolean forFill, ViewNode viewNode) {
         if (viewNode.getAutofillHints() != null && viewNode.getAutofillHints().length > 0) {
-            //TODO check to make sure hints are supported by service.
             if (forFill) {
                 mAutofillFields.add(new AutofillFieldMetadata(viewNode));
             } else {
-                mFilledAutofillFieldCollection.setAutofillValuesForHints
-                        (viewNode.getAutofillHints(), new FilledAutofillField(viewNode));
+                mFilledAutofillFieldCollection.add
+                        (new FilledAutofillField(viewNode));
             }
         }
         int childrenSize = viewNode.getChildCount();
diff --git a/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/datasource/AutofillRepository.java b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/datasource/AutofillRepository.java
index 2296feb..7ee9555 100644
--- a/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/datasource/AutofillRepository.java
+++ b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/datasource/AutofillRepository.java
@@ -26,13 +26,13 @@
      * Gets saved FilledAutofillFieldCollection that contains some objects that can autofill fields with these
      * {@code autofillHints}.
      */
-    HashMap<String, FilledAutofillFieldCollection> getClientFormData(List<String> focusedAutofillHints,
+    HashMap<String, FilledAutofillFieldCollection> getFilledAutofillFieldCollection(List<String> focusedAutofillHints,
             List<String> allAutofillHints);
 
     /**
      * Saves LoginCredential under this datasetName.
      */
-    void saveClientFormData(FilledAutofillFieldCollection filledAutofillFieldCollection);
+    void saveFilledAutofillFieldCollection(FilledAutofillFieldCollection filledAutofillFieldCollection);
 
     /**
      * Clears all data.
diff --git a/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/datasource/SharedPrefsAutofillRepository.java b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/datasource/SharedPrefsAutofillRepository.java
index 31f9200..7b7ade9 100644
--- a/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/datasource/SharedPrefsAutofillRepository.java
+++ b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/datasource/SharedPrefsAutofillRepository.java
@@ -53,7 +53,7 @@
     }
 
     @Override
-    public HashMap<String, FilledAutofillFieldCollection> getClientFormData(List<String> focusedAutofillHints,
+    public HashMap<String, FilledAutofillFieldCollection> getFilledAutofillFieldCollection(List<String> focusedAutofillHints,
             List<String> allAutofillHints) {
         boolean hasDataForFocusedAutofillHints = false;
         HashMap<String, FilledAutofillFieldCollection> clientFormDataMap = new HashMap<>();
@@ -81,7 +81,7 @@
     }
 
     @Override
-    public void saveClientFormData(FilledAutofillFieldCollection filledAutofillFieldCollection) {
+    public void saveFilledAutofillFieldCollection(FilledAutofillFieldCollection filledAutofillFieldCollection) {
         String datasetName = "dataset-" + getDatasetNumber();
         filledAutofillFieldCollection.setDatasetName(datasetName);
         Set<String> allAutofillData = getAllAutofillDataStringSet();
diff --git a/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/model/FilledAutofillField.java b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/model/FilledAutofillField.java
index 3ca61d8..e7cda0e 100644
--- a/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/model/FilledAutofillField.java
+++ b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/model/FilledAutofillField.java
@@ -18,6 +18,8 @@
 import android.app.assist.AssistStructure;
 import android.view.autofill.AutofillValue;
 
+import com.example.android.autofillframework.multidatasetservice.AutofillHelper;
+
 /**
  * JSON serializable data class containing the same data as an {@link AutofillValue}.
  */
@@ -26,7 +28,13 @@
     private Long mDateValue = null;
     private Boolean mToggleValue = null;
 
+    /**
+     * Does not need to be serialized into persistent storage, so its marked {@code transient}.
+     */
+    private transient String[] mAutofillHints = null;
+
     public FilledAutofillField(AssistStructure.ViewNode viewNode) {
+        mAutofillHints = AutofillHelper.filterForSupportedHints(viewNode.getAutofillHints());
         AutofillValue autofillValue = viewNode.getAutofillValue();
         if (autofillValue != null) {
             if (autofillValue.isList()) {
@@ -45,6 +53,10 @@
         }
     }
 
+    public String[] getAutofillHints() {
+        return mAutofillHints;
+    }
+
     public String getTextValue() {
         return mTextValue;
     }
diff --git a/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/model/FilledAutofillFieldCollection.java b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/model/FilledAutofillFieldCollection.java
index 25f6826..9499134 100644
--- a/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/model/FilledAutofillFieldCollection.java
+++ b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/model/FilledAutofillFieldCollection.java
@@ -24,7 +24,6 @@
 
 import com.example.android.autofillframework.multidatasetservice.AutofillFieldMetadata;
 import com.example.android.autofillframework.multidatasetservice.AutofillFieldMetadataCollection;
-import com.example.android.autofillframework.multidatasetservice.AutofillHelper;
 
 import java.util.HashMap;
 import java.util.List;
@@ -63,21 +62,21 @@
     }
 
     /**
-     * Sets values for a list of hints.
+     * Adds a {@code FilledAutofillField} to the collection, indexed by all of its hints.
      */
-    public void setAutofillValuesForHints(@NonNull String[] autofillHints, @NonNull FilledAutofillField autofillValue) {
+    public void add(@NonNull FilledAutofillField filledAutofillField) {
+        String[] autofillHints = filledAutofillField.getAutofillHints();
         for (int i = 0; i < autofillHints.length; i++) {
-            if (AutofillHelper.isValidHint(autofillHints[i])) {
-                mHintMap.put(autofillHints[i], autofillValue);
-            } else {
-                Log.e(TAG, "Invalid hint: " + autofillHints[i]);
-            }
+            mHintMap.put(autofillHints[i], filledAutofillField);
         }
     }
 
     /**
      * Populates a {@link Dataset.Builder} with appropriate values for each {@link AutofillId}
-     * in a {@code AutofillFieldMetadataCollection}.
+     * in a {@code AutofillFieldMetadataCollection}. In other words, it constructs an autofill
+     * {@link Dataset.Builder} by applying saved values (from this {@code FilledAutofillFieldCollection})
+     * to Views specified in a {@code AutofillFieldMetadataCollection}, which represents the current
+     * page the user is on.
      */
     public boolean applyToFields(AutofillFieldMetadataCollection autofillFieldMetadataCollection,
             Dataset.Builder datasetBuilder) {
@@ -85,7 +84,8 @@
         List<String> allHints = autofillFieldMetadataCollection.getAllHints();
         for (int hintIndex = 0; hintIndex < allHints.size(); hintIndex++) {
             String hint = allHints.get(hintIndex);
-            List<AutofillFieldMetadata> fillableAutofillFields = autofillFieldMetadataCollection.getFieldsForHint(hint);
+            List<AutofillFieldMetadata> fillableAutofillFields =
+                    autofillFieldMetadataCollection.getFieldsForHint(hint);
             if (fillableAutofillFields == null) {
                 continue;
             }
@@ -136,10 +136,15 @@
         return setValueAtLeastOnce;
     }
 
+    /**
+     * @param autofillHints List of autofill hints, usually associated with a View or set of Views.
+     * @return whether any of the filled fields on the page have at least 1 autofillHint that is
+     * in the provided autofillHints.
+     */
     public boolean helpsWithHints(List<String> autofillHints) {
         for (int i = 0; i < autofillHints.size(); i++) {
             String autofillHint = autofillHints.get(i);
-            if (mHintMap.get(autofillHint) != null && !mHintMap.get(autofillHint).isNull()) {
+            if (mHintMap.containsKey(autofillHint) && !mHintMap.get(autofillHint).isNull()) {
                 return true;
             }
         }
diff --git a/input/autofill/AutofillFramework/Application/src/main/res/drawable/ic_lock_black_24dp.xml b/input/autofill/AutofillFramework/Application/src/main/res/drawable/ic_lock_black_24dp.xml
new file mode 100644
index 0000000..67a7c73
--- /dev/null
+++ b/input/autofill/AutofillFramework/Application/src/main/res/drawable/ic_lock_black_24dp.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+        android:width="24dp"
+        android:height="24dp"
+        android:viewportWidth="24.0"
+        android:viewportHeight="24.0">
+    <path
+        android:fillColor="#FF000000"
+        android:pathData="M18,8h-1L17,6c0,-2.76 -2.24,-5 -5,-5S7,3.24 7,6v2L6,8c-1.1,0 -2,0.9 -2,2v10c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L20,10c0,-1.1 -0.9,-2 -2,-2zM12,17c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2zM15.1,8L8.9,8L8.9,6c0,-1.71 1.39,-3.1 3.1,-3.1 1.71,0 3.1,1.39 3.1,3.1v2z"/>
+</vector>
diff --git a/input/autofill/AutofillFramework/Application/src/main/res/layout/login_activity.xml b/input/autofill/AutofillFramework/Application/src/main/res/layout/login_activity.xml
index 6382fe7..f9f5657 100644
--- a/input/autofill/AutofillFramework/Application/src/main/res/layout/login_activity.xml
+++ b/input/autofill/AutofillFramework/Application/src/main/res/layout/login_activity.xml
@@ -79,13 +79,13 @@
             android:id="@+id/clear"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:text="Clear" />
+            android:text="@string/clear_label" />
 
         <Button
             android:id="@+id/login"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:text="Login" />
+            android:text="@string/login_label" />
     </LinearLayout>
 
 </LinearLayout>
\ No newline at end of file
diff --git a/input/autofill/AutofillFramework/Application/src/main/res/layout/multidataset_service_auth_activity.xml b/input/autofill/AutofillFramework/Application/src/main/res/layout/multidataset_service_auth_activity.xml
index 0890af8..28c0e7f 100644
--- a/input/autofill/AutofillFramework/Application/src/main/res/layout/multidataset_service_auth_activity.xml
+++ b/input/autofill/AutofillFramework/Application/src/main/res/layout/multidataset_service_auth_activity.xml
@@ -1,5 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
  * Copyright (C) 2017 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,30 +14,29 @@
  * limitations under the License.
 -->
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-              xmlns:tools="http://schemas.android.com/tools"
-              android:id="@+id/authLayout"
-              android:layout_width="match_parent"
-              android:layout_height="match_parent"
-              android:orientation="vertical"
-              android:paddingBottom="@dimen/activity_vertical_margin"
-              android:paddingLeft="@dimen/activity_horizontal_margin"
-              android:paddingRight="@dimen/activity_horizontal_margin"
-              android:paddingTop="@dimen/activity_vertical_margin"
-              tools:context=".multidatasetservice.AuthActivity">
+    xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/authLayout"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:importantForAutofill="noExcludeDescendants"
+    android:orientation="vertical"
+    android:paddingBottom="@dimen/activity_vertical_margin"
+    android:paddingLeft="@dimen/activity_horizontal_margin"
+    android:paddingRight="@dimen/activity_horizontal_margin"
+    android:paddingTop="@dimen/activity_vertical_margin"
+    tools:context=".multidatasetservice.AuthActivity">
 
     <TextView
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_gravity="center_horizontal"
-        android:text="Master password">
-    </TextView>
+        android:text="@string/master_password_label"/>
 
     <EditText
         android:id="@+id/master_password"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:inputType="textPassword">
-    </EditText>
+        android:inputType="textPassword"/>
 
     <LinearLayout
         android:layout_width="match_parent"
@@ -50,13 +48,13 @@
             android:id="@+id/cancel"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:text="Cancel" />
+            android:text="@string/cancel" />
 
         <Button
             android:id="@+id/login"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:text="Login" />
+            android:text="@string/login_label" />
     </LinearLayout>
 
 </LinearLayout>
\ No newline at end of file
diff --git a/input/autofill/AutofillFramework/Application/src/main/res/layout/multidataset_service_list_item.xml b/input/autofill/AutofillFramework/Application/src/main/res/layout/multidataset_service_list_item.xml
index d01bc37..fe51953 100644
--- a/input/autofill/AutofillFramework/Application/src/main/res/layout/multidataset_service_list_item.xml
+++ b/input/autofill/AutofillFramework/Application/src/main/res/layout/multidataset_service_list_item.xml
@@ -1,5 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
  * Copyright (C) 2017 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,13 +13,26 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
 -->
-<TextView xmlns:android="http://schemas.android.com/apk/res/android"
-          android:id="@+id/text1"
-          android:layout_width="fill_parent"
-          android:layout_height="fill_parent"
-          android:background="#ffffffff"
-          android:gravity="center_vertical"
-          android:minHeight="?android:attr/listPreferredItemHeightSmall"
-          android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
-          android:paddingStart="?android:attr/listPreferredItemPaddingStart"
-          android:textAppearance="?android:attr/textAppearanceListItemSmall" />
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="horizontal">
+
+    <TextView
+        android:id="@+id/text"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:background="#ffffffff"
+        android:gravity="center_vertical"
+        android:minHeight="?android:attr/listPreferredItemHeightSmall"
+        android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+        android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+        android:textAppearance="?android:attr/textAppearanceListItemSmall" />
+
+    <ImageView
+        android:id="@+id/icon"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center"
+        android:src="@drawable/ic_person_black_24dp"/>
+</LinearLayout>
\ No newline at end of file
diff --git a/input/autofill/AutofillFramework/Application/src/main/res/layout/virtual_login_activity.xml b/input/autofill/AutofillFramework/Application/src/main/res/layout/virtual_login_activity.xml
index 59f56e1..bf746ae 100644
--- a/input/autofill/AutofillFramework/Application/src/main/res/layout/virtual_login_activity.xml
+++ b/input/autofill/AutofillFramework/Application/src/main/res/layout/virtual_login_activity.xml
@@ -37,12 +37,12 @@
             android:id="@+id/clear"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:text="Clear" />
+            android:text="@string/clear_label" />
 
         <Button
             android:id="@+id/login"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:text="Login" />
+            android:text="@string/login_label" />
     </LinearLayout>
 </LinearLayout>
diff --git a/input/autofill/AutofillFramework/Application/src/main/res/values/strings.xml b/input/autofill/AutofillFramework/Application/src/main/res/values/strings.xml
index ffb8495..69cd217 100644
--- a/input/autofill/AutofillFramework/Application/src/main/res/values/strings.xml
+++ b/input/autofill/AutofillFramework/Application/src/main/res/values/strings.xml
@@ -47,6 +47,9 @@
     <string name="settings_auth_enter_current_password">Enter current password</string>
     <string name="settings_auth_enter_new_password">Enter new password</string>
     <string name="settings_auth_change_credentials_title">Change credentials</string>
+    <string name="clear_label">Clear</string>
+    <string name="login_label">Login</string>
+    <string name="master_password_label">Master Password</string>
     <string-array name="month_array">
         <item>Jan</item>
         <item>Feb</item>
diff --git a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/AuthActivity.kt b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/AuthActivity.kt
index 4c1b5b7..eea1799 100644
--- a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/AuthActivity.kt
+++ b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/AuthActivity.kt
@@ -92,7 +92,7 @@
         val autofillFields = parser.autofillFields
         mReplyIntent = Intent()
         val clientFormDataMap = SharedPrefsAutofillRepository
-                .getClientFormData(this, autofillFields.focusedAutofillHints, autofillFields.allAutofillHints)
+                .getFilledAutofillFieldCollection(this, autofillFields.focusedAutofillHints, autofillFields.allAutofillHints)
         if (forResponse) {
             AutofillHelper.newResponse(this, false, autofillFields, clientFormDataMap)?.let(this::setResponseIntent)
         } else {
diff --git a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/AutofillFieldMetadata.kt b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/AutofillFieldMetadata.kt
index 47539df..f894a18 100644
--- a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/AutofillFieldMetadata.kt
+++ b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/AutofillFieldMetadata.kt
@@ -28,7 +28,7 @@
     var saveType = 0
         private set
 
-    val autofillHints: Array<String> = view.autofillHints
+    val autofillHints: Array<String> = view.autofillHints.filter(AutofillHelper::isValidHint).toTypedArray()
     val autofillId: AutofillId = view.autofillId
     val autofillType: Int = view.autofillType
     val autofillOptions: Array<CharSequence>? = view.autofillOptions
diff --git a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/AutofillHelper.kt b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/AutofillHelper.kt
index e8b5fb1..027d0f3 100644
--- a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/AutofillHelper.kt
+++ b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/AutofillHelper.kt
@@ -19,6 +19,7 @@
 import android.service.autofill.Dataset
 import android.service.autofill.FillResponse
 import android.service.autofill.SaveInfo
+import android.support.annotation.DrawableRes
 import android.util.Log
 import android.view.View
 import android.widget.RemoteViews
@@ -52,14 +53,21 @@
      * client View.
      */
     fun newDataset(context: Context, autofillFieldMetadata: AutofillFieldMetadataCollection,
-            filledAutofillFieldCollection: FilledAutofillFieldCollection, datasetAuth: Boolean): Dataset? {
+            filledAutofillFieldCollection: FilledAutofillFieldCollection,
+            datasetAuth: Boolean): Dataset? {
         filledAutofillFieldCollection.datasetName?.let { datasetName ->
-            val datasetBuilder = Dataset.Builder(newRemoteViews(context.packageName, datasetName))
-            val setValueAtLeastOnce = filledAutofillFieldCollection.applyToFields(autofillFieldMetadata, datasetBuilder)
+            val datasetBuilder: Dataset.Builder
             if (datasetAuth) {
+                datasetBuilder = Dataset.Builder(newRemoteViews(context.packageName, datasetName,
+                        R.drawable.ic_lock_black_24dp))
                 val sender = AuthActivity.getAuthIntentSenderForDataset(context, datasetName)
                 datasetBuilder.setAuthentication(sender)
+            } else {
+                datasetBuilder = Dataset.Builder(newRemoteViews(context.packageName, datasetName,
+                        R.drawable.ic_person_black_24dp))
             }
+            val setValueAtLeastOnce = filledAutofillFieldCollection
+                    .applyToFields(autofillFieldMetadata, datasetBuilder)
             if (setValueAtLeastOnce) {
                 return datasetBuilder.build()
             }
@@ -67,9 +75,11 @@
         return null
     }
 
-    fun newRemoteViews(packageName: String, remoteViewsText: String): RemoteViews {
+    fun newRemoteViews(packageName: String, remoteViewsText: String,
+            @DrawableRes drawableId: Int): RemoteViews {
         val presentation = RemoteViews(packageName, R.layout.multidataset_service_list_item)
-        presentation.setTextViewText(R.id.text1, remoteViewsText)
+        presentation.setTextViewText(R.id.text, remoteViewsText)
+        presentation.setImageViewResource(R.id.icon, drawableId)
         return presentation
     }
 
diff --git a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/MyAutofillService.kt b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/MyAutofillService.kt
index fa06924..ce2ce0d 100644
--- a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/MyAutofillService.kt
+++ b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/MyAutofillService.kt
@@ -36,14 +36,6 @@
         val structure = request.getFillContexts().get(request.getFillContexts().size - 1).structure
         val data = request.clientState
         Log.d(TAG, "onFillRequest(): data=" + bundleToString(data))
-
-        // Temporary hack for disabling autofill for components in this autofill service.
-        // i.e. we don't want to autofill components in AuthActivity.
-        if (structure.activityComponent.toShortString()
-                .contains("com.example.android.autofillframework.service")) {
-            callback.onSuccess(null)
-            return
-        }
         cancellationSignal.setOnCancelListener { Log.w(TAG, "Cancel autofill not implemented in this sample.") }
         // Parse AutoFill data in Activity
         val parser = StructureParser(structure)
@@ -58,13 +50,13 @@
             // to generate Response.
             val sender = AuthActivity.getAuthIntentSenderForResponse(this)
             val presentation = AutofillHelper
-                    .newRemoteViews(packageName, getString(R.string.autofill_sign_in_prompt))
+                    .newRemoteViews(packageName, getString(R.string.autofill_sign_in_prompt), R.drawable.ic_lock_black_24dp)
             responseBuilder
                     .setAuthentication(autofillFields.autofillIds.toTypedArray(), sender, presentation)
             callback.onSuccess(responseBuilder.build())
         } else {
             val datasetAuth = MyPreferences.isDatasetAuth(this)
-            val clientFormDataMap = SharedPrefsAutofillRepository.getClientFormData(this,
+            val clientFormDataMap = SharedPrefsAutofillRepository.getFilledAutofillFieldCollection(this,
                     autofillFields.focusedAutofillHints, autofillFields.allAutofillHints)
             val response = AutofillHelper.newResponse(this, datasetAuth, autofillFields, clientFormDataMap)
             callback.onSuccess(response)
@@ -78,7 +70,8 @@
         Log.d(TAG, "onSaveRequest(): data=" + bundleToString(data))
         val parser = StructureParser(structure)
         parser.parseForSave()
-        SharedPrefsAutofillRepository.saveClientFormData(this, parser.filledAutofillFieldCollection)
+        SharedPrefsAutofillRepository.saveFilledAutofillFieldCollection(this,
+                parser.filledAutofillFieldCollection)
     }
 
     override fun onConnected() {
diff --git a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/StructureParser.kt b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/StructureParser.kt
index 31b59c8..d1bbc9c 100644
--- a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/StructureParser.kt
+++ b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/StructureParser.kt
@@ -61,8 +61,7 @@
                 if (forFill) {
                     autofillFields.add(AutofillFieldMetadata(viewNode))
                 } else {
-                    filledAutofillFieldCollection.setAutofillValuesForHints(viewNode.autofillHints,
-                            FilledAutofillField(viewNode))
+                    filledAutofillFieldCollection.add(FilledAutofillField(viewNode))
                 }
             }
         }
diff --git a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/datasource/AutofillRepository.kt b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/datasource/AutofillRepository.kt
index 510d759..00a7d8d 100644
--- a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/datasource/AutofillRepository.kt
+++ b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/datasource/AutofillRepository.kt
@@ -25,13 +25,13 @@
      * Gets saved FilledAutofillFieldCollection that contains some objects that can autofill fields with these
      * `autofillHints`.
      */
-    fun getClientFormData(context: Context, focusedAutofillHints: List<String>,
+    fun getFilledAutofillFieldCollection(context: Context, focusedAutofillHints: List<String>,
             allAutofillHints: List<String>): HashMap<String, FilledAutofillFieldCollection>?
 
     /**
      * Saves LoginCredential under this datasetName.
      */
-    fun saveClientFormData(context: Context, filledAutofillFieldCollection: FilledAutofillFieldCollection)
+    fun saveFilledAutofillFieldCollection(context: Context, filledAutofillFieldCollection: FilledAutofillFieldCollection)
 
     /**
      * Clears all data.
diff --git a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/datasource/SharedPrefsAutofillRepository.kt b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/datasource/SharedPrefsAutofillRepository.kt
index e217170..9811915 100644
--- a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/datasource/SharedPrefsAutofillRepository.kt
+++ b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/datasource/SharedPrefsAutofillRepository.kt
@@ -20,6 +20,7 @@
 import android.util.ArraySet
 import com.example.android.autofillframework.multidatasetservice.model.FilledAutofillFieldCollection
 import com.google.gson.Gson
+import com.google.gson.GsonBuilder
 import com.google.gson.reflect.TypeToken
 
 
@@ -37,14 +38,15 @@
         return context.applicationContext.getSharedPreferences(SHARED_PREF_KEY, Context.MODE_PRIVATE)
     }
 
-    override fun getClientFormData(context: Context, focusedAutofillHints: List<String>,
+    override fun getFilledAutofillFieldCollection(context: Context, focusedAutofillHints: List<String>,
             allAutofillHints: List<String>): HashMap<String, FilledAutofillFieldCollection>? {
         var hasDataForFocusedAutofillHints = false
         val clientFormDataMap = HashMap<String, FilledAutofillFieldCollection>()
         val clientFormDataStringSet = getAllAutofillDataStringSet(context)
         for (clientFormDataString in clientFormDataStringSet) {
             val type = object : TypeToken<FilledAutofillFieldCollection>() {}.type
-            Gson().fromJson<FilledAutofillFieldCollection>(clientFormDataString, type)?.let { clientFormData ->
+            val gson: Gson = GsonBuilder().excludeFieldsWithoutExposeAnnotation().setPrettyPrinting().create()
+            gson.fromJson<FilledAutofillFieldCollection>(clientFormDataString, type)?.let { clientFormData ->
                 if (clientFormData.helpsWithHints(focusedAutofillHints)) {
                     // Saved data has data relevant to at least 1 of the hints associated with the
                     // View in focus.
@@ -66,11 +68,12 @@
         }
     }
 
-    override fun saveClientFormData(context: Context, filledAutofillFieldCollection: FilledAutofillFieldCollection) {
+    override fun saveFilledAutofillFieldCollection(context: Context, filledAutofillFieldCollection: FilledAutofillFieldCollection) {
         val datasetName = "dataset-" + getDatasetNumber(context)
         filledAutofillFieldCollection.datasetName = datasetName
         val allAutofillData = getAllAutofillDataStringSet(context)
-        allAutofillData.add(Gson().toJson(filledAutofillFieldCollection).toString())
+        val gson: Gson = GsonBuilder().excludeFieldsWithoutExposeAnnotation().setPrettyPrinting().create()
+        allAutofillData.add(gson.toJson(filledAutofillFieldCollection).toString())
         saveAllAutofillDataStringSet(context, allAutofillData)
         incrementDatasetNumber(context)
     }
diff --git a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/model/FilledAutofillField.kt b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/model/FilledAutofillField.kt
index fd2e176..64617cc 100644
--- a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/model/FilledAutofillField.kt
+++ b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/model/FilledAutofillField.kt
@@ -17,22 +17,32 @@
 
 import android.app.assist.AssistStructure
 import android.view.autofill.AutofillValue
+import com.example.android.autofillframework.multidatasetservice.AutofillHelper
+import com.google.gson.annotations.Expose
 
 /**
  * JSON serializable data class containing the same data as an [AutofillValue].
  */
 class FilledAutofillField(viewNode: AssistStructure.ViewNode) {
-    var textValue: CharSequence? = null
+    @Expose
+    var textValue: String? = null
+
+    @Expose
     var dateValue: Long? = null
+
+    @Expose
     var toggleValue: Boolean? = null
 
+    val autofillHints: Array<String> =
+            viewNode.autofillHints.filter(AutofillHelper::isValidHint).toTypedArray()
+
     init {
         viewNode.autofillValue?.let { autofillValue ->
             if (autofillValue.isList) {
                 val index = autofillValue.listValue
                 viewNode.autofillOptions?.let { autofillOptions ->
                     if (autofillOptions.size > index) {
-                        textValue = autofillOptions[index]
+                        textValue = autofillOptions[index].toString()
                     }
                 }
             } else if (autofillValue.isDate) {
diff --git a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/model/FilledAutofillFieldCollection.kt b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/model/FilledAutofillFieldCollection.kt
index 03e13ef..032e125 100644
--- a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/model/FilledAutofillFieldCollection.kt
+++ b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/model/FilledAutofillFieldCollection.kt
@@ -23,6 +23,7 @@
 import com.example.android.autofillframework.CommonUtil.TAG
 import com.example.android.autofillframework.multidatasetservice.AutofillFieldMetadataCollection
 import com.example.android.autofillframework.multidatasetservice.AutofillHelper
+import com.google.gson.annotations.Expose
 import java.util.HashMap
 
 
@@ -30,21 +31,24 @@
  * FilledAutofillFieldCollection is the model that represents all of the form data on a client app's page, plus the
  * dataset name associated with it.
  */
-class FilledAutofillFieldCollection constructor(var datasetName: String? = null,
-        private val hintMap: HashMap<String, FilledAutofillField> = HashMap<String, FilledAutofillField>()) {
+class FilledAutofillFieldCollection constructor(@Expose var datasetName: String? = null,
+        @Expose private val hintMap: HashMap<String, FilledAutofillField> = HashMap<String, FilledAutofillField>()) {
 
     /**
      * Sets values for a list of autofillHints.
      */
-    fun setAutofillValuesForHints(autofillHints: Array<String>, autofillField: FilledAutofillField) {
-        autofillHints.filter(AutofillHelper::isValidHint).forEach { autofillHint ->
+    fun add(autofillField: FilledAutofillField) {
+        autofillField.autofillHints.forEach { autofillHint ->
             hintMap[autofillHint] = autofillField
         }
     }
 
     /**
      * Populates a [Dataset.Builder] with appropriate values for each [AutofillId]
-     * in a `AutofillFieldMetadataCollection`.
+     * in a `AutofillFieldMetadataCollection`. In other words, it builds an Autofill dataset
+     * by applying saved values (from this `FilledAutofillFieldCollection`) to Views specified
+     * in a `AutofillFieldMetadataCollection`, which represents the current page the user is
+     * on.
      */
     fun applyToFields(autofillFieldMetadataCollection: AutofillFieldMetadataCollection,
             datasetBuilder: Dataset.Builder): Boolean {
@@ -88,8 +92,9 @@
     }
 
     /**
-     * Returns whether this model contains autofill data that is relevant to any of the
-     * autofillHints that are passed in.
+     * @param autofillHints List of autofill hints, usually associated with a View or set of Views.
+     * @return whether any of the filled fields on the page have at least 1 autofillHint that is
+     * in the provided autofillHints.
      */
     fun helpsWithHints(autofillHints: List<String>): Boolean {
         for (autofillHint in autofillHints) {
diff --git a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/drawable/ic_lock_black_24dp.xml b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/drawable/ic_lock_black_24dp.xml
new file mode 100644
index 0000000..67a7c73
--- /dev/null
+++ b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/drawable/ic_lock_black_24dp.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+        android:width="24dp"
+        android:height="24dp"
+        android:viewportWidth="24.0"
+        android:viewportHeight="24.0">
+    <path
+        android:fillColor="#FF000000"
+        android:pathData="M18,8h-1L17,6c0,-2.76 -2.24,-5 -5,-5S7,3.24 7,6v2L6,8c-1.1,0 -2,0.9 -2,2v10c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L20,10c0,-1.1 -0.9,-2 -2,-2zM12,17c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2zM15.1,8L8.9,8L8.9,6c0,-1.71 1.39,-3.1 3.1,-3.1 1.71,0 3.1,1.39 3.1,3.1v2z"/>
+</vector>
diff --git a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/layout/login_activity.xml b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/layout/login_activity.xml
index 6382fe7..f9f5657 100644
--- a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/layout/login_activity.xml
+++ b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/layout/login_activity.xml
@@ -79,13 +79,13 @@
             android:id="@+id/clear"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:text="Clear" />
+            android:text="@string/clear_label" />
 
         <Button
             android:id="@+id/login"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:text="Login" />
+            android:text="@string/login_label" />
     </LinearLayout>
 
 </LinearLayout>
\ No newline at end of file
diff --git a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/layout/multidataset_service_auth_activity.xml b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/layout/multidataset_service_auth_activity.xml
index 0890af8..029db19 100644
--- a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/layout/multidataset_service_auth_activity.xml
+++ b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/layout/multidataset_service_auth_activity.xml
@@ -1,5 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
  * Copyright (C) 2017 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,30 +14,29 @@
  * limitations under the License.
 -->
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-              xmlns:tools="http://schemas.android.com/tools"
-              android:id="@+id/authLayout"
-              android:layout_width="match_parent"
-              android:layout_height="match_parent"
-              android:orientation="vertical"
-              android:paddingBottom="@dimen/activity_vertical_margin"
-              android:paddingLeft="@dimen/activity_horizontal_margin"
-              android:paddingRight="@dimen/activity_horizontal_margin"
-              android:paddingTop="@dimen/activity_vertical_margin"
-              tools:context=".multidatasetservice.AuthActivity">
+    xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/authLayout"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:importantForAutofill="noExcludeDescendants"
+    android:orientation="vertical"
+    android:paddingBottom="@dimen/activity_vertical_margin"
+    android:paddingLeft="@dimen/activity_horizontal_margin"
+    android:paddingRight="@dimen/activity_horizontal_margin"
+    android:paddingTop="@dimen/activity_vertical_margin"
+    tools:context=".multidatasetservice.AuthActivity">
 
     <TextView
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_gravity="center_horizontal"
-        android:text="Master password">
-    </TextView>
+        android:text="@string/master_password_label" />
 
     <EditText
         android:id="@+id/master_password"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:inputType="textPassword">
-    </EditText>
+        android:inputType="textPassword" />
 
     <LinearLayout
         android:layout_width="match_parent"
@@ -50,13 +48,13 @@
             android:id="@+id/cancel"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:text="Cancel" />
+            android:text="@string/cancel" />
 
         <Button
             android:id="@+id/login"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:text="Login" />
+            android:text="@string/login_label" />
     </LinearLayout>
 
 </LinearLayout>
\ No newline at end of file
diff --git a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/layout/multidataset_service_list_item.xml b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/layout/multidataset_service_list_item.xml
index d01bc37..fe51953 100644
--- a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/layout/multidataset_service_list_item.xml
+++ b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/layout/multidataset_service_list_item.xml
@@ -1,5 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
  * Copyright (C) 2017 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,13 +13,26 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
 -->
-<TextView xmlns:android="http://schemas.android.com/apk/res/android"
-          android:id="@+id/text1"
-          android:layout_width="fill_parent"
-          android:layout_height="fill_parent"
-          android:background="#ffffffff"
-          android:gravity="center_vertical"
-          android:minHeight="?android:attr/listPreferredItemHeightSmall"
-          android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
-          android:paddingStart="?android:attr/listPreferredItemPaddingStart"
-          android:textAppearance="?android:attr/textAppearanceListItemSmall" />
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="horizontal">
+
+    <TextView
+        android:id="@+id/text"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:background="#ffffffff"
+        android:gravity="center_vertical"
+        android:minHeight="?android:attr/listPreferredItemHeightSmall"
+        android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+        android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+        android:textAppearance="?android:attr/textAppearanceListItemSmall" />
+
+    <ImageView
+        android:id="@+id/icon"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center"
+        android:src="@drawable/ic_person_black_24dp"/>
+</LinearLayout>
\ No newline at end of file
diff --git a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/layout/virtual_login_activity.xml b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/layout/virtual_login_activity.xml
index 59f56e1..2860008 100644
--- a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/layout/virtual_login_activity.xml
+++ b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/layout/virtual_login_activity.xml
@@ -15,10 +15,10 @@
  * limitations under the License.
 -->
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-              android:layout_width="match_parent"
-              android:layout_height="match_parent"
-              android:orientation="vertical"
-              android:weightSum="100">
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical"
+    android:weightSum="100">
 
     <com.example.android.autofillframework.app.CustomVirtualView
         android:id="@+id/custom_view"
@@ -37,12 +37,12 @@
             android:id="@+id/clear"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:text="Clear" />
+            android:text="@string/clear_label" />
 
         <Button
             android:id="@+id/login"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:text="Login" />
+            android:text="@string/login_label" />
     </LinearLayout>
-</LinearLayout>
+</LinearLayout>
\ No newline at end of file
diff --git a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/values/strings.xml b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/values/strings.xml
index ffb8495..2072d7b 100644
--- a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/values/strings.xml
+++ b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/values/strings.xml
@@ -47,6 +47,9 @@
     <string name="settings_auth_enter_current_password">Enter current password</string>
     <string name="settings_auth_enter_new_password">Enter new password</string>
     <string name="settings_auth_change_credentials_title">Change credentials</string>
+    <string name="clear_label">Clear</string>
+    <string name="login_label">Login</string>
+    <string name="master_password_label">Master Password</string>
     <string-array name="month_array">
         <item>Jan</item>
         <item>Feb</item>
@@ -111,4 +114,4 @@
         <item>user-2</item>
     </string-array>
 
-</resources>
+</resources>
\ No newline at end of file