Use the new strings for upload and download fails when it is necessary
authormasensio <masensio@solidgear.es>
Fri, 23 May 2014 11:34:21 +0000 (13:34 +0200)
committermasensio <masensio@solidgear.es>
Fri, 23 May 2014 11:34:21 +0000 (13:34 +0200)
src/com/owncloud/android/files/services/FileDownloader.java
src/com/owncloud/android/files/services/FileUploader.java

index 461283f..db9723f 100644 (file)
@@ -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());
index 08f9d3d..d3dc8ef 100644 (file)
@@ -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());
         }
 
     }