Add animations to settings

This commit is contained in:
Lucas Lima 2020-04-01 09:10:02 -03:00
parent 77c24f9017
commit ffdafd8bb2
No known key found for this signature in database
GPG key ID: C828A958035D9C34
4 changed files with 15 additions and 4 deletions

View file

@ -403,10 +403,10 @@ class GameActivity : DaggerAppCompatActivity() {
}
private fun waitAndShowEndGameDialog(victory: Boolean, await: Boolean) {
if (await) {
if (await && viewModel.explosionDelay() != 0L) {
postDelayed(Handler(), {
showEndGameDialog(victory)
}, null, viewModel.explosionDelay())
}, null, (viewModel.explosionDelay() * 0.3).toLong())
} else {
showEndGameDialog(victory)
}

View file

@ -227,7 +227,7 @@ class GameViewModel(
fun revealAllEmptyAreas() = levelFacade.revealAllEmptyAreas()
fun explosionDelay() = 750L
fun explosionDelay() = if (preferencesRepository.useAnimations()) 750L else 0L
suspend fun gameOver() {
levelFacade.run {
@ -273,7 +273,7 @@ class GameViewModel(
fun useAccessibilityMode() = preferencesRepository.useLargeAreas()
private fun refreshIndex(targetIndex: Int, changes: Int = 1) {
if (changes > 1) {
if (!preferencesRepository.useAnimations() || changes > 1) {
field.postValue(levelFacade.field)
} else {
fieldRefresh.postValue(targetIndex)

View file

@ -13,6 +13,7 @@ interface IPreferencesRepository {
fun useFlagAssistant(): Boolean
fun useHapticFeedback(): Boolean
fun useLargeAreas(): Boolean
fun useAnimations(): Boolean
}
class PreferencesRepository(
@ -45,4 +46,7 @@ class PreferencesRepository(
override fun useLargeAreas(): Boolean =
getBoolean("preference_large_area", false)
override fun useAnimations(): Boolean =
getBoolean("preference_animation", true)
}

View file

@ -29,6 +29,13 @@
android:title="@string/auto_flag"
android:summary="@string/settings_auto_flag_desc"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:checked="true"
android:defaultValue="true"
android:key="preference_animation"
android:title="@string/animations"
app:iconSpaceReserved="false" />
</PreferenceCategory>
<PreferenceCategory