Skip to content

Commit

Permalink
Merge pull request #204 from Sav22999/beta
Browse files Browse the repository at this point in the history
2.5.0.1
  • Loading branch information
Sav22999 authored Oct 27, 2022
2 parents c22383b + c554d17 commit 4ca0a63
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 11 deletions.
Binary file modified app/GPS/release/app-GPS-release.aab
Binary file not shown.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId 'org.commonvoice.saverio'
minSdkVersion 26
targetSdk 31
versionCode = 181
versionName '2.5'
versionCode = 182
versionName '2.5.0.1'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
14 changes: 12 additions & 2 deletions app/src/main/java/org/commonvoice/saverio/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class MainActivity : VariableLanguageActivity(R.layout.activity_main) {
fun checkSentencesOfflineMode() {
lifecycleScope.launch {
//println(speakPrefManager.requiredSentencesCount.toString() + " =S= " + speakViewModel.getSentencesCount())
if (speakPrefManager.requiredSentencesCount != speakViewModel.getSentencesCount())
if (speakPrefManager.requiredSentencesCount != speakViewModel.getSentencesCount()) {
SentencesDownloadWorker.attachOneTimeJobToWorkManager(
workManager,
wifiOnly = settingsPrefManager.wifiOnlyDownload
Expand All @@ -145,13 +145,18 @@ class MainActivity : VariableLanguageActivity(R.layout.activity_main) {
checkSentencesOfflineMode()
}, 15000)
}
} else {
Handler().postDelayed({
checkSentencesOfflineMode()
}, 50000)
}
}
}

fun checkClipsOfflineMode() {
lifecycleScope.launch {
//println(listenPrefManager.requiredClipsCount.toString() + " =C= " + listenViewModel.getClipsCount())
if (listenPrefManager.requiredClipsCount != listenViewModel.getClipsCount())
if (listenPrefManager.requiredClipsCount != listenViewModel.getClipsCount()) {
ClipsDownloadWorker.attachOneTimeJobToWorkManager(
workManager,
wifiOnly = settingsPrefManager.wifiOnlyDownload
Expand All @@ -160,6 +165,11 @@ class MainActivity : VariableLanguageActivity(R.layout.activity_main) {
checkClipsOfflineMode()
}, 15000)
}
} else {
Handler().postDelayed({
checkClipsOfflineMode()
}, 50000)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,6 @@ class AdvancedSettingsFragment : ViewBoundFragment<FragmentAdvancedSettingsBindi
messageRes = R.string.text_are_you_sure_clear_offline_data,
buttonTextRes = R.string.button_yes_sure,
onButtonClick = {
listenPrefManager.requiredClipsCount = 3
speakPrefManager.requiredSentencesCount = 3

mainViewModel.clearDB().invokeOnCompletion {
SentencesDownloadWorker.attachOneTimeJobToWorkManager(
workManager, ExistingWorkPolicy.REPLACE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class OfflineModeSettingsFragment : ViewBoundFragment<FragmentOfflineSettingsBin
)
})

Handler().postDelayed({ checkProgressBar() }, 15000)
Handler().postDelayed({ checkProgressBar() }, 5000)
}
}
}
Expand Down Expand Up @@ -222,14 +222,21 @@ class OfflineModeSettingsFragment : ViewBoundFragment<FragmentOfflineSettingsBin
override fun onDestroyView() {
super.onDestroyView()

checkChangedNumber()
}

private fun checkChangedNumber() {
if (changedNumber) {
var workPolicy: ExistingWorkPolicy = ExistingWorkPolicy.APPEND_OR_REPLACE
if (listenPrefManager.requiredClipsCount == 3 || speakPrefManager.requiredSentencesCount == 3) workPolicy =
ExistingWorkPolicy.REPLACE
mainViewModel.clearDB().invokeOnCompletion {
SentencesDownloadWorker.attachOneTimeJobToWorkManager(
workManager, ExistingWorkPolicy.APPEND_OR_REPLACE,
workManager, workPolicy,
wifiOnly = settingsPrefManager.wifiOnlyDownload
)
ClipsDownloadWorker.attachOneTimeJobToWorkManager(
workManager, ExistingWorkPolicy.APPEND_OR_REPLACE,
workManager, workPolicy,
wifiOnly = settingsPrefManager.wifiOnlyDownload
)
}
Expand All @@ -249,7 +256,7 @@ class OfflineModeSettingsFragment : ViewBoundFragment<FragmentOfflineSettingsBin
view.isGone = true
} else {
val widthToUse = (downloaded * width) / total
animationProgressBar(view, view.x.toInt(), widthToUse)
animationProgressBar(view, view.width, widthToUse)
progressBar.isGone = false
}
}
Expand Down

0 comments on commit 4ca0a63

Please sign in to comment.