From 6f7bfaff9c5779fc2b1d29aa8e9738635a4bf561 Mon Sep 17 00:00:00 2001 From: Kevin Puertas Date: Tue, 20 Oct 2026 12:50:21 +0000 Subject: [PATCH] =?UTF-8?q?AdMob=2025.5.0=20+=20UMP=204.0:=20consentimient?= =?UTF-8?q?o=20EEA,=20init=20en=20background,=20proguard=20m=C3=ADnimo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/proguard-rules.pro | 44 +++---------------- .../st/calendariodefrases/MainActivity.java | 36 ++++++++++++--- app/version.count | 4 +- gradle.properties | 2 - 4 files changed, 40 insertions(+), 46 deletions(-) diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 487cbbe..a42d891 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -1,39 +1,9 @@ -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in /mnt/kevinmem/Android/sdkLinux/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the proguardFiles -# directive in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html +# Reglas de keep para anuncios y UMP ya vienen empaquetadas en las propias libs. +# Aquí solo reglas específicas del proyecto. -# Add any project specific keep options here: +# robotocalendarview (jitpack, sin reglas empaquetadas): conservar la vista y su listener +-keep class com.marcohc.robotocalendar.** { *; } -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile - --keepattributes *Annotation* --keepclassmembers class com.google.**.R$* { - public static ; -} --keep public class com.google.ads.** {*;} --keep public class com.google.android.gms.** {*;} --keep public class com.tappx.** { *; } - --ignorewarnings - --keep class * { - public private *; -} \ No newline at end of file +# Crash legibles si hace falta debug +-keepattributes SourceFile,LineNumberTable +-renamesourcefileattribute SourceFile diff --git a/app/src/main/java/com/jkanetwork/st/calendariodefrases/MainActivity.java b/app/src/main/java/com/jkanetwork/st/calendariodefrases/MainActivity.java index 196ff2f..fab3408 100644 --- a/app/src/main/java/com/jkanetwork/st/calendariodefrases/MainActivity.java +++ b/app/src/main/java/com/jkanetwork/st/calendariodefrases/MainActivity.java @@ -23,6 +23,10 @@ import java.util.Calendar; import com.google.android.gms.ads.AdRequest; import com.google.android.gms.ads.AdView; import com.google.android.gms.ads.MobileAds; +import com.google.android.ump.ConsentInformation; +import com.google.android.ump.ConsentRequestParameters; +import com.google.android.ump.FormError; +import com.google.android.ump.UserMessagingPlatform; @@ -104,11 +108,8 @@ public class MainActivity extends AppCompatActivity implements RobotoCalendarLis robotoCalendarView.setShortWeekDays(false); robotoCalendarView.showDateTitle(true); - /* Admob ads */ - MobileAds.initialize(getApplicationContext()); - AdView mAdView = (AdView) findViewById(R.id.adView); - AdRequest adRequest = new AdRequest.Builder().build(); - mAdView.loadAd(adRequest); //request a new ad + /* Admob ads: consentimiento UMP primero, luego init en background y banner */ + setUpConsentAndAds(); @@ -116,6 +117,31 @@ public class MainActivity extends AppCompatActivity implements RobotoCalendarLis registerForContextMenu(txtfraseText); } + /* Consentimiento UMP (obligatorio EEA) y tras él, init de AdMob + banner */ + private void setUpConsentAndAds() { + ConsentRequestParameters params = new ConsentRequestParameters.Builder().build(); + ConsentInformation consentInfo = UserMessagingPlatform.getConsentInformation(this); + consentInfo.requestConsentInfoUpdate( + this, + params, + () -> UserMessagingPlatform.loadAndShowConsentFormIfRequired( + this, + formError -> initAdsAfterConsent()), + formError -> initAdsAfterConsent()); + } + + private void initAdsAfterConsent() { + /* MobileAds.initialize en background: no bloquee el arranque */ + new Thread(() -> { + MobileAds.initialize(getApplicationContext()); + runOnUiThread(() -> { + AdView mAdView = findViewById(R.id.adView); + AdRequest adRequest = new AdRequest.Builder().build(); + mAdView.loadAd(adRequest); + }); + }).start(); + } + @Override public void onResume(){ super.onResume(); diff --git a/app/version.count b/app/version.count index d3be597..30cd0d1 100644 --- a/app/version.count +++ b/app/version.count @@ -1,2 +1,2 @@ -#Tue Oct 20 12:47:34 UTC 2026 -VERSION_CODE=364 +#Tue Oct 20 12:49:20 UTC 2026 +VERSION_CODE=367 diff --git a/gradle.properties b/gradle.properties index 1af9580..05f1679 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,5 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 # AndroidX android.useAndroidX=true -# R fields deben ser final: el código Java usa switch(view.getId())/menu items -android.nonFinalResIds=false # Necesario mientras se use robotocalendarview (lib pre-AndroidX, se jetifica en build) android.enableJetifier=true