Skip to content

Commit 48e138f

Browse files
SUPERCILEXsamtstern
authored andcommitted
Fix create account title not showing up (and cleanup strings) (#484)
1 parent a62f5ec commit 48e138f

File tree

13 files changed

+70
-76
lines changed

13 files changed

+70
-76
lines changed

app/src/main/java/com/firebase/uidemo/auth/AuthUiActivity.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,20 +313,20 @@ private String getSelectedTosUrl() {
313313
@MainThread
314314
private boolean isGoogleConfigured() {
315315
return !UNCHANGED_CONFIG_VALUE.equals(
316-
getResources().getString(R.string.default_web_client_id));
316+
getString(R.string.default_web_client_id));
317317
}
318318

319319
@MainThread
320320
private boolean isFacebookConfigured() {
321321
return !UNCHANGED_CONFIG_VALUE.equals(
322-
getResources().getString(R.string.facebook_application_id));
322+
getString(R.string.facebook_application_id));
323323
}
324324

325325
@MainThread
326326
private boolean isTwitterConfigured() {
327327
List<String> twitterConfigs = Arrays.asList(
328-
getResources().getString(R.string.twitter_consumer_key),
329-
getResources().getString(R.string.twitter_consumer_secret)
328+
getString(R.string.twitter_consumer_key),
329+
getString(R.string.twitter_consumer_secret)
330330
);
331331

332332
return !twitterConfigs.contains(UNCHANGED_CONFIG_VALUE);

auth/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
<activity
3636
android:name=".ui.email.RegisterEmailActivity"
37-
android:label="@string/title_check_email"
37+
android:label="@string/sign_in_default"
3838
android:exported="false"
3939
android:theme="@style/FirebaseUI"/>
4040

auth/src/main/java/com/firebase/ui/auth/ui/accountlink/WelcomeBackIdpPrompt.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ public void onClick(View view) {
113113
}
114114

115115
private String getIdpPromptString(String email) {
116-
return getResources().getString(R.string.welcome_back_idp_prompt,
117-
email,
118-
mIdpProvider.getName(this));
116+
return getString(R.string.welcome_back_idp_prompt, email, mIdpProvider.getName(this));
119117
}
120118

121119
@Override

auth/src/main/java/com/firebase/ui/auth/ui/accountlink/WelcomeBackPasswordPrompt.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ protected void onCreate(Bundle savedInstanceState) {
7979
mPasswordField = (EditText) findViewById(R.id.password);
8080

8181
// Create welcome back text with email bolded
82-
String bodyText = getResources().getString(R.string.welcome_back_password_prompt_body, mEmail);
82+
String bodyText = getString(R.string.welcome_back_password_prompt_body, mEmail);
8383
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(bodyText);
8484
int emailStart = bodyText.indexOf(mEmail);
8585
spannableStringBuilder.setSpan(new StyleSpan(Typeface.BOLD),

auth/src/main/java/com/firebase/ui/auth/ui/email/CheckEmailFragment.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,6 @@ public View onCreateView(LayoutInflater inflater,
114114
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
115115
super.onActivityCreated(savedInstanceState);
116116

117-
// Set title
118-
if (getActivity().getActionBar() != null) {
119-
getActivity().getActionBar().setTitle(R.string.title_check_email);
120-
}
121-
122117
// Set listener
123118
if (!(getActivity() instanceof CheckEmailListener)) {
124119
throw new IllegalStateException("Activity must implement CheckEmailListener");

auth/src/main/java/com/firebase/ui/auth/ui/email/RecoveryEmailSentDialog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class RecoveryEmailSentDialog extends DialogBase {
2020
@Override
2121
public Dialog onCreateDialog(Bundle savedInstanceState) {
2222
return new AlertDialog.Builder(getContext(), R.style.FirebaseUI_Dialog)
23-
.setTitle(R.string.title_confirm_recover_password_activity)
23+
.setTitle(R.string.title_confirm_recover_password)
2424
.setMessage(getString(R.string.confirm_recovery_body,
2525
getArguments().getString(ExtraConstants.EXTRA_EMAIL)))
2626
.setOnDismissListener(new DialogInterface.OnDismissListener() {

auth/src/main/java/com/firebase/ui/auth/ui/email/RegisterEmailFragment.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,7 @@ public void run() {
153153
@Override
154154
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
155155
super.onActivityCreated(savedInstanceState);
156-
// Set title
157-
if (getActivity().getActionBar() != null) {
158-
getActivity().getActionBar().setTitle(R.string.title_register_email_activity);
159-
}
156+
getActivity().setTitle(R.string.title_register_email);
160157

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

175172
private void setUpTermsOfService() {
176-
if (mHelper.getFlowParams().termsOfServiceUrl == null) {
173+
if (TextUtils.isEmpty(mHelper.getFlowParams().termsOfServiceUrl)) {
177174
return;
178175
}
176+
179177
ForegroundColorSpan foregroundColorSpan =
180178
new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.linkColor));
181179

182-
String preamble = getResources().getString(R.string.create_account_preamble);
183-
String link = getResources().getString(R.string.terms_of_service);
180+
String preamble = getString(R.string.create_account_preamble);
181+
String link = getString(R.string.terms_of_service);
184182
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(preamble + link);
185183
int start = preamble.length();
186184
spannableStringBuilder.setSpan(foregroundColorSpan, start, start + link.length(), 0);
@@ -277,7 +275,8 @@ public void onFailure(@NonNull Exception e) {
277275

278276
if (e instanceof FirebaseAuthWeakPasswordException) {
279277
// Password too weak
280-
mPasswordInput.setError(getString(R.string.error_weak_password));
278+
mPasswordInput.setError(getResources().getQuantityString(
279+
R.plurals.error_weak_password, R.integer.min_password_length));
281280
} else if (e instanceof FirebaseAuthInvalidCredentialsException) {
282281
// Email address is malformed
283282
mEmailInput.setError(getString(R.string.invalid_email_address));

auth/src/main/java/com/firebase/ui/auth/ui/email/fieldvalidators/EmailFieldValidator.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ public class EmailFieldValidator extends BaseValidator {
2323

2424
public EmailFieldValidator(TextInputLayout errorContainer) {
2525
super(errorContainer);
26-
mErrorMessage = mErrorContainer.getContext().getResources().getString(
27-
R.string.invalid_email_address);
26+
mErrorMessage = mErrorContainer.getResources().getString(R.string.invalid_email_address);
2827
mEmptyMessage = mErrorContainer.getResources().getString(R.string.missing_email_address);
2928
}
3029

auth/src/main/java/com/firebase/ui/auth/ui/email/fieldvalidators/PasswordFieldValidator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public PasswordFieldValidator(TextInputLayout errorContainer, int minLength) {
2525
super(errorContainer);
2626
mMinLength = minLength;
2727
mErrorMessage = mErrorContainer.getResources()
28-
.getQuantityString(R.plurals.password_length, minLength, mMinLength);
28+
.getQuantityString(R.plurals.error_weak_password, mMinLength, mMinLength);
2929
}
3030

3131
@Override

auth/src/main/java/com/firebase/ui/auth/ui/email/fieldvalidators/RequiredFieldValidator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
public class RequiredFieldValidator extends BaseValidator {
2222
public RequiredFieldValidator(TextInputLayout errorContainer) {
2323
super(errorContainer);
24-
mErrorMessage = mErrorContainer.getContext().getResources().getString(R.string.required_field);
24+
mErrorMessage = mErrorContainer.getResources().getString(R.string.required_field);
2525
}
2626

2727
@Override

auth/src/main/res/layout/welcome_back_password_prompt_layout.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
android:layout_width="match_parent"
1111
android:layout_height="wrap_content"
1212
style="@style/FirebaseUI.Text.Heading"
13-
android:text="@string/welcome_back"/>
13+
android:text="@string/welcome_back_email_header"/>
1414

1515
<TextView
1616
style="@style/FirebaseUI.Text.BodyText"

auth/src/main/res/values/strings.xml

Lines changed: 50 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,71 @@
11
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
22
<string name="app_name">ui_flow</string>
33

4+
<!-- Common -->
45
<string name="default_toolbar_title">@string/app_name</string>
5-
<string name="title_welcome_back_password_prompt">@string/sign_in_default</string>
6-
<string name="title_welcome_back_idp_prompt">@string/sign_in_default</string>
7-
<string name="title_check_email">@string/sign_in_default</string>
8-
<string name="title_register_email_activity">@string/create_account_title</string>
9-
<string name="title_recover_password_activity">@string/recover_password_title</string>
10-
<string name="title_confirm_recover_password_activity">@string/check_your_email</string>
6+
<string name="progress_dialog_loading">Loading…</string>
7+
<string name="sign_in_default">Sign in</string>
8+
<string name="general_error">An error has occurred.</string>
119

10+
<!-- Provider -->
11+
<string name="idp_name_google">Google</string>
12+
<string name="idp_name_facebook">Facebook</string>
13+
<string name="idp_name_twitter">Twitter</string>
14+
15+
<!-- Auth method picker -->
16+
<string name="sign_in_with_google">Sign in with Google</string>
17+
<string name="sign_in_with_facebook">Sign in with Facebook</string>
18+
<string name="sign_in_with_twitter">Sign in with Twitter</string>
19+
<string name="sign_in_with_email">Sign in with email</string>
20+
21+
<!-- Email common-->
22+
<string name="next_default">Next</string>
1223
<string name="email_hint">Email</string>
1324
<string name="password_hint">Password</string>
14-
<string name="name_hint">First &amp; last name</string>
15-
<string name="password_recovery_body">Get instructions sent to this email that explain how to
16-
reset your password.</string>
17-
<string name="create_account_title">Create account</string>
1825
<string name="required_field">You can\'t leave this empty.</string>
19-
<plurals name="password_length">
20-
<item quantity="one">Strong passwords have at least %1$d character and a mix of letters
21-
and numbers</item>
22-
<item quantity="other">Strong passwords have at least %1$d characters and a mix of letters
23-
and numbers</item>
24-
</plurals>
2526
<string name="invalid_email_address">That email address isn\'t correct</string>
2627
<string name="missing_email_address">Enter your email address to continue</string>
27-
<string name="error_weak_password">Password not strong enough. Use at least 6 characters and a mix of letters and numbers.</string>
28-
<string name="error_user_collision">An account already exists with that email address.</string>
29-
<string name="button_text_send">Send</string>
28+
<string name="progress_dialog_checking_accounts">Checking for existing accounts…</string>
29+
30+
<!-- Email sign up -->
31+
<string name="title_register_email">Sign up</string>
32+
<string name="name_hint">First &amp; last name</string>
3033
<string name="button_text_save">Save</string>
31-
<string name="confirm_recovery_body">Follow the instructions sent to %1$s to recover your
32-
password.</string>
33-
<string name="error_email_does_not_exist">That email address doesn\'t match an existing account</string>
34-
<string name="welcome_back">Welcome back!</string>
35-
<string name="trouble_signing_in">Trouble signing in?</string>
36-
<string name="next_default">Next</string>
37-
<string name="sign_in_default">Sign in</string>
38-
<string name="sign_in_with_google">Sign in with Google</string>
39-
<string name="sign_in_with_facebook">Sign in with Facebook</string>
40-
<string name="check_your_email">Check your email</string>
41-
<string name="recover_password_title">Recover password</string>
34+
<string name="progress_dialog_signing_up">Signing up…</string>
35+
<plurals name="error_weak_password">
36+
<item quantity="one">Password not strong enough. Use at least %1$d character and a mix of letters and numbers</item>
37+
<item quantity="other">Password not strong enough. Use at least %1$d characters and a mix of letters and numbers</item>
38+
</plurals>
39+
<string name="email_account_creation_error">Email account registration unsuccessful</string>
40+
<string name="error_user_collision">An account already exists with that email address.</string>
41+
<string name="create_account_preamble">"By tapping SAVE you are indicating that you agree to the "</string>
42+
<string name="terms_of_service">Terms of Service</string>
43+
44+
<!-- Idp/Email welcome back -->
45+
<string name="title_welcome_back_idp_prompt">@string/sign_in_default</string>
46+
<string name="title_welcome_back_password_prompt">@string/sign_in_default</string>
4247
<string name="welcome_back_idp_header">You already have an account</string>
48+
<string name="welcome_back_email_header">Welcome back!</string>
4349
<string name="welcome_back_idp_prompt">
4450
You\'ve already used <xliff:g id="email_addr" example="[email protected]">%1$s</xliff:g>.
4551
Sign in with <xliff:g id="provider_name" example="Google">%2$s</xliff:g> to continue.
4652
</string>
47-
<string name="welcome_back_password_prompt_body">You\'ve already used
48-
<xliff:g id="email_addr" example="[email protected]">%1$s</xliff:g> to sign in. Enter
49-
your password for that account.</string>
50-
<string name="idp_name_google">Google</string>
51-
<string name="idp_name_facebook">Facebook</string>
52-
<string name="idp_name_twitter">Twitter</string>
53-
<string name="create_account_preamble">"By tapping SAVE you are indicating that you agree to the "</string>
54-
<string name="terms_of_service">Terms of Service</string>
55-
<string name="sign_in_with_email">Sign in with email</string>
56-
<string name="sign_in_with_twitter">Sign in with Twitter</string>
57-
<string name="email_account_creation_error">Email account registration unsuccessful</string>
58-
<string name="general_error">An error has occurred.</string>
59-
53+
<string name="welcome_back_password_prompt_body">
54+
You\'ve already used <xliff:g id="email_addr" example="[email protected]">%1$s</xliff:g>
55+
to sign in. Enter your password for that account.
56+
</string>
57+
<string name="progress_dialog_signing_in">Signing in…</string>
58+
<string name="trouble_signing_in">Trouble signing in?</string>
6059

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

6770
<!-- accessibility -->
6871
<string name="accessibility_logo">App logo</string>

auth/src/test/java/com/firebase/ui/auth/ui/email/RegisterEmailActivityTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public void testSignUpButton_validatesFields() {
9393
assertEquals(
9494
String.format(
9595
registerEmailActivity.getResources().getQuantityString(
96-
R.plurals.password_length,
96+
R.plurals.error_weak_password,
9797
R.integer.min_password_length),
9898
registerEmailActivity.getResources()
9999
.getInteger(R.integer.min_password_length)

0 commit comments

Comments
 (0)