mirror of
https://github.com/nextcloud/android.git
synced 2024-11-21 20:55:31 +03:00
use localID everywhere
Co-authored-by: Álvaro Brey <alvaro.brey@nextcloud.com> Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
parent
0b3707cf25
commit
b78e991d54
25 changed files with 1270 additions and 51 deletions
1130
app/schemas/com.nextcloud.client.database.NextcloudDatabase/67.json
Normal file
1130
app/schemas/com.nextcloud.client.database.NextcloudDatabase/67.json
Normal file
File diff suppressed because it is too large
Load diff
|
@ -24,9 +24,14 @@ package com.owncloud.android.datamodel;
|
||||||
|
|
||||||
import com.owncloud.android.db.ProviderMeta;
|
import com.owncloud.android.db.ProviderMeta;
|
||||||
|
|
||||||
public class FileDataStorageManagerContentProviderClientIT extends FileDataStorageManagerIT {
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
|
public class FileDataStorageManagerContentProviderClientIT extends FileDataStorageManagerIT {
|
||||||
|
protected FileDataStorageManager sut;
|
||||||
|
|
||||||
@Override
|
|
||||||
public void before() {
|
public void before() {
|
||||||
sut = new FileDataStorageManager(user,
|
sut = new FileDataStorageManager(user,
|
||||||
targetContext
|
targetContext
|
||||||
|
@ -36,4 +41,25 @@ public class FileDataStorageManagerContentProviderClientIT extends FileDataStora
|
||||||
|
|
||||||
super.before();
|
super.before();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void saveFile() {
|
||||||
|
before();
|
||||||
|
|
||||||
|
String path = "/1.txt";
|
||||||
|
OCFile file = new OCFile(path);
|
||||||
|
file.setRemoteId("00000008ocjycgrudn78");
|
||||||
|
|
||||||
|
// TODO check via reflection that every parameter is set
|
||||||
|
|
||||||
|
file.setFileLength(1024000);
|
||||||
|
file.setModificationTimestamp(1582019340);
|
||||||
|
sut.saveNewFile(file);
|
||||||
|
|
||||||
|
|
||||||
|
OCFile read = sut.getFileByPath(path);
|
||||||
|
assertNotNull(read);
|
||||||
|
|
||||||
|
assertEquals(file.getRemotePath(), read.getRemotePath());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -369,4 +369,5 @@ abstract public class FileDataStorageManagerIT extends AbstractOnServerIT {
|
||||||
|
|
||||||
assertEquals(capability.getUserStatus(), newCapability.getUserStatus());
|
assertEquals(capability.getUserStatus(), newCapability.getUserStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,8 @@ import com.owncloud.android.db.ProviderMeta
|
||||||
],
|
],
|
||||||
version = ProviderMeta.DB_VERSION,
|
version = ProviderMeta.DB_VERSION,
|
||||||
autoMigrations = [
|
autoMigrations = [
|
||||||
AutoMigration(from = 65, to = 66)
|
AutoMigration(from = 65, to = 66),
|
||||||
|
AutoMigration(from = 66, to = 67)
|
||||||
],
|
],
|
||||||
exportSchema = true
|
exportSchema = true
|
||||||
)
|
)
|
||||||
|
|
|
@ -70,6 +70,8 @@ data class FileEntity(
|
||||||
val permissions: String?,
|
val permissions: String?,
|
||||||
@ColumnInfo(name = ProviderTableMeta.FILE_REMOTE_ID)
|
@ColumnInfo(name = ProviderTableMeta.FILE_REMOTE_ID)
|
||||||
val remoteId: String?,
|
val remoteId: String?,
|
||||||
|
@ColumnInfo(name = ProviderTableMeta.FILE_LOCAL_ID)
|
||||||
|
val localId: Long?,
|
||||||
@ColumnInfo(name = ProviderTableMeta.FILE_UPDATE_THUMBNAIL)
|
@ColumnInfo(name = ProviderTableMeta.FILE_UPDATE_THUMBNAIL)
|
||||||
val updateThumbnail: Int?,
|
val updateThumbnail: Int?,
|
||||||
@ColumnInfo(name = ProviderTableMeta.FILE_IS_DOWNLOADING)
|
@ColumnInfo(name = ProviderTableMeta.FILE_IS_DOWNLOADING)
|
||||||
|
|
|
@ -28,7 +28,7 @@ import com.owncloud.android.lib.common.OwnCloudClient
|
||||||
|
|
||||||
internal class LoadUrlTask(
|
internal class LoadUrlTask(
|
||||||
private val client: OwnCloudClient,
|
private val client: OwnCloudClient,
|
||||||
private val fileId: String,
|
private val fileId: Long,
|
||||||
private val onResult: (String?) -> Unit
|
private val onResult: (String?) -> Unit
|
||||||
) : AsyncTask<Void, Void, String>() {
|
) : AsyncTask<Void, Void, String>() {
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ internal class Player(
|
||||||
checkNotNull(user)
|
checkNotNull(user)
|
||||||
playedFile?.let {
|
playedFile?.let {
|
||||||
val client = clientFactory.create(user)
|
val client = clientFactory.create(user)
|
||||||
val task = LoadUrlTask(client, it.remoteId, this@Player::onDownloaded)
|
val task = LoadUrlTask(client, it.localId, this@Player::onDownloaded)
|
||||||
task.execute()
|
task.execute()
|
||||||
loadUrlTask = task
|
loadUrlTask = task
|
||||||
}
|
}
|
||||||
|
|
|
@ -458,6 +458,7 @@ public class FileDataStorageManager {
|
||||||
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, fileOrFolder.isSharedWithSharee() ? 1 : 0);
|
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, fileOrFolder.isSharedWithSharee() ? 1 : 0);
|
||||||
cv.put(ProviderTableMeta.FILE_PERMISSIONS, fileOrFolder.getPermissions());
|
cv.put(ProviderTableMeta.FILE_PERMISSIONS, fileOrFolder.getPermissions());
|
||||||
cv.put(ProviderTableMeta.FILE_REMOTE_ID, fileOrFolder.getRemoteId());
|
cv.put(ProviderTableMeta.FILE_REMOTE_ID, fileOrFolder.getRemoteId());
|
||||||
|
cv.put(ProviderTableMeta.FILE_LOCAL_ID, fileOrFolder.getLocalId());
|
||||||
cv.put(ProviderTableMeta.FILE_FAVORITE, fileOrFolder.isFavorite());
|
cv.put(ProviderTableMeta.FILE_FAVORITE, fileOrFolder.isFavorite());
|
||||||
cv.put(ProviderTableMeta.FILE_UNREAD_COMMENTS_COUNT, fileOrFolder.getUnreadCommentsCount());
|
cv.put(ProviderTableMeta.FILE_UNREAD_COMMENTS_COUNT, fileOrFolder.getUnreadCommentsCount());
|
||||||
cv.put(ProviderTableMeta.FILE_OWNER_ID, fileOrFolder.getOwnerId());
|
cv.put(ProviderTableMeta.FILE_OWNER_ID, fileOrFolder.getOwnerId());
|
||||||
|
|
|
@ -45,6 +45,7 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
import androidx.core.content.FileProvider;
|
import androidx.core.content.FileProvider;
|
||||||
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
import third_parties.daveKoeller.AlphanumComparator;
|
import third_parties.daveKoeller.AlphanumComparator;
|
||||||
|
|
||||||
public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterface {
|
public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterface {
|
||||||
|
@ -83,6 +84,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||||
private String etagOnServer;
|
private String etagOnServer;
|
||||||
private boolean sharedViaLink;
|
private boolean sharedViaLink;
|
||||||
private String permissions;
|
private String permissions;
|
||||||
|
private long localId; // unique fileId for the file within the instance
|
||||||
private String remoteId; // The fileid namespaced by the instance fileId, globally unique
|
private String remoteId; // The fileid namespaced by the instance fileId, globally unique
|
||||||
private boolean updateThumbnailNeeded;
|
private boolean updateThumbnailNeeded;
|
||||||
private boolean downloading;
|
private boolean downloading;
|
||||||
|
@ -166,6 +168,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||||
etagOnServer = source.readString();
|
etagOnServer = source.readString();
|
||||||
sharedViaLink = source.readInt() == 1;
|
sharedViaLink = source.readInt() == 1;
|
||||||
permissions = source.readString();
|
permissions = source.readString();
|
||||||
|
localId = source.readLong();
|
||||||
remoteId = source.readString();
|
remoteId = source.readString();
|
||||||
updateThumbnailNeeded = source.readInt() == 1;
|
updateThumbnailNeeded = source.readInt() == 1;
|
||||||
downloading = source.readInt() == 1;
|
downloading = source.readInt() == 1;
|
||||||
|
@ -208,6 +211,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||||
dest.writeString(etagOnServer);
|
dest.writeString(etagOnServer);
|
||||||
dest.writeInt(sharedViaLink ? 1 : 0);
|
dest.writeInt(sharedViaLink ? 1 : 0);
|
||||||
dest.writeString(permissions);
|
dest.writeString(permissions);
|
||||||
|
dest.writeLong(localId);
|
||||||
dest.writeString(remoteId);
|
dest.writeString(remoteId);
|
||||||
dest.writeInt(updateThumbnailNeeded ? 1 : 0);
|
dest.writeInt(updateThumbnailNeeded ? 1 : 0);
|
||||||
dest.writeInt(downloading ? 1 : 0);
|
dest.writeInt(downloading ? 1 : 0);
|
||||||
|
@ -284,8 +288,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Can be used to check, whether or not this file exists in the database
|
* Can be used to check, whether or not this file exists in the database already
|
||||||
* already
|
|
||||||
*
|
*
|
||||||
* @return true, if the file exists in the database
|
* @return true, if the file exists in the database
|
||||||
*/
|
*/
|
||||||
|
@ -486,6 +489,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||||
etagOnServer = null;
|
etagOnServer = null;
|
||||||
sharedViaLink = false;
|
sharedViaLink = false;
|
||||||
permissions = null;
|
permissions = null;
|
||||||
|
localId = -1;
|
||||||
remoteId = null;
|
remoteId = null;
|
||||||
updateThumbnailNeeded = false;
|
updateThumbnailNeeded = false;
|
||||||
downloading = false;
|
downloading = false;
|
||||||
|
@ -594,17 +598,14 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||||
return !TextUtils.isEmpty(getFileName()) && getFileName().charAt(0) == '.';
|
return !TextUtils.isEmpty(getFileName()) && getFileName().charAt(0) == '.';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@SuppressFBWarnings("STT")
|
||||||
* The unique fileId for the file within the instance
|
public long getLocalId() {
|
||||||
*
|
if (localId > 0) {
|
||||||
* @return file fileId, unique within the instance
|
return localId;
|
||||||
*/
|
} else if (remoteId != null) {
|
||||||
@Nullable
|
return Long.parseLong(remoteId.substring(0, 8).replaceAll("^0*", ""));
|
||||||
public String getLocalId() {
|
|
||||||
if (getRemoteId() != null) {
|
|
||||||
return getRemoteId().substring(0, 8).replaceAll("^0*", "");
|
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -772,6 +773,10 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||||
this.fileId = fileId;
|
this.fileId = fileId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setLocalId(long localId) {
|
||||||
|
this.localId = localId;
|
||||||
|
}
|
||||||
|
|
||||||
public void setParentId(long parentId) {
|
public void setParentId(long parentId) {
|
||||||
this.parentId = parentId;
|
this.parentId = parentId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -689,7 +689,7 @@ public final class ThumbnailsCacheManager {
|
||||||
Bitmap bitmap;
|
Bitmap bitmap;
|
||||||
if (MimeTypeUtil.isVideo(ocFile)) {
|
if (MimeTypeUtil.isVideo(ocFile)) {
|
||||||
bitmap = ThumbnailUtils.createVideoThumbnail(ocFile.getStoragePath(),
|
bitmap = ThumbnailUtils.createVideoThumbnail(ocFile.getStoragePath(),
|
||||||
MediaStore.Images.Thumbnails.MINI_KIND);
|
MediaStore.Images.Thumbnails.MINI_KIND);
|
||||||
} else {
|
} else {
|
||||||
bitmap = BitmapUtils.decodeSampledBitmapFromFile(ocFile.getStoragePath(), pxW, pxH);
|
bitmap = BitmapUtils.decodeSampledBitmapFromFile(ocFile.getStoragePath(), pxW, pxH);
|
||||||
}
|
}
|
||||||
|
@ -733,16 +733,16 @@ public final class ThumbnailsCacheManager {
|
||||||
pxW + "/" + pxH + Uri.encode(file.getRemotePath(), "/");
|
pxW + "/" + pxH + Uri.encode(file.getRemotePath(), "/");
|
||||||
} else {
|
} else {
|
||||||
uri = mClient.getBaseUri() + "/index.php/apps/files_trashbin/preview?fileId=" +
|
uri = mClient.getBaseUri() + "/index.php/apps/files_trashbin/preview?fileId=" +
|
||||||
file.getLocalId() + "&x=" + pxW + "&y=" + pxH;
|
file.getLocalId() + "&x=" + pxW + "&y=" + pxH;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_OC.d(TAG, "generate thumbnail: " + file.getFileName() + " URI: " + uri);
|
Log_OC.d(TAG, "generate thumbnail: " + file.getFileName() + " URI: " + uri);
|
||||||
getMethod = new GetMethod(uri);
|
getMethod = new GetMethod(uri);
|
||||||
getMethod.setRequestHeader("Cookie",
|
getMethod.setRequestHeader("Cookie",
|
||||||
"nc_sameSiteCookielax=true;nc_sameSiteCookiestrict=true");
|
"nc_sameSiteCookielax=true;nc_sameSiteCookiestrict=true");
|
||||||
|
|
||||||
getMethod.setRequestHeader(RemoteOperation.OCS_API_HEADER,
|
getMethod.setRequestHeader(RemoteOperation.OCS_API_HEADER,
|
||||||
RemoteOperation.OCS_API_HEADER_VALUE);
|
RemoteOperation.OCS_API_HEADER_VALUE);
|
||||||
|
|
||||||
int status = mClient.executeMethod(getMethod, READ_TIMEOUT, CONNECTION_TIMEOUT);
|
int status = mClient.executeMethod(getMethod, READ_TIMEOUT, CONNECTION_TIMEOUT);
|
||||||
if (status == HttpStatus.SC_OK) {
|
if (status == HttpStatus.SC_OK) {
|
||||||
|
|
|
@ -35,7 +35,7 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public class ProviderMeta {
|
public class ProviderMeta {
|
||||||
public static final String DB_NAME = "filelist";
|
public static final String DB_NAME = "filelist";
|
||||||
public static final int DB_VERSION = 66;
|
public static final int DB_VERSION = 67;
|
||||||
|
|
||||||
private ProviderMeta() {
|
private ProviderMeta() {
|
||||||
// No instance
|
// No instance
|
||||||
|
@ -101,6 +101,7 @@ public class ProviderMeta {
|
||||||
public static final String FILE_SHARED_VIA_LINK = "share_by_link";
|
public static final String FILE_SHARED_VIA_LINK = "share_by_link";
|
||||||
public static final String FILE_SHARED_WITH_SHAREE = "shared_via_users";
|
public static final String FILE_SHARED_WITH_SHAREE = "shared_via_users";
|
||||||
public static final String FILE_PERMISSIONS = "permissions";
|
public static final String FILE_PERMISSIONS = "permissions";
|
||||||
|
public static final String FILE_LOCAL_ID = "local_id";
|
||||||
public static final String FILE_REMOTE_ID = "remote_id";
|
public static final String FILE_REMOTE_ID = "remote_id";
|
||||||
public static final String FILE_UPDATE_THUMBNAIL = "update_thumbnail";
|
public static final String FILE_UPDATE_THUMBNAIL = "update_thumbnail";
|
||||||
public static final String FILE_IS_DOWNLOADING = "is_downloading";
|
public static final String FILE_IS_DOWNLOADING = "is_downloading";
|
||||||
|
@ -148,6 +149,7 @@ public class ProviderMeta {
|
||||||
FILE_SHARED_WITH_SHAREE,
|
FILE_SHARED_WITH_SHAREE,
|
||||||
FILE_PERMISSIONS,
|
FILE_PERMISSIONS,
|
||||||
FILE_REMOTE_ID,
|
FILE_REMOTE_ID,
|
||||||
|
FILE_LOCAL_ID,
|
||||||
FILE_UPDATE_THUMBNAIL,
|
FILE_UPDATE_THUMBNAIL,
|
||||||
FILE_IS_DOWNLOADING,
|
FILE_IS_DOWNLOADING,
|
||||||
FILE_ETAG_IN_CONFLICT,
|
FILE_ETAG_IN_CONFLICT,
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class StreamMediaFileOperation extends RemoteOperation {
|
||||||
private static final int SYNC_CONNECTION_TIMEOUT = 5000;
|
private static final int SYNC_CONNECTION_TIMEOUT = 5000;
|
||||||
private static final String STREAM_MEDIA_URL = "/ocs/v2.php/apps/dav/api/v1/direct";
|
private static final String STREAM_MEDIA_URL = "/ocs/v2.php/apps/dav/api/v1/direct";
|
||||||
|
|
||||||
private String fileID;
|
private final long fileID;
|
||||||
|
|
||||||
// JSON node names
|
// JSON node names
|
||||||
private static final String NODE_OCS = "ocs";
|
private static final String NODE_OCS = "ocs";
|
||||||
|
@ -45,7 +45,7 @@ public class StreamMediaFileOperation extends RemoteOperation {
|
||||||
private static final String NODE_URL = "url";
|
private static final String NODE_URL = "url";
|
||||||
private static final String JSON_FORMAT = "?format=json";
|
private static final String JSON_FORMAT = "?format=json";
|
||||||
|
|
||||||
public StreamMediaFileOperation(String fileID) {
|
public StreamMediaFileOperation(long fileID) {
|
||||||
this.fileID = fileID;
|
this.fileID = fileID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ public class StreamMediaFileOperation extends RemoteOperation {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
postMethod = new Utf8PostMethod(client.getBaseUri() + STREAM_MEDIA_URL + JSON_FORMAT);
|
postMethod = new Utf8PostMethod(client.getBaseUri() + STREAM_MEDIA_URL + JSON_FORMAT);
|
||||||
postMethod.setParameter("fileId", fileID);
|
postMethod.setParameter("fileId", String.valueOf(fileID));
|
||||||
|
|
||||||
// remote request
|
// remote request
|
||||||
postMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);
|
postMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);
|
||||||
|
|
|
@ -33,14 +33,14 @@ import com.owncloud.android.lib.resources.comments.CommentFileRemoteOperation;
|
||||||
public class CommentFileOperation extends RemoteOperation {
|
public class CommentFileOperation extends RemoteOperation {
|
||||||
|
|
||||||
private final String message;
|
private final String message;
|
||||||
private final String fileId;
|
private final long fileId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param message Comment to store
|
* @param message Comment to store
|
||||||
*/
|
*/
|
||||||
public CommentFileOperation(String message, String fileId) {
|
public CommentFileOperation(String message, long fileId) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.fileId = fileId;
|
this.fileId = fileId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,12 +62,12 @@ public class RemoveRemoteEncryptedFileOperation extends RemoteOperation {
|
||||||
private static final int REMOVE_READ_TIMEOUT = 30000;
|
private static final int REMOVE_READ_TIMEOUT = 30000;
|
||||||
private static final int REMOVE_CONNECTION_TIMEOUT = 5000;
|
private static final int REMOVE_CONNECTION_TIMEOUT = 5000;
|
||||||
|
|
||||||
private String remotePath;
|
private final String remotePath;
|
||||||
private String parentId;
|
private final long parentId;
|
||||||
private User user;
|
private User user;
|
||||||
|
|
||||||
private ArbitraryDataProvider arbitraryDataProvider;
|
private final ArbitraryDataProvider arbitraryDataProvider;
|
||||||
private String fileName;
|
private final String fileName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
@ -76,7 +76,7 @@ public class RemoveRemoteEncryptedFileOperation extends RemoteOperation {
|
||||||
* @param parentId local id of parent folder
|
* @param parentId local id of parent folder
|
||||||
*/
|
*/
|
||||||
RemoveRemoteEncryptedFileOperation(String remotePath,
|
RemoveRemoteEncryptedFileOperation(String remotePath,
|
||||||
String parentId,
|
long parentId,
|
||||||
User user,
|
User user,
|
||||||
Context context,
|
Context context,
|
||||||
String fileName) {
|
String fileName) {
|
||||||
|
|
|
@ -51,10 +51,10 @@ public class RichDocumentsUrlOperation extends RemoteOperation {
|
||||||
private static final String NODE_URL = "url";
|
private static final String NODE_URL = "url";
|
||||||
private static final String JSON_FORMAT = "?format=json";
|
private static final String JSON_FORMAT = "?format=json";
|
||||||
|
|
||||||
private String fileID;
|
private final long fileId;
|
||||||
|
|
||||||
public RichDocumentsUrlOperation(String fileID) {
|
public RichDocumentsUrlOperation(long fileID) {
|
||||||
this.fileID = fileID;
|
this.fileId = fileID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NextcloudServer(max = 18)
|
@NextcloudServer(max = 18)
|
||||||
|
@ -64,7 +64,7 @@ public class RichDocumentsUrlOperation extends RemoteOperation {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
postMethod = new Utf8PostMethod(client.getBaseUri() + DOCUMENT_URL + JSON_FORMAT);
|
postMethod = new Utf8PostMethod(client.getBaseUri() + DOCUMENT_URL + JSON_FORMAT);
|
||||||
postMethod.setParameter(FILE_ID, fileID);
|
postMethod.setParameter(FILE_ID, String.valueOf(fileId));
|
||||||
|
|
||||||
// remote request
|
// remote request
|
||||||
postMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);
|
postMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);
|
||||||
|
@ -86,7 +86,7 @@ public class RichDocumentsUrlOperation extends RemoteOperation {
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
result = new RemoteOperationResult(e);
|
result = new RemoteOperationResult(e);
|
||||||
Log_OC.e(TAG, "Get rich document url for file with id " + fileID + " failed: " + result.getLogMessage(),
|
Log_OC.e(TAG, "Get rich document url for file with id " + fileId + " failed: " + result.getLogMessage(),
|
||||||
result.getException());
|
result.getException());
|
||||||
} finally {
|
} finally {
|
||||||
if (postMethod != null) {
|
if (postMethod != null) {
|
||||||
|
|
|
@ -721,7 +721,7 @@ public class OperationsService extends Service {
|
||||||
|
|
||||||
case ACTION_RESTORE_VERSION:
|
case ACTION_RESTORE_VERSION:
|
||||||
FileVersion fileVersion = operationIntent.getParcelableExtra(EXTRA_FILE_VERSION);
|
FileVersion fileVersion = operationIntent.getParcelableExtra(EXTRA_FILE_VERSION);
|
||||||
operation = new RestoreFileVersionRemoteOperation(fileVersion.getRemoteId(),
|
operation = new RestoreFileVersionRemoteOperation(fileVersion.getLocalId(),
|
||||||
fileVersion.getFileName());
|
fileVersion.getFileName());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -23,12 +23,12 @@ package com.owncloud.android.ui.events;
|
||||||
* Event for set folder as encrypted/decrypted
|
* Event for set folder as encrypted/decrypted
|
||||||
*/
|
*/
|
||||||
public class EncryptionEvent {
|
public class EncryptionEvent {
|
||||||
public final String localId;
|
public final long localId;
|
||||||
public final String remotePath;
|
public final String remotePath;
|
||||||
public final String remoteId;
|
public final String remoteId;
|
||||||
public final boolean shouldBeEncrypted;
|
public final boolean shouldBeEncrypted;
|
||||||
|
|
||||||
public EncryptionEvent(String localId, String remoteId, String remotePath, boolean shouldBeEncrypted) {
|
public EncryptionEvent(long localId, String remoteId, String remotePath, boolean shouldBeEncrypted) {
|
||||||
this.localId = localId;
|
this.localId = localId;
|
||||||
this.remoteId = remoteId;
|
this.remoteId = remoteId;
|
||||||
this.remotePath = remotePath;
|
this.remotePath = remotePath;
|
||||||
|
|
|
@ -457,12 +457,14 @@ public class FileDetailActivitiesFragment extends Fragment implements
|
||||||
|
|
||||||
private static class SubmitCommentTask extends AsyncTask<Void, Void, Boolean> {
|
private static class SubmitCommentTask extends AsyncTask<Void, Void, Boolean> {
|
||||||
|
|
||||||
private String message;
|
private final String message;
|
||||||
private String fileId;
|
private final long fileId;
|
||||||
private VersionListInterface.CommentCallback callback;
|
private final VersionListInterface.CommentCallback callback;
|
||||||
private OwnCloudClient client;
|
private final OwnCloudClient client;
|
||||||
|
|
||||||
private SubmitCommentTask(String message, String fileId, VersionListInterface.CommentCallback callback,
|
private SubmitCommentTask(String message,
|
||||||
|
long fileId,
|
||||||
|
VersionListInterface.CommentCallback callback,
|
||||||
OwnCloudClient client) {
|
OwnCloudClient client) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.fileId = fileId;
|
this.fileId = fileId;
|
||||||
|
|
|
@ -1696,7 +1696,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void encryptFolder(String localId, String remoteId, String remotePath, boolean shouldBeEncrypted) {
|
private void encryptFolder(long localId, String remoteId, String remotePath, boolean shouldBeEncrypted) {
|
||||||
try {
|
try {
|
||||||
User user = accountManager.getUser();
|
User user = accountManager.getUser();
|
||||||
OwnCloudClient client = clientFactory.create(user);
|
OwnCloudClient client = clientFactory.create(user);
|
||||||
|
|
|
@ -456,7 +456,7 @@ public class FileOperationsHelper {
|
||||||
fileActivity.showLoadingDialog(fileActivity.getString(R.string.wait_a_moment));
|
fileActivity.showLoadingDialog(fileActivity.getString(R.string.wait_a_moment));
|
||||||
final User user = currentAccount.getUser();
|
final User user = currentAccount.getUser();
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
StreamMediaFileOperation sfo = new StreamMediaFileOperation(file.getRemoteId());
|
StreamMediaFileOperation sfo = new StreamMediaFileOperation(file.getLocalId());
|
||||||
RemoteOperationResult result = sfo.execute(user, fileActivity);
|
RemoteOperationResult result = sfo.execute(user, fileActivity);
|
||||||
|
|
||||||
fileActivity.dismissLoadingDialog();
|
fileActivity.dismissLoadingDialog();
|
||||||
|
|
|
@ -471,7 +471,7 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
|
||||||
playVideoUri(getFile().getStorageUri());
|
playVideoUri(getFile().getStorageUri());
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
new LoadStreamUrl(this, user, clientFactory).execute(getFile().getRemoteId());
|
new LoadStreamUrl(this, user, clientFactory).execute(getFile().getLocalId());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log_OC.e(TAG, "Loading stream url not possible: " + e);
|
Log_OC.e(TAG, "Loading stream url not possible: " + e);
|
||||||
}
|
}
|
||||||
|
@ -498,7 +498,7 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
|
||||||
Log_OC.e(TAG, "Fullscreen: " + isFullScreen);
|
Log_OC.e(TAG, "Fullscreen: " + isFullScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class LoadStreamUrl extends AsyncTask<String, Void, Uri> {
|
private static class LoadStreamUrl extends AsyncTask<Long, Void, Uri> {
|
||||||
|
|
||||||
private final ClientFactory clientFactory;
|
private final ClientFactory clientFactory;
|
||||||
private final User user;
|
private final User user;
|
||||||
|
@ -511,7 +511,7 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Uri doInBackground(String... fileId) {
|
protected Uri doInBackground(Long... fileId) {
|
||||||
OwnCloudClient client;
|
OwnCloudClient client;
|
||||||
try {
|
try {
|
||||||
client = clientFactory.create(user);
|
client = clientFactory.create(user);
|
||||||
|
|
|
@ -64,6 +64,7 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.widget.SearchView;
|
import androidx.appcompat.widget.SearchView;
|
||||||
import androidx.core.view.MenuItemCompat;
|
import androidx.core.view.MenuItemCompat;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
|
|
||||||
public class PreviewTextFileFragment extends PreviewTextFragment {
|
public class PreviewTextFileFragment extends PreviewTextFragment {
|
||||||
private static final String EXTRA_FILE = "FILE";
|
private static final String EXTRA_FILE = "FILE";
|
||||||
|
@ -228,6 +229,7 @@ public class PreviewTextFileFragment extends PreviewTextFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressFBWarnings("STT")
|
||||||
protected void onPostExecute(final StringWriter stringWriter) {
|
protected void onPostExecute(final StringWriter stringWriter) {
|
||||||
final TextView textView = textViewReference.get();
|
final TextView textView = textViewReference.get();
|
||||||
|
|
||||||
|
|
|
@ -222,6 +222,7 @@ public final class FileStorageUtils {
|
||||||
file.setEtag(remote.getEtag());
|
file.setEtag(remote.getEtag());
|
||||||
file.setPermissions(remote.getPermissions());
|
file.setPermissions(remote.getPermissions());
|
||||||
file.setRemoteId(remote.getRemoteId());
|
file.setRemoteId(remote.getRemoteId());
|
||||||
|
file.setLocalId(remote.getLocalId());
|
||||||
file.setFavorite(remote.isFavorite());
|
file.setFavorite(remote.isFavorite());
|
||||||
if (file.isFolder()) {
|
if (file.isFolder()) {
|
||||||
file.setEncrypted(remote.isEncrypted());
|
file.setEncrypted(remote.isEncrypted());
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* Nextcloud Android client application
|
||||||
|
*
|
||||||
|
* @author Tobias Kaminsky
|
||||||
|
* Copyright (C) 2022 Tobias Kaminsky
|
||||||
|
* Copyright (C) 2022 Nextcloud GmbH
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.owncloud.android.datamodel
|
||||||
|
|
||||||
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Assert.assertNotEquals
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class OCFileTest {
|
||||||
|
@Test
|
||||||
|
fun testLongIds() {
|
||||||
|
val sut = OCFile("/")
|
||||||
|
|
||||||
|
sut.remoteId = "12345678ocjycgrudn78"
|
||||||
|
assertEquals(12345678, sut.localId)
|
||||||
|
|
||||||
|
sut.remoteId = "00000008ocjycgrudn78"
|
||||||
|
assertEquals(8, sut.localId)
|
||||||
|
|
||||||
|
// this will fail as fileId is too large
|
||||||
|
sut.remoteId = "1234567891011ocjycgrudn78"
|
||||||
|
assertNotEquals(1234567891011L, sut.localId)
|
||||||
|
|
||||||
|
sut.localId = 1234567891011L
|
||||||
|
assertEquals(1234567891011L, sut.localId)
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,7 +6,7 @@ buildscript {
|
||||||
daggerVersion = "2.44.2"
|
daggerVersion = "2.44.2"
|
||||||
markwonVersion = "4.6.2"
|
markwonVersion = "4.6.2"
|
||||||
prismVersion = "2.0.0"
|
prismVersion = "2.0.0"
|
||||||
androidLibraryVersion = "master-SNAPSHOT"
|
androidLibraryVersion = "localId-SNAPSHOT"
|
||||||
mockitoVersion = "4.11.0"
|
mockitoVersion = "4.11.0"
|
||||||
mockitoKotlinVersion = "4.1.0"
|
mockitoKotlinVersion = "4.1.0"
|
||||||
mockkVersion = "1.13.3"
|
mockkVersion = "1.13.3"
|
||||||
|
|
Loading…
Reference in a new issue