Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions drawable_resources/ic_people.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ public boolean saveFile(OCFile file) {
cv.put(ProviderTableMeta.FILE_OWNER_ID, file.getOwnerId());
cv.put(ProviderTableMeta.FILE_OWNER_DISPLAY_NAME, file.getOwnerDisplayName());
cv.put(ProviderTableMeta.FILE_NOTE, file.getNote());
cv.put(ProviderTableMeta.FILE_SHAREES, TextUtils.join(",", file.getSharees()));

boolean sameRemotePath = fileExists(file.getRemotePath());
if (sameRemotePath ||
Expand Down Expand Up @@ -452,6 +453,7 @@ private ContentValues createContentValueForFile(OCFile folder) {
cv.put(ProviderTableMeta.FILE_OWNER_ID, folder.getOwnerId());
cv.put(ProviderTableMeta.FILE_OWNER_DISPLAY_NAME, folder.getOwnerDisplayName());
cv.put(ProviderTableMeta.FILE_NOTE, folder.getNote());
cv.put(ProviderTableMeta.FILE_SHAREES, TextUtils.join(",", folder.getSharees()));

return cv;
}
Expand Down Expand Up @@ -491,6 +493,7 @@ private ContentValues createContentValueForFile(OCFile file, OCFile folder) {
cv.put(ProviderTableMeta.FILE_OWNER_ID, file.getOwnerId());
cv.put(ProviderTableMeta.FILE_OWNER_DISPLAY_NAME, file.getOwnerDisplayName());
cv.put(ProviderTableMeta.FILE_NOTE, file.getNote());
cv.put(ProviderTableMeta.FILE_SHAREES, TextUtils.join(",", file.getSharees()));

return cv;
}
Expand Down Expand Up @@ -989,6 +992,14 @@ private OCFile createFileInstance(Cursor c) {
file.setOwnerId(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_OWNER_ID)));
file.setOwnerDisplayName(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_OWNER_DISPLAY_NAME)));
file.setNote(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_NOTE)));

String sharees = c.getString(c.getColumnIndex(ProviderTableMeta.FILE_SHAREES));

if (sharees == null || sharees.isEmpty()) {
file.setSharees(new ArrayList<>());
} else {
file.setSharees(new ArrayList<>(Arrays.asList(sharees.split(","))));
}
}

return file;
Expand Down Expand Up @@ -1217,7 +1228,7 @@ private OCShare createShareInstance(Cursor c) {
share.setSharedWithDisplayName(
c.getString(c.getColumnIndex(ProviderTableMeta.OCSHARES_SHARE_WITH_DISPLAY_NAME)));
share.setFolder(c.getInt(c.getColumnIndex(ProviderTableMeta.OCSHARES_IS_DIRECTORY)) == 1);
share.setUserId(c.getLong(c.getColumnIndex(ProviderTableMeta.OCSHARES_USER_ID)));
share.setUserId(c.getString(c.getColumnIndex(ProviderTableMeta.OCSHARES_USER_ID)));
share.setRemoteId(c.getLong(c.getColumnIndex(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED)));
share.setPasswordProtected(c.getInt(c.getColumnIndex(ProviderTableMeta.OCSHARES_IS_PASSWORD_PROTECTED)) == 1);
share.setNote(c.getString(c.getColumnIndex(ProviderTableMeta.OCSHARES_NOTE)));
Expand Down
13 changes: 7 additions & 6 deletions src/main/java/com/owncloud/android/datamodel/OCFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,22 @@
import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.NonNull;
import androidx.core.content.FileProvider;
import com.owncloud.android.R;
import com.owncloud.android.lib.common.network.WebdavEntry;
import com.owncloud.android.lib.common.network.WebdavUtils;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.files.model.ServerFileInterface;
import com.owncloud.android.utils.MimeType;

import java.io.File;

import androidx.annotation.NonNull;
import androidx.core.content.FileProvider;
import lombok.Getter;
import lombok.Setter;
import third_parties.daveKoeller.AlphanumComparator;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterface {
private final static String PERMISSION_SHARED_WITH_ME = "S";
private final static String PERMISSION_CAN_RESHARE = "R";
Expand Down Expand Up @@ -88,6 +88,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
@Getter @Setter private String ownerId;
@Getter @Setter private String ownerDisplayName;
@Getter @Setter String note;
@Getter @Setter private List<String> sharees = new ArrayList<>();

/**
* URI to the local path of the file contents, if stored in the device; cached after first call
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import android.view.MenuItem;
import android.view.WindowManager;
import android.widget.ImageView;

import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.lib.common.OwnCloudAccount;
Expand All @@ -62,7 +63,7 @@
import com.owncloud.android.utils.DisplayUtils.AvatarGenerationListener;
import com.owncloud.android.utils.FileStorageUtils;
import com.owncloud.android.utils.MimeTypeUtil;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.GetMethod;
import org.jetbrains.annotations.NotNull;
Expand All @@ -74,6 +75,8 @@
import java.net.URLEncoder;
import java.util.List;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

/**
* Manager for concurrent access to thumbnails cache.
*/
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/owncloud/android/db/ProviderMeta.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*/
public class ProviderMeta {
public static final String DB_NAME = "filelist";
public static final int DB_VERSION = 44;
public static final int DB_VERSION = 45;

private ProviderMeta() {
// No instance
Expand Down Expand Up @@ -109,14 +109,15 @@ static public class ProviderTableMeta implements BaseColumns {
public static final String FILE_OWNER_ID = "owner_id";
public static final String FILE_OWNER_DISPLAY_NAME = "owner_display_name";
public static final String FILE_NOTE = "note";
public static final String FILE_SHAREES = "sharees";

public static final String[] FILE_ALL_COLUMNS = {
_ID, FILE_PARENT, FILE_NAME, FILE_CREATION, FILE_MODIFIED,
FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA, FILE_CONTENT_LENGTH, FILE_CONTENT_TYPE, FILE_STORAGE_PATH,
FILE_PATH, FILE_ACCOUNT_OWNER, FILE_LAST_SYNC_DATE, FILE_LAST_SYNC_DATE_FOR_DATA, FILE_ETAG,
FILE_ETAG_ON_SERVER, FILE_SHARED_VIA_LINK, FILE_SHARED_WITH_SHAREE, FILE_PUBLIC_LINK, FILE_PERMISSIONS,
FILE_REMOTE_ID, FILE_UPDATE_THUMBNAIL, FILE_IS_DOWNLOADING, FILE_ETAG_IN_CONFLICT, FILE_FAVORITE,
FILE_IS_ENCRYPTED, FILE_MOUNT_TYPE, FILE_HAS_PREVIEW, FILE_UNREAD_COMMENTS_COUNT
FILE_IS_ENCRYPTED, FILE_MOUNT_TYPE, FILE_HAS_PREVIEW, FILE_UNREAD_COMMENTS_COUNT, FILE_SHAREES
};

public static final String FILE_DEFAULT_SORT_ORDER = FILE_NAME + " collate nocase asc";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,8 @@ private void createFilesTable(SQLiteDatabase db) {
+ ProviderTableMeta.FILE_UNREAD_COMMENTS_COUNT + INTEGER
+ ProviderTableMeta.FILE_OWNER_ID + TEXT
+ ProviderTableMeta.FILE_OWNER_DISPLAY_NAME + TEXT
+ ProviderTableMeta.FILE_NOTE + " TEXT);"
+ ProviderTableMeta.FILE_NOTE + TEXT
+ ProviderTableMeta.FILE_SHAREES + " TEXT);"
);
}

Expand Down Expand Up @@ -1874,9 +1875,9 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.beginTransaction();
try {
db.execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
ADD_COLUMN + ProviderTableMeta.FILE_OWNER_ID + " TEXT ");
ADD_COLUMN + ProviderTableMeta.FILE_OWNER_ID + " TEXT ");
db.execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
ADD_COLUMN + ProviderTableMeta.FILE_OWNER_DISPLAY_NAME + " TEXT ");
ADD_COLUMN + ProviderTableMeta.FILE_OWNER_DISPLAY_NAME + " TEXT ");

upgraded = true;
db.setTransactionSuccessful();
Expand Down Expand Up @@ -1906,6 +1907,24 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
if (!upgraded) {
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
}

if (oldVersion < 45 && newVersion >= 45) {
Log_OC.i(SQL, "Entering in the #45 add sharees to file table");
db.beginTransaction();
try {
db.execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
ADD_COLUMN + ProviderTableMeta.FILE_SHAREES + " TEXT ");

upgraded = true;
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}

if (!upgraded) {
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
}
}

@Override
Expand Down
Loading