Skip to content

Commit ceb6cd6

Browse files
Merge pull request nextcloud#11607 from nextcloud/shareLinkMissing
show share link in shared overview for folders
2 parents 412a7d0 + f313a83 commit ceb6cd6

File tree

4 files changed

+188
-18
lines changed

4 files changed

+188
-18
lines changed
25 KB
Loading

app/src/androidTest/java/com/owncloud/android/ui/fragment/GroupfolderListFragmentIT.kt

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,6 @@ class GroupfolderListFragmentIT : AbstractIT() {
4242
activity = testActivityRule.launchActivity(null)
4343
}
4444

45-
@ScreenshotTest
46-
@Test
47-
fun showEmpty() {
48-
val sut = GroupfolderListFragment()
49-
activity.addFragment(sut)
50-
51-
waitForIdleSync()
52-
53-
screenshot(activity)
54-
}
55-
5645
@Test
5746
@ScreenshotTest
5847
fun showGroupfolders() {
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
/*
2+
*
3+
* Nextcloud Android client application
4+
*
5+
* @author Tobias Kaminsky
6+
* Copyright (C) 2023 Tobias Kaminsky
7+
* Copyright (C) 2023 Nextcloud GmbH
8+
*
9+
* This program is free software: you can redistribute it and/or modify
10+
* it under the terms of the GNU Affero General Public License as published by
11+
* the Free Software Foundation, either version 3 of the License, or
12+
* (at your option) any later version.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU Affero General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Affero General Public License
20+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
21+
*/
22+
23+
package com.owncloud.android.ui.fragment
24+
25+
import android.view.View
26+
import androidx.test.espresso.intent.rule.IntentsTestRule
27+
import com.nextcloud.test.GrantStoragePermissionRule
28+
import com.nextcloud.test.TestActivity
29+
import com.owncloud.android.AbstractIT
30+
import com.owncloud.android.datamodel.OCFile
31+
import com.owncloud.android.lib.resources.shares.OCShare
32+
import com.owncloud.android.lib.resources.shares.ShareType
33+
import com.owncloud.android.utils.ScreenshotTest
34+
import org.junit.Before
35+
import org.junit.Rule
36+
import org.junit.Test
37+
38+
internal class SharedListFragmentIT : AbstractIT() {
39+
@get:Rule
40+
val testActivityRule = IntentsTestRule(TestActivity::class.java, true, false)
41+
42+
@get:Rule
43+
val permissionRule = GrantStoragePermissionRule.grant()
44+
45+
lateinit var sut: TestActivity
46+
47+
@Before
48+
fun before() {
49+
sut = testActivityRule.launchActivity(null)
50+
}
51+
52+
@Test
53+
@ScreenshotTest
54+
fun showSharedFiles() {
55+
val fragment = SharedListFragment()
56+
57+
val file = OCFile("/shared to admin.png").apply {
58+
remoteId = "00000001"
59+
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
60+
mimeType = "image/png"
61+
fileLength = 1024000
62+
modificationTimestamp = 1188206955
63+
permissions = OCFile.PERMISSION_CAN_RESHARE
64+
sut.storageManager.saveFile(this)
65+
}
66+
67+
val file1 = OCFile("/shared to group.png").apply {
68+
remoteId = "00000001"
69+
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
70+
mimeType = "image/png"
71+
fileLength = 1024000
72+
modificationTimestamp = 1188206955
73+
permissions = OCFile.PERMISSION_CAN_RESHARE
74+
sut.storageManager.saveFile(this)
75+
}
76+
77+
val file2 = OCFile("/shared via public link.png").apply {
78+
remoteId = "00000001"
79+
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
80+
mimeType = "image/png"
81+
fileLength = 1024000
82+
modificationTimestamp = 1188206955
83+
permissions = OCFile.PERMISSION_CAN_RESHARE
84+
sut.storageManager.saveFile(this)
85+
}
86+
87+
val file3 = OCFile("/shared to personal circle.png").apply {
88+
remoteId = "00000001"
89+
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
90+
mimeType = "image/png"
91+
fileLength = 1024000
92+
modificationTimestamp = 1188206955
93+
permissions = OCFile.PERMISSION_CAN_RESHARE
94+
sut.storageManager.saveFile(this)
95+
}
96+
97+
val file4 = OCFile("/shared to talk.png").apply {
98+
remoteId = "00000001"
99+
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
100+
mimeType = "image/png"
101+
fileLength = 1024000
102+
modificationTimestamp = 1188206955
103+
permissions = OCFile.PERMISSION_CAN_RESHARE
104+
sut.storageManager.saveFile(this)
105+
}
106+
107+
val shares = listOf(
108+
OCShare(file.decryptedRemotePath).apply {
109+
remoteId = 1
110+
shareType = ShareType.USER
111+
sharedWithDisplayName = "Admin"
112+
permissions = OCShare.MAXIMUM_PERMISSIONS_FOR_FILE
113+
userId = getUserId(user)
114+
sharedDate = 1188206955
115+
mimetype = "image/png"
116+
sut.storageManager.saveShare(this)
117+
},
118+
119+
OCShare(file1.decryptedRemotePath).apply {
120+
remoteId = 2
121+
shareType = ShareType.GROUP
122+
sharedWithDisplayName = "Group"
123+
permissions = OCShare.MAXIMUM_PERMISSIONS_FOR_FILE
124+
userId = getUserId(user)
125+
sharedDate = 1188206955
126+
mimetype = "image/png"
127+
sut.storageManager.saveShare(this)
128+
},
129+
130+
OCShare(file2.decryptedRemotePath).apply {
131+
remoteId = 3
132+
shareType = ShareType.PUBLIC_LINK
133+
label = "Customer"
134+
sharedDate = 1188206955
135+
mimetype = "image/png"
136+
sut.storageManager.saveShare(this)
137+
},
138+
139+
OCShare(file3.decryptedRemotePath).apply {
140+
remoteId = 4
141+
shareType = ShareType.CIRCLE
142+
sharedWithDisplayName = "Personal circle"
143+
permissions = OCShare.SHARE_PERMISSION_FLAG
144+
userId = getUserId(user)
145+
sharedDate = 1188206955
146+
mimetype = "image/png"
147+
sut.storageManager.saveShare(this)
148+
},
149+
150+
OCShare(file4.decryptedRemotePath).apply {
151+
remoteId = 11
152+
shareType = ShareType.ROOM
153+
sharedWithDisplayName = "Admin"
154+
permissions = OCShare.SHARE_PERMISSION_FLAG
155+
userId = getUserId(user)
156+
sharedDate = 1188206955
157+
mimetype = "image/png"
158+
sut.storageManager.saveShare(this)
159+
}
160+
)
161+
162+
sut.addFragment(fragment)
163+
164+
shortSleep()
165+
166+
sut.runOnUiThread {
167+
fragment.isLoading = false
168+
fragment.mEmptyListContainer.visibility = View.GONE
169+
fragment.adapter.setData(
170+
shares,
171+
SearchType.SHARED_FILTER,
172+
storageManager,
173+
null,
174+
true
175+
)
176+
}
177+
178+
waitForIdleSync()
179+
shortSleep()
180+
shortSleep()
181+
shortSleep()
182+
183+
screenshot(sut)
184+
}
185+
}

app/src/main/java/com/owncloud/android/ui/adapter/OCFileListDelegate.kt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ import com.owncloud.android.datamodel.FileDataStorageManager
3636
import com.owncloud.android.datamodel.OCFile
3737
import com.owncloud.android.datamodel.SyncedFolderProvider
3838
import com.owncloud.android.datamodel.ThumbnailsCacheManager
39-
import com.owncloud.android.datamodel.ThumbnailsCacheManager.AsyncGalleryImageDrawable
40-
import com.owncloud.android.datamodel.ThumbnailsCacheManager.GalleryImageGenerationTask
4139
import com.owncloud.android.datamodel.ThumbnailsCacheManager.GalleryImageGenerationTask.GalleryListener
42-
import com.owncloud.android.datamodel.ThumbnailsCacheManager.ThumbnailGenerationTask
4340
import com.owncloud.android.lib.common.utils.Log_OC
4441
import com.owncloud.android.ui.activity.ComponentsGetter
4542
import com.owncloud.android.ui.fragment.SearchType
@@ -68,7 +65,7 @@ class OCFileListDelegate(
6865
private val checkedFiles: MutableSet<OCFile> = HashSet()
6966
private var highlightedItem: OCFile? = null
7067
var isMultiSelect = false
71-
private val asyncTasks: MutableList<ThumbnailGenerationTask> = ArrayList()
68+
private val asyncTasks: MutableList<ThumbnailsCacheManager.ThumbnailGenerationTask> = ArrayList()
7269
private val asyncGalleryTasks: MutableList<ThumbnailsCacheManager.GalleryImageGenerationTask> = ArrayList()
7370
fun setHighlightedItem(highlightedItem: OCFile?) {
7471
this.highlightedItem = highlightedItem
@@ -139,7 +136,7 @@ class OCFileListDelegate(
139136
}
140137
}
141138
try {
142-
val task = GalleryImageGenerationTask(
139+
val task = ThumbnailsCacheManager.GalleryImageGenerationTask(
143140
thumbnailView,
144141
user,
145142
storageManager,
@@ -164,7 +161,7 @@ class OCFileListDelegate(
164161
drawable = ColorDrawable(Color.GRAY)
165162
}
166163
val thumbnail = BitmapUtils.drawableToBitmap(drawable, width / 2, width / 2)
167-
val asyncDrawable = AsyncGalleryImageDrawable(
164+
val asyncDrawable = ThumbnailsCacheManager.AsyncGalleryImageDrawable(
168165
context.resources,
169166
thumbnail,
170167
task
@@ -243,7 +240,6 @@ class OCFileListDelegate(
243240
// shares
244241
val shouldHideShare = gridView ||
245242
hideItemOptions ||
246-
file.isFolder && !file.canReshare() ||
247243
!file.isFolder && file.isEncrypted ||
248244
file.isEncrypted && !EncryptionUtils.supportsSecureFiledrop(file, user) ||
249245
searchType == SearchType.FAVORITE_SEARCH

0 commit comments

Comments
 (0)