From d0b62738e1bc0d3a96c1c17fc564e6a35470bf0a Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 7 Dec 2021 12:51:39 +0100 Subject: [PATCH] Analytics: opt-in: handle back pressed --- .../analytics/ui/consent/AnalyticsOptInFragment.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/features/analytics/ui/consent/AnalyticsOptInFragment.kt b/vector/src/main/java/im/vector/app/features/analytics/ui/consent/AnalyticsOptInFragment.kt index 35bc25e3af..1c91af063f 100644 --- a/vector/src/main/java/im/vector/app/features/analytics/ui/consent/AnalyticsOptInFragment.kt +++ b/vector/src/main/java/im/vector/app/features/analytics/ui/consent/AnalyticsOptInFragment.kt @@ -24,13 +24,15 @@ import com.airbnb.mvrx.activityViewModel import im.vector.app.R import im.vector.app.config.analyticsConfig import im.vector.app.core.extensions.setTextWithColoredPart +import im.vector.app.core.platform.OnBackPressed import im.vector.app.core.platform.VectorBaseFragment import im.vector.app.core.utils.openUrlInChromeCustomTab import im.vector.app.databinding.FragmentAnalyticsOptinBinding import javax.inject.Inject class AnalyticsOptInFragment @Inject constructor( -) : VectorBaseFragment() { +) : VectorBaseFragment(), + OnBackPressed { // Share the view model with the Activity so that the Activity // can decide what to do when the data has been saved @@ -64,4 +66,11 @@ class AnalyticsOptInFragment @Inject constructor( } ) } + + override fun onBackPressed(toolbarButton: Boolean): Boolean { + // Consider user does not give consent + viewModel.handle(AnalyticsConsentViewActions.SetUserConsent(userConsent = false)) + // And consume the event + return true + } }