diff options
author | Douglas Sigelbaum <sigelbaum@google.com> | 2017-06-12 12:40:48 -0700 |
---|---|---|
committer | Douglas Sigelbaum <sigelbaum@google.com> | 2017-09-13 15:30:33 -0700 |
commit | 955607a220516c3333f1b5f7e31d4f974ebb5948 (patch) | |
tree | 60ac6ef82e16979cb3c146d93a7d2f7888d5bb0a /input/autofill | |
parent | 1807a3e988c8eb4e26f1f4e76010cf4bac5684ec (diff) | |
download | android-955607a220516c3333f1b5f7e31d4f974ebb5948.tar.gz |
Showcase autofill in webviews.
Bug: 38182790
Test: manual
Change-Id: Iad970ced29cd82dd22f79d30afa1a16f0834f904
Diffstat (limited to 'input/autofill')
14 files changed, 454 insertions, 31 deletions
diff --git a/input/autofill/AutofillFramework/Application/src/main/AndroidManifest.xml b/input/autofill/AutofillFramework/Application/src/main/AndroidManifest.xml index 8ea7960a..2bef2c8a 100644 --- a/input/autofill/AutofillFramework/Application/src/main/AndroidManifest.xml +++ b/input/autofill/AutofillFramework/Application/src/main/AndroidManifest.xml @@ -13,7 +13,6 @@ See the License for the specific language governing permissions and limitations under the License. --> - <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.android.autofillframework" android:versionCode="1" @@ -30,6 +29,7 @@ android:taskAffinity=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> @@ -59,6 +59,9 @@ android:name=".app.MultiplePartitionsActivity" android:taskAffinity=".MultiplePartitionsActivity" android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> + <activity + android:name=".app.WebViewSignInActivity" + android:taskAffinity=".WebViewSignInActivity" /> <!-- Including launcher icon for Autofill Settings to convenience. Not necessary for a real service. @@ -70,6 +73,7 @@ android:taskAffinity=".SettingsActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> @@ -95,4 +99,4 @@ <activity android:name=".multidatasetservice.AuthActivity" /> </application> -</manifest>
\ No newline at end of file +</manifest> diff --git a/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/app/MainActivity.java b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/app/MainActivity.java index 9ad2e5c4..b8f8f94d 100644 --- a/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/app/MainActivity.java +++ b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/app/MainActivity.java @@ -49,6 +49,7 @@ public class MainActivity extends AppCompatActivity { NavigationItem creditCardCompoundView = findViewById(R.id.creditCardCompoundViewButton); NavigationItem creditCardDatePicker = findViewById(R.id.creditCardDatePickerButton); NavigationItem mulitplePartitions = findViewById(R.id.multiplePartitionsButton); + NavigationItem loginWebView = findViewById(R.id.webviewSignInButton); loginEditTexts.setNavigationButtonClickListener(new View.OnClickListener() { @Override public void onClick(View view) { @@ -97,6 +98,12 @@ public class MainActivity extends AppCompatActivity { startActivity(MultiplePartitionsActivity.getStartActivityIntent(MainActivity.this)); } }); + loginWebView.setNavigationButtonClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + startActivity(WebViewSignInActivity.getStartActivityIntent(MainActivity.this)); + } + }); } private boolean launchTrampolineActivity() { diff --git a/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/app/WebViewSignInActivity.java b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/app/WebViewSignInActivity.java new file mode 100644 index 00000000..f5f5c55c --- /dev/null +++ b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/app/WebViewSignInActivity.java @@ -0,0 +1,46 @@ +/* +* Copyright (C) 2017 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package com.example.android.autofillframework.app; + +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.view.autofill.AutofillManager; +import android.webkit.WebResourceRequest; +import android.webkit.WebView; +import android.webkit.WebViewClient; + +import com.example.android.autofillframework.R; + +public class WebViewSignInActivity extends AppCompatActivity { + + public static Intent getStartActivityIntent(Context context) { + Intent intent = new Intent(context, WebViewSignInActivity.class); + return intent; + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + setContentView(R.layout.login_webview_activity); + + WebView webView = findViewById(R.id.webview); + webView.setWebViewClient(new WebViewClient()); + webView.loadUrl("file:///android_res/raw/sample_form.html"); + } +}
\ No newline at end of file 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 8f83c22e..a0de246a 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 @@ -92,27 +92,58 @@ public class AutofillFieldMetadata { case View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR: case View.AUTOFILL_HINT_CREDIT_CARD_NUMBER: case View.AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE: + case W3cHints.CC_NAME: + case W3cHints.CC_GIVEN_NAME: + case W3cHints.CC_ADDITIONAL_NAME: + case W3cHints.CC_FAMILY_NAME: + case W3cHints.CC_NUMBER: + case W3cHints.CC_EXPIRATION: + case W3cHints.CC_EXPIRATION_MONTH: + case W3cHints.CC_EXPIRATION_YEAR: + case W3cHints.CC_CSC: + case W3cHints.CC_TYPE: + case W3cHints.TRANSACTION_CURRENCY: + case W3cHints.TRANSACTION_AMOUNT: mSaveType |= SaveInfo.SAVE_DATA_TYPE_CREDIT_CARD; break; case View.AUTOFILL_HINT_EMAIL_ADDRESS: + case W3cHints.EMAIL: mSaveType |= SaveInfo.SAVE_DATA_TYPE_EMAIL_ADDRESS; break; - case View.AUTOFILL_HINT_PHONE: - case View.AUTOFILL_HINT_NAME: - mSaveType |= SaveInfo.SAVE_DATA_TYPE_GENERIC; - break; case View.AUTOFILL_HINT_PASSWORD: + case W3cHints.NEW_PASSWORD: + case W3cHints.CURRENT_PASSWORD: mSaveType |= SaveInfo.SAVE_DATA_TYPE_PASSWORD; mSaveType &= ~SaveInfo.SAVE_DATA_TYPE_EMAIL_ADDRESS; mSaveType &= ~SaveInfo.SAVE_DATA_TYPE_USERNAME; break; case View.AUTOFILL_HINT_POSTAL_ADDRESS: case View.AUTOFILL_HINT_POSTAL_CODE: + case W3cHints.STREET_ADDRESS: + case W3cHints.ADDRESS_LINE1: + case W3cHints.ADDRESS_LINE2: + case W3cHints.ADDRESS_LINE3: + case W3cHints.ADDRESS_LEVEL4: + case W3cHints.ADDRESS_LEVEL3: + case W3cHints.ADDRESS_LEVEL2: + case W3cHints.ADDRESS_LEVEL1: + case W3cHints.COUNTRY: + case W3cHints.COUNTRY_NAME: + case W3cHints.POSTAL_CODE: mSaveType |= SaveInfo.SAVE_DATA_TYPE_ADDRESS; break; + case View.AUTOFILL_HINT_NAME: + case View.AUTOFILL_HINT_PHONE: case View.AUTOFILL_HINT_USERNAME: + case W3cHints.HONORIFIC_PREFIX: + case W3cHints.GIVEN_NAME: + case W3cHints.ADDITIONAL_NAME: + case W3cHints.FAMILY_NAME: + case W3cHints.HONORIFIC_SUFFIX: mSaveType |= SaveInfo.SAVE_DATA_TYPE_USERNAME; break; + default: + mSaveType |= SaveInfo.SAVE_DATA_TYPE_GENERIC; } } } 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 1e76f6ee..b6632a11 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 @@ -136,6 +136,56 @@ public final class AutofillHelper { case View.AUTOFILL_HINT_POSTAL_ADDRESS: case View.AUTOFILL_HINT_POSTAL_CODE: case View.AUTOFILL_HINT_USERNAME: + case W3cHints.HONORIFIC_PREFIX: + case W3cHints.GIVEN_NAME: + case W3cHints.ADDITIONAL_NAME: + case W3cHints.FAMILY_NAME: + case W3cHints.HONORIFIC_SUFFIX: + case W3cHints.NEW_PASSWORD: + case W3cHints.CURRENT_PASSWORD: + case W3cHints.ORGANIZATION_TITLE: + case W3cHints.ORGANIZATION: + case W3cHints.STREET_ADDRESS: + case W3cHints.ADDRESS_LINE1: + case W3cHints.ADDRESS_LINE2: + case W3cHints.ADDRESS_LINE3: + case W3cHints.ADDRESS_LEVEL4: + case W3cHints.ADDRESS_LEVEL3: + case W3cHints.ADDRESS_LEVEL2: + case W3cHints.ADDRESS_LEVEL1: + case W3cHints.COUNTRY: + case W3cHints.COUNTRY_NAME: + case W3cHints.POSTAL_CODE: + case W3cHints.CC_NAME: + case W3cHints.CC_GIVEN_NAME: + case W3cHints.CC_ADDITIONAL_NAME: + case W3cHints.CC_FAMILY_NAME: + case W3cHints.CC_NUMBER: + case W3cHints.CC_EXPIRATION: + case W3cHints.CC_EXPIRATION_MONTH: + case W3cHints.CC_EXPIRATION_YEAR: + case W3cHints.CC_CSC: + case W3cHints.CC_TYPE: + case W3cHints.TRANSACTION_CURRENCY: + case W3cHints.TRANSACTION_AMOUNT: + case W3cHints.LANGUAGE: + case W3cHints.BDAY: + case W3cHints.BDAY_DAY: + case W3cHints.BDAY_MONTH: + case W3cHints.BDAY_YEAR: + case W3cHints.SEX: + case W3cHints.URL: + case W3cHints.PHOTO: + case W3cHints.TEL: + case W3cHints.TEL_COUNTRY_CODE: + case W3cHints.TEL_NATIONAL: + case W3cHints.TEL_AREA_CODE: + case W3cHints.TEL_LOCAL: + case W3cHints.TEL_LOCAL_PREFIX: + case W3cHints.TEL_LOCAL_SUFFIX: + case W3cHints.TEL_EXTENSION: + case W3cHints.EMAIL: + case W3cHints.IMPP: return true; default: return false; diff --git a/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/W3cHints.java b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/W3cHints.java new file mode 100644 index 00000000..0065ff74 --- /dev/null +++ b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/multidatasetservice/W3cHints.java @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.example.android.autofillframework.multidatasetservice; + +public final class W3cHints { + + private W3cHints() {} + + // Supported W3C autofill tokens (https://html.spec.whatwg.org/multipage/forms.html#autofill) + public static final String HONORIFIC_PREFIX = "honorific-prefix"; + public static final String NAME = "name"; // same as View.AUTOFILL_HINT_NAME + public static final String GIVEN_NAME = "given-name"; + public static final String ADDITIONAL_NAME = "additional-name"; + public static final String FAMILY_NAME = "family-name"; + public static final String HONORIFIC_SUFFIX = "honorific-suffix"; + public static final String USERNAME = "username"; // same as View.AUTOFILL_HINT_USERNAME + public static final String NEW_PASSWORD = "new-password"; + public static final String CURRENT_PASSWORD = "current-password"; + public static final String ORGANIZATION_TITLE = "organization-title"; + public static final String ORGANIZATION = "organization"; + public static final String STREET_ADDRESS = "street-address"; + public static final String ADDRESS_LINE1 = "address-line1"; + public static final String ADDRESS_LINE2 = "address-line2"; + public static final String ADDRESS_LINE3 = "address-line3"; + public static final String ADDRESS_LEVEL4 = "address-level4"; + public static final String ADDRESS_LEVEL3 = "address-level3"; + public static final String ADDRESS_LEVEL2 = "address-level2"; + public static final String ADDRESS_LEVEL1 = "address-level1"; + public static final String COUNTRY = "country"; + public static final String COUNTRY_NAME = "country-name"; + public static final String POSTAL_CODE = "postal-code"; + public static final String CC_NAME = "cc-name"; + public static final String CC_GIVEN_NAME = "cc-given-name"; + public static final String CC_ADDITIONAL_NAME = "cc-additional-name"; + public static final String CC_FAMILY_NAME = "cc-family-name"; + public static final String CC_NUMBER = "cc-number"; + public static final String CC_EXPIRATION = "cc-exp"; + public static final String CC_EXPIRATION_MONTH = "cc-exp-month"; + public static final String CC_EXPIRATION_YEAR = "cc-exp-year"; + public static final String CC_CSC = "cc-csc"; + public static final String CC_TYPE = "cc-type"; + public static final String TRANSACTION_CURRENCY = "transaction-currency"; + public static final String TRANSACTION_AMOUNT = "transaction-amount"; + public static final String LANGUAGE = "language"; + public static final String BDAY = "bday"; + public static final String BDAY_DAY = "bday-day"; + public static final String BDAY_MONTH = "bday-month"; + public static final String BDAY_YEAR = "bday-year"; + public static final String SEX = "sex"; + public static final String URL = "url"; + public static final String PHOTO = "photo"; + + // Optional W3C prefixes + public static final String PREFIX_SECTION = "section-"; + public static final String SHIPPING = "shipping"; + public static final String BILLING = "billing"; + + // W3C prefixes below... + public static final String PREFIX_HOME = "home"; + public static final String PREFIX_WORK = "work"; + public static final String PREFIX_FAX = "fax"; + public static final String PREFIX_PAGER = "pager"; + // ... require those suffix + public static final String TEL = "tel"; + public static final String TEL_COUNTRY_CODE = "tel-country-code"; + public static final String TEL_NATIONAL = "tel-national"; + public static final String TEL_AREA_CODE = "tel-area-code"; + public static final String TEL_LOCAL = "tel-local"; + public static final String TEL_LOCAL_PREFIX = "tel-local-prefix"; + public static final String TEL_LOCAL_SUFFIX = "tel-local-suffix"; + public static final String TEL_EXTENSION = "tel_extension"; + public static final String EMAIL = "email"; + public static final String IMPP = "impp"; +}
\ No newline at end of file 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 d50af538..cc37c14c 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 @@ -25,10 +25,13 @@ import android.view.autofill.AutofillValue; import com.example.android.autofillframework.multidatasetservice.AutofillFieldMetadata; import com.example.android.autofillframework.multidatasetservice.AutofillFieldMetadataCollection; import com.google.gson.annotations.Expose; +import com.example.android.autofillframework.multidatasetservice.AutofillHelper; +import com.example.android.autofillframework.multidatasetservice.W3cHints; import java.util.HashMap; import java.util.List; +import static com.example.android.autofillframework.CommonUtil.DEBUG; import static com.example.android.autofillframework.CommonUtil.TAG; /** @@ -50,6 +53,48 @@ public final class FilledAutofillFieldCollection { mDatasetName = datasetName; } + private static boolean isW3cSectionPrefix(String hint) { + return hint.startsWith(W3cHints.PREFIX_SECTION); + } + + private static boolean isW3cAddressType(String hint) { + switch (hint) { + case W3cHints.SHIPPING: + case W3cHints.BILLING: + return true; + } + return false; + } + + private static boolean isW3cTypePrefix(String hint) { + switch (hint) { + case W3cHints.PREFIX_WORK: + case W3cHints.PREFIX_FAX: + case W3cHints.PREFIX_HOME: + case W3cHints.PREFIX_PAGER: + return true; + } + return false; + } + + private static boolean isW3cTypeHint(String hint) { + switch (hint) { + case W3cHints.TEL: + case W3cHints.TEL_COUNTRY_CODE: + case W3cHints.TEL_NATIONAL: + case W3cHints.TEL_AREA_CODE: + case W3cHints.TEL_LOCAL: + case W3cHints.TEL_LOCAL_PREFIX: + case W3cHints.TEL_LOCAL_SUFFIX: + case W3cHints.TEL_EXTENSION: + case W3cHints.EMAIL: + case W3cHints.IMPP: + return true; + } + Log.w(TAG, "Invalid W3C type hint: " + hint); + return false; + } + /** * Returns the name of the {@link Dataset}. */ @@ -69,8 +114,72 @@ public final class FilledAutofillFieldCollection { */ public void add(@NonNull FilledAutofillField filledAutofillField) { String[] autofillHints = filledAutofillField.getAutofillHints(); - for (String hint : autofillHints) { - mHintMap.put(hint, filledAutofillField); + String nextHint = null; + for (int i = 0; i < autofillHints.length; i++) { + String hint = autofillHints[i]; + if (i < autofillHints.length - 1) { + nextHint = autofillHints[i + 1]; + } + // First convert the compound W3C autofill hints + if (isW3cSectionPrefix(hint) && i < autofillHints.length - 1) { + hint = autofillHints[++i]; + if (DEBUG) Log.d(TAG, "Hint is a W3C section prefix; using " + hint + " instead"); + if (i < autofillHints.length - 1) { + nextHint = autofillHints[i + 1]; + } + } + if (isW3cTypePrefix(hint) && nextHint != null && isW3cTypeHint(nextHint)) { + hint = nextHint; + i++; + if (DEBUG) Log.d(TAG, "Hint is a W3C type prefix; using " + hint + " instead"); + } + if (isW3cAddressType(hint) && nextHint != null) { + hint = nextHint; + i++; + if (DEBUG) Log.d(TAG, "Hint is a W3C address prefix; using " + hint + " instead"); + } + + // Then check if the "actual" hint is supported. + + + if (AutofillHelper.isValidHint(hint)) { + mHintMap.put(transformHint(hint), filledAutofillField); + } else { + Log.e(TAG, "Invalid hint: " + autofillHints[i]); + } + } + } + + public String transformHint(String hint) { + switch (hint) { + case W3cHints.NEW_PASSWORD: + case W3cHints.CURRENT_PASSWORD: + return View.AUTOFILL_HINT_PASSWORD; + case W3cHints.STREET_ADDRESS: + return View.AUTOFILL_HINT_POSTAL_ADDRESS; + case W3cHints.POSTAL_CODE: + return View.AUTOFILL_HINT_POSTAL_CODE; + case W3cHints.CC_NAME: + case W3cHints.GIVEN_NAME: + case W3cHints.CC_GIVEN_NAME: + return View.AUTOFILL_HINT_NAME; + case W3cHints.CC_ADDITIONAL_NAME: + case W3cHints.CC_NUMBER: + return View.AUTOFILL_HINT_CREDIT_CARD_NUMBER; + case W3cHints.CC_EXPIRATION: + return View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE; + case W3cHints.CC_EXPIRATION_MONTH: + return View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH; + case W3cHints.CC_EXPIRATION_YEAR: + return View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR; + case W3cHints.CC_CSC: + return View.AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE; + case W3cHints.TEL: + return View.AUTOFILL_HINT_PHONE; + case W3cHints.EMAIL: + return View.AUTOFILL_HINT_EMAIL_ADDRESS; + default: + return hint; } } diff --git a/input/autofill/AutofillFramework/Application/src/main/res/drawable/ic_web_black_24dp.xml b/input/autofill/AutofillFramework/Application/src/main/res/drawable/ic_web_black_24dp.xml new file mode 100644 index 00000000..48e7b7ba --- /dev/null +++ b/input/autofill/AutofillFramework/Application/src/main/res/drawable/ic_web_black_24dp.xml @@ -0,0 +1,24 @@ +<!-- + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<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="M20,4L4,4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2zM15,18L4,18v-4h11v4zM15,13L4,13L4,9h11v4zM20,18h-4L16,9h4v9z"/> +</vector> diff --git a/input/autofill/AutofillFramework/Application/src/main/res/layout/activity_main.xml b/input/autofill/AutofillFramework/Application/src/main/res/layout/activity_main.xml index 34ca9b2b..557259f6 100644 --- a/input/autofill/AutofillFramework/Application/src/main/res/layout/activity_main.xml +++ b/input/autofill/AutofillFramework/Application/src/main/res/layout/activity_main.xml @@ -14,9 +14,9 @@ * limitations under the License. --> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - android:layout_width="match_parent" - android:layout_height="match_parent"> + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" @@ -31,37 +31,46 @@ android:id="@+id/standardViewSignInButton" android:layout_width="match_parent" android:layout_height="wrap_content" + app:imageColor="@android:color/holo_red_dark" app:infoText="@string/edittext_login_info" - app:labelText="@string/navigation_button_edittext_login_label" app:itemLogo="@drawable/ic_edittexts_logo_24dp" - app:imageColor="@android:color/holo_red_dark" /> + app:labelText="@string/navigation_button_edittext_login_label" /> <com.example.android.autofillframework.app.NavigationItem android:id="@+id/standardLoginWithAutoCompleteButton" android:layout_width="match_parent" android:layout_height="wrap_content" + app:imageColor="@android:color/holo_blue_dark" app:infoText="@string/autocomplete_login_info" - app:labelText="@string/navigation_button_autocomplete_login_label" app:itemLogo="@drawable/ic_autocomplete_logo_24dp" - app:imageColor="@android:color/holo_blue_dark"/> + app:labelText="@string/navigation_button_autocomplete_login_label" /> <com.example.android.autofillframework.app.NavigationItem android:id="@+id/virtualViewSignInButton" android:layout_width="match_parent" android:layout_height="wrap_content" + app:imageColor="@android:color/holo_green_dark" app:infoText="@string/custom_virtual_login_info" - app:labelText="@string/navigation_button_custom_virtual_view_login_label" app:itemLogo="@drawable/ic_custom_virtual_logo_24dp" - app:imageColor="@android:color/holo_green_dark"/> + app:labelText="@string/navigation_button_custom_virtual_view_login_label" /> + + <com.example.android.autofillframework.app.NavigationItem + android:id="@+id/webviewSignInButton" + android:layout_width="match_parent" + android:layout_height="wrap_content" + app:imageColor="@android:color/holo_green_dark" + app:infoText="@string/webview_login_info" + app:itemLogo="@drawable/ic_web_black_24dp" + app:labelText="@string/navigation_button_web_view_login_label" /> <com.example.android.autofillframework.app.NavigationItem android:id="@+id/creditCardCheckoutButton" android:layout_width="match_parent" android:layout_height="wrap_content" + app:imageColor="@android:color/holo_orange_dark" app:infoText="@string/spinners_credit_card_info" - app:labelText="@string/navigation_button_spinners_credit_card_label" app:itemLogo="@drawable/ic_spinners_logo_24dp" - app:imageColor="@android:color/holo_orange_dark"/> + app:labelText="@string/navigation_button_spinners_credit_card_label" /> <com.example.android.autofillframework.app.NavigationItem android:id="@+id/creditCardCompoundViewButton" @@ -85,10 +94,10 @@ android:id="@+id/emailComposeButton" android:layout_width="match_parent" android:layout_height="wrap_content" + app:imageColor="@android:color/holo_purple" app:infoText="@string/email_compose_info" - app:labelText="@string/navigation_button_email_compose_label" app:itemLogo="@drawable/ic_email_black_24dp" - app:imageColor="@android:color/holo_purple"/> + app:labelText="@string/navigation_button_email_compose_label" /> <com.example.android.autofillframework.app.NavigationItem android:id="@+id/multiplePartitionsButton" diff --git a/input/autofill/AutofillFramework/Application/src/main/res/layout/login_webview_activity.xml b/input/autofill/AutofillFramework/Application/src/main/res/layout/login_webview_activity.xml new file mode 100644 index 00000000..abbd1f46 --- /dev/null +++ b/input/autofill/AutofillFramework/Application/src/main/res/layout/login_webview_activity.xml @@ -0,0 +1,19 @@ +<?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"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<WebView xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/webview" + android:layout_width="match_parent" + android:layout_height="match_parent" />
\ No newline at end of file diff --git a/input/autofill/AutofillFramework/Application/src/main/res/raw/sample_form.html b/input/autofill/AutofillFramework/Application/src/main/res/raw/sample_form.html new file mode 100644 index 00000000..2a26223c --- /dev/null +++ b/input/autofill/AutofillFramework/Application/src/main/res/raw/sample_form.html @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<!-- + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<html> +<body> +<form> + Username: <input type='text' name='username' autocomplete='username'/><br/><br/> + Password: <input type='password' name='password' autocomplete='current-password'/><br/><br/> + Work email: <input type='text' name='email' autocomplete='work email'/><br/><br/> + Shipping address1: <input type='text' name='address' + autocomplete='section-whatever shipping address-line1'/><br/> + Shipping address2: <input type='text' name='address' + autocomplete='shipping address-line2'/><br/> + Shipping address3: <input type='text' name='address' + autocomplete='section-whatever address-line3'/><br/><br/> + <input type='submit' value='Login'/><br/> +</form> +</body> +</html>
\ No newline at end of file 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 16a87813..4961104d 100644 --- a/input/autofill/AutofillFramework/Application/src/main/res/values/strings.xml +++ b/input/autofill/AutofillFramework/Application/src/main/res/values/strings.xml @@ -26,6 +26,7 @@ <string name="navigation_button_compound_view_credit_card_label">Sample Credit Card Check Out Using Compound Views</string> <string name="navigation_button_date_picker_credit_card_label">Sample Credit Card Check Out Using Date Picker</string> <string name="navigation_button_multiple_partitions_label">Sample Page with Multiple Data Partitions</string> + <string name="navigation_button_web_view_login_label">Sample Login Using a WebView</string> <string name="username_label">Username</string> <string name="password_label">Password</string> <string name="welcome_text">Success!</string> @@ -76,10 +77,10 @@ interfere with the Autofill dialogs, so it is necessary to implement the AutofillCallback to disable AutoComplete when Autofill is working. </string> - <string name="custom_virtual_login_info">This is a sample login page that uses a custom View with - virtual children. Since the Autofill framework does not know how to autofill the virtual - children out of the box, it is necessary implement certain Autofill-specific methods and - interface directly with AutofillManager. + <string name="custom_virtual_login_info">This is a sample login page that uses a custom View + with virtual children. Since the Autofill framework does not know how to autofill the + virtual children out of the box, it is necessary implement certain Autofill-specific methods + and interface directly with AutofillManager. </string> <string name="spinners_credit_card_info">This is a sample credit card checkout page that uses EditTexts and Spinners to input data into the form. While EditTexts are optimized out of the @@ -96,10 +97,15 @@ did the latter. </string> <string name="compound_view_credit_card_info"> - This is a sample credit card checkout page that uses a custom compound View to input the credit - card\'s expiration date and an EditText to input the credit card number. While the EditText is - optimized out of the box for autofill, this example shows how to implement certain Autofill- - specific methods and XML properties for the custom compound view. + This is a sample credit card checkout page that uses a custom compound View to input the + credit card\'s expiration date and an EditText to input the credit card number. While the + EditText is optimized out of the box for autofill, this example shows how to implement + certain Autofill-specific methods and XML properties for the custom compound view. + </string> + <string name="webview_login_info"> + This is a sample login page that uses a WebView to control the UI. The HTML on the web page + uses standard W3C autofill hints that the autofill service recognizes. No extra code is + needed other than these hints. </string> <string name="date_picker_credit_card_info"> This is a sample credit card checkout page that uses a custom EditText and a DatePicker 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 5a370190..46b5349b 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 @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="UTF-8"?> <!-- * Copyright (C) 2017 The Android Open Source Project * diff --git a/input/autofill/AutofillFramework/settings.gradle b/input/autofill/AutofillFramework/settings.gradle index 0a5c310b..9464a359 100644 --- a/input/autofill/AutofillFramework/settings.gradle +++ b/input/autofill/AutofillFramework/settings.gradle @@ -1,2 +1 @@ - include 'Application' |