From fcc71c0d5f2ddb4ac66aa520e5b1dc573fc96a6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Borcz?= Date: Sun, 21 Nov 2021 08:34:28 +0100 Subject: [PATCH] Add ads limit (#1662) --- app/src/main/res/values/strings.xml | 1 + .../wulkanowy/ui/modules/settings/ads/AdsFragment.kt | 7 +++++++ .../wulkanowy/ui/modules/settings/ads/AdsPresenter.kt | 5 ++++- .../io/github/wulkanowy/ui/modules/settings/ads/AdsView.kt | 2 ++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f4834820..43720164 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -699,6 +699,7 @@ Agree Privacy policy Ad is loading + Thank you for your support, come back later for more ads Advanced Appearance & Behavior diff --git a/app/src/play/java/io/github/wulkanowy/ui/modules/settings/ads/AdsFragment.kt b/app/src/play/java/io/github/wulkanowy/ui/modules/settings/ads/AdsFragment.kt index 960a54b8..8d31928b 100644 --- a/app/src/play/java/io/github/wulkanowy/ui/modules/settings/ads/AdsFragment.kt +++ b/app/src/play/java/io/github/wulkanowy/ui/modules/settings/ads/AdsFragment.kt @@ -68,6 +68,13 @@ class AdsFragment : PreferenceFragmentCompat(), MainView.TitledView, AdsView { } } + override fun showWatchAdOncePerVisit(show: Boolean) { + findPreference(getString(R.string.pref_key_ads_single_support))?.run { + isEnabled = !show + summary = if (show) getString(R.string.pref_ads_once_per_visit) else null + } + } + override fun showError(text: String, error: Throwable) { (activity as? BaseActivity<*, *>)?.showError(text, error) } diff --git a/app/src/play/java/io/github/wulkanowy/ui/modules/settings/ads/AdsPresenter.kt b/app/src/play/java/io/github/wulkanowy/ui/modules/settings/ads/AdsPresenter.kt index fd5cc9b6..5ccbce1e 100644 --- a/app/src/play/java/io/github/wulkanowy/ui/modules/settings/ads/AdsPresenter.kt +++ b/app/src/play/java/io/github/wulkanowy/ui/modules/settings/ads/AdsPresenter.kt @@ -35,7 +35,10 @@ class AdsPresenter @Inject constructor( .onFailure(errorHandler::dispatch) .onSuccess { it?.let { view?.showAd(it) } } - view?.showLoadingSupportAd(false) + view?.run { + showLoadingSupportAd(false) + showWatchAdOncePerVisit(true) + } } } } \ No newline at end of file diff --git a/app/src/play/java/io/github/wulkanowy/ui/modules/settings/ads/AdsView.kt b/app/src/play/java/io/github/wulkanowy/ui/modules/settings/ads/AdsView.kt index 25eeaaec..89de7bd1 100644 --- a/app/src/play/java/io/github/wulkanowy/ui/modules/settings/ads/AdsView.kt +++ b/app/src/play/java/io/github/wulkanowy/ui/modules/settings/ads/AdsView.kt @@ -14,4 +14,6 @@ interface AdsView : BaseView { fun openPrivacyPolicy() fun showLoadingSupportAd(show: Boolean) + + fun showWatchAdOncePerVisit(show: Boolean) } \ No newline at end of file