Skip to content

Fix create account title not showing up (and cleanup strings) #484

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jan 3, 2017
Original file line number Diff line number Diff line change
Expand Up @@ -313,20 +313,20 @@ private String getSelectedTosUrl() {
@MainThread
private boolean isGoogleConfigured() {
return !UNCHANGED_CONFIG_VALUE.equals(
getResources().getString(R.string.default_web_client_id));
getString(R.string.default_web_client_id));
}

@MainThread
private boolean isFacebookConfigured() {
return !UNCHANGED_CONFIG_VALUE.equals(
getResources().getString(R.string.facebook_application_id));
getString(R.string.facebook_application_id));
}

@MainThread
private boolean isTwitterConfigured() {
List<String> twitterConfigs = Arrays.asList(
getResources().getString(R.string.twitter_consumer_key),
getResources().getString(R.string.twitter_consumer_secret)
getString(R.string.twitter_consumer_key),
getString(R.string.twitter_consumer_secret)
);

return !twitterConfigs.contains(UNCHANGED_CONFIG_VALUE);
Expand Down
2 changes: 1 addition & 1 deletion auth/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

<activity
android:name=".ui.email.RegisterEmailActivity"
android:label="@string/title_check_email"
android:label="@string/sign_in_default"
android:exported="false"
android:theme="@style/FirebaseUI"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,7 @@ public void onClick(View view) {
}

private String getIdpPromptString(String email) {
return getResources().getString(R.string.welcome_back_idp_prompt,
email,
mIdpProvider.getName(this));
return getString(R.string.welcome_back_idp_prompt, email, mIdpProvider.getName(this));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected void onCreate(Bundle savedInstanceState) {
mPasswordField = (EditText) findViewById(R.id.password);

// Create welcome back text with email bolded
String bodyText = getResources().getString(R.string.welcome_back_password_prompt_body, mEmail);
String bodyText = getString(R.string.welcome_back_password_prompt_body, mEmail);
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(bodyText);
int emailStart = bodyText.indexOf(mEmail);
spannableStringBuilder.setSpan(new StyleSpan(Typeface.BOLD),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,6 @@ public View onCreateView(LayoutInflater inflater,
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);

// Set title
if (getActivity().getActionBar() != null) {
getActivity().getActionBar().setTitle(R.string.title_check_email);
}

// Set listener
if (!(getActivity() instanceof CheckEmailListener)) {
throw new IllegalStateException("Activity must implement CheckEmailListener");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class RecoveryEmailSentDialog extends DialogBase {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new AlertDialog.Builder(getContext(), R.style.FirebaseUI_Dialog)
.setTitle(R.string.title_confirm_recover_password_activity)
.setTitle(R.string.title_confirm_recover_password)
.setMessage(getString(R.string.confirm_recovery_body,
getArguments().getString(ExtraConstants.EXTRA_EMAIL)))
.setOnDismissListener(new DialogInterface.OnDismissListener() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,7 @@ public void run() {
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
// Set title
if (getActivity().getActionBar() != null) {
getActivity().getActionBar().setTitle(R.string.title_register_email_activity);
}
getActivity().setTitle(R.string.title_register_email);

mSaveSmartLock = mHelper.getSaveSmartLockInstance(getActivity());
setUpTermsOfService();
Expand All @@ -173,14 +170,15 @@ public void onSaveInstanceState(Bundle outState) {
}

private void setUpTermsOfService() {
if (mHelper.getFlowParams().termsOfServiceUrl == null) {
if (TextUtils.isEmpty(mHelper.getFlowParams().termsOfServiceUrl)) {
return;
}

ForegroundColorSpan foregroundColorSpan =
new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.linkColor));

String preamble = getResources().getString(R.string.create_account_preamble);
String link = getResources().getString(R.string.terms_of_service);
String preamble = getString(R.string.create_account_preamble);
String link = getString(R.string.terms_of_service);
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(preamble + link);
int start = preamble.length();
spannableStringBuilder.setSpan(foregroundColorSpan, start, start + link.length(), 0);
Expand Down Expand Up @@ -277,7 +275,8 @@ public void onFailure(@NonNull Exception e) {

if (e instanceof FirebaseAuthWeakPasswordException) {
// Password too weak
mPasswordInput.setError(getString(R.string.error_weak_password));
mPasswordInput.setError(getResources().getQuantityString(
R.plurals.error_weak_password, R.integer.min_password_length));
} else if (e instanceof FirebaseAuthInvalidCredentialsException) {
// Email address is malformed
mEmailInput.setError(getString(R.string.invalid_email_address));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ public class EmailFieldValidator extends BaseValidator {

public EmailFieldValidator(TextInputLayout errorContainer) {
super(errorContainer);
mErrorMessage = mErrorContainer.getContext().getResources().getString(
R.string.invalid_email_address);
mErrorMessage = mErrorContainer.getResources().getString(R.string.invalid_email_address);
mEmptyMessage = mErrorContainer.getResources().getString(R.string.missing_email_address);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public PasswordFieldValidator(TextInputLayout errorContainer, int minLength) {
super(errorContainer);
mMinLength = minLength;
mErrorMessage = mErrorContainer.getResources()
.getQuantityString(R.plurals.password_length, minLength, mMinLength);
.getQuantityString(R.plurals.error_weak_password, mMinLength, mMinLength);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
public class RequiredFieldValidator extends BaseValidator {
public RequiredFieldValidator(TextInputLayout errorContainer) {
super(errorContainer);
mErrorMessage = mErrorContainer.getContext().getResources().getString(R.string.required_field);
mErrorMessage = mErrorContainer.getResources().getString(R.string.required_field);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/FirebaseUI.Text.Heading"
android:text="@string/welcome_back"/>
android:text="@string/welcome_back_email_header"/>

<TextView
style="@style/FirebaseUI.Text.BodyText"
Expand Down
97 changes: 50 additions & 47 deletions auth/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,68 +1,71 @@
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_name">ui_flow</string>

<!-- Common -->
<string name="default_toolbar_title">@string/app_name</string>
<string name="title_welcome_back_password_prompt">@string/sign_in_default</string>
<string name="title_welcome_back_idp_prompt">@string/sign_in_default</string>
<string name="title_check_email">@string/sign_in_default</string>
<string name="title_register_email_activity">@string/create_account_title</string>
<string name="title_recover_password_activity">@string/recover_password_title</string>
<string name="title_confirm_recover_password_activity">@string/check_your_email</string>
<string name="progress_dialog_loading">Loading…</string>
<string name="sign_in_default">Sign in</string>
<string name="general_error">An error has occurred.</string>

<!-- Provider -->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While these title_ strings are not part of the public API, I know there are some devs that do override them. We seem to have changed title_confirm_recover_password_activity to title_confirm_recover_password here, can we undo that just to keep the resource name as long as we can? Or is there a reason for the change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant to change it to title_confirm_recover_password_dialog because it's used in the dialog:

return new AlertDialog.Builder(getContext(), R.style.FirebaseUI_Dialog)
                .setTitle(R.string.title_confirm_recover_password)

@samtstern Would you like me to change it back to title_confirm_recover_password_activity or to title_confirm_recover_password_dialog?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah if was never used as an Activity title it's fine as-is.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was an activity in the dark ages before #357 (comment). I just never changed the string name...

<string name="idp_name_google">Google</string>
<string name="idp_name_facebook">Facebook</string>
<string name="idp_name_twitter">Twitter</string>

<!-- Auth method picker -->
<string name="sign_in_with_google">Sign in with Google</string>
<string name="sign_in_with_facebook">Sign in with Facebook</string>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this to "Sign up" to be more consistent with our progress dialog.

<string name="sign_in_with_twitter">Sign in with Twitter</string>
<string name="sign_in_with_email">Sign in with email</string>

<!-- Email common-->
<string name="next_default">Next</string>
<string name="email_hint">Email</string>
<string name="password_hint">Password</string>
<string name="name_hint">First &amp; last name</string>
<string name="password_recovery_body">Get instructions sent to this email that explain how to
reset your password.</string>
<string name="create_account_title">Create account</string>
<string name="required_field">You can\'t leave this empty.</string>
<plurals name="password_length">
<item quantity="one">Strong passwords have at least %1$d character and a mix of letters
and numbers</item>
<item quantity="other">Strong passwords have at least %1$d characters and a mix of letters
and numbers</item>
</plurals>
<string name="invalid_email_address">That email address isn\'t correct</string>
<string name="missing_email_address">Enter your email address to continue</string>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got rid of this; using the plural instead.

<string name="error_weak_password">Password not strong enough. Use at least 6 characters and a mix of letters and numbers.</string>
<string name="error_user_collision">An account already exists with that email address.</string>
<string name="button_text_send">Send</string>
<string name="progress_dialog_checking_accounts">Checking for existing accounts…</string>

<!-- Email sign up -->
<string name="title_register_email">Sign up</string>
<string name="name_hint">First &amp; last name</string>
<string name="button_text_save">Save</string>
<string name="confirm_recovery_body">Follow the instructions sent to %1$s to recover your
password.</string>
<string name="error_email_does_not_exist">That email address doesn\'t match an existing account</string>
<string name="welcome_back">Welcome back!</string>
<string name="trouble_signing_in">Trouble signing in?</string>
<string name="next_default">Next</string>
<string name="sign_in_default">Sign in</string>
<string name="sign_in_with_google">Sign in with Google</string>
<string name="sign_in_with_facebook">Sign in with Facebook</string>
<string name="check_your_email">Check your email</string>
<string name="recover_password_title">Recover password</string>
<string name="progress_dialog_signing_up">Signing up…</string>
<plurals name="error_weak_password">
<item quantity="one">Password not strong enough. Use at least %1$d character and a mix of letters and numbers</item>
<item quantity="other">Password not strong enough. Use at least %1$d characters and a mix of letters and numbers</item>
</plurals>
<string name="email_account_creation_error">Email account registration unsuccessful</string>
<string name="error_user_collision">An account already exists with that email address.</string>
<string name="create_account_preamble">"By tapping SAVE you are indicating that you agree to the "</string>
<string name="terms_of_service">Terms of Service</string>

<!-- Idp/Email welcome back -->
<string name="title_welcome_back_idp_prompt">@string/sign_in_default</string>
<string name="title_welcome_back_password_prompt">@string/sign_in_default</string>
<string name="welcome_back_idp_header">You already have an account</string>
<string name="welcome_back_email_header">Welcome back!</string>
<string name="welcome_back_idp_prompt">
You\'ve already used <xliff:g id="email_addr" example="[email protected]">%1$s</xliff:g>.
Sign in with <xliff:g id="provider_name" example="Google">%2$s</xliff:g> to continue.
</string>
<string name="welcome_back_password_prompt_body">You\'ve already used
<xliff:g id="email_addr" example="[email protected]">%1$s</xliff:g> to sign in. Enter
your password for that account.</string>
<string name="idp_name_google">Google</string>
<string name="idp_name_facebook">Facebook</string>
<string name="idp_name_twitter">Twitter</string>
<string name="create_account_preamble">"By tapping SAVE you are indicating that you agree to the "</string>
<string name="terms_of_service">Terms of Service</string>
<string name="sign_in_with_email">Sign in with email</string>
<string name="sign_in_with_twitter">Sign in with Twitter</string>
<string name="email_account_creation_error">Email account registration unsuccessful</string>
<string name="general_error">An error has occurred.</string>

<string name="welcome_back_password_prompt_body">
You\'ve already used <xliff:g id="email_addr" example="[email protected]">%1$s</xliff:g>
to sign in. Enter your password for that account.
</string>
<string name="progress_dialog_signing_in">Signing in…</string>
<string name="trouble_signing_in">Trouble signing in?</string>

<string name="progress_dialog_loading">Loading…</string>
<!-- Password recovery -->
<string name="title_recover_password_activity">Recover password</string>
<string name="title_confirm_recover_password">Check your email</string>
<string name="password_recovery_body">Get instructions sent to this email that explain how to
reset your password.</string>
<string name="button_text_send">Send</string>
<string name="confirm_recovery_body">Follow the instructions sent to %1$s to recover your password.</string>
<string name="progress_dialog_sending">Sending…</string>
<string name="progress_dialog_signing_in">Signing in…</string>
<string name="progress_dialog_signing_up">Signing up…</string>
<string name="progress_dialog_checking_accounts">Checking for existing accounts…</string>
<string name="error_email_does_not_exist">That email address doesn\'t match an existing account</string>

<!-- accessibility -->
<string name="accessibility_logo">App logo</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void testSignUpButton_validatesFields() {
assertEquals(
String.format(
registerEmailActivity.getResources().getQuantityString(
R.plurals.password_length,
R.plurals.error_weak_password,
R.integer.min_password_length),
registerEmailActivity.getResources()
.getInteger(R.integer.min_password_length)
Expand Down