Skip to content

Commit

Permalink
show sharees
Browse files Browse the repository at this point in the history
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
  • Loading branch information
tobiasKaminsky authored and AndyScherzinger committed Apr 3, 2019
1 parent 479a055 commit d28b7aa
Show file tree
Hide file tree
Showing 15 changed files with 221 additions and 114 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,9 @@ dependencies {
// dependencies for app building
implementation 'androidx.multidex:multidex:2.0.1'
// implementation project('nextcloud-android-library')
genericImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT'
gplayImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT'
versionDevImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT'
genericImplementation 'com.github.nextcloud:android-library:showSharees-SNAPSHOT'
gplayImplementation 'com.github.nextcloud:android-library:showSharees-SNAPSHOT'
versionDevImplementation 'com.github.nextcloud:android-library:showSharees-SNAPSHOT'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
Expand Down
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 @@ -34,7 +34,7 @@
import android.os.RemoteException;
import android.provider.MediaStore;
import android.text.TextUtils;

import androidx.annotation.Nullable;
import com.owncloud.android.MainApp;
import com.owncloud.android.db.ProviderMeta.ProviderTableMeta;
import com.owncloud.android.lib.common.network.WebdavEntry;
Expand All @@ -50,6 +50,8 @@
import com.owncloud.android.utils.FileStorageUtils;
import com.owncloud.android.utils.MimeType;
import com.owncloud.android.utils.MimeTypeUtil;
import lombok.Getter;
import lombok.Setter;

import java.io.File;
import java.util.ArrayList;
Expand Down Expand Up @@ -209,6 +211,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 @@ -451,6 +454,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 @@ -490,6 +494,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 +994,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.isEmpty()) {
file.setSharees(new ArrayList<>());
} else {
file.setSharees(new ArrayList<>(Arrays.asList(sharees.split(","))));
}
}

return file;
Expand Down Expand Up @@ -1217,7 +1230,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 @@ -859,6 +859,7 @@ private int getAvatarDimension() {
Drawable doAvatarInBackground() {
Bitmap avatar = null;

// TODO escape username here?
String accountName = mUserId + "@" + mServerName;

ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(mContext.getContentResolver());
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 @@ -32,7 +32,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 @@ -115,14 +115,15 @@ private ProviderTableMeta() {
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

0 comments on commit d28b7aa

Please sign in to comment.