From: masensio Date: Mon, 26 May 2014 06:52:38 +0000 (+0200) Subject: Merge branch 'develop' into more_concrete_error_messages_session_expires X-Git-Tag: oc-android-1.7.0_signed~303^2~3 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/f849570b0aed0d06e416a915949324e72da0ea85?hp=f6fec8bfddfa288c7df584362d24c86ade8b54f9 Merge branch 'develop' into more_concrete_error_messages_session_expires --- diff --git a/res/values/strings.xml b/res/values/strings.xml index 0bd9cef3..19d006d0 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -86,6 +86,7 @@ %1$s was successfully uploaded Upload failed Upload of %1$s could not be completed + Upload failed, you need to relogin Downloading … %1$d%% Downloading %2$s Download succeeded @@ -93,6 +94,7 @@ Download failed Download of %1$s could not be completed Not downloaded yet + Download failed, you need to relogin Choose account Synchronization failed Synchronization of %1$s could not be completed diff --git a/src/com/owncloud/android/files/services/FileDownloader.java b/src/com/owncloud/android/files/services/FileDownloader.java index 461283ff..db9723fc 100644 --- a/src/com/owncloud/android/files/services/FileDownloader.java +++ b/src/com/owncloud/android/files/services/FileDownloader.java @@ -463,18 +463,22 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis if (!downloadResult.isCancelled()) { int tickerId = (downloadResult.isSuccess()) ? R.string.downloader_download_succeeded_ticker : R.string.downloader_download_failed_ticker; int contentId = (downloadResult.isSuccess()) ? R.string.downloader_download_succeeded_content : R.string.downloader_download_failed_content; - mNotificationBuilder - .setTicker(getString(tickerId)) - .setContentTitle(getString(tickerId)) - .setAutoCancel(true) - .setOngoing(false) - .setProgress(0, 0, false); + boolean needsToUpdateCredentials = (downloadResult.getCode() == ResultCode.UNAUTHORIZED || - // (downloadResult.isTemporalRedirection() && downloadResult.isIdPRedirection() (downloadResult.isIdPRedirection() && mDownloadClient.getCredentials() == null)); - //&& MainApp.getAuthTokenTypeSamlSessionCookie().equals(mDownloadClient.getAuthTokenType()))); + tickerId = (needsToUpdateCredentials) ? + R.string.downloader_download_failed_credentials_error : tickerId; + + mNotificationBuilder + .setTicker(getString(tickerId)) + .setContentTitle(getString(tickerId)) + .setAutoCancel(true) + .setOngoing(false) + .setProgress(0, 0, false); + if (needsToUpdateCredentials) { + // let the user update credentials with one click Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class); updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, download.getAccount()); diff --git a/src/com/owncloud/android/files/services/FileUploader.java b/src/com/owncloud/android/files/services/FileUploader.java index 08f9d3d4..d3dc8ef7 100644 --- a/src/com/owncloud/android/files/services/FileUploader.java +++ b/src/com/owncloud/android/files/services/FileUploader.java @@ -766,20 +766,26 @@ public class FileUploader extends Service implements OnDatatransferProgressListe } else { // / fail -> explicit failure notification - mNotificationManager.cancel(R.string.uploader_upload_in_progress_ticker); + mNotificationManager.cancel(R.string.uploader_upload_in_progress_ticker); + NotificationCompat.Builder errorBuilder = new NotificationCompat.Builder(this); - errorBuilder - .setSmallIcon(R.drawable.notification_icon) - .setTicker(getString(R.string.uploader_upload_failed_ticker)) - .setContentTitle(getString(R.string.uploader_upload_failed_ticker)) - .setAutoCancel(true); - String content = null; - boolean needsToUpdateCredentials = (uploadResult.getCode() == ResultCode.UNAUTHORIZED || - //(uploadResult.isTemporalRedirection() && uploadResult.isIdPRedirection() && + String content = null; + + // check credentials error + boolean needsToUpdateCredentials = (uploadResult.getCode() == ResultCode.UNAUTHORIZED || (uploadResult.isIdPRedirection() && mUploadClient.getCredentials() == null)); - //MainApp.getAuthTokenTypeSamlSessionCookie().equals(mUploadClient.getAuthTokenType()))); + int tickerId = (needsToUpdateCredentials) ? + R.string.uploader_upload_failed_credentials_error : R.string.uploader_upload_failed_ticker; + + errorBuilder + .setSmallIcon(R.drawable.notification_icon) + .setTicker(getString(tickerId)) + .setContentTitle(getString(tickerId)) + .setAutoCancel(true); + + if (needsToUpdateCredentials) { // let the user update credentials with one click Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class); @@ -847,7 +853,7 @@ public class FileUploader extends Service implements OnDatatransferProgressListe } errorBuilder.setContentText(content); - mNotificationManager.notify(R.string.uploader_upload_failed_ticker, errorBuilder.build()); + mNotificationManager.notify(tickerId, errorBuilder.build()); } }