Dbrant has submitted this change and it was merged.

Change subject: Use username returned from create account API call
......................................................................


Use username returned from create account API call

This ensures that we locally store and use the canonical username.

Bug: 64409
Change-Id: Id7774cb8f7b2941dfa73860d9ec7c14f18406947
---
M wikipedia/src/main/java/org/wikipedia/createaccount/CreateAccountActivity.java
M wikipedia/src/main/java/org/wikipedia/createaccount/CreateAccountTask.java
2 files changed, 14 insertions(+), 12 deletions(-)

Approvals:
  Dbrant: Looks good to me, approved



diff --git 
a/wikipedia/src/main/java/org/wikipedia/createaccount/CreateAccountActivity.java
 
b/wikipedia/src/main/java/org/wikipedia/createaccount/CreateAccountActivity.java
index 9889a00..fdcd502 100644
--- 
a/wikipedia/src/main/java/org/wikipedia/createaccount/CreateAccountActivity.java
+++ 
b/wikipedia/src/main/java/org/wikipedia/createaccount/CreateAccountActivity.java
@@ -172,21 +172,21 @@
                         funnel.logCaptchaShown();
                     }
                     
captchaHandler.handleCaptcha(((CreateAccountCaptchaResult)result).getCaptchaResult());
+                } else if (result instanceof CreateAccountSuccessResult) {
+                    progressDialog.dismiss();
+                    captchaHandler.cancelCaptcha();
+                    funnel.logSuccess();
+                    Utils.hideSoftKeyboard(CreateAccountActivity.this);
+                    Intent resultIntent = new Intent();
+                    resultIntent.putExtra("username", 
((CreateAccountSuccessResult) result).getUsername());
+                    resultIntent.putExtra("password", 
passwordEdit.getText().toString());
+                    setResult(RESULT_ACCOUNT_CREATED, resultIntent);
+                    Toast.makeText(CreateAccountActivity.this, 
R.string.create_account_account_created_toast, Toast.LENGTH_LONG).show();
+                    finish();
                 } 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")) {
-                        funnel.logSuccess();
-                        Utils.hideSoftKeyboard(CreateAccountActivity.this);
-                        Intent resultIntent = new Intent();
-                        resultIntent.putExtra("username", 
usernameEdit.getText().toString());
-                        resultIntent.putExtra("password", 
passwordEdit.getText().toString());
-                        setResult(RESULT_ACCOUNT_CREATED, resultIntent);
-                        Toast.makeText(CreateAccountActivity.this, 
R.string.create_account_account_created_toast, Toast.LENGTH_LONG).show();
-                        finish();
-                    } else if 
(result.getResult().equals("captcha-createaccount-fail")) {
+                    if 
(result.getResult().equals("captcha-createaccount-fail")) {
                         // So for now we just need to do the entire set of 
requests again. sigh
                         // Eventually this should be fixed to have the new 
captcha info come back.
                         createAccountResult = null;
diff --git 
a/wikipedia/src/main/java/org/wikipedia/createaccount/CreateAccountTask.java 
b/wikipedia/src/main/java/org/wikipedia/createaccount/CreateAccountTask.java
index 8715cec..2cf0e82 100644
--- a/wikipedia/src/main/java/org/wikipedia/createaccount/CreateAccountTask.java
+++ b/wikipedia/src/main/java/org/wikipedia/createaccount/CreateAccountTask.java
@@ -54,6 +54,8 @@
             return performTask();
         } else if (apiResult.equals("NeedCaptcha")) {
             return new CreateAccountCaptchaResult(new 
CaptchaResult(ca.optJSONObject("captcha").optString("id")));
+        } else if (apiResult.equals("Success")) {
+            return new CreateAccountSuccessResult(ca.optString("username"));
         } else {
             return new CreateAccountResult(apiResult);
         }

-- 
To view, visit https://gerrit.wikimedia.org/r/129618
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Id7774cb8f7b2941dfa73860d9ec7c14f18406947
Gerrit-PatchSet: 1
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Yuvipanda <[email protected]>
Gerrit-Reviewer: Dbrant <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to