From fe671b6f0ab7b3a21c058fc3165c1a5c46002fbc Mon Sep 17 00:00:00 2001 From: xC3FFF0E <78732474+xC3FFF0E@users.noreply.github.com> Date: Thu, 14 Dec 2023 21:02:19 +0800 Subject: Update MainActivity.java --- .../java/com/xc3fff0e/xmanager/MainActivity.java | 71 +++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) (limited to 'app/src') diff --git a/app/src/main/java/com/xc3fff0e/xmanager/MainActivity.java b/app/src/main/java/com/xc3fff0e/xmanager/MainActivity.java index d9451aa..d1c5ec1 100644 --- a/app/src/main/java/com/xc3fff0e/xmanager/MainActivity.java +++ b/app/src/main/java/com/xc3fff0e/xmanager/MainActivity.java @@ -50,6 +50,7 @@ import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout.OnRefreshListener; +import com.google.android.ads.consent.*; import com.google.android.gms.ads.MobileAds; import com.google.firebase.FirebaseApp; import com.google.gson.Gson; @@ -86,6 +87,11 @@ import com.google.android.gms.ads.initialization.InitializationStatus; import com.google.android.gms.ads.rewarded.RewardedAdLoadCallback; import com.google.android.gms.ads.interstitial.InterstitialAdLoadCallback; import com.google.android.gms.ads.initialization.OnInitializationCompleteListener; +import com.google.android.ump.ConsentForm; +import com.google.android.ump.ConsentInformation; +import com.google.android.ump.ConsentRequestParameters; +import com.google.android.ump.FormError; +import com.google.android.ump.UserMessagingPlatform; public class MainActivity extends AppCompatActivity { @@ -159,6 +165,8 @@ public class MainActivity extends AppCompatActivity { private String Installed_Checker_Wave = ""; private double Installed_Version_Wave = 0; private double Downloaded_Version_Wave = 0; + ConsentInformation consentInformation; + ConsentForm consentForm; private ArrayList Language = new ArrayList<>(); private ArrayList Theme = new ArrayList<>(); @@ -4884,6 +4892,7 @@ public class MainActivity extends AppCompatActivity { _Gate_Keeper(); _Informations(); _Theme_Pack(); + _GDPR_Consent(); _Language_Pack(); _Dark_Navigation(); } @@ -13827,7 +13836,7 @@ public class MainActivity extends AppCompatActivity { }); } }; - _timer.schedule(Timer, (int)(3000)); + _timer.schedule(Timer, (int)(2000)); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) { Window w =MainActivity.this.getWindow(); w.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); @@ -17200,6 +17209,66 @@ public class MainActivity extends AppCompatActivity { } + + public void _GDRP_Message() { + try { + UserMessagingPlatform.loadConsentForm(this, new UserMessagingPlatform.OnConsentFormLoadSuccessListener() { + @Override + public void onConsentFormLoadSuccess(ConsentForm consentForm) { + MainActivity.this.consentForm = consentForm; + if (consentInformation.getConsentStatus() == ConsentInformation.ConsentStatus.REQUIRED) { + consentForm.show(MainActivity.this, new ConsentForm.OnConsentFormDismissedListener() { + @Override + public void onConsentFormDismissed(@Nullable FormError formError) { + if (consentInformation.getConsentStatus() == ConsentInformation.ConsentStatus.OBTAINED) { + } + } + } + ); + } else if (consentInformation.getConsentStatus() == ConsentInformation.ConsentStatus.OBTAINED) { + } + } + }, + new UserMessagingPlatform.OnConsentFormLoadFailureListener() { + @Override + public void onConsentFormLoadFailure(FormError formError) { + } + } + ); + } + catch (Exception e) { + } + + } + + + public void _GDPR_Consent() { + ConsentRequestParameters params = new ConsentRequestParameters + .Builder() + .setTagForUnderAgeOfConsent(false) + .build(); + + try { + consentInformation = UserMessagingPlatform.getConsentInformation(this); + consentInformation.requestConsentInfoUpdate(this, params, new ConsentInformation.OnConsentInfoUpdateSuccessListener() { + @Override + public void onConsentInfoUpdateSuccess() { + if (consentInformation.isConsentFormAvailable()) { + _GDRP_Message(); + } + } + }, + new ConsentInformation.OnConsentInfoUpdateFailureListener() { + @Override + public void onConsentInfoUpdateFailure(FormError formError) { + } + }); + } + catch (Exception e) { + } + + } + public class List_items_1Adapter extends BaseAdapter { ArrayList> _data; -- cgit v1.2.3