mirror of
https://github.com/nextcloud/android.git
synced 2024-11-22 05:05:31 +03:00
Groupfolders cannot be encrypted
added test showing folder types Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
parent
c56ccc8363
commit
60757a1853
12 changed files with 122 additions and 30 deletions
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
Binary file not shown.
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 49 KiB |
|
@ -29,6 +29,7 @@ import com.owncloud.android.AbstractIT
|
|||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.resources.shares.ShareType
|
||||
import com.owncloud.android.lib.resources.shares.ShareeUser
|
||||
import com.owncloud.android.utils.MimeType
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Assert
|
||||
|
@ -80,90 +81,103 @@ class OCFileListFragmentStaticServerIT : AbstractIT() {
|
|||
/**
|
||||
* Use same values as {@link FileDetailSharingFragmentIT listSharesFileAllShareTypes }
|
||||
*/
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
fun showSharedFiles() {
|
||||
val sut = testActivityRule.launchActivity(null)
|
||||
val fragment = OCFileListFragment()
|
||||
|
||||
val userShare = OCFile("/sharedToUser.jpg").apply {
|
||||
OCFile("/sharedToUser.jpg").apply {
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees = listOf(ShareeUser("Admin", "Server Admin", ShareType.USER))
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
sut.storageManager.saveFile(userShare)
|
||||
|
||||
val groupShare = OCFile("/sharedToGroup.jpg").apply {
|
||||
OCFile("/sharedToGroup.jpg").apply {
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees = listOf(ShareeUser("group", "Group", ShareType.GROUP))
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
sut.storageManager.saveFile(groupShare)
|
||||
|
||||
val emailShare = OCFile("/sharedToEmail.jpg").apply {
|
||||
OCFile("/sharedToEmail.jpg").apply {
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees = listOf(ShareeUser("admin@nextcloud.localhost", "admin@nextcloud.localhost", ShareType.EMAIL))
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
sut.storageManager.saveFile(emailShare)
|
||||
|
||||
val publicLink = OCFile("/publicLink.jpg").apply {
|
||||
OCFile("/publicLink.jpg").apply {
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedViaLink = true
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
sut.storageManager.saveFile(publicLink)
|
||||
|
||||
val federatedUserShare = OCFile("/sharedToFederatedUser.jpg").apply {
|
||||
OCFile("/sharedToFederatedUser.jpg").apply {
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees = listOf(
|
||||
ShareeUser("admin@remote.nextcloud.com", "admin@remote.nextcloud.com (remote)", ShareType.FEDERATED)
|
||||
)
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
sut.storageManager.saveFile(federatedUserShare)
|
||||
|
||||
val personalCircleShare = OCFile("/sharedToPersonalCircle.jpg").apply {
|
||||
OCFile("/sharedToPersonalCircle.jpg").apply {
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees = listOf(ShareeUser("circle", "Circle (Personal circle)", ShareType.CIRCLE))
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
sut.storageManager.saveFile(personalCircleShare)
|
||||
|
||||
// as we cannot distinguish circle types, we do not need them right now
|
||||
// val publicCircleShare = OCFile("/sharedToPublicCircle.jpg").apply {
|
||||
// OCFile("/sharedToPublicCircle.jpg").apply {
|
||||
// parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
// isSharedWithSharee = true
|
||||
// sharees = listOf(ShareeUser("circle", "Circle (Public circle)", ShareType.CIRCLE))
|
||||
// modificationTimestamp = 1000
|
||||
// sut.storageManager.saveFile(this)
|
||||
// }
|
||||
// sut.storageManager.saveFile(publicCircleShare)
|
||||
//
|
||||
// val closedCircleShare = OCFile("/sharedToClosedCircle.jpg").apply {
|
||||
// OCFile("/sharedToClosedCircle.jpg").apply {
|
||||
// parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
// isSharedWithSharee = true
|
||||
// sharees = listOf(ShareeUser("circle", "Circle (Closed circle)", ShareType.CIRCLE))
|
||||
// modificationTimestamp = 1000
|
||||
// sut.storageManager.saveFile(this)
|
||||
// }
|
||||
// sut.storageManager.saveFile(closedCircleShare)
|
||||
//
|
||||
// val secretCircleShare = OCFile("/sharedToSecretCircle.jpg").apply {
|
||||
// OCFile("/sharedToSecretCircle.jpg").apply {
|
||||
// parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
// isSharedWithSharee = true
|
||||
// sharees = listOf(ShareeUser("circle", "Circle (Secret circle)", ShareType.CIRCLE))
|
||||
// modificationTimestamp = 1000
|
||||
// sut.storageManager.saveFile(this)
|
||||
// }
|
||||
// sut.storageManager.saveFile(secretCircleShare)
|
||||
|
||||
val userRoomShare = OCFile("/sharedToUserRoom.jpg").apply {
|
||||
OCFile("/sharedToUserRoom.jpg").apply {
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees = listOf(ShareeUser("Conversation", "Admin", ShareType.ROOM))
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
sut.storageManager.saveFile(userRoomShare)
|
||||
|
||||
val groupRoomShare = OCFile("/sharedToGroupRoom.jpg").apply {
|
||||
OCFile("/sharedToGroupRoom.jpg").apply {
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees = listOf(ShareeUser("Conversation", "Meeting", ShareType.ROOM))
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
sut.storageManager.saveFile(groupRoomShare)
|
||||
|
||||
val usersShare = OCFile("/sharedToUsers.jpg").apply {
|
||||
OCFile("/sharedToUsers.jpg").apply {
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees = listOf(
|
||||
|
@ -171,13 +185,67 @@ class OCFileListFragmentStaticServerIT : AbstractIT() {
|
|||
ShareeUser("User", "User", ShareType.USER),
|
||||
ShareeUser("Christine", "Christine Scott", ShareType.USER)
|
||||
)
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
sut.storageManager.saveFile(usersShare)
|
||||
|
||||
val noShare = OCFile("/notShared.jpg").apply {
|
||||
OCFile("/notShared.jpg").apply {
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
sut.addFragment(fragment)
|
||||
|
||||
shortSleep()
|
||||
|
||||
val root = sut.storageManager.getFileByEncryptedRemotePath("/")
|
||||
|
||||
sut.runOnUiThread {
|
||||
fragment.listDirectory(root, false, false)
|
||||
fragment.adapter.setShowShareAvatar(true)
|
||||
}
|
||||
|
||||
waitForIdleSync()
|
||||
shortSleep()
|
||||
shortSleep()
|
||||
shortSleep()
|
||||
|
||||
screenshot(sut)
|
||||
}
|
||||
|
||||
/**
|
||||
* Use same values as {@link FileDetailSharingFragmentIT listSharesFileAllShareTypes }
|
||||
*/
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
fun showFolderTypes() {
|
||||
val sut = testActivityRule.launchActivity(null)
|
||||
val fragment = OCFileListFragment()
|
||||
|
||||
OCFile("/normal/").apply {
|
||||
mimeType = MimeType.DIRECTORY
|
||||
modificationTimestamp = 1624003571000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/groupFolder/").apply {
|
||||
mimeType = MimeType.DIRECTORY
|
||||
modificationTimestamp = 1615003571000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
permissions += "M"
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/encrypted/").apply {
|
||||
mimeType = MimeType.DIRECTORY
|
||||
isEncrypted = true
|
||||
decryptedRemotePath = "/encrypted/"
|
||||
modificationTimestamp = 1614003571000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
sut.storageManager.saveFile(noShare)
|
||||
|
||||
sut.addFragment(fragment)
|
||||
|
||||
|
|
|
@ -506,6 +506,7 @@ public class FileDataStorageManager {
|
|||
cv.put(ProviderTableMeta.FILE_LOCK_TIMESTAMP, file.getLockTimestamp());
|
||||
cv.put(ProviderTableMeta.FILE_LOCK_TIMEOUT, file.getLockTimeout());
|
||||
cv.put(ProviderTableMeta.FILE_LOCK_TOKEN, file.getLockToken());
|
||||
cv.put(ProviderTableMeta.FILE_MODIFIED, file.getModificationTimestamp());
|
||||
|
||||
return cv;
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
|||
@VisibleForTesting
|
||||
public final static String PERMISSION_CAN_RESHARE = "R";
|
||||
private final static String PERMISSION_CAN_WRITE = "CK";
|
||||
private final static String PERMISSION_GROUPFOLDER = "M";
|
||||
|
||||
public static final String PATH_SEPARATOR = "/";
|
||||
public static final String ROOT_PATH = PATH_SEPARATOR;
|
||||
|
@ -618,6 +619,11 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
|||
return permissions != null && permissions.contains(PERMISSION_CAN_WRITE);
|
||||
}
|
||||
|
||||
public boolean isGroupFolder() {
|
||||
String permissions = getPermissions();
|
||||
return permissions != null && permissions.contains(PERMISSION_GROUPFOLDER);
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<OCFile> CREATOR = new Parcelable.Creator<OCFile>() {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -310,7 +310,7 @@ public class FileMenuFilter {
|
|||
}
|
||||
|
||||
private void filterEncrypt(List<Integer> toShow, List<Integer> toHide, boolean endToEndEncryptionEnabled) {
|
||||
if (files.isEmpty() || !isSingleSelection() || isSingleFile() || isEncryptedFolder()
|
||||
if (files.isEmpty() || !isSingleSelection() || isSingleFile() || isEncryptedFolder() || isGroupFolder()
|
||||
|| !endToEndEncryptionEnabled) {
|
||||
toHide.add(R.id.action_encrypted);
|
||||
} else {
|
||||
|
@ -546,6 +546,10 @@ public class FileMenuFilter {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean isGroupFolder() {
|
||||
return files.iterator().next().isGroupFolder();
|
||||
}
|
||||
|
||||
private boolean isSingleImage() {
|
||||
return isSingleSelection() && MimeTypeUtil.isImage(files.iterator().next());
|
||||
}
|
||||
|
|
|
@ -156,6 +156,7 @@ public abstract class EditorWebView extends ExternalSiteWebView {
|
|||
file.isSharedWithSharee(),
|
||||
file.isSharedViaLink(),
|
||||
file.isEncrypted(),
|
||||
file.isGroupFolder(),
|
||||
file.getMountType(),
|
||||
this,
|
||||
themeColorUtils,
|
||||
|
|
|
@ -76,6 +76,7 @@ public class ShareActivity extends FileActivity {
|
|||
file.isSharedWithSharee(),
|
||||
file.isSharedViaLink(),
|
||||
file.isEncrypted(),
|
||||
file.isGroupFolder(),
|
||||
file.getMountType(),
|
||||
this,
|
||||
themeColorUtils,
|
||||
|
|
|
@ -108,6 +108,7 @@ public class UploaderAdapter extends SimpleAdapter {
|
|||
final Drawable icon = MimeTypeUtil.getFolderTypeIcon(isShared,
|
||||
file.isSharedViaLink(),
|
||||
file.isEncrypted(),
|
||||
file.isGroupFolder(),
|
||||
user,
|
||||
file.getMountType(),
|
||||
mContext,
|
||||
|
|
|
@ -858,8 +858,13 @@ public final class DisplayUtils {
|
|||
stopShimmer(shimmerThumbnail, thumbnailView);
|
||||
thumbnailView.setImageDrawable(MimeTypeUtil
|
||||
.getFolderTypeIcon(file.isSharedWithMe() || file.isSharedWithSharee(),
|
||||
file.isSharedViaLink(), file.isEncrypted(),
|
||||
file.getMountType(), context, themeColorUtils, themeDrawableUtils));
|
||||
file.isSharedViaLink(),
|
||||
file.isEncrypted(),
|
||||
file.isGroupFolder(),
|
||||
file.getMountType(),
|
||||
context,
|
||||
themeColorUtils,
|
||||
themeDrawableUtils));
|
||||
} else {
|
||||
if (file.getRemoteId() != null && file.isPreviewAvailable()) {
|
||||
// Thumbnail in cache?
|
||||
|
|
|
@ -157,6 +157,7 @@ public final class MimeTypeUtil {
|
|||
public static Drawable getFolderTypeIcon(boolean isSharedViaUsers,
|
||||
boolean isSharedViaLink,
|
||||
boolean isEncrypted,
|
||||
boolean isGroupfolder,
|
||||
WebdavEntry.MountType mountType,
|
||||
Context context,
|
||||
ThemeColorUtils themeColorUtils,
|
||||
|
@ -164,6 +165,7 @@ public final class MimeTypeUtil {
|
|||
return getFolderTypeIcon(isSharedViaUsers,
|
||||
isSharedViaLink,
|
||||
isEncrypted,
|
||||
isGroupfolder,
|
||||
null,
|
||||
mountType,
|
||||
context,
|
||||
|
@ -183,6 +185,7 @@ public final class MimeTypeUtil {
|
|||
public static Drawable getFolderTypeIcon(boolean isSharedViaUsers,
|
||||
boolean isSharedViaLink,
|
||||
boolean isEncrypted,
|
||||
boolean isGroupFolder,
|
||||
@Nullable User user,
|
||||
WebdavEntry.MountType mountType,
|
||||
Context context,
|
||||
|
@ -198,7 +201,7 @@ public final class MimeTypeUtil {
|
|||
drawableId = R.drawable.folder_encrypted;
|
||||
} else if (WebdavEntry.MountType.EXTERNAL == mountType) {
|
||||
drawableId = R.drawable.folder_external;
|
||||
} else if (WebdavEntry.MountType.GROUP == mountType) {
|
||||
} else if (WebdavEntry.MountType.GROUP == mountType || isGroupFolder) {
|
||||
drawableId = R.drawable.folder_group;
|
||||
} else {
|
||||
drawableId = R.drawable.folder;
|
||||
|
@ -214,6 +217,7 @@ public final class MimeTypeUtil {
|
|||
ThemeColorUtils themeColorUtils,
|
||||
ThemeDrawableUtils themeDrawableUtils) {
|
||||
return getFolderTypeIcon(false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
WebdavEntry.MountType.INTERNAL,
|
||||
|
|
|
@ -61,6 +61,7 @@ done < <(adb devices | cut -f1)
|
|||
|
||||
if [ "$emulatorIsRunning" == false ] ; then
|
||||
"$(command -v emulator)" -writable-system -avd uiComparison -no-snapshot -gpu swiftshader_indirect -no-audio -skin 500x833 &
|
||||
sleep 20
|
||||
fi
|
||||
|
||||
if [ -e $5 ] ; then
|
||||
|
|
Loading…
Reference in a new issue