Handle some login errors with localized strings based on error code

pull/14/head
Sam Bosley 13 years ago
parent 689c59ba79
commit 90a7cd1705

@ -60,6 +60,7 @@ import com.todoroo.andlib.utility.DialogUtilities;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.actfm.sync.ActFmInvoker;
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
import com.todoroo.astrid.actfm.sync.ActFmServiceException;
import com.todoroo.astrid.activity.Eula;
import com.todoroo.astrid.gtasks.auth.ModernAuthManager;
import com.todoroo.astrid.service.AstridDependencyInjector;
@ -546,6 +547,7 @@ public class ActFmLoginActivity extends FragmentActivity implements AuthListener
}
}
@SuppressWarnings("nls")
private void handleError(final Throwable e) {
DialogUtilities.dismissDialog(this, progressDialog);
exceptionService.reportError("astrid-sharing-login", e); //$NON-NLS-1$
@ -553,7 +555,19 @@ public class ActFmLoginActivity extends FragmentActivity implements AuthListener
runOnUiThread(new Runnable() {
@Override
public void run() {
errors.setText(e.getMessage());
String message = e.getMessage();
if (e instanceof ActFmServiceException) {
ActFmServiceException ae = (ActFmServiceException) e;
JSONObject result = ae.result;
if (result != null && result.has("code")) {
String code = result.optString("code");
if ("user_exists".equals(code))
message = getString(R.string.actfm_ALA_error_user_exists);
else if ("incorrect_password".equals(code))
message = getString(R.string.actfm_ALA_error_wrong_password);
}
}
errors.setText(message);
errors.setVisibility(View.VISIBLE);
}
});

@ -271,6 +271,12 @@
<!-- share login: OAUTH Login Prompt -->
<string name="actfm_OLA_prompt">Please log in:</string>
<!-- Login error: user exists -->
<string name="actfm_ALA_error_user_exists">User already exists. Please sign in instead.</string>
<!-- Login error: wrong password -->
<string name="actfm_ALA_error_wrong_password">Sorry, that password was incorrect. Please try again.</string>
<!-- ================================================ Featured Lists -->
<string name="actfm_feat_list_clone">Copy list</string>

Loading…
Cancel
Save