mirror of
https://github.com/nextcloud/android.git
synced 2024-11-25 14:45:47 +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.account.User;
|
||||||
import com.nextcloud.client.jobs.upload.FileUploadHelper;
|
import com.nextcloud.client.jobs.upload.FileUploadHelper;
|
||||||
import com.nextcloud.client.jobs.upload.FileUploadWorker;
|
import com.nextcloud.client.jobs.upload.FileUploadWorker;
|
||||||
|
import com.nextcloud.utils.autoRename.AutoRename;
|
||||||
import com.owncloud.android.MainApp;
|
import com.owncloud.android.MainApp;
|
||||||
import com.owncloud.android.db.OCUpload;
|
import com.owncloud.android.db.OCUpload;
|
||||||
import com.owncloud.android.db.ProviderMeta.ProviderTableMeta;
|
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.files.services.NameCollisionPolicy;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
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.operations.UploadFileOperation;
|
||||||
|
import com.owncloud.android.utils.theme.CapabilityUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -65,6 +68,7 @@ public class UploadsStorageManager extends Observable {
|
||||||
|
|
||||||
private final ContentResolver contentResolver;
|
private final ContentResolver contentResolver;
|
||||||
private final CurrentAccountProvider currentAccountProvider;
|
private final CurrentAccountProvider currentAccountProvider;
|
||||||
|
private OCCapability capability;
|
||||||
|
|
||||||
public UploadsStorageManager(
|
public UploadsStorageManager(
|
||||||
CurrentAccountProvider currentAccountProvider,
|
CurrentAccountProvider currentAccountProvider,
|
||||||
|
@ -77,6 +81,14 @@ public class UploadsStorageManager extends Observable {
|
||||||
this.currentAccountProvider = currentAccountProvider;
|
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.
|
* Stores an upload object in DB.
|
||||||
*
|
*
|
||||||
|
@ -570,10 +582,17 @@ public class UploadsStorageManager extends Observable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private OCUpload createOCUploadFromCursor(Cursor c) {
|
private OCUpload createOCUploadFromCursor(Cursor c) {
|
||||||
|
initOCCapability();
|
||||||
|
|
||||||
OCUpload upload = null;
|
OCUpload upload = null;
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
String localPath = c.getString(c.getColumnIndexOrThrow(ProviderTableMeta.UPLOADS_LOCAL_PATH));
|
String localPath = c.getString(c.getColumnIndexOrThrow(ProviderTableMeta.UPLOADS_LOCAL_PATH));
|
||||||
|
|
||||||
String remotePath = c.getString(c.getColumnIndexOrThrow(ProviderTableMeta.UPLOADS_REMOTE_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));
|
String accountName = c.getString(c.getColumnIndexOrThrow(ProviderTableMeta.UPLOADS_ACCOUNT_NAME));
|
||||||
upload = new OCUpload(localPath, remotePath, accountName);
|
upload = new OCUpload(localPath, remotePath, accountName);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue