Opposite if for better code clarity

This commit is contained in:
Benoit Marty 2022-05-05 12:15:10 +02:00
parent ced4146350
commit 0b30c28fe4
5 changed files with 10 additions and 10 deletions

View File

@ -55,8 +55,8 @@ fun Context.isAirplaneModeOn(): Boolean {
return Settings.Global.getInt(contentResolver, Settings.Global.AIRPLANE_MODE_ON, 0) != 0 return Settings.Global.getInt(contentResolver, Settings.Global.AIRPLANE_MODE_ON, 0) != 0
} }
fun Context.isAnimationDisabled(): Boolean { fun Context.isAnimationEnabled(): Boolean {
return Settings.Global.getFloat(contentResolver, Settings.Global.ANIMATOR_DURATION_SCALE, 1f) == 0f return Settings.Global.getFloat(contentResolver, Settings.Global.ANIMATOR_DURATION_SCALE, 1f) != 0f
} }
/** /**

View File

@ -105,7 +105,7 @@ import im.vector.app.core.utils.colorizeMatchingText
import im.vector.app.core.utils.copyToClipboard import im.vector.app.core.utils.copyToClipboard
import im.vector.app.core.utils.createJSonViewerStyleProvider import im.vector.app.core.utils.createJSonViewerStyleProvider
import im.vector.app.core.utils.createUIHandler import im.vector.app.core.utils.createUIHandler
import im.vector.app.core.utils.isAnimationDisabled import im.vector.app.core.utils.isAnimationEnabled
import im.vector.app.core.utils.isValidUrl import im.vector.app.core.utils.isValidUrl
import im.vector.app.core.utils.onPermissionDeniedDialog import im.vector.app.core.utils.onPermissionDeniedDialog
import im.vector.app.core.utils.onPermissionDeniedSnackbar import im.vector.app.core.utils.onPermissionDeniedSnackbar
@ -587,7 +587,7 @@ class TimelineFragment @Inject constructor(
} }
private fun handleChatEffect(chatEffect: ChatEffect) { private fun handleChatEffect(chatEffect: ChatEffect) {
if (requireContext().isAnimationDisabled()) { if (!requireContext().isAnimationEnabled()) {
Timber.d("Do not perform chat effect, animations are disabled.") Timber.d("Do not perform chat effect, animations are disabled.")
return return
} }

View File

@ -24,7 +24,7 @@ import androidx.core.view.isVisible
import im.vector.app.R import im.vector.app.R
import im.vector.app.core.animations.play import im.vector.app.core.animations.play
import im.vector.app.core.di.ActiveSessionHolder import im.vector.app.core.di.ActiveSessionHolder
import im.vector.app.core.utils.isAnimationDisabled import im.vector.app.core.utils.isAnimationEnabled
import im.vector.app.databinding.FragmentFtueAccountCreatedBinding import im.vector.app.databinding.FragmentFtueAccountCreatedBinding
import im.vector.app.features.onboarding.OnboardingAction import im.vector.app.features.onboarding.OnboardingAction
import im.vector.app.features.onboarding.OnboardingViewEvents import im.vector.app.features.onboarding.OnboardingViewEvents
@ -58,7 +58,7 @@ class FtueAuthAccountCreatedFragment @Inject constructor(
views.personalizeButtonGroup.isVisible = canPersonalize views.personalizeButtonGroup.isVisible = canPersonalize
views.takeMeHomeButtonGroup.isVisible = !canPersonalize views.takeMeHomeButtonGroup.isVisible = !canPersonalize
if (!hasPlayedConfetti && !canPersonalize && !requireContext().isAnimationDisabled()) { if (!hasPlayedConfetti && !canPersonalize && requireContext().isAnimationEnabled()) {
hasPlayedConfetti = true hasPlayedConfetti = true
views.viewKonfetti.isVisible = true views.viewKonfetti.isVisible = true
views.viewKonfetti.play() views.viewKonfetti.play()

View File

@ -22,7 +22,7 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.core.view.isVisible import androidx.core.view.isVisible
import im.vector.app.core.animations.play import im.vector.app.core.animations.play
import im.vector.app.core.utils.isAnimationDisabled import im.vector.app.core.utils.isAnimationEnabled
import im.vector.app.databinding.FragmentFtuePersonalizationCompleteBinding import im.vector.app.databinding.FragmentFtuePersonalizationCompleteBinding
import im.vector.app.features.onboarding.OnboardingAction import im.vector.app.features.onboarding.OnboardingAction
import im.vector.app.features.onboarding.OnboardingViewEvents import im.vector.app.features.onboarding.OnboardingViewEvents
@ -44,7 +44,7 @@ class FtueAuthPersonalizationCompleteFragment @Inject constructor() : AbstractFt
private fun setupViews() { private fun setupViews() {
views.personalizationCompleteCta.debouncedClicks { viewModel.handle(OnboardingAction.PostViewEvent(OnboardingViewEvents.OnTakeMeHome)) } views.personalizationCompleteCta.debouncedClicks { viewModel.handle(OnboardingAction.PostViewEvent(OnboardingViewEvents.OnTakeMeHome)) }
if (!hasPlayedConfetti && !requireContext().isAnimationDisabled()) { if (!hasPlayedConfetti && requireContext().isAnimationEnabled()) {
hasPlayedConfetti = true hasPlayedConfetti = true
views.viewKonfetti.isVisible = true views.viewKonfetti.isVisible = true
views.viewKonfetti.play() views.viewKonfetti.play()

View File

@ -25,7 +25,7 @@ import com.tapadoo.alerter.Alerter
import im.vector.app.R import im.vector.app.R
import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.core.platform.VectorBaseActivity
import im.vector.app.core.time.Clock import im.vector.app.core.time.Clock
import im.vector.app.core.utils.isAnimationDisabled import im.vector.app.core.utils.isAnimationEnabled
import im.vector.app.features.analytics.ui.consent.AnalyticsOptInActivity import im.vector.app.features.analytics.ui.consent.AnalyticsOptInActivity
import im.vector.app.features.pin.PinActivity import im.vector.app.features.pin.PinActivity
import im.vector.app.features.signout.hard.SignedOutActivity import im.vector.app.features.signout.hard.SignedOutActivity
@ -218,7 +218,7 @@ class PopupAlertManager @Inject constructor(
if (!alert.isLight) { if (!alert.isLight) {
clearLightStatusBar() clearLightStatusBar()
} }
val noAnimation = !animate || activity.isAnimationDisabled() val noAnimation = !(animate && activity.isAnimationEnabled())
alert.weakCurrentActivity = WeakReference(activity) alert.weakCurrentActivity = WeakReference(activity)
val alerter = Alerter.create(activity, alert.layoutRes) val alerter = Alerter.create(activity, alert.layoutRes)