- if (requestCode == ACTION_SELECT_FILE) {\r
- if (resultCode == RESULT_OK) {\r
- String filepath = null;\r
- try {\r
- Uri selectedImageUri = data.getData();\r
- \r
- String filemanagerstring = selectedImageUri.getPath();\r
- String selectedImagePath = getPath(selectedImageUri);\r
- \r
- if (selectedImagePath != null)\r
- filepath = selectedImagePath;\r
- else\r
- filepath = filemanagerstring;\r
- \r
- } catch (Exception e) {\r
- Log.e("FileDisplay", "Unexpected exception when trying to read the result of Intent.ACTION_GET_CONTENT", e);\r
- e.printStackTrace();\r
- \r
- } finally {\r
- if (filepath == null) {\r
- Log.e("FileDisplay", "Couldnt resolve path to file");\r
- Toast t = Toast.makeText(this, getString(R.string.filedisplay_unexpected_bad_get_content), Toast.LENGTH_LONG);\r
- t.show();\r
- return;\r
- }\r
- }\r
- \r
- Intent i = new Intent(this, FileUploader.class);\r
- i.putExtra(FileUploader.KEY_ACCOUNT,\r
- AccountUtils.getCurrentOwnCloudAccount(this));\r
- String remotepath = new String();\r
- for (int j = mDirectories.getCount() - 2; j >= 0; --j) {\r
- remotepath += OCFile.PATH_SEPARATOR + mDirectories.getItem(j);\r
- }\r
- if (!remotepath.endsWith(OCFile.PATH_SEPARATOR))\r
- remotepath += OCFile.PATH_SEPARATOR;\r
- remotepath += new File(filepath).getName();\r
- \r
- i.putExtra(FileUploader.KEY_LOCAL_FILE, filepath);\r
- i.putExtra(FileUploader.KEY_REMOTE_FILE, remotepath);\r
- i.putExtra(FileUploader.KEY_UPLOAD_TYPE, FileUploader.UPLOAD_SINGLE_FILE);\r
- startService(i);\r
+ \r
+ if (requestCode == ACTION_SELECT_CONTENT_FROM_APPS && resultCode == RESULT_OK) {\r
+ requestSimpleUpload(data);\r
+ \r
+ } else if (requestCode == ACTION_SELECT_MULTIPLE_FILES && resultCode == RESULT_OK) {\r
+ requestMultipleUpload(data);\r
+ \r
+ }\r
+ }\r
+\r
+ private void requestMultipleUpload(Intent data) {\r
+ String[] filePaths = data.getStringArrayExtra(UploadFilesActivity.EXTRA_CHOSEN_FILES);\r
+ if (filePaths != null) {\r
+ String[] remotePaths = new String[filePaths.length];\r
+ String remotePathBase = "";\r
+ for (int j = mDirectories.getCount() - 2; j >= 0; --j) {\r
+ remotePathBase += OCFile.PATH_SEPARATOR + mDirectories.getItem(j);\r
+ }\r
+ if (!remotePathBase.endsWith(OCFile.PATH_SEPARATOR))\r
+ remotePathBase += OCFile.PATH_SEPARATOR;\r
+ for (int j = 0; j< remotePaths.length; j++) {\r
+ remotePaths[j] = remotePathBase + (new File(filePaths[j])).getName();\r