Commit 12bb139b authored by leichao.gao's avatar leichao.gao

Merge branch 'free-master-ad-legal' of…

Merge branch 'free-master-ad-legal' of gitlab.huolea.com:koko/easy-junk-cleaner-6-18 into free-master-ad-legal
parents ce595e72 7543625b
...@@ -111,4 +111,8 @@ dependencies { ...@@ -111,4 +111,8 @@ dependencies {
implementation 'com.makeramen:roundedimageview:2.3.0' implementation 'com.makeramen:roundedimageview:2.3.0'
implementation 'com.mikhaellopez:circularprogressbar:3.1.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
...@@ -18,6 +18,7 @@ import com.test.easy.easycleanerjunk.helps.BaseApplication ...@@ -18,6 +18,7 @@ import com.test.easy.easycleanerjunk.helps.BaseApplication
import com.test.easy.easycleanerjunk.helps.ComUtils import com.test.easy.easycleanerjunk.helps.ComUtils
import com.test.easy.easycleanerjunk.helps.ConfigHelper import com.test.easy.easycleanerjunk.helps.ConfigHelper
import com.test.easy.easycleanerjunk.helps.InstallHelps import com.test.easy.easycleanerjunk.helps.InstallHelps
import com.test.easy.easycleanerjunk.helps.UmpHelp.canRequestAds
import com.test.easy.easycleanerjunk.helps.ads.AdmobUtils import com.test.easy.easycleanerjunk.helps.ads.AdmobUtils
import com.test.easy.easycleanerjunk.utils.ActivityManagerUtils import com.test.easy.easycleanerjunk.utils.ActivityManagerUtils
import com.test.easy.easycleanerjunk.utils.SPUtils import com.test.easy.easycleanerjunk.utils.SPUtils
...@@ -51,8 +52,10 @@ class MyApplication : BaseApplication() { ...@@ -51,8 +52,10 @@ class MyApplication : BaseApplication() {
initNotificationWork() initNotificationWork()
if (ConfigHelper.ifAgreePrivacy) { if (ConfigHelper.ifAgreePrivacy) {
if (context.canRequestAds()) {
MobileAds.initialize(this) { initializationStatus -> MobileAds.initialize(this) { initializationStatus ->
} }
}
InstallHelps.init() InstallHelps.init()
} }
initLifeListener() initLifeListener()
......
...@@ -13,10 +13,8 @@ import com.test.easy.easycleanerjunk.fcm.CloseNotificationReceiver ...@@ -13,10 +13,8 @@ import com.test.easy.easycleanerjunk.fcm.CloseNotificationReceiver
import com.test.easy.easycleanerjunk.fcm.NotificationUtil import com.test.easy.easycleanerjunk.fcm.NotificationUtil
import com.test.easy.easycleanerjunk.helps.BaseActivity import com.test.easy.easycleanerjunk.helps.BaseActivity
import com.test.easy.easycleanerjunk.helps.ConfigHelper import com.test.easy.easycleanerjunk.helps.ConfigHelper
import com.test.easy.easycleanerjunk.helps.ConfigHelper.remainNotification
import com.test.easy.easycleanerjunk.helps.EventUtils import com.test.easy.easycleanerjunk.helps.EventUtils
import com.test.easy.easycleanerjunk.helps.ads.AdmobUtils import com.test.easy.easycleanerjunk.helps.ads.AdmobUtils
import com.test.easy.easycleanerjunk.service.PermanentNotificationService
import com.test.easy.easycleanerjunk.service.PermanentNotificationService.Companion.startNotification import com.test.easy.easycleanerjunk.service.PermanentNotificationService.Companion.startNotification
import com.test.easy.easycleanerjunk.utils.BarUtils import com.test.easy.easycleanerjunk.utils.BarUtils
......
...@@ -6,13 +6,17 @@ import android.net.Uri ...@@ -6,13 +6,17 @@ import android.net.Uri
import android.text.SpannableString import android.text.SpannableString
import android.text.Spanned import android.text.Spanned
import android.text.style.UnderlineSpan import android.text.style.UnderlineSpan
import android.widget.Toast
import com.test.easy.easycleanerjunk.MyApplication import com.test.easy.easycleanerjunk.MyApplication
import com.test.easy.easycleanerjunk.databinding.ActivityLayoutSplashBinding import com.test.easy.easycleanerjunk.databinding.ActivityLayoutSplashBinding
import com.test.easy.easycleanerjunk.helps.ConfigHelper import com.test.easy.easycleanerjunk.helps.ConfigHelper
import com.test.easy.easycleanerjunk.helps.EventUtils import com.test.easy.easycleanerjunk.helps.EventUtils
import com.test.easy.easycleanerjunk.helps.LogEx
import com.test.easy.easycleanerjunk.helps.UmpHelp.requestUMP
class PrivacyAgreementManager { class PrivacyAgreementManager {
private val TAG = "PrivacyAgreementManager"
private val binding: ActivityLayoutSplashBinding private val binding: ActivityLayoutSplashBinding
...@@ -30,7 +34,6 @@ class PrivacyAgreementManager { ...@@ -30,7 +34,6 @@ class PrivacyAgreementManager {
private fun initView() { private fun initView() {
val spannableString = SpannableString("Privacy Policy") val spannableString = SpannableString("Privacy Policy")
spannableString.setSpan( spannableString.setSpan(
UnderlineSpan(), UnderlineSpan(),
...@@ -54,9 +57,6 @@ class PrivacyAgreementManager { ...@@ -54,9 +57,6 @@ class PrivacyAgreementManager {
return@setOnClickListener return@setOnClickListener
} }
clicked = true clicked = true
// binding.idTvStart.isVisible = false
// binding.idLlJindu.isVisible = true
// binding.idLlYinsi.isVisible = false
ConfigHelper.ifAgreePrivacy = true ConfigHelper.ifAgreePrivacy = true
(context.application as MyApplication).initApp() (context.application as MyApplication).initApp()
listener.onAgreePrivacy() listener.onAgreePrivacy()
......
...@@ -5,6 +5,7 @@ import android.annotation.SuppressLint ...@@ -5,6 +5,7 @@ import android.annotation.SuppressLint
import android.content.Intent import android.content.Intent
import android.view.animation.LinearInterpolator import android.view.animation.LinearInterpolator
import android.widget.ScrollView import android.widget.ScrollView
import android.widget.Toast
import androidx.core.view.updatePadding import androidx.core.view.updatePadding
import com.test.easy.easycleanerjunk.activity.scanjunk.ScanJunkActivity import com.test.easy.easycleanerjunk.activity.scanjunk.ScanJunkActivity
import com.test.easy.easycleanerjunk.activity.SettingActivity import com.test.easy.easycleanerjunk.activity.SettingActivity
...@@ -17,7 +18,9 @@ import com.test.easy.easycleanerjunk.activity.similarphotos.RepeatPhotoAnimation ...@@ -17,7 +18,9 @@ import com.test.easy.easycleanerjunk.activity.similarphotos.RepeatPhotoAnimation
import com.test.easy.easycleanerjunk.activity.whatsapp.WhatsAppCleanerAnimationActivity import com.test.easy.easycleanerjunk.activity.whatsapp.WhatsAppCleanerAnimationActivity
import com.test.easy.easycleanerjunk.databinding.FragmentLayoutHomeBinding import com.test.easy.easycleanerjunk.databinding.FragmentLayoutHomeBinding
import com.test.easy.easycleanerjunk.helps.BaseFragment import com.test.easy.easycleanerjunk.helps.BaseFragment
import com.test.easy.easycleanerjunk.helps.ConfigHelper
import com.test.easy.easycleanerjunk.helps.KotlinExt.setOnClickListener import com.test.easy.easycleanerjunk.helps.KotlinExt.setOnClickListener
import com.test.easy.easycleanerjunk.helps.UmpHelp.requestUMP
import com.test.easy.easycleanerjunk.utils.BarUtils import com.test.easy.easycleanerjunk.utils.BarUtils
class HomeFragment : BaseFragment<FragmentLayoutHomeBinding>() { class HomeFragment : BaseFragment<FragmentLayoutHomeBinding>() {
...@@ -71,7 +74,18 @@ class HomeFragment : BaseFragment<FragmentLayoutHomeBinding>() { ...@@ -71,7 +74,18 @@ class HomeFragment : BaseFragment<FragmentLayoutHomeBinding>() {
binding.idScrollView.fullScroll(ScrollView.FOCUS_DOWN) binding.idScrollView.fullScroll(ScrollView.FOCUS_DOWN)
} }
listOf(binding.idCleanJunk, binding.idFlClean, binding.idCleanUp).setOnClickListener { listOf(binding.idCleanJunk, binding.idFlClean, binding.idCleanUp).setOnClickListener {
startActivity(Intent(requireContext(), ScanJunkActivity::class.java)) // startActivity(Intent(requireContext(), ScanJunkActivity::class.java))
requireActivity().requestUMP(loadAndShowErrorAction = {
Toast.makeText(context, "loadAndShowErrorAction", Toast.LENGTH_SHORT).show()
}, formErrorAction = {
Toast.makeText(context, "formErrorAction", Toast.LENGTH_SHORT).show()
},
dialogAction = {
Toast.makeText(context, "dialogAction flag=$it", Toast.LENGTH_SHORT).show()
})
} }
binding.idPhotoCompress.setOnClickListener { binding.idPhotoCompress.setOnClickListener {
......
...@@ -40,7 +40,6 @@ object ConfigHelper { ...@@ -40,7 +40,6 @@ object ConfigHelper {
SPUtils.getInstance().put("junkSizeClean", value) SPUtils.getInstance().put("junkSizeClean", value)
} }
var ifAgreePrivacy = false var ifAgreePrivacy = false
get() { get() {
return SPUtils.getInstance().getBoolean("ifAgreePrivacy", field) return SPUtils.getInstance().getBoolean("ifAgreePrivacy", field)
......
package com.test.easy.easycleanerjunk.helps
import android.app.Activity
import android.content.Context
import com.google.android.ump.ConsentDebugSettings
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
import com.test.easy.easycleanerjunk.BuildConfig
import com.test.easy.easycleanerjunk.helps.UmpHelp.requestUMP
object UmpHelp {
private fun Context.umpTest(): ConsentDebugSettings {
val debugSettings = ConsentDebugSettings.Builder(this)
debugSettings.addTestDeviceHashedId("TEST-DEVICE-HASHED-ID")
debugSettings.addTestDeviceHashedId("33BE2250B43518CCDA7DE426D04EE231")
return debugSettings.build()
}
private val TAG = "UmpHelp"
fun Activity.requestUMP(
loadAndShowErrorAction: (() -> Unit)? = null,//加载弹出错误
formErrorAction: (() -> Unit)? = null,//请求错误
dialogAction: ((flag: Boolean) -> Unit)? = null,//dialog授权
) {
val paramsBuild = ConsentRequestParameters.Builder()
if (BuildConfig.DEBUG) {
paramsBuild.setConsentDebugSettings(umpTest())
}
// 指示用户是否低于同意年龄; true 低于同意年龄
// 未满同意年龄的用户不会收到 GDPR 消息表单
paramsBuild.setTagForUnderAgeOfConsent(false)
val params = paramsBuild.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()
})
}
fun Context.canRequestAds(): Boolean {
val consentInformation = UserMessagingPlatform.getConsentInformation(this)
return 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