From 7992714545387f6e60bebe7a70e0e6a220dab3de Mon Sep 17 00:00:00 2001 From: Mihai-Cristian Condrea Date: Fri, 19 Sep 2025 11:33:41 +0300 Subject: [PATCH] Respect ad consent on support screen --- .../java/ui/screens/support/SupportActivity.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/d4rk/androidtutorials/java/ui/screens/support/SupportActivity.java b/app/src/main/java/com/d4rk/androidtutorials/java/ui/screens/support/SupportActivity.java index e3187ac3..81587480 100644 --- a/app/src/main/java/com/d4rk/androidtutorials/java/ui/screens/support/SupportActivity.java +++ b/app/src/main/java/com/d4rk/androidtutorials/java/ui/screens/support/SupportActivity.java @@ -3,6 +3,7 @@ import android.content.Intent; import android.net.Uri; import android.os.Bundle; +import android.view.View; import android.widget.Toast; import androidx.lifecycle.ViewModelProvider; @@ -12,6 +13,7 @@ import com.d4rk.androidtutorials.java.data.repository.SupportRepository; import com.d4rk.androidtutorials.java.databinding.ActivitySupportBinding; import com.d4rk.androidtutorials.java.ui.components.navigation.BaseActivity; +import com.d4rk.androidtutorials.java.utils.ConsentUtils; import com.google.android.gms.ads.AdRequest; import java.util.List; @@ -32,9 +34,16 @@ protected void onCreate(Bundle savedInstanceState) { supportViewModel = new ViewModelProvider(this).get(SupportViewModel.class); - AdRequest adRequest = supportViewModel.initMobileAds(); - binding.supportNativeAd.loadAd(adRequest); - binding.bannerAdView.loadAd(adRequest); + if (ConsentUtils.canShowAds(this)) { + AdRequest adRequest = supportViewModel.initMobileAds(); + binding.supportNativeAd.setVisibility(View.VISIBLE); + binding.bannerAdView.setVisibility(View.VISIBLE); + binding.supportNativeAd.loadAd(adRequest); + binding.bannerAdView.loadAd(adRequest); + } else { + binding.supportNativeAd.setVisibility(View.GONE); + binding.bannerAdView.setVisibility(View.GONE); + } binding.buttonWebAd.setOnClickListener(v -> openSupportLink());