+ * Notifies the user about a failed synchronization through the status notification bar \r
+ */\r
+ private void notifyFailedSynchronization() {\r
+ Notification notification = new Notification(R.drawable.icon, getContext().getString(R.string.sync_fail_ticker), System.currentTimeMillis());\r
+ notification.flags |= Notification.FLAG_AUTO_CANCEL;\r
+ boolean needsToUpdateCredentials = (mLastFailedResult != null && mLastFailedResult.getCode() == ResultCode.UNAUTHORIZED);\r
+ // TODO put something smart in the contentIntent below for all the possible errors\r
+ notification.contentIntent = PendingIntent.getActivity(getContext().getApplicationContext(), (int)System.currentTimeMillis(), new Intent(), 0);\r
+ if (needsToUpdateCredentials) {\r
+ // let the user update credentials with one click\r
+ Intent updateAccountCredentials = new Intent(getContext(), AuthenticatorActivity.class);\r
+ updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, getAccount());\r
+ updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACTION, AuthenticatorActivity.ACTION_UPDATE_TOKEN);\r
+ updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);\r
+ updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);\r
+ updateAccountCredentials.addFlags(Intent.FLAG_FROM_BACKGROUND);\r
+ notification.contentIntent = PendingIntent.getActivity(getContext(), (int)System.currentTimeMillis(), updateAccountCredentials, PendingIntent.FLAG_ONE_SHOT);\r
+ notification.setLatestEventInfo(getContext().getApplicationContext(), \r
+ getContext().getString(R.string.sync_fail_ticker), \r
+ String.format(getContext().getString(R.string.sync_fail_content_unauthorized), getAccount().name), \r
+ notification.contentIntent);\r
+ Log.e(TAG, "NEEDS TO UPDATE CREDENTIALS");\r
+ } else {\r
+ notification.setLatestEventInfo(getContext().getApplicationContext(), \r
+ getContext().getString(R.string.sync_fail_ticker), \r
+ String.format(getContext().getString(R.string.sync_fail_content), getAccount().name), \r
+ notification.contentIntent);\r
+ }\r
+ ((NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE)).notify(R.string.sync_fail_ticker, notification);\r
+ }\r
+\r
+\r
+ /**\r
+ * Notifies the user about conflicts and strange fails when trying to synchronize the contents of kept-in-sync files.\r