Skip to content

Commit

Permalink
user confirmation before disabling ads
Browse files Browse the repository at this point in the history
  • Loading branch information
itszechs committed Jun 25, 2023
1 parent be54abc commit 67fcedf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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))
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,7 @@
<string name="mpv">MPV</string>
<string name="enable_ads">Enable Ads</string>
<string name="support_the_developer_by_enabling_ads">Support the developer by enabling ads</string>
<string name="disable_ads">Disable Ads</string>
<string name="disable_ads_message">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.</string>
<string name="thank_you_for_supporting_the_app">Thank you for supporting the app!</string>
</resources>

0 comments on commit 67fcedf

Please sign in to comment.