Yuvipanda has uploaded a new change for review.
https://gerrit.wikimedia.org/r/114750
Change subject: Handle user account creation errors
......................................................................
Handle user account creation errors
Change-Id: Ibdd13bafcafd38c258bd6641c71f32ed64f45f0a
---
M wikipedia/res/values/strings.xml
M wikipedia/src/main/java/org/wikipedia/createaccount/CreateAccountActivity.java
2 files changed, 21 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/apps/android/wikipedia
refs/changes/50/114750/1
diff --git a/wikipedia/res/values/strings.xml b/wikipedia/res/values/strings.xml
index 6899dce..5b3925a 100644
--- a/wikipedia/res/values/strings.xml
+++ b/wikipedia/res/values/strings.xml
@@ -91,4 +91,8 @@
<string name="create_account_password_repeat_hint">Repeat password</string>
<string name="create_account_passwords_mismatch_error">Passwords don\'t
match</string>
<string name="create_account_email_error">Invalid email address</string>
+ <string name="create_account_username_exists_error">Username already in
use</string>
+ <string name="create_account_ip_throttle_error">Too many accounts created
from this IP. Try again later.</string>
+ <string name="create_account_open_proxy_error">This IP has been blocked
from creating accounts.</string>
+ <string name="create_account_generic_error">Could not create
account</string>
</resources>
diff --git
a/wikipedia/src/main/java/org/wikipedia/createaccount/CreateAccountActivity.java
b/wikipedia/src/main/java/org/wikipedia/createaccount/CreateAccountActivity.java
index f88038d..4ec1c6d 100644
---
a/wikipedia/src/main/java/org/wikipedia/createaccount/CreateAccountActivity.java
+++
b/wikipedia/src/main/java/org/wikipedia/createaccount/CreateAccountActivity.java
@@ -7,6 +7,7 @@
import android.widget.*;
import com.mobsandgeeks.saripaar.*;
import com.mobsandgeeks.saripaar.annotation.*;
+import de.keyboardsurfer.android.widget.crouton.*;
import org.mediawiki.api.json.*;
import org.wikipedia.*;
import org.wikipedia.editing.*;
@@ -90,6 +91,19 @@
return true;
}
+ public void handleError(CreateAccountResult result) {
+ String errorCode = result.getResult();
+ if (errorCode.equals("userexists")) {
+
usernameEdit.setError(getString(R.string.create_account_username_exists_error));
+ } else if (errorCode.equals("acct_creation_throttle_hit")) {
+ Crouton.makeText(this, R.string.create_account_ip_throttle_error,
Style.ALERT).show();
+ } else if (errorCode.equals("sorbs_create_account_reason")) {
+ Crouton.makeText(this, R.string.create_account_open_proxy_error,
Style.ALERT).show();
+ } else {
+ Crouton.makeText(this, R.string.create_account_generic_error,
Style.ALERT).show();
+ }
+ }
+
public void doCreateAccount() {
String token = null, email = null;
if (createAccountResult != null && createAccountResult instanceof
CreateAccountTokenResult) {
@@ -118,6 +132,8 @@
if (result instanceof CreateAccountTokenResult) {
captchaHandler.handleCaptcha(((CreateAccountTokenResult)result).getCaptchaResult());
} else {
+ progressDialog.dismiss();
+ captchaHandler.cancelCaptcha();
// Returns lowercase 'success', unlike every other API.
GRR man, GRR
// Replace wen
https://bugzilla.wikimedia.org/show_bug.cgi?id=61663 is fixed?
if (result.getResult().toLowerCase().equals("success")) {
@@ -128,7 +144,7 @@
createAccountResult = null;
doCreateAccount();
} else {
- throw new RuntimeException("Errored with " +
result.getResult());
+ handleError(result);
}
}
}
--
To view, visit https://gerrit.wikimedia.org/r/114750
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibdd13bafcafd38c258bd6641c71f32ed64f45f0a
Gerrit-PatchSet: 1
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Yuvipanda <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits