From 67fcedf958af66d613f8b7860c25810f75bda493 Mon Sep 17 00:00:00 2001 From: zechs Date: Sun, 25 Jun 2023 16:04:55 +0530 Subject: [PATCH] user confirmation before disabling ads --- .../stream/ui/settings/SettingsFragment.kt | 22 +++++++++++++++++-- app/src/main/res/values/strings.xml | 3 +++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/zechs/drive/stream/ui/settings/SettingsFragment.kt b/app/src/main/java/zechs/drive/stream/ui/settings/SettingsFragment.kt index 08634a4..2d090ba 100644 --- a/app/src/main/java/zechs/drive/stream/ui/settings/SettingsFragment.kt +++ b/app/src/main/java/zechs/drive/stream/ui/settings/SettingsFragment.kt @@ -1,6 +1,7 @@ package zechs.drive.stream.ui.settings import android.os.Bundle +import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -161,8 +162,25 @@ class SettingsFragment : BaseFragment() { private fun setupAdsSetting() { binding.switchAdsSupport.isChecked = mainViewModel.adsEnabled binding.settingAdsSupport.setOnClickListener { - binding.switchAdsSupport.isChecked = !binding.switchAdsSupport.isChecked - mainViewModel.setEnableAds(binding.switchAdsSupport.isChecked) + if (binding.switchAdsSupport.isChecked) { + MaterialAlertDialogBuilder(requireContext()) + .setTitle(getString(R.string.disable_ads)) + .setMessage(getString(R.string.disable_ads_message)) + .setNegativeButton(getString(R.string.no)) { dialog, _ -> + dialog.dismiss() + } + .setPositiveButton(getString(R.string.yes)) { dialog, _ -> + dialog.dismiss() + Log.d(TAG, "Disabling ads") + binding.switchAdsSupport.isChecked = false + mainViewModel.setEnableAds(false) + } + .show() + } else { + binding.switchAdsSupport.isChecked = true + mainViewModel.setEnableAds(true) + showSnackBar(getString(R.string.thank_you_for_supporting_the_app)) + } } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d7f996c..5466297 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -69,4 +69,7 @@ MPV Enable Ads Support the developer by enabling ads + Disable Ads + Are you sure you want to disable ads?\n\nThis will remove all ads from the app. Ads help support the development of this app. + Thank you for supporting the app! \ No newline at end of file