Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Verified Commit 50a7906d authored by Fahim M. Choudhury's avatar Fahim M. Choudhury
Browse files

refactor: update NSFW warning feature code organization

Refactored the code for displaying NSFW warnings on the ApplicationFragment. The warning is now handled by a dedicated function, improving code readability and maintainability.
parent f2796532
Loading
Loading
Loading
Loading
Loading
+12 −16
Original line number Diff line number Diff line
@@ -440,24 +440,20 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) {
    }

    private fun updateAntiFeaturesUi(app: Application) {
        val isNsfwApp =
            app.antiFeatures.find { antiFeature -> antiFeature.containsKey(KEY_ANTI_FEATURES_NSFW) } != null
        with(binding.titleInclude.antiFeatureInfoLayout) {
            isVisible =
                app.antiFeatures.any { antiFeature -> antiFeature.containsKey(KEY_ANTI_FEATURES_NSFW) }
            setOnClickListener { showNsfwWarning() }
        }
    }

        if (isNsfwApp) {
            with(binding.titleInclude) {
                antiFeatureInfoLayout.apply {
                    isVisible = true
                    setOnClickListener {
    private fun showNsfwWarning() {
        ApplicationDialogFragment(
            title = getString(R.string.nsfw_dialog_title),
            message = getString(R.string.nsfw_dialog_message),
            drawableResId = R.drawable.ic_visibility_off
        ).show(childFragmentManager, TAG)
    }
                }
            }
        }
    }

    private fun updateCategoryTitle(app: Application) {
        binding.titleInclude.apply {