From 81229dcac1da83d24ab171343b12a0bb9db509eb Mon Sep 17 00:00:00 2001 From: Tim Su Date: Mon, 20 Dec 2010 20:46:44 -0800 Subject: [PATCH] Added a message if google login fails too many times. This will help users get un-stuck --- .../astrid/gtasks/auth/GtasksLoginActivity.java | 16 +++++++++++++++- astrid/res/values/strings-gtasks.xml | 4 ++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/gtasks/auth/GtasksLoginActivity.java b/astrid/plugin-src/com/todoroo/astrid/gtasks/auth/GtasksLoginActivity.java index 45b90c79e..f1a37c344 100644 --- a/astrid/plugin-src/com/todoroo/astrid/gtasks/auth/GtasksLoginActivity.java +++ b/astrid/plugin-src/com/todoroo/astrid/gtasks/auth/GtasksLoginActivity.java @@ -29,6 +29,8 @@ import android.content.Intent; import android.os.Build; import android.os.Bundle; import android.text.Editable; +import android.text.Html; +import android.text.method.LinkMovementMethod; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; @@ -114,6 +116,7 @@ public class GtasksLoginActivity extends Activity { } + private int loginTries = 0; private void performLogin(final String email, final String password, final boolean isDomain) { final ProgressDialog dialog = DialogUtilities.progressDialog(this, @@ -127,6 +130,9 @@ public class GtasksLoginActivity extends Activity { final StringBuilder errorMessage = new StringBuilder(); GoogleConnectionManager gcm = new GoogleConnectionManager(email.toString(), password.toString(), !isDomain); + + loginTries++; + try { gcm.authenticate(false); gcm.get(); @@ -140,6 +146,13 @@ public class GtasksLoginActivity extends Activity { synchronize(); } catch (GoogleLoginException e) { errorMessage.append(getString(R.string.gtasks_GLA_errorAuth)); + + if(loginTries > 1) { + errorMessage.append("

").append(getString( + R.string.gtasks_GLA_errorAuth_captcha)).append( + "
Google Sign In"); + } + Log.e("gtasks", "login-auth", e); return; } catch (GoogleTasksException e) { @@ -158,7 +171,8 @@ public class GtasksLoginActivity extends Activity { dialog.dismiss(); if(errorMessage.length() > 0) { errors.setVisibility(View.VISIBLE); - errors.setText(errorMessage); + errors.setText(Html.fromHtml(errorMessage.toString())); + errors.setMovementMethod(LinkMovementMethod.getInstance()); } } }); diff --git a/astrid/res/values/strings-gtasks.xml b/astrid/res/values/strings-gtasks.xml index 9adb4f4bb..a4271fc21 100644 --- a/astrid/res/values/strings-gtasks.xml +++ b/astrid/res/values/strings-gtasks.xml @@ -51,6 +51,10 @@ Error: e-mail or password incorrect! + + + You may have encountered a captcha. + Try logging in from the browser, then come back to try again: