Commit ede7d63d authored by wanglei's avatar wanglei

...ump

parent d3e9a1f7
......@@ -111,4 +111,8 @@ dependencies {
implementation 'com.makeramen:roundedimageview:2.3.0'
implementation 'com.mikhaellopez:circularprogressbar:3.1.0'
//Google UMP
//https://docs.tradplusad.com/docs/tradplussdk_android_doc_v6/privacy_policy/google_ump/
implementation 'com.google.android.ump:user-messaging-platform:2.1.0'
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ package com.test.easy.easycleanerjunk
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.text.TextUtils
......@@ -43,7 +44,9 @@ class MyApplication : BaseApplication() {
fun initApp() {
initNotificationWork()
if (ConfigHelper.ifAgreePrivacy) {
MobileAds.initialize(this) { initializationStatus ->
if (ConfigHelper.umpGathered) {
MobileAds.initialize(this) { initializationStatus ->
}
}
InstallHelps.init()
}
......@@ -59,7 +62,7 @@ class MyApplication : BaseApplication() {
val timerDelay = SPUtils.getInstance().getInt("timerDelay", 1)
val timerInterval = SPUtils.getInstance().getInt("timerinterval", 5)
MyTimerManager.getInstance()
.startTimer((timerDelay * 60*1000).toLong(), (timerInterval * 60*1000).toLong())
.startTimer((timerDelay * 60 * 1000).toLong(), (timerInterval * 60 * 1000).toLong())
}
}
......
......@@ -14,7 +14,10 @@ import com.test.easy.easycleanerjunk.fcm.NotificationUtil
import com.test.easy.easycleanerjunk.helps.BaseActivity
import com.test.easy.easycleanerjunk.helps.ConfigHelper
import com.test.easy.easycleanerjunk.helps.ConfigHelper.remainNotification
import com.test.easy.easycleanerjunk.helps.ConfigHelper.umpGathered
import com.test.easy.easycleanerjunk.helps.EventUtils
import com.test.easy.easycleanerjunk.helps.LogEx
import com.test.easy.easycleanerjunk.helps.UmpHelp.requestUMP
import com.test.easy.easycleanerjunk.helps.ads.AdmobUtils
import com.test.easy.easycleanerjunk.service.PermanentNotificationService
import com.test.easy.easycleanerjunk.service.PermanentNotificationService.Companion.startNotification
......
......@@ -10,9 +10,12 @@ import com.test.easy.easycleanerjunk.MyApplication
import com.test.easy.easycleanerjunk.databinding.ActivityLayoutSplashBinding
import com.test.easy.easycleanerjunk.helps.ConfigHelper
import com.test.easy.easycleanerjunk.helps.EventUtils
import com.test.easy.easycleanerjunk.helps.LogEx
import com.test.easy.easycleanerjunk.helps.UmpHelp.requestUMP
class PrivacyAgreementManager {
private val TAG = "PrivacyAgreementManager"
private val binding: ActivityLayoutSplashBinding
......@@ -58,9 +61,24 @@ class PrivacyAgreementManager {
// binding.idLlJindu.isVisible = true
// binding.idLlYinsi.isVisible = false
ConfigHelper.ifAgreePrivacy = true
(context.application as MyApplication).initApp()
listener.onAgreePrivacy()
EventUtils.event("app_start")
context.requestUMP(loadAndShowErrorAction = {}, formErrorAction = {},
gatheredAction = {
// LogEx.logDebug(TAG, "gatherAction $it")
// ConfigHelper.umpGathered = it
// (context.application as MyApplication).initApp()
//
// listener.onAgreePrivacy()
// EventUtils.event("app_start")
},
dialogAction = {
LogEx.logDebug(TAG, "dialogAction $it")
ConfigHelper.umpGathered = it
(context.application as MyApplication).initApp()
listener.onAgreePrivacy()
EventUtils.event("app_start")
})
}
}
......
......@@ -18,6 +18,7 @@ import com.test.easy.easycleanerjunk.activity.whatsapp.WhatsAppCleanerAnimationA
import com.test.easy.easycleanerjunk.databinding.FragmentLayoutHomeBinding
import com.test.easy.easycleanerjunk.helps.BaseFragment
import com.test.easy.easycleanerjunk.helps.KotlinExt.setOnClickListener
import com.test.easy.easycleanerjunk.helps.UmpHelp.requestUMP
import com.test.easy.easycleanerjunk.utils.BarUtils
class HomeFragment : BaseFragment<FragmentLayoutHomeBinding>() {
......
......@@ -38,6 +38,14 @@ object ConfigHelper {
SPUtils.getInstance().put("junkSizeClean", value)
}
var umpGathered = true
get() {
return SPUtils.getInstance().getBoolean("umpGathered", field)
}
set(value) {
field = value
SPUtils.getInstance().put("umpGathered", value, true)
}
var ifAgreePrivacy = false
get() {
......
package com.test.easy.easycleanerjunk.helps
import android.app.Activity
import com.google.android.ump.ConsentForm.OnConsentFormDismissedListener
import com.google.android.ump.ConsentInformation.OnConsentInfoUpdateFailureListener
import com.google.android.ump.ConsentRequestParameters
import com.google.android.ump.FormError
import com.google.android.ump.UserMessagingPlatform
object UmpHelp {
private val TAG = "UmpHelp"
fun Activity.requestUMP(
loadAndShowErrorAction: (() -> Unit)? = null,//加载弹出错误
formErrorAction: (() -> Unit)? = null,//请求错误
gatheredAction: ((flag: Boolean) -> Unit)? = null,//已经授权过
dialogAction: ((flag: Boolean) -> Unit)? = null,//dialog授权
) {
val params = ConsentRequestParameters.Builder()
// 指示用户是否低于同意年龄; true 低于同意年龄
// 未满同意年龄的用户不会收到 GDPR 消息表单
.setTagForUnderAgeOfConsent(false)
.build()
val consentInformation = UserMessagingPlatform.getConsentInformation(this)
consentInformation.requestConsentInfoUpdate(
this, params, {
UserMessagingPlatform.loadAndShowConsentFormIfRequired(this) { loadAndShowError: FormError? ->
if (loadAndShowError != null) {
// Consent gathering failed.
LogEx.logDebug(TAG, "loadAndShowError=${loadAndShowError.errorCode} ${loadAndShowError.message}")
loadAndShowErrorAction?.invoke()
}
// Consent has been gathered.
// 授权完成,初始化SDK
dialogAction?.invoke(consentInformation.canRequestAds())
}
},
{ requestConsentError: FormError? ->
LogEx.logDebug(TAG, "FormError=${requestConsentError?.errorCode} ${requestConsentError?.message}")
formErrorAction?.invoke()
})
// 授权完成,初始化SDK
gatheredAction?.invoke(consentInformation.canRequestAds())
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment