Add animations to settings
This commit is contained in:
parent
77c24f9017
commit
ffdafd8bb2
4 changed files with 15 additions and 4 deletions
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue