Browse Source

Changes after CR (WIP)

jabarros 8 years ago
parent
commit
36a0cd5a67

+ 7 - 8
src/com/owncloud/android/ui/activity/FileDisplayActivity.java

@@ -642,6 +642,8 @@ public class FileDisplayActivity extends HookActivity
         if (requestCode == REQUEST_CODE__SELECT_CONTENT_FROM_APPS && (resultCode == RESULT_OK ||
                 resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)) {
 
+            ArrayList<Parcelable> streamsToUpload = new ArrayList<Parcelable>();
+
             //getClipData is only supported on api level 16+, Jelly Bean
             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN &&
                     data.getClipData() != null &&
@@ -650,12 +652,13 @@ public class FileDisplayActivity extends HookActivity
                 for (int i = 0; i < data.getClipData().getItemCount(); i++) {
                     Intent intent = new Intent();
                     intent.setData(data.getClipData().getItemAt(i).getUri());
-                    requestSimpleUpload(intent, resultCode);
+                    streamsToUpload.add(intent.getData());
                 }
 
             } else {
-                requestSimpleUpload(data, resultCode);
+                streamsToUpload.add(data.getData());
             }
+            requestSimpleUpload(streamsToUpload, resultCode);
         } else if (requestCode == REQUEST_CODE__SELECT_MULTIPLE_FILES && (resultCode == RESULT_OK ||
                 resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)) {
             requestMultipleUpload(data, resultCode);
@@ -726,21 +729,17 @@ public class FileDisplayActivity extends HookActivity
     }
 
 
-    private void requestSimpleUpload(final Intent data, int resultCode) {
+    private void requestSimpleUpload(ArrayList<Parcelable> streamsToUpload, int resultCode) {
 
         int behaviour = (resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE) ? FileUploader.LOCAL_BEHAVIOUR_MOVE :
                 FileUploader.LOCAL_BEHAVIOUR_COPY;
 
-        ArrayList<Parcelable> mStreamsToUpload = new ArrayList<Parcelable>() {{
-            add(data.getData());
-        }};
-
         OCFile currentDir = getCurrentDir();
         String remotePath = (currentDir != null) ? currentDir.getRemotePath() : OCFile.ROOT_PATH;
 
         UriUploader uploader = new UriUploader(
                 this,
-                mStreamsToUpload,
+                streamsToUpload,
                 remotePath,
                 getAccount(),
                 behaviour,

+ 3 - 0
src/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java

@@ -502,6 +502,9 @@ public class ReceiveExternalFilesActivity extends FileActivity
                     messageResId,
                     messageResTitle
             );
+
+            // Save the path to shared preferences; even if upload is not possible, user chose the folder
+            PreferenceManager.setLastUploadPath(mUploadPath, this);
         }
     }
 

+ 1 - 1
src/com/owncloud/android/ui/asynctasks/CopyAndUploadContentUrisTask.java

@@ -238,7 +238,7 @@ public class CopyAndUploadContentUrisTask extends AsyncTask<Object, Void, Result
             listener.onTmpFilesCopied(result);
 
         } else {
-            Log_OC.i(TAG, "User left ReceiveExternalFilesActivity activity before the temporal copies were finished ");
+            Log_OC.i(TAG, "User left the caller activity before the temporal copies were finished ");
             if (result != ResultCode.OK) {
                 // if the user left the app, report background error in a Toast
                 int messageId;

+ 1 - 5
src/com/owncloud/android/ui/helpers/UriUploader.java

@@ -24,7 +24,6 @@ import android.net.Uri;
 import android.os.Parcelable;
 
 import com.owncloud.android.R;
-import com.owncloud.android.db.PreferenceManager;
 import com.owncloud.android.files.services.FileUploader;
 import com.owncloud.android.lib.common.utils.Log_OC;
 import com.owncloud.android.operations.UploadFileOperation;
@@ -123,11 +122,8 @@ public class UriUploader {
 
         } catch (Exception e) {
             mCode = UriUploaderResultCode.ERROR_UNKNOWN;
-            Log_OC.e(TAG, "Unexpted error", e);
+            Log_OC.e(TAG, "Unexpected error", e);
 
-        } finally {
-            // Save the path to shared preferences; even if upload is not possible, user chose the folder
-            PreferenceManager.setLastUploadPath(mUploadPath, mActivity);
         }
         return mCode;
     }

+ 0 - 17
src/com/owncloud/android/utils/DisplayUtils.java

@@ -172,23 +172,6 @@ public class DisplayUtils {
         }
     }
 
-    /**
-     * Get the file extension if it is on path as type "content://.../DocInfo.doc"
-     * @param filepath: Content Uri converted to string format
-     * @return String: fileExtension (type '.pdf'). Empty if no extension
-     */
-    public static String getFileExtension(String filepath) {
-        String fileExtension = "";
-        String fileNameInContentUri = filepath.substring(filepath.lastIndexOf("/"));
-
-        // Check if extension is included in uri
-        int pos = fileNameInContentUri.lastIndexOf('.');
-        if (pos >= 0) {
-            fileExtension = fileNameInContentUri.substring(pos);
-        }
-        return fileExtension;
-    }
-
     @SuppressWarnings("deprecation")
     public static CharSequence getRelativeDateTimeString (
             Context c, long time, long minResolution, long transitionResolution, int flags