mirror of
https://github.com/nextcloud/android.git
synced 2024-11-22 13:15:35 +03:00
Auto rename oc upload
Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
parent
c10c97bf22
commit
b0082d26f9
1 changed files with 19 additions and 0 deletions
|
@ -27,6 +27,7 @@ import com.nextcloud.client.account.CurrentAccountProvider;
|
|||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.jobs.upload.FileUploadHelper;
|
||||
import com.nextcloud.client.jobs.upload.FileUploadWorker;
|
||||
import com.nextcloud.utils.autoRename.AutoRename;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.db.OCUpload;
|
||||
import com.owncloud.android.db.ProviderMeta.ProviderTableMeta;
|
||||
|
@ -34,7 +35,9 @@ import com.owncloud.android.db.UploadResult;
|
|||
import com.owncloud.android.files.services.NameCollisionPolicy;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.status.OCCapability;
|
||||
import com.owncloud.android.operations.UploadFileOperation;
|
||||
import com.owncloud.android.utils.theme.CapabilityUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
@ -65,6 +68,7 @@ public class UploadsStorageManager extends Observable {
|
|||
|
||||
private final ContentResolver contentResolver;
|
||||
private final CurrentAccountProvider currentAccountProvider;
|
||||
private OCCapability capability;
|
||||
|
||||
public UploadsStorageManager(
|
||||
CurrentAccountProvider currentAccountProvider,
|
||||
|
@ -77,6 +81,14 @@ public class UploadsStorageManager extends Observable {
|
|||
this.currentAccountProvider = currentAccountProvider;
|
||||
}
|
||||
|
||||
private void initOCCapability() {
|
||||
try {
|
||||
this.capability = CapabilityUtils.getCapability(MainApp.getAppContext());
|
||||
} catch (RuntimeException e) {
|
||||
Log_OC.e(TAG,"Failed to set OCCapability: Dependencies are not yet ready.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores an upload object in DB.
|
||||
*
|
||||
|
@ -570,10 +582,17 @@ public class UploadsStorageManager extends Observable {
|
|||
}
|
||||
|
||||
private OCUpload createOCUploadFromCursor(Cursor c) {
|
||||
initOCCapability();
|
||||
|
||||
OCUpload upload = null;
|
||||
if (c != null) {
|
||||
String localPath = c.getString(c.getColumnIndexOrThrow(ProviderTableMeta.UPLOADS_LOCAL_PATH));
|
||||
|
||||
String remotePath = c.getString(c.getColumnIndexOrThrow(ProviderTableMeta.UPLOADS_REMOTE_PATH));
|
||||
if (capability != null) {
|
||||
remotePath = AutoRename.INSTANCE.rename(remotePath, capability,true);
|
||||
}
|
||||
|
||||
String accountName = c.getString(c.getColumnIndexOrThrow(ProviderTableMeta.UPLOADS_ACCOUNT_NAME));
|
||||
upload = new OCUpload(localPath, remotePath, accountName);
|
||||
|
||||
|
|
Loading…
Reference in a new issue