فهرست منبع

Line wrapping and getApplicationContext calls removed from last commit

Juan Carlos González Cabrero 9 سال پیش
والد
کامیت
5fd891413e

+ 35 - 34
src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java

@@ -1,21 +1,20 @@
 /**
- *   ownCloud Android client application
- *
- *   Copyright (C) 2012  Bartek Przybylski
- *   Copyright (C) 2015 ownCloud Inc.
- *
- *   This program is free software: you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License version 2,
- *   as published by the Free Software Foundation.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
+ * ownCloud Android client application
+ * <p/>
+ * Copyright (C) 2012  Bartek Przybylski
+ * Copyright (C) 2015 ownCloud Inc.
+ * <p/>
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2,
+ * as published by the Free Software Foundation.
+ * <p/>
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * <p/>
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
 package com.owncloud.android.files;
@@ -54,14 +53,14 @@ public class InstantUploadBroadcastReceiver extends BroadcastReceiver {
     public void onReceive(Context context, Intent intent) {
         Log_OC.d(TAG, "Received: " + intent.getAction());
         if (intent.getAction().equals(NEW_PHOTO_ACTION_UNOFFICIAL)) {
-            handleNewPictureAction(context, intent); 
+            handleNewPictureAction(context, intent);
             Log_OC.d(TAG, "UNOFFICIAL processed: com.android.camera.NEW_PICTURE");
         } else if (intent.getAction().equals(NEW_PHOTO_ACTION)) {
-            handleNewPictureAction(context, intent); 
+            handleNewPictureAction(context, intent);
             Log_OC.d(TAG, "OFFICIAL processed: android.hardware.action.NEW_PICTURE");
         } else if (intent.getAction().equals(NEW_VIDEO_ACTION)) {
             handleNewVideoAction(context, intent);
-            Log_OC.d(TAG, "OFFICIAL processed: android.hardware.action.NEW_VIDEO");            
+            Log_OC.d(TAG, "OFFICIAL processed: android.hardware.action.NEW_VIDEO");
         } else {
             Log_OC.e(TAG, "Incorrect intent sent: " + intent.getAction());
         }
@@ -73,6 +72,7 @@ public class InstantUploadBroadcastReceiver extends BroadcastReceiver {
      * remember last uploaded photo to filter duplicates. Must not be null!
      */
     static String lastUploadedPhotoPath = "";
+
     private void handleNewPictureAction(Context context, Intent intent) {
         Cursor c = null;
         String file_path = null;
@@ -80,7 +80,7 @@ public class InstantUploadBroadcastReceiver extends BroadcastReceiver {
         String mime_type = null;
 
         Log_OC.w(TAG, "New photo received");
-        
+
         if (!instantPictureUploadEnabled(context)) {
             Log_OC.d(TAG, "Instant picture upload disabled, ignoring new picture");
             return;
@@ -92,8 +92,8 @@ public class InstantUploadBroadcastReceiver extends BroadcastReceiver {
             return;
         }
 
-        String[] CONTENT_PROJECTION = { Images.Media.DATA, Images.Media.DISPLAY_NAME, Images.Media.MIME_TYPE,
-                Images.Media.SIZE };
+        String[] CONTENT_PROJECTION = {Images.Media.DATA, Images.Media.DISPLAY_NAME, Images.Media.MIME_TYPE,
+                Images.Media.SIZE};
         c = context.getContentResolver().query(intent.getData(), CONTENT_PROJECTION, null, null, null);
         if (!c.moveToFirst()) {
             Log_OC.e(TAG, "Couldn't resolve given uri: " + intent.getDataString());
@@ -103,21 +103,21 @@ public class InstantUploadBroadcastReceiver extends BroadcastReceiver {
         file_name = c.getString(c.getColumnIndex(Images.Media.DISPLAY_NAME));
         mime_type = c.getString(c.getColumnIndex(Images.Media.MIME_TYPE));
         c.close();
-        
-        if(file_path.equals(lastUploadedPhotoPath)) {
+
+        if (file_path.equals(lastUploadedPhotoPath)) {
             Log_OC.d(TAG, "Duplicate detected: " + file_path + ". Ignore.");
             return;
         }
 
         lastUploadedPhotoPath = file_path;
-        Log_OC.d(TAG, "Path: " + file_path + "");        
-        
+        Log_OC.d(TAG, "Path: " + file_path + "");
+
         int behaviour = getUploadBehaviour(context);
         FileUploader.uploadNewFile(context, account, file_path, FileStorageUtils.getInstantUploadFilePath(context,
                 file_name), behaviour, mime_type, true, instantPictureUploadViaWiFiOnly(context));
     }
 
-    private Integer getUploadBehaviour(Context context){
+    private Integer getUploadBehaviour(Context context) {
         SharedPreferences appPreferences = PreferenceManager.getDefaultSharedPreferences(context);
         String behaviour = appPreferences.getString("prefs_instant_behaviour", "NOTHING");
 
@@ -138,7 +138,7 @@ public class InstantUploadBroadcastReceiver extends BroadcastReceiver {
         String mime_type = null;
 
         Log_OC.w(TAG, "New video received");
-        
+
         if (!instantVideoUploadEnabled(context)) {
             Log_OC.d(TAG, "Instant video upload disabled, ignoring new video");
             return;
@@ -150,13 +150,13 @@ public class InstantUploadBroadcastReceiver extends BroadcastReceiver {
             return;
         }
 
-        String[] CONTENT_PROJECTION = { Video.Media.DATA, Video.Media.DISPLAY_NAME, Video.Media.MIME_TYPE,
-                Video.Media.SIZE };
+        String[] CONTENT_PROJECTION = {Video.Media.DATA, Video.Media.DISPLAY_NAME, Video.Media.MIME_TYPE,
+                Video.Media.SIZE};
         c = context.getContentResolver().query(intent.getData(), CONTENT_PROJECTION, null, null, null);
         if (!c.moveToFirst()) {
             Log_OC.e(TAG, "Couldn't resolve given uri: " + intent.getDataString());
             return;
-        } 
+        }
         file_path = c.getString(c.getColumnIndex(Video.Media.DATA));
         file_name = c.getString(c.getColumnIndex(Video.Media.DISPLAY_NAME));
         mime_type = c.getString(c.getColumnIndex(Video.Media.MIME_TYPE));
@@ -164,7 +164,8 @@ public class InstantUploadBroadcastReceiver extends BroadcastReceiver {
         Log_OC.d(TAG, file_path + "");
 
         int behaviour = getUploadBehaviour(context);
-        FileUploader.uploadNewFile(context, account, file_path, FileStorageUtils.getInstantUploadFilePath(context, file_name), behaviour, mime_type, true, instantPictureUploadViaWiFiOnly(context));
+        FileUploader.uploadNewFile(context, account, file_path, FileStorageUtils.getInstantUploadFilePath(context,
+                file_name), behaviour, mime_type, true, instantPictureUploadViaWiFiOnly(context));
     }
 
     public static boolean instantPictureUploadEnabled(Context context) {
@@ -178,7 +179,7 @@ public class InstantUploadBroadcastReceiver extends BroadcastReceiver {
     public static boolean instantPictureUploadViaWiFiOnly(Context context) {
         return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("instant_upload_on_wifi", false);
     }
-    
+
     public static boolean instantVideoUploadViaWiFiOnly(Context context) {
         return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("instant_video_upload_on_wifi", false);
     }

+ 58 - 52
src/com/owncloud/android/files/services/FileUploader.java

@@ -1,25 +1,24 @@
 /**
- *   ownCloud Android client application
- *
- *   @author Bartek Przybylski
- *   @authro masensio
- *   @author LukeOwnCloud
- *   @author David A. Velasco
- *   Copyright (C) 2012 Bartek Przybylski
- *   Copyright (C) 2012-2016 ownCloud Inc.
- *
- *   This program is free software: you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License version 2,
- *   as published by the Free Software Foundation.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ * ownCloud Android client application
  *
+ * @author Bartek Przybylski
+ * @authro masensio
+ * @author LukeOwnCloud
+ * @author David A. Velasco
+ * Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2012-2016 ownCloud Inc.
+ * <p/>
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2,
+ * as published by the Free Software Foundation.
+ * <p/>
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * <p/>
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
 package com.owncloud.android.files.services;
@@ -262,7 +261,7 @@ public class FileUploader extends Service
         Log_OC.d(TAG, "FileUploader.retry()");
         Intent i = new Intent(context, FileUploader.class);
         i.putExtra(FileUploader.KEY_RETRY, true);
-        if(upload!= null) {
+        if (upload != null) {
             i.putExtra(FileUploader.KEY_ACCOUNT, account);
             i.putExtra(FileUploader.KEY_RETRY_UPLOAD, upload);
         }
@@ -272,7 +271,8 @@ public class FileUploader extends Service
     /**
      * Call to upload a new file. Main method.
      */
-    public static void uploadNewFile(Context context, Account account, String[] localPaths, String[] remotePaths, Integer behaviour, String mimeType, Boolean createRemoteFolder, Boolean wifiOnly) {
+    public static void uploadNewFile(Context context, Account account, String[] localPaths, String[] remotePaths,
+                                     Integer behaviour, String mimeType, Boolean createRemoteFolder, Boolean wifiOnly) {
         Log_OC.d(TAG, "FileUploader.uploadNewFile()");
         Intent intent = new Intent(context, FileUploader.class);
 
@@ -295,7 +295,8 @@ public class FileUploader extends Service
     /**
      * Call to upload multiple new files from the FileDisplayActivity
      */
-    public static void uploadNewFile(Context context, Account account, String[] localPaths, String[] remotePaths, int behaviour) {
+    public static void uploadNewFile(Context context, Account account, String[] localPaths, String[] remotePaths, int
+            behaviour) {
 
         uploadNewFile(context, account, localPaths, remotePaths, behaviour, null, null, null);
     }
@@ -303,9 +304,11 @@ public class FileUploader extends Service
     /**
      * Call to upload a new single file from the FileDisplayActivity
      */
-    public static void uploadNewFile(Context context, String localPath, String remotePath, int resultCode, String mimeType) {
+    public static void uploadNewFile(Context context, String localPath, String remotePath, int resultCode, String
+            mimeType) {
 
-        uploadNewFile(context, null, new String[]{localPath}, new String[]{remotePath}, resultCode, mimeType, null, null);
+        uploadNewFile(context, null, new String[]{localPath}, new String[]{remotePath}, resultCode, mimeType, null,
+                null);
     }
 
     /**
@@ -327,7 +330,8 @@ public class FileUploader extends Service
     /**
      * Call to upload a new single file from the Instant Upload Broadcast Receiver
      */
-    public static void uploadNewFile(Context context, Account account, String localPath, String remotePath, int behaviour, String mimeType, boolean createRemoteFile, boolean wifiOnly) {
+    public static void uploadNewFile(Context context, Account account, String localPath, String remotePath, int
+            behaviour, String mimeType, boolean createRemoteFile, boolean wifiOnly) {
 
         uploadNewFile(context, account, new String[]{localPath}, new String[]{remotePath}, behaviour, mimeType,
                 createRemoteFile, wifiOnly);
@@ -336,7 +340,8 @@ public class FileUploader extends Service
     /**
      * Call to update a file already uploaded from the ConflictsResolveActivity
      */
-    public static void uploadUpdate(Context context, Account account, OCFile[] existingFiles, Integer behaviour, Boolean forceOverwrite) {
+    public static void uploadUpdate(Context context, Account account, OCFile[] existingFiles, Integer behaviour,
+                                    Boolean forceOverwrite) {
         Log_OC.d(TAG, "FileUploader.uploadUpdate()");
         Intent intent = new Intent(context, FileUploader.class);
 
@@ -351,7 +356,8 @@ public class FileUploader extends Service
     /**
      * Call to update a file already uploaded from the ConflictsResolveActivity
      */
-    public static void uploadUpdate(Context context, Account account, OCFile existingFile, Integer behaviour, Boolean forceOverwrite) {
+    public static void uploadUpdate(Context context, Account account, OCFile existingFile, Integer behaviour, Boolean
+            forceOverwrite) {
 
         uploadUpdate(context, account, new OCFile[]{existingFile}, behaviour, forceOverwrite);
     }
@@ -457,7 +463,7 @@ public class FileUploader extends Service
         boolean chunked = FileUploader.chunkedUploadIsSupported(ocv);
 
         if (!retry) {
-            if ( !(intent.hasExtra(KEY_LOCAL_FILE) ||
+            if (!(intent.hasExtra(KEY_LOCAL_FILE) ||
                     intent.hasExtra(KEY_FILE))) {
                 Log_OC.e(TAG, "Not enough information provided in intent");
                 return Service.START_NOT_STICKY;
@@ -585,7 +591,8 @@ public class FileUploader extends Service
                 return START_NOT_STICKY;
 
             }
-            // *** TODO REWRITE: block inserted to request retries in a raw; too many code copied, no control exception ***/
+            // *** TODO REWRITE: block inserted to request retries in a raw; too many code copied, no control
+            // exception ***/
         } else {
             if (!intent.hasExtra(KEY_ACCOUNT) || !intent.hasExtra(KEY_RETRY_UPLOAD)) {
                 Log_OC.e(TAG, "Not enough information provided in intent: no KEY_RETRY_UPLOAD_KEY");
@@ -648,7 +655,7 @@ public class FileUploader extends Service
      */
     @Override
     public boolean onUnbind(Intent intent) {
-        ((FileUploaderBinder)mBinder).clearListeners();
+        ((FileUploaderBinder) mBinder).clearListeners();
         return false;   // not accepting rebinding (default behaviour)
     }
 
@@ -696,7 +703,7 @@ public class FileUploader extends Service
                 if (mCurrentUpload != null && mCurrentAccount != null &&
                         mCurrentUpload.isUploadInProgress() &&  // TODO added with reliale_uploads, to check
                         mCurrentUpload.getRemotePath().startsWith(file.getRemotePath()) &&
-                        account.name.equals(mCurrentAccount.name) ) {
+                        account.name.equals(mCurrentAccount.name)) {
                     Log_OC.d(TAG, "Calling cancel for " + file.getRemotePath() + " during upload operation.");
                     mCurrentUpload.cancel();
 //            } else if(mCancellationPossible.get()){
@@ -741,24 +748,25 @@ public class FileUploader extends Service
             Pair<UploadFileOperation, String> removeResult = mPendingUploads.remove(account, file.getRemotePath());
             UploadFileOperation upload = removeResult.first;
             //OCUpload upload = mPendingUploads.remove(buildRemoteName(account, file));
-            if(upload == null) {
+            if (upload == null) {
                 Log_OC.e(TAG, "Could not delete upload " + file + " from mPendingUploads.");
             }
             int d = mUploadsStorageManager.removeUpload(upload.getStoragePath());
-            if(d == 0) {
-                Log_OC.e(TAG, "Could not delete upload "+ file.getStoragePath() +" from database.");
+            if (d == 0) {
+                Log_OC.e(TAG, "Could not delete upload " + file.getStoragePath() + " from database.");
             }
         }
 
         public void remove(OCUpload upload) {
             int d = mUploadsStorageManager.removeUpload(upload.getUploadId());
-            if(d == 0) {
-                Log_OC.e(TAG, "Could not delete upload "+ upload.getRemotePath() +" from database.");
+            if (d == 0) {
+                Log_OC.e(TAG, "Could not delete upload " + upload.getRemotePath() + " from database.");
             }
         }
 
         // TODO: Review: Method from FileUploader with some changes because the merge with FileUploader
         // TODO Complete operation to retry the upload
+
         /**
          * Puts upload in upload list and tell FileUploader to upload items in list.
          */
@@ -800,15 +808,14 @@ public class FileUploader extends Service
          * @param account       ownCloud account holding the file of interest.
          * @param file          {@link OCFile} of interest for listener.
          */
-        public void addDatatransferProgressListener (OnDatatransferProgressListener listener,
-                                                     Account account, OCFile file) {
+        public void addDatatransferProgressListener(OnDatatransferProgressListener listener,
+                                                    Account account, OCFile file) {
             if (account == null || file == null || listener == null) return;
             String targetKey = buildRemoteName(account, file);
             mBoundListeners.put(targetKey, listener);
         }
 
 
-
         /**
          * Removes a listener interested in the progress of the upload for a concrete file.
          *
@@ -816,8 +823,8 @@ public class FileUploader extends Service
          * @param account       ownCloud account holding the file of interest.
          * @param file          {@link OCFile} of interest for listener.
          */
-        public void removeDatatransferProgressListener (OnDatatransferProgressListener listener,
-                                                        Account account, OCFile file) {
+        public void removeDatatransferProgressListener(OnDatatransferProgressListener listener,
+                                                       Account account, OCFile file) {
             if (account == null || file == null || listener == null) return;
             String targetKey = buildRemoteName(account, file);
             if (mBoundListeners.get(targetKey) == listener) {
@@ -846,7 +853,7 @@ public class FileUploader extends Service
          *
          * @param account       ownCloud account where the file to upload belongs.
          * @param file          File to upload
-         * @return              Key
+         * @return Key
          */
         private String buildRemoteName(Account account, OCFile file) {
             return account.name + file.getRemotePath();
@@ -1001,7 +1008,7 @@ public class FileUploader extends Service
      * create it both remote and locally.
      *
      *  @param  pathToGrant     Full remote path whose existence will be granted.
-     *  @return  An {@link OCFile} instance corresponding to the folder where the file
+     *  @return An {@link OCFile} instance corresponding to the folder where the file
      *  will be uploaded.
      */
     private RemoteOperationResult grantFolderExistence(String pathToGrant) {
@@ -1009,7 +1016,7 @@ public class FileUploader extends Service
         RemoteOperationResult result = operation.execute(mUploadClient);
         if (!result.isSuccess() && result.getCode() == ResultCode.FILE_NOT_FOUND &&
                 mCurrentUpload.isRemoteFolderToBeCreated()) {
-            SyncOperation syncOp = new CreateFolderOperation( pathToGrant, true);
+            SyncOperation syncOp = new CreateFolderOperation(pathToGrant, true);
             result = syncOp.execute(mUploadClient, mStorageManager);
         }
         if (result.isSuccess()) {
@@ -1122,7 +1129,7 @@ public class FileUploader extends Service
             mimeType = "application/octet-stream";
         }
 
-        if (isPdfFileFromContentProviderWithoutExtension(localPath, mimeType)){
+        if (isPdfFileFromContentProviderWithoutExtension(localPath, mimeType)) {
             remotePath += FILE_EXTENSION_PDF;
         }
 
@@ -1162,7 +1169,8 @@ public class FileUploader extends Service
                 .setContentTitle(getString(R.string.uploader_upload_in_progress_ticker))
                 .setProgress(100, 0, false)
                 .setContentText(
-                        String.format(getString(R.string.uploader_upload_in_progress_content), 0, upload.getFileName()));
+                        String.format(getString(R.string.uploader_upload_in_progress_content), 0, upload.getFileName
+                                ()));
 
         /// includes a pending intent in the notification showing the details
         Intent showUploadListIntent = new Intent(this, UploadListActivity.class);
@@ -1239,7 +1247,7 @@ public class FileUploader extends Service
                     .setOngoing(false)
                     .setProgress(0, 0, false);
 
-            content =  ErrorMessageAdapter.getErrorCauseMessage(
+            content = ErrorMessageAdapter.getErrorCauseMessage(
                     uploadResult, upload, getResources()
             );
 
@@ -1296,7 +1304,7 @@ public class FileUploader extends Service
 //                }
             }
 
-            if(!uploadResult.isSuccess()){
+            if (!uploadResult.isSuccess()) {
                 //in case of failure, do not show details file view (because there is no file!)
                 Intent showUploadListIntent = new Intent(this, UploadListActivity.class);
                 showUploadListIntent.putExtra(FileActivity.EXTRA_FILE, upload.getFile());
@@ -1395,7 +1403,7 @@ public class FileUploader extends Service
      *
      * @param account       Downloads account to remove
      */
-    private void cancelUploadsForAccount(Account account){
+    private void cancelUploadsForAccount(Account account) {
         // Cancel pending uploads
         mPendingUploads.remove(account);
     }
@@ -1408,6 +1416,4 @@ public class FileUploader extends Service
 //    }
 
 
-
-
 }

+ 56 - 57
src/com/owncloud/android/operations/SynchronizeFileOperation.java

@@ -1,23 +1,22 @@
 /**
- *   ownCloud Android client application
- *
- *   @author David A. Velasco
- *   @author masensio
- *   Copyright (C) 2012 Bartek Przybylski
- *   Copyright (C) 2015 ownCloud Inc.
- *
- *   This program is free software: you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License version 2,
- *   as published by the Free Software Foundation.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ * ownCloud Android client application
  *
+ * @author David A. Velasco
+ * @author masensio
+ * Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2015 ownCloud Inc.
+ * <p/>
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2,
+ * as published by the Free Software Foundation.
+ * <p/>
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * <p/>
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
 package com.owncloud.android.operations;
@@ -46,44 +45,44 @@ import com.owncloud.android.utils.FileStorageUtils;
 public class SynchronizeFileOperation extends SyncOperation {
 
     private String TAG = SynchronizeFileOperation.class.getSimpleName();
-    
+
     private OCFile mLocalFile;
     private String mRemotePath;
     private OCFile mServerFile;
     private Account mAccount;
     private boolean mSyncFileContents;
     private Context mContext;
-    
+
     private boolean mTransferWasRequested = false;
 
-    /** 
+    /**
      * When 'false', uploads to the server are not done; only downloads or conflict detection.  
      * This is a temporal field. 
      * TODO Remove when 'folder synchronization' replaces 'folder download'.
-     */    
+     */
     private boolean mAllowUploads;
 
-    
+
     /**
      * Constructor for "full synchronization mode".
-     * 
+     *
      * Uses remotePath to retrieve all the data both in local cache and in the remote OC server
      * when the operation is executed, instead of reusing {@link OCFile} instances.
-     * 
+     *
      * Useful for direct synchronization of a single file.
-     * 
-     * @param 
+     *
+     * @param
      * @param account               ownCloud account holding the file.
      * @param syncFileContents      When 'true', transference of data will be started by the 
      *                              operation if needed and no conflict is detected.
      * @param context               Android context; needed to start transfers.
      */
     public SynchronizeFileOperation(
-            String remotePath,  
-            Account account, 
+            String remotePath,
+            Account account,
             boolean syncFileContents,
             Context context) {
-        
+
         mRemotePath = remotePath;
         mLocalFile = null;
         mServerFile = null;
@@ -93,18 +92,18 @@ public class SynchronizeFileOperation extends SyncOperation {
         mAllowUploads = true;
     }
 
-    
+
     /**
      * Constructor allowing to reuse {@link OCFile} instances just queried from local cache or
      * from remote OC server.
-     * 
+     *
      * Useful to include this operation as part of the synchronization of a folder
      * (or a full account), avoiding the repetition of fetch operations (both in local database
      * or remote server).
-     * 
+     *
      * At least one of localFile or serverFile MUST NOT BE NULL. If you don't have none of them,
      * use the other constructor.
-     * 
+     *
      * @param localFile             Data of file (just) retrieved from local cache/database.
      * @param serverFile            Data of file (just) retrieved from a remote server. If null,
      *                              will be retrieved from network by the operation when executed.
@@ -115,11 +114,11 @@ public class SynchronizeFileOperation extends SyncOperation {
      */
     public SynchronizeFileOperation(
             OCFile localFile,
-            OCFile serverFile, 
-            Account account, 
+            OCFile serverFile,
+            Account account,
             boolean syncFileContents,
             Context context) {
-        
+
         mLocalFile = localFile;
         mServerFile = serverFile;
         if (mLocalFile != null) {
@@ -138,19 +137,19 @@ public class SynchronizeFileOperation extends SyncOperation {
         mContext = context;
         mAllowUploads = true;
     }
-    
+
 
     /**
      * Temporal constructor.
-     * 
+     *
      * Extends the previous one to allow constrained synchronizations where uploads are never
      * performed - only downloads or conflict detection.
-     * 
+     *
      * Do not use unless you are involved in 'folder synchronization' or 'folder download' work
      * in progress.
-     * 
+     *
      * TODO Remove when 'folder synchronization' replaces 'folder download'.
-     * 
+     *
      * @param localFile             Data of file (just) retrieved from local cache/database.
      *                              MUSTN't be null.
      * @param serverFile            Data of file (just) retrieved from a remote server.
@@ -165,28 +164,28 @@ public class SynchronizeFileOperation extends SyncOperation {
      */
     public SynchronizeFileOperation(
             OCFile localFile,
-            OCFile serverFile, 
-            Account account, 
+            OCFile serverFile,
+            Account account,
             boolean syncFileContents,
-            boolean allowUploads, 
+            boolean allowUploads,
             Context context) {
-        
+
         this(localFile, serverFile, account, syncFileContents, context);
         mAllowUploads = allowUploads;
     }
-    
+
 
     @Override
     protected RemoteOperationResult run(OwnCloudClient client) {
 
         RemoteOperationResult result = null;
         mTransferWasRequested = false;
-        
+
         if (mLocalFile == null) {
             // Get local file from the DB
             mLocalFile = getStorageManager().getFileByPath(mRemotePath);
         }
-        
+
         if (!mLocalFile.isDown()) {
             /// easy decision
             requestForDownload(mLocalFile);
@@ -198,13 +197,13 @@ public class SynchronizeFileOperation extends SyncOperation {
             if (mServerFile == null) {
                 ReadRemoteFileOperation operation = new ReadRemoteFileOperation(mRemotePath);
                 result = operation.execute(client);
-                if (result.isSuccess()){
+                if (result.isSuccess()) {
                     mServerFile = FileStorageUtils.fillOCFile((RemoteFile) result.getData().get(0));
                     mServerFile.setLastSyncDateForProperties(System.currentTimeMillis());
                 }
             }
 
-            if (mServerFile != null) {   
+            if (mServerFile != null) {
 
                 /// check changes in server and local file
                 boolean serverChanged = false;
@@ -216,7 +215,7 @@ public class SynchronizeFileOperation extends SyncOperation {
                     serverChanged = (!mServerFile.getEtag().equals(mLocalFile.getEtag()));
                 }
                 boolean localChanged = (
-                    mLocalFile.getLocalModificationTimestamp() > mLocalFile.getLastSyncDateForData()
+                        mLocalFile.getLocalModificationTimestamp() > mLocalFile.getLastSyncDateForData()
                 );
 
                 /// decide action to perform depending upon changes
@@ -241,7 +240,7 @@ public class SynchronizeFileOperation extends SyncOperation {
 
                 } else if (serverChanged) {
                     mLocalFile.setRemoteId(mServerFile.getRemoteId());
-                    
+
                     if (mSyncFileContents) {
                         requestForDownload(mLocalFile); // local, not server; we won't to keep
                         // the value of favorite!
@@ -278,10 +277,10 @@ public class SynchronizeFileOperation extends SyncOperation {
         return result;
     }
 
-    
+
     /**
      * Requests for an upload to the FileUploader service
-     * 
+     *
      * @param file     OCFile object representing the file to upload
      */
     private void requestForUpload(OCFile file) {
@@ -294,13 +293,13 @@ public class SynchronizeFileOperation extends SyncOperation {
 
     /**
      * Requests for a download to the FileDownloader service
-     * 
+     *
      * @param file     OCFile object representing the file to download
      */
     private void requestForDownload(OCFile file) {
         Intent i = new Intent(mContext, FileDownloader.class);
         i.putExtra(FileDownloader.EXTRA_ACCOUNT, mAccount);
-        i.putExtra(FileDownloader.EXTRA_FILE, (Parcelable)file);
+        i.putExtra(FileDownloader.EXTRA_FILE, (Parcelable) file);
         mContext.startService(i);
         mTransferWasRequested = true;
     }

+ 24 - 25
src/com/owncloud/android/ui/activity/ConflictsResolveActivity.java

@@ -1,23 +1,22 @@
 /**
- *   ownCloud Android client application
- *
- *   @author Bartek Przybylski
- *   @author David A. Velasco
- *   Copyright (C) 2012 Bartek Przybylski
- *   Copyright (C) 2015 ownCloud Inc.
- *
- *   This program is free software: you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License version 2,
- *   as published by the Free Software Foundation.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ * ownCloud Android client application
  *
+ * @author Bartek Przybylski
+ * @author David A. Velasco
+ * Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2015 ownCloud Inc.
+ * <p/>
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2,
+ * as published by the Free Software Foundation.
+ * <p/>
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * <p/>
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
 package com.owncloud.android.ui.activity;
@@ -41,7 +40,7 @@ import com.owncloud.android.ui.dialog.ConflictsResolveDialog.OnConflictDecisionM
 public class ConflictsResolveActivity extends FileActivity implements OnConflictDecisionMadeListener {
 
     private String TAG = ConflictsResolveActivity.class.getSimpleName();
-    
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -49,7 +48,6 @@ public class ConflictsResolveActivity extends FileActivity implements OnConflict
 
     @Override
     public void conflictDecisionMade(Decision decision) {
-        Intent i = new Intent(getApplicationContext(), FileUploader.class);
 
         Integer behaviour = null;
         Boolean forceOverwrite = null;
@@ -78,7 +76,7 @@ public class ConflictsResolveActivity extends FileActivity implements OnConflict
                 return;
         }
 
-        FileUploader.uploadUpdate(getApplicationContext(), getAccount(), getFile(), behaviour, forceOverwrite);
+        FileUploader.uploadUpdate(this, getAccount(), getFile(), behaviour, forceOverwrite);
         finish();
     }
 
@@ -92,21 +90,22 @@ public class ConflictsResolveActivity extends FileActivity implements OnConflict
                 finish();
             } else {
                 /// Check whether the 'main' OCFile handled by the Activity is contained in the current Account
-                file = getStorageManager().getFileByPath(file.getRemotePath());   // file = null if not in the current Account
+                file = getStorageManager().getFileByPath(file.getRemotePath());   // file = null if not in the
+                // current Account
                 if (file != null) {
                     setFile(file);
                     ConflictsResolveDialog d = ConflictsResolveDialog.newInstance(file.getRemotePath(), this);
                     d.showDialog(this);
-                    
+
                 } else {
                     // account was changed to a different one - just finish
                     finish();
                 }
             }
-            
+
         } else {
             finish();
         }
-        
+
     }
 }

+ 81 - 79
src/com/owncloud/android/ui/activity/FileDisplayActivity.java

@@ -1,23 +1,22 @@
 /**
- *   ownCloud Android client application
- *
- *   @author Bartek Przybylski
- *   @author David A. Velasco
- *   Copyright (C) 2011  Bartek Przybylski
- *   Copyright (C) 2015 ownCloud Inc.
- *
- *   This program is free software: you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License version 2,
- *   as published by the Free Software Foundation.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ * ownCloud Android client application
  *
+ * @author Bartek Przybylski
+ * @author David A. Velasco
+ * Copyright (C) 2011  Bartek Przybylski
+ * Copyright (C) 2015 ownCloud Inc.
+ * <p/>
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2,
+ * as published by the Free Software Foundation.
+ * <p/>
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * <p/>
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
 package com.owncloud.android.ui.activity;
@@ -153,7 +152,7 @@ public class FileDisplayActivity extends HookActivity implements
         Log_OC.v(TAG, "onCreate() start");
 
         super.onCreate(savedInstanceState); // this calls onAccountChanged() when ownCloud Account
-                                            // is valid
+        // is valid
 
         /// grant that FileObserverService is watching favorite files
         if (savedInstanceState == null) {
@@ -162,7 +161,7 @@ public class FileDisplayActivity extends HookActivity implements
         }
 
         /// Load of saved instance state
-        if(savedInstanceState != null) {
+        if (savedInstanceState != null) {
             mWaitingToPreview = (OCFile) savedInstanceState.getParcelable(
                     FileDisplayActivity.KEY_WAITING_TO_PREVIEW);
             mSyncInProgress = savedInstanceState.getBoolean(KEY_SYNC_IN_PROGRESS);
@@ -196,8 +195,8 @@ public class FileDisplayActivity extends HookActivity implements
 
         // Action bar setup
         getSupportActionBar().setHomeButtonEnabled(true);       // mandatory since Android ICS,
-                                                                // according to the official
-                                                                // documentation
+        // according to the official
+        // documentation
 
         // enable ActionBar app icon to behave as action to toggle nav drawer
         //getSupportActionBar().setDisplayHomeAsUpEnabled(true);
@@ -250,7 +249,7 @@ public class FileDisplayActivity extends HookActivity implements
                     // cache until the upload is successful get parent from path
                     parentPath = file.getRemotePath().substring(0,
                             file.getRemotePath().lastIndexOf(file.getFileName()));
-                    if (getStorageManager().getFileByPath(parentPath) ==  null)
+                    if (getStorageManager().getFileByPath(parentPath) == null)
                         file = null; // not able to know the directory where the file is uploading
                 } else {
                     file = getStorageManager().getFileByPath(file.getRemotePath());
@@ -341,8 +340,8 @@ public class FileDisplayActivity extends HookActivity implements
             } else if (file.isDown() && PreviewTextFragment.canBePreviewed(file)) {
                 secondFragment = null;
             } else {
-            secondFragment = FileDetailFragment.newInstance(file, getAccount());
-        }
+                secondFragment = FileDetailFragment.newInstance(file, getAccount());
+            }
         }
         return secondFragment;
     }
@@ -455,7 +454,7 @@ public class FileDisplayActivity extends HookActivity implements
                     if (success) {
                         mWaitingToPreview = getStorageManager().getFileById(
                                 mWaitingToPreview.getFileId());   // update the file from database,
-                                                                  // for the local storage path
+                        // for the local storage path
                         if (PreviewMediaFragment.canBePreviewed(mWaitingToPreview)) {
                             startMediaPreview(mWaitingToPreview, 0, true);
                             detailsFragmentChanged = true;
@@ -493,7 +492,7 @@ public class FileDisplayActivity extends HookActivity implements
         inflater.inflate(R.menu.main_menu, menu);
         return true;
     }
-    
+
 
     @Override
     public boolean onOptionsItemSelected(MenuItem item) {
@@ -521,7 +520,7 @@ public class FileDisplayActivity extends HookActivity implements
                 OCFile currentDir = getCurrentDir();
                 if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
                     mDrawerLayout.closeDrawer(GravityCompat.START);
-                } else if((currentDir != null && currentDir.getParentId() != 0) ||
+                } else if ((currentDir != null && currentDir.getParentId() != 0) ||
                         (second != null && second.getFile() != null)) {
                     onBackPressed();
 
@@ -540,26 +539,26 @@ public class FileDisplayActivity extends HookActivity implements
 
                 AlertDialog.Builder builder = new AlertDialog.Builder(this);
                 builder.setTitle(R.string.actionbar_sort_title)
-                        .setSingleChoiceItems(R.array.actionbar_sortby, sortOrder ,
+                        .setSingleChoiceItems(R.array.actionbar_sortby, sortOrder,
                                 new DialogInterface.OnClickListener() {
-                            public void onClick(DialogInterface dialog, int which) {
-                                switch (which){
-                                    case 0:
-                                        sortByName(true);
-                                        break;
-                                    case 1:
-                                        sortByDate(false);
-                                        break;
-                                }
-
-                                dialog.dismiss();
-                            }
-                        });
+                                    public void onClick(DialogInterface dialog, int which) {
+                                        switch (which) {
+                                            case 0:
+                                                sortByName(true);
+                                                break;
+                                            case 1:
+                                                sortByDate(false);
+                                                break;
+                                        }
+
+                                        dialog.dismiss();
+                                    }
+                                });
                 builder.create().show();
                 break;
             }
-            case R.id.action_switch_view:{
-                if (isGridView()){
+            case R.id.action_switch_view: {
+                if (isGridView()) {
                     item.setTitle(getString(R.string.action_switch_grid_view));
                     item.setIcon(ContextCompat.getDrawable(getApplicationContext(),
                             R.drawable.ic_view_module));
@@ -572,8 +571,8 @@ public class FileDisplayActivity extends HookActivity implements
                 }
                 return true;
             }
-        default:
-            retval = super.onOptionsItemSelected(item);
+            default:
+                retval = super.onOptionsItemSelected(item);
         }
         return retval;
     }
@@ -626,7 +625,7 @@ public class FileDisplayActivity extends HookActivity implements
                     data.getClipData() != null &&
                     data.getClipData().getItemCount() > 0) {
 
-                for( int i = 0; i < data.getClipData().getItemCount(); i++){
+                for (int i = 0; i < data.getClipData().getItemCount(); i++) {
                     Intent intent = new Intent();
                     intent.setData(data.getClipData().getItemAt(i).getUri());
                     requestSimpleUpload(intent, resultCode);
@@ -639,7 +638,7 @@ public class FileDisplayActivity extends HookActivity implements
                 resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)) {
             requestMultipleUpload(data, resultCode);
 
-        } else if (requestCode == ACTION_MOVE_FILES && resultCode == RESULT_OK){
+        } else if (requestCode == ACTION_MOVE_FILES && resultCode == RESULT_OK) {
             final Intent fData = data;
             final int fResultCode = resultCode;
             getHandler().postDelayed(
@@ -677,11 +676,11 @@ public class FileDisplayActivity extends HookActivity implements
         if (filePaths != null) {
             String[] remotePaths = new String[filePaths.length];
             String remotePathBase = getCurrentDir().getRemotePath();
-            for (int j = 0; j< remotePaths.length; j++) {
+            for (int j = 0; j < remotePaths.length; j++) {
                 remotePaths[j] = remotePathBase + (new File(filePaths[j])).getName();
             }
 
-            FileUploader.uploadNewFile(getApplicationContext(), getAccount(), filePaths, remotePaths, resultCode);
+            FileUploader.uploadNewFile(this, getAccount(), filePaths, remotePaths, resultCode);
 
         } else {
             Log_OC.d(TAG, "User clicked on 'Update' with no selection");
@@ -730,7 +729,7 @@ public class FileDisplayActivity extends HookActivity implements
         i.putExtra(FileUploader.KEY_ACCOUNT,
                 getAccount());
         OCFile currentDir = getCurrentDir();
-        String remotePath =  (currentDir != null) ? currentDir.getRemotePath() : OCFile.ROOT_PATH;
+        String remotePath = (currentDir != null) ? currentDir.getRemotePath() : OCFile.ROOT_PATH;
 
         if (filePath.startsWith(UriUtils.URI_CONTENT_SCHEME)) {
             Cursor cursor = getContentResolver().query(Uri.parse(filePath), null, null, null, null);
@@ -738,7 +737,7 @@ public class FileDisplayActivity extends HookActivity implements
                 if (cursor != null && cursor.moveToFirst()) {
                     String displayName = cursor.getString(cursor.getColumnIndex(
                             OpenableColumns.DISPLAY_NAME));
-                    Log_OC.v(TAG, "Display Name: " + displayName );
+                    Log_OC.v(TAG, "Display Name: " + displayName);
 
                     displayName.replace(File.separatorChar, '_');
                     displayName.replace(File.pathSeparatorChar, '_');
@@ -754,7 +753,7 @@ public class FileDisplayActivity extends HookActivity implements
             remotePath += new File(filePath).getName();
         }
 
-        FileUploader.uploadNewFile(getApplicationContext(), filePath, remotePath, resultCode, mimeType);
+        FileUploader.uploadNewFile(this, filePath, remotePath, resultCode, mimeType);
 
     }
 
@@ -784,7 +783,7 @@ public class FileDisplayActivity extends HookActivity implements
 
     @Override
     public void onBackPressed() {
-        if (!isDrawerOpen()){
+        if (!isDrawerOpen()) {
             OCFileListFragment listOfFiles = getListOfFilesFragment();
             if (mDualPane || getSecondFragment() == null) {
                 OCFile currentDir = getCurrentDir();
@@ -895,7 +894,7 @@ public class FileDisplayActivity extends HookActivity implements
                 String synchFolderRemotePath =
                         intent.getStringExtra(FileSyncAdapter.EXTRA_FOLDER_PATH);
                 RemoteOperationResult synchResult =
-                        (RemoteOperationResult)intent.getSerializableExtra(
+                        (RemoteOperationResult) intent.getSerializableExtra(
                                 FileSyncAdapter.EXTRA_RESULT);
                 boolean sameAccount = (getAccount() != null &&
                         accountName.equals(getAccount().name) && getStorageManager() != null);
@@ -910,17 +909,17 @@ public class FileDisplayActivity extends HookActivity implements
                                 getStorageManager().getFileByPath(getFile().getRemotePath());
                         OCFile currentDir = (getCurrentDir() == null) ? null :
                                 getStorageManager().getFileByPath(getCurrentDir().getRemotePath());
-    
+
                         if (currentDir == null) {
                             // current folder was removed from the server 
-                            Toast.makeText( FileDisplayActivity.this, 
-                                            String.format(
-                                                    getString(R.string.
-                                                            sync_current_folder_was_removed),
-                                                   synchFolderRemotePath),
+                            Toast.makeText(FileDisplayActivity.this,
+                                    String.format(
+                                            getString(R.string.
+                                                    sync_current_folder_was_removed),
+                                            synchFolderRemotePath),
 
-                                            Toast.LENGTH_LONG)
-                                .show();
+                                    Toast.LENGTH_LONG)
+                                    .show();
 
                             browseToRoot();
 
@@ -948,9 +947,9 @@ public class FileDisplayActivity extends HookActivity implements
                         mSyncInProgress = (!FileSyncAdapter.EVENT_FULL_SYNC_END.equals(event) &&
                                 !RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED
                                         .equals(event));
-                                
+
                         if (RefreshFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED.
-                                    equals(event) &&/// TODO refactor and make common
+                                equals(event) &&/// TODO refactor and make common
 
                                 synchResult != null && !synchResult.isSuccess() &&
                                 (synchResult.getCode() == ResultCode.UNAUTHORIZED ||
@@ -1148,17 +1147,17 @@ public class FileDisplayActivity extends HookActivity implements
         private boolean isDescendant(String downloadedRemotePath) {
             OCFile currentDir = getCurrentDir();
             return (
-                currentDir != null &&
-                downloadedRemotePath != null &&
-                downloadedRemotePath.startsWith(currentDir.getRemotePath())
+                    currentDir != null &&
+                            downloadedRemotePath != null &&
+                            downloadedRemotePath.startsWith(currentDir.getRemotePath())
             );
         }
 
         private boolean isAscendant(String linkedToRemotePath) {
             OCFile currentDir = getCurrentDir();
             return (
-                currentDir != null &&
-                currentDir.getRemotePath().startsWith(linkedToRemotePath)
+                    currentDir != null &&
+                            currentDir.getRemotePath().startsWith(linkedToRemotePath)
             );
         }
 
@@ -1241,7 +1240,7 @@ public class FileDisplayActivity extends HookActivity implements
                 mDownloaderBinder = (FileDownloaderBinder) service;
                 if (mWaitingToPreview != null)
                     if (getStorageManager() != null) {
-                         // update the file
+                        // update the file
                         mWaitingToPreview =
                                 getStorageManager().getFileById(mWaitingToPreview.getFileId());
                         if (!mWaitingToPreview.isDown()) {
@@ -1381,7 +1380,7 @@ public class FileDisplayActivity extends HookActivity implements
                 setFile(getStorageManager().getFileById(removedFile.getParentId()));
                 cleanSecondFragment();
             }
-            if (getStorageManager().getFileById(removedFile.getParentId()).equals(getCurrentDir())){
+            if (getStorageManager().getFileById(removedFile.getParentId()).equals(getCurrentDir())) {
                 refreshListOfFilesFragment();
             }
             invalidateOptionsMenu();
@@ -1455,7 +1454,7 @@ public class FileDisplayActivity extends HookActivity implements
             FileFragment details = getSecondFragment();
             if (details != null) {
                 if (details instanceof FileDetailFragment &&
-                        renamedFile.equals(details.getFile()) ) {
+                        renamedFile.equals(details.getFile())) {
                     ((FileDetailFragment) details).updateFileDetails(renamedFile, getAccount());
                     showDetails(renamedFile);
 
@@ -1479,7 +1478,7 @@ public class FileDisplayActivity extends HookActivity implements
                 }
             }
 
-            if (getStorageManager().getFileById(renamedFile.getParentId()).equals(getCurrentDir())){
+            if (getStorageManager().getFileById(renamedFile.getParentId()).equals(getCurrentDir())) {
                 refreshListOfFilesFragment();
             }
 
@@ -1542,7 +1541,7 @@ public class FileDisplayActivity extends HookActivity implements
         refreshListOfFilesFragment();
         FileFragment details = getSecondFragment();
         if (details != null && details instanceof FileDetailFragment &&
-                file.equals(details.getFile()) ) {
+                file.equals(details.getFile())) {
             if (downloading || uploading) {
                 ((FileDetailFragment) details).updateFileDetails(file, getAccount());
             } else {
@@ -1793,9 +1792,12 @@ public class FileDisplayActivity extends HookActivity implements
     private void sortByName(boolean ascending) {
         getListOfFilesFragment().sortByName(ascending);
     }
-    private boolean isGridView(){ return getListOfFilesFragment().isGridView(); }
 
-   public void allFilesOption() {
-       browseToRoot();
-   }
+    private boolean isGridView() {
+        return getListOfFilesFragment().isGridView();
+    }
+
+    public void allFilesOption() {
+        browseToRoot();
+    }
 }

+ 193 - 195
src/com/owncloud/android/ui/activity/Uploader.java

@@ -1,23 +1,22 @@
 /**
- *   ownCloud Android client application
- *
- *   @author Bartek Przybylski
- *   @author masensio
- *   Copyright (C) 2012  Bartek Przybylski
- *   Copyright (C) 2015 ownCloud Inc.
- *
- *   This program is free software: you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License version 2,
- *   as published by the Free Software Foundation.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ * ownCloud Android client application
  *
+ * @author Bartek Przybylski
+ * @author masensio
+ * Copyright (C) 2012  Bartek Przybylski
+ * Copyright (C) 2015 ownCloud Inc.
+ * <p/>
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2,
+ * as published by the Free Software Foundation.
+ * <p/>
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * <p/>
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
 package com.owncloud.android.ui.activity;
@@ -109,7 +108,7 @@ public class Uploader extends FileActivity
 
     private ArrayList<String> mRemoteCacheData;
     private int mNumCacheFile;
-    
+
     private final static int DIALOG_NO_ACCOUNT = 0;
     private final static int DIALOG_WAITING = 1;
     private final static int DIALOG_NO_STREAM = 2;
@@ -188,7 +187,7 @@ public class Uploader extends FileActivity
 
     @Override
     protected void onSaveInstanceState(Bundle outState) {
-         Log_OC.d(TAG, "onSaveInstanceState() start");
+        Log_OC.d(TAG, "onSaveInstanceState() start");
         super.onSaveInstanceState(outState);
         outState.putSerializable(KEY_PARENTS, mParents);
         //outState.putParcelable(KEY_ACCOUNT, mAccount);
@@ -206,101 +205,101 @@ public class Uploader extends FileActivity
     protected Dialog onCreateDialog(final int id) {
         final AlertDialog.Builder builder = new Builder(this);
         switch (id) {
-        case DIALOG_WAITING:
-            final ProgressDialog pDialog = new ProgressDialog(this, R.style.ProgressDialogTheme);
-            pDialog.setIndeterminate(false);
-            pDialog.setCancelable(false);
-            pDialog.setMessage(getResources().getString(R.string.uploader_info_uploading));
-            pDialog.setOnShowListener(new DialogInterface.OnShowListener() {
-                @Override
-                public void onShow(DialogInterface dialog) {
-                    ProgressBar v = (ProgressBar) pDialog.findViewById(android.R.id.progress);
-                    v.getIndeterminateDrawable().setColorFilter(getResources().getColor(R.color.color_accent),
-                            android.graphics.PorterDuff.Mode.MULTIPLY);
+            case DIALOG_WAITING:
+                final ProgressDialog pDialog = new ProgressDialog(this, R.style.ProgressDialogTheme);
+                pDialog.setIndeterminate(false);
+                pDialog.setCancelable(false);
+                pDialog.setMessage(getResources().getString(R.string.uploader_info_uploading));
+                pDialog.setOnShowListener(new DialogInterface.OnShowListener() {
+                    @Override
+                    public void onShow(DialogInterface dialog) {
+                        ProgressBar v = (ProgressBar) pDialog.findViewById(android.R.id.progress);
+                        v.getIndeterminateDrawable().setColorFilter(getResources().getColor(R.color.color_accent),
+                                android.graphics.PorterDuff.Mode.MULTIPLY);
 
-                }
-            });
-            return pDialog;
-        case DIALOG_NO_ACCOUNT:
-            builder.setIcon(android.R.drawable.ic_dialog_alert);
-            builder.setTitle(R.string.uploader_wrn_no_account_title);
-            builder.setMessage(String.format(
-                    getString(R.string.uploader_wrn_no_account_text),
-                    getString(R.string.app_name)));
-            builder.setCancelable(false);
-            builder.setPositiveButton(R.string.uploader_wrn_no_account_setup_btn_text, new OnClickListener() {
-                @Override
-                public void onClick(DialogInterface dialog, int which) {
-                    if (android.os.Build.VERSION.SDK_INT >
-                            android.os.Build.VERSION_CODES.ECLAIR_MR1) {
-                        // using string value since in API7 this
-                        // constatn is not defined
-                        // in API7 < this constatant is defined in
-                        // Settings.ADD_ACCOUNT_SETTINGS
-                        // and Settings.EXTRA_AUTHORITIES
-                        Intent intent = new Intent(android.provider.Settings.ACTION_ADD_ACCOUNT);
-                        intent.putExtra("authorities", new String[] { MainApp.getAuthTokenType() });
-                        startActivityForResult(intent, REQUEST_CODE_SETUP_ACCOUNT);
-                    } else {
-                        // since in API7 there is no direct call for
-                        // account setup, so we need to
-                        // show our own AccountSetupAcricity, get
-                        // desired results and setup
-                        // everything for ourself
-                        Intent intent = new Intent(getBaseContext(), AccountAuthenticator.class);
-                        startActivityForResult(intent, REQUEST_CODE_SETUP_ACCOUNT);
                     }
+                });
+                return pDialog;
+            case DIALOG_NO_ACCOUNT:
+                builder.setIcon(android.R.drawable.ic_dialog_alert);
+                builder.setTitle(R.string.uploader_wrn_no_account_title);
+                builder.setMessage(String.format(
+                        getString(R.string.uploader_wrn_no_account_text),
+                        getString(R.string.app_name)));
+                builder.setCancelable(false);
+                builder.setPositiveButton(R.string.uploader_wrn_no_account_setup_btn_text, new OnClickListener() {
+                    @Override
+                    public void onClick(DialogInterface dialog, int which) {
+                        if (android.os.Build.VERSION.SDK_INT >
+                                android.os.Build.VERSION_CODES.ECLAIR_MR1) {
+                            // using string value since in API7 this
+                            // constatn is not defined
+                            // in API7 < this constatant is defined in
+                            // Settings.ADD_ACCOUNT_SETTINGS
+                            // and Settings.EXTRA_AUTHORITIES
+                            Intent intent = new Intent(android.provider.Settings.ACTION_ADD_ACCOUNT);
+                            intent.putExtra("authorities", new String[]{MainApp.getAuthTokenType()});
+                            startActivityForResult(intent, REQUEST_CODE_SETUP_ACCOUNT);
+                        } else {
+                            // since in API7 there is no direct call for
+                            // account setup, so we need to
+                            // show our own AccountSetupAcricity, get
+                            // desired results and setup
+                            // everything for ourself
+                            Intent intent = new Intent(getBaseContext(), AccountAuthenticator.class);
+                            startActivityForResult(intent, REQUEST_CODE_SETUP_ACCOUNT);
+                        }
+                    }
+                });
+                builder.setNegativeButton(R.string.uploader_wrn_no_account_quit_btn_text, new OnClickListener() {
+                    @Override
+                    public void onClick(DialogInterface dialog, int which) {
+                        finish();
+                    }
+                });
+                return builder.create();
+            case DIALOG_MULTIPLE_ACCOUNT:
+                CharSequence ac[] = new CharSequence[
+                        mAccountManager.getAccountsByType(MainApp.getAccountType()).length];
+                for (int i = 0; i < ac.length; ++i) {
+                    ac[i] = DisplayUtils.convertIdn(
+                            mAccountManager.getAccountsByType(MainApp.getAccountType())[i].name, false);
                 }
-            });
-            builder.setNegativeButton(R.string.uploader_wrn_no_account_quit_btn_text, new OnClickListener() {
-                @Override
-                public void onClick(DialogInterface dialog, int which) {
-                    finish();
-                }
-            });
-            return builder.create();
-        case DIALOG_MULTIPLE_ACCOUNT:
-            CharSequence ac[] = new CharSequence[
-                    mAccountManager.getAccountsByType(MainApp.getAccountType()).length];
-            for (int i = 0; i < ac.length; ++i) {
-                ac[i] = DisplayUtils.convertIdn(
-                        mAccountManager.getAccountsByType(MainApp.getAccountType())[i].name, false);
-            }
-            builder.setTitle(R.string.common_choose_account);
-            builder.setItems(ac, new OnClickListener() {
-                @Override
-                public void onClick(DialogInterface dialog, int which) {
-                    setAccount(mAccountManager.getAccountsByType(MainApp.getAccountType())[which]);
-                    onAccountSet(mAccountWasRestored);
-                    dialog.dismiss();
-                    mAccountSelected = true;
-                    mAccountSelectionShowing = false;
-                }
-            });
-            builder.setCancelable(true);
-            builder.setOnCancelListener(new OnCancelListener() {
-                @Override
-                public void onCancel(DialogInterface dialog) {
-                    mAccountSelectionShowing = false;
-                    dialog.cancel();
-                    finish();
-                }
-            });
-            return builder.create();
-        case DIALOG_NO_STREAM:
-            builder.setIcon(android.R.drawable.ic_dialog_alert);
-            builder.setTitle(R.string.uploader_wrn_no_content_title);
-            builder.setMessage(R.string.uploader_wrn_no_content_text);
-            builder.setCancelable(false);
-            builder.setNegativeButton(R.string.common_cancel, new OnClickListener() {
-                @Override
-                public void onClick(DialogInterface dialog, int which) {
-                    finish();
-                }
-            });
-            return builder.create();
-        default:
-            throw new IllegalArgumentException("Unknown dialog id: " + id);
+                builder.setTitle(R.string.common_choose_account);
+                builder.setItems(ac, new OnClickListener() {
+                    @Override
+                    public void onClick(DialogInterface dialog, int which) {
+                        setAccount(mAccountManager.getAccountsByType(MainApp.getAccountType())[which]);
+                        onAccountSet(mAccountWasRestored);
+                        dialog.dismiss();
+                        mAccountSelected = true;
+                        mAccountSelectionShowing = false;
+                    }
+                });
+                builder.setCancelable(true);
+                builder.setOnCancelListener(new OnCancelListener() {
+                    @Override
+                    public void onCancel(DialogInterface dialog) {
+                        mAccountSelectionShowing = false;
+                        dialog.cancel();
+                        finish();
+                    }
+                });
+                return builder.create();
+            case DIALOG_NO_STREAM:
+                builder.setIcon(android.R.drawable.ic_dialog_alert);
+                builder.setTitle(R.string.uploader_wrn_no_content_title);
+                builder.setMessage(R.string.uploader_wrn_no_content_text);
+                builder.setCancelable(false);
+                builder.setNegativeButton(R.string.common_cancel, new OnClickListener() {
+                    @Override
+                    public void onClick(DialogInterface dialog, int which) {
+                        finish();
+                    }
+                });
+                return builder.create();
+            default:
+                throw new IllegalArgumentException("Unknown dialog id: " + id);
         }
     }
 
@@ -309,7 +308,7 @@ public class Uploader extends FileActivity
         EditText mDirname;
 
         public a(String path, EditText dirname) {
-            mPath = path; 
+            mPath = path;
             mDirname = dirname;
         }
 
@@ -356,24 +355,24 @@ public class Uploader extends FileActivity
     public void onClick(View v) {
         // click on button
         switch (v.getId()) {
-        case R.id.uploader_choose_folder:
-            mUploadPath = "";   // first element in mParents is root dir, represented by "";
-                                // init mUploadPath with "/" results in a "//" prefix
-            for (String p : mParents)
-                mUploadPath += p + OCFile.PATH_SEPARATOR;
-            Log_OC.d(TAG, "Uploading file to dir " + mUploadPath);
+            case R.id.uploader_choose_folder:
+                mUploadPath = "";   // first element in mParents is root dir, represented by "";
+                // init mUploadPath with "/" results in a "//" prefix
+                for (String p : mParents)
+                    mUploadPath += p + OCFile.PATH_SEPARATOR;
+                Log_OC.d(TAG, "Uploading file to dir " + mUploadPath);
 
-            uploadFiles();
+                uploadFiles();
+
+                break;
+
+            case R.id.uploader_cancel:
+                finish();
+                break;
 
-            break;
-            
-        case R.id.uploader_cancel:
-            finish();
-            break;
-            
-            
-        default:
-            throw new IllegalArgumentException("Wrong element clicked");
+
+            default:
+                throw new IllegalArgumentException("Wrong element clicked");
         }
     }
 
@@ -401,14 +400,13 @@ public class Uploader extends FileActivity
 
     private void populateDirectoryList() {
         setContentView(R.layout.uploader_layout);
-        
+
         ListView mListView = (ListView) findViewById(android.R.id.list);
 
         String current_dir = mParents.peek();
-        if(current_dir.equals("")){
+        if (current_dir.equals("")) {
             getSupportActionBar().setTitle(getString(R.string.default_display_name_for_root_folder));
-        }
-        else{
+        } else {
             getSupportActionBar().setTitle(current_dir);
         }
         boolean notRoot = (mParents.size() > 1);
@@ -424,7 +422,7 @@ public class Uploader extends FileActivity
         if (mFile != null) {
             // TODO Enable when "On Device" is recovered ?
             Vector<OCFile> files = getStorageManager().getFolderContent(mFile/*, false*/);
-            List<HashMap<String, Object>> data = new LinkedList<HashMap<String,Object>>();
+            List<HashMap<String, Object>> data = new LinkedList<HashMap<String, Object>>();
             for (OCFile f : files) {
                 HashMap<String, Object> h = new HashMap<String, Object>();
                 if (f.isFolder()) {
@@ -433,18 +431,18 @@ public class Uploader extends FileActivity
                 }
             }
             SimpleAdapter sa = new SimpleAdapter(this,
-                                                data,
-                                                R.layout.uploader_list_item_layout,
-                                                new String[] {"dirname"},
-                                                new int[] {R.id.filename});
-            
+                    data,
+                    R.layout.uploader_list_item_layout,
+                    new String[]{"dirname"},
+                    new int[]{R.id.filename});
+
             mListView.setAdapter(sa);
             Button btnChooseFolder = (Button) findViewById(R.id.uploader_choose_folder);
             btnChooseFolder.setOnClickListener(this);
-            
+
             Button btnNewFolder = (Button) findViewById(R.id.uploader_cancel);
             btnNewFolder.setOnClickListener(this);
-            
+
             mListView.setOnItemClickListener(this);
         }
     }
@@ -471,16 +469,16 @@ public class Uploader extends FileActivity
     }
 
     @SuppressLint("NewApi")
-	public void uploadFiles() {
+    public void uploadFiles() {
         try {
 
             // ArrayList for files with path in external storage
             ArrayList<String> local = new ArrayList<String>();
             ArrayList<String> remote = new ArrayList<String>();
-            
+
             // this checks the mimeType 
             for (Parcelable mStream : mStreamsToUpload) {
-                
+
                 Uri uri = (Uri) mStream;
                 String data = null;
                 String filePath = "";
@@ -490,9 +488,9 @@ public class Uploader extends FileActivity
                         String mimeType = getContentResolver().getType(uri);
 
                         if (mimeType.contains("image")) {
-                            String[] CONTENT_PROJECTION = { Images.Media.DATA,
+                            String[] CONTENT_PROJECTION = {Images.Media.DATA,
                                     Images.Media.DISPLAY_NAME, Images.Media.MIME_TYPE,
-                                    Images.Media.SIZE };
+                                    Images.Media.SIZE};
                             Cursor c = getContentResolver().query(uri, CONTENT_PROJECTION, null,
                                     null, null);
                             c.moveToFirst();
@@ -502,37 +500,37 @@ public class Uploader extends FileActivity
                                     c.getString(c.getColumnIndex(Images.Media.DISPLAY_NAME));
 
                         } else if (mimeType.contains("video")) {
-                            String[] CONTENT_PROJECTION = { Video.Media.DATA,
-                                   Video.Media.DISPLAY_NAME, Video.Media.MIME_TYPE,
-                                   Video.Media.SIZE, Video.Media.DATE_MODIFIED };
+                            String[] CONTENT_PROJECTION = {Video.Media.DATA,
+                                    Video.Media.DISPLAY_NAME, Video.Media.MIME_TYPE,
+                                    Video.Media.SIZE, Video.Media.DATE_MODIFIED};
                             Cursor c = getContentResolver().query(uri, CONTENT_PROJECTION, null,
-                                   null, null);
+                                    null, null);
                             c.moveToFirst();
                             int index = c.getColumnIndex(Video.Media.DATA);
                             data = c.getString(index);
                             filePath = mUploadPath +
-                                   c.getString(c.getColumnIndex(Video.Media.DISPLAY_NAME));
-                          
+                                    c.getString(c.getColumnIndex(Video.Media.DISPLAY_NAME));
+
                         } else if (mimeType.contains("audio")) {
-                            String[] CONTENT_PROJECTION = { Audio.Media.DATA,
-                                   Audio.Media.DISPLAY_NAME, Audio.Media.MIME_TYPE,
-                                   Audio.Media.SIZE };
+                            String[] CONTENT_PROJECTION = {Audio.Media.DATA,
+                                    Audio.Media.DISPLAY_NAME, Audio.Media.MIME_TYPE,
+                                    Audio.Media.SIZE};
                             Cursor c = getContentResolver().query(uri, CONTENT_PROJECTION, null,
-                                   null, null);
+                                    null, null);
                             c.moveToFirst();
                             int index = c.getColumnIndex(Audio.Media.DATA);
                             data = c.getString(index);
                             filePath = mUploadPath +
-                                   c.getString(c.getColumnIndex(Audio.Media.DISPLAY_NAME));
+                                    c.getString(c.getColumnIndex(Audio.Media.DISPLAY_NAME));
 
-                        } else  {
+                        } else {
                             Cursor cursor = getContentResolver().query(uri,
-                                   new String[]{MediaStore.MediaColumns.DISPLAY_NAME},
-                                   null, null, null);
+                                    new String[]{MediaStore.MediaColumns.DISPLAY_NAME},
+                                    null, null, null);
                             cursor.moveToFirst();
                             int nameIndex = cursor.getColumnIndex(cursor.getColumnNames()[0]);
                             if (nameIndex >= 0) {
-                               filePath = mUploadPath + cursor.getString(nameIndex);
+                                filePath = mUploadPath + cursor.getString(nameIndex);
                             }
                         }
 
@@ -540,20 +538,19 @@ public class Uploader extends FileActivity
                         filePath = Uri.decode(uri.toString()).replace(uri.getScheme() +
                                 "://", "");
                         if (filePath.contains("mnt")) {
-                           String splitedFilePath[] = filePath.split("/mnt");
-                           filePath = splitedFilePath[1];
+                            String splitedFilePath[] = filePath.split("/mnt");
+                            filePath = splitedFilePath[1];
                         }
                         final File file = new File(filePath);
                         data = file.getAbsolutePath();
                         filePath = mUploadPath + file.getName();
-                    }
-                    else {
+                    } else {
                         throw new SecurityException();
                     }
                     if (data == null) {
                         mRemoteCacheData.add(filePath);
                         CopyTmpFileAsyncTask copyTask = new CopyTmpFileAsyncTask(this);
-                        Object[] params = { uri, filePath, mRemoteCacheData.size()-1,
+                        Object[] params = {uri, filePath, mRemoteCacheData.size() - 1,
                                 getAccount().name, getContentResolver()};
                         mNumCacheFile++;
                         showWaitingCopyDialog();
@@ -562,12 +559,12 @@ public class Uploader extends FileActivity
                         remote.add(filePath);
                         local.add(data);
                     }
-                }
-                else {
+                } else {
                     throw new SecurityException();
                 }
 
-                FileUploader.uploadNewFile(getApplicationContext(), getAccount(), local.toArray(new String[local.size()]), remote.toArray(new String[remote.size()]));
+                FileUploader.uploadNewFile(this, getAccount(), local.toArray(new String[local.size()]), remote
+                        .toArray(new String[remote.size()]));
 
                 //Save the path to shared preferences
                 SharedPreferences.Editor appPrefs = PreferenceManager
@@ -577,29 +574,29 @@ public class Uploader extends FileActivity
 
                 finish();
             }
-            
+
         } catch (SecurityException e) {
             String message = String.format(getString(R.string.uploader_error_forbidden_content),
                     getString(R.string.app_name));
-            Toast.makeText(this, message, Toast.LENGTH_LONG).show();            
+            Toast.makeText(this, message, Toast.LENGTH_LONG).show();
         }
     }
-    
+
     @Override
     public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) {
         super.onRemoteOperationFinish(operation, result);
-        
-      
+
+
         if (operation instanceof CreateFolderOperation) {
-            onCreateFolderOperationFinish((CreateFolderOperation)operation, result);
+            onCreateFolderOperationFinish((CreateFolderOperation) operation, result);
         }
-        
+
     }
-    
+
     /**
      * Updates the view associated to the activity after the finish of an operation
      * trying create a new folder
-     * 
+     *
      * @param operation     Creation operation performed.
      * @param result        Result of the creation.
      */
@@ -609,21 +606,21 @@ public class Uploader extends FileActivity
             populateDirectoryList();
         } else {
             try {
-                Toast msg = Toast.makeText(this, 
-                        ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()), 
-                        Toast.LENGTH_LONG); 
+                Toast msg = Toast.makeText(this,
+                        ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()),
+                        Toast.LENGTH_LONG);
                 msg.show();
 
             } catch (NotFoundException e) {
-                Log_OC.e(TAG, "Error while trying to show fail message " , e);
+                Log_OC.e(TAG, "Error while trying to show fail message ", e);
             }
         }
     }
-    
-    
+
+
     /**
      *  Loads the target folder initialize shown to the user.
-     * 
+     *
      *  The target account has to be chosen before this method is called. 
      */
     private void initTargetFolder() {
@@ -631,22 +628,22 @@ public class Uploader extends FileActivity
             throw new IllegalStateException("Do not call this method before " +
                     "initializing mStorageManager");
         }
-        
+
         SharedPreferences appPreferences = PreferenceManager
                 .getDefaultSharedPreferences(getApplicationContext());
 
         String last_path = appPreferences.getString("last_upload_path", "");
         // "/" equals root-directory
-        if(last_path.equals("/")) {
+        if (last_path.equals("/")) {
             mParents.add("");
-        } else{
+        } else {
             String[] dir_names = last_path.split("/");
             mParents.clear();
             for (String dir : dir_names)
                 mParents.add(dir);
         }
         //Make sure that path still exists, if it doesn't pop the stack and try the previous path
-        while(!getStorageManager().fileExists(generatePath(mParents)) && mParents.size() > 1){
+        while (!getStorageManager().fileExists(generatePath(mParents)) && mParents.size() > 1) {
             mParents.pop();
         }
     }
@@ -660,7 +657,7 @@ public class Uploader extends FileActivity
         menu.findItem(R.id.action_sync_account).setVisible(false);
         return true;
     }
-    
+
     @Override
     public boolean onOptionsItemSelected(MenuItem item) {
         boolean retval = true;
@@ -672,7 +669,7 @@ public class Uploader extends FileActivity
                         CreateFolderDialogFragment.CREATE_FOLDER_FRAGMENT);
                 break;
             case android.R.id.home:
-                if((mParents.size() > 1)) {
+                if ((mParents.size() > 1)) {
                     onBackPressed();
                 }
                 break;
@@ -691,11 +688,11 @@ public class Uploader extends FileActivity
      */
     @Override
     public void onTmpFileCopied(String result, int index) {
-        if (mNumCacheFile -- == 0) {
+        if (mNumCacheFile-- == 0) {
             dismissWaitingCopyDialog();
         }
         if (result != null) {
-            FileUploader.uploadNewFile(getApplicationContext(), getAccount(), result, mRemoteCacheData.get(index));
+            FileUploader.uploadNewFile(this, getAccount(), result, mRemoteCacheData.get(index));
 
         } else {
             String message = String.format(getString(R.string.uploader_error_forbidden_content),
@@ -705,7 +702,8 @@ public class Uploader extends FileActivity
         }
 
     }
-/**
+
+    /**
      * Show waiting for copy dialog
      */
     public void showWaitingCopyDialog() {
@@ -722,7 +720,7 @@ public class Uploader extends FileActivity
     /**
      * Dismiss waiting for copy dialog
      */
-    public void dismissWaitingCopyDialog(){
+    public void dismissWaitingCopyDialog() {
         Fragment frag = getSupportFragmentManager().findFragmentByTag(DIALOG_WAIT_COPY_FILE);
         if (frag != null) {
             LoadingDialog loading = (LoadingDialog) frag;