|
@@ -30,7 +30,6 @@ import com.owncloud.android.operations.UploadFileOperation;
|
|
import com.owncloud.android.ui.activity.FileActivity;
|
|
import com.owncloud.android.ui.activity.FileActivity;
|
|
import com.owncloud.android.ui.asynctasks.CopyAndUploadContentUrisTask;
|
|
import com.owncloud.android.ui.asynctasks.CopyAndUploadContentUrisTask;
|
|
import com.owncloud.android.ui.fragment.TaskRetainerFragment;
|
|
import com.owncloud.android.ui.fragment.TaskRetainerFragment;
|
|
-import com.owncloud.android.utils.DisplayUtils;
|
|
|
|
import com.owncloud.android.utils.UriUtils;
|
|
import com.owncloud.android.utils.UriUtils;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
@@ -40,27 +39,27 @@ import androidx.fragment.app.FragmentManager;
|
|
|
|
|
|
/**
|
|
/**
|
|
* This class examines URIs pointing to files to upload and then requests {@link FileUploader} to upload them.
|
|
* This class examines URIs pointing to files to upload and then requests {@link FileUploader} to upload them.
|
|
- *
|
|
|
|
- * URIs with scheme file:// do not require any previous processing, their path is sent to {@link FileUploader}
|
|
|
|
- * to find the source file.
|
|
|
|
- *
|
|
|
|
- * URIs with scheme content:// are handling assuming that file is in private storage owned by a different app,
|
|
|
|
- * and that persistency permission is not granted. Due to this, contents of the file are temporary copied by
|
|
|
|
- * the OC app, and then passed {@link FileUploader}.
|
|
|
|
|
|
+ * <p>
|
|
|
|
+ * URIs with scheme file:// do not require any previous processing, their path is sent to {@link FileUploader} to find
|
|
|
|
+ * the source file.
|
|
|
|
+ * <p>
|
|
|
|
+ * URIs with scheme content:// are handling assuming that file is in private storage owned by a different app, and that
|
|
|
|
+ * persistence permission is not granted. Due to this, contents of the file are temporary copied by the OC app, and then
|
|
|
|
+ * passed {@link FileUploader}.
|
|
*/
|
|
*/
|
|
public class UriUploader {
|
|
public class UriUploader {
|
|
|
|
|
|
private final String TAG = UriUploader.class.getSimpleName();
|
|
private final String TAG = UriUploader.class.getSimpleName();
|
|
|
|
|
|
- private FileActivity mActivity;
|
|
|
|
- private List<Parcelable> mUrisToUpload;
|
|
|
|
- private CopyAndUploadContentUrisTask.OnCopyTmpFilesTaskListener mCopyTmpTaskListener;
|
|
|
|
|
|
+ private final FileActivity mActivity;
|
|
|
|
+ private final List<Parcelable> mUrisToUpload;
|
|
|
|
+ private final CopyAndUploadContentUrisTask.OnCopyTmpFilesTaskListener mCopyTmpTaskListener;
|
|
|
|
|
|
- private int mBehaviour;
|
|
|
|
|
|
+ private final int mBehaviour;
|
|
|
|
|
|
- private String mUploadPath;
|
|
|
|
- private Account mAccount;
|
|
|
|
- private boolean mShowWaitingDialog;
|
|
|
|
|
|
+ private final String mUploadPath;
|
|
|
|
+ private final Account mAccount;
|
|
|
|
+ private final boolean mShowWaitingDialog;
|
|
|
|
|
|
private UriUploaderResultCode mCode = UriUploaderResultCode.OK;
|
|
private UriUploaderResultCode mCode = UriUploaderResultCode.OK;
|
|
|
|
|
|
@@ -102,6 +101,11 @@ public class UriUploader {
|
|
Uri sourceUri = (Uri) sourceStream;
|
|
Uri sourceUri = (Uri) sourceStream;
|
|
if (sourceUri != null) {
|
|
if (sourceUri != null) {
|
|
String displayName = UriUtils.getDisplayNameForUri(sourceUri, mActivity);
|
|
String displayName = UriUtils.getDisplayNameForUri(sourceUri, mActivity);
|
|
|
|
+
|
|
|
|
+ if (displayName == null) {
|
|
|
|
+ throw new IllegalStateException("DisplayName may not be null!");
|
|
|
|
+ }
|
|
|
|
+
|
|
String remotePath = mUploadPath + displayName;
|
|
String remotePath = mUploadPath + displayName;
|
|
|
|
|
|
if (ContentResolver.SCHEME_CONTENT.equals(sourceUri.getScheme())) {
|
|
if (ContentResolver.SCHEME_CONTENT.equals(sourceUri.getScheme())) {
|
|
@@ -138,11 +142,6 @@ public class UriUploader {
|
|
return mCode;
|
|
return mCode;
|
|
}
|
|
}
|
|
|
|
|
|
- private String generateDiplayName() {
|
|
|
|
- return mActivity.getString(R.string.common_unknown) +
|
|
|
|
- "-" + DisplayUtils.unixTimeToHumanReadable(System.currentTimeMillis());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Requests the upload of a file in the local file system to {@link FileUploader} service.
|
|
* Requests the upload of a file in the local file system to {@link FileUploader} service.
|
|
*
|
|
*
|