mirror of
https://github.com/nextcloud/android.git
synced 2024-12-20 07:52:18 +03:00
Merge remote-tracking branch 'origin/master' into dev
This commit is contained in:
commit
8360983238
6 changed files with 38 additions and 25 deletions
4
.github/workflows/codeql.yml
vendored
4
.github/workflows/codeql.yml
vendored
|
@ -32,7 +32,7 @@ jobs:
|
|||
with:
|
||||
swap-size-gb: 10
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@8662eabe0e9f338a07350b7fd050732745f93848 # v2.3.1
|
||||
uses: github/codeql-action/init@f3feb00acb00f31a6f60280e6ace9ca31d91c76a # v2.3.2
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
- name: Set up JDK
|
||||
|
@ -46,4 +46,4 @@ jobs:
|
|||
echo "org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > "$HOME/.gradle/gradle.properties"
|
||||
./gradlew assembleDebug
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@8662eabe0e9f338a07350b7fd050732745f93848 # v2.3.1
|
||||
uses: github/codeql-action/analyze@f3feb00acb00f31a6f60280e6ace9ca31d91c76a # v2.3.2
|
||||
|
|
2
.github/workflows/scorecard.yml
vendored
2
.github/workflows/scorecard.yml
vendored
|
@ -33,6 +33,6 @@ jobs:
|
|||
|
||||
# Upload the results to GitHub's code scanning dashboard.
|
||||
- name: "Upload to code-scanning"
|
||||
uses: github/codeql-action/upload-sarif@8662eabe0e9f338a07350b7fd050732745f93848 # v2.3.1
|
||||
uses: github/codeql-action/upload-sarif@f3feb00acb00f31a6f60280e6ace9ca31d91c76a # v2.3.2
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 8 KiB |
Binary file not shown.
After Width: | Height: | Size: 42 KiB |
|
@ -32,8 +32,10 @@ import com.owncloud.android.AbstractIT
|
|||
import com.owncloud.android.datamodel.ImageDimension
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.datamodel.ThumbnailsCacheManager
|
||||
import com.owncloud.android.datamodel.ThumbnailsCacheManager.InitDiskCacheTask
|
||||
import com.owncloud.android.datamodel.ThumbnailsCacheManager.PREFIX_RESIZED_IMAGE
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertNotNull
|
||||
import org.junit.Before
|
||||
|
@ -46,16 +48,14 @@ class GalleryFragmentIT : AbstractIT() {
|
|||
val testActivityRule = IntentsTestRule(TestActivity::class.java, true, false)
|
||||
|
||||
lateinit var activity: TestActivity
|
||||
val random = Random()
|
||||
val random = Random(1)
|
||||
|
||||
@Before
|
||||
fun before() {
|
||||
activity = testActivityRule.launchActivity(null)
|
||||
|
||||
createImage(10000001, true, 700, 300)
|
||||
createImage(10000002, true, 500, 300)
|
||||
|
||||
createImage(10000007, true, 300, 400)
|
||||
// initialise thumbnails cache on background thread
|
||||
InitDiskCacheTask().execute()
|
||||
}
|
||||
|
||||
@After
|
||||
|
@ -65,15 +65,32 @@ class GalleryFragmentIT : AbstractIT() {
|
|||
super.after()
|
||||
}
|
||||
|
||||
@ScreenshotTest
|
||||
@Test
|
||||
fun showGallery() {
|
||||
fun showEmpty() {
|
||||
val sut = GalleryFragment()
|
||||
activity.addFragment(sut)
|
||||
|
||||
longSleep()
|
||||
waitForIdleSync()
|
||||
|
||||
screenshot(activity)
|
||||
}
|
||||
|
||||
private fun createImage(id: Int, createPreview: Boolean = true, width: Int? = null, height: Int? = null) {
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
fun showGallery() {
|
||||
createImage(10000001, 700, 300)
|
||||
createImage(10000002, 500, 300)
|
||||
createImage(10000007, 300, 400)
|
||||
|
||||
val sut = GalleryFragment()
|
||||
activity.addFragment(sut)
|
||||
|
||||
waitForIdleSync()
|
||||
screenshot(activity)
|
||||
}
|
||||
|
||||
private fun createImage(id: Int, width: Int? = null, height: Int? = null) {
|
||||
val defaultSize = ThumbnailsCacheManager.getThumbnailDimension().toFloat()
|
||||
val file = OCFile("/$id.png").apply {
|
||||
fileId = id.toLong()
|
||||
|
@ -85,13 +102,9 @@ class GalleryFragmentIT : AbstractIT() {
|
|||
storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
if (!createPreview) {
|
||||
return
|
||||
}
|
||||
|
||||
// create dummy thumbnail
|
||||
var w: Int
|
||||
var h: Int
|
||||
val w: Int
|
||||
val h: Int
|
||||
if (width == null || height == null) {
|
||||
if (random.nextBoolean()) {
|
||||
// portrait
|
||||
|
@ -110,7 +123,7 @@ class GalleryFragmentIT : AbstractIT() {
|
|||
val bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888)
|
||||
Canvas(bitmap).apply {
|
||||
drawRGB(random.nextInt(256), random.nextInt(256), random.nextInt(256))
|
||||
drawCircle(w / 2f, h / 2f, Math.min(w, h) / 2f, Paint().apply { color = Color.BLACK })
|
||||
drawCircle(w / 2f, h / 2f, w.coerceAtMost(h) / 2f, Paint().apply { color = Color.BLACK })
|
||||
}
|
||||
ThumbnailsCacheManager.addBitmapToCache(PREFIX_RESIZED_IMAGE + file.remoteId, bitmap)
|
||||
|
||||
|
|
|
@ -195,14 +195,14 @@ class GalleryAdapter(
|
|||
|
||||
if (finalSortedList.isEmpty()) {
|
||||
photoFragment.setEmptyListMessage(SearchType.GALLERY_SEARCH)
|
||||
} else {
|
||||
files = finalSortedList
|
||||
.groupBy { firstOfMonth(it.modificationTimestamp) }
|
||||
.map { GalleryItems(it.key, transformToRows(it.value)) }
|
||||
.sortedBy { it.date }.reversed()
|
||||
|
||||
Handler(Looper.getMainLooper()).post { notifyDataSetChanged() }
|
||||
}
|
||||
|
||||
files = finalSortedList
|
||||
.groupBy { firstOfMonth(it.modificationTimestamp) }
|
||||
.map { GalleryItems(it.key, transformToRows(it.value)) }
|
||||
.sortedBy { it.date }.reversed()
|
||||
|
||||
Handler(Looper.getMainLooper()).post { notifyDataSetChanged() }
|
||||
}
|
||||
|
||||
private fun transformToRows(list: List<OCFile>): List<GalleryRow> {
|
||||
|
|
Loading…
Reference in a new issue