Skip to content

Commit

Permalink
Media Scanner Simplifications (#1465)
Browse files Browse the repository at this point in the history
* Make the chapter name nullable.

* Directly pass the DocumentFile to the MediaAnalyzer. Unit-test the chapter-name fallback.
Fixes #1447

* Use multi-bindings for the migrations.

* Reset the fileLastModified to trigger a rescan of the chapters.

* Log the uri, not the document file as it has no toString implementation.

* Fix the formatting.
  • Loading branch information
PaulWoitaschek authored Aug 26, 2022
1 parent b5d8fb8 commit 5f8ca69
Show file tree
Hide file tree
Showing 45 changed files with 1,332 additions and 216 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package voice.app.misc

import androidx.annotation.RawRes
import androidx.core.net.toUri
import androidx.documentfile.provider.DocumentFile
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
Expand All @@ -11,17 +11,18 @@ import org.junit.Rule
import org.junit.Test
import org.junit.rules.TemporaryFolder
import org.junit.runner.RunWith
import voice.app.scanner.FFProbeAnalyze
import voice.app.scanner.MediaAnalyzer
import voice.app.test.R
import java.io.File

@RunWith(AndroidJUnit4::class)
class MediaAnalyzerTest {
class MediaAnalyzerInstrumentationTest {

@get:Rule
val temporaryFolder = TemporaryFolder()

private val mediaAnalyzer = MediaAnalyzer(ApplicationProvider.getApplicationContext())
private val mediaAnalyzer = MediaAnalyzer(FFProbeAnalyze(ApplicationProvider.getApplicationContext()))

@Test(timeout = 1000)
fun defectFile_noDuration() {
Expand All @@ -45,7 +46,7 @@ class MediaAnalyzerTest {
private fun durationOfResource(@RawRes resource: Int): Long? {
val file = resourceToTemporaryFile(resource)
return runBlocking {
mediaAnalyzer.analyze(file.toUri())?.duration
mediaAnalyzer.analyze(DocumentFile.fromFile(file))?.duration
}
}

Expand Down
4 changes: 4 additions & 0 deletions data/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("voice.library")
id("kotlin-parcelize")
id("kotlin-kapt")
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.anvil)
alias(libs.plugins.ksp)
Expand Down Expand Up @@ -39,11 +40,13 @@ dependencies {
implementation(libs.appCompat)
implementation(libs.androidxCore)
implementation(libs.serialization.json)
implementation(libs.prefs.core)

api(libs.room.runtime)
ksp(libs.room.compiler)

implementation(libs.dagger.core)
kaptTest(libs.dagger.compiler)

testImplementation(libs.room.testing)
testImplementation(libs.androidX.test.core)
Expand All @@ -52,6 +55,7 @@ dependencies {
testImplementation(libs.junit)
testImplementation(libs.robolectric)
testImplementation(libs.truth)
testImplementation(libs.prefs.inMemory)
testImplementation(libs.koTest.assert)
testImplementation(libs.coroutines.test)
}
Loading

0 comments on commit 5f8ca69

Please sign in to comment.