From: masensio Date: Fri, 23 May 2014 11:34:21 +0000 (+0200) Subject: Use the new strings for upload and download fails when it is necessary X-Git-Tag: oc-android-1.7.0_signed~303^2~4 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/121887c8991ce7184d7bdfcd22efbbf85dafc236?hp=--cc Use the new strings for upload and download fails when it is necessary --- 121887c8991ce7184d7bdfcd22efbbf85dafc236 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()); } }