Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
E
Easy Cleaner Junk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wanglei
Easy Cleaner Junk
Commits
752fa4d7
Commit
752fa4d7
authored
Jul 01, 2024
by
maxiaoliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加上报
parent
ccd27664
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
117 additions
and
83 deletions
+117
-83
NewMainActivity.kt
...est/easy/easycleanerjunk/activity/home/NewMainActivity.kt
+2
-1
NewSplashActivity.kt
...easy/easycleanerjunk/activity/splash/NewSplashActivity.kt
+2
-0
PrivacyAgreementManager.kt
...asycleanerjunk/activity/splash/PrivacyAgreementManager.kt
+2
-0
AdmobUtils.kt
...ava/com/test/easy/easycleanerjunk/helps/ads/AdmobUtils.kt
+111
-82
No files found.
app/src/main/java/com/test/easy/easycleanerjunk/activity/home/NewMainActivity.kt
View file @
752fa4d7
...
...
@@ -10,6 +10,7 @@ import com.test.easy.easycleanerjunk.databinding.ActivityMainBinding
import
com.test.easy.easycleanerjunk.fragment.HomeFragment
import
com.test.easy.easycleanerjunk.fragment.ToolsFragment
import
com.test.easy.easycleanerjunk.helps.BaseActivity
import
com.test.easy.easycleanerjunk.helps.EventUtils
import
com.test.easy.easycleanerjunk.utils.BarUtils
import
com.test.easy.easycleanerjunk.view.RateStarPop
import
kotlinx.coroutines.Dispatchers
...
...
@@ -37,7 +38,7 @@ class NewMainActivity : BaseActivity<ActivityMainBinding>() {
override
fun
initView
()
{
BarUtils
.
setStatusBarLightMode
(
this
,
true
)
BarUtils
.
setStatusBarColor
(
this
,
Color
.
TRANSPARENT
)
EventUtils
.
event
(
"page_home"
)
binding
.
idVp
.
run
{
adapter
=
object
:
FragmentStateAdapter
(
this
@NewMainActivity
)
{
override
fun
getItemCount
():
Int
{
...
...
app/src/main/java/com/test/easy/easycleanerjunk/activity/splash/NewSplashActivity.kt
View file @
752fa4d7
...
...
@@ -13,6 +13,7 @@ import com.test.easy.easycleanerjunk.fcm.CloseNotificationReceiver
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.EventUtils
import
com.test.easy.easycleanerjunk.helps.ads.AdmobUtils
import
com.test.easy.easycleanerjunk.service.PermanentNotificationService
import
com.test.easy.easycleanerjunk.utils.BarUtils
...
...
@@ -59,6 +60,7 @@ class NewSplashActivity : BaseActivity<ActivityLayoutSplashBinding>(),
binding
.
idLlJindu
.
isVisible
=
true
binding
.
idLlYinsi
.
isVisible
=
false
onAgreePrivacy
()
EventUtils
.
event
(
"app_start"
)
}
else
{
PrivacyAgreementManager
(
binding
,
this
,
this
)
}
...
...
app/src/main/java/com/test/easy/easycleanerjunk/activity/splash/PrivacyAgreementManager.kt
View file @
752fa4d7
...
...
@@ -9,6 +9,7 @@ import android.text.style.UnderlineSpan
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
class
PrivacyAgreementManager
{
...
...
@@ -59,6 +60,7 @@ class PrivacyAgreementManager {
ConfigHelper
.
ifAgreePrivacy
=
true
(
context
.
application
as
MyApplication
).
initApp
()
listener
.
onAgreePrivacy
()
EventUtils
.
event
(
"app_start"
)
}
}
...
...
app/src/main/java/com/test/easy/easycleanerjunk/helps/ads/AdmobUtils.kt
View file @
752fa4d7
...
...
@@ -4,7 +4,6 @@ import android.app.Activity
import
android.app.Dialog
import
android.os.Bundle
import
android.os.CountDownTimer
import
android.util.Log
import
android.view.ViewGroup
import
android.widget.Toast
import
androidx.core.view.isVisible
...
...
@@ -30,11 +29,10 @@ import com.test.easy.easycleanerjunk.R
import
com.test.easy.easycleanerjunk.activity.photocompress.photo.CustomDialog
import
com.test.easy.easycleanerjunk.helps.BaseApplication
import
com.test.easy.easycleanerjunk.helps.ConfigHelper
import
com.test.easy.easycleanerjunk.helps.EventUtils
import
com.test.easy.easycleanerjunk.utils.ActivityManagerUtils
import
com.test.easy.easycleanerjunk.utils.SPUtils
import
org.json.JSONObject
import
java.util.UUID
import
kotlin.system.exitProcess
object
AdmobUtils
{
...
...
@@ -45,19 +43,8 @@ object AdmobUtils {
private
var
nativeLoadTime
=
Long
.
MAX_VALUE
private
var
mOpenAd
:
AppOpenAd
?
=
null
private
const
val
typeShow
=
"Show"
private
const
val
typeClick
=
"Click"
var
isBlack
=
false
get
()
{
return
SPUtils
.
getInstance
().
getBoolean
(
"isBlack"
,
field
)
}
set
(
value
)
{
field
=
value
SPUtils
.
getInstance
().
put
(
"isBlack"
,
value
,
true
)
}
fun
loadAppOpenAd
(
skip
:
Boolean
=
false
,
onLoad
:
(()
->
Unit
)?
=
null
)
{
if
(
mOpenAd
!=
null
||
skip
)
{
...
...
@@ -72,27 +59,26 @@ object AdmobUtils {
val
obj
=
JSONObject
()
obj
.
put
(
"req_id"
,
reqId
)
obj
.
put
(
"ad_type"
,
"openAd"
)
EventUtils
.
event
(
"ad_pull_start"
,
ext
=
obj
)
AppOpenAd
.
load
(
BaseApplication
.
context
,
ConfigHelper
.
openAdmobId
,
mRequest
,
object
:
AppOpenAd
.
AppOpenAdLoadCallback
()
{
override
fun
onAdLoaded
(
ad
:
AppOpenAd
)
{
openLoadTime
=
System
.
currentTimeMillis
()
mOpenAd
=
ad
onLoad
?.
invoke
()
pull
(
ad
.
responseInfo
,
"openAd"
,
reqId
=
reqId
)
ad
.
onPaidEventListener
=
EventOnPaidEventListener
(
ad
)
// Log.e("MXL", "拉取成功: ", )
}
BaseApplication
.
context
,
ConfigHelper
.
openAdmobId
,
mRequest
,
object
:
AppOpenAd
.
AppOpenAdLoadCallback
()
{
override
fun
onAdLoaded
(
ad
:
AppOpenAd
)
{
openLoadTime
=
System
.
currentTimeMillis
()
mOpenAd
=
ad
onLoad
?.
invoke
()
pull
(
ad
.
responseInfo
,
"openAd"
,
reqId
=
reqId
)
ad
.
onPaidEventListener
=
EventOnPaidEventListener
(
ad
)
}
override
fun
onAdFailedToLoad
(
p0
:
LoadAdError
)
{
mOpenAd
=
null
onLoad
?.
invoke
()
pull
(
p0
.
responseInfo
,
"openAd"
,
p0
.
message
,
reqId
=
reqId
)
// Log.e("MXL", "onAdFailedToLoad: " + p0.message)
}
})
override
fun
onAdFailedToLoad
(
p0
:
LoadAdError
)
{
mOpenAd
=
null
onLoad
?.
invoke
()
pull
(
p0
.
responseInfo
,
"openAd"
,
p0
.
message
,
reqId
=
reqId
)
}
})
}
fun
isOpenAdLoaded
()
=
mOpenAd
!=
null
...
...
@@ -107,16 +93,14 @@ object AdmobUtils {
}
val
obj
=
JSONObject
()
obj
.
put
(
"ad_unit"
,
"openAd"
)
// if (mOpenAd == null || skip) {
// onHidden?.invoke()
// return
// }
EventUtils
.
event
(
"ad_prepare_show"
,
ext
=
obj
)
if
(
System
.
currentTimeMillis
()
-
openLoadTime
>
1000
*
60
*
60
)
{
mOpenAd
=
null
loadAppOpenAd
()
onHidden
?.
invoke
()
val
obj
=
JSONObject
()
obj
.
put
(
"ad_unit"
,
"openAd"
)
EventUtils
.
event
(
"ad_expire"
,
ext
=
obj
)
return
}
if
(
mOpenAd
!=
null
)
{
...
...
@@ -141,6 +125,7 @@ object AdmobUtils {
val
obj
=
JSONObject
()
obj
.
put
(
"reason"
,
p0
.
message
)
obj
.
put
(
"ad_unit"
,
"openAd"
)
EventUtils
.
event
(
"ad_show_error"
,
ext
=
obj
)
}
override
fun
onAdShowedFullScreenContent
()
{
...
...
@@ -154,6 +139,7 @@ object AdmobUtils {
val
obj
=
JSONObject
()
obj
.
put
(
"reason"
,
"no_ad"
)
obj
.
put
(
"ad_unit"
,
"openAd"
)
EventUtils
.
event
(
"ad_show_error"
,
ext
=
obj
)
}
}
...
...
@@ -164,6 +150,7 @@ object AdmobUtils {
fun
showNativeAd
(
activity
:
Activity
?,
parent
:
ViewGroup
)
{
val
obj
=
JSONObject
()
obj
.
put
(
"ad_unit"
,
"NativeAd"
)
EventUtils
.
event
(
"ad_prepare_show"
,
ext
=
obj
)
if
(!
AdDisplayUtils
.
getInstance
().
shouldShowAd
())
{
return
}
...
...
@@ -188,6 +175,7 @@ object AdmobUtils {
val
obj
=
JSONObject
()
obj
.
put
(
"reason"
,
"no_ad"
)
obj
.
put
(
"ad_unit"
,
"nativeAd"
)
EventUtils
.
event
(
"ad_show_error"
,
ext
=
obj
)
}
else
{
loadingListener
?.
invoke
()
}
...
...
@@ -214,7 +202,7 @@ object AdmobUtils {
obj
.
put
(
"ad_type"
,
"nativeAd"
)
val
adLoader
=
AdLoader
.
Builder
(
BaseApplication
.
context
,
ConfigHelper
.
nativeAdmobId
BaseApplication
.
context
,
ConfigHelper
.
nativeAdmobId
).
forNativeAd
{
nativeLoadTime
=
System
.
currentTimeMillis
()
nativeAd
=
it
...
...
@@ -250,33 +238,38 @@ object AdmobUtils {
return
}
val
reqId
=
UUID
.
randomUUID
().
toString
()
val
obj
=
JSONObject
()
obj
.
put
(
"req_id"
,
reqId
)
obj
.
put
(
"ad_type"
,
"interAd"
)
obj
.
put
(
"from"
,
activity
.
javaClass
.
simpleName
)
EventUtils
.
event
(
"ad_pull_start"
,
ext
=
obj
)
InterstitialAd
.
load
(
activity
,
ConfigHelper
.
interAdmobId
,
mRequest
,
object
:
InterstitialAdLoadCallback
()
{
override
fun
onAdFailedToLoad
(
p0
:
LoadAdError
)
{
interAd
=
null
onLoad
?.
invoke
()
pull
(
p0
.
responseInfo
,
"interAd"
,
p0
.
message
,
reqId
=
reqId
)
if
(
BuildConfig
.
DEBUG
)
{
Toast
.
makeText
(
BaseApplication
.
context
,
"拉取失败"
+
p0
.
message
,
Toast
.
LENGTH_SHORT
)
}
activity
,
ConfigHelper
.
interAdmobId
,
mRequest
,
object
:
InterstitialAdLoadCallback
()
{
override
fun
onAdFailedToLoad
(
p0
:
LoadAdError
)
{
interAd
=
null
onLoad
?.
invoke
()
pull
(
p0
.
responseInfo
,
"interAd"
,
p0
.
message
,
reqId
=
reqId
)
if
(
BuildConfig
.
DEBUG
)
{
Toast
.
makeText
(
BaseApplication
.
context
,
"拉取失败"
+
p0
.
message
,
Toast
.
LENGTH_SHORT
).
show
()
}
override
fun
onAdLoaded
(
ad
:
InterstitialAd
)
{
interAd
=
ad
onLoad
?.
invoke
()
interLoadTime
=
System
.
currentTimeMillis
()
pull
(
ad
.
responseInfo
,
"interAd"
,
reqId
=
reqId
)
ad
.
onPaidEventListener
=
EventOnPaidEventListener
(
ad
)
}
})
}
override
fun
onAdLoaded
(
ad
:
InterstitialAd
)
{
interAd
=
ad
onLoad
?.
invoke
()
interLoadTime
=
System
.
currentTimeMillis
()
pull
(
ad
.
responseInfo
,
"interAd"
,
reqId
=
reqId
)
ad
.
onPaidEventListener
=
EventOnPaidEventListener
(
ad
)
}
})
}
private
fun
isAdExpired
():
Boolean
{
...
...
@@ -286,12 +279,22 @@ object AdmobUtils {
var
adDisplayInterval
:
Int
=
10
var
adLastDisplayTime
:
Long
=
0
fun
showInterstitialAd
(
activity
:
Activity
,
isLoadAdNow
:
Boolean
=
false
,
onHidden
:
(()
->
Unit
)?
=
null
)
{
fun
showInterstitialAd
(
activity
:
Activity
,
isLoadAdNow
:
Boolean
=
false
,
onHidden
:
(()
->
Unit
)?
=
null
)
{
if
(
activity
.
isFinishing
||
activity
.
isDestroyed
)
{
return
}
val
obj
=
JSONObject
()
obj
.
put
(
"ad_unit"
,
"interAd"
)
EventUtils
.
event
(
"ad_prepare_show"
,
ext
=
obj
)
if
(
isAdExpired
())
{
val
obj
=
JSONObject
()
obj
.
put
(
"ad_unit"
,
"interAd"
)
EventUtils
.
event
(
"ad_expire"
,
ext
=
obj
)
interAd
=
null
loadInterstitialAd
(
activity
)
onHidden
?.
invoke
()
...
...
@@ -311,7 +314,12 @@ object AdmobUtils {
}
}
private
fun
showIntervalDialogAndShowAd
(
activity
:
Activity
,
isLoadAdNow
:
Boolean
,
onHidden
:
(()
->
Unit
)?,
interval
:
Int
)
{
private
fun
showIntervalDialogAndShowAd
(
activity
:
Activity
,
isLoadAdNow
:
Boolean
,
onHidden
:
(()
->
Unit
)?,
interval
:
Int
)
{
val
customDialog
=
CustomDialog
(
activity
,
R
.
layout
.
dialog_ad_loading
)
customDialog
.
setCountdownText
(
R
.
id
.
dialog_ad_loading_text
)
val
countdownTimer
=
object
:
CountDownTimer
((
interval
*
1000
).
toLong
(),
1000
)
{
...
...
@@ -330,7 +338,11 @@ object AdmobUtils {
customDialog
.
show
()
}
private
fun
showCachedInterstitialAd
(
activity
:
Activity
,
isLoadAdNow
:
Boolean
,
onHidden
:
(()
->
Unit
)?)
{
private
fun
showCachedInterstitialAd
(
activity
:
Activity
,
isLoadAdNow
:
Boolean
,
onHidden
:
(()
->
Unit
)?
)
{
if
(
interAd
!=
null
)
{
displayInterstitialAd
(
activity
,
onHidden
)
}
else
{
...
...
@@ -345,7 +357,11 @@ object AdmobUtils {
}
private
fun
showAdDialogAndLoadInterstitial
(
activity
:
Activity
,
isLoadAdNow
:
Boolean
,
onHidden
:
(()
->
Unit
)?)
{
private
fun
showAdDialogAndLoadInterstitial
(
activity
:
Activity
,
isLoadAdNow
:
Boolean
,
onHidden
:
(()
->
Unit
)?
)
{
var
mDialog
:
Dialog
?
=
null
mDialog
=
CustomDialog
(
activity
,
R
.
layout
.
dialog_ad_loading
)
mDialog
.
show
()
...
...
@@ -405,7 +421,8 @@ object AdmobUtils {
if
(
lastAd
==
currentAd
)
{
multiClick
++
if
(
multiClick
>=
maxMultiClick
)
{
AdDisplayUtils
.
getInstance
().
setAdClickCount
(
AdDisplayUtils
.
getInstance
().
maxAdClickCount
)
AdDisplayUtils
.
getInstance
()
.
setAdClickCount
(
AdDisplayUtils
.
getInstance
().
maxAdClickCount
)
ActivityManagerUtils
.
getInstance
().
finishAllActivity
()
return
}
...
...
@@ -418,10 +435,10 @@ object AdmobUtils {
}
private
fun
pull
(
responseInfo
:
ResponseInfo
?,
adUnit
:
String
,
error
:
String
?
=
null
,
reqId
:
String
?
=
null
responseInfo
:
ResponseInfo
?,
adUnit
:
String
,
error
:
String
?
=
null
,
reqId
:
String
?
=
null
)
{
val
obj
=
JSONObject
()
if
(
responseInfo
!=
null
)
{
...
...
@@ -430,9 +447,9 @@ object AdmobUtils {
obj
.
put
(
"source"
,
response
.
adSourceName
)
val
credentials
=
mapOf
(
"placementid"
to
response
.
credentials
.
get
(
"placementid"
),
"appid"
to
response
.
credentials
.
get
(
"appid"
),
"pubid"
to
response
.
credentials
.
get
(
"pubid"
)
"placementid"
to
response
.
credentials
.
get
(
"placementid"
),
"appid"
to
response
.
credentials
.
get
(
"appid"
),
"pubid"
to
response
.
credentials
.
get
(
"pubid"
)
)
obj
.
put
(
"credentials"
,
credentials
.
toString
())
}
...
...
@@ -447,6 +464,7 @@ object AdmobUtils {
obj
.
put
(
"errMsg"
,
error
)
obj
.
put
(
"status"
,
"2"
)
}
EventUtils
.
event
(
"ad_pull"
,
ext
=
obj
)
}
private
fun
show
(
responseInfo
:
ResponseInfo
?,
adUnit
:
String
,
activity
:
Activity
?
=
null
)
{
...
...
@@ -456,13 +474,18 @@ object AdmobUtils {
obj
.
put
(
"ad_unit"
,
adUnit
)
obj
.
put
(
"networkname"
,
responseInfo
?.
mediationAdapterClassName
)
val
credentials
=
mapOf
(
"placementid"
to
response
?.
credentials
?.
get
(
"placementid"
),
"appid"
to
response
?.
credentials
?.
get
(
"appid"
),
"pubid"
to
response
?.
credentials
?.
get
(
"pubid"
)
"placementid"
to
response
?.
credentials
?.
get
(
"placementid"
),
"appid"
to
response
?.
credentials
?.
get
(
"appid"
),
"pubid"
to
response
?.
credentials
?.
get
(
"pubid"
)
)
obj
.
put
(
"credentials"
,
credentials
.
toString
())
obj
.
put
(
"session_id"
,
responseInfo
?.
responseId
)
obj
.
put
(
"from"
,
activity
?.
javaClass
?.
simpleName
)
if
(
adUnit
!=
"nativeAd"
)
{
EventUtils
.
event
(
"ad_show"
,
ext
=
obj
)
}
else
{
EventUtils
.
event
(
"bigimage_ad_show"
,
ext
=
obj
)
}
}
...
...
@@ -475,13 +498,18 @@ object AdmobUtils {
obj
.
put
(
"ad_unit"
,
adUnit
)
val
credentials
=
mapOf
(
"placementid"
to
response
?.
credentials
?.
get
(
"placementid"
),
"appid"
to
response
?.
credentials
?.
get
(
"appid"
),
"pubid"
to
response
?.
credentials
?.
get
(
"pubid"
)
"placementid"
to
response
?.
credentials
?.
get
(
"placementid"
),
"appid"
to
response
?.
credentials
?.
get
(
"appid"
),
"pubid"
to
response
?.
credentials
?.
get
(
"pubid"
)
)
obj
.
put
(
"credentials"
,
credentials
.
toString
())
obj
.
put
(
"session_id"
,
responseInfo
?.
responseId
)
obj
.
put
(
"networkname"
,
responseInfo
?.
mediationAdapterClassName
)
if
(
adUnit
!=
"nativeAd"
)
{
EventUtils
.
event
(
"ad_click"
,
ext
=
obj
)
}
else
{
EventUtils
.
event
(
"bigimage_ad_click"
,
ext
=
obj
)
}
}
private
val
taichiPref
by
lazy
{
...
...
@@ -525,8 +553,8 @@ object AdmobUtils {
if
(
currentTaichiTroasCache
>=
0.01
)
{
//如果超过0.01就触发一次tROAS taichi事件
val
roasbundle
=
Bundle
()
roasbundle
.
putDouble
(
FirebaseAnalytics
.
Param
.
VALUE
,
currentTaichiTroasCache
.
toDouble
()
FirebaseAnalytics
.
Param
.
VALUE
,
currentTaichiTroasCache
.
toDouble
()
)
roasbundle
.
putString
(
FirebaseAnalytics
.
Param
.
CURRENCY
,
"USD"
)
Firebase
.
analytics
.
logEvent
(
"Total_Ads_Revenue_001"
,
roasbundle
)
...
...
@@ -625,6 +653,7 @@ object AdmobUtils {
obj
.
put
(
"session_id"
,
sessionId
)
}
}
EventUtils
.
event
(
"ad_price"
,
ext
=
obj
)
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment