Fix for oauth error when you are not online

pull/14/head
Tim Su 13 years ago
parent 9597e91ecc
commit d0a9889490

@ -19,6 +19,7 @@
*/ */
package com.todoroo.astrid.actfm; package com.todoroo.astrid.actfm;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -105,13 +106,15 @@ public class ActFmGoogleAuthActivity extends ListActivity {
authToken = bundle.getString(AccountManager.KEY_AUTHTOKEN); authToken = bundle.getString(AccountManager.KEY_AUTHTOKEN);
onAuthTokenSuccess(); onAuthTokenSuccess();
} }
} catch (Exception e) { } catch (final Exception e) {
Log.e("actfm-google-auth", "Login Error", e); //$NON-NLS-1$ //$NON-NLS-2$ Log.e("actfm-google-auth", "Login Error", e); //$NON-NLS-1$ //$NON-NLS-2$
ActFmGoogleAuthActivity.this.runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
int error = e instanceof IOException ? R.string.gtasks_GLA_errorIOAuth :
R.string.gtasks_GLA_errorAuth;
Toast.makeText(ActFmGoogleAuthActivity.this, Toast.makeText(ActFmGoogleAuthActivity.this,
R.string.gtasks_GLA_errorAuth, error,
Toast.LENGTH_LONG).show(); Toast.LENGTH_LONG).show();
} }
}); });

@ -19,6 +19,7 @@
*/ */
package com.todoroo.astrid.gtasks.auth; package com.todoroo.astrid.gtasks.auth;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -30,6 +31,7 @@ import android.app.ListActivity;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.ListView; import android.widget.ListView;
@ -118,12 +120,16 @@ public class GtasksLoginActivity extends ListActivity {
authToken = bundle.getString(AccountManager.KEY_AUTHTOKEN); authToken = bundle.getString(AccountManager.KEY_AUTHTOKEN);
onAuthTokenSuccess(); onAuthTokenSuccess();
} }
} catch (Exception e) { } catch (final Exception e) {
e.printStackTrace(); Log.e("gtasks-login", "Login Error", e); //$NON-NLS-1$ //$NON-NLS-2$
GtasksLoginActivity.this.runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
Toast.makeText(GtasksLoginActivity.this, R.string.gtasks_GLA_errorAuth, Toast.LENGTH_LONG).show(); int error = e instanceof IOException ? R.string.gtasks_GLA_errorIOAuth :
R.string.gtasks_GLA_errorAuth;
Toast.makeText(GtasksLoginActivity.this,
error,
Toast.LENGTH_LONG).show();
} }
}); });
} finally { } finally {

@ -76,6 +76,9 @@
<!-- Error Message when we receive a HTTP 401 Unauthorized --> <!-- Error Message when we receive a HTTP 401 Unauthorized -->
<string name="gtasks_GLA_errorAuth">Error authenticating! Please check your username and password in your phone\'s account manager</string> <string name="gtasks_GLA_errorAuth">Error authenticating! Please check your username and password in your phone\'s account manager</string>
<!-- Error Message when we receive an IO Exception -->
<string name="gtasks_GLA_errorIOAuth">Sorry, we had trouble communicating with Google servers. Please try again later.</string>
<!-- Error Message when we receive a HTTP 401 Unauthorized multiple times --> <!-- Error Message when we receive a HTTP 401 Unauthorized multiple times -->
<string name="gtasks_GLA_errorAuth_captcha">You may have encountered a captcha. <string name="gtasks_GLA_errorAuth_captcha">You may have encountered a captcha.
Try logging in from the browser, then come back to try again:</string> Try logging in from the browser, then come back to try again:</string>

Loading…
Cancel
Save