Skip to content

Commit 58c5f02

Browse files
author
Aaron Mandle
committed
Update error strings to match spreadsheet.
Change-Id: I901c8d8132d93582f30ee1589080bb3f882fa452
1 parent f9fd1db commit 58c5f02

File tree

2 files changed

+60
-25
lines changed

2 files changed

+60
-25
lines changed

auth/src/main/java/com/firebase/ui/auth/ui/phone/PhoneVerificationActivity.java

Lines changed: 53 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ public class PhoneVerificationActivity extends AppCompatBase {
5757
static final long AUTO_RETRIEVAL_TIMEOUT_MILLIS = 90000;
5858
static final String ERROR_INVALID_PHONE = "ERROR_INVALID_PHONE_NUMBER";
5959
static final String ERROR_INVALID_VERIFICATION = "ERROR_INVALID_VERIFICATION_CODE";
60+
static final String ERROR_TOO_MANY_REQUESTS = "ERROR_TOO_MANY_REQUESTS";
61+
static final String ERROR_QUOTA_EXCEEDED = "ERROR_QUOTA_EXCEEDED";
62+
static final String ERROR_SESSION_EXPIRED = "ERROR_SESSION_EXPIRED";
6063
static final String KEY_VERIFICATION_PHONE = "KEY_VERIFICATION_PHONE";
6164
static final String KEY_STATE = "KEY_STATE";
6265

@@ -197,15 +200,26 @@ void onVerificationFailed(@NonNull FirebaseException ex) {
197200
if (verifyPhoneNumberFragment == null) {
198201
return;
199202
}
200-
201-
if (ex instanceof FirebaseAuthException && ((FirebaseAuthException) ex).getErrorCode() ==
202-
ERROR_INVALID_PHONE) {
203-
verifyPhoneNumberFragment.showError(getString(R.string.invalid_phone_number));
204-
dismissLoadingDialog();
205-
} else {
206-
Log.w(PHONE_VERIFICATION_LOG_TAG, ex.getLocalizedMessage());
207-
dismissLoadingDialog();
208-
showAlertDialog(ex.getLocalizedMessage(), null);
203+
if (ex instanceof FirebaseAuthException) {
204+
FirebaseAuthException firebaseAuthException = (FirebaseAuthException) ex;
205+
switch (firebaseAuthException.getErrorCode()) {
206+
case ERROR_INVALID_PHONE:
207+
verifyPhoneNumberFragment.showError(getString(R.string.invalid_phone_number));
208+
dismissLoadingDialog();
209+
break;
210+
case ERROR_TOO_MANY_REQUESTS:
211+
showAlertDialog(getString(R.string.error_too_many_attempts), null);
212+
dismissLoadingDialog();
213+
break;
214+
case ERROR_QUOTA_EXCEEDED:
215+
showAlertDialog(getString(R.string.error_quota_exceeded), null);
216+
dismissLoadingDialog();
217+
break;
218+
default:
219+
Log.w(PHONE_VERIFICATION_LOG_TAG, ex.getLocalizedMessage());
220+
dismissLoadingDialog();
221+
showAlertDialog(ex.getLocalizedMessage(), null);
222+
}
209223
}
210224
}
211225

@@ -306,19 +320,35 @@ public void run() {
306320
public void onFailure(@NonNull Exception e) {
307321
dismissLoadingDialog();
308322
//incorrect confirmation code
309-
if (e instanceof FirebaseAuthInvalidCredentialsException && (
310-
(FirebaseAuthInvalidCredentialsException) e).getErrorCode() ==
311-
ERROR_INVALID_VERIFICATION) {
312-
showAlertDialog(getString(R.string.incorrect_code_dialog_body), new
313-
DialogInterface.OnClickListener() {
314-
@Override
315-
public void onClick(DialogInterface dialog, int which) {
316-
SubmitConfirmationCodeFragment f = getSubmitConfirmationCodeFragment();
317-
f.setConfirmationCode("");
318-
}
319-
});
320-
} else {
321-
showAlertDialog(e.getLocalizedMessage(), null);
323+
if (e instanceof FirebaseAuthInvalidCredentialsException) {
324+
FirebaseAuthInvalidCredentialsException firebaseAuthInvalidCredentialsException
325+
= (FirebaseAuthInvalidCredentialsException) e;
326+
switch (firebaseAuthInvalidCredentialsException.getErrorCode()) {
327+
case ERROR_INVALID_VERIFICATION:
328+
showAlertDialog(getString(R.string.incorrect_code_dialog_body), new
329+
DialogInterface.OnClickListener() {
330+
@Override
331+
public void onClick(DialogInterface dialog, int which) {
332+
SubmitConfirmationCodeFragment f
333+
= getSubmitConfirmationCodeFragment();
334+
f.setConfirmationCode("");
335+
}
336+
});
337+
break;
338+
case ERROR_SESSION_EXPIRED:
339+
showAlertDialog(getString(R.string.error_session_expired), new
340+
DialogInterface.OnClickListener() {
341+
@Override
342+
public void onClick(DialogInterface dialog, int which) {
343+
SubmitConfirmationCodeFragment f
344+
= getSubmitConfirmationCodeFragment();
345+
f.setConfirmationCode("");
346+
}
347+
});
348+
break;
349+
default:
350+
showAlertDialog(e.getLocalizedMessage(), null);
351+
}
322352
}
323353
}
324354
});
@@ -354,4 +384,4 @@ private SubmitConfirmationCodeFragment getSubmitConfirmationCodeFragment() {
354384
return (SubmitConfirmationCodeFragment) getSupportFragmentManager().findFragmentByTag
355385
(SubmitConfirmationCodeFragment.TAG);
356386
}
357-
}
387+
}

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,20 @@
8282
<!-- accessibility -->
8383
<string name="accessibility_logo" translation_description="Content description for app logo">App logo</string>
8484
<string name="signed_in_with_specific_account" translation_description="Post signin message showing method of authentication">Signed in as <xliff:g id="email_addr" example="[email protected]" translation_description="">%1$s</xliff:g></string>
85+
86+
<!-- phone number auth -->
8587
<string name="verify_phone_number_title" translation_description="Phone number entry form title">Enter your phone number</string>
86-
<string name="invalid_phone_number" translation_description="Inline error when phone number entered is invalid">Invalid phone format</string>
88+
<string name="invalid_phone_number" translation_description="Inline error when phone number entered is invalid">Enter a valid phone number.</string>
8789
<string name="enter_confirmation_code" translation_description="Phone number verification code entry form title">Enter the 6-digit code we sent to</string>
8890
<string name="resend_code_in" translation_description="Countdown timer text that the user needs to wait for before attempting to resend verification sms">Resend code in 0:%02d</string>
8991
<string name="verify_your_phone_title" translation_description="Button text to complete phone number verification">Verify your phone number</string>
9092
<string name="verifying" translation_description="Progress dialog text while phone number is being verified">Verifying …</string>
9193
<string name="retrieving_sms" translation_description="Progress dialog text when sms is being retrieved before auto-submit">Retrieving sms…</string>
92-
<string name="incorrect_code_dialog_body" translation_description="Inline error when incorrect sms verification code is being used to verify">The code you entered is incorrect. Please try again</string>
94+
<string name="incorrect_code_dialog_body" translation_description="Inline error when incorrect sms verification code is being used to verify">Wrong code. Try again.</string>
9395
<string name="incorrect_code_dialog_positive_button_text" translation_description="Text to dismiss error alert dialog">OK</string>
96+
<string name="error_too_many_attempts" translation_description="Error message when the phone number has been used too many times">This phone number has been used too many times.</string>
97+
<string name="error_quota_exceeded" translation_description="Error message when the Firebase project's quota has been exceeded.">There was a problem verifying your phone number.</string>
98+
<string name="error_session_expired" translation_description="Error message when SMS confirmation code has expired.">This code is no longer valid.</string>
9499
<string name="sign_in_with_phone_number" translation_description="Label for phone number input form">Sign in with phone number</string>
95100
<string name="done" translation_description="Progress dialog success transition once sms is sent">Done</string>
96101
<string name="verified" translation_description="Progress dialog success transition when phone number was verified">Verified!</string>

0 commit comments

Comments
 (0)