diff options
author | Douglas Sigelbaum <sigelbaum@google.com> | 2017-06-07 16:12:11 -0400 |
---|---|---|
committer | Douglas Sigelbaum <sigelbaum@google.com> | 2017-06-22 10:54:31 -0700 |
commit | bb55ff972cb9708b875bebcbd3ceef4f283c2ae6 (patch) | |
tree | 7cf8e7307435c3e0abc552752ef3e416045acd25 /input/autofill/AutofillFramework/kotlinApp/Application | |
parent | 7c931def08ecff434a0b12e2dca6f38336a340bc (diff) | |
download | android-bb55ff972cb9708b875bebcbd3ceef4f283c2ae6.tar.gz |
Check autofillHints to make sure autofillHint is supported by service.
Bug: 38182790
Test: manual
Change-Id: I5b55445a0a1432d15a34b360f5e7e7713e13eeb8
Diffstat (limited to 'input/autofill/AutofillFramework/kotlinApp/Application')
3 files changed, 43 insertions, 5 deletions
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 d3e07ce2..4c1b5b72 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 @@ -24,6 +24,7 @@ import android.content.IntentSender import android.os.Bundle import android.service.autofill.Dataset import android.service.autofill.FillResponse +import android.support.v7.app.AppCompatActivity import android.util.Log import android.view.autofill.AutofillManager.EXTRA_ASSIST_STRUCTURE import android.view.autofill.AutofillManager.EXTRA_AUTHENTICATION_RESULT @@ -43,7 +44,7 @@ import kotlinx.android.synthetic.main.multidataset_service_auth_activity.master_ * It is launched when an Autofill Response or specific Dataset within the Response requires * authentication to access. It bundles the result in an Intent. */ -class AuthActivity : Activity() { +class AuthActivity : AppCompatActivity() { private var mReplyIntent: Intent? = null 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 394f620f..e8b5fb1e 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 @@ -20,11 +20,27 @@ import android.service.autofill.Dataset import android.service.autofill.FillResponse import android.service.autofill.SaveInfo import android.util.Log +import android.view.View import android.widget.RemoteViews import com.example.android.autofillframework.CommonUtil.TAG import com.example.android.autofillframework.R import com.example.android.autofillframework.multidatasetservice.model.FilledAutofillFieldCollection import java.util.HashMap +import android.view.View.AUTOFILL_HINT_USERNAME +import android.view.View.AUTOFILL_HINT_POSTAL_CODE +import android.view.View.AUTOFILL_HINT_POSTAL_ADDRESS +import android.view.View.AUTOFILL_HINT_PASSWORD +import android.view.View.AUTOFILL_HINT_NAME +import android.view.View.AUTOFILL_HINT_PHONE +import android.view.View.AUTOFILL_HINT_EMAIL_ADDRESS +import android.view.View.AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE +import android.view.View.AUTOFILL_HINT_CREDIT_CARD_NUMBER +import android.view.View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR +import android.view.View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH +import android.view.View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY +import android.view.View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE + + /** * This is a class containing helper methods for building Autofill Datasets and Responses. @@ -83,4 +99,25 @@ object AutofillHelper { return null } } + + fun isValidHint(hint: String): Boolean { + when (hint) { + View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE, + View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY, + View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH, + View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR, + View.AUTOFILL_HINT_CREDIT_CARD_NUMBER, + View.AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE, + View.AUTOFILL_HINT_EMAIL_ADDRESS, + View.AUTOFILL_HINT_PHONE, + View.AUTOFILL_HINT_NAME, + View.AUTOFILL_HINT_PASSWORD, + View.AUTOFILL_HINT_POSTAL_ADDRESS, + View.AUTOFILL_HINT_POSTAL_CODE, + View.AUTOFILL_HINT_USERNAME -> + return true + else -> + return false + } + } }
\ No newline at end of file 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 1adf1dcc..03e13ef5 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 @@ -20,7 +20,9 @@ import android.util.Log import android.view.View import android.view.autofill.AutofillId import android.view.autofill.AutofillValue +import com.example.android.autofillframework.CommonUtil.TAG import com.example.android.autofillframework.multidatasetservice.AutofillFieldMetadataCollection +import com.example.android.autofillframework.multidatasetservice.AutofillHelper import java.util.HashMap @@ -31,14 +33,12 @@ import java.util.HashMap class FilledAutofillFieldCollection constructor(var datasetName: String? = null, private val hintMap: HashMap<String, FilledAutofillField> = HashMap<String, FilledAutofillField>()) { - private val TAG = "FilledAutofillFieldCollection" - /** * Sets values for a list of autofillHints. */ fun setAutofillValuesForHints(autofillHints: Array<String>, autofillField: FilledAutofillField) { - autofillHints.forEach { hint -> - hintMap[hint] = autofillField + autofillHints.filter(AutofillHelper::isValidHint).forEach { autofillHint -> + hintMap[autofillHint] = autofillField } } |