Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
F
File Recovery RecycleBin
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
File Recovery RecycleBin
Commits
2c0cd27f
Commit
2c0cd27f
authored
Jan 04, 2025
by
wanglei
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
4ca82a26
c3135d6b
Show whitespace changes
Inline
Side-by-side
Showing
51 changed files
with
1706 additions
and
1444 deletions
+1706
-1444
build.gradle
app/build.gradle
+7
-2
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+10
-3
MyApplication.kt
...ain/java/com/base/filerecoveryrecyclebin/MyApplication.kt
+6
-2
MainActivity.kt
.../com/base/filerecoveryrecyclebin/activity/MainActivity.kt
+24
-12
ResultActivity.kt
...om/base/filerecoveryrecyclebin/activity/ResultActivity.kt
+16
-7
SettingActivity.kt
...m/base/filerecoveryrecyclebin/activity/SettingActivity.kt
+7
-3
SplashActivity.kt
...om/base/filerecoveryrecyclebin/activity/SplashActivity.kt
+283
-283
BatteryActivity.kt
...ilerecoveryrecyclebin/activity/battery/BatteryActivity.kt
+0
-1
BatteryInfoAnimationActivity.kt
...cyclebin/activity/battery/BatteryInfoAnimationActivity.kt
+1
-1
RecycleBinDetailActivity.kt
...ecyclebin/activity/recyclebin/RecycleBinDetailActivity.kt
+9
-16
RepeatActivity.kt
.../filerecoveryrecyclebin/activity/repeat/RepeatActivity.kt
+24
-17
ScreenShotActivity.kt
...overyrecyclebin/activity/screenshot/ScreenShotActivity.kt
+34
-14
Splash2Activity.kt
...filerecoveryrecyclebin/activity/splash/Splash2Activity.kt
+2
-13
StartUtils.kt
...base/filerecoveryrecyclebin/activity/splash/StartUtils.kt
+1
-0
AppFunctionAdapter.kt
...base/filerecoveryrecyclebin/adapter/AppFunctionAdapter.kt
+0
-1
RecycleBinAdapter.kt
.../base/filerecoveryrecyclebin/adapter/RecycleBinAdapter.kt
+1
-6
AdCommonUtils.kt
...java/com/base/filerecoveryrecyclebin/ads/AdCommonUtils.kt
+27
-0
AdDisplayUtils.java
...a/com/base/filerecoveryrecyclebin/ads/AdDisplayUtils.java
+12
-0
AdmobMaxHelper.kt
...ava/com/base/filerecoveryrecyclebin/ads/AdmobMaxHelper.kt
+38
-43
AdmobCommonUtils.kt
...base/filerecoveryrecyclebin/ads/admob/AdmobCommonUtils.kt
+0
-31
AdmobInterstitialUtils.kt
...ilerecoveryrecyclebin/ads/admob/AdmobInterstitialUtils.kt
+1
-45
AdmobNativeUtils.kt
...base/filerecoveryrecyclebin/ads/admob/AdmobNativeUtils.kt
+0
-3
AdmobOpenUtils.kt
...m/base/filerecoveryrecyclebin/ads/admob/AdmobOpenUtils.kt
+0
-10
AdMaxEvent.kt
...ava/com/base/filerecoveryrecyclebin/ads/max/AdMaxEvent.kt
+144
-144
AdMaxInit.kt
...java/com/base/filerecoveryrecyclebin/ads/max/AdMaxInit.kt
+47
-48
AdMaxInterstitialUtils.kt
.../filerecoveryrecyclebin/ads/max/AdMaxInterstitialUtils.kt
+196
-204
AdMaxNativeUtils.kt
...m/base/filerecoveryrecyclebin/ads/max/AdMaxNativeUtils.kt
+160
-162
AdMaxOpenUtils.kt
...com/base/filerecoveryrecyclebin/ads/max/AdMaxOpenUtils.kt
+176
-193
RecycleBinBean.kt
...va/com/base/filerecoveryrecyclebin/bean/RecycleBinBean.kt
+5
-3
FCMManager.java
.../java/com/base/filerecoveryrecyclebin/fcm/FCMManager.java
+0
-50
FCMManager.kt
...in/java/com/base/filerecoveryrecyclebin/fcm/FCMManager.kt
+68
-0
FcmReceiver.java
...java/com/base/filerecoveryrecyclebin/fcm/FcmReceiver.java
+6
-1
MessagingService.java
...com/base/filerecoveryrecyclebin/fcm/MessagingService.java
+21
-1
NotificationUtil.kt
...a/com/base/filerecoveryrecyclebin/fcm/NotificationUtil.kt
+2
-2
HomeFragment.kt
.../com/base/filerecoveryrecyclebin/fragment/HomeFragment.kt
+1
-1
InstallHelps.kt
...java/com/base/filerecoveryrecyclebin/help/InstallHelps.kt
+16
-17
NewComUtils.kt
.../java/com/base/filerecoveryrecyclebin/help/NewComUtils.kt
+14
-12
BackUpUtils.kt
...va/com/base/filerecoveryrecyclebin/service/BackUpUtils.kt
+32
-24
FileObserverExample.java
...e/filerecoveryrecyclebin/service/FileObserverExample.java
+12
-17
StayJobService.kt
...com/base/filerecoveryrecyclebin/service/StayJobService.kt
+191
-0
StayNotificationService.kt
...filerecoveryrecyclebin/service/StayNotificationService.kt
+13
-14
EventUtils.kt
.../java/com/base/filerecoveryrecyclebin/utils/EventUtils.kt
+5
-2
LogEx.kt
.../main/java/com/base/filerecoveryrecyclebin/utils/LogEx.kt
+2
-1
SimilarHelper.kt
...va/com/base/filerecoveryrecyclebin/utils/SimilarHelper.kt
+46
-30
RepeatingWorker.kt
...a/com/base/filerecoveryrecyclebin/work/RepeatingWorker.kt
+42
-0
activity_battery.xml
app/src/main/res/layout/activity_battery.xml
+1
-1
activity_main.xml
app/src/main/res/layout/activity_main.xml
+1
-1
activity_recycle_bin_detail.xml
app/src/main/res/layout/activity_recycle_bin_detail.xml
+1
-1
item_result_fun_2.xml
app/src/main/res/layout/item_result_fun_2.xml
+1
-1
layout_max_native_custom.xml
app/src/main/res/layout/layout_max_native_custom.xml
+0
-1
zhanweitu2.png
app/src/main/res/mipmap-xxhdpi/zhanweitu2.png
+0
-0
No files found.
app/build.gradle
View file @
2c0cd27f
...
@@ -92,13 +92,13 @@ dependencies {
...
@@ -92,13 +92,13 @@ dependencies {
//广告
//广告
implementation
(
"com.google.android.gms:play-services-ads:23.1.0"
)
implementation
(
"com.google.android.gms:play-services-ads:23.1.0"
)
implementation
'com.google.ads.mediation:applovin:1
2.4.3
.0'
implementation
'com.google.ads.mediation:applovin:1
3.0.1
.0'
implementation
'com.google.ads.mediation:facebook:6.17.0.0'
implementation
'com.google.ads.mediation:facebook:6.17.0.0'
implementation
'com.google.ads.mediation:mintegral:16.7.21.0'
implementation
'com.google.ads.mediation:mintegral:16.7.21.0'
implementation
'com.google.ads.mediation:pangle:5.9.0.4.0'
implementation
'com.google.ads.mediation:pangle:5.9.0.4.0'
//max
//max
implementation
'com.applovin:applovin-sdk:+'
//
implementation 'com.applovin:applovin-sdk:+'
// implementation 'com.applovin.mediation:google-adapter:+'
// implementation 'com.applovin.mediation:google-adapter:+'
// implementation 'com.applovin.mediation:facebook-adapter:+'
// implementation 'com.applovin.mediation:facebook-adapter:+'
// implementation 'com.applovin.mediation:mintegral-adapter:+'
// implementation 'com.applovin.mediation:mintegral-adapter:+'
...
@@ -115,9 +115,14 @@ dependencies {
...
@@ -115,9 +115,14 @@ dependencies {
implementation
'com.google.firebase:firebase-crashlytics'
implementation
'com.google.firebase:firebase-crashlytics'
implementation
'com.google.firebase:firebase-crashlytics-ktx'
implementation
'com.google.firebase:firebase-crashlytics-ktx'
implementation
'com.google.firebase:firebase-analytics:21.6.2'
implementation
'com.google.firebase:firebase-analytics:21.6.2'
implementation
(
"com.google.firebase:firebase-messaging-directboot"
)
//google 内购订阅
//google 内购订阅
def
billing_version
=
"7.0.0"
def
billing_version
=
"7.0.0"
implementation
"com.android.billingclient:billing:$billing_version"
implementation
"com.android.billingclient:billing:$billing_version"
//work
implementation
(
"androidx.work:work-runtime-ktx:2.7.1"
)
// 请使用最新版本
}
}
\ No newline at end of file
app/src/main/AndroidManifest.xml
View file @
2c0cd27f
...
@@ -250,12 +250,19 @@
...
@@ -250,12 +250,19 @@
android:name=
"com.google.android.gms.ads.flag.NATIVE_AD_DEBUGGER_ENABLED"
android:name=
"com.google.android.gms.ads.flag.NATIVE_AD_DEBUGGER_ENABLED"
android:value=
"false"
/>
android:value=
"false"
/>
<!-- 常驻通知栏 -->
<!-- 常驻通知栏 -->
<!-- <service-->
<!-- android:name=".service.StayNotificationService"-->
<!-- android:foregroundServiceType="dataSync" />-->
<service
<service
android:name=
".service.StayNotificationService"
android:name=
".service.StayJobService"
android:foregroundServiceType=
"dataSync"
/>
android:exported=
"false"
android:foregroundServiceType=
"dataSync"
android:permission=
"android.permission.BIND_JOB_SERVICE"
/>
<service
<service
android:directBootAware=
"true"
android:name=
".fcm.MessagingService"
android:name=
".fcm.MessagingService"
android:exported=
"
tru
e"
>
android:exported=
"
fals
e"
>
<intent-filter>
<intent-filter>
<action
android:name=
"com.google.firebase.MESSAGING_EVENT"
/>
<action
android:name=
"com.google.firebase.MESSAGING_EVENT"
/>
</intent-filter>
</intent-filter>
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/MyApplication.kt
View file @
2c0cd27f
...
@@ -16,8 +16,10 @@ import com.base.filerecoveryrecyclebin.help.BlackUtils
...
@@ -16,8 +16,10 @@ import com.base.filerecoveryrecyclebin.help.BlackUtils
import
com.base.filerecoveryrecyclebin.help.ConfigHelper
import
com.base.filerecoveryrecyclebin.help.ConfigHelper
import
com.base.filerecoveryrecyclebin.utils.ActivityManagerUtils
import
com.base.filerecoveryrecyclebin.utils.ActivityManagerUtils
import
com.base.filerecoveryrecyclebin.utils.AppPreferences
import
com.base.filerecoveryrecyclebin.utils.AppPreferences
import
com.base.filerecoveryrecyclebin.utils.InstallHelps
import
com.base.filerecoveryrecyclebin.help.InstallHelps
import
com.base.filerecoveryrecyclebin.service.StayJobService.Companion.startJob
import
com.base.filerecoveryrecyclebin.utils.LogEx
import
com.base.filerecoveryrecyclebin.utils.LogEx
import
com.base.filerecoveryrecyclebin.work.schedulePeriodicWork
import
com.facebook.FacebookSdk
import
com.facebook.FacebookSdk
import
com.google.android.gms.ads.identifier.AdvertisingIdClient
import
com.google.android.gms.ads.identifier.AdvertisingIdClient
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.Dispatchers
...
@@ -59,7 +61,7 @@ class MyApplication : BaseApplication() {
...
@@ -59,7 +61,7 @@ class MyApplication : BaseApplication() {
fun
initApp
(
isStartClick
:
Boolean
=
false
)
{
fun
initApp
(
isStartClick
:
Boolean
=
false
)
{
if
(!
isStartClick
)
{
if
(!
isStartClick
)
{
Log
.
e
(
"MXL"
,
"initApp: "
,
)
Log
.
e
(
"MXL"
,
"initApp: "
)
@Suppress
(
"DEPRECATION"
)
@Suppress
(
"DEPRECATION"
)
FacebookSdk
.
sdkInitialize
(
applicationContext
)
FacebookSdk
.
sdkInitialize
(
applicationContext
)
// FacebookSdk.setIsDebugEnabled(true)
// FacebookSdk.setIsDebugEnabled(true)
...
@@ -72,6 +74,8 @@ class MyApplication : BaseApplication() {
...
@@ -72,6 +74,8 @@ class MyApplication : BaseApplication() {
InstallHelps
.
init
()
InstallHelps
.
init
()
BlackUtils
.
requestBlack
()
BlackUtils
.
requestBlack
()
initLifeListener
()
initLifeListener
()
schedulePeriodicWork
(
this
)
startJob
()
}
}
if
(
ifAgreePrivacy
)
{
if
(
ifAgreePrivacy
)
{
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/activity/MainActivity.kt
View file @
2c0cd27f
package
com.base.filerecoveryrecyclebin.activity
package
com.base.filerecoveryrecyclebin.activity
import
android.content.ClipData
import
android.content.ClipboardManager
import
android.content.Intent
import
android.content.Intent
import
android.graphics.Color
import
android.graphics.Color
import
android.graphics.Typeface
import
android.graphics.Typeface
import
android.view.View
import
android.view.View
import
android.widget.Toast
import
androidx.activity.addCallback
import
androidx.activity.addCallback
import
androidx.core.view.isVisible
import
androidx.core.view.updatePadding
import
androidx.core.view.updatePadding
import
androidx.fragment.app.Fragment
import
androidx.fragment.app.Fragment
import
androidx.lifecycle.lifecycleScope
import
androidx.lifecycle.lifecycleScope
import
androidx.viewpager2.adapter.FragmentStateAdapter
import
androidx.viewpager2.adapter.FragmentStateAdapter
import
androidx.viewpager2.widget.ViewPager2
import
androidx.viewpager2.widget.ViewPager2
import
com.base.filerecoveryrecyclebin.activity.repeat.RepeatActivity
import
com.base.filerecoveryrecyclebin.activity.repeat.RepeatActivity.Companion.similarPhotoDeleted
import
com.base.filerecoveryrecyclebin.activity.screenshot.ScreenShotActivity.Companion.screenPhotoDeleted
import
com.base.filerecoveryrecyclebin.ads.admob.AdmobBannerUtils
import
com.base.filerecoveryrecyclebin.ads.admob.AdmobBannerUtils
import
com.base.filerecoveryrecyclebin.bean.MediaBean
import
com.base.filerecoveryrecyclebin.bean.MediaBean
import
com.base.filerecoveryrecyclebin.databinding.ActivityMainBinding
import
com.base.filerecoveryrecyclebin.databinding.ActivityMainBinding
...
@@ -33,8 +32,10 @@ import com.base.filerecoveryrecyclebin.view.PermissionDialog.showPermissionBotto
...
@@ -33,8 +32,10 @@ import com.base.filerecoveryrecyclebin.view.PermissionDialog.showPermissionBotto
import
com.base.filerecoveryrecyclebin.view.RateStarPop.showRateStarPopDialog
import
com.base.filerecoveryrecyclebin.view.RateStarPop.showRateStarPopDialog
import
com.facebook.appevents.AppEventsLogger
import
com.facebook.appevents.AppEventsLogger
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.Job
import
kotlinx.coroutines.delay
import
kotlinx.coroutines.delay
import
kotlinx.coroutines.flow.MutableSharedFlow
import
kotlinx.coroutines.flow.MutableSharedFlow
import
kotlinx.coroutines.flow.last
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.launch
import
java.io.File
import
java.io.File
import
java.util.Locale
import
java.util.Locale
...
@@ -118,8 +119,6 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
...
@@ -118,8 +119,6 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
logger
.
logEvent
(
"home"
)
logger
.
logEvent
(
"home"
)
AppPreferences
.
getInstance
().
put
(
"fb_home"
,
1
)
AppPreferences
.
getInstance
().
put
(
"fb_home"
,
1
)
}
}
}
}
private
fun
initStayServiceObserver
()
{
private
fun
initStayServiceObserver
()
{
...
@@ -186,22 +185,35 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
...
@@ -186,22 +185,35 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
}
}
}
}
private
var
initPhotoSizeFirst
=
true
private
fun
initPhotoSize
()
=
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
private
fun
initPhotoSize
()
=
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
LogEx
.
logDebug
(
TAG
,
"initPhotoSize"
)
LogEx
.
logDebug
(
TAG
,
"initPhotoSize"
)
val
list
=
arrayListOf
<
MediaBean
>()
val
list
=
arrayListOf
<
MediaBean
>()
getImageMedia
(
list
)
getImageMedia
(
list
)
val
screenSize
=
list
.
filter
{
it
.
path
.
lowercase
(
Locale
.
ENGLISH
).
contains
(
"screenshot"
)
}.
map
{
File
(
it
.
path
)
}.
sumOf
{
it
.
length
()
}
val
similar
=
calculateSimilar
(
list
).
flatMap
{
it
.
value
}.
map
{
File
(
it
.
path
)
}.
sumOf
{
it
.
length
()
}
LogEx
.
logDebug
(
TAG
,
"screenSize=$screenSize"
)
var
screenSize
=
0L
if
(
screenPhotoDeleted
||
initPhotoSizeFirst
)
{
screenSize
=
list
.
filter
{
it
.
path
.
lowercase
(
Locale
.
ENGLISH
).
contains
(
"screenshot"
)
}.
map
{
File
(
it
.
path
)
}.
sumOf
{
it
.
length
()
}
screenPhotoDeleted
=
false
delay
(
1500
)
photoSizeFlow
.
emit
(
Pair
(
screenSize
,
0L
))
}
var
similar
=
0L
if
(
similarPhotoDeleted
||
initPhotoSizeFirst
)
{
val
similarPhoto
=
calculateSimilar
(
list
)
RepeatActivity
.
readySimilarList
=
similarPhoto
similar
=
similarPhoto
.
flatMap
{
it
.
value
}.
map
{
File
(
it
.
path
)
}.
sumOf
{
it
.
length
()
}
similarPhotoDeleted
=
false
delay
(
1500
)
delay
(
1500
)
photoSizeFlow
.
emit
(
Pair
(
screenSize
,
similar
))
photoSizeFlow
.
emit
(
Pair
(
screenSize
,
similar
))
}
}
initPhotoSizeFirst
=
false
}
}
}
\ No newline at end of file
app/src/main/java/com/base/filerecoveryrecyclebin/activity/ResultActivity.kt
View file @
2c0cd27f
...
@@ -5,6 +5,7 @@ import android.content.Intent
...
@@ -5,6 +5,7 @@ import android.content.Intent
import
android.graphics.Color
import
android.graphics.Color
import
androidx.activity.OnBackPressedCallback
import
androidx.activity.OnBackPressedCallback
import
androidx.core.view.updatePadding
import
androidx.core.view.updatePadding
import
com.base.filerecoveryrecyclebin.activity.appmanager.AppManagerAnimationActivity
import
com.base.filerecoveryrecyclebin.activity.appprocess.AppProcessAnimationActivity
import
com.base.filerecoveryrecyclebin.activity.appprocess.AppProcessAnimationActivity
import
com.base.filerecoveryrecyclebin.activity.battery.BatteryInfoAnimationActivity
import
com.base.filerecoveryrecyclebin.activity.battery.BatteryInfoAnimationActivity
import
com.base.filerecoveryrecyclebin.activity.junkclean.ScanJunkActivity
import
com.base.filerecoveryrecyclebin.activity.junkclean.ScanJunkActivity
...
@@ -15,6 +16,8 @@ import com.base.filerecoveryrecyclebin.activity.screenshot.ScreenShotAnimationAc
...
@@ -15,6 +16,8 @@ import com.base.filerecoveryrecyclebin.activity.screenshot.ScreenShotAnimationAc
import
com.base.filerecoveryrecyclebin.activity.whatsapp.WhatsAppCleanerAnimationActivity
import
com.base.filerecoveryrecyclebin.activity.whatsapp.WhatsAppCleanerAnimationActivity
import
com.base.filerecoveryrecyclebin.adapter.AppFunctionAdapter
import
com.base.filerecoveryrecyclebin.adapter.AppFunctionAdapter
import
com.base.filerecoveryrecyclebin.ads.AdmobMaxHelper
import
com.base.filerecoveryrecyclebin.ads.AdmobMaxHelper
import
com.base.filerecoveryrecyclebin.bean.ConstObject
import
com.base.filerecoveryrecyclebin.bean.ConstObject.APP_MANAGER
import
com.base.filerecoveryrecyclebin.bean.ConstObject.APP_PROCESS
import
com.base.filerecoveryrecyclebin.bean.ConstObject.APP_PROCESS
import
com.base.filerecoveryrecyclebin.bean.ConstObject.BATTERY_INFO
import
com.base.filerecoveryrecyclebin.bean.ConstObject.BATTERY_INFO
import
com.base.filerecoveryrecyclebin.bean.ConstObject.JUNK_CLEANER
import
com.base.filerecoveryrecyclebin.bean.ConstObject.JUNK_CLEANER
...
@@ -53,13 +56,6 @@ class ResultActivity : BaseActivity<ActivityLayoutResultBinding>() {
...
@@ -53,13 +56,6 @@ class ResultActivity : BaseActivity<ActivityLayoutResultBinding>() {
startActivity
(
Intent
(
this
,
ScanJunkActivity
::
class
.
java
))
startActivity
(
Intent
(
this
,
ScanJunkActivity
::
class
.
java
))
}
}
REPEAT_PHOTOS
->
{
startActivity
(
Intent
(
this
,
RepeatAnimationActivity
::
class
.
java
))
}
SCREENSHOT_CLEANER
->
{
startActivity
(
Intent
(
this
,
ScreenShotAnimationActivity
::
class
.
java
))
}
RECOVERY_PHOTOS
->
{
RECOVERY_PHOTOS
->
{
startActivity
(
Intent
(
this
,
FileScanResultActivity
::
class
.
java
).
apply
{
startActivity
(
Intent
(
this
,
FileScanResultActivity
::
class
.
java
).
apply
{
...
@@ -79,6 +75,15 @@ class ResultActivity : BaseActivity<ActivityLayoutResultBinding>() {
...
@@ -79,6 +75,15 @@ class ResultActivity : BaseActivity<ActivityLayoutResultBinding>() {
})
})
}
}
REPEAT_PHOTOS
->
{
startActivity
(
Intent
(
this
,
RepeatAnimationActivity
::
class
.
java
))
}
SCREENSHOT_CLEANER
->
{
startActivity
(
Intent
(
this
,
ScreenShotAnimationActivity
::
class
.
java
))
}
WHATSAPP_CLEANER
->
{
WHATSAPP_CLEANER
->
{
startActivity
(
Intent
(
this
,
WhatsAppCleanerAnimationActivity
::
class
.
java
))
startActivity
(
Intent
(
this
,
WhatsAppCleanerAnimationActivity
::
class
.
java
))
}
}
...
@@ -87,6 +92,10 @@ class ResultActivity : BaseActivity<ActivityLayoutResultBinding>() {
...
@@ -87,6 +92,10 @@ class ResultActivity : BaseActivity<ActivityLayoutResultBinding>() {
startActivity
(
Intent
(
this
,
AppProcessAnimationActivity
::
class
.
java
))
startActivity
(
Intent
(
this
,
AppProcessAnimationActivity
::
class
.
java
))
}
}
APP_MANAGER
->
{
startActivity
(
Intent
(
this
,
AppManagerAnimationActivity
::
class
.
java
))
}
LARGE_FILE
->
{
LARGE_FILE
->
{
startActivity
(
Intent
(
this
,
LargeFileAnimationActivity
::
class
.
java
))
startActivity
(
Intent
(
this
,
LargeFileAnimationActivity
::
class
.
java
))
}
}
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/activity/SettingActivity.kt
View file @
2c0cd27f
...
@@ -11,6 +11,8 @@ import com.base.filerecoveryrecyclebin.fcm.FCMManager.subscribeToTopic
...
@@ -11,6 +11,8 @@ import com.base.filerecoveryrecyclebin.fcm.FCMManager.subscribeToTopic
import
com.base.filerecoveryrecyclebin.fcm.FCMManager.unsubscribeFromTopic
import
com.base.filerecoveryrecyclebin.fcm.FCMManager.unsubscribeFromTopic
import
com.base.filerecoveryrecyclebin.help.BaseActivity
import
com.base.filerecoveryrecyclebin.help.BaseActivity
import
com.base.filerecoveryrecyclebin.help.ConfigHelper
import
com.base.filerecoveryrecyclebin.help.ConfigHelper
import
com.base.filerecoveryrecyclebin.service.StayJobService
import
com.base.filerecoveryrecyclebin.service.StayJobService.Companion.startJob
import
com.base.filerecoveryrecyclebin.service.StayNotificationService
import
com.base.filerecoveryrecyclebin.service.StayNotificationService
import
com.base.filerecoveryrecyclebin.service.StayNotificationService.Companion.startStayNotification
import
com.base.filerecoveryrecyclebin.service.StayNotificationService.Companion.startStayNotification
import
com.base.filerecoveryrecyclebin.utils.BarUtils
import
com.base.filerecoveryrecyclebin.utils.BarUtils
...
@@ -41,10 +43,12 @@ class SettingActivity : BaseActivity<ActivitySettingBinding>() {
...
@@ -41,10 +43,12 @@ class SettingActivity : BaseActivity<ActivitySettingBinding>() {
binding
.
switchStayNotification
.
setOnCheckedChangeListener
{
buttonView
,
isChecked
->
binding
.
switchStayNotification
.
setOnCheckedChangeListener
{
buttonView
,
isChecked
->
stayNotification
=
isChecked
stayNotification
=
isChecked
if
(
isChecked
)
{
if
(
isChecked
)
{
startStayNotification
()
startJob
()
// startStayNotification()
}
else
{
}
else
{
val
serviceIntent
=
Intent
(
this
,
StayNotificationService
::
class
.
java
)
StayJobService
.
isCancel
=
true
stopService
(
serviceIntent
)
// val serviceIntent = Intent(this, StayNotificationService::class.java)
// stopService(serviceIntent)
}
}
}
}
binding
.
switchFcmNotification
.
setOnCheckedChangeListener
{
buttonView
,
isChecked
->
binding
.
switchFcmNotification
.
setOnCheckedChangeListener
{
buttonView
,
isChecked
->
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/activity/SplashActivity.kt
View file @
2c0cd27f
package
com.base.filerecoveryrecyclebin.activity
//package com.base.filerecoveryrecyclebin.activity
//
import
android.annotation.SuppressLint
//import android.annotation.SuppressLint
import
android.content.Intent
//import android.content.Intent
import
android.graphics.Color
//import android.graphics.Color
import
android.net.Uri
//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.view.View
//import android.view.View
import
androidx.lifecycle.lifecycleScope
//import androidx.lifecycle.lifecycleScope
import
com.base.filerecoveryrecyclebin.MyApplication
//import com.base.filerecoveryrecyclebin.MyApplication
import
com.base.filerecoveryrecyclebin.activity.appmanager.AppManagerAnimationActivity
//import com.base.filerecoveryrecyclebin.activity.appmanager.AppManagerAnimationActivity
import
com.base.filerecoveryrecyclebin.activity.appprocess.AppProcessAnimationActivity
//import com.base.filerecoveryrecyclebin.activity.appprocess.AppProcessAnimationActivity
import
com.base.filerecoveryrecyclebin.activity.battery.BatteryInfoAnimationActivity
//import com.base.filerecoveryrecyclebin.activity.battery.BatteryInfoAnimationActivity
import
com.base.filerecoveryrecyclebin.activity.guide.GuideActivity
//import com.base.filerecoveryrecyclebin.activity.guide.GuideActivity
import
com.base.filerecoveryrecyclebin.activity.junkclean.ScanJunkActivity
//import com.base.filerecoveryrecyclebin.activity.junkclean.ScanJunkActivity
import
com.base.filerecoveryrecyclebin.activity.photomanager.PhotoManagerAnimationActivity
//import com.base.filerecoveryrecyclebin.activity.photomanager.PhotoManagerAnimationActivity
import
com.base.filerecoveryrecyclebin.activity.recovery.FileScanResultActivity
//import com.base.filerecoveryrecyclebin.activity.recovery.FileScanResultActivity
import
com.base.filerecoveryrecyclebin.activity.repeat.RepeatActivity
//import com.base.filerecoveryrecyclebin.activity.repeat.RepeatActivity
import
com.base.filerecoveryrecyclebin.activity.whatsapp.WhatsAppCleanerAnimationActivity
//import com.base.filerecoveryrecyclebin.activity.whatsapp.WhatsAppCleanerAnimationActivity
import
com.base.filerecoveryrecyclebin.ads.AdmobMaxHelper
//import com.base.filerecoveryrecyclebin.ads.AdmobMaxHelper
import
com.base.filerecoveryrecyclebin.bean.ConstObject
//import com.base.filerecoveryrecyclebin.bean.ConstObject
import
com.base.filerecoveryrecyclebin.bean.ConstObject.ID_APP_MANAGER
//import com.base.filerecoveryrecyclebin.bean.ConstObject.ID_APP_MANAGER
import
com.base.filerecoveryrecyclebin.bean.ConstObject.ID_APP_PROCESS
//import com.base.filerecoveryrecyclebin.bean.ConstObject.ID_APP_PROCESS
import
com.base.filerecoveryrecyclebin.bean.ConstObject.ID_BATTERY_INFO
//import com.base.filerecoveryrecyclebin.bean.ConstObject.ID_BATTERY_INFO
import
com.base.filerecoveryrecyclebin.bean.ConstObject.ID_JUNK_CLEAN_PUSH
//import com.base.filerecoveryrecyclebin.bean.ConstObject.ID_JUNK_CLEAN_PUSH
import
com.base.filerecoveryrecyclebin.bean.ConstObject.ID_RECOVERY_DOCUMENTS
//import com.base.filerecoveryrecyclebin.bean.ConstObject.ID_RECOVERY_DOCUMENTS
import
com.base.filerecoveryrecyclebin.bean.ConstObject.ID_RECOVERY_PHOTOS
//import com.base.filerecoveryrecyclebin.bean.ConstObject.ID_RECOVERY_PHOTOS
import
com.base.filerecoveryrecyclebin.bean.ConstObject.ID_RECOVERY_VIDEOS
//import com.base.filerecoveryrecyclebin.bean.ConstObject.ID_RECOVERY_VIDEOS
import
com.base.filerecoveryrecyclebin.bean.ConstObject.ID_SCREENSHOT_CLEAN
//import com.base.filerecoveryrecyclebin.bean.ConstObject.ID_SCREENSHOT_CLEAN
import
com.base.filerecoveryrecyclebin.bean.ConstObject.ID_SIMILAR_IMAGE
//import com.base.filerecoveryrecyclebin.bean.ConstObject.ID_SIMILAR_IMAGE
import
com.base.filerecoveryrecyclebin.bean.ConstObject.ID_WHATSAPP
//import com.base.filerecoveryrecyclebin.bean.ConstObject.ID_WHATSAPP
import
com.base.filerecoveryrecyclebin.bean.ConstObject.ifAgreePrivacy
//import com.base.filerecoveryrecyclebin.bean.ConstObject.ifAgreePrivacy
import
com.base.filerecoveryrecyclebin.bean.ConstObject.isGuide
//import com.base.filerecoveryrecyclebin.bean.ConstObject.isGuide
import
com.base.filerecoveryrecyclebin.databinding.ActivitySplashBinding
//import com.base.filerecoveryrecyclebin.databinding.ActivitySplashBinding
import
com.base.filerecoveryrecyclebin.fcm.CloseNotificationReceiver
//import com.base.filerecoveryrecyclebin.fcm.CloseNotificationReceiver
import
com.base.filerecoveryrecyclebin.fcm.CloseNotificationReceiver.Companion.NotificationId
//import com.base.filerecoveryrecyclebin.fcm.CloseNotificationReceiver.Companion.NotificationId
import
com.base.filerecoveryrecyclebin.fcm.NotificationUtil
//import com.base.filerecoveryrecyclebin.fcm.NotificationUtil
import
com.base.filerecoveryrecyclebin.help.BaseActivity
//import com.base.filerecoveryrecyclebin.help.BaseActivity
import
com.base.filerecoveryrecyclebin.help.ConfigHelper
//import com.base.filerecoveryrecyclebin.help.ConfigHelper
import
com.base.filerecoveryrecyclebin.service.StayNotificationService.Companion.startStayNotification
//import com.base.filerecoveryrecyclebin.service.StayNotificationService.Companion.startStayNotification
import
com.base.filerecoveryrecyclebin.utils.AppPreferences
//import com.base.filerecoveryrecyclebin.utils.AppPreferences
import
com.base.filerecoveryrecyclebin.utils.BarUtils
//import com.base.filerecoveryrecyclebin.utils.BarUtils
import
com.base.filerecoveryrecyclebin.utils.LogEx
//import com.base.filerecoveryrecyclebin.utils.LogEx
import
kotlinx.coroutines.Job
//import kotlinx.coroutines.Job
import
kotlinx.coroutines.cancel
//import kotlinx.coroutines.cancel
import
kotlinx.coroutines.delay
//import kotlinx.coroutines.delay
import
kotlinx.coroutines.flow.MutableSharedFlow
//import kotlinx.coroutines.flow.MutableSharedFlow
import
kotlinx.coroutines.flow.SharedFlow
//import kotlinx.coroutines.flow.SharedFlow
import
kotlinx.coroutines.flow.collectLatest
//import kotlinx.coroutines.flow.collectLatest
import
kotlinx.coroutines.isActive
//import kotlinx.coroutines.isActive
import
kotlinx.coroutines.launch
//import kotlinx.coroutines.launch
import
kotlin.random.Random
//import kotlin.random.Random
//
@SuppressLint
(
"CustomSplashScreen"
)
//@SuppressLint("CustomSplashScreen")
class
SplashActivity
:
BaseActivity
<
ActivitySplashBinding
>()
{
//class SplashActivity : BaseActivity<ActivitySplashBinding>() {
//
private
val
TAG
=
"SplashActivity"
// private val TAG = "SplashActivity"
private
var
job
:
Job
?
=
null
// private var job: Job? = null
private
val
progress
=
MutableSharedFlow
<
Int
>()
// private val progress = MutableSharedFlow<Int>()
private
val
progressFlow
:
SharedFlow
<
Int
>
=
progress
// private val progressFlow: SharedFlow<Int> = progress
private
var
oneClickStart
:
Boolean
=
false
// private var oneClickStart: Boolean = false
private
var
actionId
=
-
1
// private var actionId = -1
//
//
override
val
binding
:
ActivitySplashBinding
by
lazy
{
// override val binding: ActivitySplashBinding by lazy {
ActivitySplashBinding
.
inflate
(
layoutInflater
)
// ActivitySplashBinding.inflate(layoutInflater)
}
// }
//
override
fun
initView
()
{
// override fun initView() {
BarUtils
.
setStatusBarLightMode
(
this
,
true
)
// BarUtils.setStatusBarLightMode(this, true)
BarUtils
.
setStatusBarColor
(
this
,
Color
.
TRANSPARENT
)
// BarUtils.setStatusBarColor(this, Color.TRANSPARENT)
//
// if (MyApplication.isInterOpenShowing) {
//// if (MyApplication.isInterOpenShowing) {
// finish()
//// finish()
//// return
//// }
//
// startStayNotification()
// NotificationUtil.stopNotificationHandler()
//
// actionId = intent?.extras?.getInt("actionId") ?: -1
// closeNotification()
//
// progressCollect()
//
// if (ifAgreePrivacy) {
// AdmobMaxHelper.preloadAd(this)
// job = startProgress()
// binding.llStart.visibility = View.GONE
// binding.llProgress.visibility = View.VISIBLE
// } else {
// binding.llStart.visibility = View.VISIBLE
// binding.llProgress.visibility = View.GONE
// }
//
// val spannableString = SpannableString("Privacy Policy")
// spannableString.setSpan(
// UnderlineSpan(),
// 0,
// spannableString.length,
// Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
// )
// binding.idTvPrivacyPolicy.text = spannableString
//
// binding.idTvPrivacyPolicy.setOnClickListener {
// val intent = Intent(
// Intent.ACTION_VIEW,
// Uri.parse(ConfigHelper.privacyPolicy)
// )
// startActivity(intent)
// }
// }
//
// private fun progressCollect() {
// lifecycleScope.launch {
// progressFlow.collectLatest {
// if (it >= 100) {
// job?.cancel()
// jumpNext()
// this.cancel()
// }
// }
// }
// }
//
// var jumped: Boolean = false
// private fun jumpNext() {
//
// if (jumped) {
// return
// return
// }
// }
// jumped = true
startStayNotification
()
// LogEx.logDebug(TAG, "jumpNext actionId=$actionId")
NotificationUtil
.
stopNotificationHandler
()
//
// when (actionId) {
actionId
=
intent
?.
extras
?.
getInt
(
"actionId"
)
?:
-
1
// ID_JUNK_CLEAN_PUSH -> {
closeNotification
()
// startActivity(Intent(this, ScanJunkActivity::class.java))
// }
progressCollect
()
//
// ID_SIMILAR_IMAGE -> {
if
(
ifAgreePrivacy
)
{
// startActivity(Intent(this, PhotoManagerAnimationActivity::class.java))
AdmobMaxHelper
.
preloadAd
(
this
)
// }
job
=
startProgress
()
//
binding
.
llStart
.
visibility
=
View
.
GONE
// ID_SCREENSHOT_CLEAN -> {
binding
.
llProgress
.
visibility
=
View
.
VISIBLE
// startActivity(Intent(this, PhotoManagerAnimationActivity::class.java))
}
else
{
// }
binding
.
llStart
.
visibility
=
View
.
VISIBLE
//
binding
.
llProgress
.
visibility
=
View
.
GONE
// ID_RECOVERY_PHOTOS -> {
}
// startActivity(Intent(this, FileScanResultActivity::class.java).apply {
// putExtra("ScanType", ConstObject.SCAN_PHOTOS)
val
spannableString
=
SpannableString
(
"Privacy Policy"
)
// })
spannableString
.
setSpan
(
// }
UnderlineSpan
(),
//
0
,
// ID_RECOVERY_VIDEOS -> {
spannableString
.
length
,
// startActivity(Intent(this, FileScanResultActivity::class.java).apply {
Spanned
.
SPAN_EXCLUSIVE_EXCLUSIVE
// putExtra("ScanType", ConstObject.SCAN_VIDEOS)
)
// })
binding
.
idTvPrivacyPolicy
.
text
=
spannableString
// }
//
binding
.
idTvPrivacyPolicy
.
setOnClickListener
{
// ID_RECOVERY_DOCUMENTS -> {
val
intent
=
Intent
(
// startActivity(Intent(this, FileScanResultActivity::class.java).apply {
Intent
.
ACTION_VIEW
,
// putExtra("ScanType", ConstObject.SCAN_DOCUMENTS)
Uri
.
parse
(
ConfigHelper
.
privacyPolicy
)
// })
)
// }
startActivity
(
intent
)
//
}
// ID_WHATSAPP -> {
}
// startActivity(Intent(this, WhatsAppCleanerAnimationActivity::class.java))
// }
private
fun
progressCollect
()
{
//
lifecycleScope
.
launch
{
// ID_APP_PROCESS -> {
progressFlow
.
collectLatest
{
// startActivity(Intent(this, AppProcessAnimationActivity::class.java))
if
(
it
>=
100
)
{
// }
job
?.
cancel
()
//
jumpNext
()
// ID_APP_MANAGER -> {
this
.
cancel
()
// startActivity(Intent(this, AppManagerAnimationActivity::class.java))
}
// }
}
//
}
// ID_BATTERY_INFO -> {
}
// startActivity(Intent(this, BatteryInfoAnimationActivity::class.java))
// }
var
jumped
:
Boolean
=
false
//
private
fun
jumpNext
()
{
//
// else -> {
if
(
jumped
)
{
// val isHotLaunch = intent?.extras?.getBoolean("isHotLaunch", false) ?: false
return
// if (!isHotLaunch) {
}
// startActivity(Intent(this@SplashActivity, MainActivity::class.java))
jumped
=
true
// if (!isGuide) {
LogEx
.
logDebug
(
TAG
,
"jumpNext actionId=$actionId"
)
// startActivity(Intent(this@SplashActivity, GuideActivity::class.java))
// isGuide = true
when
(
actionId
)
{
// } else {
ID_JUNK_CLEAN_PUSH
->
{
// startActivity(Intent(this@SplashActivity, MainActivity::class.java))
startActivity
(
Intent
(
this
,
ScanJunkActivity
::
class
.
java
))
// }
}
// }
// }
ID_SIMILAR_IMAGE
->
{
// }
startActivity
(
Intent
(
this
,
PhotoManagerAnimationActivity
::
class
.
java
))
// finish()
}
// intent?.extras?.clear()
// }
ID_SCREENSHOT_CLEAN
->
{
//
startActivity
(
Intent
(
this
,
PhotoManagerAnimationActivity
::
class
.
java
))
// private fun closeNotification() {
}
// sendBroadcast(Intent(this, CloseNotificationReceiver::class.java).apply {
// this.action = CloseNotificationReceiver.Action
ID_RECOVERY_PHOTOS
->
{
// this.putExtra(NotificationId, actionId)
startActivity
(
Intent
(
this
,
FileScanResultActivity
::
class
.
java
).
apply
{
// })
putExtra
(
"ScanType"
,
ConstObject
.
SCAN_PHOTOS
)
// }
})
//
}
// override fun initListener() {
//
ID_RECOVERY_VIDEOS
->
{
// binding.idTvStart.setOnClickListener {
startActivity
(
Intent
(
this
,
FileScanResultActivity
::
class
.
java
).
apply
{
// if (oneClickStart) {
putExtra
(
"ScanType"
,
ConstObject
.
SCAN_VIDEOS
)
// return@setOnClickListener
})
// }
}
// oneClickStart = true
// ifAgreePrivacy = true
ID_RECOVERY_DOCUMENTS
->
{
// (application as MyApplication).initApp(true)
startActivity
(
Intent
(
this
,
FileScanResultActivity
::
class
.
java
).
apply
{
// AdmobMaxHelper.preloadAd(this)
putExtra
(
"ScanType"
,
ConstObject
.
SCAN_DOCUMENTS
)
// binding.llStart.visibility = View.GONE
})
// binding.llProgress.visibility = View.VISIBLE
}
// job = startProgress()
// }
ID_WHATSAPP
->
{
// }
startActivity
(
Intent
(
this
,
WhatsAppCleanerAnimationActivity
::
class
.
java
))
//
}
// private var processTime = 0L
// private var outTimeAdStart = false
ID_APP_PROCESS
->
{
// private fun startProgress() = lifecycleScope.launch {
startActivity
(
Intent
(
this
,
AppProcessAnimationActivity
::
class
.
java
))
// LogEx.logDebug(TAG, "startProgress")
}
// while (isActive) {
// val value = binding.pb.progress + 2
ID_APP_MANAGER
->
{
// binding.pb.setProgress(value, true)
startActivity
(
Intent
(
this
,
AppManagerAnimationActivity
::
class
.
java
))
// progress.emit(value)
}
//
// val delayTime = 300L
ID_BATTERY_INFO
->
{
// delay(delayTime)
startActivity
(
Intent
(
this
,
BatteryInfoAnimationActivity
::
class
.
java
))
// processTime += delayTime
}
// if (processTime >= Random.nextLong(2500, 3000)) {
// if (!outTimeAdStart) {
// outTimeAdStart = true
else
->
{
// outTimeAd()
val
isHotLaunch
=
intent
?.
extras
?.
getBoolean
(
"isHotLaunch"
,
false
)
?:
false
// }
if
(!
isHotLaunch
)
{
// }
startActivity
(
Intent
(
this
@SplashActivity
,
MainActivity
::
class
.
java
))
// }
if
(!
isGuide
)
{
// }
startActivity
(
Intent
(
this
@SplashActivity
,
GuideActivity
::
class
.
java
))
//
isGuide
=
true
//
}
else
{
// private fun outTimeAd() {
startActivity
(
Intent
(
this
@SplashActivity
,
MainActivity
::
class
.
java
))
// LogEx.logDebug(TAG, "outTimeAd")
}
//
}
// var loaded: Boolean = true
}
// AdmobMaxHelper.admobMaxShowOpenAd(this, showBeforeAction = { flag ->
}
// LogEx.logDebug(TAG, "showBeforeAction flag=$flag")
finish
()
// loaded = flag
intent
?.
extras
?.
clear
()
// job?.cancel()
}
// }, onHidden = {
// val sp = AppPreferences.getInstance().getString("splashShowInter", "0").toInt()
private
fun
closeNotification
()
{
// if (sp == 1 && !loaded) {
sendBroadcast
(
Intent
(
this
,
CloseNotificationReceiver
::
class
.
java
).
apply
{
// AdmobMaxHelper.admobMaxShowInterstitialAd(this, isLoading = false) {
this
.
action
=
CloseNotificationReceiver
.
Action
// binding.pb.progress = 100
this
.
putExtra
(
NotificationId
,
actionId
)
// jumpNext()
})
// }
}
// } else {
// binding.pb.progress = 100
override
fun
initListener
()
{
// jumpNext()
// }
binding
.
idTvStart
.
setOnClickListener
{
//
if
(
oneClickStart
)
{
// })
return
@setOnClickListener
// }
}
//
oneClickStart
=
true
// override fun onResume() {
ifAgreePrivacy
=
true
// super.onResume()
(
application
as
MyApplication
).
initApp
(
true
)
// LogEx.logDebug(TAG, "onResume")
AdmobMaxHelper
.
preloadAd
(
this
)
// if (ifAgreePrivacy && job?.isActive == false) {
binding
.
llStart
.
visibility
=
View
.
GONE
// job = startProgress()
binding
.
llProgress
.
visibility
=
View
.
VISIBLE
// }
job
=
startProgress
()
// }
}
//
}
// override fun onPause() {
// super.onPause()
private
var
processTime
=
0L
// job?.cancel()
private
var
outTimeAdStart
=
false
// LogEx.logDebug(TAG, "onPause")
private
fun
startProgress
()
=
lifecycleScope
.
launch
{
// }
LogEx
.
logDebug
(
TAG
,
"startProgress"
)
//
while
(
isActive
)
{
//
val
value
=
binding
.
pb
.
progress
+
2
//}
binding
.
pb
.
setProgress
(
value
,
true
)
\ No newline at end of file
progress
.
emit
(
value
)
val
delayTime
=
300L
delay
(
delayTime
)
processTime
+=
delayTime
if
(
processTime
>=
Random
.
nextLong
(
2500
,
3000
))
{
if
(!
outTimeAdStart
)
{
outTimeAdStart
=
true
outTimeAd
()
}
}
}
}
private
fun
outTimeAd
()
{
LogEx
.
logDebug
(
TAG
,
"outTimeAd"
)
var
loaded
:
Boolean
=
true
AdmobMaxHelper
.
admobMaxShowOpenAd
(
this
,
showBeforeAction
=
{
flag
->
LogEx
.
logDebug
(
TAG
,
"showBeforeAction flag=$flag"
)
loaded
=
flag
job
?.
cancel
()
},
onHidden
=
{
val
sp
=
AppPreferences
.
getInstance
().
getString
(
"splashShowInter"
,
"0"
).
toInt
()
if
(
sp
==
1
&&
!
loaded
)
{
AdmobMaxHelper
.
admobMaxShowInterstitialAd
(
this
,
isLoading
=
false
)
{
binding
.
pb
.
progress
=
100
jumpNext
()
}
}
else
{
binding
.
pb
.
progress
=
100
jumpNext
()
}
})
}
override
fun
onResume
()
{
super
.
onResume
()
LogEx
.
logDebug
(
TAG
,
"onResume"
)
if
(
ifAgreePrivacy
&&
job
?.
isActive
==
false
)
{
job
=
startProgress
()
}
}
override
fun
onPause
()
{
super
.
onPause
()
job
?.
cancel
()
LogEx
.
logDebug
(
TAG
,
"onPause"
)
}
}
\ No newline at end of file
app/src/main/java/com/base/filerecoveryrecyclebin/activity/battery/BatteryActivity.kt
View file @
2c0cd27f
...
@@ -14,7 +14,6 @@ import com.base.filerecoveryrecyclebin.databinding.ActivityBatteryBinding
...
@@ -14,7 +14,6 @@ import com.base.filerecoveryrecyclebin.databinding.ActivityBatteryBinding
import
com.base.filerecoveryrecyclebin.help.BaseActivity
import
com.base.filerecoveryrecyclebin.help.BaseActivity
import
com.base.filerecoveryrecyclebin.receiver.BatteryReceiver
import
com.base.filerecoveryrecyclebin.receiver.BatteryReceiver
import
com.base.filerecoveryrecyclebin.utils.BarUtils
import
com.base.filerecoveryrecyclebin.utils.BarUtils
import
com.base.filerecoveryrecyclebin.utils.LogEx
import
com.base.filerecoveryrecyclebin.view.DialogViews.showExitFunctionDialog
import
com.base.filerecoveryrecyclebin.view.DialogViews.showExitFunctionDialog
import
kotlin.math.abs
import
kotlin.math.abs
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/activity/battery/BatteryInfoAnimationActivity.kt
View file @
2c0cd27f
...
@@ -63,7 +63,7 @@ class BatteryInfoAnimationActivity : BaseActivity<ActivityBatteryInfoAnimationBi
...
@@ -63,7 +63,7 @@ class BatteryInfoAnimationActivity : BaseActivity<ActivityBatteryInfoAnimationBi
binding
.
lottieCompleted
.
playAnimation
()
binding
.
lottieCompleted
.
playAnimation
()
binding
.
tv
.
text
=
"Completed!"
binding
.
tv
.
text
=
"Completed!"
delay
(
1000
)
delay
(
1000
)
AdmobMaxHelper
.
admobMaxShow
OpenAd
(
this
@BatteryInfoAnimationActivity
,
showBeforeAction
=
{}
)
{
AdmobMaxHelper
.
admobMaxShow
InterstitialAd
(
this
@BatteryInfoAnimationActivity
)
{
binding
.
lottie
.
clearAnimation
()
binding
.
lottie
.
clearAnimation
()
startActivity
(
Intent
(
this
@BatteryInfoAnimationActivity
,
BatteryActivity
::
class
.
java
))
startActivity
(
Intent
(
this
@BatteryInfoAnimationActivity
,
BatteryActivity
::
class
.
java
))
finish
()
finish
()
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/activity/recyclebin/RecycleBinDetailActivity.kt
View file @
2c0cd27f
...
@@ -4,19 +4,14 @@ import android.annotation.SuppressLint
...
@@ -4,19 +4,14 @@ import android.annotation.SuppressLint
import
android.content.Intent
import
android.content.Intent
import
android.graphics.Color
import
android.graphics.Color
import
android.os.Build
import
android.os.Build
import
android.util.Log
import
android.view.View
import
android.view.View
import
androidx.activity.addCallback
import
androidx.activity.addCallback
import
androidx.annotation.RequiresApi
import
androidx.annotation.RequiresApi
import
androidx.core.view.isVisible
import
androidx.core.view.isVisible
import
androidx.core.view.updatePadding
import
androidx.core.view.updatePadding
import
com.base.filerecoveryrecyclebin.R
import
com.base.filerecoveryrecyclebin.R
import
com.base.filerecoveryrecyclebin.activity.ResultActivity
import
com.base.filerecoveryrecyclebin.activity.recovery.FileRecoveredActivity
import
com.base.filerecoveryrecyclebin.activity.recovery.FileRecoveredActivity
import
com.base.filerecoveryrecyclebin.activity.recyclebin.RecycleBinFileEx.findRecycleBinFile
import
com.base.filerecoveryrecyclebin.activity.recyclebin.RecycleBinFileEx.findRecycleBinJsonFile
import
com.base.filerecoveryrecyclebin.bean.ConstObject
import
com.base.filerecoveryrecyclebin.bean.ConstObject
import
com.base.filerecoveryrecyclebin.bean.ConstObject.RECYCLE_BIN
import
com.base.filerecoveryrecyclebin.bean.RecycleBinBean
import
com.base.filerecoveryrecyclebin.bean.RecycleBinBean
import
com.base.filerecoveryrecyclebin.bean.RecycleBinBean.Companion.mAudioStr
import
com.base.filerecoveryrecyclebin.bean.RecycleBinBean.Companion.mAudioStr
import
com.base.filerecoveryrecyclebin.bean.RecycleBinBean.Companion.mDocumentStr
import
com.base.filerecoveryrecyclebin.bean.RecycleBinBean.Companion.mDocumentStr
...
@@ -27,6 +22,7 @@ import com.base.filerecoveryrecyclebin.help.BaseActivity
...
@@ -27,6 +22,7 @@ import com.base.filerecoveryrecyclebin.help.BaseActivity
import
com.base.filerecoveryrecyclebin.help.KotlinExt.toFormatSize
import
com.base.filerecoveryrecyclebin.help.KotlinExt.toFormatSize
import
com.base.filerecoveryrecyclebin.help.KotlinExt.toFormatTime
import
com.base.filerecoveryrecyclebin.help.KotlinExt.toFormatTime
import
com.base.filerecoveryrecyclebin.help.VideoPlayerUtil
import
com.base.filerecoveryrecyclebin.help.VideoPlayerUtil
import
com.base.filerecoveryrecyclebin.service.BackUpUtils
import
com.base.filerecoveryrecyclebin.service.BackUpUtils.recoveryFile
import
com.base.filerecoveryrecyclebin.service.BackUpUtils.recoveryFile
import
com.base.filerecoveryrecyclebin.utils.BarUtils
import
com.base.filerecoveryrecyclebin.utils.BarUtils
import
com.base.filerecoveryrecyclebin.utils.LogEx
import
com.base.filerecoveryrecyclebin.utils.LogEx
...
@@ -85,7 +81,7 @@ class RecycleBinDetailActivity : BaseActivity<ActivityRecycleBinDetailBinding>()
...
@@ -85,7 +81,7 @@ class RecycleBinDetailActivity : BaseActivity<ActivityRecycleBinDetailBinding>()
}
}
Glide
.
with
(
this
).
load
(
bean
.
backupPath
).
centerCrop
().
into
(
binding
.
iv
)
Glide
.
with
(
this
).
load
(
bean
.
backupPath
).
centerCrop
().
into
(
binding
.
iv
)
binding
.
tv
Name
.
text
=
bean
.
path
binding
.
tv
Path
.
text
=
bean
.
path
binding
.
tvSize
.
text
=
bean
.
size
.
toFormatSize
()
binding
.
tvSize
.
text
=
bean
.
size
.
toFormatSize
()
binding
.
tvTime
.
text
=
"Delete time:${bean.deleteTime.toFormatTime()}"
binding
.
tvTime
.
text
=
"Delete time:${bean.deleteTime.toFormatTime()}"
}
}
...
@@ -106,7 +102,7 @@ class RecycleBinDetailActivity : BaseActivity<ActivityRecycleBinDetailBinding>()
...
@@ -106,7 +102,7 @@ class RecycleBinDetailActivity : BaseActivity<ActivityRecycleBinDetailBinding>()
runCatching
{
runCatching
{
binFile
.
copyTo
(
file
,
true
)
binFile
.
copyTo
(
file
,
true
)
binFile
.
delete
()
binFile
.
delete
()
recoveryFile
(
bean
.
name
)
recoveryFile
(
bean
.
name
Path
)
}
}
}
}
startActivity
(
Intent
(
this
,
FileRecoveredActivity
::
class
.
java
).
apply
{
startActivity
(
Intent
(
this
,
FileRecoveredActivity
::
class
.
java
).
apply
{
...
@@ -132,20 +128,17 @@ class RecycleBinDetailActivity : BaseActivity<ActivityRecycleBinDetailBinding>()
...
@@ -132,20 +128,17 @@ class RecycleBinDetailActivity : BaseActivity<ActivityRecycleBinDetailBinding>()
binding
.
ivBofang
.
setOnClickListener
{
binding
.
ivBofang
.
setOnClickListener
{
recycleBinBean
?.
let
{
bean
->
recycleBinBean
?.
let
{
bean
->
val
file
=
File
(
bean
.
path
)
VideoPlayerUtil
.
playVideo
(
this
,
bean
.
backupPath
)
val
binFile
=
findRecycleBinFile
(
file
.
name
)
VideoPlayerUtil
.
playVideo
(
this
,
binFile
?.
absolutePath
)
}
}
}
}
binding
.
flDelete
.
setOnClickListener
{
binding
.
flDelete
.
setOnClickListener
{
recycleBinBean
?.
let
{
bean
->
recycleBinBean
?.
let
{
bean
->
val
file
=
File
(
bean
.
path
)
BackUpUtils
.
deleteFileSp
(
bean
.
namePath
)
val
binFile
=
findRecycleBinFile
(
file
.
name
)
val
file
=
File
(
bean
.
backupPath
)
val
binJsonFile
=
findRecycleBinJsonFile
(
file
.
name
)
if
(
file
.
exists
())
{
file
.
delete
()
binFile
?.
delete
()
}
binJsonFile
?.
delete
()
}
}
finish
()
finish
()
}
}
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/activity/repeat/RepeatActivity.kt
View file @
2c0cd27f
...
@@ -27,6 +27,7 @@ import com.base.filerecoveryrecyclebin.view.DialogViews.showGerPermission
...
@@ -27,6 +27,7 @@ import com.base.filerecoveryrecyclebin.view.DialogViews.showGerPermission
import
com.base.filerecoveryrecyclebin.view.DialogViews.showTittleDescExitDialog
import
com.base.filerecoveryrecyclebin.view.DialogViews.showTittleDescExitDialog
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.withTimeout
import
java.io.File
import
java.io.File
class
RepeatActivity
:
BaseActivity
<
ActivityRepeatBinding
>()
{
class
RepeatActivity
:
BaseActivity
<
ActivityRepeatBinding
>()
{
...
@@ -74,9 +75,6 @@ class RepeatActivity : BaseActivity<ActivityRepeatBinding>() {
...
@@ -74,9 +75,6 @@ class RepeatActivity : BaseActivity<ActivityRepeatBinding>() {
})
})
}
}
// val s = opencvCompareSimilar("/storage/emulated/0/DCIM/1.jpg","/storage/emulated/0/DCIM/22.jpg")
// LogEx.logDebug(TAG,"s=$s")
// Toast.makeText(this, s.toString(), Toast.LENGTH_SHORT).show()
}
}
override
fun
initListener
()
{
override
fun
initListener
()
{
...
@@ -121,6 +119,7 @@ class RepeatActivity : BaseActivity<ActivityRepeatBinding>() {
...
@@ -121,6 +119,7 @@ class RepeatActivity : BaseActivity<ActivityRepeatBinding>() {
private
fun
cleanFile
()
{
private
fun
cleanFile
()
{
similarPhotoDeleted
=
true
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
val
cleanList
=
mediaAdapter
.
getSelectData
().
second
val
cleanList
=
mediaAdapter
.
getSelectData
().
second
cleanList
.
forEach
{
cleanList
.
forEach
{
...
@@ -147,20 +146,24 @@ class RepeatActivity : BaseActivity<ActivityRepeatBinding>() {
...
@@ -147,20 +146,24 @@ class RepeatActivity : BaseActivity<ActivityRepeatBinding>() {
val
list
=
arrayListOf
<
MediaBean
>()
val
list
=
arrayListOf
<
MediaBean
>()
getImageMedia
(
list
)
getImageMedia
(
list
)
LogEx
.
logDebug
(
TAG
,
"list=${list.size}"
)
LogEx
.
logDebug
(
TAG
,
"list=${list.size}"
)
val
similarList
=
calculateSimilar
(
list
)
list
.
reversed
()
// similarList.forEach { t, u ->
// LogEx.logDebug(TAG, "t=$t u=$u")
// }
val
result
=
if
(
readySimilarList
==
null
)
{
val
similarList
=
HashMap
<
String
,
ArrayList
<
MediaBean
>>()
// val hashMap = HashMap<String, ArrayList<MediaBean>>()
val
startTime
=
System
.
currentTimeMillis
()
// list.forEach {
val
endTime
=
withTimeout
(
15
*
1000
)
{
// val time = it.time.toFormatTime()
calculateSimilar
(
list
,
similarList
)
// if (hashMap[time] == null) {
System
.
currentTimeMillis
()
// hashMap[time] = arrayListOf()
}
// }
val
spendTime
=
endTime
-
startTime
// hashMap[time]?.add(it)
LogEx
.
logDebug
(
TAG
,
"spendTime=$spendTime startTime=$startTime endTime=$endTime"
)
// }
similarList
val
beanList
=
similarList
.
map
{
map
->
}
else
{
readySimilarList
?:
hashMapOf
()
}
val
beanList
=
result
.
map
{
map
->
val
time
=
File
(
map
.
key
).
lastModified
().
toFormatTime
()
val
time
=
File
(
map
.
key
).
lastModified
().
toFormatTime
()
MediaTimeBean
(
time
=
time
,
beans
=
map
.
value
)
MediaTimeBean
(
time
=
time
,
beans
=
map
.
value
)
}
}
...
@@ -175,7 +178,11 @@ class RepeatActivity : BaseActivity<ActivityRepeatBinding>() {
...
@@ -175,7 +178,11 @@ class RepeatActivity : BaseActivity<ActivityRepeatBinding>() {
binding
.
llEmpty
.
isVisible
=
beanList
.
isEmpty
()
binding
.
llEmpty
.
isVisible
=
beanList
.
isEmpty
()
}
}
}
}
}
companion
object
{
var
readySimilarList
:
HashMap
<
String
,
ArrayList
<
MediaBean
>>?
=
null
var
similarPhotoDeleted
:
Boolean
=
false
}
}
}
}
\ No newline at end of file
app/src/main/java/com/base/filerecoveryrecyclebin/activity/screenshot/ScreenShotActivity.kt
View file @
2c0cd27f
...
@@ -22,9 +22,12 @@ import com.base.filerecoveryrecyclebin.utils.BarUtils
...
@@ -22,9 +22,12 @@ import com.base.filerecoveryrecyclebin.utils.BarUtils
import
com.base.filerecoveryrecyclebin.view.DialogViews.showDeletePermanentlyDialog
import
com.base.filerecoveryrecyclebin.view.DialogViews.showDeletePermanentlyDialog
import
com.base.filerecoveryrecyclebin.view.DialogViews.showExitFunctionDialog
import
com.base.filerecoveryrecyclebin.view.DialogViews.showExitFunctionDialog
import
com.base.filerecoveryrecyclebin.view.DialogViews.showGerPermission
import
com.base.filerecoveryrecyclebin.view.DialogViews.showGerPermission
import
kotlinx.coroutines.CoroutineScope
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.async
import
kotlinx.coroutines.async
import
kotlinx.coroutines.isActive
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.withTimeout
import
java.io.File
import
java.io.File
import
java.text.SimpleDateFormat
import
java.text.SimpleDateFormat
import
java.util.Locale
import
java.util.Locale
...
@@ -32,6 +35,7 @@ import kotlin.collections.HashSet
...
@@ -32,6 +35,7 @@ import kotlin.collections.HashSet
class
ScreenShotActivity
:
BaseActivity
<
ActivityScreenShotBinding
>()
{
class
ScreenShotActivity
:
BaseActivity
<
ActivityScreenShotBinding
>()
{
private
val
TAG
=
"ScreenShotActivity"
private
lateinit
var
screenShotAdapter
:
ScreenShotAdapter
private
lateinit
var
screenShotAdapter
:
ScreenShotAdapter
override
val
binding
:
ActivityScreenShotBinding
by
lazy
{
override
val
binding
:
ActivityScreenShotBinding
by
lazy
{
...
@@ -66,7 +70,6 @@ class ScreenShotActivity : BaseActivity<ActivityScreenShotBinding>() {
...
@@ -66,7 +70,6 @@ class ScreenShotActivity : BaseActivity<ActivityScreenShotBinding>() {
@SuppressLint
(
"SetTextI18n"
)
@SuppressLint
(
"SetTextI18n"
)
private
fun
setCleanUpUi
(
size
:
Int
)
{
private
fun
setCleanUpUi
(
size
:
Int
)
{
if
(
size
>
0
)
{
if
(
size
>
0
)
{
binding
.
tvClean
.
isEnabled
=
true
binding
.
tvClean
.
isEnabled
=
true
...
@@ -79,7 +82,9 @@ class ScreenShotActivity : BaseActivity<ActivityScreenShotBinding>() {
...
@@ -79,7 +82,9 @@ class ScreenShotActivity : BaseActivity<ActivityScreenShotBinding>() {
}
}
private
fun
initData
()
=
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
private
fun
initData
()
=
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
val
list
=
getScreenshotBean
()
val
list
=
getScreenshotBean
()
launch
(
Dispatchers
.
Main
)
{
launch
(
Dispatchers
.
Main
)
{
screenShotAdapter
.
setData
(
list
)
screenShotAdapter
.
setData
(
list
)
val
size
=
list
.
sumOf
{
it
.
screenPhotoBean
.
sumOf
{
ss
->
ss
.
file
.
length
()
}
}
val
size
=
list
.
sumOf
{
it
.
screenPhotoBean
.
sumOf
{
ss
->
ss
.
file
.
length
()
}
}
...
@@ -135,6 +140,7 @@ class ScreenShotActivity : BaseActivity<ActivityScreenShotBinding>() {
...
@@ -135,6 +140,7 @@ class ScreenShotActivity : BaseActivity<ActivityScreenShotBinding>() {
@SuppressLint
(
"SetTextI18n"
)
@SuppressLint
(
"SetTextI18n"
)
private
fun
cleanFile
()
{
private
fun
cleanFile
()
{
screenPhotoDeleted
=
true
val
files
=
screenShotAdapter
.
getSelectData
()
val
files
=
screenShotAdapter
.
getSelectData
()
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
async
{
async
{
...
@@ -156,28 +162,42 @@ class ScreenShotActivity : BaseActivity<ActivityScreenShotBinding>() {
...
@@ -156,28 +162,42 @@ class ScreenShotActivity : BaseActivity<ActivityScreenShotBinding>() {
}
}
}
}
private
fun
getScreenshotBean
():
ArrayList
<
ScreenshotBean
>
{
private
fun
CoroutineScope
.
getScreenshotBean
(
myBeans
:
ArrayList
<
ScreenshotBean
>?
=
null
):
ArrayList
<
ScreenshotBean
>
{
val
beans
=
myBeans
?:
arrayListOf
<
ScreenshotBean
>()
val
dcim
=
Environment
.
getExternalStoragePublicDirectory
(
Environment
.
DIRECTORY_DCIM
)
val
dcim
=
Environment
.
getExternalStoragePublicDirectory
(
Environment
.
DIRECTORY_DCIM
)
val
screenFiles
=
FileHelp
.
getDirFiles
(
dcim
)
val
screenFiles
=
FileHelp
.
getDirFiles
(
dcim
)
val
hash
=
HashMap
<
String
,
HashSet
<
File
>>()
val
hash
=
HashMap
<
String
,
HashSet
<
File
>>()
val
formatter
=
SimpleDateFormat
(
"yyyy/MM"
,
Locale
.
getDefault
())
val
formatter
=
SimpleDateFormat
(
"yyyy/MM"
,
Locale
.
getDefault
())
runCatching
{
screenFiles
.
forEach
{
file
->
screenFiles
.
forEach
{
file
->
val
time
=
formatter
.
format
(
file
.
lastModified
())
val
time
=
formatter
.
format
(
file
.
lastModified
())
if
(
hash
[
time
]
==
null
)
{
if
(
hash
[
time
]
==
null
)
{
hash
[
time
]
=
HashSet
()
hash
[
time
]
=
HashSet
()
}
}
val
set
=
hash
[
time
]
val
set
=
hash
[
time
]
set
?.
add
(
file
)
set
?.
add
(
file
)
if
(!
isActive
)
throw
Exception
(
"out Time"
)
}
}
}
val
beans
=
arrayListOf
<
ScreenshotBean
>()
runCatching
{
hash
.
forEach
{
(
t
,
u
)
->
hash
.
forEach
{
(
t
,
u
)
->
val
arrayList
=
arrayListOf
<
ScreenPhotoBean
>()
val
arrayList
=
arrayListOf
<
ScreenPhotoBean
>()
val
mapList
=
u
.
map
{
file
->
ScreenPhotoBean
(
file
)
}
val
mapList
=
u
.
map
{
file
->
ScreenPhotoBean
(
file
)
}
arrayList
.
addAll
(
mapList
)
arrayList
.
addAll
(
mapList
)
beans
.
add
(
ScreenshotBean
(
t
,
arrayList
))
beans
.
add
(
ScreenshotBean
(
t
,
arrayList
))
if
(!
isActive
)
throw
Exception
(
"out Time"
)
}
}
}
return
beans
return
beans
}
}
companion
object
{
var
screenPhotoDeleted
:
Boolean
=
false
}
}
}
\ No newline at end of file
app/src/main/java/com/base/filerecoveryrecyclebin/activity/splash/Splash2Activity.kt
View file @
2c0cd27f
...
@@ -64,7 +64,6 @@ class Splash2Activity : BaseActivity<ActivitySplashBinding>(),
...
@@ -64,7 +64,6 @@ class Splash2Activity : BaseActivity<ActivitySplashBinding>(),
mTaskManager
=
TaskManager
(
binding
,
this
)
mTaskManager
=
TaskManager
(
binding
,
this
)
if
(
ifAgreePrivacy
)
{
if
(
ifAgreePrivacy
)
{
onAgreePrivacy
()
onAgreePrivacy
()
// EventUtils.event("app_start")
}
else
{
}
else
{
PrivacyManager
(
binding
,
this
,
this
)
PrivacyManager
(
binding
,
this
,
this
)
}
}
...
@@ -81,18 +80,11 @@ class Splash2Activity : BaseActivity<ActivitySplashBinding>(),
...
@@ -81,18 +80,11 @@ class Splash2Activity : BaseActivity<ActivitySplashBinding>(),
override
fun
onAgreePrivacy
()
{
override
fun
onAgreePrivacy
()
{
EventUtils
.
event
(
"app_start"
)
EventUtils
.
event
(
"app_start"
)
if
(
jumpType
==
0
)
{
if
(
jumpType
==
0
)
{
startStayNotification
()
//
startStayNotification()
}
}
AdmobMaxHelper
.
preloadAd
(
this
)
mTaskManager
?.
startProgress
()
mTaskManager
?.
startProgress
()
loadAd
()
loadAd
()
// if (!ConfigHelper.ifGuest) {
// mTaskManager?.pauseProgress()
// onProgressMax()
// return
// } else {
// loadAd()
// }
}
}
...
@@ -103,9 +95,6 @@ class Splash2Activity : BaseActivity<ActivitySplashBinding>(),
...
@@ -103,9 +95,6 @@ class Splash2Activity : BaseActivity<ActivitySplashBinding>(),
}
}
private
fun
loadAd
()
{
private
fun
loadAd
()
{
// AdmobMaxHelper.admobMaxShowOpenAd(this){
//
// }
AdmobMaxHelper
.
admobMaxShowOpenAd
(
this
,
{
AdmobMaxHelper
.
admobMaxShowOpenAd
(
this
,
{
mTaskManager
?.
pauseProgress
()
mTaskManager
?.
pauseProgress
()
},
{
},
{
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/activity/splash/StartUtils.kt
View file @
2c0cd27f
...
@@ -89,6 +89,7 @@ object StartUtils {
...
@@ -89,6 +89,7 @@ object StartUtils {
if
(!
isHotLaunch
)
{
if
(!
isHotLaunch
)
{
if
(!
isGuide
)
{
if
(!
isGuide
)
{
context
.
startActivity
(
Intent
(
context
,
GuideActivity
::
class
.
java
))
context
.
startActivity
(
Intent
(
context
,
GuideActivity
::
class
.
java
))
isGuide
=
true
}
else
{
}
else
{
context
.
startActivity
(
Intent
(
context
,
MainActivity
::
class
.
java
))
context
.
startActivity
(
Intent
(
context
,
MainActivity
::
class
.
java
))
}
}
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/adapter/AppFunctionAdapter.kt
View file @
2c0cd27f
...
@@ -32,7 +32,6 @@ class AppFunctionAdapter(val click: (name: String) -> Unit) :
...
@@ -32,7 +32,6 @@ class AppFunctionAdapter(val click: (name: String) -> Unit) :
Fun
(
RECOVERY_PHOTOS
,
R
.
mipmap
.
photos_ss
),
Fun
(
RECOVERY_PHOTOS
,
R
.
mipmap
.
photos_ss
),
Fun
(
RECOVERY_VIDEOS
,
R
.
mipmap
.
videos_ss
),
Fun
(
RECOVERY_VIDEOS
,
R
.
mipmap
.
videos_ss
),
Fun
(
RECOVERY_DOCUMENTS
,
R
.
mipmap
.
documents_ss
),
Fun
(
RECOVERY_DOCUMENTS
,
R
.
mipmap
.
documents_ss
),
Fun
(
PRIVACY_SPACE
,
R
.
mipmap
.
space
),
Fun
(
REPEAT_PHOTOS
,
R
.
mipmap
.
repeatedphotos
),
Fun
(
REPEAT_PHOTOS
,
R
.
mipmap
.
repeatedphotos
),
Fun
(
SCREENSHOT_CLEANER
,
R
.
mipmap
.
screenshots
),
Fun
(
SCREENSHOT_CLEANER
,
R
.
mipmap
.
screenshots
),
Fun
(
WHATSAPP_CLEANER
,
R
.
mipmap
.
h_whatsapp
),
Fun
(
WHATSAPP_CLEANER
,
R
.
mipmap
.
h_whatsapp
),
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/adapter/RecycleBinAdapter.kt
View file @
2c0cd27f
...
@@ -2,15 +2,11 @@ package com.base.filerecoveryrecyclebin.adapter
...
@@ -2,15 +2,11 @@ package com.base.filerecoveryrecyclebin.adapter
import
android.annotation.SuppressLint
import
android.annotation.SuppressLint
import
android.graphics.drawable.Drawable
import
android.graphics.drawable.Drawable
import
android.os.Build
import
android.view.View
import
android.view.View
import
android.view.ViewGroup
import
android.view.ViewGroup
import
androidx.annotation.RequiresApi
import
androidx.core.content.ContextCompat
import
androidx.recyclerview.widget.RecyclerView
import
androidx.recyclerview.widget.RecyclerView
import
androidx.recyclerview.widget.RecyclerView.ViewHolder
import
androidx.recyclerview.widget.RecyclerView.ViewHolder
import
com.base.filerecoveryrecyclebin.R
import
com.base.filerecoveryrecyclebin.R
import
com.base.filerecoveryrecyclebin.activity.recyclebin.RecycleBinFileEx.findRecycleBinFile
import
com.base.filerecoveryrecyclebin.bean.RecycleBinBean
import
com.base.filerecoveryrecyclebin.bean.RecycleBinBean
import
com.base.filerecoveryrecyclebin.bean.RecycleBinBean.Companion.mAudioStr
import
com.base.filerecoveryrecyclebin.bean.RecycleBinBean.Companion.mAudioStr
import
com.base.filerecoveryrecyclebin.bean.RecycleBinBean.Companion.mDocumentStr
import
com.base.filerecoveryrecyclebin.bean.RecycleBinBean.Companion.mDocumentStr
...
@@ -26,7 +22,6 @@ import com.bumptech.glide.load.DataSource
...
@@ -26,7 +22,6 @@ import com.bumptech.glide.load.DataSource
import
com.bumptech.glide.load.engine.GlideException
import
com.bumptech.glide.load.engine.GlideException
import
com.bumptech.glide.request.RequestListener
import
com.bumptech.glide.request.RequestListener
import
com.bumptech.glide.request.target.Target
import
com.bumptech.glide.request.target.Target
import
java.io.File
class
RecycleBinAdapter
(
val
click
:
(
bean
:
RecycleBinBean
)
->
Unit
)
:
RecyclerView
.
Adapter
<
RecycleBinAdapter
.
RBAV
>()
{
class
RecycleBinAdapter
(
val
click
:
(
bean
:
RecycleBinBean
)
->
Unit
)
:
RecyclerView
.
Adapter
<
RecycleBinAdapter
.
RBAV
>()
{
...
@@ -86,7 +81,7 @@ class RecycleBinAdapter(val click: (bean: RecycleBinBean) -> Unit) : RecyclerVie
...
@@ -86,7 +81,7 @@ class RecycleBinAdapter(val click: (bean: RecycleBinBean) -> Unit) : RecyclerVie
binding
.
iv
.
setImageResource
(
R
.
mipmap
.
h_documents
)
binding
.
iv
.
setImageResource
(
R
.
mipmap
.
h_documents
)
}
}
binding
.
tvName
.
text
=
bean
.
name
binding
.
tvName
.
text
=
bean
.
name
Path
binding
.
tvTime
.
text
=
"delete time:"
+
bean
.
deleteTime
.
toFormatTime
()
binding
.
tvTime
.
text
=
"delete time:"
+
bean
.
deleteTime
.
toFormatTime
()
binding
.
tvSize
.
text
=
bean
.
size
.
toFormatSize
()
binding
.
tvSize
.
text
=
bean
.
size
.
toFormatSize
()
binding
.
root
.
setOnClickListener
{
binding
.
root
.
setOnClickListener
{
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/ads/AdCommonUtils.kt
0 → 100644
View file @
2c0cd27f
package
com.base.filerecoveryrecyclebin.ads
//object AdmobCommonUtils {
//
// private var lastAd: Any? = null
// private var maxMultiClick = AppPreferences.getInstance().getString("maxMultiClick", "10").toInt()
// private var multiClick = 0
// fun isMultiClick(currentAd: Any?) {
// if (currentAd == null) {
// return
// }
// if (lastAd == currentAd) {
// multiClick++
// if (multiClick >= maxMultiClick) {
// AdDisplayUtils.getInstance()
// .setAdClickCount(AdDisplayUtils.getInstance().maxAdClickCount)
// ActivityManagerUtils.getInstance().finishAllActivity()
// return
// }
// } else {
// multiClick = 0
// }
//
// lastAd = currentAd
//
// }
//}
\ No newline at end of file
app/src/main/java/com/base/filerecoveryrecyclebin/ads/AdDisplayUtils.java
View file @
2c0cd27f
...
@@ -112,6 +112,18 @@ public class AdDisplayUtils {
...
@@ -112,6 +112,18 @@ public class AdDisplayUtils {
obj2
.
put
(
"shouldDisplayAd"
,
shouldDisplayAd
);
obj2
.
put
(
"shouldDisplayAd"
,
shouldDisplayAd
);
obj2
.
put
(
"shouldIncrementClickCount"
,
shouldIncrementClickCount
);
obj2
.
put
(
"shouldIncrementClickCount"
,
shouldIncrementClickCount
);
obj2
.
put
(
"adDisplayCount"
,
adDisplayCount
);
obj2
.
put
(
"maxAdDisplayCount"
,
maxAdDisplayCount
);
obj2
.
put
(
"adClickCount"
,
adClickCount
);
obj2
.
put
(
"maxAdClickCount"
,
maxAdClickCount
);
obj2
.
put
(
"adRequestFailCount"
,
adRequestFailCount
);
obj2
.
put
(
"adRequestCount"
,
maxAdRequestFailCount
);
obj2
.
put
(
"adRequestCount"
,
adRequestCount
);
obj2
.
put
(
"maxAdRequestCount"
,
maxAdRequestCount
);
obj2
.
put
(
"ad_unit"
,
ad_unit
);
obj2
.
put
(
"ad_unit"
,
ad_unit
);
EventUtils
.
INSTANCE
.
event
(
"ad_show_error"
,
null
,
obj2
,
false
);
EventUtils
.
INSTANCE
.
event
(
"ad_show_error"
,
null
,
obj2
,
false
);
}
catch
(
JSONException
ignored
)
{
}
catch
(
JSONException
ignored
)
{
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/ads/AdmobMaxHelper.kt
View file @
2c0cd27f
...
@@ -3,15 +3,9 @@ package com.base.filerecoveryrecyclebin.ads
...
@@ -3,15 +3,9 @@ package com.base.filerecoveryrecyclebin.ads
import
android.app.Activity
import
android.app.Activity
import
android.util.Log
import
android.util.Log
import
android.view.ViewGroup
import
android.view.ViewGroup
import
com.base.filerecoveryrecyclebin.R
import
com.base.filerecoveryrecyclebin.ads.admob.AdmobInterstitialUtils
import
com.base.filerecoveryrecyclebin.ads.admob.AdmobInterstitialUtils
import
com.base.filerecoveryrecyclebin.ads.admob.AdmobNativeUtils
import
com.base.filerecoveryrecyclebin.ads.admob.AdmobNativeUtils
import
com.base.filerecoveryrecyclebin.ads.admob.AdmobOpenUtils
import
com.base.filerecoveryrecyclebin.ads.admob.AdmobOpenUtils
import
com.base.filerecoveryrecyclebin.ads.max.AdMaxInit
import
com.base.filerecoveryrecyclebin.ads.max.AdMaxInit.initAdMax
import
com.base.filerecoveryrecyclebin.ads.max.AdMaxInterstitialUtils
import
com.base.filerecoveryrecyclebin.ads.max.AdMaxNativeUtils
import
com.base.filerecoveryrecyclebin.ads.max.AdMaxOpenUtils
import
com.base.filerecoveryrecyclebin.help.BaseApplication
import
com.base.filerecoveryrecyclebin.help.BaseApplication
import
com.base.filerecoveryrecyclebin.utils.AppPreferences
import
com.base.filerecoveryrecyclebin.utils.AppPreferences
import
com.base.filerecoveryrecyclebin.utils.EventUtils
import
com.base.filerecoveryrecyclebin.utils.EventUtils
...
@@ -51,7 +45,7 @@ object AdmobMaxHelper {
...
@@ -51,7 +45,7 @@ object AdmobMaxHelper {
if
(
isBlack
)
{
if
(
isBlack
)
{
return
return
}
}
if
(
getSpAdmobTrueMaxFalse
()
)
{
if
(
true
)
{
if
(!
isAdInit
.
get
())
{
if
(!
isAdInit
.
get
())
{
LogEx
.
logDebug
(
TAG
,
"init sp Admob"
)
LogEx
.
logDebug
(
TAG
,
"init sp Admob"
)
MobileAds
.
initialize
(
BaseApplication
.
context
)
{
initializationStatus
->
MobileAds
.
initialize
(
BaseApplication
.
context
)
{
initializationStatus
->
...
@@ -59,20 +53,21 @@ object AdmobMaxHelper {
...
@@ -59,20 +53,21 @@ object AdmobMaxHelper {
}
}
}
}
}
else
{
}
else
{
if
(!
isAdInit
.
get
())
{
//
if (!isAdInit.get()) {
LogEx
.
logDebug
(
TAG
,
"init sp AdMax"
)
//
LogEx.logDebug(TAG, "init sp AdMax")
BaseApplication
.
context
.
initAdMax
()
//
BaseApplication.context.initAdMax()
}
//
}
}
}
}
}
//End end
//End end
fun
isOpenAdLoaded
():
Boolean
{
fun
isOpenAdLoaded
():
Boolean
{
return
if
(
getSpAdmobTrueMaxFalse
())
{
// if (getSpAdmobTrueMaxFalse()) {
AdmobOpenUtils
.
isOpenAdLoaded
()
//
}
else
{
// } else {
AdMaxOpenUtils
.
isOpenAdLoaded
()
// AdMaxOpenUtils.isOpenAdLoaded()
}
// }
return
AdmobOpenUtils
.
isOpenAdLoaded
()
}
}
//展示广告关闭时赋值
//展示广告关闭时赋值
...
@@ -96,14 +91,14 @@ object AdmobMaxHelper {
...
@@ -96,14 +91,14 @@ object AdmobMaxHelper {
return
return
}
}
if
(
getSpAdmobTrueMaxFalse
()
)
{
if
(
true
)
{
AdmobInterstitialUtils
.
showInterstitialAd
(
activity
)
{
AdmobInterstitialUtils
.
showInterstitialAd
(
activity
)
{
onHidden
?.
invoke
()
onHidden
?.
invoke
()
}
}
}
else
{
}
else
{
AdMaxInterstitialUtils
.
showInterstitialAd
(
activity
)
{
//
AdMaxInterstitialUtils.showInterstitialAd(activity) {
onHidden
?.
invoke
()
//
onHidden?.invoke()
}
//
}
}
}
}
}
...
@@ -116,14 +111,14 @@ object AdmobMaxHelper {
...
@@ -116,14 +111,14 @@ object AdmobMaxHelper {
onHidden
?.
invoke
()
onHidden
?.
invoke
()
return
return
}
}
if
(
getSpAdmobTrueMaxFalse
()
)
{
if
(
true
)
{
AdmobOpenUtils
.
showAppOpenAd
(
activity
,
showBefore
=
showBeforeAction
)
{
AdmobOpenUtils
.
showAppOpenAd
(
activity
,
showBefore
=
showBeforeAction
)
{
onHidden
?.
invoke
()
onHidden
?.
invoke
()
}
}
}
else
{
}
else
{
AdMaxOpenUtils
.
showAppOpenAd
(
activity
,
loadCallBack
=
showBeforeAction
)
{
//
AdMaxOpenUtils.showAppOpenAd(activity, loadCallBack = showBeforeAction) {
onHidden
?.
invoke
()
//
onHidden?.invoke()
}
//
}
}
}
}
}
...
@@ -131,20 +126,20 @@ object AdmobMaxHelper {
...
@@ -131,20 +126,20 @@ object AdmobMaxHelper {
if
(
isBlack
)
{
if
(
isBlack
)
{
return
return
}
}
if
(
getSpAdmobTrueMaxFalse
()
)
{
if
(
true
)
{
AdmobNativeUtils
.
showNativeAd
(
activity
,
parent
)
AdmobNativeUtils
.
showNativeAd
(
activity
,
parent
)
}
else
{
}
else
{
var
layout
=
R
.
layout
.
layout_max_native_small
//
var layout = R.layout.layout_max_native_small
if
(
where
==
0
)
{
//
if (where == 0) {
layout
=
R
.
layout
.
layout_max_native_small_f8f8f8
//
layout = R.layout.layout_max_native_small_f8f8f8
}
//
}
if
(
where
==
1
)
{
//
if (where == 1) {
layout
=
R
.
layout
.
layout_max_native_big
//
layout = R.layout.layout_max_native_big
}
//
}
if
(
where
==
2
)
{
//
if (where == 2) {
layout
=
R
.
layout
.
layout_max_native_big_2
//
layout = R.layout.layout_max_native_big_2
}
//
}
AdMaxNativeUtils
.
showNativeAd
(
activity
,
parent
,
layout
)
//
AdMaxNativeUtils.showNativeAd(activity, parent, layout)
}
}
}
}
...
@@ -153,19 +148,19 @@ object AdmobMaxHelper {
...
@@ -153,19 +148,19 @@ object AdmobMaxHelper {
return
return
}
}
if
(
getSpAdmobTrueMaxFalse
()
)
{
if
(
true
)
{
AdmobOpenUtils
.
loadAppOpenAd
()
//
AdmobOpenUtils.loadAppOpenAd()
AdmobInterstitialUtils
.
loadInterstitialAd
(
activity
)
AdmobInterstitialUtils
.
loadInterstitialAd
(
activity
)
}
else
{
}
else
{
if
(
isAdInit
.
get
())
{
if
(
isAdInit
.
get
())
{
AdMaxOpenUtils
.
loadAppOpenAd
(
activity
)
//
AdMaxOpenUtils.loadAppOpenAd(activity)
AdMaxInterstitialUtils
.
loadInterstitialAd
(
activity
)
//
AdMaxInterstitialUtils.loadInterstitialAd(activity)
}
else
{
}
else
{
AdMaxInit
.
maxInitAction
=
{
//
AdMaxInit.maxInitAction = {
Log
.
d
(
TAG
,
"max init suc"
)
Log
.
d
(
TAG
,
"max init suc"
)
// AdMaxOpenUtils.loadAppOpenAd(activity)
// AdMaxOpenUtils.loadAppOpenAd(activity)
// AdMaxInterstitialUtils.loadInterstitialAd(activity)
// AdMaxInterstitialUtils.loadInterstitialAd(activity)
}
//
}
}
}
}
}
}
}
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/ads/admob/AdmobCommonUtils.kt
deleted
100644 → 0
View file @
4ca82a26
package
com.base.filerecoveryrecyclebin.ads.admob
import
com.base.filerecoveryrecyclebin.ads.AdDisplayUtils
import
com.base.filerecoveryrecyclebin.utils.ActivityManagerUtils
import
com.base.filerecoveryrecyclebin.utils.AppPreferences
object
AdmobCommonUtils
{
private
var
lastAd
:
Any
?
=
null
private
var
maxMultiClick
=
AppPreferences
.
getInstance
().
getString
(
"maxMultiClick"
,
"10"
).
toInt
()
private
var
multiClick
=
0
fun
isMultiClick
(
currentAd
:
Any
?)
{
if
(
currentAd
==
null
)
{
return
}
if
(
lastAd
==
currentAd
)
{
multiClick
++
if
(
multiClick
>=
maxMultiClick
)
{
AdDisplayUtils
.
getInstance
()
.
setAdClickCount
(
AdDisplayUtils
.
getInstance
().
maxAdClickCount
)
ActivityManagerUtils
.
getInstance
().
finishAllActivity
()
return
}
}
else
{
multiClick
=
0
}
lastAd
=
currentAd
}
}
\ No newline at end of file
app/src/main/java/com/base/filerecoveryrecyclebin/ads/admob/AdmobInterstitialUtils.kt
View file @
2c0cd27f
package
com.base.filerecoveryrecyclebin.ads.admob
package
com.base.filerecoveryrecyclebin.ads.admob
import
android.annotation.SuppressLint
import
android.app.Activity
import
android.app.Activity
import
android.app.Dialog
import
android.app.Dialog
import
android.os.CountDownTimer
import
android.widget.Toast
import
android.widget.Toast
import
com.base.filerecoveryrecyclebin.BuildConfig
import
com.base.filerecoveryrecyclebin.BuildConfig
import
com.base.filerecoveryrecyclebin.R
import
com.base.filerecoveryrecyclebin.R
import
com.base.filerecoveryrecyclebin.ads.AdDisplayUtils
import
com.base.filerecoveryrecyclebin.ads.AdDisplayUtils
import
com.base.filerecoveryrecyclebin.ads.AdmobMaxHelper.lastShowedOnHiddenTime
import
com.base.filerecoveryrecyclebin.ads.AdmobMaxHelper.lastShowedOnHiddenTime
import
com.base.filerecoveryrecyclebin.ads.admob.AdmobCommonUtils.isMultiClick
import
com.base.filerecoveryrecyclebin.ads.admob.AdmobEvent.clickAd
import
com.base.filerecoveryrecyclebin.ads.admob.AdmobEvent.clickAd
import
com.base.filerecoveryrecyclebin.ads.admob.AdmobEvent.pullAd
import
com.base.filerecoveryrecyclebin.ads.admob.AdmobEvent.pullAd
import
com.base.filerecoveryrecyclebin.ads.admob.AdmobEvent.showAd
import
com.base.filerecoveryrecyclebin.ads.admob.AdmobEvent.showAd
import
com.base.filerecoveryrecyclebin.help.BaseApplication
import
com.base.filerecoveryrecyclebin.help.BaseApplication
import
com.base.filerecoveryrecyclebin.help.ConfigHelper
import
com.base.filerecoveryrecyclebin.help.ConfigHelper
import
com.base.filerecoveryrecyclebin.utils.AppPreferences
import
com.base.filerecoveryrecyclebin.utils.EventUtils
import
com.base.filerecoveryrecyclebin.utils.EventUtils
import
com.base.filerecoveryrecyclebin.view.CustomDialog
import
com.base.filerecoveryrecyclebin.view.CustomDialog
import
com.google.android.gms.ads.AdError
import
com.google.android.gms.ads.AdError
...
@@ -34,9 +30,6 @@ object AdmobInterstitialUtils {
...
@@ -34,9 +30,6 @@ object AdmobInterstitialUtils {
private
var
adLastDisplayTime
:
Long
=
0
private
var
adLastDisplayTime
:
Long
=
0
private
val
mRequest
=
AdRequest
.
Builder
().
build
()
private
val
mRequest
=
AdRequest
.
Builder
().
build
()
@SuppressLint
(
"StaticFieldLeak"
)
private
var
customDialog
:
CustomDialog
?
=
null
private
fun
isAdExpired
():
Boolean
{
private
fun
isAdExpired
():
Boolean
{
return
System
.
currentTimeMillis
()
-
interLoadTime
>
1000
*
60
*
60
return
System
.
currentTimeMillis
()
-
interLoadTime
>
1000
*
60
*
60
}
}
...
@@ -72,7 +65,7 @@ object AdmobInterstitialUtils {
...
@@ -72,7 +65,7 @@ object AdmobInterstitialUtils {
}
}
if
(
interAd
!=
null
)
{
if
(
interAd
!=
null
)
{
showIntervalDialogAndShowAd
(
activity
,
isShowDialog
,
onHidden
,
2
)
displayInterstitialAd
(
activity
,
onHidden
)
}
else
{
}
else
{
showAdDialogAndLoadInterstitial
(
activity
,
isReLoadAd
,
isShowDialog
,
onHidden
)
showAdDialogAndLoadInterstitial
(
activity
,
isReLoadAd
,
isShowDialog
,
onHidden
)
}
}
...
@@ -122,42 +115,6 @@ object AdmobInterstitialUtils {
...
@@ -122,42 +115,6 @@ object AdmobInterstitialUtils {
})
})
}
}
private
fun
showIntervalDialogAndShowAd
(
activity
:
Activity
,
isShowDialog
:
Boolean
,
onHidden
:
(()
->
Unit
)?,
interval
:
Int
)
{
// if (!isShowDialog) {
displayInterstitialAd
(
activity
,
onHidden
)
return
// }
// if (customDialog != null && customDialog?.isShowing == true) {
// return // 如果对话框已经显示,则不再显示
// }
//
// customDialog = CustomDialog(activity, R.layout.dialog_ad_loading)
// customDialog?.setCountdownText(R.id.dialog_ad_loading_text)
// val countdownTimer = object : CountDownTimer((interval * 1000).toLong(), 1000) {
// override fun onTick(millisUntilFinished: Long) {
// val seconds = (millisUntilFinished / 1000).toInt()
// customDialog?.updateCountdownText("Advertising in preparation ($seconds" + "s)...")
// }
//
// override fun onFinish() {
// displayInterstitialAd(activity, onHidden)
// if (!activity.isDestroyed && !activity.isFinishing) {
// customDialog?.dismiss()
// }
// customDialog = null
// }
// }
// countdownTimer.start()
// customDialog?.show()
}
private
fun
showAdDialogAndLoadInterstitial
(
private
fun
showAdDialogAndLoadInterstitial
(
activity
:
Activity
,
activity
:
Activity
,
isReLoadAd
:
Boolean
,
isReLoadAd
:
Boolean
,
...
@@ -197,7 +154,6 @@ object AdmobInterstitialUtils {
...
@@ -197,7 +154,6 @@ object AdmobInterstitialUtils {
override
fun
onAdClicked
()
{
override
fun
onAdClicked
()
{
clickAd
(
thisInterAd
?.
responseInfo
,
"interAd"
)
clickAd
(
thisInterAd
?.
responseInfo
,
"interAd"
)
AdDisplayUtils
.
getInstance
().
incrementAdClickCount
()
AdDisplayUtils
.
getInstance
().
incrementAdClickCount
()
isMultiClick
(
thisInterAd
)
}
}
override
fun
onAdDismissedFullScreenContent
()
{
override
fun
onAdDismissedFullScreenContent
()
{
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/ads/admob/AdmobNativeUtils.kt
View file @
2c0cd27f
...
@@ -6,7 +6,6 @@ import androidx.core.view.isVisible
...
@@ -6,7 +6,6 @@ import androidx.core.view.isVisible
import
com.base.filerecoveryrecyclebin.BuildConfig
import
com.base.filerecoveryrecyclebin.BuildConfig
import
com.base.filerecoveryrecyclebin.R
import
com.base.filerecoveryrecyclebin.R
import
com.base.filerecoveryrecyclebin.ads.AdDisplayUtils
import
com.base.filerecoveryrecyclebin.ads.AdDisplayUtils
import
com.base.filerecoveryrecyclebin.ads.admob.AdmobCommonUtils.isMultiClick
import
com.base.filerecoveryrecyclebin.ads.admob.AdmobEvent.clickAd
import
com.base.filerecoveryrecyclebin.ads.admob.AdmobEvent.clickAd
import
com.base.filerecoveryrecyclebin.ads.admob.AdmobEvent.pullAd
import
com.base.filerecoveryrecyclebin.ads.admob.AdmobEvent.pullAd
import
com.base.filerecoveryrecyclebin.ads.admob.AdmobEvent.showAd
import
com.base.filerecoveryrecyclebin.ads.admob.AdmobEvent.showAd
...
@@ -64,7 +63,6 @@ object AdmobNativeUtils {
...
@@ -64,7 +63,6 @@ object AdmobNativeUtils {
}.
withAdListener
(
object
:
AdListener
()
{
}.
withAdListener
(
object
:
AdListener
()
{
override
fun
onAdClicked
()
{
override
fun
onAdClicked
()
{
clickAd
(
nativeAd
?.
responseInfo
,
"nativeAd"
)
clickAd
(
nativeAd
?.
responseInfo
,
"nativeAd"
)
isMultiClick
(
nativeAd
)
}
}
override
fun
onAdFailedToLoad
(
p0
:
LoadAdError
)
{
override
fun
onAdFailedToLoad
(
p0
:
LoadAdError
)
{
...
@@ -72,7 +70,6 @@ object AdmobNativeUtils {
...
@@ -72,7 +70,6 @@ object AdmobNativeUtils {
nativeAd
=
null
nativeAd
=
null
isLoading
=
false
isLoading
=
false
pullAd
(
p0
.
responseInfo
,
"nativeAd"
,
p0
.
message
,
reqId
=
reqId
)
pullAd
(
p0
.
responseInfo
,
"nativeAd"
,
p0
.
message
,
reqId
=
reqId
)
// Log.e("MXL", "NativeAdFailedToLoad: " + p0.message)
}
}
}).
build
()
}).
build
()
adLoader
.
loadAd
(
mRequest
)
adLoader
.
loadAd
(
mRequest
)
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/ads/admob/AdmobOpenUtils.kt
View file @
2c0cd27f
package
com.base.filerecoveryrecyclebin.ads.admob
package
com.base.filerecoveryrecyclebin.ads.admob
import
android.app.Activity
import
android.app.Activity
import
android.graphics.Bitmap.Config
import
com.base.filerecoveryrecyclebin.BuildConfig
import
com.base.filerecoveryrecyclebin.BuildConfig
import
com.base.filerecoveryrecyclebin.ads.AdDisplayUtils
import
com.base.filerecoveryrecyclebin.ads.AdDisplayUtils
import
com.base.filerecoveryrecyclebin.ads.admob.AdmobCommonUtils.isMultiClick
import
com.base.filerecoveryrecyclebin.ads.admob.AdmobEvent.clickAd
import
com.base.filerecoveryrecyclebin.ads.admob.AdmobEvent.clickAd
import
com.base.filerecoveryrecyclebin.ads.admob.AdmobEvent.pullAd
import
com.base.filerecoveryrecyclebin.ads.admob.AdmobEvent.pullAd
import
com.base.filerecoveryrecyclebin.ads.admob.AdmobEvent.showAd
import
com.base.filerecoveryrecyclebin.ads.admob.AdmobEvent.showAd
...
@@ -104,7 +102,6 @@ object AdmobOpenUtils {
...
@@ -104,7 +102,6 @@ object AdmobOpenUtils {
thisMOpenAd
?.
fullScreenContentCallback
=
object
:
FullScreenContentCallback
()
{
thisMOpenAd
?.
fullScreenContentCallback
=
object
:
FullScreenContentCallback
()
{
override
fun
onAdClicked
()
{
override
fun
onAdClicked
()
{
clickAd
(
thisMOpenAd
?.
responseInfo
,
"openAd"
)
clickAd
(
thisMOpenAd
?.
responseInfo
,
"openAd"
)
isMultiClick
(
thisMOpenAd
)
}
}
override
fun
onAdDismissedFullScreenContent
()
{
override
fun
onAdDismissedFullScreenContent
()
{
...
@@ -130,13 +127,6 @@ object AdmobOpenUtils {
...
@@ -130,13 +127,6 @@ object AdmobOpenUtils {
}
}
thisMOpenAd
?.
show
(
activity
)
thisMOpenAd
?.
show
(
activity
)
}
else
{
}
else
{
// LogEx.logDebug(TAG, "mOpenAd=null")
// onHidden?.invoke(5)
// loadAppOpenAd()
// val obj = JSONObject()
// obj.put("reason", "no_ad")
// obj.put("ad_unit", "openAd")
// EventUtils.event("ad_show_error", ext = obj)
LogEx
.
logDebug
(
TAG
,
"mOpenAd=null"
)
LogEx
.
logDebug
(
TAG
,
"mOpenAd=null"
)
loadAppOpenAd
{
loadAppOpenAd
{
if
(
mOpenAd
!=
null
)
{
if
(
mOpenAd
!=
null
)
{
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/ads/max/AdMaxEvent.kt
View file @
2c0cd27f
package
com.base.filerecoveryrecyclebin.ads.max
//package com.base.filerecoveryrecyclebin.ads.max
//
import
android.os.Bundle
//import android.os.Bundle
import
com.applovin.mediation.MaxAd
//import com.applovin.mediation.MaxAd
import
com.applovin.mediation.MaxAdRevenueListener
//import com.applovin.mediation.MaxAdRevenueListener
import
com.applovin.sdk.AppLovinSdk
//import com.applovin.sdk.AppLovinSdk
import
com.base.filerecoveryrecyclebin.help.BaseApplication
//import com.base.filerecoveryrecyclebin.help.BaseApplication
import
com.base.filerecoveryrecyclebin.utils.EventUtils
//import com.base.filerecoveryrecyclebin.utils.EventUtils
import
com.base.filerecoveryrecyclebin.utils.LogEx
//import com.base.filerecoveryrecyclebin.utils.LogEx
import
com.facebook.FacebookSdk
//import com.facebook.FacebookSdk
import
com.facebook.appevents.AppEventsConstants
//import com.facebook.appevents.AppEventsConstants
import
com.facebook.appevents.AppEventsLogger
//import com.facebook.appevents.AppEventsLogger
import
com.google.firebase.analytics.FirebaseAnalytics
//import com.google.firebase.analytics.FirebaseAnalytics
import
org.json.JSONObject
//import org.json.JSONObject
//
object
AdMaxEvent
{
//object AdMaxEvent {
fun
pullAd
(
ad
:
MaxAd
?,
adUnit
:
String
,
error
:
String
?
=
null
,
reqId
:
String
?
=
null
,
code
:
Int
?
=
null
)
{
// fun pullAd(ad: MaxAd?, adUnit: String, error: String? = null, reqId: String? = null, code: Int? = null) {
val
obj
=
JSONObject
()
// val obj = JSONObject()
obj
.
put
(
"UnitId"
,
ad
?.
adUnitId
)
// obj.put("UnitId", ad?.adUnitId)
obj
.
put
(
"ad_unit"
,
adUnit
)
// obj.put("ad_unit", adUnit)
obj
.
put
(
// obj.put(
"creativeId"
,
// "creativeId",
ad
?.
creativeId
// ad?.creativeId
)
// )
obj
.
put
(
"req_id"
,
reqId
)
// obj.put("req_id", reqId)
obj
.
put
(
"status"
,
if
(
ad
==
null
)
"0"
else
"1"
)
// obj.put("status", if (ad == null) "0" else "1")
obj
.
put
(
"networkname"
,
ad
?.
networkName
)
// obj.put("networkname", ad?.networkName)
obj
.
put
(
"placement"
,
ad
?.
placement
)
// obj.put("placement", ad?.placement)
obj
.
put
(
"networkplacement"
,
ad
?.
networkPlacement
)
// obj.put("networkplacement", ad?.networkPlacement)
obj
.
put
(
"latency"
,
ad
?.
requestLatencyMillis
)
// obj.put("latency", ad?.requestLatencyMillis)
obj
.
put
(
"valueMicros"
,
ad
?.
revenue
)
// obj.put("valueMicros", ad?.revenue)
if
(
error
==
null
)
{
// if (error == null) {
obj
.
put
(
"status"
,
"1"
)
// obj.put("status", "1")
}
else
{
// } else {
obj
.
put
(
"errMsg"
,
error
)
// obj.put("errMsg", error)
obj
.
put
(
"status"
,
"2"
)
// obj.put("status", "2")
}
// }
EventUtils
.
event
(
"ad_pull"
,
ext
=
obj
)
// EventUtils.event("ad_pull", ext = obj)
}
// }
//
fun
clickAd
(
ad
:
MaxAd
?,
adUnit
:
String
)
{
// fun clickAd(ad: MaxAd?, adUnit: String) {
//
val
obj
=
JSONObject
()
// val obj = JSONObject()
obj
.
put
(
"UnitId"
,
ad
?.
adUnitId
)
// obj.put("UnitId", ad?.adUnitId)
obj
.
put
(
"ad_unit"
,
adUnit
)
// obj.put("ad_unit", adUnit)
obj
.
put
(
// obj.put(
"creativeId"
,
// "creativeId",
ad
?.
creativeId
// ad?.creativeId
)
// )
obj
.
put
(
"networkname"
,
ad
?.
networkName
)
// obj.put("networkname", ad?.networkName)
obj
.
put
(
"placement"
,
ad
?.
placement
)
// obj.put("placement", ad?.placement)
obj
.
put
(
"networkplacement"
,
ad
?.
networkPlacement
)
// obj.put("networkplacement", ad?.networkPlacement)
obj
.
put
(
"latency"
,
ad
?.
requestLatencyMillis
)
// obj.put("latency", ad?.requestLatencyMillis)
obj
.
put
(
"valueMicros"
,
ad
?.
revenue
)
// obj.put("valueMicros", ad?.revenue)
if
(!
adUnit
.
equals
(
"nativeAd"
))
{
// if (!adUnit.equals("nativeAd")) {
EventUtils
.
event
(
"ad_click"
,
ext
=
obj
)
// EventUtils.event("ad_click", ext = obj)
}
else
{
// } else {
EventUtils
.
event
(
"big_imgad_click"
,
ext
=
obj
)
// EventUtils.event("big_imgad_click", ext = obj)
}
// }
//
}
// }
//
fun
showAd
(
ad
:
MaxAd
?,
adUnit
:
String
,
activity
:
String
?)
{
// fun showAd(ad: MaxAd?, adUnit: String, activity: String?) {
val
obj
=
JSONObject
()
// val obj = JSONObject()
obj
.
put
(
"UnitId"
,
ad
?.
adUnitId
)
// obj.put("UnitId", ad?.adUnitId)
obj
.
put
(
"ad_unit"
,
adUnit
)
// obj.put("ad_unit", adUnit)
obj
.
put
(
// obj.put(
"creativeId"
,
// "creativeId",
ad
?.
creativeId
// ad?.creativeId
)
// )
obj
.
put
(
"networkname"
,
ad
?.
networkName
)
// obj.put("networkname", ad?.networkName)
obj
.
put
(
"placement"
,
ad
?.
placement
)
// obj.put("placement", ad?.placement)
obj
.
put
(
"networkplacement"
,
ad
?.
networkPlacement
)
// obj.put("networkplacement", ad?.networkPlacement)
obj
.
put
(
"latency"
,
ad
?.
requestLatencyMillis
)
// obj.put("latency", ad?.requestLatencyMillis)
obj
.
put
(
"valueMicros"
,
ad
?.
revenue
)
// obj.put("valueMicros", ad?.revenue)
obj
.
put
(
"from"
,
activity
)
// obj.put("from", activity)
obj
.
put
(
"mediation"
,
"applovin"
)
// obj.put("mediation", "applovin")
LogEx
.
logDebug
(
"glc"
,
"from: $activity"
)
// LogEx.logDebug("glc", "from: $activity")
if
(
adUnit
!=
"nativeAd"
)
{
// if (adUnit != "nativeAd") {
EventUtils
.
event
(
"ad_show"
,
ext
=
obj
)
// EventUtils.event("ad_show", ext = obj)
}
else
{
// } else {
EventUtils
.
event
(
"big_img_show"
,
ext
=
obj
)
// EventUtils.event("big_img_show", ext = obj)
}
// }
//
}
// }
//
private
val
taichiPref
=
FacebookSdk
.
getApplicationContext
()
// private val taichiPref = FacebookSdk.getApplicationContext()
.
getSharedPreferences
(
"TaichiTroasCache"
,
0
)
// .getSharedPreferences("TaichiTroasCache", 0)
private
val
taichiSharedPreferencesEditor
=
taichiPref
.
edit
()
// private val taichiSharedPreferencesEditor = taichiPref.edit()
//
class
EventOnPaidEventListener
:
MaxAdRevenueListener
{
// class EventOnPaidEventListener : MaxAdRevenueListener {
override
fun
onAdRevenuePaid
(
ad
:
MaxAd
)
{
// override fun onAdRevenuePaid(ad: MaxAd) {
val
params
=
Bundle
()
// val params = Bundle()
val
currentImpressionRevenue
:
Double
=
ad
.
revenue
// In USD
// val currentImpressionRevenue: Double = ad.revenue // In USD
val
mFirebaseAnalytics
=
FirebaseAnalytics
.
getInstance
(
BaseApplication
.
context
)
// val mFirebaseAnalytics = FirebaseAnalytics.getInstance(BaseApplication.context)
params
.
putString
(
FirebaseAnalytics
.
Param
.
AD_PLATFORM
,
"appLovin"
)
// params.putString(FirebaseAnalytics.Param.AD_PLATFORM, "appLovin")
params
.
putString
(
FirebaseAnalytics
.
Param
.
AD_SOURCE
,
ad
.
networkName
)
// params.putString(FirebaseAnalytics.Param.AD_SOURCE, ad.networkName)
params
.
putString
(
FirebaseAnalytics
.
Param
.
AD_FORMAT
,
ad
.
format
.
getDisplayName
())
// params.putString(FirebaseAnalytics.Param.AD_FORMAT, ad.format.getDisplayName())
params
.
putString
(
FirebaseAnalytics
.
Param
.
AD_UNIT_NAME
,
ad
.
adUnitId
)
// params.putString(FirebaseAnalytics.Param.AD_UNIT_NAME, ad.adUnitId)
params
.
putDouble
(
FirebaseAnalytics
.
Param
.
VALUE
,
currentImpressionRevenue
)
// params.putDouble(FirebaseAnalytics.Param.VALUE, currentImpressionRevenue)
params
.
putString
(
FirebaseAnalytics
.
Param
.
CURRENCY
,
"USD"
)
// params.putString(FirebaseAnalytics.Param.CURRENCY, "USD")
mFirebaseAnalytics
.
logEvent
(
FirebaseAnalytics
.
Event
.
AD_IMPRESSION
,
params
)
// mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.AD_IMPRESSION, params)
mFirebaseAnalytics
.
logEvent
(
"Ad_Impression_Revenue"
,
params
)
// mFirebaseAnalytics.logEvent("Ad_Impression_Revenue", params)
val
previousTaichiTroasCache
=
taichiPref
.
getFloat
(
"TaichiTroasCache"
,
0f
)
// val previousTaichiTroasCache = taichiPref.getFloat("TaichiTroasCache", 0f)
val
currentTaichiTroasCache
=
previousTaichiTroasCache
+
currentImpressionRevenue
// val currentTaichiTroasCache = previousTaichiTroasCache + currentImpressionRevenue
if
(
currentTaichiTroasCache
>=
0.01
)
{
// if (currentTaichiTroasCache >= 0.01) {
val
roasbundle
=
Bundle
()
// val roasbundle = Bundle()
roasbundle
.
putDouble
(
FirebaseAnalytics
.
Param
.
VALUE
,
currentTaichiTroasCache
)
// roasbundle.putDouble(FirebaseAnalytics.Param.VALUE, currentTaichiTroasCache)
roasbundle
.
putString
(
FirebaseAnalytics
.
Param
.
CURRENCY
,
"USD"
)
///(Required)tROAS事件必须
// roasbundle.putString(FirebaseAnalytics.Param.CURRENCY, "USD")///(Required)tROAS事件必须
mFirebaseAnalytics
.
logEvent
(
"Total_Ads_Revenue_001"
,
roasbundle
)
// 给Taichi用
// mFirebaseAnalytics.logEvent("Total_Ads_Revenue_001", roasbundle) // 给Taichi用
taichiSharedPreferencesEditor
.
putFloat
(
"TaichiTroasCache"
,
0f
)
//重新清零,开始计算
// taichiSharedPreferencesEditor.putFloat("TaichiTroasCache", 0f)//重新清零,开始计算
//
val
logger
=
AppEventsLogger
.
newLogger
(
BaseApplication
.
context
)
// val logger = AppEventsLogger.newLogger(BaseApplication.context)
val
parameters
=
Bundle
()
// val parameters = Bundle()
parameters
.
putString
(
AppEventsConstants
.
EVENT_PARAM_CURRENCY
,
"USD"
)
// parameters.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, "USD")
logger
.
logEvent
(
"ad_value"
,
currentTaichiTroasCache
,
parameters
)
// logger.logEvent("ad_value", currentTaichiTroasCache, parameters)
}
else
{
// } else {
taichiSharedPreferencesEditor
.
putFloat
(
// taichiSharedPreferencesEditor.putFloat(
"TaichiTroasCache"
,
// "TaichiTroasCache",
currentTaichiTroasCache
.
toFloat
()
// currentTaichiTroasCache.toFloat()
)
// )
taichiSharedPreferencesEditor
.
commit
()
// taichiSharedPreferencesEditor.commit()
}
// }
val
obj
=
JSONObject
()
// val obj = JSONObject()
val
revenue
=
ad
.
revenue
// val revenue = ad.revenue
val
countryCode
=
// val countryCode =
AppLovinSdk
.
getInstance
(
BaseApplication
.
context
).
configuration
.
countryCode
// AppLovinSdk.getInstance(BaseApplication.context).configuration.countryCode
val
networkName
=
ad
.
networkName
// val networkName = ad.networkName
val
adUnitId
=
ad
.
adUnitId
// val adUnitId = ad.adUnitId
val
adFormat
=
ad
.
format
// val adFormat = ad.format
val
placement
=
ad
.
placement
// val placement = ad.placement
val
networkPlacement
=
ad
.
networkPlacement
// val networkPlacement = ad.networkPlacement
obj
.
put
(
"valueMicros"
,
revenue
)
// obj.put("valueMicros", revenue)
obj
.
put
(
"currencyCode"
,
countryCode
)
// obj.put("currencyCode", countryCode)
obj
.
put
(
"adUnitId"
,
adUnitId
)
// obj.put("adUnitId", adUnitId)
obj
.
put
(
"networkName"
,
networkName
)
// obj.put("networkName", networkName)
obj
.
put
(
"adFormat"
,
adFormat
)
// obj.put("adFormat", adFormat)
obj
.
put
(
"placement"
,
placement
)
// obj.put("placement", placement)
obj
.
put
(
"networkPlacement"
,
networkPlacement
)
// obj.put("networkPlacement", networkPlacement)
EventUtils
.
event
(
"ad_price"
,
ext
=
obj
)
// EventUtils.event("ad_price", ext = obj)
}
// }
//
}
// }
}
//}
\ No newline at end of file
\ No newline at end of file
app/src/main/java/com/base/filerecoveryrecyclebin/ads/max/AdMaxInit.kt
View file @
2c0cd27f
package
com.base.filerecoveryrecyclebin.ads.max
//package com.base.filerecoveryrecyclebin.ads.max
//
import
android.content.Context
//import android.content.Context
import
com.applovin.sdk.AppLovinMediationProvider
//import com.applovin.sdk.AppLovinMediationProvider
import
com.applovin.sdk.AppLovinSdk
//import com.applovin.sdk.AppLovinSdk
import
com.applovin.sdk.AppLovinSdkInitializationConfiguration
//import com.applovin.sdk.AppLovinSdkInitializationConfiguration
import
com.base.filerecoveryrecyclebin.BuildConfig
//import com.base.filerecoveryrecyclebin.ads.AdmobMaxHelper.isAdInit
import
com.base.filerecoveryrecyclebin.ads.AdmobMaxHelper.isAdInit
//import com.base.filerecoveryrecyclebin.utils.EventUtils
import
com.base.filerecoveryrecyclebin.utils.EventUtils
//import com.base.filerecoveryrecyclebin.utils.LogEx
import
com.base.filerecoveryrecyclebin.utils.LogEx
//import java.util.concurrent.Executors
import
java.util.concurrent.Executors
//
//object AdMaxInit {
object
AdMaxInit
{
//
// private val TAG = "AdMaxInit"
private
val
TAG
=
"AdMaxInit"
// var maxInitAction: (() -> Unit)? = null
var
maxInitAction
:
(()
->
Unit
)?
=
null
//
// fun Context.initAdMax() {
fun
Context
.
initAdMax
()
{
// // If you want to test your own AppLovin SDK key, change the value here and update the package name in the build.gradle
// If you want to test your own AppLovin SDK key, change the value here and update the package name in the build.gradle
//// val YOUR_SDK_KEY = "05TMDQ5tZabpXQ45_UTbmEGNUtVAzSTzT6KmWQc5_CuWdzccS4DCITZoL3yIWUG3bbq60QC_d4WF28tUC4gVTF"
// val YOUR_SDK_KEY = "05TMDQ5tZabpXQ45_UTbmEGNUtVAzSTzT6KmWQc5_CuWdzccS4DCITZoL3yIWUG3bbq60QC_d4WF28tUC4gVTF"
// val YOUR_SDK_KEY = "GGPreND6SRmCt1zJgn5faiLGD8c2PVGPLgPpSg7cHanVTud1DhtuI9MmteTqlEviaJ57WnxW68kQDaATJ5z3cW"
val
YOUR_SDK_KEY
=
"GGPreND6SRmCt1zJgn5faiLGD8c2PVGPLgPpSg7cHanVTud1DhtuI9MmteTqlEviaJ57WnxW68kQDaATJ5z3cW"
//
// val executor = Executors.newSingleThreadExecutor();
val
executor
=
Executors
.
newSingleThreadExecutor
();
// executor.execute {
executor
.
execute
{
//
// val initConfigBuilder = AppLovinSdkInitializationConfiguration.builder(YOUR_SDK_KEY, this)
val
initConfigBuilder
=
AppLovinSdkInitializationConfiguration
.
builder
(
YOUR_SDK_KEY
,
this
)
// initConfigBuilder.mediationProvider = AppLovinMediationProvider.MAX
initConfigBuilder
.
mediationProvider
=
AppLovinMediationProvider
.
MAX
//
// // Enable test mode by default for the current device. Cannot be run on the main thread.
// Enable test mode by default for the current device. Cannot be run on the main thread.
//// val currentGaid = AdvertisingIdClient.getAdvertisingIdInfo(this).id
// val currentGaid = AdvertisingIdClient.getAdvertisingIdInfo(this).id
//// if (currentGaid != null) {
// if (currentGaid != null) {
//// initConfigBuilder.testDeviceAdvertisingIds = Collections.singletonList(currentGaid)
// initConfigBuilder.testDeviceAdvertisingIds = Collections.singletonList(currentGaid)
//// }
//
//
// // Initialize the AppLovin SDK
// val sdk = AppLovinSdk.getInstance(this)
// sdk.initialize(initConfigBuilder.build()) {
// LogEx.logDebug(TAG, "max init")
// isAdInit.set(true)
// maxInitAction?.invoke()
// maxInitAction = null
// EventUtils.event("MaxInit", "MaxInit")
// }
// }
//
// executor.shutdown()
// Initialize the AppLovin SDK
// }
val
sdk
=
AppLovinSdk
.
getInstance
(
this
)
// }
sdk
.
initialize
(
initConfigBuilder
.
build
())
{
//}
LogEx
.
logDebug
(
TAG
,
"max init"
)
\ No newline at end of file
isAdInit
.
set
(
true
)
maxInitAction
?.
invoke
()
maxInitAction
=
null
EventUtils
.
event
(
"MaxInit"
,
"MaxInit"
)
}
executor
.
shutdown
()
}
}
}
\ No newline at end of file
app/src/main/java/com/base/filerecoveryrecyclebin/ads/max/AdMaxInterstitialUtils.kt
View file @
2c0cd27f
package
com.base.filerecoveryrecyclebin.ads.max
//package com.base.filerecoveryrecyclebin.ads.max
//
import
android.app.Activity
//import android.app.Activity
import
android.app.Dialog
//import android.app.Dialog
import
com.applovin.mediation.MaxAd
//import com.applovin.mediation.MaxAd
import
com.applovin.mediation.MaxAdListener
//import com.applovin.mediation.MaxAdListener
import
com.applovin.mediation.MaxError
//import com.applovin.mediation.MaxError
import
com.applovin.mediation.ads.MaxInterstitialAd
//import com.applovin.mediation.ads.MaxInterstitialAd
import
com.base.filerecoveryrecyclebin.MyApplication
//import com.base.filerecoveryrecyclebin.MyApplication.Companion.isInterOpenShowing
import
com.base.filerecoveryrecyclebin.MyApplication.Companion.isInterOpenShowing
//import com.base.filerecoveryrecyclebin.R
import
com.base.filerecoveryrecyclebin.R
//import com.base.filerecoveryrecyclebin.ads.AdDisplayUtils
import
com.base.filerecoveryrecyclebin.ads.AdDisplayUtils
//import com.base.filerecoveryrecyclebin.ads.AdmobMaxHelper.isAdInit
import
com.base.filerecoveryrecyclebin.ads.AdmobMaxHelper.isAdInit
//import com.base.filerecoveryrecyclebin.ads.AdmobMaxHelper.lastShowedOnHiddenTime
import
com.base.filerecoveryrecyclebin.ads.AdmobMaxHelper.lastShowedOnHiddenTime
//import com.base.filerecoveryrecyclebin.help.ConfigHelper
import
com.base.filerecoveryrecyclebin.help.ConfigHelper
//import com.base.filerecoveryrecyclebin.utils.EventUtils
import
com.base.filerecoveryrecyclebin.utils.EventUtils
//import com.base.filerecoveryrecyclebin.utils.LogEx
import
com.base.filerecoveryrecyclebin.utils.LogEx
//import com.base.filerecoveryrecyclebin.view.CustomDialog
import
com.base.filerecoveryrecyclebin.view.CustomDialog
//import org.json.JSONObject
import
org.json.JSONObject
//import java.util.UUID
import
java.util.UUID
//
//object AdMaxInterstitialUtils {
object
AdMaxInterstitialUtils
{
//
// private val TAG = "AdMaxInterstitialUtils"
private
val
TAG
=
"AdMaxInterstitialUtils"
// private var interstitialAd: MaxInterstitialAd? = null
private
var
interstitialAd
:
MaxInterstitialAd
?
=
null
// private var interLoadTime = Long.MAX_VALUE
private
var
interLoadTime
=
Long
.
MAX_VALUE
// private var onHidden: (() -> Unit)? = null
private
var
onHidden
:
(()
->
Unit
)?
=
null
// private var loadingListener: (() -> Unit)? = null
private
var
loadingListener
:
(()
->
Unit
)?
=
null
// private var activityString: String = ""
private
var
activityString
:
String
=
""
//
// private fun setListener(activity: Activity) {
private
fun
setListener
(
activity
:
Activity
)
{
// activityString = activity::class.java.toString().split(".").last()
activityString
=
activity
::
class
.
java
.
toString
().
split
(
"."
).
last
()
// if (interstitialAd == null) {
if
(
interstitialAd
==
null
)
{
//
// interstitialAd = MaxInterstitialAd(ConfigHelper.interAdMaxId, activity)
interstitialAd
=
MaxInterstitialAd
(
ConfigHelper
.
interAdMaxId
,
activity
)
// interstitialAd?.setListener(object : MaxAdListener {
interstitialAd
?.
setListener
(
object
:
MaxAdListener
{
// override fun onAdLoaded(p0: MaxAd) {
override
fun
onAdLoaded
(
p0
:
MaxAd
)
{
// LogEx.logDebug(TAG, "onAdLoaded")
LogEx
.
logDebug
(
TAG
,
"onAdLoaded"
)
//
// loadingListener?.invoke()
loadingListener
?.
invoke
()
// loadingListener = null
loadingListener
=
null
//
// interLoadTime = System.currentTimeMillis()
interLoadTime
=
System
.
currentTimeMillis
()
// val reqId = UUID.randomUUID().toString()
val
reqId
=
UUID
.
randomUUID
().
toString
()
// AdMaxEvent.pullAd(p0, "interAd", reqId = reqId)
AdMaxEvent
.
pullAd
(
p0
,
"interAd"
,
reqId
=
reqId
)
// }
}
//
// override fun onAdLoadFailed(p0: String, p1: MaxError) {
override
fun
onAdLoadFailed
(
p0
:
String
,
p1
:
MaxError
)
{
// LogEx.logDebug(TAG, "onAdLoadFailed")
LogEx
.
logDebug
(
TAG
,
"onAdLoadFailed"
)
// val reqId = UUID.randomUUID().toString()
val
reqId
=
UUID
.
randomUUID
().
toString
()
// AdMaxEvent.pullAd(null, "interAd", reqId = reqId, error = p1.message, code = p1.code)
AdMaxEvent
.
pullAd
(
null
,
"interAd"
,
reqId
=
reqId
,
error
=
p1
.
message
,
code
=
p1
.
code
)
// AdDisplayUtils.getInstance().incrementAdRequestFailCount()
AdDisplayUtils
.
getInstance
().
incrementAdRequestFailCount
()
//
// loadingListener?.invoke()
loadingListener
?.
invoke
()
// loadingListener = null
loadingListener
=
null
// }
}
//
// override fun onAdDisplayed(p0: MaxAd) {
override
fun
onAdDisplayed
(
p0
:
MaxAd
)
{
// LogEx.logDebug(TAG, "onAdDisplayed")
LogEx
.
logDebug
(
TAG
,
"onAdDisplayed"
)
// AdDisplayUtils.getInstance().incrementAdDisplayCount()
AdDisplayUtils
.
getInstance
().
incrementAdDisplayCount
()
// AdMaxEvent.showAd(p0, "interAd", activityString)
AdMaxEvent
.
showAd
(
p0
,
"interAd"
,
activityString
)
//
// isInterOpenShowing = true
isInterOpenShowing
=
true
// }
}
//
// override fun onAdHidden(p0: MaxAd) {
override
fun
onAdHidden
(
p0
:
MaxAd
)
{
// LogEx.logDebug(TAG, "onAdHidden")
LogEx
.
logDebug
(
TAG
,
"onAdHidden"
)
// onHidden?.invoke()
onHidden
?.
invoke
()
// onHidden = null
onHidden
=
null
// AdMaxOpenUtils.loadAppOpenAd(activity)
AdMaxOpenUtils
.
loadAppOpenAd
(
activity
)
//// loadInterstitialAd(activity)
//
// isInterOpenShowing = false
// lastShowedOnHiddenTime = System.currentTimeMillis()
// }
//
// override fun onAdClicked(p0: MaxAd) {
// LogEx.logDebug(TAG, "onAdClicked activity=$activityString")
// AdDisplayUtils.getInstance().incrementAdClickCount()
// AdMaxEvent.clickAd(p0, "interAd")
// }
//
//
// override fun onAdDisplayFailed(p0: MaxAd, p1: MaxError) {
// LogEx.logDebug(TAG, "onAdDisplayFailed")
// onHidden?.invoke()
// onHidden = null
// val obj2 = JSONObject()
// obj2.put("code", p1.code)
// obj2.put("reason", p1.message)
// obj2.put("ad_unit", "interAd")
// EventUtils.event("ad_show_error", ext = obj2)
//
// isInterOpenShowing = false
// }
// })
// interstitialAd?.setRevenueListener(AdMaxEvent.EventOnPaidEventListener())
// }
// }
//
// fun showInterstitialAd(activity: Activity, onHidden: (() -> Unit)? = null) {
// setListener(activity)
//
// if (activity.isFinishing || activity.isDestroyed) {
// return
// }
//
// if (isAdExpired()) {
// val obj2 = JSONObject()
// obj2.put("ad_unit", "interAd")
// EventUtils.event("ad_expire", ext = obj2)
// onHidden?.invoke()
// loadInterstitialAd(activity)
// loadInterstitialAd(activity)
// return
isInterOpenShowing
=
false
// }
lastShowedOnHiddenTime
=
System
.
currentTimeMillis
()
//
}
//
// if (!AdDisplayUtils.getInstance().shouldShowAd("interAd")) {
override
fun
onAdClicked
(
p0
:
MaxAd
)
{
// onHidden?.invoke()
LogEx
.
logDebug
(
TAG
,
"onAdClicked activity=$activityString"
)
// return
AdDisplayUtils
.
getInstance
().
incrementAdClickCount
()
// }
AdMaxEvent
.
clickAd
(
p0
,
"interAd"
)
//
}
// LogEx.logDebug(TAG, "showInterstitialAd,展示插屏广告")
//
// val obj1 = JSONObject()
override
fun
onAdDisplayFailed
(
p0
:
MaxAd
,
p1
:
MaxError
)
{
// obj1.put("ad_unit", "interAd")
LogEx
.
logDebug
(
TAG
,
"onAdDisplayFailed"
)
// EventUtils.event("ad_prepare_show", ext = obj1)
onHidden
?.
invoke
()
// isInterOpenShowing = false
onHidden
=
null
//
val
obj2
=
JSONObject
()
// if (interstitialAd?.isReady == true) {
obj2
.
put
(
"code"
,
p1
.
code
)
// LogEx.logDebug(TAG, "有缓存直接播放。")
obj2
.
put
(
"reason"
,
p1
.
message
)
// this.onHidden = onHidden
obj2
.
put
(
"ad_unit"
,
"interAd"
)
// interstitialAd?.showAd(activity)
EventUtils
.
event
(
"ad_show_error"
,
ext
=
obj2
)
// } else {
// LogEx.logDebug(TAG, "展示广告时,没有缓存,需要拉取。")
isInterOpenShowing
=
false
// val obj2 = JSONObject()
}
// obj2.put("reason", "no cache ad")
})
// obj2.put("ad_unit", "interAd")
interstitialAd
?.
setRevenueListener
(
AdMaxEvent
.
EventOnPaidEventListener
())
// EventUtils.event("ad_nocache_pull", ext = obj2)
}
// val loaded = loadInterstitialAd(activity)
}
// if (loaded) {
// LogEx.logDebug(TAG, "loaded=true")
fun
showInterstitialAd
(
activity
:
Activity
,
onHidden
:
(()
->
Unit
)?
=
null
)
{
// val dialog = showAdDialogAndLoadInterstitial(activity)
setListener
(
activity
)
// loadingListener = {
// dialog?.dismiss()
if
(
activity
.
isFinishing
||
activity
.
isDestroyed
)
{
// if (interstitialAd?.isReady == true) {
return
// this.onHidden = onHidden
}
// interstitialAd?.showAd(activity)
// } else {
if
(
isAdExpired
())
{
// onHidden?.invoke()
val
obj2
=
JSONObject
()
// }
obj2
.
put
(
"ad_unit"
,
"interAd"
)
// }
EventUtils
.
event
(
"ad_expire"
,
ext
=
obj2
)
// } else {
onHidden
?.
invoke
()
// LogEx.logDebug(TAG, "loaded=false")
loadInterstitialAd
(
activity
)
// onHidden?.invoke()
return
// }
}
// }
//
// }
if
(!
AdDisplayUtils
.
getInstance
().
shouldShowAd
(
"interAd"
))
{
//
onHidden
?.
invoke
()
// private fun isAdExpired(): Boolean {
return
// return System.currentTimeMillis() - interLoadTime > 1000 * 60 * 60
}
// }
//
LogEx
.
logDebug
(
TAG
,
"showInterstitialAd,展示插屏广告"
)
//
// private fun showAdDialogAndLoadInterstitial(
val
obj1
=
JSONObject
()
// activity: Activity,
obj1
.
put
(
"ad_unit"
,
"interAd"
)
// ): Dialog? {
EventUtils
.
event
(
"ad_prepare_show"
,
ext
=
obj1
)
// var customDialog: Dialog? = null
isInterOpenShowing
=
false
// if (!activity.isFinishing && !activity.isDestroyed) {
// customDialog = CustomDialog(activity, R.layout.dialog_ad_loading)
if
(
interstitialAd
?.
isReady
==
true
)
{
// // 设置对话框的样式和内容
LogEx
.
logDebug
(
TAG
,
"有缓存直接播放。"
)
// customDialog.show()
this
.
onHidden
=
onHidden
// }
interstitialAd
?.
showAd
(
activity
)
// return customDialog
}
else
{
// }
LogEx
.
logDebug
(
TAG
,
"展示广告时,没有缓存,需要拉取。"
)
//
val
obj2
=
JSONObject
()
// fun loadInterstitialAd(activity: Activity): Boolean {
obj2
.
put
(
"reason"
,
"no cache ad"
)
// setListener(activity)
obj2
.
put
(
"ad_unit"
,
"interAd"
)
//
EventUtils
.
event
(
"ad_nocache_pull"
,
ext
=
obj2
)
// if (!AdDisplayUtils.getInstance().shouldShowAd("interAd")) {
val
loaded
=
loadInterstitialAd
(
activity
)
// return false
if
(
loaded
)
{
// }
LogEx
.
logDebug
(
TAG
,
"loaded=true"
)
//
val
dialog
=
showAdDialogAndLoadInterstitial
(
activity
)
// LogEx.logDebug(TAG, "loadInterstitialAd")
loadingListener
=
{
// val reqId = UUID.randomUUID().toString()
dialog
?.
dismiss
()
// val obj = JSONObject()
if
(
interstitialAd
?.
isReady
==
true
)
{
// obj.put("req_id", reqId)
this
.
onHidden
=
onHidden
// obj.put("ad_type", "interAd")
interstitialAd
?.
showAd
(
activity
)
// EventUtils.event("ad_pull_start", ext = obj)
}
else
{
// interstitialAd?.loadAd()
onHidden
?.
invoke
()
// AdDisplayUtils.getInstance().incrementAdRequestCount()
}
// return true
}
// }
}
else
{
//
LogEx
.
logDebug
(
TAG
,
"loaded=false"
)
//
onHidden
?.
invoke
()
//}
}
\ No newline at end of file
}
}
private
fun
isAdExpired
():
Boolean
{
return
System
.
currentTimeMillis
()
-
interLoadTime
>
1000
*
60
*
60
}
private
fun
showAdDialogAndLoadInterstitial
(
activity
:
Activity
,
):
Dialog
?
{
var
customDialog
:
Dialog
?
=
null
if
(!
activity
.
isFinishing
&&
!
activity
.
isDestroyed
)
{
customDialog
=
CustomDialog
(
activity
,
R
.
layout
.
dialog_ad_loading
)
// 设置对话框的样式和内容
customDialog
.
show
()
}
return
customDialog
}
fun
loadInterstitialAd
(
activity
:
Activity
):
Boolean
{
setListener
(
activity
)
if
(!
AdDisplayUtils
.
getInstance
().
shouldShowAd
(
"interAd"
))
{
return
false
}
if
(
interstitialAd
?.
isReady
==
true
)
{
return
false
}
if
(
isAdInit
.
get
())
{
LogEx
.
logDebug
(
TAG
,
"loadInterstitialAd"
)
val
reqId
=
UUID
.
randomUUID
().
toString
()
val
obj
=
JSONObject
()
obj
.
put
(
"req_id"
,
reqId
)
obj
.
put
(
"ad_type"
,
"interAd"
)
EventUtils
.
event
(
"ad_pull_start"
,
ext
=
obj
)
interstitialAd
?.
loadAd
()
AdDisplayUtils
.
getInstance
().
incrementAdRequestCount
()
return
true
}
else
{
EventUtils
.
event
(
"isAdInit"
,
value
=
"loadInterstitialAd isAdInit=${isAdInit.get()}"
)
}
return
false
}
}
\ No newline at end of file
app/src/main/java/com/base/filerecoveryrecyclebin/ads/max/AdMaxNativeUtils.kt
View file @
2c0cd27f
package
com.base.filerecoveryrecyclebin.ads.max
//package com.base.filerecoveryrecyclebin.ads.max
//
import
android.app.Activity
//import android.app.Activity
import
android.content.Context
//import android.content.Context
import
android.view.ViewGroup
//import android.view.ViewGroup
import
androidx.core.view.isVisible
//import androidx.core.view.isVisible
import
com.applovin.mediation.MaxAd
//import com.applovin.mediation.MaxAd
import
com.applovin.mediation.MaxError
//import com.applovin.mediation.MaxError
import
com.applovin.mediation.nativeAds.MaxNativeAdListener
//import com.applovin.mediation.nativeAds.MaxNativeAdListener
import
com.applovin.mediation.nativeAds.MaxNativeAdLoader
//import com.applovin.mediation.nativeAds.MaxNativeAdLoader
import
com.applovin.mediation.nativeAds.MaxNativeAdView
//import com.applovin.mediation.nativeAds.MaxNativeAdView
import
com.applovin.mediation.nativeAds.MaxNativeAdViewBinder
//import com.applovin.mediation.nativeAds.MaxNativeAdViewBinder
import
com.base.filerecoveryrecyclebin.R
//import com.base.filerecoveryrecyclebin.R
import
com.base.filerecoveryrecyclebin.ads.AdDisplayUtils
//import com.base.filerecoveryrecyclebin.ads.AdDisplayUtils
import
com.base.filerecoveryrecyclebin.ads.admob.AdmobCommonUtils
//import com.base.filerecoveryrecyclebin.help.BaseApplication
import
com.base.filerecoveryrecyclebin.help.BaseApplication
//import com.base.filerecoveryrecyclebin.help.ConfigHelper
import
com.base.filerecoveryrecyclebin.help.ConfigHelper
//import com.base.filerecoveryrecyclebin.utils.EventUtils
import
com.base.filerecoveryrecyclebin.utils.EventUtils
//import com.base.filerecoveryrecyclebin.utils.LogEx
import
com.base.filerecoveryrecyclebin.utils.LogEx
//import org.json.JSONObject
import
org.json.JSONObject
//
//object AdMaxNativeUtils {
object
AdMaxNativeUtils
{
//
// private val TAG = "AdMaxNativeUtils"
private
val
TAG
=
"AdMaxNativeUtils"
// private var nativeAdLoader: MaxNativeAdLoader = MaxNativeAdLoader(ConfigHelper.nativeAdMaxId, BaseApplication.context)
private
var
nativeAdLoader
:
MaxNativeAdLoader
=
MaxNativeAdLoader
(
ConfigHelper
.
nativeAdMaxId
,
BaseApplication
.
context
)
// private var nativeAd: MaxAd? = null
private
var
nativeAd
:
MaxAd
?
=
null
// private var nativeLoadTime = Long.MAX_VALUE
private
var
nativeLoadTime
=
Long
.
MAX_VALUE
// private var haveSetAdListener: Boolean = false
private
var
haveSetAdListener
:
Boolean
=
false
// private var loadingListener: (() -> Unit)? = null
private
var
loadingListener
:
(()
->
Unit
)?
=
null
// private var activityString: String = ""
private
var
activityString
:
String
=
""
// private fun setNativeAdListener() {
private
fun
setNativeAdListener
()
{
// if (!haveSetAdListener) {
if
(!
haveSetAdListener
)
{
// //加载展示监听
//加载展示监听
// nativeAdLoader.setNativeAdListener(object : MaxNativeAdListener() {
nativeAdLoader
.
setNativeAdListener
(
object
:
MaxNativeAdListener
()
{
// override fun onNativeAdLoaded(nativeAdView: MaxNativeAdView?, ad: MaxAd) {
override
fun
onNativeAdLoaded
(
nativeAdView
:
MaxNativeAdView
?,
ad
:
MaxAd
)
{
// LogEx.logDebug(TAG, "onNativeAdLoaded")
LogEx
.
logDebug
(
TAG
,
"onNativeAdLoaded"
)
// // Cleanup any pre-existing native ad to prevent memory leaks.
// Cleanup any pre-existing native ad to prevent memory leaks.
// if (nativeAd?.nativeAd?.isExpired == true) {
if
(
nativeAd
?.
nativeAd
?.
isExpired
==
true
)
{
// nativeAdLoader.destroy(nativeAd)
nativeAdLoader
.
destroy
(
nativeAd
)
// }
}
//
// // Save ad to be rendered later.
// Save ad to be rendered later.
// nativeAd = ad
nativeAd
=
ad
// nativeLoadTime = System.currentTimeMillis()
nativeLoadTime
=
System
.
currentTimeMillis
()
// loadingListener?.invoke()
loadingListener
?.
invoke
()
// loadingListener = null
loadingListener
=
null
// }
}
//
// override fun onNativeAdLoadFailed(p0: String, p1: MaxError) {
override
fun
onNativeAdLoadFailed
(
p0
:
String
,
p1
:
MaxError
)
{
// super.onNativeAdLoadFailed(p0, p1)
super
.
onNativeAdLoadFailed
(
p0
,
p1
)
// loadingListener?.invoke()
loadingListener
?.
invoke
()
// loadingListener = null
loadingListener
=
null
// LogEx.logDebug(TAG, "onNativeAdLoadFailed")
LogEx
.
logDebug
(
TAG
,
"onNativeAdLoadFailed"
)
// LogEx.logDebug(TAG, "code=${p1.code}")
LogEx
.
logDebug
(
TAG
,
"code=${p1.code}"
)
// LogEx.logDebug(TAG, "message=${p1.message}")
LogEx
.
logDebug
(
TAG
,
"message=${p1.message}"
)
//// AdDisplayUtils.getInstance().incrementAdRequestFailCount()
// AdDisplayUtils.getInstance().incrementAdRequestFailCount()
// val obj2 = JSONObject()
val
obj2
=
JSONObject
()
// obj2.put("reason", "no_ad")
obj2
.
put
(
"reason"
,
"no_ad"
)
// obj2.put("ad_unit", "nativeAd")
obj2
.
put
(
"ad_unit"
,
"nativeAd"
)
// EventUtils.event("ad_show_error", ext = obj2)
EventUtils
.
event
(
"ad_show_error"
,
ext
=
obj2
)
// }
}
//
// override fun onNativeAdClicked(p0: MaxAd) {
override
fun
onNativeAdClicked
(
p0
:
MaxAd
)
{
// super.onNativeAdClicked(p0)
super
.
onNativeAdClicked
(
p0
)
// LogEx.logDebug(TAG, "onNativeAdClicked")
LogEx
.
logDebug
(
TAG
,
"onNativeAdClicked"
)
//// AdDisplayUtils.getInstance().incrementAdClickCount()
// AdDisplayUtils.getInstance().incrementAdClickCount()
// nativeAd?.let { AdMaxEvent.clickAd(it, "nativeAd") }
nativeAd
?.
let
{
AdMaxEvent
.
clickAd
(
it
,
"nativeAd"
)
}
// }
AdmobCommonUtils
.
isMultiClick
(
nativeAd
)
//
}
// override fun onNativeAdExpired(p0: MaxAd) {
// super.onNativeAdExpired(p0)
override
fun
onNativeAdExpired
(
p0
:
MaxAd
)
{
// }
super
.
onNativeAdExpired
(
p0
)
// })
}
//
})
//
// //广告价格监听
// nativeAdLoader.setRevenueListener { ad ->
//广告价格监听
//
nativeAdLoader
.
setRevenueListener
{
ad
->
// }
//
}
//
// haveSetAdListener = true
//
haveSetAdListener
=
true
//
// }
// }
}
//
}
// private fun createNativeAdView(context: Context, layout: Int): MaxNativeAdView {
//
private
fun
createNativeAdView
(
context
:
Context
,
layout
:
Int
):
MaxNativeAdView
{
//// val binder: MaxNativeAdViewBinder = MaxNativeAdViewBinder.Builder(R.layout.layout_max_native_custom)
//// .setTitleTextViewId(R.id.title_text_view)
// val binder: MaxNativeAdViewBinder = MaxNativeAdViewBinder.Builder(R.layout.layout_max_native_custom)
//// .setBodyTextViewId(R.id.body_text_view)
// .setTitleTextViewId(R.id.title_text_view)
//// .setAdvertiserTextViewId(R.id.advertiser_text_view)
// .setBodyTextViewId(R.id.body_text_view)
//// .setIconImageViewId(R.id.icon_image_view)
// .setAdvertiserTextViewId(R.id.advertiser_text_view)
//// .setMediaContentViewGroupId(R.id.media_view_container)
// .setIconImageViewId(R.id.icon_image_view)
//// .setOptionsContentViewGroupId(R.id.options_view)
// .setMediaContentViewGroupId(R.id.media_view_container)
//// .setStarRatingContentViewGroupId(R.id.star_rating_view)
// .setOptionsContentViewGroupId(R.id.options_view)
//// .setCallToActionButtonId(R.id.cta_button)
// .setStarRatingContentViewGroupId(R.id.star_rating_view)
//// .build()
// .setCallToActionButtonId(R.id.cta_button)
//// return MaxNativeAdView(binder, context)
//
// val binder: MaxNativeAdViewBinder = MaxNativeAdViewBinder.Builder(layout)
// .setTitleTextViewId(R.id.ad_headline)
// .setBodyTextViewId(R.id.ad_body)
//// .setAdvertiserTextViewId(R.id.advertiser_text_view)
// .setIconImageViewId(R.id.ad_app_icon)
// .setMediaContentViewGroupId(R.id.ad_media)
//// .setOptionsContentViewGroupId(R.id.options_view)
//// .setStarRatingContentViewGroupId(R.id.star_rating_view)
// .setCallToActionButtonId(R.id.ad_call_to_action)
// .build()
// .build()
// return MaxNativeAdView(binder, context)
// return MaxNativeAdView(binder, context)
// }
val
binder
:
MaxNativeAdViewBinder
=
MaxNativeAdViewBinder
.
Builder
(
layout
)
//
.
setTitleTextViewId
(
R
.
id
.
ad_headline
)
// fun loadNativeAd() {
.
setBodyTextViewId
(
R
.
id
.
ad_body
)
// setNativeAdListener()
// .setAdvertiserTextViewId(R.id.advertiser_text_view)
// if (!AdDisplayUtils.getInstance().shouldShowAd("nativeAd")) {
.
setIconImageViewId
(
R
.
id
.
ad_app_icon
)
// return
.
setMediaContentViewGroupId
(
R
.
id
.
ad_media
)
// }
// .setOptionsContentViewGroupId(R.id.options_view)
// nativeAdLoader.loadAd()
// .setStarRatingContentViewGroupId(R.id.star_rating_view)
// }
.
setCallToActionButtonId
(
R
.
id
.
ad_call_to_action
)
//
.
build
()
//
return
MaxNativeAdView
(
binder
,
context
)
// fun showNativeAd(activity: Activity, parent: ViewGroup, layout: Int) {
}
// activityString = activity::class.java.toString().split(".").last()
// LogEx.logDebug(TAG, "activityString=$activityString")
fun
loadNativeAd
()
{
// setNativeAdListener()
setNativeAdListener
()
//
if
(!
AdDisplayUtils
.
getInstance
().
shouldShowAd
(
"nativeAd"
))
{
// if (!AdDisplayUtils.getInstance().shouldShowAd("nativeAd")) {
return
// LogEx.logDebug(TAG, "!shouldShowAd")
}
// return
nativeAdLoader
.
loadAd
()
// }
}
//
// if (nativeAd?.nativeAd?.isExpired == true || nativeAd == null) {
// LogEx.logDebug(TAG, "nativeAd?.nativeAd?.isExpired == true")
fun
showNativeAd
(
activity
:
Activity
,
parent
:
ViewGroup
,
layout
:
Int
)
{
// nativeAdLoader.destroy(nativeAd)
activityString
=
activity
::
class
.
java
.
toString
().
split
(
"."
).
last
()
// nativeAdLoader.loadAd()
LogEx
.
logDebug
(
TAG
,
"activityString=$activityString"
)
// loadingListener = {
setNativeAdListener
()
// if (nativeAd != null) {
// showReadyNative(activity, parent, layout)
if
(!
AdDisplayUtils
.
getInstance
().
shouldShowAd
(
"nativeAd"
))
{
// }
LogEx
.
logDebug
(
TAG
,
"!shouldShowAd"
)
// }
return
// } else {
}
// showReadyNative(activity, parent, layout)
// }
if
(
nativeAd
?.
nativeAd
?.
isExpired
==
true
||
nativeAd
==
null
)
{
//
LogEx
.
logDebug
(
TAG
,
"nativeAd?.nativeAd?.isExpired == true"
)
// }
nativeAdLoader
.
destroy
(
nativeAd
)
//
nativeAdLoader
.
loadAd
()
// private fun showReadyNative(activity: Activity, parent: ViewGroup, layout: Int) {
loadingListener
=
{
// val adView = createNativeAdView(activity, layout)
if
(
nativeAd
!=
null
)
{
//
showReadyNative
(
activity
,
parent
,
layout
)
// LogEx.logDebug(TAG, "showReadNative adUnitId=${nativeAd?.adUnitId}")
}
// parent.isVisible = true
}
// parent.removeAllViews()
}
else
{
// nativeAdLoader.render(adView, nativeAd)
showReadyNative
(
activity
,
parent
,
layout
)
// parent.addView(adView)
}
// nativeAd?.let { AdMaxEvent.showAd(it, "nativeAd", activityString) }
//// AdDisplayUtils.getInstance().incrementAdDisplayCount()
}
//
// LogEx.logDebug(TAG, "loadingListener finish")
private
fun
showReadyNative
(
activity
:
Activity
,
parent
:
ViewGroup
,
layout
:
Int
)
{
// }
val
adView
=
createNativeAdView
(
activity
,
layout
)
//
//}
LogEx
.
logDebug
(
TAG
,
"showReadNative adUnitId=${nativeAd?.adUnitId}"
)
\ No newline at end of file
parent
.
isVisible
=
true
parent
.
removeAllViews
()
nativeAdLoader
.
render
(
adView
,
nativeAd
)
parent
.
addView
(
adView
)
nativeAd
?.
let
{
AdMaxEvent
.
showAd
(
it
,
"nativeAd"
,
activityString
)
}
// AdDisplayUtils.getInstance().incrementAdDisplayCount()
LogEx
.
logDebug
(
TAG
,
"loadingListener finish"
)
}
}
\ No newline at end of file
app/src/main/java/com/base/filerecoveryrecyclebin/ads/max/AdMaxOpenUtils.kt
View file @
2c0cd27f
package
com.base.filerecoveryrecyclebin.ads.max
//package com.base.filerecoveryrecyclebin.ads.max
//
import
android.app.Activity
//import android.app.Activity
import
com.applovin.mediation.MaxAd
//import com.applovin.mediation.MaxAd
import
com.applovin.mediation.MaxAdListener
//import com.applovin.mediation.MaxAdListener
import
com.applovin.mediation.MaxError
//import com.applovin.mediation.MaxError
import
com.applovin.mediation.ads.MaxAppOpenAd
//import com.applovin.mediation.ads.MaxAppOpenAd
import
com.base.filerecoveryrecyclebin.MyApplication.Companion.isInterOpenShowing
//import com.base.filerecoveryrecyclebin.MyApplication.Companion.isInterOpenShowing
import
com.base.filerecoveryrecyclebin.ads.AdDisplayUtils
//import com.base.filerecoveryrecyclebin.ads.AdDisplayUtils
import
com.base.filerecoveryrecyclebin.ads.AdmobMaxHelper
//import com.base.filerecoveryrecyclebin.ads.AdmobMaxHelper.isAdInit
import
com.base.filerecoveryrecyclebin.ads.AdmobMaxHelper.isAdInit
//import com.base.filerecoveryrecyclebin.help.ConfigHelper
import
com.base.filerecoveryrecyclebin.ads.admob.AdmobCommonUtils
//import com.base.filerecoveryrecyclebin.utils.EventUtils
import
com.base.filerecoveryrecyclebin.help.ConfigHelper
//import com.base.filerecoveryrecyclebin.utils.LogEx
import
com.base.filerecoveryrecyclebin.utils.EventUtils
//import org.json.JSONObject
import
com.base.filerecoveryrecyclebin.utils.LogEx
//import java.util.UUID
import
org.json.JSONObject
//
import
java.util.UUID
//object AdMaxOpenUtils {
// private val TAG = "AdMaxOpenUtils"
object
AdMaxOpenUtils
{
// private var appOpenAd: MaxAppOpenAd? = null
private
val
TAG
=
"AdMaxOpenUtils"
// private var openLoadTime = Long.MAX_VALUE
private
var
appOpenAd
:
MaxAppOpenAd
?
=
null
// private var onHidden: (() -> Unit)? = null
private
var
openLoadTime
=
Long
.
MAX_VALUE
// private var loadingListener: ((flag: Boolean) -> Unit)? = null
private
var
onHidden
:
(()
->
Unit
)?
=
null
// private var activityString = ""
private
var
loadingListener
:
((
flag
:
Boolean
)
->
Unit
)?
=
null
//
private
var
activityString
=
""
// private fun setListener(activity: Activity) {
// activityString = activity::class.java.toString().split(".").last()
private
fun
setListener
(
activity
:
Activity
)
{
// if (appOpenAd == null) {
activityString
=
activity
::
class
.
java
.
toString
().
split
(
"."
).
last
()
// appOpenAd = MaxAppOpenAd(ConfigHelper.openAdMaxId, activity)
if
(
appOpenAd
==
null
)
{
//
appOpenAd
=
MaxAppOpenAd
(
ConfigHelper
.
openAdMaxId
,
activity
)
// appOpenAd?.setListener(object : MaxAdListener {
// override fun onAdLoaded(p0: MaxAd) {
appOpenAd
?.
setListener
(
object
:
MaxAdListener
{
// LogEx.logDebug(TAG, "广告拉取成功")
override
fun
onAdLoaded
(
p0
:
MaxAd
)
{
// openLoadTime = System.currentTimeMillis()
LogEx
.
logDebug
(
TAG
,
"广告拉取成功"
)
// loadingListener?.invoke(true)
openLoadTime
=
System
.
currentTimeMillis
()
// loadingListener = null
loadingListener
?.
invoke
(
true
)
// AdMaxEvent.pullAd(p0, "openAd")
loadingListener
=
null
// }
AdMaxEvent
.
pullAd
(
p0
,
"openAd"
)
//
}
// override fun onAdLoadFailed(p0: String, p1: MaxError) {
// LogEx.logDebug(TAG, "广告拉取失败了,onAdLoadFailed:" + p0)
override
fun
onAdLoadFailed
(
p0
:
String
,
p1
:
MaxError
)
{
// LogEx.logDebug(TAG, "广告拉取失败了,onAdLoadFailed:" + p1.message.toString())
LogEx
.
logDebug
(
TAG
,
"广告拉取失败了,onAdLoadFailed:"
+
p0
)
// LogEx.logDebug(TAG, "广告拉取失败了,onAdLoadFailed:" + p1.code)
LogEx
.
logDebug
(
TAG
,
"广告拉取失败了,onAdLoadFailed:"
+
p1
.
message
.
toString
())
// loadingListener?.invoke(false)
LogEx
.
logDebug
(
TAG
,
"广告拉取失败了,onAdLoadFailed:"
+
p1
.
code
)
// loadingListener = null
loadingListener
?.
invoke
(
false
)
// AdDisplayUtils.getInstance().incrementAdRequestFailCount()
loadingListener
=
null
// val reqId = UUID.randomUUID().toString()
AdDisplayUtils
.
getInstance
().
incrementAdRequestFailCount
()
// AdMaxEvent.pullAd(null, "openAd", reqId = reqId, error = p1.message, code = p1.code)
val
reqId
=
UUID
.
randomUUID
().
toString
()
// }
AdMaxEvent
.
pullAd
(
null
,
"openAd"
,
reqId
=
reqId
,
error
=
p1
.
message
,
code
=
p1
.
code
)
//
}
// override fun onAdDisplayed(p0: MaxAd) {
// AdDisplayUtils.getInstance().incrementAdDisplayCount()
override
fun
onAdDisplayed
(
p0
:
MaxAd
)
{
// AdMaxEvent.showAd(p0, "openAd", activityString)
AdDisplayUtils
.
getInstance
().
incrementAdDisplayCount
()
//
AdMaxEvent
.
showAd
(
p0
,
"openAd"
,
activityString
)
// isInterOpenShowing = true
// }
isInterOpenShowing
=
true
//
}
// override fun onAdHidden(p0: MaxAd) {
// LogEx.logDebug(TAG, "onAdHidden")
override
fun
onAdHidden
(
p0
:
MaxAd
)
{
// onHidden?.invoke()
LogEx
.
logDebug
(
TAG
,
"onAdHidden"
)
// onHidden = null
onHidden
?.
invoke
()
// loadAppOpenAd(activity)
onHidden
=
null
//
loadAppOpenAd
(
activity
)
// isInterOpenShowing = false
// }
isInterOpenShowing
=
false
//
}
// override fun onAdDisplayFailed(p0: MaxAd, p1: MaxError) {
// LogEx.logDebug(TAG, "onAdDisplayFailed")
override
fun
onAdDisplayFailed
(
p0
:
MaxAd
,
p1
:
MaxError
)
{
// onHidden?.invoke()
LogEx
.
logDebug
(
TAG
,
"onAdDisplayFailed"
)
// onHidden = null
onHidden
?.
invoke
()
// loadAppOpenAd(activity)
onHidden
=
null
// val obj = JSONObject()
loadAppOpenAd
(
activity
)
// obj.put("code", p1.code)
val
obj
=
JSONObject
()
// obj.put("reason", p1.message)
obj
.
put
(
"code"
,
p1
.
code
)
// obj.put("ad_unit", "openAd")
obj
.
put
(
"reason"
,
p1
.
message
)
// EventUtils.event("ad_show_error", ext = obj)
obj
.
put
(
"ad_unit"
,
"openAd"
)
//
EventUtils
.
event
(
"ad_show_error"
,
ext
=
obj
)
// isInterOpenShowing = false
// }
isInterOpenShowing
=
false
//
}
// override fun onAdClicked(p0: MaxAd) {
// AdDisplayUtils.getInstance().incrementAdClickCount()
override
fun
onAdClicked
(
p0
:
MaxAd
)
{
// AdMaxEvent.clickAd(p0, "openAd")
AdDisplayUtils
.
getInstance
().
incrementAdClickCount
()
// }
AdmobCommonUtils
.
isMultiClick
(
appOpenAd
)
//
AdMaxEvent
.
clickAd
(
p0
,
"openAd"
)
// })
}
//
// appOpenAd?.setRevenueListener(AdMaxEvent.EventOnPaidEventListener())
})
// }
// }
appOpenAd
?.
setRevenueListener
(
AdMaxEvent
.
EventOnPaidEventListener
())
//
}
// fun showAppOpenAd(
}
// activity: Activity,
// loadCallBack: ((loaded: Boolean) -> Unit)? = null,
fun
showAppOpenAd
(
// onHidden: (() -> Unit)? = null
activity
:
Activity
,
// ) {
loadCallBack
:
((
loaded
:
Boolean
)
->
Unit
)?
=
null
,
//
onHidden
:
(()
->
Unit
)?
=
null
// setListener(activity)
)
{
//
// if (activity.isFinishing || activity.isDestroyed) {
setListener
(
activity
)
// return
// }
if
(
activity
.
isFinishing
||
activity
.
isDestroyed
)
{
//
return
// if (!AdDisplayUtils.getInstance().shouldShowAd("openAd")) {
}
// LogEx.logDebug(TAG, "!shouldShowAd")
if
(!
AdDisplayUtils
.
getInstance
().
shouldShowAd
(
"openAd"
))
{
LogEx
.
logDebug
(
TAG
,
"!shouldShowAd"
)
onHidden
?.
invoke
()
return
}
if
(
System
.
currentTimeMillis
()
-
openLoadTime
>
1000
*
60
*
60
)
{
LogEx
.
logDebug
(
TAG
,
"openLoadTime > "
)
onHidden
?.
invoke
()
val
obj2
=
JSONObject
()
obj2
.
put
(
"ad_unit"
,
"openAd"
)
EventUtils
.
event
(
"ad_expire"
,
ext
=
obj2
)
appOpenAd
?.
loadAd
()
}
// if (!isAdInit.get()) {
// EventUtils.event("isAdInit", value = "showAppOpenAd isAdInit=${isAdInit.get()}")
// onHidden?.invoke()
// onHidden?.invoke()
// return
// return
// }
// }
//
// if (System.currentTimeMillis() - openLoadTime > 1000 * 60 * 60) {
LogEx
.
logDebug
(
TAG
,
"showAppOpenAd"
)
// LogEx.logDebug(TAG, "openLoadTime > ")
val
obj1
=
JSONObject
()
// onHidden?.invoke()
obj1
.
put
(
"ad_unit"
,
"openAd"
)
// val obj2 = JSONObject()
EventUtils
.
event
(
"ad_prepare_show"
,
ext
=
obj1
)
// obj2.put("ad_unit", "openAd")
// EventUtils.event("ad_expire", ext = obj2)
isInterOpenShowing
=
false
// appOpenAd?.loadAd()
// }
if
(
appOpenAd
?.
isReady
==
true
)
{
//
LogEx
.
logDebug
(
TAG
,
"广告准备好了,展示广告"
)
//
AdMaxOpenUtils
.
onHidden
=
onHidden
//
appOpenAd
?.
showAd
()
// LogEx.logDebug(TAG, "showAppOpenAd")
}
else
{
// val obj1 = JSONObject()
val
obj
=
JSONObject
()
// obj1.put("ad_unit", "openAd")
obj
.
put
(
"reason"
,
"no cache ad"
)
// EventUtils.event("ad_prepare_show", ext = obj1)
obj
.
put
(
"ad_unit"
,
"openAd"
)
//
EventUtils
.
event
(
"ad_nocache_pull"
,
ext
=
obj
)
// isInterOpenShowing = false
LogEx
.
logDebug
(
TAG
,
"展示时候,发现广告需要拉取"
)
//
val
loaded
=
loadAppOpenAd
(
activity
)
// if (appOpenAd?.isReady == true) {
if
(
loaded
)
{
// LogEx.logDebug(TAG, "广告准备好了,展示广告")
loadingListener
=
{
loadResult
->
// AdMaxOpenUtils.onHidden = onHidden
loadCallBack
?.
invoke
(
loadResult
)
// appOpenAd?.showAd()
LogEx
.
logDebug
(
TAG
,
"loadingListener callback"
)
// } else {
if
(
appOpenAd
?.
isReady
==
true
)
{
// val obj = JSONObject()
AdMaxOpenUtils
.
onHidden
=
onHidden
// obj.put("reason", "no cache ad")
appOpenAd
?.
showAd
()
// obj.put("ad_unit", "openAd")
}
else
{
// EventUtils.event("ad_nocache_pull", ext = obj)
onHidden
?.
invoke
()
// LogEx.logDebug(TAG, "展示时候,发现广告需要拉取")
}
// val loaded = loadAppOpenAd(activity)
}
// if (loaded) {
}
else
{
// loadingListener = { loadResult ->
onHidden
?.
invoke
()
// loadCallBack?.invoke(loadResult)
}
// LogEx.logDebug(TAG, "loadingListener callback")
// if (appOpenAd?.isReady == true) {
}
// AdMaxOpenUtils.onHidden = onHidden
}
// appOpenAd?.showAd()
// } else {
fun
loadAppOpenAd
(
activity
:
Activity
):
Boolean
{
// onHidden?.invoke()
setListener
(
activity
)
// }
// }
if
(!
AdDisplayUtils
.
getInstance
().
shouldShowAd
(
"openAd"
))
{
// } else {
LogEx
.
logDebug
(
TAG
,
"!shouldShowAd"
)
// onHidden?.invoke()
return
false
// }
}
//
if
(
appOpenAd
?.
isReady
==
true
)
{
// }
LogEx
.
logDebug
(
TAG
,
"appOpenAd?.isReady == true"
)
// }
return
false
//
}
// fun loadAppOpenAd(activity: Activity): Boolean {
// setListener(activity)
if
(
isAdInit
.
get
())
{
//
val
reqId
=
UUID
.
randomUUID
().
toString
()
// if (!AdDisplayUtils.getInstance().shouldShowAd("openAd")) {
val
obj
=
JSONObject
()
// LogEx.logDebug(TAG, "!shouldShowAd")
obj
.
put
(
"req_id"
,
reqId
)
// return false
obj
.
put
(
"ad_type"
,
"openAd"
)
// }
EventUtils
.
event
(
"ad_pull_start"
,
ext
=
obj
)
//
appOpenAd
?.
loadAd
()
// val reqId = UUID.randomUUID().toString()
AdDisplayUtils
.
getInstance
().
incrementAdRequestCount
()
// val obj = JSONObject()
return
true
// obj.put("req_id", reqId)
}
else
{
// obj.put("ad_type", "openAd")
EventUtils
.
event
(
"isAdInit"
,
value
=
"loadAppOpenAd isAdInit=${isAdInit.get()}"
)
// EventUtils.event("ad_pull_start", ext = obj)
}
// appOpenAd?.loadAd()
return
false
// AdDisplayUtils.getInstance().incrementAdRequestCount()
}
// return true
// }
fun
isOpenAdLoaded
():
Boolean
{
//
return
appOpenAd
?.
isReady
==
true
// fun isOpenAdLoaded(): Boolean {
}
// return appOpenAd?.isReady == true
// }
}
//
//}
//
app/src/main/java/com/base/filerecoveryrecyclebin/bean/RecycleBinBean.kt
View file @
2c0cd27f
...
@@ -2,14 +2,16 @@ package com.base.filerecoveryrecyclebin.bean
...
@@ -2,14 +2,16 @@ package com.base.filerecoveryrecyclebin.bean
data class
RecycleBinBean
(
data class
RecycleBinBean
(
val
name
:
String
=
""
,
val
name
Path
:
String
=
""
,
//文件名称,sp的key,容易重复,所已会覆盖之前的文件
val
path
:
String
=
""
,
val
path
:
String
=
""
,
//原文件路径
val
backupPath
:
String
=
""
,
val
backupPath
:
String
=
""
,
//备份文件路径
var
deleteTime
:
Long
=
0
,
var
deleteTime
:
Long
=
0
,
val
size
:
Long
=
0
,
val
size
:
Long
=
0
,
val
mimeType
:
String
=
""
,
val
mimeType
:
String
=
""
,
var
deleted
:
Boolean
=
false
var
deleted
:
Boolean
=
false
)
{
)
{
companion
object
{
companion
object
{
val
mImageStr
:
Set
<
String
>
=
HashSet
(
val
mImageStr
:
Set
<
String
>
=
HashSet
(
mutableListOf
(
mutableListOf
(
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/fcm/FCMManager.java
deleted
100644 → 0
View file @
4ca82a26
package
com
.
base
.
filerecoveryrecyclebin
.
fcm
;
import
android.content.Context
;
import
android.util.Log
;
import
androidx.annotation.NonNull
;
import
com.base.filerecoveryrecyclebin.utils.EventUtils
;
import
com.google.android.gms.tasks.OnCompleteListener
;
import
com.google.android.gms.tasks.Task
;
import
com.google.firebase.FirebaseApp
;
import
com.google.firebase.messaging.FirebaseMessaging
;
public
class
FCMManager
{
public
static
void
initFirebase
(
Context
context
)
{
FirebaseApp
.
initializeApp
(
context
);
}
public
static
void
subscribeToTopic
(
String
topic
)
{
FirebaseMessaging
.
getInstance
().
subscribeToTopic
(
topic
)
.
addOnCompleteListener
(
new
OnCompleteListener
<
Void
>()
{
@Override
public
void
onComplete
(
@NonNull
Task
<
Void
>
task
)
{
if
(
task
.
isSuccessful
())
{
Log
.
d
(
"FCMUtil"
,
"suc:"
+
topic
);
EventUtils
.
INSTANCE
.
event
(
"FCM_Topic_"
+
topic
,
null
,
null
,
false
);
}
else
{
Log
.
d
(
"FCMUtil"
,
"fail"
);
}
}
});
}
public
static
void
unsubscribeFromTopic
(
String
topic
)
{
FirebaseMessaging
.
getInstance
().
unsubscribeFromTopic
(
topic
)
.
addOnCompleteListener
(
new
OnCompleteListener
<
Void
>()
{
@Override
public
void
onComplete
(
@NonNull
Task
<
Void
>
task
)
{
if
(
task
.
isSuccessful
())
{
}
else
{
}
}
});
}
}
app/src/main/java/com/base/filerecoveryrecyclebin/fcm/FCMManager.kt
0 → 100644
View file @
2c0cd27f
package
com.base.filerecoveryrecyclebin.fcm
import
android.content.Context
import
android.util.Log
import
com.base.filerecoveryrecyclebin.utils.AppPreferences
import
com.base.filerecoveryrecyclebin.utils.EventUtils
import
com.base.filerecoveryrecyclebin.utils.EventUtils.event
import
com.base.filerecoveryrecyclebin.utils.LogEx
import
com.google.android.gms.tasks.OnCompleteListener
import
com.google.android.gms.tasks.Task
import
com.google.firebase.FirebaseApp
import
com.google.firebase.messaging.FirebaseMessaging
import
org.json.JSONObject
object
FCMManager
{
fun
initFirebase
(
context
:
Context
?)
{
FirebaseApp
.
initializeApp
(
context
!!
)
getToken
()
}
fun
subscribeToTopic
(
topic
:
String
)
{
FirebaseMessaging
.
getInstance
().
subscribeToTopic
(
topic
)
.
addOnCompleteListener
{
task
->
if
(
task
.
isSuccessful
)
{
getToken
()
Log
.
d
(
"FCMUtil"
,
"suc:$topic"
)
event
(
"FCM_Topic_$topic"
,
null
,
null
,
false
)
}
else
{
Log
.
d
(
"FCMUtil"
,
"fail"
)
}
}
}
fun
unsubscribeFromTopic
(
topic
:
String
?)
{
FirebaseMessaging
.
getInstance
().
unsubscribeFromTopic
(
topic
!!
)
.
addOnCompleteListener
{
task
->
if
(
task
.
isSuccessful
)
{
}
else
{
}
}
}
fun
getToken
()
{
FirebaseMessaging
.
getInstance
().
token
.
addOnCompleteListener
(
object
:
OnCompleteListener
<
String
>
{
override
fun
onComplete
(
task
:
Task
<
String
>)
{
LogEx
.
logDebug
(
"FCM"
,
"onComplete ${task.isSuccessful}"
)
if
(!
task
.
isSuccessful
)
{
Log
.
e
(
"FCM"
,
"Fetching FCM registration token failed"
,
task
.
exception
)
return
}
// Get new FCM registration token
val
token
:
String
=
task
.
result
LogEx
.
logDebug
(
"FCM"
,
"token=$token"
)
val
json
=
JSONObject
()
json
.
put
(
"token"
,
token
)
EventUtils
.
event
(
"fcm_message_received"
,
ext
=
json
)
AppPreferences
.
getInstance
().
put
(
"token"
,
token
)
// Handle new token
Log
.
d
(
"FCM"
,
"FCM Registration Token: $token"
)
}
})
}
}
app/src/main/java/com/base/filerecoveryrecyclebin/fcm/FcmReceiver.java
View file @
2c0cd27f
...
@@ -4,11 +4,16 @@ import android.content.BroadcastReceiver;
...
@@ -4,11 +4,16 @@ import android.content.BroadcastReceiver;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.Intent
;
import
com.base.filerecoveryrecyclebin.MyApplication
;
import
com.base.filerecoveryrecyclebin.utils.EventUtils
;
public
class
FcmReceiver
extends
BroadcastReceiver
{
public
class
FcmReceiver
extends
BroadcastReceiver
{
@Override
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
EventUtils
.
INSTANCE
.
event
(
"FCM_Received"
,
"FcmReceiver"
,
null
,
false
);
NotificationUtil
.
INSTANCE
.
sendNotification
(
MyApplication
.
context
,
"FcmReceiver"
);
}
}
}
}
app/src/main/java/com/base/filerecoveryrecyclebin/fcm/MessagingService.java
View file @
2c0cd27f
...
@@ -11,6 +11,9 @@ import com.base.filerecoveryrecyclebin.utils.EventUtils;
...
@@ -11,6 +11,9 @@ import com.base.filerecoveryrecyclebin.utils.EventUtils;
import
com.google.firebase.messaging.FirebaseMessagingService
;
import
com.google.firebase.messaging.FirebaseMessagingService
;
import
com.google.firebase.messaging.RemoteMessage
;
import
com.google.firebase.messaging.RemoteMessage
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
java.util.Map
;
import
java.util.Map
;
@SuppressLint
(
"MissingFirebaseInstanceTokenRefresh"
)
@SuppressLint
(
"MissingFirebaseInstanceTokenRefresh"
)
...
@@ -25,7 +28,24 @@ public class MessagingService extends FirebaseMessagingService {
...
@@ -25,7 +28,24 @@ public class MessagingService extends FirebaseMessagingService {
// manageTimerBasedOnMessage(remoteMessage.getData());
// manageTimerBasedOnMessage(remoteMessage.getData());
// AdDisplayUtils.getInstance().saveSp();
// AdDisplayUtils.getInstance().saveSp();
EventUtils
.
INSTANCE
.
event
(
"FCM_Received"
,
null
,
null
,
false
);
String
id
=
remoteMessage
.
getMessageId
();
JSONObject
ext
=
new
JSONObject
();
try
{
ext
.
put
(
"getMessageType"
,
remoteMessage
.
getMessageType
());
ext
.
put
(
"getData"
,
remoteMessage
.
getData
());
ext
.
put
(
"getCollapseKey"
,
remoteMessage
.
getCollapseKey
());
ext
.
put
(
"getFrom"
,
remoteMessage
.
getFrom
());
ext
.
put
(
"getPriority"
,
remoteMessage
.
getPriority
());
ext
.
put
(
"getSenderId"
,
remoteMessage
.
getSenderId
());
ext
.
put
(
"getSentTime"
,
remoteMessage
.
getSentTime
());
}
catch
(
JSONException
e
)
{
EventUtils
.
INSTANCE
.
event
(
"FCM_Received_Error"
,
id
,
ext
,
false
);
throw
new
RuntimeException
(
e
);
}
finally
{
}
EventUtils
.
INSTANCE
.
event
(
"FCM_Received"
,
id
,
ext
,
false
);
sendLocalNotification
();
sendLocalNotification
();
}
}
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/fcm/NotificationUtil.kt
View file @
2c0cd27f
...
@@ -266,13 +266,13 @@ object NotificationUtil {
...
@@ -266,13 +266,13 @@ object NotificationUtil {
for
(
i
in
1
..
num
)
{
for
(
i
in
1
..
num
)
{
val
time
=
i
*
delay
val
time
=
i
*
delay
handler
?.
postDelayed
(
Runnable
{
handler
?.
postDelayed
(
Runnable
{
if
(
MyApplication
.
PAUSED_VALUE
==
=
1
)
{
if
(
MyApplication
.
PAUSED_VALUE
==
1
)
{
if
(
handler
!=
null
)
{
if
(
handler
!=
null
)
{
handler
?.
removeCallbacksAndMessages
(
null
)
handler
?.
removeCallbacksAndMessages
(
null
)
}
}
return
@Runnable
return
@Runnable
}
}
if
(
MyApplication
.
PAUSED_VALUE
!=
=
1
&&
ScreenStatusReceiver
.
isDeviceInteractive
()
&&
!
ScreenStatusReceiver
.
isSecureLockActive
())
{
if
(
MyApplication
.
PAUSED_VALUE
!=
1
&&
ScreenStatusReceiver
.
isDeviceInteractive
()
&&
!
ScreenStatusReceiver
.
isSecureLockActive
())
{
sendNotification
(
context
,
actionId
)
sendNotification
(
context
,
actionId
)
}
}
},
time
)
},
time
)
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/fragment/HomeFragment.kt
View file @
2c0cd27f
...
@@ -60,7 +60,7 @@ class HomeFragment : BaseFragment<FragmentHome3Binding>() {
...
@@ -60,7 +60,7 @@ class HomeFragment : BaseFragment<FragmentHome3Binding>() {
binding
.
tvDuplicateSize
.
visibility
=
View
.
VISIBLE
binding
.
tvDuplicateSize
.
visibility
=
View
.
VISIBLE
binding
.
tvDuplicateSize
.
text
=
pair
.
second
.
toFormatSize
()
binding
.
tvDuplicateSize
.
text
=
pair
.
second
.
toFormatSize
()
}
else
{
}
else
{
binding
.
tvDuplicateSize
.
visibility
=
View
.
VISIBL
E
binding
.
tvDuplicateSize
.
visibility
=
View
.
GON
E
}
}
}
}
}
}
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/
utils
/InstallHelps.kt
→
app/src/main/java/com/base/filerecoveryrecyclebin/
help
/InstallHelps.kt
View file @
2c0cd27f
package
com.base.filerecoveryrecyclebin.
utils
package
com.base.filerecoveryrecyclebin.
help
import
android.os.Build
import
android.os.Build
import
android.text.TextUtils
import
androidx.annotation.RequiresApi
import
androidx.annotation.RequiresApi
import
com.android.installreferrer.api.InstallReferrerClient
import
com.android.installreferrer.api.InstallReferrerClient
import
com.android.installreferrer.api.InstallReferrerStateListener
import
com.android.installreferrer.api.InstallReferrerStateListener
...
@@ -9,7 +8,8 @@ import com.base.filerecoveryrecyclebin.BuildConfig
...
@@ -9,7 +8,8 @@ import com.base.filerecoveryrecyclebin.BuildConfig
import
com.base.filerecoveryrecyclebin.ads.AdmobMaxHelper
import
com.base.filerecoveryrecyclebin.ads.AdmobMaxHelper
import
com.base.filerecoveryrecyclebin.fcm.RecoveryTimerManager
import
com.base.filerecoveryrecyclebin.fcm.RecoveryTimerManager
import
com.base.filerecoveryrecyclebin.fcm.ScreenStatusReceiver
import
com.base.filerecoveryrecyclebin.fcm.ScreenStatusReceiver
import
com.base.filerecoveryrecyclebin.help.BaseApplication
import
com.base.filerecoveryrecyclebin.utils.AppPreferences
import
com.base.filerecoveryrecyclebin.utils.EventUtils
import
org.json.JSONObject
import
org.json.JSONObject
/**
/**
...
@@ -19,22 +19,21 @@ object InstallHelps {
...
@@ -19,22 +19,21 @@ object InstallHelps {
private
val
TAG
=
"InstallHelps"
private
val
TAG
=
"InstallHelps"
fun
init
()
{
fun
init
()
=
Thread
{
//InstallReferrer not empty
//InstallReferrer not empty
if
(!
TextUtils
.
isEmpty
(
AppPreferences
.
getInstance
().
getString
(
"install_source"
,
""
)))
{
//
if (!TextUtils.isEmpty(AppPreferences.getInstance().getString("install_source", ""))) {
if
(
AdmobMaxHelper
.
haveSpAdmobTrueMaxFalse
())
{
//
if (AdmobMaxHelper.haveSpAdmobTrueMaxFalse()) {
AdmobMaxHelper
.
initAdmobMaxAd
()
//
AdmobMaxHelper.initAdmobMaxAd()
requestCfg
(
false
)
//
requestCfg(false)
}
else
{
//
} else {
requestCfg
(
true
)
//
requestCfg(true)
}
//
}
return
//
return
}
//
}
val
referrerClient
=
InstallReferrerClient
.
newBuilder
(
BaseApplication
.
context
).
build
()
val
referrerClient
=
InstallReferrerClient
.
newBuilder
(
BaseApplication
.
context
).
build
()
referrerClient
.
startConnection
(
object
:
InstallReferrerStateListener
{
referrerClient
.
startConnection
(
object
:
InstallReferrerStateListener
{
@RequiresApi
(
Build
.
VERSION_CODES
.
O
)
override
fun
onInstallReferrerSetupFinished
(
responseCode
:
Int
)
{
override
fun
onInstallReferrerSetupFinished
(
responseCode
:
Int
)
{
try
{
try
{
when
(
responseCode
)
{
when
(
responseCode
)
{
...
@@ -50,9 +49,9 @@ object InstallHelps {
...
@@ -50,9 +49,9 @@ object InstallHelps {
AppPreferences
.
getInstance
().
put
(
"referrer"
,
response
.
installReferrer
)
AppPreferences
.
getInstance
().
put
(
"referrer"
,
response
.
installReferrer
)
if
(
listOf
(
"gclid"
,
"facebook"
,
"instagram"
).
all
{
!
installInfo
.
contains
(
it
,
true
)
})
{
if
(
listOf
(
"gclid"
,
"facebook"
,
"instagram"
).
all
{
!
installInfo
.
contains
(
it
,
true
)
})
{
//自然用户
//自然用户
if
(
BuildConfig
.
DEBUG
)
{
if
(
BuildConfig
.
DEBUG
)
{
AppPreferences
.
getInstance
().
put
(
"install_source"
,
"channel"
)
AppPreferences
.
getInstance
().
put
(
"install_source"
,
"channel"
)
}
else
{
}
else
{
AppPreferences
.
getInstance
().
put
(
"install_source"
,
"origin"
)
AppPreferences
.
getInstance
().
put
(
"install_source"
,
"origin"
)
}
}
}
else
{
}
else
{
...
@@ -76,7 +75,7 @@ object InstallHelps {
...
@@ -76,7 +75,7 @@ object InstallHelps {
override
fun
onInstallReferrerServiceDisconnected
()
{
override
fun
onInstallReferrerServiceDisconnected
()
{
}
}
})
})
}
}
.
start
()
fun
requestCfg
(
callBackAd
:
Boolean
)
{
fun
requestCfg
(
callBackAd
:
Boolean
)
{
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/
utils
/NewComUtils.kt
→
app/src/main/java/com/base/filerecoveryrecyclebin/
help
/NewComUtils.kt
View file @
2c0cd27f
package
com.base.filerecoveryrecyclebin.
utils
package
com.base.filerecoveryrecyclebin.
help
import
android.os.Build
import
android.os.Build
import
android.util.Log
import
android.util.Log
import
com.base.filerecoveryrecyclebin.BuildConfig
import
com.base.filerecoveryrecyclebin.BuildConfig
import
com.base.filerecoveryrecyclebin.ads.AdDisplayUtils
import
com.base.filerecoveryrecyclebin.ads.AdDisplayUtils
import
com.base.filerecoveryrecyclebin.bean.ConfigBean
import
com.base.filerecoveryrecyclebin.bean.ConfigBean
import
com.base.filerecoveryrecyclebin.help.ConfigHelper
import
com.base.filerecoveryrecyclebin.utils.AESHelper
import
com.base.filerecoveryrecyclebin.utils.AppPreferences
import
com.base.filerecoveryrecyclebin.utils.EventUtils
import
com.base.filerecoveryrecyclebin.utils.LogEx
import
com.google.gson.Gson
import
com.google.gson.Gson
import
com.google.gson.reflect.TypeToken
import
com.google.gson.reflect.TypeToken
import
kotlinx.coroutines.CoroutineScope
import
kotlinx.coroutines.CoroutineScope
...
@@ -31,16 +34,15 @@ object NewComUtils {
...
@@ -31,16 +34,15 @@ object NewComUtils {
private
val
url
:
String
by
lazy
{
private
val
url
:
String
by
lazy
{
val
packageName
=
ConfigHelper
.
packageName
val
packageName
=
ConfigHelper
.
packageName
val
appCode
=
packageName
.
substringAfter
(
PACKAGE_NAME_PREFIX
).
take
(
5
).
toLowerCase
(
Locale
.
getDefault
())
val
appCode
=
packageName
.
substringAfter
(
PACKAGE_NAME_PREFIX
).
take
(
5
).
toLowerCase
(
Locale
.
getDefault
())
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
val
bRefer
=
Base64
.
getEncoder
().
encodeToString
(
AppPreferences
.
getInstance
().
getString
(
"referrer"
,
""
).
toByteArray
())
val
bRefer
=
android
.
util
.
Base64
.
encodeToString
(
AppPreferences
.
getInstance
().
getString
(
"referrerUrl"
,
""
).
toByteArray
(),
android
.
util
.
Base64
.
DEFAULT
)
"$API_URL/${appCode}spk?pkg=$packageName&referrer=${bRefer}&vn=${BuildConfig.VERSION_NAME}&vc=${BuildConfig.VERSION_CODE}&device=${
"$API_URL/${appCode}spk?pkg=$packageName&referrer=${bRefer}&vn=${BuildConfig.VERSION_NAME}&vc=${BuildConfig.VERSION_CODE}&device=${
AppPreferences
.
getInstance
().
getString
(
"gid"
,
""
)
AppPreferences
.
getInstance
().
getString
(
"gid"
,
""
)
}&
aid
=
$
{
AppPreferences
.
getInstance
().
getString
(
"uuid"
,
""
)}
"
}&
aid
=
$
{
AppPreferences
.
getInstance
().
getString
(
"uuid"
,
""
)}
"
}
else
{
"$API_URL/${appCode}spk?pkg=$packageName&vn=${BuildConfig.VERSION_NAME}&vc=${BuildConfig.VERSION_CODE}&device=${
AppPreferences
.
getInstance
().
getString
(
"gid"
,
""
)
}&
aid
=
$
{
AppPreferences
.
getInstance
().
getString
(
"uuid"
,
""
)}
"
}
// &mode=3
// &mode=3
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/service/BackUpUtils.kt
View file @
2c0cd27f
...
@@ -25,12 +25,13 @@ object BackUpUtils {
...
@@ -25,12 +25,13 @@ object BackUpUtils {
private
const
val
KEY
=
"backup_key"
private
const
val
KEY
=
"backup_key"
fun
backupFile
(
src
:
File
,
path
:
String
)
{
fun
backupFile
(
src
:
File
,
namePath
:
String
)
{
if
(
namePath
.
isEmpty
())
return
if
(!
hasStorageReadWritePermission
())
{
if
(!
hasStorageReadWritePermission
())
{
return
return
}
}
try
{
try
{
val
recycleBinFile
=
File
(
getRecycleBinDir
(),
".$
p
ath"
)
val
recycleBinFile
=
File
(
getRecycleBinDir
(),
".$
nameP
ath"
)
LogEx
.
logDebug
(
TAG
,
"oo=$src ${src.length()}"
)
LogEx
.
logDebug
(
TAG
,
"oo=$src ${src.length()}"
)
if
(
src
.
length
()
==
0L
)
{
if
(
src
.
length
()
==
0L
)
{
return
return
...
@@ -41,19 +42,35 @@ object BackUpUtils {
...
@@ -41,19 +42,35 @@ object BackUpUtils {
return
return
}
}
val
binBean
=
RecycleBinBean
(
val
binBean
=
RecycleBinBean
(
p
ath
,
nameP
ath
,
src
.
p
ath
,
src
.
absoluteP
ath
,
recycleBinFile
.
absolutePath
,
recycleBinFile
.
absolutePath
,
0
,
0
,
src
.
length
(),
src
.
length
(),
getFileExtension
(
src
),
getFileExtension
(
src
),
false
false
)
)
saveData
(
binBean
,
p
ath
)
saveData
(
binBean
,
nameP
ath
)
}
catch
(
e
:
Exception
)
{
}
catch
(
e
:
Exception
)
{
}
}
}
fun
deleteFile
(
path
:
String
)
{
if
(
path
.
isEmpty
())
return
val
isExists
=
queryFileExists
(
path
)
if
(
isExists
)
{
val
hashMap
=
queryBackUpSp
()
val
data
=
hashMap
[
path
]
if
(
data
!=
null
)
{
data
.
deleted
=
true
data
.
deleteTime
=
System
.
currentTimeMillis
()
hashMap
[
path
]
=
data
saveBackUpSp
(
hashMap
)
}
}
}
}
private
fun
getFileExtension
(
file
:
File
):
String
{
private
fun
getFileExtension
(
file
:
File
):
String
{
...
@@ -65,10 +82,10 @@ object BackUpUtils {
...
@@ -65,10 +82,10 @@ object BackUpUtils {
}
}
}
}
fun
saveData
(
binBean
:
RecycleBinBean
,
path
:
String
)
{
fun
saveData
(
binBean
:
RecycleBinBean
,
namePath
:
String
)
{
if
(
namePath
.
isEmpty
())
return
val
hashMap
=
queryBackUpSp
()
val
hashMap
=
queryBackUpSp
()
hashMap
.
put
(
path
,
binBean
)
hashMap
.
put
(
namePath
,
binBean
)
saveBackUpSp
(
hashMap
)
saveBackUpSp
(
hashMap
)
}
}
...
@@ -103,25 +120,16 @@ object BackUpUtils {
...
@@ -103,25 +120,16 @@ object BackUpUtils {
}
}
}
}
fun
queryFileExists
(
path
:
String
):
Boolean
{
val
hashMap
=
queryBackUpSp
()
return
hashMap
.
contains
(
path
)
}
fun
deleteFile
(
path
:
String
)
{
fun
queryFileExists
(
namePath
:
String
):
Boolean
{
val
isExists
=
queryFileExists
(
path
)
if
(
isExists
)
{
val
hashMap
=
queryBackUpSp
()
val
hashMap
=
queryBackUpSp
()
val
data
=
hashMap
[
path
]
return
hashMap
.
contains
(
namePath
)
if
(
data
!=
null
)
{
data
?.
deleted
=
true
data
?.
deleteTime
=
System
.
currentTimeMillis
()
hashMap
[
path
]
=
data
saveBackUpSp
(
hashMap
)
}
}
}
fun
deleteFileSp
(
namePath
:
String
)
{
val
map
=
queryBackUpSp
()
map
.
remove
(
namePath
)
saveBackUpSp
(
map
)
}
}
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/service/FileObserverExample.java
View file @
2c0cd27f
package
com
.
base
.
filerecoveryrecyclebin
.
service
;
package
com
.
base
.
filerecoveryrecyclebin
.
service
;
import
static
android
.
os
.
FileObserver
.
ALL_EVENTS
;
import
static
android
.
os
.
FileObserver
.
ATTRIB
;
import
static
android
.
os
.
FileObserver
.
MOVED_FROM
;
import
android.os.Build
;
import
android.os.Environment
;
import
android.os.Environment
;
import
android.os.FileObserver
;
import
android.os.FileObserver
;
import
android.os.Handler
;
import
android.os.Handler
;
import
android.os.HandlerThread
;
import
android.os.HandlerThread
;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.util.Log
;
import
com.base.filerecoveryrecyclebin.MyApplication
;
import
com.base.filerecoveryrecyclebin.activity.recyclebin.RecycleBinFileEx
;
import
com.base.filerecoveryrecyclebin.help.FileHelp
;
import
com.base.filerecoveryrecyclebin.help.FileHelp
;
import
java.io.File
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
...
@@ -108,16 +99,20 @@ public class FileObserverExample {
...
@@ -108,16 +99,20 @@ public class FileObserverExample {
}
}
}
}
private
void
handleFileCreation
(
String
path
)
{
private
void
handleFileCreation
(
String
namePath
)
{
try
{
// 确保线程安全,这里我们只是打印出来,实际使用中可能需要同步机制
// 确保线程安全,这里我们只是打印出来,实际使用中可能需要同步机制
for
(
File
dir
:
watchList
)
{
for
(
File
dir
:
watchList
)
{
File
src
=
new
File
(
dir
,
p
ath
);
File
src
=
new
File
(
dir
,
nameP
ath
);
if
(
src
.
exists
())
{
if
(
src
.
exists
())
{
Log
.
d
(
TAG
,
"新创建的文件 "
+
p
ath
+
" 属于目录: "
+
dir
.
getAbsolutePath
());
Log
.
d
(
TAG
,
"新创建的文件 "
+
nameP
ath
+
" 属于目录: "
+
dir
.
getAbsolutePath
());
BackUpUtils
.
INSTANCE
.
backupFile
(
src
,
p
ath
);
BackUpUtils
.
INSTANCE
.
backupFile
(
src
,
nameP
ath
);
break
;
break
;
}
}
}
}
}
catch
(
Exception
e
){
}
}
}
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/service/StayJobService.kt
0 → 100644
View file @
2c0cd27f
package
com.base.filerecoveryrecyclebin.service
import
android.app.Notification
import
android.app.NotificationChannel
import
android.app.NotificationManager
import
android.app.PendingIntent
import
android.app.job.JobInfo
import
android.app.job.JobParameters
import
android.app.job.JobScheduler
import
android.app.job.JobService
import
android.content.ComponentName
import
android.content.Context
import
android.content.Intent
import
android.content.pm.ServiceInfo
import
android.graphics.BitmapFactory
import
android.graphics.drawable.Icon
import
android.os.Build
import
android.os.CountDownTimer
import
android.widget.RemoteViews
import
androidx.core.app.NotificationCompat
import
androidx.core.graphics.drawable.IconCompat
import
androidx.work.Configuration
import
com.base.filerecoveryrecyclebin.R
import
com.base.filerecoveryrecyclebin.activity.MainActivity
import
com.base.filerecoveryrecyclebin.utils.LogEx
/**
* 常驻通知栏
*/
class
StayJobService
:
JobService
()
{
init
{
val
builder
=
Configuration
.
Builder
()
builder
.
setJobSchedulerJobIdRange
(
0
,
1000
)
}
private
val
TAG
=
"StayJobService"
val
channelName
=
"Photo Recovery Foreground Service Channel"
val
channelId
=
"Photo_Recovery_Service_Id"
private
val
NOTIFICATION_PERMANENT_ID
=
199
companion
object
{
var
isRunning
=
false
private
const
val
JOB_INFO_ID
:
Int
=
101
private
const
val
JOB_PERIODIC
:
Long
=
5
*
1000L
fun
Context
.
startJob
()
{
isCancel
=
false
if
(
isRunning
)
return
val
jobScheduler
=
getSystemService
(
JOB_SCHEDULER_SERVICE
)
as
JobScheduler
val
componentName
=
ComponentName
(
this
,
StayJobService
::
class
.
java
)
val
jobInfo
=
JobInfo
.
Builder
(
JOB_INFO_ID
,
componentName
)
.
setMinimumLatency
(
30000
)
.
build
()
jobScheduler
.
schedule
(
jobInfo
)
}
var
isCancel
:
Boolean
=
false
fun
createPermanentNotification
(
context
:
Context
):
Notification
{
val
channelName
=
"Permanent Foreground Service Channel"
val
channelId
=
"permanent_channel"
val
contentView
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
stay_notification_big
)
val
expendView
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
stay_notification_big
)
val
builder
=
NotificationCompat
.
Builder
(
context
,
channelId
)
val
smallIcon
=
IconCompat
.
createFromIcon
(
context
,
Icon
.
createWithResource
(
context
,
R
.
mipmap
.
logo
)
)
smallIcon
?.
let
{
builder
.
setSmallIcon
(
smallIcon
)
//设置状态栏内的小图标
}
val
nfIntent
=
Intent
(
context
,
MainActivity
::
class
.
java
)
val
pendingIntent
=
PendingIntent
.
getActivity
(
context
,
0
,
nfIntent
,
PendingIntent
.
FLAG_IMMUTABLE
)
builder
.
setLargeIcon
(
BitmapFactory
.
decodeResource
(
context
.
resources
,
R
.
mipmap
.
logo
)
)
builder
.
setContentTitle
(
context
.
resources
.
getString
(
R
.
string
.
app_name
))
builder
.
setContentIntent
(
pendingIntent
)
//设置PendingIntent
builder
.
setVisibility
(
NotificationCompat
.
VISIBILITY_PRIVATE
)
//设置通知公开可见
builder
.
setAutoCancel
(
false
)
builder
.
setOngoing
(
true
)
builder
.
setPriority
(
NotificationCompat
.
PRIORITY_MAX
)
//优先级为:重要通知
builder
.
setWhen
(
System
.
currentTimeMillis
())
builder
.
setCustomContentView
(
contentView
)
builder
.
setCustomBigContentView
(
expendView
)
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
val
channel
=
NotificationChannel
(
channelId
,
channelName
,
NotificationManager
.
IMPORTANCE_HIGH
)
channel
.
lockscreenVisibility
=
1
val
notificationManager
=
context
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
)
as
NotificationManager
notificationManager
.
createNotificationChannel
(
channel
)
builder
.
setChannelId
(
channelId
)
}
return
builder
.
build
()
}
}
override
fun
onStartCommand
(
intent
:
Intent
?,
flags
:
Int
,
startId
:
Int
):
Int
{
if
(
fileObserver
==
null
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
Q
)
{
fileObserver
=
FileObserverExample
()
fileObserver
?.
startObserving
()
}
}
return
super
.
onStartCommand
(
intent
,
flags
,
startId
)
}
private
fun
startForeground
()
{
val
notification
=
createPermanentNotification
(
applicationContext
)
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
Q
)
{
startForeground
(
NOTIFICATION_PERMANENT_ID
,
notification
,
ServiceInfo
.
FOREGROUND_SERVICE_TYPE_DATA_SYNC
)
}
else
{
startForeground
(
NOTIFICATION_PERMANENT_ID
,
notification
)
}
isRunning
=
true
}
private
fun
notifyForeground
()
{
val
notificationManager
=
getSystemService
(
Context
.
NOTIFICATION_SERVICE
)
as
NotificationManager
notificationManager
.
notify
(
NOTIFICATION_PERMANENT_ID
,
createPermanentNotification
(
applicationContext
)
)
}
override
fun
onDestroy
()
{
isRunning
=
false
super
.
onDestroy
()
fileObserver
?.
stopObserving
()
}
override
fun
onCreate
()
{
LogEx
.
logDebug
(
TAG
,
"onCreate isRunning=$isRunning"
)
if
(!
isRunning
)
{
isRunning
=
true
startForeground
()
Timer
().
start
()
}
super
.
onCreate
()
}
override
fun
onStartJob
(
params
:
JobParameters
?):
Boolean
{
return
true
}
override
fun
onStopJob
(
params
:
JobParameters
?):
Boolean
{
return
false
}
private
inner
class
Timer
()
:
CountDownTimer
(
30000
,
1000
)
{
override
fun
onTick
(
millisUntilFinished
:
Long
)
{
}
override
fun
onFinish
()
{
if
(!
isCancel
)
{
notifyForeground
()
Timer
().
start
()
}
}
}
private
var
fileObserver
:
FileObserverExample
?
=
null
}
app/src/main/java/com/base/filerecoveryrecyclebin/service/StayNotificationService.kt
View file @
2c0cd27f
...
@@ -54,6 +54,7 @@ class StayNotificationService : Service() {
...
@@ -54,6 +54,7 @@ class StayNotificationService : Service() {
//Android 14 no
//Android 14 no
return
return
}
}
runCatching
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
startForegroundService
(
intent
)
startForegroundService
(
intent
)
}
else
{
}
else
{
...
@@ -61,6 +62,7 @@ class StayNotificationService : Service() {
...
@@ -61,6 +62,7 @@ class StayNotificationService : Service() {
}
}
}
}
}
}
}
override
fun
onStartCommand
(
intent
:
Intent
?,
flags
:
Int
,
startId
:
Int
):
Int
{
override
fun
onStartCommand
(
intent
:
Intent
?,
flags
:
Int
,
startId
:
Int
):
Int
{
...
@@ -68,11 +70,6 @@ class StayNotificationService : Service() {
...
@@ -68,11 +70,6 @@ class StayNotificationService : Service() {
EventUtils
.
event
(
"onStartCommand"
,
"Foreground System auto launch intent=null isRunning=$isRunning"
)
EventUtils
.
event
(
"onStartCommand"
,
"Foreground System auto launch intent=null isRunning=$isRunning"
)
return
START_NOT_STICKY
return
START_NOT_STICKY
}
}
if
(
Build
.
VERSION
.
SDK_INT
>
Build
.
VERSION_CODES
.
TIRAMISU
)
{
//Android 14 no
return
START_NOT_STICKY
}
if
(
fileObserver
==
null
)
{
if
(
fileObserver
==
null
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
Q
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
Q
)
{
fileObserver
=
FileObserverExample
()
fileObserver
=
FileObserverExample
()
...
@@ -80,12 +77,14 @@ class StayNotificationService : Service() {
...
@@ -80,12 +77,14 @@ class StayNotificationService : Service() {
}
}
}
}
if
(!
isRunning
)
{
if
(!
isRunning
)
{
runCatching
{
val
notification
=
createPermanentNotification
(
applicationContext
)
val
notification
=
createPermanentNotification
(
applicationContext
)
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
Q
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
Q
)
{
startForeground
(
1
,
notification
,
ServiceInfo
.
FOREGROUND_SERVICE_TYPE_DATA_SYNC
)
startForeground
(
1
,
notification
,
ServiceInfo
.
FOREGROUND_SERVICE_TYPE_DATA_SYNC
)
}
else
{
}
else
{
startForeground
(
1
,
notification
)
startForeground
(
1
,
notification
)
}
}
}
isRunning
=
true
isRunning
=
true
}
}
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/utils/EventUtils.kt
View file @
2c0cd27f
...
@@ -10,7 +10,7 @@ import org.json.JSONException
...
@@ -10,7 +10,7 @@ import org.json.JSONException
import
org.json.JSONObject
import
org.json.JSONObject
object
EventUtils
{
object
EventUtils
{
private
val
TAG
=
"EventUtils"
fun
event
(
fun
event
(
key
:
String
,
key
:
String
,
value
:
String
?
=
null
,
value
:
String
?
=
null
,
...
@@ -57,6 +57,9 @@ object EventUtils {
...
@@ -57,6 +57,9 @@ object EventUtils {
}
catch
(
e
:
JSONException
)
{
}
catch
(
e
:
JSONException
)
{
parmJson
=
""
parmJson
=
""
}
}
if
(
key
.
contains
(
"install_"
))
{
LogEx
.
logDebug
(
TAG
,
"key=$key"
)
}
doPost
(
doPost
(
url
,
url
,
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/utils/LogEx.kt
View file @
2c0cd27f
...
@@ -9,7 +9,8 @@ object LogEx {
...
@@ -9,7 +9,8 @@ object LogEx {
"FileScanActivity"
,
"FileScanActivity"
,
// "FileHexEx",
// "FileHexEx",
"FileScanResultActivity"
,
"FileScanResultActivity"
,
"FileGridAdapter"
"FileGridAdapter"
,
// "TestSimilar", "SimilarHelper"
)
)
fun
logDebug
(
tag
:
String
,
content
:
String
,
isMust
:
Boolean
=
false
)
{
fun
logDebug
(
tag
:
String
,
content
:
String
,
isMust
:
Boolean
=
false
)
{
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/utils/SimilarHelper.kt
View file @
2c0cd27f
...
@@ -4,8 +4,11 @@ import android.graphics.BitmapFactory
...
@@ -4,8 +4,11 @@ import android.graphics.BitmapFactory
import
android.provider.MediaStore.Audio.Radio
import
android.provider.MediaStore.Audio.Radio
import
com.base.filerecoveryrecyclebin.bean.MediaBean
import
com.base.filerecoveryrecyclebin.bean.MediaBean
import
com.base.filerecoveryrecyclebin.utils.TestSimilar.testSimilar
import
com.base.filerecoveryrecyclebin.utils.TestSimilar.testSimilar
import
kotlinx.coroutines.CoroutineScope
import
kotlinx.coroutines.isActive
//import com.base.filerecoveryrecyclebin.utils.OpencvImageHelp.opencvCompareSimilar
//import com.base.filerecoveryrecyclebin.utils.OpencvImageHelp.opencvCompareSimilar
import
java.io.File
import
java.io.File
import
kotlin.math.abs
import
kotlin.random.Random
import
kotlin.random.Random
object
SimilarHelper
{
object
SimilarHelper
{
...
@@ -13,9 +16,14 @@ object SimilarHelper {
...
@@ -13,9 +16,14 @@ object SimilarHelper {
private
val
TAG
=
"SimilarHelper"
private
val
TAG
=
"SimilarHelper"
fun
calculateSimilar
(
list
:
List
<
MediaBean
>):
HashMap
<
String
,
ArrayList
<
MediaBean
>>
{
fun
CoroutineScope
.
calculateSimilar
(
list
:
List
<
MediaBean
>,
myResult
:
HashMap
<
String
,
ArrayList
<
MediaBean
>>?
=
null
):
HashMap
<
String
,
ArrayList
<
MediaBean
>>
{
val
result
=
myResult
?:
HashMap
<
String
,
ArrayList
<
MediaBean
>>()
try
{
val
result
=
HashMap
<
String
,
ArrayList
<
MediaBean
>>()
val
eachArrayList
=
arrayListOf
<
MediaBean
>().
apply
{
val
eachArrayList
=
arrayListOf
<
MediaBean
>().
apply
{
addAll
(
list
)
addAll
(
list
)
}
}
...
@@ -24,7 +32,7 @@ object SimilarHelper {
...
@@ -24,7 +32,7 @@ object SimilarHelper {
val
iterator
=
list
.
iterator
()
val
iterator
=
list
.
iterator
()
while
(
iterator
.
hasNext
()
)
{
while
(
iterator
.
hasNext
()
&&
isActive
)
{
val
item
=
iterator
.
next
()
val
item
=
iterator
.
next
()
LogEx
.
logDebug
(
TAG
,
"next item=$item"
)
LogEx
.
logDebug
(
TAG
,
"next item=$item"
)
...
@@ -32,13 +40,17 @@ object SimilarHelper {
...
@@ -32,13 +40,17 @@ object SimilarHelper {
if
(!
haveComperedList
.
contains
(
item
.
path
))
{
if
(!
haveComperedList
.
contains
(
item
.
path
))
{
val
compareIterator
=
eachArrayList
.
iterator
()
val
compareIterator
=
eachArrayList
.
iterator
()
while
(
compareIterator
.
hasNext
()
)
{
while
(
compareIterator
.
hasNext
()
&&
isActive
)
{
val
compareItem
=
compareIterator
.
next
()
val
compareItem
=
compareIterator
.
next
()
// LogEx.logDebug(TAG, "compareItem=$compareItem")
// LogEx.logDebug(TAG, "compareItem=$compareItem")
if
(
item
.
path
!=
compareItem
.
path
)
{
if
(
item
.
path
!=
compareItem
.
path
)
{
// val percent = opencvCompareSimilar(item.path, compareItem.path)
// val percent = opencvCompareSimilar(item.path, compareItem.path)
// val percent = similarPercent(File(item.path), File(compareItem.path))
// val percent = similarPercent(File(item.path), File(compareItem.path))
val
file
=
File
(
item
.
path
)
val
compareFile
=
File
(
compareItem
.
path
)
val
timeFlag
=
abs
(
file
.
lastModified
()
-
compareFile
.
lastModified
())
<
7
*
24
*
60
*
60
*
1000L
if
(!
timeFlag
)
continue
val
isSimilar
=
testSimilar
(
item
.
path
,
compareItem
.
path
)
val
isSimilar
=
testSimilar
(
item
.
path
,
compareItem
.
path
)
LogEx
.
logDebug
(
TAG
,
"isSimilar=$isSimilar"
)
LogEx
.
logDebug
(
TAG
,
"isSimilar=$isSimilar"
)
if
(
isSimilar
)
{
if
(
isSimilar
)
{
...
@@ -60,6 +72,10 @@ object SimilarHelper {
...
@@ -60,6 +72,10 @@ object SimilarHelper {
}
}
}
}
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
}
return
result
return
result
}
}
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/work/RepeatingWorker.kt
0 → 100644
View file @
2c0cd27f
package
com.base.filerecoveryrecyclebin.work
import
android.content.Context
import
androidx.work.Constraints
import
androidx.work.ExistingPeriodicWorkPolicy
import
androidx.work.NetworkType
import
androidx.work.PeriodicWorkRequestBuilder
import
androidx.work.WorkManager
import
androidx.work.Worker
import
androidx.work.WorkerParameters
import
com.base.filerecoveryrecyclebin.fcm.NotificationUtil
import
com.base.filerecoveryrecyclebin.utils.EventUtils
import
java.util.concurrent.TimeUnit
fun
schedulePeriodicWork
(
context
:
Context
)
{
val
request
=
PeriodicWorkRequestBuilder
<
RepeatingWorker
>(
15
,
TimeUnit
.
MINUTES
)
.
setConstraints
(
Constraints
.
Builder
().
setRequiredNetworkType
(
NetworkType
.
CONNECTED
).
build
()
)
.
build
()
WorkManager
.
getInstance
(
context
).
enqueueUniquePeriodicWork
(
"uniqueWorkName"
,
ExistingPeriodicWorkPolicy
.
KEEP
,
request
)
}
class
RepeatingWorker
(
val
appContext
:
Context
,
workerParams
:
WorkerParameters
)
:
Worker
(
appContext
,
workerParams
)
{
override
fun
doWork
():
Result
{
// 这里执行你的任务
// 例如,更新UI,发送网络请求等
EventUtils
.
event
(
"workmanager_live"
)
try
{
NotificationUtil
.
sendNotification
(
appContext
,
"WorkManager"
);
}
catch
(
e
:
Exception
)
{
EventUtils
.
event
(
"WorkManager Error"
)
}
return
Result
.
success
()
}
}
\ No newline at end of file
app/src/main/res/layout/activity_battery.xml
View file @
2c0cd27f
...
@@ -338,7 +338,7 @@
...
@@ -338,7 +338,7 @@
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"8dp"
android:layout_marginTop=
"8dp"
android:text=
"
Temperatur
e"
android:text=
"
Capacitanc
e"
android:textColor=
"#838383"
android:textColor=
"#838383"
android:textSize=
"13sp"
android:textSize=
"13sp"
tools:ignore=
"HardcodedText"
/>
tools:ignore=
"HardcodedText"
/>
...
...
app/src/main/res/layout/activity_main.xml
View file @
2c0cd27f
...
@@ -130,7 +130,7 @@
...
@@ -130,7 +130,7 @@
<ImageView
<ImageView
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:src=
"@mipmap/zhanweitu"
android:src=
"@mipmap/zhanweitu
2
"
android:tag=
"zhanweitu"
android:tag=
"zhanweitu"
tools:ignore=
"ContentDescription"
/>
tools:ignore=
"ContentDescription"
/>
</FrameLayout>
</FrameLayout>
...
...
app/src/main/res/layout/activity_recycle_bin_detail.xml
View file @
2c0cd27f
...
@@ -109,7 +109,7 @@
...
@@ -109,7 +109,7 @@
app:layout_constraintTop_toTopOf=
"parent"
>
app:layout_constraintTop_toTopOf=
"parent"
>
<TextView
<TextView
android:id=
"@+id/tv_
name
"
android:id=
"@+id/tv_
path
"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:textColor=
"@color/black"
android:textColor=
"@color/black"
...
...
app/src/main/res/layout/item_result_fun_2.xml
View file @
2c0cd27f
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
xmlns:tools=
"http://schemas.android.com/tools"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"166dp"
android:layout_width=
"166dp"
android:layout_height=
"100dp"
android:layout_height=
"100dp"
android:layout_marginHorizontal=
"
10
dp"
android:layout_marginHorizontal=
"
8
dp"
android:layout_marginVertical=
"5dp"
android:layout_marginVertical=
"5dp"
app:cardCornerRadius=
"10dp"
>
app:cardCornerRadius=
"10dp"
>
...
...
app/src/main/res/layout/layout_max_native_custom.xml
View file @
2c0cd27f
...
@@ -104,7 +104,6 @@
...
@@ -104,7 +104,6 @@
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"8dp"
android:layout_marginTop=
"8dp"
android:backgroundTint=
"@color/applovin_sdk_brand_color"
android:textColor=
"@android:color/white"
android:textColor=
"@android:color/white"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/ad_media"
app:layout_constraintTop_toBottomOf=
"@+id/ad_media"
...
...
app/src/main/res/mipmap-xxhdpi/zhanweitu2.png
0 → 100644
View file @
2c0cd27f
10.6 KB
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