Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.5.0.1 #204

Merged
merged 1 commit into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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