Merge lp:~tomdroid-dev/tomdroid/rework-auth-error-handling into lp:~tomdroid-maintainers/tomdroid/main
- rework-auth-error-handling
- Merge into main
Status: | Needs review |
---|---|
Proposed branch: | lp:~tomdroid-dev/tomdroid/rework-auth-error-handling |
Merge into: | lp:~tomdroid-maintainers/tomdroid/main |
Diff against target: |
454 lines (+137/-76) 7 files modified
res/values/strings.xml (+1/-0) src/org/tomdroid/sync/SyncService.java (+20/-2) src/org/tomdroid/sync/web/OAuthConnection.java (+30/-42) src/org/tomdroid/sync/web/SnowySyncService.java (+29/-11) src/org/tomdroid/sync/web/WebConnection.java (+9/-3) src/org/tomdroid/ui/PreferencesActivity.java (+31/-18) src/org/tomdroid/ui/SyncMessageHandler.java (+17/-0) |
To merge this branch: | bzr merge lp:~tomdroid-dev/tomdroid/rework-auth-error-handling |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Tomdroid Maintainers | Pending | ||
Review via email:
|
Commit message
Description of the change
Could one of you just run the branch and tell me it works for you (tm).
please please
Then we'll have wider testing as a launchpad.net release.

Stefan Hammer (j-4-deactivatedaccount) wrote : | # |
I authenticated now several times and at the 3rd time I entered a false address and got two error messages on top of each other.
One says: The connection th the server has hailed, please check that the address you entered is correct. Exeption Exception"
The other says: The connection to the... correct. Exeption\n JSONException"
Both Dialogs don't show up immediately in the preferences dialog, but only after pressing the back-button, they are shown on top of the notes-list.
log:
04-01 10:22:31.942: E/SnowySyncServ
04-01 10:22:31.942: W/System.
04-01 10:22:31.942: W/System.
04-01 10:22:31.942: W/System.
04-01 10:22:31.942: W/System.
04-01 10:22:31.942: W/System.
I hope this helps!
Another thing... I i am already authenticated to the server and I do it again just like this, I often get following, but it still sends the toast message, that it was sucessfull. This shows up after the first sync:
04-01 10:34:44.867: E/SnowySyncServ
04-01 10:34:44.867: W/System.
04-01 10:34:44.867: W/System.
04-01 10:34:44.867: W/System.
04-01 10:34:44.867: W/System.
04-01 10:34:44.867: W/System.
04-01 10:34:45.127: E/WindowManager
04-01 10:34:45.127: E/WindowManager
04-01 10:34:45.127: E/WindowManager
04-01 10:34:45.127: E/WindowManager
04-01 10:34:45.127: E/WindowManager
04-01 10:34:45.127: E/WindowManager
04-01 10:34:45.127: ...

Olivier Bilodeau (plaxx) wrote : | # |
Great testing! I'll try to address these soon. This fix is definitely going in the next release unless there's a cataclysm because we get a lot of these types of reports.
The error handling is quite convoluted (or I didn't figure it out properly) but making this possible shouldn't be too much work.

Stefan Hammer (j-4-deactivatedaccount) wrote : | # |
I finally caught a log of the case where authentification with the right url fails leading to the "check your addres"-Dialog!
weird thing, as also in the browser of the SDK pages did not load, but there was also no "no internet connection" message... it just hung.
Here the Log: http://
- 286. By Olivier Bilodeau
-
added tasks
I think it's ugly and shouldn't be done this way but I have no idea on how to better do it in a timtely fashion
- 287. By Olivier Bilodeau
-
errors now sent to proper activity
by sending the exception message to the handler which called the sync methods the error shows on the right activity
- 288. By Olivier Bilodeau
-
added parenthesis around exception stuff so diminish user confusion

Olivier Bilodeau (plaxx) wrote : | # |
Preferences are trashed even by an obviously invalid URL. I tried to fix it but it's tricky and I would prefer it cleanly fixed so I filed a ticket with the whole story: lp:982749.

Olivier Bilodeau (plaxx) wrote : | # |
Here's another bug experienced: the activity refresh is odd on first sync (lp:982752).
I also get exceptions on second account setup but, for now, they are handled correctly: they don't show up on the screen and are logged. I'm fine with that.
Forget about the two previously mentioned filed issues unless you think they are market release blocker. Can you test again and tell me how this works for you?
Unfortunately, through my own testing, I'm finding out that we've gone from a 'no idea' exception to a 'JSON' one since the JSON portion of the OAuth code seems to wrap all the other lower-level exceptions.. Again, we'll know more about this gets more thoroughly tested.
- 289. By Olivier Bilodeau
-
don't send an AUTH_SUCCESS if we got exceptions...
unfortunately this still doesn't fix the preference saving issue but is cleaner now

Olivier Bilodeau (plaxx) wrote : | # |
@j-4 review request bump.
If you are busy that's ok, I'll do a launchpad release and we'll do the broader testing there.
As soon as I have a few contiguous hours I'll merge this, review/merge sql-args branch and do a release.
Unmerged revisions
- 289. By Olivier Bilodeau
-
don't send an AUTH_SUCCESS if we got exceptions...
unfortunately this still doesn't fix the preference saving issue but is cleaner now
- 288. By Olivier Bilodeau
-
added parenthesis around exception stuff so diminish user confusion
- 287. By Olivier Bilodeau
-
errors now sent to proper activity
by sending the exception message to the handler which called the sync methods the error shows on the right activity
- 286. By Olivier Bilodeau
-
added tasks
I think it's ugly and shouldn't be done this way but I have no idea on how to better do it in a timtely fashion
- 285. By Olivier Bilodeau
-
OAuth subsystem exception rework
OAuth authentication core is now throwing all throwable exceptions
Callers are now logging and sending to handlers
Handlers are now showing exception short name on the UI (starting with that since we don't know what to expect and don't want something like 'Token plaintext-token was rejected by server' shown on the screen)
Preview Diff
1 | === modified file 'res/values/strings.xml' |
2 | --- res/values/strings.xml 2012-04-03 13:12:50 +0000 |
3 | +++ res/values/strings.xml 2012-04-16 03:55:20 +0000 |
4 | @@ -62,6 +62,7 @@ |
5 | |
6 | <string name="prefSyncCompleteAuth">Completing authentication. Please wait...</string> |
7 | <string name="prefSyncConnectionFailed">The connection to the server has failed, please check that the address you entered is correct.</string> |
8 | + <string name="prefSyncConnectionFailedWithDetails">The connection to the server has failed, please check that the address you entered is correct. (Exception: %1$s)</string> |
9 | <string name="prefServerEmpty">The server address changed but the new value is empty</string> |
10 | |
11 | <string name="titleSyncService">Choose the sync service to use</string> |
12 | |
13 | === modified file 'src/org/tomdroid/sync/SyncService.java' |
14 | --- src/org/tomdroid/sync/SyncService.java 2012-03-31 19:30:28 +0000 |
15 | +++ src/org/tomdroid/sync/SyncService.java 2012-04-16 03:55:20 +0000 |
16 | @@ -64,6 +64,9 @@ |
17 | public final static int NO_INTERNET = 4; |
18 | public final static int NO_SD_CARD = 5; |
19 | public final static int SYNC_PROGRESS = 6; |
20 | + public final static int AUTH_SUCCESS = 7; |
21 | + public final static int ERROR_OAUTH_AUTHENTICATION = 8; |
22 | + |
23 | |
24 | public SyncService(Activity activity, Handler handler) { |
25 | |
26 | @@ -184,14 +187,17 @@ |
27 | * |
28 | * @param message The message id to send, the PARSING_* or NO_INTERNET attributes can be used. |
29 | */ |
30 | - |
31 | + // TODO ok i'm not refactoring this right now but I see little value in such a wrapper |
32 | + // and lots of confusion for people who know android |
33 | protected void sendMessage(int message) { |
34 | |
35 | if(!sendMessage(message, null)) { |
36 | handler.sendEmptyMessage(message); |
37 | } |
38 | } |
39 | - |
40 | + |
41 | + // This stuff is convoluted and should be either be renamed, reworked or documented |
42 | + // I tried hard to re-use it to propagate exceptions but I wasn't able to |
43 | protected boolean sendMessage(int message_id, HashMap<String, Object> payload) { |
44 | |
45 | switch(message_id) { |
46 | @@ -207,6 +213,18 @@ |
47 | return false; |
48 | } |
49 | |
50 | + protected void sendException(int messageId, Exception e) { |
51 | + |
52 | + Message message = handler.obtainMessage(messageId, e); |
53 | + handler.sendMessage(message); |
54 | + } |
55 | + |
56 | + protected void sendExceptionToHandler(Handler handler, int messageId, Exception e) { |
57 | + |
58 | + Message message = handler.obtainMessage(messageId, e); |
59 | + handler.sendMessage(message); |
60 | + } |
61 | + |
62 | /** |
63 | * Update the synchronization progress |
64 | * |
65 | |
66 | === modified file 'src/org/tomdroid/sync/web/OAuthConnection.java' |
67 | --- src/org/tomdroid/sync/web/OAuthConnection.java 2012-03-31 15:54:09 +0000 |
68 | +++ src/org/tomdroid/sync/web/OAuthConnection.java 2012-04-16 03:55:20 +0000 |
69 | @@ -91,7 +91,7 @@ |
70 | return provider; |
71 | } |
72 | |
73 | - private void sign(HttpRequest request) { |
74 | + private void sign(HttpRequest request) throws OAuthMessageSignerException, OAuthExpectationFailedException, OAuthCommunicationException { |
75 | |
76 | if (isAuthenticated()) |
77 | consumer.setTokenWithSecret(accessToken, accessTokenSecret); |
78 | @@ -101,17 +101,16 @@ |
79 | // TODO: figure out if we should throw exceptions |
80 | try { |
81 | consumer.sign(request); |
82 | - } catch (OAuthMessageSignerException e1) { |
83 | - e1.printStackTrace(); |
84 | - } catch (OAuthExpectationFailedException e1) { |
85 | - e1.printStackTrace(); |
86 | + } catch (OAuthMessageSignerException e) { |
87 | + throw e; |
88 | + } catch (OAuthExpectationFailedException e) { |
89 | + throw e; |
90 | } catch (OAuthCommunicationException e) { |
91 | - // TODO Auto-generated catch block |
92 | - e.printStackTrace(); |
93 | + throw e; |
94 | } |
95 | } |
96 | |
97 | - public Uri getAuthorizationUrl(String server) throws UnknownHostException { |
98 | + public Uri getAuthorizationUrl(String server) throws UnknownHostException, OAuthCommunicationException, OAuthMessageSignerException, OAuthNotAuthorizedException, OAuthExpectationFailedException, JSONException { |
99 | |
100 | String url = ""; |
101 | |
102 | @@ -134,8 +133,7 @@ |
103 | authorizeUrl = jsonResponse.getString("oauth_authorize_url"); |
104 | |
105 | } catch (JSONException e) { |
106 | - e.printStackTrace(); |
107 | - return null; |
108 | + throw e; |
109 | } |
110 | |
111 | OAuthProvider provider = getProvider(); |
112 | @@ -151,18 +149,14 @@ |
113 | accessTokenSecret = ""; |
114 | saveConfiguration(); |
115 | |
116 | - } catch (OAuthMessageSignerException e1) { |
117 | - e1.printStackTrace(); |
118 | - return null; |
119 | - } catch (OAuthNotAuthorizedException e1) { |
120 | - e1.printStackTrace(); |
121 | - return null; |
122 | - } catch (OAuthExpectationFailedException e1) { |
123 | - e1.printStackTrace(); |
124 | - return null; |
125 | - } catch (OAuthCommunicationException e1) { |
126 | - e1.printStackTrace(); |
127 | - return null; |
128 | + } catch (OAuthMessageSignerException e) { |
129 | + throw e; |
130 | + } catch (OAuthNotAuthorizedException e) { |
131 | + throw e; |
132 | + } catch (OAuthExpectationFailedException e) { |
133 | + throw e; |
134 | + } catch (OAuthCommunicationException e) { |
135 | + throw e; |
136 | } |
137 | |
138 | TLog.i(TAG, "Authorization URL : {0}", url); |
139 | @@ -170,7 +164,7 @@ |
140 | return Uri.parse(url); |
141 | } |
142 | |
143 | - public boolean getAccess(String verifier) throws UnknownHostException { |
144 | + public boolean getAccess(String verifier) throws UnknownHostException, OAuthMessageSignerException, OAuthNotAuthorizedException, OAuthExpectationFailedException, OAuthCommunicationException, JSONException { |
145 | |
146 | TLog.i(TAG, "Verifier: {0}", verifier); |
147 | |
148 | @@ -189,18 +183,14 @@ |
149 | |
150 | try { |
151 | provider.retrieveAccessToken(consumer, verifier); |
152 | - } catch (OAuthMessageSignerException e1) { |
153 | - e1.printStackTrace(); |
154 | - return false; |
155 | - } catch (OAuthNotAuthorizedException e1) { |
156 | - e1.printStackTrace(); |
157 | - return false; |
158 | - } catch (OAuthExpectationFailedException e1) { |
159 | - e1.printStackTrace(); |
160 | - return false; |
161 | - } catch (OAuthCommunicationException e1) { |
162 | - e1.printStackTrace(); |
163 | - return false; |
164 | + } catch (OAuthMessageSignerException e) { |
165 | + throw e; |
166 | + } catch (OAuthNotAuthorizedException e) { |
167 | + throw e; |
168 | + } catch (OAuthExpectationFailedException e) { |
169 | + throw e; |
170 | + } catch (OAuthCommunicationException e) { |
171 | + throw e; |
172 | } |
173 | |
174 | // access has been granted, store the access token |
175 | @@ -214,8 +204,7 @@ |
176 | // append a slash to the url, else the signature will fail |
177 | userApi = response.getJSONObject("user-ref").getString("api-ref"); |
178 | } catch (JSONException e) { |
179 | - // TODO Auto-generated catch block |
180 | - e.printStackTrace(); |
181 | + throw e; |
182 | } |
183 | |
184 | saveConfiguration(); |
185 | @@ -226,7 +215,7 @@ |
186 | } |
187 | |
188 | @Override |
189 | - public String get(String uri) throws java.net.UnknownHostException { |
190 | + public String get(String uri) throws java.net.UnknownHostException, OAuthMessageSignerException, OAuthExpectationFailedException, OAuthCommunicationException { |
191 | |
192 | // Prepare a request object |
193 | HttpGet httpGet = new HttpGet(uri); |
194 | @@ -236,7 +225,7 @@ |
195 | } |
196 | |
197 | @Override |
198 | - public String put(String uri, String data) throws UnknownHostException { |
199 | + public String put(String uri, String data) throws UnknownHostException, UnsupportedEncodingException, OAuthMessageSignerException, OAuthExpectationFailedException, OAuthCommunicationException { |
200 | |
201 | // Prepare a request object |
202 | HttpPut httpPut = new HttpPut(uri); |
203 | @@ -244,9 +233,8 @@ |
204 | try { |
205 | // The default http content charset is ISO-8859-1, JSON requires UTF-8 |
206 | httpPut.setEntity(new StringEntity(data, "UTF-8")); |
207 | - } catch (UnsupportedEncodingException e1) { |
208 | - e1.printStackTrace(); |
209 | - return null; |
210 | + } catch (UnsupportedEncodingException e) { |
211 | + throw e; |
212 | } |
213 | |
214 | httpPut.setHeader("Content-Type", "application/json"); |
215 | |
216 | === modified file 'src/org/tomdroid/sync/web/SnowySyncService.java' |
217 | --- src/org/tomdroid/sync/web/SnowySyncService.java 2012-03-31 22:13:13 +0000 |
218 | +++ src/org/tomdroid/sync/web/SnowySyncService.java 2012-04-16 03:55:20 +0000 |
219 | @@ -26,6 +26,11 @@ |
220 | import android.net.Uri; |
221 | import android.os.Handler; |
222 | import android.os.Message; |
223 | +import oauth.signpost.exception.OAuthCommunicationException; |
224 | +import oauth.signpost.exception.OAuthExpectationFailedException; |
225 | +import oauth.signpost.exception.OAuthMessageSignerException; |
226 | +import oauth.signpost.exception.OAuthNotAuthorizedException; |
227 | + |
228 | import org.json.JSONArray; |
229 | import org.json.JSONException; |
230 | import org.json.JSONObject; |
231 | @@ -83,21 +88,23 @@ |
232 | |
233 | public void run() { |
234 | |
235 | - // Reset the authentication credentials |
236 | - OAuthConnection auth = new OAuthConnection(); |
237 | - Uri authUri = null; |
238 | - |
239 | try { |
240 | - authUri = auth.getAuthorizationUrl(server); |
241 | - |
242 | + // Reset the authentication credentials |
243 | + OAuthConnection auth = new OAuthConnection(); |
244 | + Uri authUri = auth.getAuthorizationUrl(server); |
245 | + Message message = handler.obtainMessage(AUTH_SUCCESS, authUri); |
246 | + handler.sendMessage(message); |
247 | + |
248 | } catch (UnknownHostException e) { |
249 | TLog.e(TAG, "Internet connection not available"); |
250 | sendMessage(NO_INTERNET); |
251 | + |
252 | + } catch (Exception e) { |
253 | + TLog.e(TAG, "Unidentified authentication error. Expception: {0} Message: {1}", e.getClass().getCanonicalName(), e.getMessage()); |
254 | + e.printStackTrace(); |
255 | + sendExceptionToHandler(handler, ERROR_OAUTH_AUTHENTICATION, e); |
256 | } |
257 | |
258 | - Message message = new Message(); |
259 | - message.obj = authUri; |
260 | - handler.sendMessage(message); |
261 | } |
262 | |
263 | }); |
264 | @@ -119,11 +126,15 @@ |
265 | if (result) { |
266 | TLog.i(TAG, "The authorization process is complete."); |
267 | } else { |
268 | - TLog.e(TAG, "Something went wrong during the authorization process."); |
269 | + throw new Exception("Something went wrong during the authorization process. auth.getAccess returned false"); |
270 | } |
271 | } catch (UnknownHostException e) { |
272 | TLog.e(TAG, "Internet connection not available"); |
273 | sendMessage(NO_INTERNET); |
274 | + } catch (Exception e) { |
275 | + TLog.e(TAG, "Unidentified authentication error. Expception: {0} Message: {1}", e.getClass().getCanonicalName(), e.getMessage()); |
276 | + e.printStackTrace(); |
277 | + sendExceptionToHandler(handler, ERROR_OAUTH_AUTHENTICATION, e); |
278 | } |
279 | |
280 | // We don't care what we send, just remove the dialog |
281 | @@ -224,8 +235,15 @@ |
282 | sendMessage(NO_INTERNET); |
283 | setSyncProgress(100); |
284 | return; |
285 | + |
286 | + } catch (Exception e) { |
287 | + TLog.e(TAG, "Unidentified authentication error. Expception: {0} Message: {1}", e.getClass().getCanonicalName(), e.getMessage()); |
288 | + e.printStackTrace(); |
289 | + sendException(ERROR_OAUTH_AUTHENTICATION, e); |
290 | + setSyncProgress(100); |
291 | + return; |
292 | } |
293 | - |
294 | + |
295 | sendMessage(PARSING_COMPLETE); |
296 | } |
297 | }); |
298 | |
299 | === modified file 'src/org/tomdroid/sync/web/WebConnection.java' |
300 | --- src/org/tomdroid/sync/web/WebConnection.java 2011-10-27 16:33:12 +0000 |
301 | +++ src/org/tomdroid/sync/web/WebConnection.java 2012-04-16 03:55:20 +0000 |
302 | @@ -22,6 +22,10 @@ |
303 | */ |
304 | package org.tomdroid.sync.web; |
305 | |
306 | +import oauth.signpost.exception.OAuthCommunicationException; |
307 | +import oauth.signpost.exception.OAuthExpectationFailedException; |
308 | +import oauth.signpost.exception.OAuthMessageSignerException; |
309 | + |
310 | import org.apache.http.HttpEntity; |
311 | import org.apache.http.HttpResponse; |
312 | import org.apache.http.client.ClientProtocolException; |
313 | @@ -33,14 +37,16 @@ |
314 | import java.io.IOException; |
315 | import java.io.InputStream; |
316 | import java.io.InputStreamReader; |
317 | +import java.io.UnsupportedEncodingException; |
318 | import java.net.UnknownHostException; |
319 | |
320 | public abstract class WebConnection { |
321 | |
322 | private static final String TAG = "WebConnection"; |
323 | - |
324 | - public abstract String get(String uri) throws UnknownHostException; |
325 | - public abstract String put(String uri, String data) throws UnknownHostException; |
326 | + |
327 | + // TODO implementation specific exceptions should be removed from here but for now we want visibility in the UI of the problems |
328 | + public abstract String get(String uri) throws UnknownHostException, OAuthMessageSignerException, OAuthExpectationFailedException, OAuthCommunicationException; |
329 | + public abstract String put(String uri, String data) throws UnknownHostException, UnsupportedEncodingException, OAuthMessageSignerException, OAuthExpectationFailedException, OAuthCommunicationException; |
330 | |
331 | private static String convertStreamToString(InputStream is) { |
332 | /* |
333 | |
334 | === modified file 'src/org/tomdroid/ui/PreferencesActivity.java' |
335 | --- src/org/tomdroid/ui/PreferencesActivity.java 2012-04-01 13:27:09 +0000 |
336 | +++ src/org/tomdroid/ui/PreferencesActivity.java 2012-04-16 03:55:20 +0000 |
337 | @@ -41,6 +41,7 @@ |
338 | import android.preference.PreferenceActivity; |
339 | import android.provider.SearchRecentSuggestions; |
340 | import android.widget.Toast; |
341 | + |
342 | import org.tomdroid.NoteManager; |
343 | import org.tomdroid.R; |
344 | import org.tomdroid.sync.ServiceAuth; |
345 | @@ -106,6 +107,7 @@ |
346 | public boolean onPreferenceChange(Preference preference, |
347 | Object serverUri) { |
348 | |
349 | + // FIXME this shouldn't be here, it should be up to the SyncService to decide |
350 | if (serverUri == null) { |
351 | Toast.makeText(PreferencesActivity.this, |
352 | getString(R.string.prefServerEmpty), |
353 | @@ -195,26 +197,27 @@ |
354 | @Override |
355 | public void handleMessage(Message msg) { |
356 | |
357 | - boolean wasSuccsessful = false; |
358 | - Uri authorizationUri = (Uri) msg.obj; |
359 | - if (authorizationUri != null) { |
360 | - |
361 | - Intent i = new Intent(Intent.ACTION_VIEW, authorizationUri); |
362 | - startActivity(i); |
363 | - wasSuccsessful = true; |
364 | - |
365 | - } else { |
366 | - // Auth failed, don't update the value |
367 | - wasSuccsessful = false; |
368 | + switch(msg.what) { |
369 | + case SyncService.AUTH_SUCCESS: |
370 | + Uri authorizationUri = (Uri) msg.obj; |
371 | + if (authorizationUri != null) { |
372 | + Intent i = new Intent(Intent.ACTION_VIEW, authorizationUri); |
373 | + startActivity(i); |
374 | + resetLocalDatabase(); |
375 | + } |
376 | + break; |
377 | + |
378 | + case SyncService.ERROR_OAUTH_AUTHENTICATION: |
379 | + connectionFailed((Exception) msg.obj); |
380 | + break; |
381 | + |
382 | + default: |
383 | + connectionFailed(); |
384 | + break; |
385 | } |
386 | - |
387 | - if (authProgress != null) |
388 | + |
389 | + if (authProgress != null) { |
390 | authProgress.dismiss(); |
391 | - |
392 | - if (wasSuccsessful) { |
393 | - resetLocalDatabase(); |
394 | - } else { |
395 | - connectionFailed(); |
396 | } |
397 | } |
398 | }; |
399 | @@ -279,6 +282,16 @@ |
400 | .show(); |
401 | } |
402 | |
403 | + private void connectionFailed(Exception e) { |
404 | + new AlertDialog.Builder(this) |
405 | + .setMessage(String.format(getString(R.string.prefSyncConnectionFailedWithDetails), e.getClass().getSimpleName())) |
406 | + .setNeutralButton(getString(R.string.btnOk), new OnClickListener() { |
407 | + public void onClick(DialogInterface dialog, int which) { |
408 | + dialog.dismiss(); |
409 | + }}) |
410 | + .show(); |
411 | + } |
412 | + |
413 | private void folderNotExisting(String path) { |
414 | new AlertDialog.Builder(this) |
415 | .setTitle(getString(R.string.error)) |
416 | |
417 | === modified file 'src/org/tomdroid/ui/SyncMessageHandler.java' |
418 | --- src/org/tomdroid/ui/SyncMessageHandler.java 2012-04-03 13:12:50 +0000 |
419 | +++ src/org/tomdroid/ui/SyncMessageHandler.java 2012-04-16 03:55:20 +0000 |
420 | @@ -62,6 +62,7 @@ |
421 | case SyncService.PARSING_COMPLETE: |
422 | final ErrorList errors = (ErrorList)msg.obj; |
423 | if(errors.isEmpty()) { |
424 | + |
425 | message = this.activity.getString(R.string.messageSyncComplete); |
426 | message = String.format(message,serviceDescription); |
427 | Toast.makeText(activity, message, Toast.LENGTH_SHORT).show(); |
428 | @@ -92,10 +93,26 @@ |
429 | Toast.makeText(activity, message, Toast.LENGTH_SHORT).show(); |
430 | break; |
431 | |
432 | + // FIXME shouldn't be here (should be in PreferencesActivity) |
433 | case SyncService.NO_INTERNET: |
434 | Toast.makeText(activity, this.activity.getString(R.string.messageSyncNoConnection), |
435 | Toast.LENGTH_SHORT).show(); |
436 | break; |
437 | + |
438 | + // FIXME shouldn't be here (should be in PreferencesActivity) |
439 | + case SyncService.ERROR_OAUTH_AUTHENTICATION: |
440 | + new AlertDialog.Builder(this.activity) |
441 | + .setMessage( |
442 | + String.format( |
443 | + this.activity.getString(R.string.prefSyncConnectionFailedWithDetails), |
444 | + ((Exception) msg.obj).getClass().getSimpleName())) |
445 | + .setNeutralButton(this.activity.getString(R.string.btnOk), new OnClickListener() { |
446 | + public void onClick(DialogInterface dialog, int which) { |
447 | + dialog.dismiss(); |
448 | + }}) |
449 | + .show(); |
450 | + break; |
451 | + |
452 | |
453 | case SyncService.NO_SD_CARD: |
454 | Toast.makeText(activity, activity.getString(R.string.messageNoSDCard), |
I started my testengines... wait for a result shortly!