-->

Can I change the sign in-hints modal title (from &

2019-08-13 06:26发布

问题:

A possible flow within Smart Lock integration leads to a 'Choose an Account' modal for a new user. Selecting an account on this pop-up pre-fills the sign up page but the user does have to subsequently enter a new password to create an account. I find 'Choose an Account' header to be misleading since it leads a user to believe that they have an account on the app already. Is it possible to change the header of this modal to say something else - maybe something more intuitive like 'Prefill sign up form with:'?

回答1:

I'm the product manager for Smart Lock at Google. We added some functionality to support this in the 8.3 release of Play Services APIs (November 2015).

In the past the "hint" dialog to allow the user to pick an email address with one tap to sign in or sign up had the title "Choose an Account", which, as noted in the question, caused some user confusion. In 8.3, we changed the default text to be "Sign in with" and allowed customization by the calling app to "Sign up with". Complete customization of the dialog text is not possible since it is rendered by Play Services and must be localized, but in UX research we found that "Sign up with" had the same user acceptance and completion as "Prefill sign up form with" and other variants but gave the developer more latitude in the scenarios where the dialog could be used. (aside: in testing, we found most users don't read the text at the top of the dialog at all!)

Sample code: build a CredentialPickerConfig with setForNewAccount(true) for account creation and supply this to setHintPickerConfig() when building a HintRequest for the getHintPickerIntent() method added to the Auth.CredentialsApi in Play Services 8.3.

import com.google.android.gms.auth.api.Auth;
import com.google.android.gms.auth.api.credentials.CredentialPickerConfig;
import com.google.android.gms.auth.api.credentials.HintRequest;

CredentialPickerConfig selectorConfig = new CredentialPickerConfig.Builder()
        .setForNewAccount(true).build();
HintRequest hintRequest = new HintRequest.Builder()
        .setHintPickerConfig(selectorConfig).build();
PendingIntent intent = Auth.CredentialsApi.getHintPickerIntent(apiClient, hintRequest);
try {
    startIntentSenderForResult(intent.getIntentSender(), RESOLVE_HINT, null, 0, 0, 0);
} catch (IntentSender.SendIntentException e) {
    Log.e(TAG, "Intent failure", e);
}

Check out the sample code on Github for details on setting up the apiClient and integrating the rest of the API. Leave a comment if you have questions or feedback.

https://github.com/googlesamples/android-credentials