From 0313e2912dea8a1bd9108e527485e961fb62b2fc Mon Sep 17 00:00:00 2001 From: Guillaume Jacquart Date: Fri, 29 Apr 2022 16:47:04 +0000 Subject: 226 Highlight leaks from widget click --- .../features/dashboard/DashboardFragment.kt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'app/src/main/java/foundation/e/privacycentralapp/features') diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFragment.kt b/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFragment.kt index 32549c9..3f849a6 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFragment.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFragment.kt @@ -24,6 +24,7 @@ import android.text.Html.FROM_HTML_MODE_LEGACY import android.view.View import android.widget.Toast import androidx.core.content.ContextCompat.getColor +import androidx.core.os.bundleOf import androidx.core.view.isVisible import androidx.fragment.app.activityViewModels import androidx.fragment.app.commit @@ -56,6 +57,13 @@ class DashboardFragment : NavToolbarFragment(R.layout.fragment_dashboard), MVIView { + companion object { + private const val PARAM_HIGHLIGHT_INDEX = "PARAM_HIGHLIGHT_INDEX" + fun buildArgs(highlightIndex: Int): Bundle = bundleOf( + PARAM_HIGHLIGHT_INDEX to highlightIndex + ) + } + private val dependencyContainer: DependencyContainer by lazy { (this.requireActivity().application as PrivacyCentralApplication).dependencyContainer } @@ -69,11 +77,15 @@ class DashboardFragment : private var qpDisabledSnackbar: Snackbar? = null + private var highlightIndexOnStart: Int? = null + private var updateUIJob: Job? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + highlightIndexOnStart = arguments?.getInt(PARAM_HIGHLIGHT_INDEX, -1) + updateUIJob = lifecycleScope.launchWhenStarted { viewModel.dashboardFeature.takeView(this, this@DashboardFragment) } @@ -250,6 +262,13 @@ class DashboardFragment : ), FROM_HTML_MODE_LEGACY ) + + highlightIndexOnStart?.let { + binding.graph.post { + graphHolder.highlightIndex(it) + } + highlightIndexOnStart = null + } } if (state.allowedTrackersCount != null && state.trackersCount != null) { -- cgit v1.2.3