Skip to content

Commit

Permalink
Only show the review for supported languages.
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulWoitaschek committed Jun 18, 2023
1 parent 4c17ff8 commit f0c1274
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
15 changes: 15 additions & 0 deletions review/src/main/kotlin/voice/review/ReviewTranslated.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package voice.review

import android.content.Context
import javax.inject.Inject

class ReviewTranslated
@Inject constructor(
private val context: Context,
) {

fun translated(): Boolean {
val language = context.resources.configuration.locales[0].language.lowercase()
return language in listOf("en", "de")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ class ShouldShowReviewDialog
private val reviewDialogShown: DataStore<Boolean>,
private val bookRepository: BookRepository,
private val playStateManager: PlayStateManager,
private val reviewTranslated: ReviewTranslated,
) {

internal suspend fun shouldShow(): Boolean {
return isNotPlaying() &&
return reviewTranslated.translated() &&
isNotPlaying() &&
enoughTimeElapsedSinceInstallation() &&
reviewDialogNotShown() &&
listenedForEnoughTime()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,13 @@ class ShouldShowReviewDialogTest {
reviewDialogShown = mockk {
every { data } returns flowOf(reviewDialogShown)
},
reviewTranslated = mockk {
every { translated() } returns true
},
)
val showsreviewDialog = runBlocking {
val showsReviewDialog = runBlocking {
shouldShowReviewDialog.shouldShow()
}
showsreviewDialog shouldBe expected
showsReviewDialog shouldBe expected
}
}

0 comments on commit f0c1274

Please sign in to comment.