Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
E
Easy Cleaner Junk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wanglei
Easy Cleaner Junk
Commits
f299164f
Commit
f299164f
authored
Jun 23, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.垃圾清理
2.截图清理 3.照片压缩 4.重复照片清理 5.大文件清理
parent
47b8bf8a
Hide whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
18 additions
and
3394 deletions
+18
-3394
MyApplication.kt
.../main/java/com/test/easy/easycleanerjunk/MyApplication.kt
+0
-5
AppManagerActivity.kt
.../test/easy/easycleanerjunk/activity/AppManagerActivity.kt
+0
-499
BatteryInfoActivity.kt
...test/easy/easycleanerjunk/activity/BatteryInfoActivity.kt
+0
-260
DeviceScanInfoActivity.kt
...t/easy/easycleanerjunk/activity/DeviceScanInfoActivity.kt
+0
-201
NetWorkActivity.kt
...com/test/easy/easycleanerjunk/activity/NetWorkActivity.kt
+0
-339
PermissionManagerActivity.kt
...asy/easycleanerjunk/activity/PermissionManagerActivity.kt
+0
-265
RecentAppActivity.kt
...m/test/easy/easycleanerjunk/activity/RecentAppActivity.kt
+0
-399
ResultActivity.kt
.../com/test/easy/easycleanerjunk/activity/ResultActivity.kt
+0
-65
SettingActivity.kt
...com/test/easy/easycleanerjunk/activity/SettingActivity.kt
+1
-13
SplashJumpUtils.kt
...t/easy/easycleanerjunk/activity/splash/SplashJumpUtils.kt
+2
-25
AppFunctionAdapter.kt
...m/test/easy/easycleanerjunk/adapter/AppFunctionAdapter.kt
+0
-24
ToolsAdapter.kt
...ava/com/test/easy/easycleanerjunk/adapter/ToolsAdapter.kt
+1
-17
ConfigBean.kt
...ain/java/com/test/easy/easycleanerjunk/bean/ConfigBean.kt
+0
-14
NotificationUtils.kt
...om/test/easy/easycleanerjunk/display/NotificationUtils.kt
+11
-18
AppListFragment.kt
...com/test/easy/easycleanerjunk/fragment/AppListFragment.kt
+0
-301
HomeFragment.kt
...va/com/test/easy/easycleanerjunk/fragment/HomeFragment.kt
+0
-20
LaunchesFragment.kt
...om/test/easy/easycleanerjunk/fragment/LaunchesFragment.kt
+0
-422
ScreenTimeFragment.kt
.../test/easy/easycleanerjunk/fragment/ScreenTimeFragment.kt
+0
-123
ToolsFragment.kt
...a/com/test/easy/easycleanerjunk/fragment/ToolsFragment.kt
+1
-40
AFunOb.kt
...rc/main/java/com/test/easy/easycleanerjunk/view/AFunOb.kt
+0
-11
AppDetailDialog.kt
...ava/com/test/easy/easycleanerjunk/view/AppDetailDialog.kt
+0
-10
activity_setting.xml
app/src/main/res/layout/activity_setting.xml
+0
-31
dialog_app_detail.xml
app/src/main/res/layout/dialog_app_detail.xml
+0
-14
fragment_layout_home.xml
app/src/main/res/layout/fragment_layout_home.xml
+2
-147
reminder_layout_notification_big_notify.xml
...in/res/layout/reminder_layout_notification_big_notify.xml
+0
-79
reminder_layout_notification_notify.xml
...c/main/res/layout/reminder_layout_notification_notify.xml
+0
-52
No files found.
app/src/main/java/com/test/easy/easycleanerjunk/MyApplication.kt
View file @
f299164f
...
@@ -10,9 +10,7 @@ import android.util.Log
...
@@ -10,9 +10,7 @@ import android.util.Log
import
com.google.android.gms.ads.MobileAds
import
com.google.android.gms.ads.MobileAds
import
com.google.firebase.FirebaseApp
import
com.google.firebase.FirebaseApp
import
com.test.easy.easycleanerjunk.activity.splash.NewSplashActivity
import
com.test.easy.easycleanerjunk.activity.splash.NewSplashActivity
import
com.test.easy.easycleanerjunk.display.fcm.FcmHelper
import
com.test.easy.easycleanerjunk.helps.BaseApplication
import
com.test.easy.easycleanerjunk.helps.BaseApplication
import
com.test.easy.easycleanerjunk.helps.ComUtils.requestCfg
import
com.test.easy.easycleanerjunk.helps.ConfigHelper
import
com.test.easy.easycleanerjunk.helps.ConfigHelper
import
com.test.easy.easycleanerjunk.helps.InstallHelps
import
com.test.easy.easycleanerjunk.helps.InstallHelps
import
com.test.easy.easycleanerjunk.helps.ads.AdmobUtils
import
com.test.easy.easycleanerjunk.helps.ads.AdmobUtils
...
@@ -47,7 +45,6 @@ class MyApplication : BaseApplication() {
...
@@ -47,7 +45,6 @@ class MyApplication : BaseApplication() {
if
(
ConfigHelper
.
ifAgreePrivacy
)
{
if
(
ConfigHelper
.
ifAgreePrivacy
)
{
initNotificationWork
()
initNotificationWork
()
MainScope
().
launch
{
MainScope
().
launch
{
requestCfg
()
InstallHelps
.
init
()
InstallHelps
.
init
()
}
}
MobileAds
.
initialize
(
this
)
{
initializationStatus
->
MobileAds
.
initialize
(
this
)
{
initializationStatus
->
...
@@ -69,8 +66,6 @@ class MyApplication : BaseApplication() {
...
@@ -69,8 +66,6 @@ class MyApplication : BaseApplication() {
private
fun
initNotificationWork
()
{
private
fun
initNotificationWork
()
{
FirebaseApp
.
initializeApp
(
this
)
FirebaseApp
.
initializeApp
(
this
)
FcmHelper
.
getToken
()
FcmHelper
.
subscribeToTopic
()
Log
.
d
(
"MyService"
,
"startService:"
+
Process
.
myPid
());
Log
.
d
(
"MyService"
,
"startService:"
+
Process
.
myPid
());
}
}
...
...
app/src/main/java/com/test/easy/easycleanerjunk/activity/AppManagerActivity.kt
deleted
100644 → 0
View file @
47b8bf8a
package
com.test.easy.easycleanerjunk.activity
import
android.annotation.SuppressLint
import
android.app.AppOpsManager
import
android.app.usage.UsageStats
import
android.app.usage.UsageStatsManager
import
android.content.Context
import
android.content.Intent
import
android.content.pm.ApplicationInfo
import
android.content.pm.PackageInfo
import
android.content.pm.PackageManager
import
android.graphics.Color
import
android.net.Uri
import
android.os.Build
import
android.util.Log
import
android.view.View
import
androidx.activity.addCallback
import
androidx.core.view.ViewCompat
import
androidx.core.view.WindowInsetsCompat
import
androidx.core.view.isVisible
import
androidx.fragment.app.Fragment
import
androidx.fragment.app.FragmentActivity
import
androidx.lifecycle.lifecycleScope
import
androidx.viewpager2.adapter.FragmentStateAdapter
import
androidx.viewpager2.widget.ViewPager2
import
com.test.easy.easycleanerjunk.R
import
com.test.easy.easycleanerjunk.bean.AppBean
import
com.test.easy.easycleanerjunk.databinding.ActivityAppManagerBinding
import
com.test.easy.easycleanerjunk.fragment.AppListFragment
import
com.test.easy.easycleanerjunk.fragment.AppListFragment.Companion.APP_LIST_TYPE_INSTALL
import
com.test.easy.easycleanerjunk.fragment.AppListFragment.Companion.APP_LIST_TYPE_LAST_USE
import
com.test.easy.easycleanerjunk.fragment.AppListFragment.Companion.APP_LIST_TYPE_NAME
import
com.test.easy.easycleanerjunk.fragment.AppListFragment.Companion.APP_LIST_TYPE_SIZE
import
com.test.easy.easycleanerjunk.helps.AppSizeUtils
import
com.test.easy.easycleanerjunk.helps.BaseActivity
import
com.test.easy.easycleanerjunk.helps.LogEx
import
com.test.easy.easycleanerjunk.helps.PermissionHelp.checkUsageAccessSettings
import
com.test.easy.easycleanerjunk.helps.TimeUtils.THIRTY_DAYS_QUERY
import
com.test.easy.easycleanerjunk.helps.TimeUtils.timePair
import
com.test.easy.easycleanerjunk.helps.ads.AdmobUtils
import
com.test.easy.easycleanerjunk.utils.BarUtils
import
kotlinx.coroutines.CoroutineScope
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.async
import
kotlinx.coroutines.cancel
import
kotlinx.coroutines.delay
import
kotlinx.coroutines.isActive
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.withContext
import
org.json.JSONObject
import
java.util.concurrent.LinkedBlockingDeque
/**
* 所需权限:
* 使用情况 last use
* android.permission.PACKAGE_USAGE_STATS
* 卸载
* android.permission.REQUEST_DELETE_PACKAGES
*/
class
AppManagerActivity
:
BaseActivity
<
ActivityAppManagerBinding
>()
{
override
val
isLightMode
=
true
private
val
dataList
=
ArrayList
<
AppBean
>()
private
val
pages
=
arrayListOf
<
Fragment
>()
private
lateinit
var
pagerAdapter
:
ScreenSlidePagerAdapter
private
val
TAG
:
String
=
"AppManager2Activity"
private
var
currentPosition
:
Int
=
0
private
lateinit
var
context
:
Context
var
animationFinish
:
Boolean
=
false
override
val
binding
:
ActivityAppManagerBinding
by
lazy
{
ActivityAppManagerBinding
.
inflate
(
layoutInflater
)
}
override
fun
initView
()
{
BarUtils
.
setStatusBarColor
(
this
,
Color
.
TRANSPARENT
)
context
=
this
playLottie
()
initViewPager
()
lifecycleScope
.
launch
((
Dispatchers
.
IO
))
{
initAppData
()
if
(
checkUsageAccessSettings
())
{
setAppBeanSize
()
setAppLastUseTime
()
}
launch
(
Dispatchers
.
Main
)
{
pages
.
forEachIndexed
{
index
,
fragment
->
val
appListFragment
=
(
fragment
as
AppListFragment
)
appListFragment
.
refreshFragmentData
(
dataList
,
index
==
currentPosition
)
}
}
}
binding
.
llName
.
setOnClickListener
{
if
(
currentPosition
==
0
)
{
val
fragment
=
(
pages
[
0
]
as
AppListFragment
)
fragment
.
reverseOrder
()
val
isAsc
=
fragment
.
isAsc
changeAsc
(
0
,
isAsc
)
}
binding
.
viewpager2
.
setCurrentItem
(
0
,
false
)
}
binding
.
llInstall
.
setOnClickListener
{
if
(
currentPosition
==
1
)
{
val
fragment
=
(
pages
[
1
]
as
AppListFragment
)
fragment
.
reverseOrder
()
val
isAsc
=
fragment
.
isAsc
changeAsc
(
1
,
isAsc
)
}
binding
.
viewpager2
.
setCurrentItem
(
1
,
false
)
}
binding
.
llSize
.
setOnClickListener
{
if
(
currentPosition
==
2
)
{
val
fragment
=
(
pages
[
2
]
as
AppListFragment
)
fragment
.
reverseOrder
()
val
isAsc
=
fragment
.
isAsc
changeAsc
(
2
,
isAsc
)
}
binding
.
viewpager2
.
setCurrentItem
(
2
,
false
)
}
binding
.
llLastUse
.
setOnClickListener
{
if
(
currentPosition
==
3
)
{
val
fragment
=
(
pages
[
3
]
as
AppListFragment
)
fragment
.
reverseOrder
()
val
isAsc
=
fragment
.
isAsc
changeAsc
(
3
,
isAsc
)
}
binding
.
viewpager2
.
setCurrentItem
(
3
,
false
)
}
binding
.
flBack
.
setOnClickListener
{
AdmobUtils
.
showInterstitialAd
(
this
)
{
finishToMain
()
}
}
onBackPressedDispatcher
.
addCallback
{
AdmobUtils
.
showInterstitialAd
(
this
@AppManagerActivity
)
{
finishToMain
()
}
}
}
override
fun
onDestroy
()
{
super
.
onDestroy
()
binding
.
llLottie
.
clearAnimation
()
binding
.
lottie
.
clearAnimation
()
}
private
fun
playLottie
()
{
binding
.
llLottie
.
isVisible
=
true
binding
.
lottie
.
imageAssetsFolder
=
"easy_appmanager_scan/images/"
binding
.
lottie
.
setAnimation
(
"easy_appmanager_scan/data.json"
)
binding
.
lottie
.
playAnimation
()
binding
.
root
.
postDelayed
({
AdmobUtils
.
showInterstitialAd
(
this
)
{
animationFinish
=
true
binding
.
llLottie
.
isVisible
=
false
}
},
6000
)
}
fun
refreshUsageAccessData
()
{
val
obj
=
JSONObject
()
obj
.
put
(
"activity"
,
javaClass
.
simpleName
)
if
(
checkUsageAccessSettings
())
{
pages
.
forEachIndexed
{
index
,
fragment
->
val
appListFragment
=
(
fragment
as
AppListFragment
)
appListFragment
.
showContent
(
index
==
currentPosition
)
}
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
setAppBeanSize
()
setAppLastUseTime
()
launch
(
Dispatchers
.
Main
)
{
pages
.
forEachIndexed
{
index
,
fragment
->
val
appListFragment
=
(
fragment
as
AppListFragment
)
appListFragment
.
refreshFragmentData
(
dataList
,
index
==
currentPosition
,
index
)
}
}
}
}
}
private
fun
changeAsc
(
position
:
Int
,
isAsc
:
Boolean
)
{
when
(
position
)
{
0
->
{
binding
.
arrowInstall
.
setAscOrder
(
false
)
binding
.
arrowSize
.
setAscOrder
(
false
)
binding
.
arrowLastUse
.
setAscOrder
(
false
)
binding
.
arrowName
.
setAscOrder
(
true
,
isAsc
)
}
1
->
{
binding
.
arrowName
.
setAscOrder
(
false
)
binding
.
arrowSize
.
setAscOrder
(
false
)
binding
.
arrowLastUse
.
setAscOrder
(
false
)
binding
.
arrowInstall
.
setAscOrder
(
true
,
isAsc
)
}
2
->
{
binding
.
arrowName
.
setAscOrder
(
false
)
binding
.
arrowInstall
.
setAscOrder
(
false
)
binding
.
arrowLastUse
.
setAscOrder
(
false
)
binding
.
arrowSize
.
setAscOrder
(
true
,
isAsc
)
}
3
->
{
binding
.
arrowName
.
setAscOrder
(
false
)
binding
.
arrowInstall
.
setAscOrder
(
false
)
binding
.
arrowSize
.
setAscOrder
(
false
)
binding
.
arrowLastUse
.
setAscOrder
(
true
,
isAsc
)
}
}
}
private
fun
changeIndicator
(
position
:
Int
)
{
when
(
position
)
{
0
->
{
binding
.
vName
.
visibility
=
View
.
VISIBLE
binding
.
vInstall
.
visibility
=
View
.
INVISIBLE
binding
.
vSize
.
visibility
=
View
.
INVISIBLE
binding
.
vLastUse
.
visibility
=
View
.
INVISIBLE
}
1
->
{
binding
.
vName
.
visibility
=
View
.
INVISIBLE
binding
.
vInstall
.
visibility
=
View
.
VISIBLE
binding
.
vSize
.
visibility
=
View
.
INVISIBLE
binding
.
vLastUse
.
visibility
=
View
.
INVISIBLE
}
2
->
{
binding
.
vName
.
visibility
=
View
.
INVISIBLE
binding
.
vInstall
.
visibility
=
View
.
INVISIBLE
binding
.
vSize
.
visibility
=
View
.
VISIBLE
binding
.
vLastUse
.
visibility
=
View
.
INVISIBLE
}
3
->
{
binding
.
vName
.
visibility
=
View
.
INVISIBLE
binding
.
vInstall
.
visibility
=
View
.
INVISIBLE
binding
.
vSize
.
visibility
=
View
.
INVISIBLE
binding
.
vLastUse
.
visibility
=
View
.
VISIBLE
}
}
}
private
fun
initViewPager
()
{
pages
.
add
(
AppListFragment
().
apply
{
setInitData
(
launcher
,
APP_LIST_TYPE_NAME
,
true
)
})
pages
.
add
(
AppListFragment
().
apply
{
setInitData
(
launcher
,
APP_LIST_TYPE_INSTALL
,
false
)
})
pages
.
add
(
AppListFragment
().
apply
{
setInitData
(
launcher
,
APP_LIST_TYPE_SIZE
,
false
,
needPermission
=
true
)
})
pages
.
add
(
AppListFragment
().
apply
{
setInitData
(
launcher
,
APP_LIST_TYPE_LAST_USE
,
false
,
needPermission
=
true
)
})
pagerAdapter
=
ScreenSlidePagerAdapter
(
this
@AppManagerActivity
)
binding
.
viewpager2
.
adapter
=
pagerAdapter
binding
.
viewpager2
.
registerOnPageChangeCallback
(
object
:
ViewPager2
.
OnPageChangeCallback
()
{
override
fun
onPageScrolled
(
position
:
Int
,
positionOffset
:
Float
,
positionOffsetPixels
:
Int
)
{
super
.
onPageScrolled
(
position
,
positionOffset
,
positionOffsetPixels
)
currentPosition
=
position
changeIndicator
(
position
)
val
fragment
=
(
pages
[
position
]
as
AppListFragment
)
fragment
.
setDataRefresh
(
dataList
)
changeAsc
(
position
,
fragment
.
isAsc
)
}
})
}
@SuppressLint
(
"QueryPermissionsNeeded"
)
private
fun
initAppData
()
{
dataList
.
clear
()
val
pm
=
packageManager
val
packages
=
pm
.
getInstalledPackages
(
0
)
packages
.
forEach
{
app
->
if
(
isLaunchApp
(
context
,
app
))
{
val
appBean
=
AppBean
(
app
.
applicationInfo
.
loadIcon
(
pm
),
app
.
applicationInfo
.
loadLabel
(
pm
).
toString
(),
app
.
applicationInfo
.
packageName
,
false
)
//安装时间
setAppInstallTime
(
appBean
,
context
)
dataList
.
add
(
appBean
)
}
}
}
private
fun
setAppBeanSize
()
{
dataList
.
forEach
{
app
->
val
size
=
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
AppSizeUtils
.
instance
?.
getAppSizeO
(
context
,
app
.
pkg
)
}
else
{
AppSizeUtils
.
instance
?.
getAppSize
(
context
,
app
.
pkg
)
}
app
.
appSize
=
size
?:
0
}
}
private
fun
setAppLastUseTime
(
queryTime
:
Int
=
THIRTY_DAYS_QUERY
)
{
val
pair
=
timePair
(
queryTime
)
val
startTime
:
Long
=
pair
.
first
val
endTime
:
Long
=
pair
.
second
val
usageList
=
getUsageList
(
context
,
startTime
,
endTime
)
dataList
.
forEach
{
app
->
val
filterList
=
usageList
.
filter
{
it
.
packageName
==
app
.
pkg
}
app
.
usageStats
=
filterList
app
.
lastUsedTime
=
if
(
filterList
.
isNotEmpty
())
filterList
.
maxOf
{
it
.
lastTimeUsed
}
else
-
2
//默认30天没数据
}
}
@SuppressLint
(
"NotifyDataSetChanged"
)
fun
otherPageRemove
(
appBean
:
AppBean
,
fragment
:
AppListFragment
)
{
dataList
.
remove
(
appBean
)
pages
.
forEach
{
if
(
it
!=
fragment
)
{
(
it
as
AppListFragment
).
setData
(
dataList
)
}
}
}
private
fun
allPageRemove
(
unInstalled
:
List
<
AppBean
>)
{
Log
.
e
(
TAG
,
"unInstalled=$unInstalled"
)
dataList
.
removeAll
(
unInstalled
.
toSet
())
pages
.
forEachIndexed
{
index
,
fragment
->
val
fg
=
fragment
as
AppListFragment
if
(
index
==
currentPosition
)
{
Log
.
e
(
TAG
,
"dataList=$dataList currentPosition=$currentPosition"
)
lifecycleScope
.
launch
(
Dispatchers
.
Main
)
{
delay
(
1500
)
fg
.
setDataRefresh
(
dataList
)
}
}
else
{
Log
.
e
(
TAG
,
"dataList=$dataList index=$index"
)
fg
.
setData
(
dataList
)
}
}
}
@SuppressLint
(
"StringFormatMatches"
,
"SetTextI18n"
)
fun
showUnInstall
(
selectList
:
List
<
AppBean
>)
{
if
(
selectList
.
isNotEmpty
())
{
binding
.
tvUninstall
.
isVisible
=
true
binding
.
tvUninstall
.
text
=
"Uninstall(${selectList.size})"
binding
.
tvUninstall
.
setOnClickListener
{
binding
.
tvUninstall
.
isVisible
=
false
binding
.
tvUninstall
.
setOnClickListener
{
}
unInstallApps
(
selectList
)
{
unInstalled
->
allPageRemove
(
unInstalled
)
}
}
}
else
{
binding
.
tvUninstall
.
isVisible
=
false
binding
.
tvUninstall
.
setOnClickListener
{
}
}
}
private
fun
unInstallApps
(
selectList
:
List
<
AppBean
>,
finishUnInstall
:
(
unInstalled
:
List
<
AppBean
>)
->
Unit
)
=
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
val
unInstall
=
arrayListOf
<
AppBean
>()
//待卸载列表
unInstall
.
addAll
(
selectList
)
val
unInstalled
=
arrayListOf
<
AppBean
>()
//已卸载列表
val
queue
=
LinkedBlockingDeque
<
AppBean
>()
val
first
=
unInstall
[
0
]
queue
.
put
(
first
)
while
(
isActive
)
{
val
appBean
=
withContext
(
Dispatchers
.
IO
)
{
queue
.
take
()
}
delay
(
250
)
LogEx
.
logDebug
(
TAG
,
"循环。。。。。。。。。。。。。。。。。。。。。。。。"
)
val
intent
=
Intent
(
Intent
.
ACTION_DELETE
,
Uri
.
parse
(
"package:${appBean.pkg}"
))
launcher
.
launch
(
intent
)
{
val
flag
=
isInstalled
(
this
@AppManagerActivity
,
appBean
.
pkg
,
error
=
{
unInstall
.
remove
(
appBean
)
unInstalled
.
add
(
appBean
)
})
if
(!
flag
)
{
unInstalled
.
add
(
appBean
)
}
unInstall
.
remove
(
appBean
)
if
(
unInstall
.
isNotEmpty
())
{
val
next
=
unInstall
[
0
]
LogEx
.
logDebug
(
TAG
,
"卸载回调 next=$next"
)
queue
.
put
(
next
)
}
else
{
LogEx
.
logDebug
(
TAG
,
"卸载完成回调 finishUnInstall unInstalled=$unInstalled"
)
finishUnInstall
.
invoke
(
unInstalled
)
cancel
()
}
}
}
}
inner
class
ScreenSlidePagerAdapter
(
fa
:
FragmentActivity
)
:
FragmentStateAdapter
(
fa
)
{
override
fun
getItemCount
():
Int
=
pages
.
size
override
fun
createFragment
(
position
:
Int
):
Fragment
=
pages
[
position
]
}
private
fun
isLaunchApp
(
context
:
Context
,
app
:
PackageInfo
,
filterSystem
:
Boolean
=
true
):
Boolean
{
val
flagSystem
=
(
app
.
applicationInfo
.
flags
and
ApplicationInfo
.
FLAG_SYSTEM
)
==
0
val
flagSelf
=
app
.
applicationInfo
.
packageName
!=
context
.
packageName
return
if
(
filterSystem
)
flagSystem
&&
flagSelf
else
flagSelf
}
private
fun
setAppInstallTime
(
appBean
:
AppBean
,
context
:
Context
)
{
//安装时间
var
firstInstallTime
=
0L
try
{
val
packageManager
=
context
.
packageManager
val
packageInfo
:
PackageInfo
=
packageManager
.
getPackageInfo
(
appBean
.
pkg
,
0
)
//应用装时间
firstInstallTime
=
packageInfo
.
firstInstallTime
//应用最后一次更新时间
val
lastUpdateTime
=
packageInfo
.
lastUpdateTime
// LogEx.logDebug(TAG, "lastUpdateTime=$lastUpdateTime")
}
catch
(
e
:
PackageManager
.
NameNotFoundException
)
{
e
.
printStackTrace
()
}
appBean
.
installTime
=
firstInstallTime
}
/**
* 前台运行App+后台运行App=总的启动App
*/
private
fun
getUsageList
(
context
:
Context
,
startTime
:
Long
,
endTime
:
Long
):
ArrayList
<
UsageStats
>
{
val
list
=
arrayListOf
<
UsageStats
>()
val
mUsmManager
=
context
.
getSystemService
(
Context
.
USAGE_STATS_SERVICE
)
as
UsageStatsManager
val
map
=
mUsmManager
.
queryAndAggregateUsageStats
(
startTime
,
endTime
)
map
.
values
.
forEach
{
stats
->
if
(
stats
.
totalTimeInForeground
>
0
)
{
list
.
add
(
stats
)
}
else
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
Q
)
{
if
(
stats
.
totalTimeForegroundServiceUsed
>
0
)
{
list
.
add
(
stats
)
}
}
}
}
return
list
}
private
fun
isInstalled
(
context
:
Context
,
pkg
:
String
,
error
:
(()
->
Unit
)?
=
null
):
Boolean
{
return
try
{
context
.
packageManager
.
getPackageInfo
(
pkg
,
0
)
true
}
catch
(
e
:
Exception
)
{
error
?.
invoke
()
false
}
}
companion
object
{
}
}
app/src/main/java/com/test/easy/easycleanerjunk/activity/BatteryInfoActivity.kt
deleted
100644 → 0
View file @
47b8bf8a
package
com.test.easy.easycleanerjunk.activity
import
android.animation.Animator
import
android.annotation.SuppressLint
import
android.content.BroadcastReceiver
import
android.content.Context
import
android.content.Intent
import
android.content.IntentFilter
import
android.hardware.camera2.CameraAccessException
import
android.hardware.camera2.CameraManager
import
android.location.LocationManager
import
android.os.BatteryManager
import
android.os.Build
import
android.os.SystemClock
import
android.provider.Settings
import
android.view.View
import
android.widget.Toast
import
androidx.activity.addCallback
import
androidx.activity.result.contract.ActivityResultContracts
import
androidx.core.view.isVisible
import
com.test.easy.easycleanerjunk.R
import
com.test.easy.easycleanerjunk.databinding.ActivityBatteryInfoBinding
import
com.test.easy.easycleanerjunk.helps.BaseActivity
import
com.test.easy.easycleanerjunk.helps.ads.AdmobUtils
import
com.test.easy.easycleanerjunk.view.AFunOb
import
java.util.Calendar
import
java.util.Date
import
kotlin.math.roundToInt
@SuppressLint
(
"SetTextI18n"
)
class
BatteryInfoActivity
:
BaseActivity
<
ActivityBatteryInfoBinding
>()
{
override
val
isLightMode
=
true
private
lateinit
var
receiver
:
BatteryReceiver
private
lateinit
var
cm
:
CameraManager
private
lateinit
var
cameraId
:
String
private
var
isTorchOn
=
false
override
val
binding
:
ActivityBatteryInfoBinding
by
lazy
{
ActivityBatteryInfoBinding
.
inflate
(
layoutInflater
)
}
override
fun
initView
()
{
receiver
=
BatteryReceiver
()
val
filter
=
IntentFilter
(
Intent
.
ACTION_BATTERY_CHANGED
)
registerReceiver
(
receiver
,
filter
)
cm
=
getSystemService
(
Context
.
CAMERA_SERVICE
)
as
CameraManager
try
{
cameraId
=
cm
.
cameraIdList
[
0
]
}
catch
(
e
:
CameraAccessException
)
{
e
.
printStackTrace
()
}
setFilter
()
binding
.
idBatteryLottie
.
imageAssetsFolder
=
"easy_battery_scan/images/"
binding
.
idBatteryLottie
.
setAnimation
(
"easy_battery_scan/data.json"
)
binding
.
idBatteryLottie
.
playAnimation
()
binding
.
root
.
postDelayed
({
playFinish
()
},
5000
)
binding
.
switchTwo
.
setOnClickListener
{
turnOnBluetooth
()
}
binding
.
switchThree
.
setOnCheckedChangeListener
{
_
,
isChecked
->
if
(
isChecked
)
{
turnOnFlashLight
()
}
else
{
turnOffFlashLight
()
}
}
binding
.
switchFour
.
setOnClickListener
{
jumpLocationSettings
()
}
binding
.
btOk
.
setOnClickListener
{
AdmobUtils
.
showInterstitialAd
(
this
)
{
binding
.
btOk
.
setBackgroundResource
(
R
.
drawable
.
bg_shape_set_click
)
startActivity
(
Intent
(
this
,
ResultActivity
::
class
.
java
).
apply
{
putExtra
(
"from"
,
AFunOb
.
BATTERY_INFO
)
})
finish
()
}
}
binding
.
ivBack
.
setOnClickListener
{
AdmobUtils
.
showInterstitialAd
(
this
@BatteryInfoActivity
)
{
finishToMain
()
}
}
onBackPressedDispatcher
.
addCallback
{
AdmobUtils
.
showInterstitialAd
(
this
@BatteryInfoActivity
)
{
finishToMain
()
}
}
}
private
val
result1
=
registerForActivityResult
(
ActivityResultContracts
.
StartActivityForResult
())
{
}
private
val
settingResult
=
registerForActivityResult
(
ActivityResultContracts
.
StartActivityForResult
())
{
}
private
inner
class
BatteryReceiver
:
BroadcastReceiver
()
{
override
fun
onReceive
(
context
:
Context
?,
intent
:
Intent
?)
{
val
current
=
intent
?.
extras
?.
getInt
(
"level"
)
?:
0
val
total
=
intent
?.
extras
?.
getInt
(
"scale"
)
?:
0
val
percent
=
current
*
100
/
total
if
(
percent
>=
30
)
{
binding
.
imagePower
.
setImageResource
(
R
.
drawable
.
batteryl
)
}
else
{
binding
.
imagePower
.
setImageResource
(
R
.
drawable
.
batteryh
)
}
val
voltage
=
intent
?.
getIntExtra
(
"voltage"
,
0
)
?.
toFloat
()
?.
roundToInt
()
?:
0
binding
.
tvVo
.
text
=
"${voltage / 1000f}V"
val
temperature
=
intent
?.
getIntExtra
(
"temperature"
,
0
)
?.
toFloat
()
?.
roundToInt
()
?:
0
binding
.
tvTemp
.
text
=
"${temperature / 10f}°C"
binding
.
tvLevel
.
text
=
"$percent%"
}
}
private
fun
playFinish
()
{
binding
.
idConsOne
.
isVisible
=
false
binding
.
idConsBatteryFinish
.
isVisible
=
true
binding
.
idBatteryFinish
.
addAnimatorListener
(
object
:
Animator
.
AnimatorListener
{
override
fun
onAnimationStart
(
p0
:
Animator
)
{
}
override
fun
onAnimationEnd
(
p0
:
Animator
)
{
AdmobUtils
.
showInterstitialAd
(
this
@BatteryInfoActivity
)
{
updateUI
()
}
}
override
fun
onAnimationCancel
(
p0
:
Animator
)
{
}
override
fun
onAnimationRepeat
(
p0
:
Animator
)
{
}
})
}
private
fun
checkFlashLight
()
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
M
)
{
cm
.
registerTorchCallback
(
object
:
CameraManager
.
TorchCallback
()
{
override
fun
onTorchModeChanged
(
cameraId
:
String
,
enabled
:
Boolean
)
{
super
.
onTorchModeChanged
(
cameraId
,
enabled
)
if
(
cameraId
==
this
@BatteryInfoActivity
.
cameraId
)
{
if
(
enabled
&&
!
isTorchOn
)
{
isTorchOn
=
true
binding
.
switchThree
.
isChecked
=
true
}
else
if
(!
enabled
&&
isTorchOn
)
{
isTorchOn
=
false
binding
.
switchThree
.
isChecked
=
false
}
}
}
},
null
)
}
else
{
Toast
.
makeText
(
this
,
"don't support you phone"
,
Toast
.
LENGTH_SHORT
).
show
()
}
}
private
fun
turnOnFlashLight
()
{
try
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
M
)
{
cm
.
setTorchMode
(
cameraId
,
true
)
}
// 打开手电筒
}
catch
(
e
:
CameraAccessException
)
{
e
.
printStackTrace
()
}
}
private
fun
turnOffFlashLight
()
{
try
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
M
)
{
cm
.
setTorchMode
(
cameraId
,
false
)
}
// 打开手电筒
}
catch
(
e
:
CameraAccessException
)
{
e
.
printStackTrace
()
}
}
private
fun
jumpLocationSettings
()
{
val
intent
=
Intent
(
Settings
.
ACTION_LOCATION_SOURCE_SETTINGS
)
settingResult
.
launch
(
intent
)
}
private
fun
checkLocation
()
{
binding
.
switchFour
.
isChecked
=
isLocationEnabled
(
this
)
}
private
fun
isLocationEnabled
(
context
:
Context
):
Boolean
{
val
locationManager
=
context
.
getSystemService
(
Context
.
LOCATION_SERVICE
)
as
LocationManager
return
locationManager
.
isProviderEnabled
(
LocationManager
.
GPS_PROVIDER
)
||
locationManager
.
isProviderEnabled
(
LocationManager
.
NETWORK_PROVIDER
)
}
private
fun
setFilter
()
{
val
uptime
=
SystemClock
.
elapsedRealtime
()
val
currantTime
=
Calendar
.
getInstance
().
time
val
batteryUseTime
=
currantTime
.
time
-
uptime
val
batteryDate
=
Date
(
batteryUseTime
)
binding
.
tvTime
.
text
=
"${batteryDate.hours} H ${batteryDate.minutes} M"
val
bm
=
getSystemService
(
Context
.
BATTERY_SERVICE
)
as
BatteryManager
val
chargeCounter
=
bm
.
getIntProperty
(
BatteryManager
.
BATTERY_PROPERTY_CHARGE_COUNTER
)
val
pCapacity
=
bm
.
getIntProperty
(
BatteryManager
.
BATTERY_PROPERTY_CAPACITY
)
if
(
chargeCounter
!=
Int
.
MIN_VALUE
&&
pCapacity
!=
Int
.
MIN_VALUE
)
{
binding
.
tvMa
.
text
=
"${
String
.
format
(
"%.1f"
,
(
chargeCounter
/
(
pCapacity
.
toFloat
()
/
100f
))
/
1000f
)
}
mAh
"
}
}
private
fun
updateUI
()
{
binding
.
idBatteryLottie
.
visibility
=
View
.
GONE
binding
.
idConsBatteryFinish
.
isVisible
=
false
binding
.
llContent
.
isVisible
=
true
}
override
fun
onResume
()
{
super
.
onResume
()
binding
.
btOk
.
setBackgroundResource
(
R
.
drawable
.
bg_shape_set
)
checkFlashLight
()
checkLocation
()
}
fun
turnOnBluetooth
()
{
val
intent2
=
Intent
(
Settings
.
ACTION_BLUETOOTH_SETTINGS
)
result1
.
launch
(
intent2
)
}
override
fun
onDestroy
()
{
super
.
onDestroy
()
unregisterReceiver
(
receiver
)
binding
?.
idBatteryLottie
?.
clearAnimation
()
}
}
\ No newline at end of file
app/src/main/java/com/test/easy/easycleanerjunk/activity/DeviceScanInfoActivity.kt
deleted
100644 → 0
View file @
47b8bf8a
package
com.test.easy.easycleanerjunk.activity
import
android.annotation.SuppressLint
import
android.content.Context
import
android.content.Intent
import
android.net.ConnectivityManager
import
android.net.wifi.WifiManager
import
android.os.Build
import
android.os.Environment
import
android.os.StatFs
import
androidx.activity.addCallback
import
com.test.easy.easycleanerjunk.databinding.ActivityDeviceScanInfoBinding
import
com.test.easy.easycleanerjunk.helps.BaseActivity
import
com.test.easy.easycleanerjunk.helps.KotlinExt.toFormatSize
import
com.test.easy.easycleanerjunk.helps.LogEx
import
com.test.easy.easycleanerjunk.helps.ads.AdmobUtils
import
com.test.easy.easycleanerjunk.utils.DeviceUtils
import
com.test.easy.easycleanerjunk.view.AFunOb
import
java.io.BufferedReader
import
java.io.File
import
java.io.FileReader
import
java.io.IOException
import
java.nio.file.Files
import
java.nio.file.Paths
import
java.util.Locale
class
DeviceScanInfoActivity
:
BaseActivity
<
ActivityDeviceScanInfoBinding
>()
{
private
val
TAG
=
"DeviceScanActivity"
override
val
binding
:
ActivityDeviceScanInfoBinding
by
lazy
{
ActivityDeviceScanInfoBinding
.
inflate
(
layoutInflater
)
}
@SuppressLint
(
"SetTextI18n"
)
override
fun
initView
()
{
binding
.
tvDeviceName
.
text
=
getDeviceName
()
binding
.
tvAndroidVersion
.
text
=
"System Version: Android ${Build.VERSION.RELEASE}"
binding
.
tvAbis
.
text
=
DeviceUtils
.
getABIs
().
toStringEx
()
val
cupInfo
=
cpuInfo
()
cupInfo
.
forEach
{
LogEx
.
logDebug
(
TAG
,
"cupInfo $it"
)
}
binding
.
tvCpuCores
.
text
=
cupInfo
.
find
{
it
.
contains
(
"CPU architecture"
)
}
?.
split
(
":"
)
?.
get
(
1
)
binding
.
tvIpAddress
.
text
=
if
(
isWifiConnected
(
this
))
getWifiIpAddress
(
this
)
else
""
binding
.
tvSsid
.
text
=
getWifiSSID
(
this
)
binding
.
tvLinkSpeed
.
text
=
"${getWifiLinkSpeed(this)} Mbps"
binding
.
tvCpuFrequency
.
text
=
"${getCpuFreq("
cpuinfo_min_freq
") / 1000}MHZ - ${getCpuFreq("
cpuinfo_max_freq
") / 1000}MHZ"
binding
.
tvCpuHardware
.
text
=
getCpuHardware
()
}
override
fun
initListener
()
{
binding
.
tvOk
.
setOnClickListener
{
startActivity
(
Intent
(
this
,
ResultActivity
::
class
.
java
).
apply
{
putExtra
(
"from"
,
AFunOb
.
DEVICE_SCAN
)
})
}
binding
.
flBack
.
setOnClickListener
{
onBackPressedDispatcher
.
onBackPressed
()
}
onBackPressedDispatcher
.
addCallback
{
AdmobUtils
.
showInterstitialAd
(
this
@DeviceScanInfoActivity
){
finishToMain
()
}
}
}
private
fun
capitalize
(
str
:
String
?):
String
?
{
return
if
(
str
.
isNullOrEmpty
())
{
str
}
else
str
.
substring
(
0
,
1
).
uppercase
(
Locale
.
getDefault
())
+
str
.
substring
(
1
).
lowercase
(
Locale
.
getDefault
())
}
fun
getDeviceName
():
String
?
{
val
manufacturer
=
Build
.
MANUFACTURER
val
model
=
Build
.
MODEL
return
if
(
model
.
lowercase
(
Locale
.
getDefault
()).
startsWith
(
manufacturer
.
lowercase
(
Locale
.
getDefault
())))
{
capitalize
(
model
)
}
else
capitalize
(
manufacturer
)
+
" "
+
model
}
private
fun
cpuInfo
():
ArrayList
<
String
>
{
val
cpuList
:
ArrayList
<
String
>
=
arrayListOf
()
try
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
val
cpuInfo
=
String
(
Files
.
readAllBytes
(
Paths
.
get
(
"/proc/cpuinfo"
)))
LogEx
.
logDebug
(
TAG
,
"$cpuInfo"
)
val
arrays
=
cpuInfo
.
split
(
"\n"
)
cpuList
.
addAll
(
arrays
)
}
}
catch
(
e
:
IOException
)
{
e
.
printStackTrace
()
}
return
cpuList
}
fun
isWifiConnected
(
context
:
Context
):
Boolean
{
val
connectivityManager
=
context
.
getSystemService
(
CONNECTIVITY_SERVICE
)
as
ConnectivityManager
val
networkInfo
=
connectivityManager
.
activeNetworkInfo
// 检查networkInfo是否为null以及是否连接到Wi-Fi
return
networkInfo
!=
null
&&
networkInfo
.
type
==
ConnectivityManager
.
TYPE_WIFI
}
fun
getWifiIpAddress
(
context
:
Context
):
String
{
val
wifiManager
=
context
.
getSystemService
(
WIFI_SERVICE
)
as
WifiManager
val
wifiInfo
=
wifiManager
.
connectionInfo
val
ip
=
wifiInfo
.
ipAddress
return
if
(
ip
==
0
)
{
"No network connection"
}
else
(
ip
and
0
xff
).
toString
()
+
"."
+
(
ip
shr
8
and
0
xff
)
+
"."
+
(
ip
shr
16
and
0
xff
)
+
"."
+
(
ip
shr
24
and
0
xff
)
}
fun
getMobileIpAddress
(
context
:
Context
):
String
{
val
connectivityManager
=
context
.
getSystemService
(
CONNECTIVITY_SERVICE
)
as
ConnectivityManager
val
activeNetwork
=
connectivityManager
.
activeNetworkInfo
return
if
(
activeNetwork
!=
null
&&
activeNetwork
.
isConnected
)
{
activeNetwork
.
extraInfo
.
toString
().
split
(
" "
.
toRegex
()).
dropLastWhile
{
it
.
isEmpty
()
}.
toTypedArray
()[
1
].
trim
{
it
<=
' '
}
}
else
"No network connection"
}
fun
getWifiSSID
(
context
:
Context
):
String
?
{
val
wifiManager
=
context
.
getSystemService
(
WIFI_SERVICE
)
as
WifiManager
val
wifiInfo
=
wifiManager
.
connectionInfo
if
(
wifiInfo
!=
null
)
{
val
ssid
=
wifiInfo
.
ssid
// 移除SSID周围的双引号
return
if
(
ssid
!=
null
&&
ssid
.
isNotEmpty
())
ssid
.
replace
(
"\""
.
toRegex
(),
""
)
else
null
}
return
"<unknown ssid>"
}
/**
* 获取当前Wi-Fi连接的链路速度。
*
* @param context Android上下文对象。
* @return 链路速度,单位为Mbps。如果没有连接到Wi-Fi或无法获取,则返回-1。
*/
fun
getWifiLinkSpeed
(
context
:
Context
):
Int
{
val
wifiManager
=
context
.
getSystemService
(
WIFI_SERVICE
)
as
WifiManager
val
wifiInfo
=
wifiManager
.
connectionInfo
// 获取Wi-Fi链路速度,单位为Mbps
return
wifiInfo
?.
linkSpeed
?:
-
1
}
/**
* @param filePath
* cpuinfo_cur_freq
* cpuinfo_min_freq
* cpuinfo_max_freq
* scaling_available_frequencies
*
* @return 返回数据 546000KHZ=546MHZ
*/
fun
getCpuFreq
(
filePath
:
String
):
Int
{
val
scalingPath
=
"/sys/devices/system/cpu/cpu0/cpufreq/"
val
path
=
File
(
scalingPath
+
filePath
)
var
frequency
=
0
try
{
if
(
path
.
exists
())
{
val
reader
=
BufferedReader
(
FileReader
(
path
))
val
line
=
reader
.
readLine
()
reader
.
close
()
if
(
line
!=
null
)
{
// 处理读取到的频率值
LogEx
.
logDebug
(
"CPU Frequency"
,
"$filePath: $line kHz"
)
frequency
=
line
.
toInt
()
}
}
}
catch
(
e
:
IOException
)
{
e
.
printStackTrace
()
}
return
frequency
}
@SuppressLint
(
"PrivateApi"
)
fun
getCpuHardware
():
String
{
val
classType
=
Class
.
forName
(
"android.os.SystemProperties"
)
val
method
=
classType
.
getDeclaredMethod
(
"get"
,
String
::
class
.
java
)
val
result
=
method
.
invoke
(
classType
,
"ro.board.platform"
)
as
String
return
result
}
private
fun
<
T
>
Array
<
T
>.
toStringEx
():
String
{
val
sb
=
StringBuffer
()
sb
.
append
(
"["
)
forEachIndexed
{
index
,
t
->
if
(
index
==
size
-
1
)
{
sb
.
append
(
"$t"
)
}
else
{
sb
.
append
(
"$t"
).
append
(
","
)
}
}
sb
.
append
(
"]"
)
return
sb
.
toString
()
}
}
\ No newline at end of file
app/src/main/java/com/test/easy/easycleanerjunk/activity/NetWorkActivity.kt
deleted
100644 → 0
View file @
47b8bf8a
package
com.test.easy.easycleanerjunk.activity
import
android.annotation.SuppressLint
import
android.app.AppOpsManager
import
android.app.usage.NetworkStats
import
android.app.usage.NetworkStatsManager
import
android.content.Context
import
android.graphics.Color
import
android.net.ConnectivityManager
import
android.os.Build
import
android.util.SparseLongArray
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
android.widget.ImageView
import
android.widget.ProgressBar
import
android.widget.TextView
import
androidx.activity.OnBackPressedCallback
import
androidx.core.util.forEach
import
androidx.core.view.isVisible
import
androidx.core.view.updatePadding
import
androidx.recyclerview.widget.LinearLayoutManager
import
androidx.recyclerview.widget.RecyclerView
import
com.test.easy.easycleanerjunk.R
import
com.test.easy.easycleanerjunk.bean.AppInfo
import
com.test.easy.easycleanerjunk.bean.TrafficBean
import
com.test.easy.easycleanerjunk.databinding.ActivityLayoutNetworkBinding
import
com.test.easy.easycleanerjunk.helps.BaseActivity
import
com.test.easy.easycleanerjunk.helps.BaseApplication
import
com.test.easy.easycleanerjunk.helps.KotlinExt.toFormatSize
import
com.test.easy.easycleanerjunk.helps.NetworkStatsHelper
import
com.test.easy.easycleanerjunk.helps.ads.AdmobUtils
import
com.test.easy.easycleanerjunk.utils.AppUtils
import
com.test.easy.easycleanerjunk.utils.BarUtils
import
com.test.easy.easycleanerjunk.view.DialogViews
import
kotlin.random.Random
class
NetWorkActivity
:
BaseActivity
<
ActivityLayoutNetworkBinding
>()
{
private
val
TAG
=
"NetWorkActivity"
private
var
appList
=
mutableListOf
<
AppInfo
>()
private
val
wifiList
=
mutableListOf
<
TrafficBean
>()
private
val
mobileList
=
mutableListOf
<
TrafficBean
>()
private
val
AllList
=
mutableListOf
<
TrafficBean
>()
private
var
startTime
=
NetworkStatsHelper
.
getTimesMonthmorning
()
private
var
types
=
2
private
var
ifPlayAnimal
=
false
override
fun
onStart
()
{
super
.
onStart
()
if
(
ifPlayAnimal
)
{
hasAccessSettings
()
}
}
private
fun
hasAccessSettings
()
{
val
appOpsManager
=
getSystemService
(
Context
.
APP_OPS_SERVICE
)
as
AppOpsManager
if
(
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
Q
)
{
appOpsManager
.
unsafeCheckOpNoThrow
(
AppOpsManager
.
OPSTR_GET_USAGE_STATS
,
android
.
os
.
Process
.
myUid
(),
this
.
packageName
)
==
AppOpsManager
.
MODE_ALLOWED
}
else
{
appOpsManager
.
checkOpNoThrow
(
AppOpsManager
.
OPSTR_GET_USAGE_STATS
,
android
.
os
.
Process
.
myUid
(),
this
.
packageName
)
==
AppOpsManager
.
MODE_ALLOWED
})
{
binding
.
idLlNoAccpermion
.
isVisible
=
false
initList
()
}
else
{
binding
.
idLlNoAccpermion
.
isVisible
=
true
}
}
override
fun
onDestroy
()
{
super
.
onDestroy
()
binding
.
idLottieNetwork
.
clearAnimation
()
}
private
fun
playLottie
()
{
binding
.
idLlNetDh
.
isVisible
=
true
binding
.
idLottieNetwork
.
imageAssetsFolder
=
"easy_network_scan/images/"
binding
.
idLottieNetwork
.
setAnimation
(
"easy_network_scan/data.json"
)
binding
.
idLottieNetwork
.
playAnimation
()
binding
.
root
.
postDelayed
({
AdmobUtils
.
showInterstitialAd
(
this
)
{
binding
.
idLottieNetwork
.
pauseAnimation
()
binding
.
idLlNetDh
.
isVisible
=
false
ifPlayAnimal
=
true
hasAccessSettings
()
}
},
Random
.
nextLong
(
2500
,
4000
))
}
override
val
binding
:
ActivityLayoutNetworkBinding
by
lazy
{
ActivityLayoutNetworkBinding
.
inflate
(
layoutInflater
)
}
override
fun
initView
()
{
BarUtils
.
setStatusBarLightMode
(
this
,
true
)
BarUtils
.
setStatusBarColor
(
this
,
Color
.
TRANSPARENT
)
binding
.
root
.
updatePadding
(
top
=
BarUtils
.
getStatusBarHeight
())
binding
.
idTvThisMonth
.
isSelected
=
true
playLottie
()
}
@SuppressLint
(
"SetTextI18n"
)
override
fun
initListener
()
{
binding
.
idBackNetwork
.
setOnClickListener
{
onBackPressedDispatcher
.
onBackPressed
()
}
onBackPressedDispatcher
.
addCallback
(
object
:
OnBackPressedCallback
(
true
)
{
override
fun
handleOnBackPressed
()
{
AdmobUtils
.
showInterstitialAd
(
this
@NetWorkActivity
)
{
finishToMain
()
}
}
})
binding
.
idGant
.
setOnClickListener
{
checkAccesSettings
(
true
)
}
binding
.
idTvThisMonth
.
setOnClickListener
{
clickTop
(
0
)
startTime
=
NetworkStatsHelper
.
getTimesMonthmorning
()
setData
()
}
binding
.
id30Day
.
setOnClickListener
{
clickTop
(
1
)
startTime
=
NetworkStatsHelper
.
getNeedTime
(
30
)
setData
()
}
binding
.
id24Hours
.
setOnClickListener
{
clickTop
(
2
)
startTime
=
NetworkStatsHelper
.
getNeedTime
(
1
)
setData
()
}
binding
.
idTvTypes
.
setOnClickListener
{
DialogViews
.
showBothTypes
(
this
)
{
when
(
it
)
{
0
->
{
binding
.
idTvTypes
.
text
=
"Mobile Network"
types
=
0
}
1
->
{
binding
.
idTvTypes
.
text
=
"Wi-Fi"
types
=
1
}
2
->
{
binding
.
idTvTypes
.
text
=
"Both types"
types
=
2
}
}
setData
()
}
}
}
private
fun
clickTop
(
p
:
Int
)
{
listOf
(
binding
.
idTvThisMonth
,
binding
.
id30Day
,
binding
.
id24Hours
).
forEachIndexed
{
index
,
view
->
view
.
isSelected
=
p
==
index
}
}
private
fun
initList
()
{
appList
=
AppUtils
.
getAppsInfo
()
setData
()
}
private
fun
setData
()
{
val
allMobile
=
getNetworkStats
(
ConnectivityManager
.
TYPE_MOBILE
,
startTime
,
System
.
currentTimeMillis
())
val
allWifi
=
getNetworkStats
(
ConnectivityManager
.
TYPE_WIFI
,
startTime
,
System
.
currentTimeMillis
())
AllList
.
clear
()
mobileList
.
clear
()
wifiList
.
clear
()
var
mobileSize
=
0L
allMobile
.
forEach
{
key
,
value
->
mobileSize
+=
value
val
appPkg
=
packageManager
.
getPackagesForUid
(
key
)
if
(
appPkg
?.
isNotEmpty
()
==
true
)
{
val
bean
=
TrafficBean
(
1
,
appPkg
[
0
],
0
,
value
)
mobileList
.
add
(
bean
)
}
}
mobileList
.
sortByDescending
{
it
.
mobileUsed
}
binding
.
idMobileLiuliang
.
text
=
mobileSize
.
toFormatSize
()
var
wifi
=
0L
allWifi
.
forEach
{
key
,
value
->
wifi
+=
value
val
appPkg
=
packageManager
.
getPackagesForUid
(
key
)
if
(
appPkg
?.
isNotEmpty
()
==
true
)
{
val
bean
=
TrafficBean
(
2
,
appPkg
[
0
],
value
,
0
)
wifiList
.
add
(
bean
)
}
}
binding
.
idWifiLiuliang
.
text
=
wifi
.
toFormatSize
()
wifiList
.
sortByDescending
{
it
.
wifiUsed
}
val
map
=
hashMapOf
<
String
,
TrafficBean
>()
if
(
types
!=
0
)
{
for
(
bean
in
wifiList
)
{
map
[
bean
.
packageName
]
=
bean
}
}
if
(
types
!=
1
)
{
for
(
bean
in
mobileList
)
{
if
(
map
.
containsKey
(
bean
.
packageName
))
{
val
oldBean
=
map
[
bean
.
packageName
]
oldBean
?.
type
=
oldBean
?.
type
?.
plus
(
bean
.
type
)
?:
bean
.
type
oldBean
?.
mobileUsed
=
oldBean
?.
mobileUsed
?.
plus
(
bean
.
mobileUsed
)
?:
bean
.
mobileUsed
oldBean
?.
wifiUsed
=
oldBean
?.
wifiUsed
?.
plus
(
bean
.
wifiUsed
)
?:
bean
.
wifiUsed
}
else
{
map
[
bean
.
packageName
]
=
bean
}
}
}
for
(
value
in
map
.
values
)
{
AllList
.
add
(
value
)
}
AllList
.
sortByDescending
{
it
.
mobileUsed
+
it
.
wifiUsed
}
AllList
.
removeAll
(
AllList
.
filter
{
it
.
packageName
==
this
.
packageName
})
if
(
AllList
.
isNotEmpty
())
{
binding
.
idTvNoData
.
isVisible
=
false
binding
.
idRlNetworkTra
.
run
{
layoutManager
=
LinearLayoutManager
(
context
)
adapter
=
mAdapter
}
}
else
{
mAdapter
.
notifyDataSetChanged
()
binding
.
idTvNoData
.
isVisible
=
true
}
}
fun
getNetworkStats
(
uid
:
Int
,
start
:
Long
,
end
:
Long
):
SparseLongArray
{
val
result
=
SparseLongArray
()
val
bucket
=
NetworkStats
.
Bucket
()
try
{
val
manager
=
this
.
getSystemService
(
Context
.
NETWORK_STATS_SERVICE
)
as
NetworkStatsManager
val
stats
=
manager
.
querySummary
(
uid
,
null
,
start
,
end
)
while
(
stats
.
hasNextBucket
())
{
stats
.
getNextBucket
(
bucket
)
val
currentUid
=
bucket
.
uid
val
txBytes
=
bucket
.
txBytes
val
rxBytes
=
bucket
.
rxBytes
val
totalBytes
=
txBytes
+
rxBytes
val
existingBytes
=
result
[
currentUid
,
0
]
if
(
existingBytes
==
0L
)
{
result
.
put
(
currentUid
,
totalBytes
)
}
else
{
result
.
put
(
currentUid
,
totalBytes
+
existingBytes
)
}
}
var
b
=
0L
result
.
forEach
{
key
,
value
->
val
a
=
packageManager
.
getPackagesForUid
(
key
)
if
(
a
?.
isNotEmpty
()
==
true
)
{
b
+=
value
}
}
stats
.
close
()
}
catch
(
_
:
Exception
)
{
}
return
result
}
private
val
mAdapter
by
lazy
{
class
ViewHolder
(
view
:
View
)
:
RecyclerView
.
ViewHolder
(
view
)
{
val
ivImage
:
ImageView
val
tvName
:
TextView
val
tvTraffic
:
TextView
val
wifiPro
:
ProgressBar
val
mobilePro
:
ProgressBar
val
tvstop
:
TextView
init
{
ivImage
=
view
.
findViewById
(
R
.
id
.
id_icon
)
tvName
=
view
.
findViewById
(
R
.
id
.
id_name
)
tvTraffic
=
view
.
findViewById
(
R
.
id
.
id_tra_used
)
wifiPro
=
view
.
findViewById
(
R
.
id
.
id_wifi_pro
)
mobilePro
=
view
.
findViewById
(
R
.
id
.
id_mobile_pro
)
tvstop
=
view
.
findViewById
(
R
.
id
.
id_tv_stop
)
}
}
object
:
RecyclerView
.
Adapter
<
ViewHolder
>()
{
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
ViewHolder
{
val
view
=
LayoutInflater
.
from
(
this
@NetWorkActivity
).
inflate
(
R
.
layout
.
item_app_used_traffic
,
parent
,
false
)
return
ViewHolder
(
view
)
}
override
fun
getItemCount
()
=
AllList
.
size
@SuppressLint
(
"SetTextI18n"
)
override
fun
onBindViewHolder
(
holder
:
ViewHolder
,
position
:
Int
)
{
val
c
=
appList
.
firstOrNull
{
it
.
packageName
==
AllList
[
position
].
packageName
}
holder
.
ivImage
.
setImageDrawable
(
c
?.
icon
)
holder
.
tvName
.
text
=
c
?.
name
holder
.
tvTraffic
.
text
=
(
AllList
[
position
].
wifiUsed
+
AllList
[
position
].
mobileUsed
).
toFormatSize
()
holder
.
wifiPro
.
max
=
(
AllList
[
0
].
wifiUsed
+
AllList
[
0
].
mobileUsed
).
toInt
()
holder
.
mobilePro
.
max
=
(
AllList
[
0
].
wifiUsed
+
AllList
[
0
].
mobileUsed
).
toInt
()
holder
.
wifiPro
.
progress
=
(
AllList
[
position
].
wifiUsed
+
AllList
[
position
].
mobileUsed
).
toInt
()
holder
.
mobilePro
.
progress
=
(
AllList
[
position
].
mobileUsed
).
toInt
()
holder
.
tvstop
.
isEnabled
=
NetworkStatsHelper
.
canStop
(
this
@NetWorkActivity
,
AllList
[
position
].
packageName
)
holder
.
tvstop
.
setOnClickListener
{
AppUtils
.
jumpToAppSettings
(
BaseApplication
.
context
,
AllList
[
position
].
packageName
)
}
holder
.
itemView
.
setOnClickListener
{
}
}
override
fun
onBindViewHolder
(
holder
:
ViewHolder
,
position
:
Int
,
payloads
:
MutableList
<
Any
>
)
{
super
.
onBindViewHolder
(
holder
,
position
,
payloads
)
}
}
}
}
\ No newline at end of file
app/src/main/java/com/test/easy/easycleanerjunk/activity/PermissionManagerActivity.kt
deleted
100644 → 0
View file @
47b8bf8a
package
com.test.easy.easycleanerjunk.activity
import
android.Manifest
import
android.annotation.SuppressLint
import
android.content.Intent
import
android.content.pm.PackageInfo
import
android.content.pm.PackageManager
import
android.content.pm.PackageManager.NameNotFoundException
import
android.net.Uri
import
android.provider.Settings
import
android.view.View
import
androidx.core.view.ViewCompat
import
androidx.core.view.WindowInsetsCompat
import
com.test.easy.easycleanerjunk.R
import
com.test.easy.easycleanerjunk.adapter.PermissionAdapter
import
com.test.easy.easycleanerjunk.bean.AppBean
import
com.test.easy.easycleanerjunk.bean.PermissionBean
import
com.test.easy.easycleanerjunk.bean.PermissionBean.Companion.setDesc
import
com.test.easy.easycleanerjunk.bean.PermissionBean.Companion.setTittle
import
com.test.easy.easycleanerjunk.databinding.ActivityPermissionManagerBinding
import
com.test.easy.easycleanerjunk.helps.BaseActivity
import
com.test.easy.easycleanerjunk.helps.LogEx
import
com.test.easy.easycleanerjunk.view.PermissionFilterDialog.showPermissionFilterDialog
class
PermissionManagerActivity
:
BaseActivity
<
ActivityPermissionManagerBinding
>()
{
override
val
isLightMode
=
true
private
val
TAG
=
"PermissionManagerActivity"
private
var
appBean
:
AppBean
?
=
null
private
val
appNormalPermissions
=
arrayListOf
<
PermissionBean
>()
private
val
appSensitivePermissions
=
arrayListOf
<
PermissionBean
>()
private
lateinit
var
normalAdapter
:
PermissionAdapter
private
lateinit
var
sensitiveAdapter
:
PermissionAdapter
private
var
normalExpand
=
true
private
var
sensitiveExpand
=
true
private
var
isAllPermission
=
true
//是否所有权限
override
val
binding
:
ActivityPermissionManagerBinding
by
lazy
{
ActivityPermissionManagerBinding
.
inflate
(
layoutInflater
)
}
override
fun
initView
()
{
ViewCompat
.
setOnApplyWindowInsetsListener
(
findViewById
(
R
.
id
.
main
))
{
v
,
insets
->
val
systemBars
=
insets
.
getInsets
(
WindowInsetsCompat
.
Type
.
systemBars
())
v
.
setPadding
(
systemBars
.
left
,
systemBars
.
top
,
systemBars
.
right
,
systemBars
.
bottom
)
insets
}
val
json
=
intent
.
extras
?.
getString
(
"AppBean"
)
LogEx
.
logDebug
(
TAG
,
"json=$json"
)
appBean
=
json
?.
let
{
AppBean
.
appBeanGson
.
fromJson
(
it
,
AppBean
::
class
.
java
)
}
LogEx
.
logDebug
(
TAG
,
"appBean=$appBean"
)
appBean
?.
apply
{
val
applicationInfo
=
packageManager
.
getApplicationInfo
(
this
.
pkg
,
PackageManager
.
GET_META_DATA
)
binding
.
ivIcon
.
setImageDrawable
(
packageManager
.
getApplicationIcon
(
applicationInfo
))
binding
.
tvName
.
text
=
this
.
appName
getAppPermissions
(
this
.
pkg
)
}
}
override
fun
initListener
()
{
binding
.
flBack
.
setOnClickListener
{
finish
()
}
binding
.
tvAdministration
.
setOnClickListener
{
val
intent
=
Intent
()
intent
.
setAction
(
Settings
.
ACTION_APPLICATION_DETAILS_SETTINGS
)
intent
.
setData
(
Uri
.
parse
(
"package:"
+
appBean
?.
pkg
))
startActivity
(
intent
)
}
binding
.
llNormal
.
setOnClickListener
{
normalExpand
=
!
normalExpand
setExpandCollapseNormal
()
}
binding
.
llSensitive
.
setOnClickListener
{
sensitiveExpand
=
!
sensitiveExpand
setExpandCollapseSensitive
()
}
binding
.
flFilter
.
setOnClickListener
{
showPermissionFilterDialog
(
allClick
=
{
if
(!
isAllPermission
)
{
changeAllPermission
()
normalExpand
=
true
setExpandCollapseNormal
()
}
isAllPermission
=
true
},
authorizedClick
=
{
if
(
isAllPermission
)
{
changeOnlyAuthorized
()
sensitiveExpand
=
true
setExpandCollapseSensitive
()
}
isAllPermission
=
false
}
)
}
}
private
fun
changeOnlyAuthorized
()
{
val
list1
=
appNormalPermissions
.
filter
{
it
.
isAuthorized
}
normalAdapter
.
setData
(
list1
)
binding
.
tvNormalNumber
.
text
=
list1
.
size
.
toString
()
val
list2
=
appSensitivePermissions
.
filter
{
it
.
isAuthorized
}
sensitiveAdapter
.
setData
(
list2
)
binding
.
tvSensitiveNumber
.
text
=
list2
.
size
.
toString
()
}
private
fun
changeAllPermission
()
{
normalAdapter
.
setData
(
appNormalPermissions
)
binding
.
tvNormalNumber
.
text
=
appNormalPermissions
.
size
.
toString
()
sensitiveAdapter
.
setData
(
appSensitivePermissions
)
binding
.
tvSensitiveNumber
.
text
=
appSensitivePermissions
.
size
.
toString
()
}
@SuppressLint
(
"StringFormatMatches"
,
"SetTextI18n"
)
private
fun
getAppPermissions
(
pkg
:
String
)
{
val
pm
=
this
.
packageManager
val
info
:
PackageInfo
try
{
info
=
pm
.
getPackageInfo
(
pkg
,
PackageManager
.
GET_PERMISSIONS
)
val
packagePermissions
:
Array
<
String
>?
=
info
.
requestedPermissions
?:
null
packagePermissions
?.
forEach
{
permission
->
LogEx
.
logDebug
(
TAG
,
"permission=$permission"
)
val
common
=
commonPermissions
.
find
{
it
.
permissionMatch
==
permission
}
common
?.
let
{
val
ss
=
pm
.
checkPermission
(
it
.
permissionMatch
,
pkg
)
==
PackageManager
.
PERMISSION_GRANTED
if
(
it
.
permissionMatch
==
Manifest
.
permission
.
INTERNET
)
{
LogEx
.
logDebug
(
TAG
,
"ss=$ss"
)
}
it
.
isAuthorized
=
ss
appNormalPermissions
.
add
(
it
)
}
val
sensitive
=
sensitivePermissions
.
find
{
it
.
permissionMatch
==
permission
}
sensitive
?.
let
{
it
.
isAuthorized
=
pm
.
checkPermission
(
it
.
permissionMatch
,
pkg
)
==
PackageManager
.
PERMISSION_GRANTED
appSensitivePermissions
.
add
(
it
)
}
}
}
catch
(
e
:
NameNotFoundException
)
{
e
.
printStackTrace
()
}
binding
.
tvDesc
.
text
=
"${appSensitivePermissions.size} Sensitive permissions"
appNormalPermissions
.
forEach
{
it
.
setTittle
()
it
.
setDesc
()
}
sensitivePermissions
.
forEach
{
it
.
setTittle
()
it
.
setDesc
()
}
binding
.
tvNormalNumber
.
text
=
appNormalPermissions
.
size
.
toString
()
binding
.
tvSensitiveNumber
.
text
=
appSensitivePermissions
.
size
.
toString
()
intiRv
()
}
private
fun
intiRv
()
{
normalAdapter
=
PermissionAdapter
()
binding
.
rvNormal
.
adapter
=
normalAdapter
normalAdapter
.
setData
(
appNormalPermissions
)
sensitiveAdapter
=
PermissionAdapter
()
binding
.
rvSensitive
.
adapter
=
sensitiveAdapter
sensitiveAdapter
.
setData
(
appSensitivePermissions
)
setExpandCollapseSensitive
()
setExpandCollapseNormal
()
}
private
fun
setExpandCollapseSensitive
()
{
if
(
sensitiveExpand
)
{
binding
.
ivArrowSensitive
.
setImageResource
(
R
.
drawable
.
hxiala_s
)
binding
.
rvSensitive
.
visibility
=
View
.
VISIBLE
}
else
{
binding
.
ivArrowSensitive
.
setImageResource
(
R
.
drawable
.
hxiala_x
)
binding
.
rvSensitive
.
visibility
=
View
.
GONE
}
}
private
fun
setExpandCollapseNormal
()
{
if
(
normalExpand
)
{
binding
.
ivArrowNormal
.
setImageResource
(
R
.
drawable
.
aa_xiala_s
)
binding
.
rvNormal
.
visibility
=
View
.
VISIBLE
}
else
{
binding
.
ivArrowNormal
.
setImageResource
(
R
.
drawable
.
aa_xiala_x
)
binding
.
rvNormal
.
visibility
=
View
.
GONE
}
}
companion
object
{
@SuppressLint
(
"InlinedApi"
)
val
commonPermissions
=
arrayListOf
(
PermissionBean
(
Manifest
.
permission
.
ACCESS_NETWORK_STATE
),
PermissionBean
(
Manifest
.
permission
.
ACCESS_WIFI_STATE
),
PermissionBean
(
Manifest
.
permission
.
BLUETOOTH
),
PermissionBean
(
Manifest
.
permission
.
BLUETOOTH_ADMIN
),
PermissionBean
(
Manifest
.
permission
.
BLUETOOTH_CONNECT
),
PermissionBean
(
Manifest
.
permission
.
BLUETOOTH_PRIVILEGED
),
PermissionBean
(
Manifest
.
permission
.
BLUETOOTH_SCAN
),
PermissionBean
(
Manifest
.
permission
.
CHANGE_NETWORK_STATE
),
PermissionBean
(
Manifest
.
permission
.
CHANGE_WIFI_STATE
),
PermissionBean
(
Manifest
.
permission
.
CONTROL_LOCATION_UPDATES
),
PermissionBean
(
Manifest
.
permission
.
DELETE_PACKAGES
),
PermissionBean
(
Manifest
.
permission
.
INSTALL_PACKAGES
),
PermissionBean
(
Manifest
.
permission
.
INTERNET
),
PermissionBean
(
Manifest
.
permission
.
MANAGE_EXTERNAL_STORAGE
),
PermissionBean
(
Manifest
.
permission
.
MANAGE_MEDIA
),
PermissionBean
(
Manifest
.
permission
.
MANAGE_WIFI_NETWORK_SELECTION
),
PermissionBean
(
Manifest
.
permission
.
MODIFY_AUDIO_SETTINGS
),
PermissionBean
(
Manifest
.
permission
.
NFC
),
PermissionBean
(
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
),
PermissionBean
(
Manifest
.
permission
.
READ_MEDIA_AUDIO
),
PermissionBean
(
Manifest
.
permission
.
READ_MEDIA_IMAGES
),
PermissionBean
(
Manifest
.
permission
.
READ_MEDIA_VIDEO
),
PermissionBean
(
Manifest
.
permission
.
READ_SYNC_SETTINGS
),
PermissionBean
(
Manifest
.
permission
.
READ_SYNC_STATS
),
PermissionBean
(
Manifest
.
permission
.
REQUEST_DELETE_PACKAGES
),
PermissionBean
(
Manifest
.
permission
.
UPDATE_PACKAGES_WITHOUT_USER_ACTION
),
PermissionBean
(
Manifest
.
permission
.
USE_FINGERPRINT
),
PermissionBean
(
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
),
PermissionBean
(
Manifest
.
permission
.
WRITE_SETTINGS
),
PermissionBean
(
Manifest
.
permission
.
WRITE_SYNC_SETTINGS
),
)
@SuppressLint
(
"InlinedApi"
)
val
sensitivePermissions
=
arrayListOf
(
PermissionBean
(
Manifest
.
permission
.
ACCESS_BACKGROUND_LOCATION
,
isSensitive
=
true
),
PermissionBean
(
Manifest
.
permission
.
ACCESS_COARSE_LOCATION
,
isSensitive
=
true
),
PermissionBean
(
Manifest
.
permission
.
ACCESS_FINE_LOCATION
,
isSensitive
=
true
),
PermissionBean
(
Manifest
.
permission
.
ACCESS_MEDIA_LOCATION
,
isSensitive
=
true
),
PermissionBean
(
Manifest
.
permission
.
CAMERA
,
isSensitive
=
true
),
PermissionBean
(
Manifest
.
permission
.
RECORD_AUDIO
,
isSensitive
=
true
),
PermissionBean
(
Manifest
.
permission
.
RECEIVE_BOOT_COMPLETED
,
isSensitive
=
true
),
PermissionBean
(
Manifest
.
permission
.
READ_CONTACTS
,
isSensitive
=
true
),
PermissionBean
(
Manifest
.
permission
.
WRITE_CONTACTS
,
isSensitive
=
true
),
PermissionBean
(
Manifest
.
permission
.
GET_ACCOUNTS
,
isSensitive
=
true
),
PermissionBean
(
Manifest
.
permission
.
READ_PHONE_STATE
,
isSensitive
=
true
),
PermissionBean
(
Manifest
.
permission
.
READ_PHONE_NUMBERS
,
isSensitive
=
true
),
PermissionBean
(
Manifest
.
permission
.
CALL_PHONE
,
isSensitive
=
true
),
PermissionBean
(
Manifest
.
permission
.
READ_CALL_LOG
,
isSensitive
=
true
),
PermissionBean
(
Manifest
.
permission
.
WRITE_CALL_LOG
,
isSensitive
=
true
),
PermissionBean
(
Manifest
.
permission
.
ANSWER_PHONE_CALLS
,
isSensitive
=
true
),
PermissionBean
(
Manifest
.
permission
.
BODY_SENSORS
,
isSensitive
=
true
),
PermissionBean
(
Manifest
.
permission
.
ACTIVITY_RECOGNITION
,
isSensitive
=
true
),
PermissionBean
(
Manifest
.
permission
.
SEND_SMS
,
isSensitive
=
true
),
PermissionBean
(
Manifest
.
permission
.
RECEIVE_SMS
,
isSensitive
=
true
),
PermissionBean
(
Manifest
.
permission
.
READ_SMS
,
isSensitive
=
true
),
PermissionBean
(
Manifest
.
permission
.
READ_CALENDAR
,
isSensitive
=
true
),
PermissionBean
(
Manifest
.
permission
.
WRITE_CALENDAR
,
isSensitive
=
true
),
PermissionBean
(
Manifest
.
permission
.
QUERY_ALL_PACKAGES
,
isSensitive
=
true
),
)
}
}
\ No newline at end of file
app/src/main/java/com/test/easy/easycleanerjunk/activity/RecentAppActivity.kt
deleted
100644 → 0
View file @
47b8bf8a
package
com.test.easy.easycleanerjunk.activity
import
android.annotation.SuppressLint
import
android.app.AppOpsManager
import
android.app.usage.UsageEvents
import
android.app.usage.UsageStats
import
android.app.usage.UsageStatsManager
import
android.content.Context
import
android.content.Intent
import
android.content.pm.ApplicationInfo
import
android.content.pm.PackageInfo
import
android.content.pm.PackageManager
import
android.net.Uri
import
android.os.Build
import
android.provider.Settings
import
android.util.Log
import
android.view.View
import
android.widget.Toast
import
androidx.activity.addCallback
import
androidx.core.view.isVisible
import
androidx.fragment.app.Fragment
import
androidx.fragment.app.FragmentActivity
import
androidx.lifecycle.lifecycleScope
import
androidx.viewpager2.adapter.FragmentStateAdapter
import
com.google.android.material.tabs.TabLayoutMediator
import
com.test.easy.easycleanerjunk.bean.AppBean
import
com.test.easy.easycleanerjunk.databinding.ActivityRecentAppBinding
import
com.test.easy.easycleanerjunk.fragment.LaunchesFragment
import
com.test.easy.easycleanerjunk.fragment.ScreenTimeFragment
import
com.test.easy.easycleanerjunk.helps.BaseActivity
import
com.test.easy.easycleanerjunk.helps.LogEx
import
com.test.easy.easycleanerjunk.helps.PermissionHelp.checkUsageAccessSettings
import
com.test.easy.easycleanerjunk.helps.PermissionHelp.requestUsageAccessSettings
import
com.test.easy.easycleanerjunk.helps.TimeUtils.TODAY_QUERY
import
com.test.easy.easycleanerjunk.helps.TimeUtils.YESTERDAY_QUERY
import
com.test.easy.easycleanerjunk.helps.TimeUtils.timePair
import
com.test.easy.easycleanerjunk.helps.ads.AdmobUtils
import
com.test.easy.easycleanerjunk.helps.recentapp.LaunchTimeStat
import
com.test.easy.easycleanerjunk.helps.recentapp.ScreenTimeStat
import
kotlinx.coroutines.CoroutineScope
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.launch
import
org.json.JSONObject
import
kotlin.random.Random
class
RecentAppActivity
:
BaseActivity
<
ActivityRecentAppBinding
>()
{
override
val
isLightMode
=
true
private
val
TAG
=
"RecentAppActivity"
private
val
pages
=
arrayListOf
<
Fragment
>()
private
lateinit
var
pagerAdapter
:
ScreenSlidePagerAdapter
private
lateinit
var
tabs
:
Array
<
String
>
private
var
dataList
=
ArrayList
<
AppBean
>()
private
lateinit
var
context
:
Context
override
val
binding
:
ActivityRecentAppBinding
by
lazy
{
ActivityRecentAppBinding
.
inflate
(
layoutInflater
)
}
@SuppressLint
(
"SetTextI18n"
)
override
fun
initView
()
{
context
=
this
initPage
()
intTab
()
playLottie
()
if
(
checkUsageAccessSettings
())
{
Log
.
e
(
"MXL"
,
"onCreate: "
+
checkUsageAccessSettings
())
intData
()
}
else
{
binding
.
llContent
.
visibility
=
View
.
GONE
binding
.
flPermission
.
visibility
=
View
.
VISIBLE
binding
.
tvPermissionTip
.
text
=
" We need to request your recent app access permission to help you view your recently used applications. This can help you access your most commonly used apps faster."
}
}
override
fun
initListener
()
{
binding
.
flBack
.
setOnClickListener
{
AdmobUtils
.
showInterstitialAd
(
this
)
{
finishToMain
()
}
}
onBackPressedDispatcher
.
addCallback
{
LogEx
.
logDebug
(
TAG
,
"onBackPressedDispatcher"
)
AdmobUtils
.
showInterstitialAd
(
this
@RecentAppActivity
)
{
finishToMain
()
}
}
binding
.
tvGrand
.
setOnClickListener
{
requestUsageAccessSettings
(
launcher
,
result
=
{
flag
->
if
(
flag
)
{
binding
.
flPermission
.
visibility
=
View
.
GONE
binding
.
llContent
.
visibility
=
View
.
VISIBLE
intData
()
}
else
{
finishToMain
()
}
},
resolveNoAction
=
{
Toast
.
makeText
(
this
,
"no support function"
,
Toast
.
LENGTH_SHORT
).
show
()
})
}
}
private
fun
playLottie
(
showFinish
:
(()
->
Unit
)?
=
null
)
{
binding
.
llLottie
.
isVisible
=
true
binding
.
lottie
.
imageAssetsFolder
=
"easy_recentapp_scan/images/"
binding
.
lottie
.
setAnimation
(
"easy_recentapp_scan/data.json"
)
binding
.
lottie
.
playAnimation
()
binding
.
root
.
postDelayed
({
AdmobUtils
.
showInterstitialAd
(
this
)
{
binding
.
llLottie
.
isVisible
=
false
showFinish
?.
invoke
()
}
},
Random
.
nextLong
(
3000
,
4000
))
}
private
fun
intData
()
{
CoroutineScope
(
Dispatchers
.
IO
).
launch
{
//测试打印数据
// printEventList(context, lifecycleScope).await()
//构建AppData列表
initAppData
()
//设置启动数据
setLaunchesData
()
//屏幕时间数据
setScreenTimeData
()
//更新UI数据
launch
(
Dispatchers
.
Main
)
{
updateFragmentData
(
0
,
1
)
}
}
}
@SuppressLint
(
"QueryPermissionsNeeded"
)
private
fun
initAppData
()
{
dataList
.
clear
()
val
pm
=
packageManager
val
packages
=
pm
.
getInstalledPackages
(
0
)
packages
.
forEach
{
app
->
if
(
isLaunchApp
(
context
,
app
))
{
val
appBean
=
AppBean
(
app
.
applicationInfo
.
loadIcon
(
pm
),
app
.
applicationInfo
.
loadLabel
(
pm
).
toString
(),
app
.
applicationInfo
.
packageName
,
false
)
//安装时间
setAppInstallTime
(
appBean
,
context
)
dataList
.
add
(
appBean
)
}
}
}
private
fun
updateFragmentData
(
vararg
position
:
Int
)
{
if
(
position
.
contains
(
0
))
{
val
launchesFragment
=
pages
[
0
]
as
LaunchesFragment
launchesFragment
.
setAppUseData
(
dataList
)
}
if
(
position
.
contains
(
1
))
{
val
screenTimeFragment
=
pages
[
1
]
as
ScreenTimeFragment
screenTimeFragment
.
setScreenData
(
dataList
)
}
}
private
fun
setScreenTimeData
(
queryTime
:
Int
=
TODAY_QUERY
)
{
val
pair
=
timePair
(
queryTime
)
val
screenTimeMap
=
ScreenTimeStat
(
pair
.
first
,
pair
.
second
).
run
(
context
)
//key=com.vivo.appfilter pkg=com.vivo.appfilter f30766a=防拉起服务 f30767b=com.vivo.appfilter c=1132
dataList
.
forEach
{
app
->
if
(
screenTimeMap
.
keys
.
contains
(
app
.
pkg
))
{
val
value
=
screenTimeMap
[
app
.
pkg
]
value
?.
let
{
b
->
app
.
screenTime
=
b
.
c
}
}
}
}
private
fun
setLaunchesData
(
queryTime
:
Int
=
TODAY_QUERY
)
{
val
tempList
=
arrayListOf
<
AppBean
>()
tempList
.
addAll
(
dataList
)
//后台启动数据
dataList
=
getAppUseAnalyze
(
context
,
queryTime
,
tempList
)
//前台启动数据
val
pair
=
timePair
(
queryTime
)
val
ast
=
LaunchTimeStat
(
pair
.
first
,
pair
.
second
)
val
hashMap
=
ast
.
run
(
context
)
dataList
.
forEach
{
app
->
if
(
hashMap
.
keys
.
contains
(
app
.
pkg
))
{
val
value
=
hashMap
[
app
.
pkg
]
if
(
value
!=
null
)
{
val
tempList2
=
arrayListOf
<
UsageEvents
.
Event
>()
tempList2
.
addAll
(
value
)
app
.
usageEvents
?.
also
{
evens
->
tempList2
.
addAll
(
evens
)
}
app
.
usageEvents
=
tempList2
}
}
}
}
fun
changeTimeRefresh
(
queryTime
:
Int
,
fragmentPosition
:
Int
)
{
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
initAppData
()
//设置启动数据
setLaunchesData
(
queryTime
)
//屏幕时间数据
setScreenTimeData
(
queryTime
)
//更新UI数据
launch
(
Dispatchers
.
Main
)
{
updateFragmentData
(
fragmentPosition
)
}
}
}
private
fun
intTab
()
{
//有个问题结合ViewPager2就无法用静态xml中的TabItem
tabs
=
arrayOf
(
"LAUNCHES"
,
"SCREEN TIME"
)
TabLayoutMediator
(
binding
.
tabLayout
,
binding
.
viewpager2
)
{
tab
,
position
->
tab
.
text
=
tabs
[
position
]
binding
.
viewpager2
.
currentItem
=
position
}.
attach
()
binding
.
viewpager2
.
currentItem
=
0
}
private
fun
initPage
()
{
pages
.
add
(
LaunchesFragment
())
pages
.
add
(
ScreenTimeFragment
())
pagerAdapter
=
ScreenSlidePagerAdapter
(
this
)
binding
.
viewpager2
.
adapter
=
pagerAdapter
}
inner
class
ScreenSlidePagerAdapter
(
fa
:
FragmentActivity
)
:
FragmentStateAdapter
(
fa
)
{
override
fun
getItemCount
():
Int
=
pages
.
size
override
fun
createFragment
(
position
:
Int
):
Fragment
=
pages
[
position
]
}
private
fun
isLaunchApp
(
context
:
Context
,
app
:
PackageInfo
,
filterSystem
:
Boolean
=
true
):
Boolean
{
val
flagSystem
=
(
app
.
applicationInfo
.
flags
and
ApplicationInfo
.
FLAG_SYSTEM
)
<
1
val
flag
=
if
(
filterSystem
)
flagSystem
else
true
return
flag
&&
app
.
applicationInfo
.
packageName
!=
context
.
packageName
}
private
fun
setAppInstallTime
(
appBean
:
AppBean
,
context
:
Context
)
{
//安装时间
var
firstInstallTime
=
0L
try
{
val
packageManager
=
context
.
packageManager
val
packageInfo
:
PackageInfo
=
packageManager
.
getPackageInfo
(
appBean
.
pkg
,
0
)
//应用装时间
firstInstallTime
=
packageInfo
.
firstInstallTime
//应用最后一次更新时间
val
lastUpdateTime
=
packageInfo
.
lastUpdateTime
// LogEx.logDebug(TAG, "lastUpdateTime=$lastUpdateTime")
}
catch
(
e
:
PackageManager
.
NameNotFoundException
)
{
e
.
printStackTrace
()
}
appBean
.
installTime
=
firstInstallTime
}
/**
* 设置最近使用分析数据
*/
private
fun
getAppUseAnalyze
(
context
:
Context
,
queryTime
:
Int
=
YESTERDAY_QUERY
,
dataList
:
List
<
AppBean
>,
):
ArrayList
<
AppBean
>
{
val
launchList
=
arrayListOf
<
AppBean
>()
val
pair
=
timePair
(
queryTime
)
val
startTime
:
Long
=
pair
.
first
val
endTime
:
Long
=
pair
.
second
val
stateList
=
getUsageList
(
context
,
startTime
,
endTime
)
val
evenMap
=
getEventList2
(
context
,
startTime
,
endTime
)
// evenList.forEach { event -> printEvent(event) }
// stateList.forEach { state -> printState(state) }
dataList
.
forEach
{
app
->
//这里只使用后台启动数据
//FOREGROUND_SERVICE_START 19
app
.
usageEvents
=
evenMap
[
app
.
pkg
]
?.
filter
{
it
.
eventType
==
19
}
app
.
usageStats
=
stateList
.
filter
{
it
.
packageName
==
app
.
pkg
}
}
launchList
.
addAll
(
dataList
)
return
launchList
}
/**
* 前台运行App+后台运行App=总的启动App
*/
private
fun
getUsageList
(
context
:
Context
,
startTime
:
Long
,
endTime
:
Long
):
ArrayList
<
UsageStats
>
{
val
list
=
arrayListOf
<
UsageStats
>()
val
mUsmManager
=
context
.
getSystemService
(
Context
.
USAGE_STATS_SERVICE
)
as
UsageStatsManager
val
map
=
mUsmManager
.
queryAndAggregateUsageStats
(
startTime
,
endTime
)
map
.
values
.
forEach
{
stats
->
if
(
stats
.
totalTimeInForeground
>
0
)
{
list
.
add
(
stats
)
}
else
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
Q
)
{
if
(
stats
.
totalTimeForegroundServiceUsed
>
0
)
{
list
.
add
(
stats
)
}
}
}
}
return
list
}
@SuppressLint
(
"InlinedApi"
)
fun
getEventList2
(
context
:
Context
,
startTime
:
Long
,
endTime
:
Long
,
):
HashMap
<
String
,
ArrayList
<
UsageEvents
.
Event
>>
{
val
mUsmManager
=
context
.
getSystemService
(
Context
.
USAGE_STATS_SERVICE
)
as
UsageStatsManager
//链表记录所有的Event.快速查找
val
allList
=
ArrayList
<
UsageEvents
.
Event
>()
try
{
val
events
=
mUsmManager
.
queryEvents
(
startTime
,
endTime
)
while
(
events
.
hasNextEvent
())
{
val
event
=
UsageEvents
.
Event
()
events
.
getNextEvent
(
event
)
val
flag2
=
(
event
.
eventType
!=
UsageEvents
.
Event
.
ACTIVITY_STOPPED
)
&&
(
event
.
eventType
!=
UsageEvents
.
Event
.
STANDBY_BUCKET_CHANGED
)
if
(
flag2
)
{
allList
.
add
(
event
)
}
}
}
catch
(
e
:
Exception
)
{
LogEx
.
logDebug
(
TAG
,
"Exception ${e.printStackTrace()}"
)
e
.
printStackTrace
()
}
//记录数据结构
val
hashMap
=
HashMap
<
String
,
ArrayList
<
UsageEvents
.
Event
>>()
allList
.
forEachIndexed
{
index
,
event
->
//例子:CCAAVCSAABBBCDEFGABCDEFAABB
//过滤的结果
//CAASAAGAFAA
val
list
=
hashMap
[
event
.
packageName
]
if
(
list
==
null
)
{
hashMap
[
event
.
packageName
]
=
arrayListOf
()
}
//上个Event是否存在
var
lastEvent
:
UsageEvents
.
Event
?
=
null
val
lastIndex
=
index
-
1
if
(
index
>
0
)
{
lastEvent
=
allList
[
lastIndex
]
}
//上一个Event是否相同包
if
(
lastEvent
!=
null
&&
lastEvent
.
packageName
!=
event
.
packageName
)
{
list
?.
add
(
lastEvent
)
}
list
?.
add
(
event
)
}
return
hashMap
}
}
\ No newline at end of file
app/src/main/java/com/test/easy/easycleanerjunk/activity/ResultActivity.kt
View file @
f299164f
...
@@ -10,20 +10,11 @@ import com.test.easy.easycleanerjunk.adapter.AppFunctionAdapter
...
@@ -10,20 +10,11 @@ import com.test.easy.easycleanerjunk.adapter.AppFunctionAdapter
import
com.test.easy.easycleanerjunk.databinding.ActivityLayoutResultBinding
import
com.test.easy.easycleanerjunk.databinding.ActivityLayoutResultBinding
import
com.test.easy.easycleanerjunk.helps.BaseActivity
import
com.test.easy.easycleanerjunk.helps.BaseActivity
import
com.test.easy.easycleanerjunk.helps.KotlinExt.toFormatSize
import
com.test.easy.easycleanerjunk.helps.KotlinExt.toFormatSize
import
com.test.easy.easycleanerjunk.notificationclean.NotificationGuestActivity
import
com.test.easy.easycleanerjunk.utils.BarUtils
import
com.test.easy.easycleanerjunk.utils.BarUtils
import
com.test.easy.easycleanerjunk.utils.SPUtils
import
com.test.easy.easycleanerjunk.utils.SPUtils
import
com.test.easy.easycleanerjunk.view.AFunOb.APP_MANAGER
import
com.test.easy.easycleanerjunk.view.AFunOb.APP_SPEED
import
com.test.easy.easycleanerjunk.view.AFunOb.BATTERY_INFO
import
com.test.easy.easycleanerjunk.view.AFunOb.BATTERY_OPTIMIZER
import
com.test.easy.easycleanerjunk.view.AFunOb.EMPTY_FILE_CLEANER
import
com.test.easy.easycleanerjunk.view.AFunOb.JUNK_CLEANER
import
com.test.easy.easycleanerjunk.view.AFunOb.JUNK_CLEANER
import
com.test.easy.easycleanerjunk.view.AFunOb.LARGE_FILE_CLEANER
import
com.test.easy.easycleanerjunk.view.AFunOb.LARGE_FILE_CLEANER
import
com.test.easy.easycleanerjunk.view.AFunOb.NETWORK_TRAFFIC
import
com.test.easy.easycleanerjunk.view.AFunOb.NOTIFICATION_CLEANER
import
com.test.easy.easycleanerjunk.view.AFunOb.PHOTO_COMPRESS
import
com.test.easy.easycleanerjunk.view.AFunOb.PHOTO_COMPRESS
import
com.test.easy.easycleanerjunk.view.AFunOb.RECENT_APP_USAGE
import
com.test.easy.easycleanerjunk.view.AFunOb.SIMILAR_PHOTOS
import
com.test.easy.easycleanerjunk.view.AFunOb.SIMILAR_PHOTOS
class
ResultActivity
:
BaseActivity
<
ActivityLayoutResultBinding
>()
{
class
ResultActivity
:
BaseActivity
<
ActivityLayoutResultBinding
>()
{
...
@@ -41,31 +32,9 @@ class ResultActivity : BaseActivity<ActivityLayoutResultBinding>() {
...
@@ -41,31 +32,9 @@ class ResultActivity : BaseActivity<ActivityLayoutResultBinding>() {
JUNK_CLEANER
->
{
JUNK_CLEANER
->
{
startActivity
(
Intent
(
this
,
ScanJunkActivity
::
class
.
java
))
startActivity
(
Intent
(
this
,
ScanJunkActivity
::
class
.
java
))
}
}
RECENT_APP_USAGE
->
{
startActivity
(
Intent
(
this
,
RecentAppActivity
::
class
.
java
))
}
LARGE_FILE_CLEANER
->
{
LARGE_FILE_CLEANER
->
{
startActivity
(
Intent
(
this
,
LargeFileCleanActivity
::
class
.
java
))
startActivity
(
Intent
(
this
,
LargeFileCleanActivity
::
class
.
java
))
}
}
NOTIFICATION_CLEANER
->
{
startActivity
(
Intent
(
this
,
NotificationGuestActivity
::
class
.
java
))
}
NETWORK_TRAFFIC
->
{
startActivity
(
Intent
(
this
,
NetWorkActivity
::
class
.
java
))
}
APP_MANAGER
->
{
startActivity
(
Intent
(
this
,
AppManagerActivity
::
class
.
java
))
}
BATTERY_INFO
->
{
startActivity
(
Intent
(
this
,
BatteryInfoActivity
::
class
.
java
))
}
SIMILAR_PHOTOS
->
{
SIMILAR_PHOTOS
->
{
startActivity
(
Intent
(
this
,
RepeatPhotoActivity
::
class
.
java
))
startActivity
(
Intent
(
this
,
RepeatPhotoActivity
::
class
.
java
))
}
}
...
@@ -96,49 +65,15 @@ class ResultActivity : BaseActivity<ActivityLayoutResultBinding>() {
...
@@ -96,49 +65,15 @@ class ResultActivity : BaseActivity<ActivityLayoutResultBinding>() {
}
}
RECENT_APP_USAGE
->
{
binding
.
tvInfo
.
text
=
""
}
LARGE_FILE_CLEANER
->
{
LARGE_FILE_CLEANER
->
{
binding
.
tvInfo
.
text
=
""
binding
.
tvInfo
.
text
=
""
}
}
NOTIFICATION_CLEANER
->
{
binding
.
tvInfo
.
text
=
""
}
NETWORK_TRAFFIC
->
{
binding
.
tvInfo
.
text
=
""
}
APP_MANAGER
->
{
binding
.
tvInfo
.
text
=
""
}
BATTERY_INFO
->
{
binding
.
tvInfo
.
text
=
"Battery scan completed."
SPUtils
.
getInstance
().
put
(
"last_use_battery_info"
,
System
.
currentTimeMillis
())
}
EMPTY_FILE_CLEANER
->
{
binding
.
tvInfo
.
text
=
""
}
PHOTO_COMPRESS
->
{
PHOTO_COMPRESS
->
{
val
size
=
intent
.
getLongExtra
(
"size"
,
0L
).
toFormatSize
(
1
)
val
size
=
intent
.
getLongExtra
(
"size"
,
0L
).
toFormatSize
(
1
)
binding
.
tvInfo
.
text
=
"Compress ${intent.getIntExtra("
num
", 0)} photo, $size space freed"
binding
.
tvInfo
.
text
=
"Compress ${intent.getIntExtra("
num
", 0)} photo, $size space freed"
}
}
BATTERY_OPTIMIZER
->
{
binding
.
tvInfo
.
text
=
"Completed"
}
APP_SPEED
->
{
binding
.
tvInfo
.
text
=
"Completed"
}
else
->
{}
else
->
{}
}
}
from
?.
let
{
from
?.
let
{
...
...
app/src/main/java/com/test/easy/easycleanerjunk/activity/SettingActivity.kt
View file @
f299164f
...
@@ -5,7 +5,6 @@ import android.net.Uri
...
@@ -5,7 +5,6 @@ import android.net.Uri
import
android.os.Build
import
android.os.Build
import
com.test.easy.easycleanerjunk.databinding.ActivitySettingBinding
import
com.test.easy.easycleanerjunk.databinding.ActivitySettingBinding
import
com.test.easy.easycleanerjunk.display.NotificationService
import
com.test.easy.easycleanerjunk.display.NotificationService
import
com.test.easy.easycleanerjunk.display.fcm.FcmHelper
import
com.test.easy.easycleanerjunk.helps.BaseActivity
import
com.test.easy.easycleanerjunk.helps.BaseActivity
import
com.test.easy.easycleanerjunk.helps.ConfigHelper
import
com.test.easy.easycleanerjunk.helps.ConfigHelper
import
com.test.easy.easycleanerjunk.helps.ConfigHelper.allNotification
import
com.test.easy.easycleanerjunk.helps.ConfigHelper.allNotification
...
@@ -20,7 +19,6 @@ class SettingActivity : BaseActivity<ActivitySettingBinding>() {
...
@@ -20,7 +19,6 @@ class SettingActivity : BaseActivity<ActivitySettingBinding>() {
override
fun
initView
()
{
override
fun
initView
()
{
binding
.
switchRemainNotification
.
isChecked
=
remainNotification
binding
.
switchRemainNotification
.
isChecked
=
remainNotification
binding
.
switchAllNotification
.
isChecked
=
allNotification
}
}
override
fun
initListener
()
{
override
fun
initListener
()
{
...
@@ -38,10 +36,7 @@ class SettingActivity : BaseActivity<ActivitySettingBinding>() {
...
@@ -38,10 +36,7 @@ class SettingActivity : BaseActivity<ActivitySettingBinding>() {
stopService
(
serviceIntent
)
stopService
(
serviceIntent
)
}
}
}
}
binding
.
switchAllNotification
.
setOnCheckedChangeListener
{
buttonView
,
isChecked
->
allNotification
=
isChecked
switchFcm
(
isChecked
)
}
binding
.
cardPrivacy
.
setOnClickListener
{
binding
.
cardPrivacy
.
setOnClickListener
{
val
intent
=
Intent
(
val
intent
=
Intent
(
Intent
.
ACTION_VIEW
,
Intent
.
ACTION_VIEW
,
...
@@ -58,11 +53,4 @@ class SettingActivity : BaseActivity<ActivitySettingBinding>() {
...
@@ -58,11 +53,4 @@ class SettingActivity : BaseActivity<ActivitySettingBinding>() {
startService
(
intent
)
startService
(
intent
)
}
}
}
}
private
fun
switchFcm
(
checked
:
Boolean
)
{
if
(
checked
)
{
FcmHelper
.
subscribeToTopic
()
}
else
{
FcmHelper
.
unSubscribeToTopic
()
}
}
}
}
\ No newline at end of file
app/src/main/java/com/test/easy/easycleanerjunk/activity/splash/SplashJumpUtils.kt
View file @
f299164f
...
@@ -2,24 +2,17 @@ package com.test.easy.easycleanerjunk.activity.splash
...
@@ -2,24 +2,17 @@ package com.test.easy.easycleanerjunk.activity.splash
import
android.app.Activity
import
android.app.Activity
import
android.content.Intent
import
android.content.Intent
import
com.test.easy.easycleanerjunk.activity.AppManagerActivity
import
com.test.easy.easycleanerjunk.activity.CleanGuestActivity
import
com.test.easy.easycleanerjunk.activity.CleanGuestActivity
import
com.test.easy.easycleanerjunk.activity.DeviceScanActivity
import
com.test.easy.easycleanerjunk.activity.DeviceScanActivity
import
com.test.easy.easycleanerjunk.activity.LargeFileCleanActivity
import
com.test.easy.easycleanerjunk.activity.LargeFileCleanActivity
import
com.test.easy.easycleanerjunk.activity.NetWorkActivity
import
com.test.easy.easycleanerjunk.activity.RecentAppActivity
import
com.test.easy.easycleanerjunk.activity.RepeatPhotoActivity
import
com.test.easy.easycleanerjunk.activity.RepeatPhotoActivity
import
com.test.easy.easycleanerjunk.activity.ScanJunkActivity
import
com.test.easy.easycleanerjunk.activity.ScanJunkActivity
import
com.test.easy.easycleanerjunk.activity.ScreenShotActivity
import
com.test.easy.easycleanerjunk.activity.ScreenShotActivity
import
com.test.easy.easycleanerjunk.activity.home.NewMainActivity
import
com.test.easy.easycleanerjunk.activity.home.NewMainActivity
import
com.test.easy.easycleanerjunk.activity.photocompress.photo.StartCompressionPhotoActivity
import
com.test.easy.easycleanerjunk.activity.photocompress.photo.StartCompressionPhotoActivity
import
com.test.easy.easycleanerjunk.bean.ConfigBean.Companion.ID_APP_MANAGER
import
com.test.easy.easycleanerjunk.bean.ConfigBean.Companion.ID_CLEAN_NOTIFICATION
import
com.test.easy.easycleanerjunk.bean.ConfigBean.Companion.ID_JUNK_CLEAN_PUSH
import
com.test.easy.easycleanerjunk.bean.ConfigBean.Companion.ID_JUNK_CLEAN_PUSH
import
com.test.easy.easycleanerjunk.bean.ConfigBean.Companion.ID_LARGE_FILE_PUSH
import
com.test.easy.easycleanerjunk.bean.ConfigBean.Companion.ID_LARGE_FILE_PUSH
import
com.test.easy.easycleanerjunk.bean.ConfigBean.Companion.ID_NETWORK_TRAFFIC
import
com.test.easy.easycleanerjunk.bean.ConfigBean.Companion.ID_PHOTO_COMPRESS
import
com.test.easy.easycleanerjunk.bean.ConfigBean.Companion.ID_PHOTO_COMPRESS
import
com.test.easy.easycleanerjunk.bean.ConfigBean.Companion.ID_RECENT_USE_APP
import
com.test.easy.easycleanerjunk.bean.ConfigBean.Companion.ID_SCREENSHOT_CLEAN
import
com.test.easy.easycleanerjunk.bean.ConfigBean.Companion.ID_SCREENSHOT_CLEAN
import
com.test.easy.easycleanerjunk.bean.ConfigBean.Companion.ID_SIMILAR_IMAGE
import
com.test.easy.easycleanerjunk.bean.ConfigBean.Companion.ID_SIMILAR_IMAGE
import
com.test.easy.easycleanerjunk.helps.ConfigHelper
import
com.test.easy.easycleanerjunk.helps.ConfigHelper
...
@@ -44,28 +37,12 @@ object SplashJumpUtils {
...
@@ -44,28 +37,12 @@ object SplashJumpUtils {
context
.
startActivity
(
Intent
(
context
,
ScanJunkActivity
::
class
.
java
))
context
.
startActivity
(
Intent
(
context
,
ScanJunkActivity
::
class
.
java
))
}
}
ID_LARGE_FILE_PUSH
->
{
context
.
startActivity
(
Intent
(
context
,
LargeFileCleanActivity
::
class
.
java
))
}
ID_PHOTO_COMPRESS
->
{
ID_PHOTO_COMPRESS
->
{
context
.
startActivity
(
Intent
(
context
,
StartCompressionPhotoActivity
::
class
.
java
))
context
.
startActivity
(
Intent
(
context
,
StartCompressionPhotoActivity
::
class
.
java
))
}
}
ID_APP_MANAGER
->
{
ID_LARGE_FILE_PUSH
->
{
context
.
startActivity
(
Intent
(
context
,
AppManagerActivity
::
class
.
java
))
context
.
startActivity
(
Intent
(
context
,
LargeFileCleanActivity
::
class
.
java
))
}
ID_NETWORK_TRAFFIC
->
{
context
.
startActivity
(
Intent
(
context
,
NetWorkActivity
::
class
.
java
))
}
ID_CLEAN_NOTIFICATION
->
{
context
.
startActivity
(
Intent
(
context
,
NotificationGuestActivity
::
class
.
java
))
}
ID_RECENT_USE_APP
->
{
context
.
startActivity
(
Intent
(
context
,
RecentAppActivity
::
class
.
java
))
}
}
ID_SIMILAR_IMAGE
->
{
ID_SIMILAR_IMAGE
->
{
...
...
app/src/main/java/com/test/easy/easycleanerjunk/adapter/AppFunctionAdapter.kt
View file @
f299164f
...
@@ -9,14 +9,9 @@ import androidx.recyclerview.widget.RecyclerView.ViewHolder
...
@@ -9,14 +9,9 @@ import androidx.recyclerview.widget.RecyclerView.ViewHolder
import
com.test.easy.easycleanerjunk.R
import
com.test.easy.easycleanerjunk.R
import
com.test.easy.easycleanerjunk.databinding.ItemResultFunBinding
import
com.test.easy.easycleanerjunk.databinding.ItemResultFunBinding
import
com.test.easy.easycleanerjunk.utils.SPUtils
import
com.test.easy.easycleanerjunk.utils.SPUtils
import
com.test.easy.easycleanerjunk.view.AFunOb.APP_MANAGER
import
com.test.easy.easycleanerjunk.view.AFunOb.BATTERY_INFO
import
com.test.easy.easycleanerjunk.view.AFunOb.JUNK_CLEANER
import
com.test.easy.easycleanerjunk.view.AFunOb.JUNK_CLEANER
import
com.test.easy.easycleanerjunk.view.AFunOb.LARGE_FILE_CLEANER
import
com.test.easy.easycleanerjunk.view.AFunOb.LARGE_FILE_CLEANER
import
com.test.easy.easycleanerjunk.view.AFunOb.NETWORK_TRAFFIC
import
com.test.easy.easycleanerjunk.view.AFunOb.NOTIFICATION_CLEANER
import
com.test.easy.easycleanerjunk.view.AFunOb.PHOTO_COMPRESS
import
com.test.easy.easycleanerjunk.view.AFunOb.PHOTO_COMPRESS
import
com.test.easy.easycleanerjunk.view.AFunOb.RECENT_APP_USAGE
import
com.test.easy.easycleanerjunk.view.AFunOb.SIMILAR_PHOTOS
import
com.test.easy.easycleanerjunk.view.AFunOb.SIMILAR_PHOTOS
import
com.test.easy.easycleanerjunk.view.XmlEx.inflate
import
com.test.easy.easycleanerjunk.view.XmlEx.inflate
import
java.util.Collections
import
java.util.Collections
...
@@ -28,31 +23,12 @@ class AppFunctionAdapter(val click: (name: String) -> Unit) :
...
@@ -28,31 +23,12 @@ class AppFunctionAdapter(val click: (name: String) -> Unit) :
Fun
(
JUNK_CLEANER
,
R
.
mipmap
.
t_cleanjunk
,
"Clean junk regularly to free up space"
,
"Clean Up"
),
Fun
(
JUNK_CLEANER
,
R
.
mipmap
.
t_cleanjunk
,
"Clean junk regularly to free up space"
,
"Clean Up"
),
Fun
(
PHOTO_COMPRESS
,
R
.
mipmap
.
t_photo
,
"Compress photos to save space"
,
"Compress"
),
Fun
(
PHOTO_COMPRESS
,
R
.
mipmap
.
t_photo
,
"Compress photos to save space"
,
"Compress"
),
Fun
(
LARGE_FILE_CLEANER
,
R
.
mipmap
.
t_large
,
"Clean large files to free up storage space"
,
"Clean Up"
),
Fun
(
LARGE_FILE_CLEANER
,
R
.
mipmap
.
t_large
,
"Clean large files to free up storage space"
,
"Clean Up"
),
Fun
(
APP_MANAGER
,
R
.
mipmap
.
t_appmanager
,
"Check apps size and uninstall some apps to release storage space"
,
"Check Now"
),
Fun
(
Fun
(
SIMILAR_PHOTOS
,
SIMILAR_PHOTOS
,
R
.
mipmap
.
t_similar
,
R
.
mipmap
.
t_similar
,
"Check similar photos to release more space"
,
"Check similar photos to release more space"
,
"Clean Up"
"Clean Up"
),
),
Fun
(
NOTIFICATION_CLEANER
,
R
.
mipmap
.
t_notification
,
"Too many annoying notifications? Block and clean"
,
"Check Now"
),
Fun
(
RECENT_APP_USAGE
,
R
.
mipmap
.
t_recent
,
"Check and manage recently active apps"
,
"View Now"
),
Fun
(
NETWORK_TRAFFIC
,
R
.
mipmap
.
t_network
,
"View network traffic usage and stop traffic-consuming apps"
,
"View Now"
),
)
)
//修改顺序
//修改顺序
...
...
app/src/main/java/com/test/easy/easycleanerjunk/adapter/ToolsAdapter.kt
View file @
f299164f
...
@@ -10,14 +10,9 @@ import com.test.easy.easycleanerjunk.databinding.ItemAdBinding
...
@@ -10,14 +10,9 @@ import com.test.easy.easycleanerjunk.databinding.ItemAdBinding
import
com.test.easy.easycleanerjunk.databinding.ItemToolGrid1Binding
import
com.test.easy.easycleanerjunk.databinding.ItemToolGrid1Binding
import
com.test.easy.easycleanerjunk.databinding.ItemToolsGrid1Binding
import
com.test.easy.easycleanerjunk.databinding.ItemToolsGrid1Binding
import
com.test.easy.easycleanerjunk.helps.ads.AdmobUtils
import
com.test.easy.easycleanerjunk.helps.ads.AdmobUtils
import
com.test.easy.easycleanerjunk.view.AFunOb.APP_MANAGER
import
com.test.easy.easycleanerjunk.view.AFunOb.DEVICE_SCAN
import
com.test.easy.easycleanerjunk.view.AFunOb.JUNK_CLEANER
import
com.test.easy.easycleanerjunk.view.AFunOb.JUNK_CLEANER
import
com.test.easy.easycleanerjunk.view.AFunOb.LARGE_FILE_CLEANER
import
com.test.easy.easycleanerjunk.view.AFunOb.LARGE_FILE_CLEANER
import
com.test.easy.easycleanerjunk.view.AFunOb.NETWORK_TRAFFIC
import
com.test.easy.easycleanerjunk.view.AFunOb.NOTIFICATION_CLEANER
import
com.test.easy.easycleanerjunk.view.AFunOb.PHOTO_COMPRESS
import
com.test.easy.easycleanerjunk.view.AFunOb.PHOTO_COMPRESS
import
com.test.easy.easycleanerjunk.view.AFunOb.RECENT_APP_USAGE
import
com.test.easy.easycleanerjunk.view.AFunOb.SCREENSHOT_CLEANER
import
com.test.easy.easycleanerjunk.view.AFunOb.SCREENSHOT_CLEANER
import
com.test.easy.easycleanerjunk.view.AFunOb.SIMILAR_PHOTOS
import
com.test.easy.easycleanerjunk.view.AFunOb.SIMILAR_PHOTOS
import
com.test.easy.easycleanerjunk.view.XmlEx.inflate
import
com.test.easy.easycleanerjunk.view.XmlEx.inflate
...
@@ -34,21 +29,10 @@ class ToolsAdapter(
...
@@ -34,21 +29,10 @@ class ToolsAdapter(
ToolUI
(
LARGE_FILE_CLEANER
,
context
.
getString
(
R
.
string
.
large_file_cleaner
),
R
.
mipmap
.
t_large
),
ToolUI
(
LARGE_FILE_CLEANER
,
context
.
getString
(
R
.
string
.
large_file_cleaner
),
R
.
mipmap
.
t_large
),
ToolUI
(
PHOTO_COMPRESS
,
context
.
getString
(
R
.
string
.
photo_compress
),
R
.
mipmap
.
t_photo
),
ToolUI
(
PHOTO_COMPRESS
,
context
.
getString
(
R
.
string
.
photo_compress
),
R
.
mipmap
.
t_photo
),
ToolUI
(
SIMILAR_PHOTOS
,
context
.
getString
(
R
.
string
.
similar_photos
),
R
.
mipmap
.
t_similar
),
ToolUI
(
SIMILAR_PHOTOS
,
context
.
getString
(
R
.
string
.
similar_photos
),
R
.
mipmap
.
t_similar
),
ToolUI
(
APP_MANAGER
,
context
.
getString
(
R
.
string
.
app_manager
),
R
.
mipmap
.
t_appmanager
),
)
),
ToolsUI
(
isAd
=
true
),
ToolsUI
(
tittle
=
"More"
,
tools
=
listOf
(
ToolUI
(
NOTIFICATION_CLEANER
,
context
.
getString
(
R
.
string
.
notification_cleaner
),
R
.
mipmap
.
t_notification
),
ToolUI
(
NETWORK_TRAFFIC
,
context
.
getString
(
R
.
string
.
network_traffic
),
R
.
mipmap
.
t_network
),
ToolUI
(
RECENT_APP_USAGE
,
context
.
getString
(
R
.
string
.
recent_app_usage
),
R
.
mipmap
.
t_recent
),
ToolUI
(
DEVICE_SCAN
,
context
.
getString
(
R
.
string
.
device_scan
),
R
.
mipmap
.
devicescan
),
ToolUI
(
SCREENSHOT_CLEANER
,
context
.
getString
(
R
.
string
.
screenshot_cleaner
),
R
.
mipmap
.
screenshot
)
ToolUI
(
SCREENSHOT_CLEANER
,
context
.
getString
(
R
.
string
.
screenshot_cleaner
),
R
.
mipmap
.
screenshot
)
)
)
),
),
ToolsUI
(
isAd
=
true
),
)
)
override
fun
getItemViewType
(
position
:
Int
):
Int
{
override
fun
getItemViewType
(
position
:
Int
):
Int
{
...
...
app/src/main/java/com/test/easy/easycleanerjunk/bean/ConfigBean.kt
View file @
f299164f
...
@@ -39,15 +39,9 @@ data class ConfigBean(
...
@@ -39,15 +39,9 @@ data class ConfigBean(
companion
object
{
companion
object
{
//功能触发push actionId 主动发送
//功能触发push actionId 主动发送
const
val
ID_JUNK_CLEAN_PUSH
=
11001
//清理垃圾
const
val
ID_JUNK_CLEAN_PUSH
=
11001
//清理垃圾
const
val
ID_BATTERY_PUSH
=
11004
// 电量信息
const
val
ID_LARGE_FILE_PUSH
=
11006
// 大文件清理
const
val
ID_LARGE_FILE_PUSH
=
11006
// 大文件清理
const
val
ID_DUPLICATE_FILE_PUSH
=
11007
//文件备份,重复文件,相似文件
const
val
ID_PHOTO_CLEAN_PUSH
=
11009
//清理相册
const
val
ID_PHOTO_COMPRESS
=
11010
//照片压缩
const
val
ID_PHOTO_COMPRESS
=
11010
//照片压缩
const
val
ID_APP_MANAGER
=
11011
//应用管理
const
val
ID_APP_MANAGER
=
11011
//应用管理
const
val
ID_NETWORK_TRAFFIC
=
11012
//网络流量
const
val
ID_CLEAN_NOTIFICATION
=
11013
//清理通知栏
const
val
ID_RECENT_USE_APP
=
11014
//最近使用APP
const
val
ID_SIMILAR_IMAGE
=
11015
//清理相似图片
const
val
ID_SIMILAR_IMAGE
=
11015
//清理相似图片
const
val
ID_SCREENSHOT_CLEAN
=
12000
//截图清理
const
val
ID_SCREENSHOT_CLEAN
=
12000
//截图清理
...
@@ -55,17 +49,9 @@ data class ConfigBean(
...
@@ -55,17 +49,9 @@ data class ConfigBean(
fun
ConfigBean
.
getActionPushInterval
(
actionId
:
Int
):
Int
{
fun
ConfigBean
.
getActionPushInterval
(
actionId
:
Int
):
Int
{
val
interval
=
when
(
actionId
)
{
val
interval
=
when
(
actionId
)
{
ID_JUNK_CLEAN_PUSH
->
push_interval_11001
ID_JUNK_CLEAN_PUSH
->
push_interval_11001
ID_BATTERY_PUSH
->
push_interval_11004
ID_LARGE_FILE_PUSH
->
push_interval_11006
ID_DUPLICATE_FILE_PUSH
->
push_interval_11007
ID_PHOTO_CLEAN_PUSH
->
push_interval_11009
ID_PHOTO_COMPRESS
->
push_interval_11010
ID_PHOTO_COMPRESS
->
push_interval_11010
ID_APP_MANAGER
->
push_interval_11011
ID_APP_MANAGER
->
push_interval_11011
ID_NETWORK_TRAFFIC
->
push_interval_11012
ID_CLEAN_NOTIFICATION
->
push_interval_11013
ID_RECENT_USE_APP
->
push_interval_11014
ID_SIMILAR_IMAGE
->
push_interval_11015
ID_SIMILAR_IMAGE
->
push_interval_11015
ID_SCREENSHOT_CLEAN
->
push_interval_12000
else
->
0
else
->
0
}
}
return
interval
return
interval
...
...
app/src/main/java/com/test/easy/easycleanerjunk/display/NotificationUtils.kt
View file @
f299164f
...
@@ -15,13 +15,10 @@ import android.widget.RemoteViews
...
@@ -15,13 +15,10 @@ import android.widget.RemoteViews
import
androidx.core.app.NotificationCompat
import
androidx.core.app.NotificationCompat
import
androidx.core.app.NotificationManagerCompat
import
androidx.core.app.NotificationManagerCompat
import
com.test.easy.easycleanerjunk.R
import
com.test.easy.easycleanerjunk.R
import
com.test.easy.easycleanerjunk.activity.AppManagerActivity
import
com.test.easy.easycleanerjunk.activity.BatteryInfoActivity
import
com.test.easy.easycleanerjunk.activity.ScanJunkActivity
import
com.test.easy.easycleanerjunk.activity.ScanJunkActivity
import
com.test.easy.easycleanerjunk.activity.home.NewMainActivity
import
com.test.easy.easycleanerjunk.activity.home.NewMainActivity
import
com.test.easy.easycleanerjunk.display.NotificationHelper.postActionNotification
import
com.test.easy.easycleanerjunk.display.NotificationHelper.postActionNotification
import
com.test.easy.easycleanerjunk.helps.BaseApplication
import
com.test.easy.easycleanerjunk.helps.BaseApplication
import
com.test.easy.easycleanerjunk.helps.KotlinExt.string
import
com.test.easy.easycleanerjunk.service.FlashlightService
import
com.test.easy.easycleanerjunk.service.FlashlightService
...
@@ -111,7 +108,7 @@ object NotificationUtils {
...
@@ -111,7 +108,7 @@ object NotificationUtils {
"Start foreground service."
"Start foreground service."
)
)
val
isOngoing
=
true
//是否持续(为不消失的常驻通知)
val
isOngoing
=
true
//是否持续(为不消失的常驻通知)
val
channelName
=
R
.
string
.
foreground_service_channel
.
string
(
)
val
channelName
=
context
.
resources
.
getString
(
R
.
string
.
foreground_service_channel
)
val
channelId
=
"Service_Id"
val
channelId
=
"Service_Id"
val
category
=
Notification
.
CATEGORY_SERVICE
val
category
=
Notification
.
CATEGORY_SERVICE
val
contentView
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
reminder_layout_notification_notify
)
val
contentView
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
reminder_layout_notification_notify
)
...
@@ -124,11 +121,11 @@ object NotificationUtils {
...
@@ -124,11 +121,11 @@ object NotificationUtils {
expendView
.
setOnClickPendingIntent
(
R
.
id
.
id_ll_clean
,
pendingIntent0
)
expendView
.
setOnClickPendingIntent
(
R
.
id
.
id_ll_clean
,
pendingIntent0
)
val
intent2
=
Intent
(
context
,
BatteryInfoActivity
::
class
.
java
)
// val intent2 = Intent(context,
::class.java)
val
pendingIntent2
=
//
val pendingIntent2 =
PendingIntent
.
getActivity
(
context
,
0
,
intent2
,
PendingIntent
.
FLAG_IMMUTABLE
)
//
PendingIntent.getActivity(context, 0, intent2, PendingIntent.FLAG_IMMUTABLE)
contentView
.
setOnClickPendingIntent
(
R
.
id
.
id_battery
,
pendingIntent2
)
//
contentView.setOnClickPendingIntent(R.id.id_battery, pendingIntent2)
expendView
.
setOnClickPendingIntent
(
R
.
id
.
id_battery
,
pendingIntent2
)
//
expendView.setOnClickPendingIntent(R.id.id_battery, pendingIntent2)
val
intent3
=
Intent
()
val
intent3
=
Intent
()
val
serviceComponent
=
ComponentName
(
context
,
FlashlightService
::
class
.
java
)
val
serviceComponent
=
ComponentName
(
context
,
FlashlightService
::
class
.
java
)
...
@@ -138,11 +135,11 @@ object NotificationUtils {
...
@@ -138,11 +135,11 @@ object NotificationUtils {
contentView
.
setOnClickPendingIntent
(
R
.
id
.
id_lighit
,
pendingIntent3
)
contentView
.
setOnClickPendingIntent
(
R
.
id
.
id_lighit
,
pendingIntent3
)
expendView
.
setOnClickPendingIntent
(
R
.
id
.
id_lighit
,
pendingIntent3
)
expendView
.
setOnClickPendingIntent
(
R
.
id
.
id_lighit
,
pendingIntent3
)
val
intent4
=
Intent
(
context
,
AppManagerActivity
::
class
.
java
)
// val intent4 = Intent(context,
::class.java)
val
pendingIntent4
=
//
val pendingIntent4 =
PendingIntent
.
getActivity
(
context
,
0
,
intent4
,
PendingIntent
.
FLAG_IMMUTABLE
)
//
PendingIntent.getActivity(context, 0, intent4, PendingIntent.FLAG_IMMUTABLE)
contentView
.
setOnClickPendingIntent
(
R
.
id
.
id_app_manager
,
pendingIntent4
)
//
contentView.setOnClickPendingIntent(R.id.id_app_manager, pendingIntent4)
expendView
.
setOnClickPendingIntent
(
R
.
id
.
id_app_manager
,
pendingIntent4
)
//
expendView.setOnClickPendingIntent(R.id.id_app_manager, pendingIntent4)
val
nfIntent
=
Intent
(
context
,
NewMainActivity
::
class
.
java
)
val
nfIntent
=
Intent
(
context
,
NewMainActivity
::
class
.
java
)
val
pendingIntent
=
val
pendingIntent
=
...
@@ -184,10 +181,6 @@ object NotificationUtils {
...
@@ -184,10 +181,6 @@ object NotificationUtils {
val
log
=
"isPush=$isPush "
+
"id=${id} "
val
log
=
"isPush=$isPush "
+
"id=${id} "
Log
.
d
(
TAG
,
log
)
Log
.
d
(
TAG
,
log
)
if
(
isPush
)
{
if
(
isPush
)
{
// var extra: Int? = null
// if (id == ID_PHONE_ACCELERATE) {
// extra = RamMemoryEx.getMemoryUsage(BaseApplication.context).toInt()
// }
BaseApplication
.
context
.
postActionNotification
(
id
,
null
,
s
)
BaseApplication
.
context
.
postActionNotification
(
id
,
null
,
s
)
}
}
}
}
...
...
app/src/main/java/com/test/easy/easycleanerjunk/fragment/AppListFragment.kt
deleted
100644 → 0
View file @
47b8bf8a
package
com.test.easy.easycleanerjunk.fragment
import
android.annotation.SuppressLint
import
android.app.AppOpsManager
import
android.content.Context
import
android.content.Intent
import
android.net.Uri
import
android.os.Build
import
android.os.Bundle
import
android.provider.Settings
import
android.view.View
import
com.test.easy.easycleanerjunk.activity.AppManagerActivity
import
com.test.easy.easycleanerjunk.adapter.AppListAdapter
import
com.test.easy.easycleanerjunk.bean.AppBean
import
com.test.easy.easycleanerjunk.databinding.FragmentAppListBinding
import
com.test.easy.easycleanerjunk.helps.ActivityLauncher
import
com.test.easy.easycleanerjunk.helps.BaseFragment
import
com.test.easy.easycleanerjunk.helps.LogEx
import
com.test.easy.easycleanerjunk.view.AppDetailDialog.showAppDetailDialog
import
net.sourceforge.pinyin4j.PinyinHelper
import
net.sourceforge.pinyin4j.format.HanyuPinyinCaseType
import
net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat
import
net.sourceforge.pinyin4j.format.HanyuPinyinToneType
import
net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination
/**
*/
class
AppListFragment
:
BaseFragment
<
FragmentAppListBinding
>()
{
private
val
TAG
=
"AppListFragment"
private
var
adapter
:
AppListAdapter
?
=
null
private
var
list
=
arrayListOf
<
AppBean
>()
private
var
isRefreshData
=
false
//是否需要更新数据
private
lateinit
var
launcher
:
ActivityLauncher
private
var
type
:
Int
=
0
var
isAsc
:
Boolean
=
true
private
var
needPermission
:
Boolean
=
false
override
val
binding
:
FragmentAppListBinding
by
lazy
{
FragmentAppListBinding
.
inflate
(
layoutInflater
)
}
fun
setInitData
(
launcher
:
ActivityLauncher
,
type
:
Int
=
0
,
isAsc
:
Boolean
=
true
,
needPermission
:
Boolean
=
false
)
{
this
.
launcher
=
launcher
this
.
type
=
type
this
.
isAsc
=
isAsc
this
.
needPermission
=
needPermission
}
@SuppressLint
(
"SetTextI18n"
)
override
fun
setView
()
{
if
(
needPermission
&&
!
checkUsageAccessSettings
(
requireContext
()))
{
binding
.
flContent
.
visibility
=
View
.
GONE
binding
.
flPermission
.
visibility
=
View
.
VISIBLE
}
else
{
if
(
isRefreshData
)
{
binding
.
progressbar
.
visibility
=
View
.
GONE
}
initRv
()
initData
()
}
}
override
fun
setListener
()
{
binding
.
tvAuthorization
.
setOnClickListener
{
val
intent
=
Intent
(
Settings
.
ACTION_USAGE_ACCESS_SETTINGS
)
intent
.
addCategory
(
"android.intent.category.DEFAULT"
)
intent
.
data
=
Uri
.
parse
(
"package:${requireActivity().packageName}"
)
launcher
.
launch
(
intent
)
{
LogEx
.
logDebug
(
TAG
,
"launcher callback"
)
(
requireActivity
()
as
AppManagerActivity
).
refreshUsageAccessData
()
}
}
}
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
super
.
onViewCreated
(
view
,
savedInstanceState
)
}
override
fun
onResume
()
{
super
.
onResume
()
if
(
checkUsageAccessSettings
(
requireContext
()))
{
binding
.
flPermission
.
visibility
=
View
.
GONE
binding
.
flContent
.
visibility
=
View
.
VISIBLE
}
}
private
fun
initData
()
{
orderList
()
adapter
?.
setData
(
list
)
}
/**
* 更新数据不刷洗
*/
fun
setData
(
dataList
:
List
<
AppBean
>)
{
list
.
clear
()
list
.
addAll
(
dataList
)
orderList
()
}
/**
* 更新数据刷新
*/
@SuppressLint
(
"NotifyDataSetChanged"
)
fun
setDataRefresh
(
dataList
:
List
<
AppBean
>)
{
list
.
clear
()
list
.
addAll
(
dataList
)
orderList
()
if
(
isVisible
)
{
if
(
adapter
==
null
)
{
initRv
()
}
if
(
isRefreshData
)
{
binding
.
progressbar
.
visibility
=
View
.
GONE
}
adapter
?.
setData
(
list
)
}
}
/**
* 刷洗fragment数据
*/
@SuppressLint
(
"NotifyDataSetChanged"
)
fun
refreshFragmentData
(
dataList
:
List
<
AppBean
>,
isRefresh
:
Boolean
=
false
,
index
:
Int
=
0
)
{
isRefreshData
=
true
LogEx
.
logDebug
(
TAG
,
"isRefresh=$isRefresh isVisible=$isVisible index=$index"
)
if
(
isRefresh
&&
isVisible
)
{
binding
.
flPermission
.
visibility
=
View
.
GONE
binding
.
progressbar
.
visibility
=
View
.
GONE
setDataRefresh
(
dataList
)
}
else
{
setData
(
dataList
)
}
}
fun
showContent
(
isRefresh
:
Boolean
=
false
)
{
if
(
isRefresh
)
{
binding
.
flContent
.
visibility
=
View
.
VISIBLE
}
}
private
fun
initRv
()
{
adapter
=
AppListAdapter
(
itemClick
=
{
if
(!(
requireActivity
()
as
AppManagerActivity
).
animationFinish
)
{
return
@AppListAdapter
}
requireActivity
().
showAppDetailDialog
(
it
,
launcher
)
{
unInstalled
->
if
(
unInstalled
)
{
adapter
?.
removeData
(
it
)
otherAppRemove
(
it
)
}
}
},
itemSelect
=
{
selectList
->
showUnInstall
(
selectList
)
})
binding
.
rv
.
adapter
=
adapter
}
private
fun
showUnInstall
(
selectList
:
List
<
AppBean
>)
{
(
requireActivity
()
as
AppManagerActivity
).
showUnInstall
(
selectList
)
}
private
fun
orderList
()
{
when
(
type
)
{
APP_LIST_TYPE_NAME
->
{
list
.
forEach
{
it
.
pinYin
=
getPinyin
(
it
.
appName
)
}
if
(
isAsc
)
{
list
.
sortBy
{
it
.
pinYin
}
}
else
{
list
.
sortByDescending
{
it
.
pinYin
}
}
}
APP_LIST_TYPE_INSTALL
->
{
if
(
isAsc
)
{
list
.
sortBy
{
it
.
installTime
}
}
else
{
list
.
sortByDescending
{
it
.
installTime
}
}
}
APP_LIST_TYPE_SIZE
->
{
if
(
isAsc
)
{
list
.
sortBy
{
it
.
appSize
}
}
else
{
list
.
sortByDescending
{
it
.
appSize
}
}
}
APP_LIST_TYPE_LAST_USE
->
{
if
(
isAsc
)
{
list
.
sortBy
{
it
.
lastUsedTime
}
}
else
{
list
.
sortByDescending
{
it
.
lastUsedTime
}
}
}
}
}
/**
* 翻转顺序
*/
fun
reverseOrder
()
{
isAsc
=
!
isAsc
orderList
()
adapter
?.
setData
(
list
)
}
private
fun
otherAppRemove
(
appBean
:
AppBean
)
{
(
requireActivity
()
as
AppManagerActivity
).
otherPageRemove
(
appBean
,
this
)
}
companion
object
{
const
val
APP_LIST_TYPE_NAME
=
12
const
val
APP_LIST_TYPE_INSTALL
=
15
const
val
APP_LIST_TYPE_SIZE
=
19
const
val
APP_LIST_TYPE_LAST_USE
=
123
}
/**
* 汉字转为拼音
* https://cloud.tencent.com/developer/article/1731852
* @return
*/
fun
getPinyin
(
str
:
String
):
String
{
val
format
=
HanyuPinyinOutputFormat
()
format
.
caseType
=
HanyuPinyinCaseType
.
UPPERCASE
format
.
toneType
=
HanyuPinyinToneType
.
WITHOUT_TONE
val
sb
=
StringBuilder
()
val
strNoSpace
=
str
.
replace
(
"\\s"
.
toRegex
(),
""
).
trim
()
// LogEx.logDebug(TAG, "strNoSpace=$strNoSpace")
val
charArray
=
strNoSpace
.
toCharArray
()
for
(
i
in
charArray
.
indices
)
{
val
c
=
charArray
[
i
]
// 如果是空格, 跳过
if
(
Character
.
isWhitespace
(
c
))
{
continue
}
// LogEx.logDebug(TAG, "c.code=${c.code}")
if
(
c
.
code
==
-
127
||
c
.
code
<
128
)
{
// 肯定不是汉字
sb
.
append
(
c
)
}
else
{
var
s
:
String
?
=
""
try
{
// LogEx.logDebug(TAG, "c=$c")
// 通过char得到拼音集合. 单 - dan, shan
val
array
=
PinyinHelper
.
toHanyuPinyinStringArray
(
c
,
format
)
if
(
array
.
isNotEmpty
())
{
s
=
array
.
first
()
sb
.
append
(
s
)
}
}
catch
(
e
:
BadHanyuPinyinOutputFormatCombination
)
{
e
.
printStackTrace
()
sb
.
append
(
s
)
}
}
}
// LogEx.logDebug(TAG, "ping str=$sb")
return
sb
.
toString
()
}
private
fun
checkUsageAccessSettings
(
context
:
Context
):
Boolean
{
val
appOpsManager
=
context
.
getSystemService
(
Context
.
APP_OPS_SERVICE
)
as
AppOpsManager
return
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
Q
)
{
appOpsManager
.
unsafeCheckOpNoThrow
(
AppOpsManager
.
OPSTR_GET_USAGE_STATS
,
android
.
os
.
Process
.
myUid
(),
context
.
packageName
)
==
AppOpsManager
.
MODE_ALLOWED
}
else
{
appOpsManager
.
checkOpNoThrow
(
AppOpsManager
.
OPSTR_GET_USAGE_STATS
,
android
.
os
.
Process
.
myUid
(),
context
.
packageName
)
==
AppOpsManager
.
MODE_ALLOWED
}
}
}
\ No newline at end of file
app/src/main/java/com/test/easy/easycleanerjunk/fragment/HomeFragment.kt
View file @
f299164f
...
@@ -6,11 +6,7 @@ import android.content.Intent
...
@@ -6,11 +6,7 @@ import android.content.Intent
import
android.view.animation.LinearInterpolator
import
android.view.animation.LinearInterpolator
import
android.widget.ScrollView
import
android.widget.ScrollView
import
androidx.core.view.updatePadding
import
androidx.core.view.updatePadding
import
com.test.easy.easycleanerjunk.activity.AppManagerActivity
import
com.test.easy.easycleanerjunk.activity.BatteryInfoActivity
import
com.test.easy.easycleanerjunk.activity.LargeFileCleanActivity
import
com.test.easy.easycleanerjunk.activity.LargeFileCleanActivity
import
com.test.easy.easycleanerjunk.activity.NetWorkActivity
import
com.test.easy.easycleanerjunk.activity.RecentAppActivity
import
com.test.easy.easycleanerjunk.activity.RepeatPhotoActivity
import
com.test.easy.easycleanerjunk.activity.RepeatPhotoActivity
import
com.test.easy.easycleanerjunk.activity.ScanJunkActivity
import
com.test.easy.easycleanerjunk.activity.ScanJunkActivity
import
com.test.easy.easycleanerjunk.activity.SettingActivity
import
com.test.easy.easycleanerjunk.activity.SettingActivity
...
@@ -18,7 +14,6 @@ import com.test.easy.easycleanerjunk.activity.photocompress.photo.StartCompressi
...
@@ -18,7 +14,6 @@ import com.test.easy.easycleanerjunk.activity.photocompress.photo.StartCompressi
import
com.test.easy.easycleanerjunk.databinding.FragmentLayoutHomeBinding
import
com.test.easy.easycleanerjunk.databinding.FragmentLayoutHomeBinding
import
com.test.easy.easycleanerjunk.helps.BaseFragment
import
com.test.easy.easycleanerjunk.helps.BaseFragment
import
com.test.easy.easycleanerjunk.helps.KotlinExt.setOnClickListener
import
com.test.easy.easycleanerjunk.helps.KotlinExt.setOnClickListener
import
com.test.easy.easycleanerjunk.helps.KotlinExt.toFormatSize
import
com.test.easy.easycleanerjunk.notificationclean.NotificationGuestActivity
import
com.test.easy.easycleanerjunk.notificationclean.NotificationGuestActivity
import
com.test.easy.easycleanerjunk.utils.BarUtils
import
com.test.easy.easycleanerjunk.utils.BarUtils
...
@@ -83,25 +78,10 @@ class HomeFragment : BaseFragment<FragmentLayoutHomeBinding>() {
...
@@ -83,25 +78,10 @@ class HomeFragment : BaseFragment<FragmentLayoutHomeBinding>() {
binding
.
idLargeFile
.
setOnClickListener
{
binding
.
idLargeFile
.
setOnClickListener
{
startActivity
(
Intent
(
requireContext
(),
LargeFileCleanActivity
::
class
.
java
))
startActivity
(
Intent
(
requireContext
(),
LargeFileCleanActivity
::
class
.
java
))
}
}
binding
.
idAppManager
.
setOnClickListener
{
startActivity
(
Intent
(
requireContext
(),
AppManagerActivity
::
class
.
java
))
}
binding
.
idBatteryInfo
.
setOnClickListener
{
startActivity
(
Intent
(
requireContext
(),
BatteryInfoActivity
::
class
.
java
))
}
binding
.
idSimilarPhotos
.
setOnClickListener
{
binding
.
idSimilarPhotos
.
setOnClickListener
{
startActivity
(
Intent
(
requireContext
(),
RepeatPhotoActivity
::
class
.
java
))
startActivity
(
Intent
(
requireContext
(),
RepeatPhotoActivity
::
class
.
java
))
}
}
binding
.
idHomeNetwork
.
setOnClickListener
{
startActivity
(
Intent
(
requireContext
(),
NetWorkActivity
::
class
.
java
))
}
binding
.
idNotificationCleaner
.
setOnClickListener
{
startActivity
(
Intent
(
requireActivity
(),
NotificationGuestActivity
::
class
.
java
))
}
binding
.
idHomeRecent
.
setOnClickListener
{
startActivity
(
Intent
(
requireContext
(),
RecentAppActivity
::
class
.
java
))
}
binding
.
ivSetting
.
setOnClickListener
{
binding
.
ivSetting
.
setOnClickListener
{
startActivity
(
Intent
(
requireContext
(),
SettingActivity
::
class
.
java
))
startActivity
(
Intent
(
requireContext
(),
SettingActivity
::
class
.
java
))
}
}
...
...
app/src/main/java/com/test/easy/easycleanerjunk/fragment/LaunchesFragment.kt
deleted
100644 → 0
View file @
47b8bf8a
package
com.test.easy.easycleanerjunk.fragment
import
android.annotation.SuppressLint
import
android.app.usage.UsageEvents
import
android.app.usage.UsageEvents.Event.ACTIVITY_PAUSED
import
android.app.usage.UsageEvents.Event.ACTIVITY_RESUMED
import
android.app.usage.UsageEvents.Event.FOREGROUND_SERVICE_START
import
android.graphics.Typeface
import
android.os.Bundle
import
android.view.View
import
androidx.core.content.ContextCompat
import
com.test.easy.easycleanerjunk.R
import
com.test.easy.easycleanerjunk.activity.RecentAppActivity
import
com.test.easy.easycleanerjunk.adapter.RecentAppAdapter
import
com.test.easy.easycleanerjunk.bean.AppBean
import
com.test.easy.easycleanerjunk.databinding.FragmentLaunchesBinding
import
com.test.easy.easycleanerjunk.helps.BaseFragment
import
com.test.easy.easycleanerjunk.helps.LogEx
import
com.test.easy.easycleanerjunk.helps.TimeUtils
import
com.test.easy.easycleanerjunk.helps.TimeUtils.PAST_60_MINUS_QUERY
import
com.test.easy.easycleanerjunk.helps.TimeUtils.SEVEN_DAYS_QUERY
import
com.test.easy.easycleanerjunk.helps.TimeUtils.TODAY_QUERY
import
com.test.easy.easycleanerjunk.helps.TimeUtils.YESTERDAY_QUERY
import
com.test.easy.easycleanerjunk.view.TimeSelectDialog.showTimeSelectDialog
import
java.text.SimpleDateFormat
import
kotlin.time.Duration.Companion.hours
import
kotlin.time.DurationUnit
class
LaunchesFragment
:
BaseFragment
<
FragmentLaunchesBinding
>()
{
private
val
TAG
=
"LaunchesFragment"
private
var
dataList
=
arrayListOf
<
AppBean
>()
private
lateinit
var
adapter
:
RecentAppAdapter
private
var
simpleDateFormat2
=
SimpleDateFormat
(
"(yyyy/MM/dd)"
)
private
var
UI_MODE
=
UI_MODE_ALL
override
val
binding
:
FragmentLaunchesBinding
by
lazy
{
FragmentLaunchesBinding
.
inflate
(
layoutInflater
)
}
override
fun
setView
()
{
setTextFont
()
adapter
=
RecentAppAdapter
(
requireActivity
(),
RecentAppAdapter
.
UI_LAUNCHES_MODE
)
binding
.
rv
.
adapter
=
adapter
}
override
fun
setListener
()
{
binding
.
clLaunches
.
setOnClickListener
{
launchesMode
()
}
binding
.
clForeground
.
setOnClickListener
{
foregroundMode
()
}
binding
.
clBackground
.
setOnClickListener
{
backgroundMode
()
}
binding
.
llDate
.
setOnClickListener
{
requireContext
().
showTimeSelectDialog
{
when
(
it
)
{
PAST_60_MINUS_QUERY
->
{
recent60UI
()
}
TODAY_QUERY
->
{
todayUI
()
}
YESTERDAY_QUERY
->
{
yesterdayUI
()
}
SEVEN_DAYS_QUERY
->
{
sevenDaysUI
()
}
}
}
}
todayUI
(
false
)
}
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
super
.
onViewCreated
(
view
,
savedInstanceState
)
}
override
fun
onResume
()
{
super
.
onResume
()
}
@SuppressLint
(
"SetTextI18n"
)
fun
todayUI
(
isReFresh
:
Boolean
=
true
)
{
binding
.
tvDate
.
text
=
"Today"
+
simpleDateFormat2
.
format
(
System
.
currentTimeMillis
())
if
(
isReFresh
)
{
(
requireActivity
()
as
RecentAppActivity
).
changeTimeRefresh
(
TODAY_QUERY
,
0
)
}
}
@SuppressLint
(
"SetTextI18n"
)
fun
recent60UI
(
isReFresh
:
Boolean
=
true
)
{
binding
.
tvDate
.
text
=
"Recent 60 minus"
if
(
isReFresh
)
{
(
requireActivity
()
as
RecentAppActivity
).
changeTimeRefresh
(
PAST_60_MINUS_QUERY
,
0
)
}
}
@SuppressLint
(
"SetTextI18n"
)
fun
yesterdayUI
(
isReFresh
:
Boolean
=
true
)
{
binding
.
tvDate
.
text
=
"Yesterday"
+
simpleDateFormat2
.
format
(
System
.
currentTimeMillis
()
-
24
.
hours
.
toLong
(
DurationUnit
.
MILLISECONDS
))
if
(
isReFresh
)
{
(
requireActivity
()
as
RecentAppActivity
).
changeTimeRefresh
(
YESTERDAY_QUERY
,
0
)
}
}
@SuppressLint
(
"SetTextI18n"
)
fun
sevenDaysUI
(
isReFresh
:
Boolean
=
true
)
{
binding
.
tvDate
.
text
=
"Last 7 days"
if
(
isReFresh
)
{
(
requireActivity
()
as
RecentAppActivity
).
changeTimeRefresh
(
SEVEN_DAYS_QUERY
,
0
)
}
}
private
fun
filterRv
()
{
adapter
.
setNumberMode
(
UI_MODE
)
when
(
UI_MODE
)
{
UI_MODE_ALL
->
{
val
data
=
dataList
.
filter
{
it
.
launchTimes
>
0
}
adapter
.
setData
(
data
)
}
UI_MODE_FOREGROUND
->
{
val
data
=
dataList
.
filter
{
it
.
foregroundTimes
>
0
}
adapter
.
setData
(
data
)
}
UI_MODE_BACKGROUND
->
{
val
data
=
dataList
.
filter
{
it
.
backgroundTimes
>
0
}
adapter
.
setData
(
data
)
}
}
}
fun
launchesMode
()
{
foregroundEnable
(
false
)
backgroundEnable
(
false
)
launchesEnable
(
true
)
UI_MODE
=
UI_MODE_ALL
filterRv
()
}
fun
foregroundMode
()
{
launchesEnable
(
false
)
backgroundEnable
(
false
)
foregroundEnable
(
true
)
UI_MODE
=
UI_MODE_FOREGROUND
filterRv
()
}
fun
backgroundMode
()
{
launchesEnable
(
false
)
foregroundEnable
(
false
)
backgroundEnable
(
true
)
UI_MODE
=
UI_MODE_BACKGROUND
filterRv
()
}
fun
launchesEnable
(
enable
:
Boolean
)
{
if
(
enable
)
{
val
enableBorder
=
ContextCompat
.
getDrawable
(
requireContext
(),
R
.
drawable
.
bg_corners_recent
)
binding
.
ivLaunchesBorder
.
background
=
enableBorder
binding
.
ivLaunchesTriangle
.
visibility
=
View
.
VISIBLE
binding
.
tvLaunchesNumber
.
setTextColor
(
ContextCompat
.
getColor
(
requireContext
(),
R
.
color
.
white
)
)
binding
.
tvLaunches
.
setTextColor
(
ContextCompat
.
getColor
(
requireContext
(),
R
.
color
.
white
))
}
else
{
val
disableBorder
=
ContextCompat
.
getDrawable
(
requireContext
(),
R
.
drawable
.
bg_stroke_e3e5ea
)
binding
.
ivLaunchesBorder
.
background
=
disableBorder
binding
.
ivLaunchesTriangle
.
visibility
=
View
.
GONE
binding
.
tvLaunchesNumber
.
setTextColor
(
ContextCompat
.
getColor
(
requireContext
(),
R
.
color
.
black
)
)
binding
.
tvLaunches
.
setTextColor
(
ContextCompat
.
getColor
(
requireContext
(),
R
.
color
.
color_999999
)
)
}
}
fun
foregroundEnable
(
enable
:
Boolean
)
{
if
(
enable
)
{
val
enableBorder
=
ContextCompat
.
getDrawable
(
requireContext
(),
R
.
drawable
.
bg_corners_recent
)
binding
.
ivForegroundBorder
.
background
=
enableBorder
binding
.
ivForegroundTriangle
.
visibility
=
View
.
VISIBLE
binding
.
tvForegroundNumber
.
setTextColor
(
ContextCompat
.
getColor
(
requireContext
(),
R
.
color
.
white
)
)
binding
.
tvForeground
.
setTextColor
(
ContextCompat
.
getColor
(
requireContext
(),
R
.
color
.
white
)
)
}
else
{
val
disableBorder
=
ContextCompat
.
getDrawable
(
requireContext
(),
R
.
drawable
.
bg_stroke_e3e5ea
)
binding
.
ivForegroundBorder
.
background
=
disableBorder
binding
.
ivForegroundTriangle
.
visibility
=
View
.
GONE
binding
.
tvForegroundNumber
.
setTextColor
(
ContextCompat
.
getColor
(
requireContext
(),
R
.
color
.
black
)
)
binding
.
tvForeground
.
setTextColor
(
ContextCompat
.
getColor
(
requireContext
(),
R
.
color
.
color_999999
)
)
}
}
fun
backgroundEnable
(
enable
:
Boolean
)
{
if
(
enable
)
{
val
enableBorder
=
ContextCompat
.
getDrawable
(
requireContext
(),
R
.
drawable
.
bg_corners_recent
)
binding
.
ivBackgroundBorder
.
background
=
enableBorder
binding
.
ivBackgroundTriangle
.
visibility
=
View
.
VISIBLE
binding
.
tvBackgroundNumber
.
setTextColor
(
ContextCompat
.
getColor
(
requireContext
(),
R
.
color
.
white
)
)
binding
.
tvBackground
.
setTextColor
(
ContextCompat
.
getColor
(
requireContext
(),
R
.
color
.
white
)
)
}
else
{
val
disableBorder
=
ContextCompat
.
getDrawable
(
requireContext
(),
R
.
drawable
.
bg_stroke_e3e5ea
)
binding
.
ivBackgroundBorder
.
background
=
disableBorder
binding
.
ivBackgroundTriangle
.
visibility
=
View
.
GONE
binding
.
tvBackgroundNumber
.
setTextColor
(
ContextCompat
.
getColor
(
requireContext
(),
R
.
color
.
black
)
)
binding
.
tvBackground
.
setTextColor
(
ContextCompat
.
getColor
(
requireContext
(),
R
.
color
.
color_999999
)
)
}
}
private
fun
setTextFont
()
{
val
fontMedium
=
"sans-serif-medium"
val
fontMediumTypeface
=
Typeface
.
create
(
fontMedium
,
Typeface
.
NORMAL
)
binding
.
tvDate
.
setTypeface
(
fontMediumTypeface
)
}
/**
* 更新数据
*/
fun
setAppUseData
(
dataList
:
List
<
AppBean
>)
{
LogEx
.
logDebug
(
TAG
,
"setAppUseData"
)
this
.
dataList
.
clear
()
this
.
dataList
.
addAll
(
dataList
)
//setLaunchNumber()
if
(
isVisible
)
{
setLaunchNumber2
()
launchesMode
()
}
}
private
fun
setLaunchNumber2
()
{
dataList
.
forEach
{
app
->
app
.
foregroundTimes
=
app
.
usageEvents
?.
filter
{
it
.
eventType
==
1
}
?.
size
?:
0
app
.
backgroundTimes
=
app
.
usageEvents
?.
filter
{
it
.
eventType
==
19
}
?.
size
?:
0
app
.
launchTimes
=
app
.
foregroundTimes
+
app
.
backgroundTimes
}
val
totalNumber
=
dataList
.
sumOf
{
it
.
launchTimes
}
val
foregroundNumber
=
dataList
.
sumOf
{
it
.
foregroundTimes
}
val
backgroundNumber
=
dataList
.
sumOf
{
it
.
backgroundTimes
}
binding
.
tvLaunchesNumber
.
text
=
totalNumber
.
toString
()
binding
.
tvForegroundNumber
.
text
=
foregroundNumber
.
toString
()
binding
.
tvBackgroundNumber
.
text
=
backgroundNumber
.
toString
()
}
/**
* 旧的计算前台后台数量逻辑
*/
@SuppressLint
(
"InlinedApi"
)
private
fun
setLaunchNumber
()
{
val
tempList
=
ArrayList
<
UsageEvents
.
Event
>()
dataList
.
forEach
{
app
->
app
.
usageEvents
?.
let
{
events
->
tempList
.
clear
()
tempList
.
addAll
(
events
)
tempList
.
forEachIndexed
{
index
,
event
->
if
(
app
.
pkg
==
"tv.danmaku.bili"
)
{
LogEx
.
logDebug
(
TAG
,
"$index ${event.packageName} "
+
TimeUtils
.
simpleDateFormat
.
format
(
event
.
timeStamp
)
+
" ${event.eventType}"
)
}
//后台启动次数
if
(
event
.
eventType
==
FOREGROUND_SERVICE_START
)
{
app
.
backgroundTimes
++
}
//上一个事件
val
lastIndex
=
index
-
1
var
lastEvent
:
UsageEvents
.
Event
?
=
null
if
(
lastIndex
>=
0
)
{
lastEvent
=
tempList
[
lastIndex
]
}
//上面是欧拉的前台判断逻辑 event上次 event2本次
// (event == null || !Objects.equals(event.getPackageName(), event2.getPackageName()))
// &&
//((event == null || event.getEventType() == 2) && event2.getEventType() == 1)
if
(
event
.
eventType
==
ACTIVITY_RESUMED
)
{
val
flag1
=
lastEvent
==
null
||
((
lastEvent
.
packageName
!=
app
.
pkg
)
&&
(
lastEvent
.
eventType
==
ACTIVITY_PAUSED
))
val
flag2
=
(
lastEvent
!=
null
)
&&
(
lastEvent
.
packageName
!=
app
.
pkg
)
if
(
flag1
)
{
app
.
foregroundTimes
++
if
(
app
.
pkg
==
"tv.danmaku.bili"
)
{
LogEx
.
logDebug
(
TAG
,
"前台加一 flag1 ${app.foregroundTimes}"
)
}
}
else
if
(
flag2
)
{
app
.
foregroundTimes
++
if
(
app
.
pkg
==
"tv.danmaku.bili"
)
{
LogEx
.
logDebug
(
TAG
,
"前台加一 flag2 ${app.foregroundTimes}"
)
}
}
}
}
}
//2的阈值
if
(
app
.
foregroundTimes
<
2
)
{
app
.
foregroundTimes
=
0
}
app
.
launchTimes
=
app
.
foregroundTimes
+
app
.
backgroundTimes
if
(
app
.
pkg
==
"tv.danmaku.bili"
)
{
LogEx
.
logDebug
(
TAG
,
"${app.pkg} launchTimes=${app.launchTimes} "
+
"foregroundTimes=${app.foregroundTimes} "
+
"backgroundTimes=${app.backgroundTimes}"
)
}
}
val
totalNumber
=
dataList
.
sumOf
{
it
.
launchTimes
}
val
foregroundNumber
=
dataList
.
sumOf
{
it
.
foregroundTimes
}
val
backgroundNumber
=
dataList
.
sumOf
{
it
.
backgroundTimes
}
binding
.
tvLaunchesNumber
.
text
=
totalNumber
.
toString
()
binding
.
tvForegroundNumber
.
text
=
foregroundNumber
.
toString
()
binding
.
tvBackgroundNumber
.
text
=
backgroundNumber
.
toString
()
}
companion
object
{
const
val
UI_MODE_ALL
=
5
const
val
UI_MODE_FOREGROUND
=
25
const
val
UI_MODE_BACKGROUND
=
35
}
}
\ No newline at end of file
app/src/main/java/com/test/easy/easycleanerjunk/fragment/ScreenTimeFragment.kt
deleted
100644 → 0
View file @
47b8bf8a
package
com.test.easy.easycleanerjunk.fragment
import
android.annotation.SuppressLint
import
android.graphics.Typeface
import
android.os.Bundle
import
com.test.easy.easycleanerjunk.activity.RecentAppActivity
import
com.test.easy.easycleanerjunk.adapter.RecentAppAdapter
import
com.test.easy.easycleanerjunk.adapter.RecentAppAdapter.Companion.UI_SCREEN_TIME_MODE
import
com.test.easy.easycleanerjunk.bean.AppBean
import
com.test.easy.easycleanerjunk.databinding.FragmentScreenTimeBinding
import
com.test.easy.easycleanerjunk.helps.BaseFragment
import
com.test.easy.easycleanerjunk.helps.TimeUtils.PAST_60_MINUS_QUERY
import
com.test.easy.easycleanerjunk.helps.TimeUtils.SEVEN_DAYS_QUERY
import
com.test.easy.easycleanerjunk.helps.TimeUtils.TODAY_QUERY
import
com.test.easy.easycleanerjunk.helps.TimeUtils.YESTERDAY_QUERY
import
com.test.easy.easycleanerjunk.view.TimeSelectDialog.showTimeSelectDialog
import
java.text.SimpleDateFormat
import
kotlin.time.Duration.Companion.hours
import
kotlin.time.DurationUnit
/**
*/
class
ScreenTimeFragment
:
BaseFragment
<
FragmentScreenTimeBinding
>()
{
private
var
simpleDateFormat2
=
SimpleDateFormat
(
"(yyyy/MM/dd)"
)
private
lateinit
var
adapter
:
RecentAppAdapter
private
val
dataList
=
arrayListOf
<
AppBean
>()
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
}
override
val
binding
:
FragmentScreenTimeBinding
by
lazy
{
FragmentScreenTimeBinding
.
inflate
(
layoutInflater
)
}
override
fun
setView
()
{
setTextFont
()
binding
.
llDate
.
setOnClickListener
{
requireContext
().
showTimeSelectDialog
{
when
(
it
)
{
PAST_60_MINUS_QUERY
->
{
recent60UI
()
}
TODAY_QUERY
->
{
todayUI
()
}
YESTERDAY_QUERY
->
{
yesterdayUI
()
}
SEVEN_DAYS_QUERY
->
{
sevenDaysUI
()
}
}
}
}
adapter
=
RecentAppAdapter
(
requireActivity
(),
UI_SCREEN_TIME_MODE
)
binding
.
rv
.
adapter
=
adapter
adapter
.
setData
(
dataList
)
todayUI
(
false
)
}
private
fun
setTextFont
()
{
val
fontMedium
=
"sans-serif-medium"
val
fontMediumTypeface
=
Typeface
.
create
(
fontMedium
,
Typeface
.
NORMAL
)
binding
.
tvDate
.
setTypeface
(
fontMediumTypeface
)
}
@SuppressLint
(
"SetTextI18n"
)
fun
todayUI
(
isReFresh
:
Boolean
=
true
)
{
binding
.
tvDate
.
text
=
"Today"
+
simpleDateFormat2
.
format
(
System
.
currentTimeMillis
())
if
(
isReFresh
)
{
(
requireActivity
()
as
RecentAppActivity
).
changeTimeRefresh
(
TODAY_QUERY
,
1
)
}
}
@SuppressLint
(
"SetTextI18n"
)
fun
recent60UI
(
isReFresh
:
Boolean
=
true
)
{
binding
.
tvDate
.
text
=
"Recent 60 minus"
if
(
isReFresh
)
{
(
requireActivity
()
as
RecentAppActivity
).
changeTimeRefresh
(
PAST_60_MINUS_QUERY
,
1
)
}
}
@SuppressLint
(
"SetTextI18n"
)
fun
yesterdayUI
(
isReFresh
:
Boolean
=
true
)
{
binding
.
tvDate
.
text
=
"Yesterday"
+
simpleDateFormat2
.
format
(
System
.
currentTimeMillis
()
-
24
.
hours
.
toLong
(
DurationUnit
.
MILLISECONDS
)
)
if
(
isReFresh
)
{
(
requireActivity
()
as
RecentAppActivity
).
changeTimeRefresh
(
YESTERDAY_QUERY
,
1
)
}
}
@SuppressLint
(
"SetTextI18n"
)
fun
sevenDaysUI
(
isReFresh
:
Boolean
=
true
)
{
binding
.
tvDate
.
text
=
"Last 7 days"
if
(
isReFresh
)
{
(
requireActivity
()
as
RecentAppActivity
).
changeTimeRefresh
(
SEVEN_DAYS_QUERY
,
1
)
}
}
fun
setScreenData
(
dataList
:
ArrayList
<
AppBean
>)
{
this
.
dataList
.
clear
()
this
.
dataList
.
addAll
(
dataList
.
filter
{
it
.
screenTime
>
0
})
if
(
isVisible
)
{
adapter
.
setData
(
this
.
dataList
)
}
}
override
fun
onResume
()
{
super
.
onResume
()
}
}
\ No newline at end of file
app/src/main/java/com/test/easy/easycleanerjunk/fragment/ToolsFragment.kt
View file @
f299164f
package
com.test.easy.easycleanerjunk.fragment
package
com.test.easy.easycleanerjunk.fragment
import
android.content.Intent
import
android.content.Intent
import
com.test.easy.easycleanerjunk.activity.AppManagerActivity
import
com.test.easy.easycleanerjunk.activity.BatteryInfoActivity
import
com.test.easy.easycleanerjunk.activity.DeviceScanInfoActivity
import
com.test.easy.easycleanerjunk.activity.LargeFileCleanActivity
import
com.test.easy.easycleanerjunk.activity.LargeFileCleanActivity
import
com.test.easy.easycleanerjunk.activity.NetWorkActivity
import
com.test.easy.easycleanerjunk.activity.RecentAppActivity
import
com.test.easy.easycleanerjunk.activity.RepeatPhotoActivity
import
com.test.easy.easycleanerjunk.activity.RepeatPhotoActivity
import
com.test.easy.easycleanerjunk.activity.ScanJunkActivity
import
com.test.easy.easycleanerjunk.activity.ScanJunkActivity
import
com.test.easy.easycleanerjunk.activity.ScreenShotActivity
import
com.test.easy.easycleanerjunk.activity.photocompress.photo.StartCompressionPhotoActivity
import
com.test.easy.easycleanerjunk.activity.photocompress.photo.StartCompressionPhotoActivity
import
com.test.easy.easycleanerjunk.adapter.ToolsAdapter
import
com.test.easy.easycleanerjunk.adapter.ToolsAdapter
import
com.test.easy.easycleanerjunk.databinding.FragmentLayoutTools1Binding
import
com.test.easy.easycleanerjunk.databinding.FragmentLayoutTools1Binding
import
com.test.easy.easycleanerjunk.helps.BaseFragment
import
com.test.easy.easycleanerjunk.helps.BaseFragment
import
com.test.easy.easycleanerjunk.notificationclean.NotificationGuestActivity
import
com.test.easy.easycleanerjunk.view.AFunOb
import
com.test.easy.easycleanerjunk.view.AFunOb
import
com.test.easy.easycleanerjunk.view.AFunOb.APP_MANAGER
import
com.test.easy.easycleanerjunk.view.AFunOb.BATTERY_INFO
import
com.test.easy.easycleanerjunk.view.AFunOb.DEVICE_SCAN
import
com.test.easy.easycleanerjunk.view.AFunOb.LARGE_FILE_CLEANER
import
com.test.easy.easycleanerjunk.view.AFunOb.LARGE_FILE_CLEANER
import
com.test.easy.easycleanerjunk.view.AFunOb.NETWORK_TRAFFIC
import
com.test.easy.easycleanerjunk.view.AFunOb.NOTIFICATION_CLEANER
import
com.test.easy.easycleanerjunk.view.AFunOb.PHOTO_COMPRESS
import
com.test.easy.easycleanerjunk.view.AFunOb.PHOTO_COMPRESS
import
com.test.easy.easycleanerjunk.view.AFunOb.RECENT_APP_USAGE
import
com.test.easy.easycleanerjunk.view.AFunOb.SCREENSHOT_CLEANER
import
com.test.easy.easycleanerjunk.view.AFunOb.SIMILAR_PHOTOS
import
com.test.easy.easycleanerjunk.view.AFunOb.SIMILAR_PHOTOS
class
ToolsFragment
:
BaseFragment
<
FragmentLayoutTools1Binding
>()
{
class
ToolsFragment
:
BaseFragment
<
FragmentLayoutTools1Binding
>()
{
...
@@ -41,25 +27,13 @@ class ToolsFragment : BaseFragment<FragmentLayoutTools1Binding>() {
...
@@ -41,25 +27,13 @@ class ToolsFragment : BaseFragment<FragmentLayoutTools1Binding>() {
startActivity
(
Intent
(
requireContext
(),
ScanJunkActivity
::
class
.
java
))
startActivity
(
Intent
(
requireContext
(),
ScanJunkActivity
::
class
.
java
))
}
}
RECENT_APP_USAGE
->
{
startActivity
(
Intent
(
requireActivity
(),
RecentAppActivity
::
class
.
java
))
}
LARGE_FILE_CLEANER
->
{
LARGE_FILE_CLEANER
->
{
startActivity
(
Intent
(
requireContext
(),
LargeFileCleanActivity
::
class
.
java
))
startActivity
(
Intent
(
requireContext
(),
LargeFileCleanActivity
::
class
.
java
))
}
}
NOTIFICATION_CLEANER
->
{
startActivity
(
Intent
(
requireActivity
(),
NotificationGuestActivity
::
class
.
java
))
}
NETWORK_TRAFFIC
->
{
startActivity
(
Intent
(
requireContext
(),
NetWorkActivity
::
class
.
java
))
}
APP_MANAGER
->
{
startActivity
(
Intent
(
requireContext
(),
AppManagerActivity
::
class
.
java
))
}
SIMILAR_PHOTOS
->
{
SIMILAR_PHOTOS
->
{
startActivity
(
Intent
(
requireContext
(),
RepeatPhotoActivity
::
class
.
java
))
startActivity
(
Intent
(
requireContext
(),
RepeatPhotoActivity
::
class
.
java
))
...
@@ -68,19 +42,6 @@ class ToolsFragment : BaseFragment<FragmentLayoutTools1Binding>() {
...
@@ -68,19 +42,6 @@ class ToolsFragment : BaseFragment<FragmentLayoutTools1Binding>() {
PHOTO_COMPRESS
->
{
PHOTO_COMPRESS
->
{
startActivity
(
Intent
(
requireActivity
(),
StartCompressionPhotoActivity
::
class
.
java
))
startActivity
(
Intent
(
requireActivity
(),
StartCompressionPhotoActivity
::
class
.
java
))
}
}
BATTERY_INFO
->
{
startActivity
(
Intent
(
requireActivity
(),
BatteryInfoActivity
::
class
.
java
))
}
DEVICE_SCAN
->
{
startActivity
(
Intent
(
requireActivity
(),
DeviceScanInfoActivity
::
class
.
java
))
}
SCREENSHOT_CLEANER
->
{
startActivity
(
Intent
(
requireActivity
(),
ScreenShotActivity
::
class
.
java
))
}
}
}
}
}
binding
.
rvTools
.
adapter
=
adapter
binding
.
rvTools
.
adapter
=
adapter
...
...
app/src/main/java/com/test/easy/easycleanerjunk/view/AFunOb.kt
View file @
f299164f
...
@@ -2,20 +2,9 @@ package com.test.easy.easycleanerjunk.view
...
@@ -2,20 +2,9 @@ package com.test.easy.easycleanerjunk.view
object
AFunOb
{
object
AFunOb
{
const
val
JUNK_CLEANER
=
"Junk Cleaner"
//垃圾清理
const
val
JUNK_CLEANER
=
"Junk Cleaner"
//垃圾清理
const
val
RECENT_APP_USAGE
=
"Recent App Usage"
//最近使用
const
val
LARGE_FILE_CLEANER
=
"Large File Cleaner"
//大文件
const
val
LARGE_FILE_CLEANER
=
"Large File Cleaner"
//大文件
const
val
NOTIFICATION_CLEANER
=
"Notification Cleaner"
const
val
NETWORK_TRAFFIC
=
"Network Traffic"
const
val
APP_MANAGER
=
"App Manager"
const
val
BATTERY_INFO
=
"Battery Info"
const
val
EMPTY_FILE_CLEANER
=
"Empty File Cleaner"
const
val
SIMILAR_PHOTOS
=
"Similar Photos"
const
val
SIMILAR_PHOTOS
=
"Similar Photos"
const
val
SPEAK_CLEANER
=
"Speaker Cleaner"
const
val
PHOTO_COMPRESS
=
"Photo Compress"
const
val
PHOTO_COMPRESS
=
"Photo Compress"
const
val
APP_LOCK
=
"App Lock"
const
val
APP_SPEED
=
"App Speed"
const
val
BATTERY_OPTIMIZER
=
"Battery Optimizer"
const
val
DEVICE_SCAN
=
"Device Scan"
const
val
SCREENSHOT_CLEANER
=
"Screenshot Cleaner"
const
val
SCREENSHOT_CLEANER
=
"Screenshot Cleaner"
}
}
\ No newline at end of file
app/src/main/java/com/test/easy/easycleanerjunk/view/AppDetailDialog.kt
View file @
f299164f
...
@@ -14,7 +14,6 @@ import android.view.View
...
@@ -14,7 +14,6 @@ import android.view.View
import
android.view.ViewGroup
import
android.view.ViewGroup
import
com.google.android.material.bottomsheet.BottomSheetDialog
import
com.google.android.material.bottomsheet.BottomSheetDialog
import
com.test.easy.easycleanerjunk.R
import
com.test.easy.easycleanerjunk.R
import
com.test.easy.easycleanerjunk.activity.PermissionManagerActivity
import
com.test.easy.easycleanerjunk.bean.AppBean
import
com.test.easy.easycleanerjunk.bean.AppBean
import
com.test.easy.easycleanerjunk.bean.AppBean.Companion.appBeanGson
import
com.test.easy.easycleanerjunk.bean.AppBean.Companion.appBeanGson
import
com.test.easy.easycleanerjunk.databinding.DialogAppDetailBinding
import
com.test.easy.easycleanerjunk.databinding.DialogAppDetailBinding
...
@@ -106,15 +105,6 @@ object AppDetailDialog {
...
@@ -106,15 +105,6 @@ object AppDetailDialog {
startActivity
(
intent
)
startActivity
(
intent
)
}
}
}
}
binding
.
tvPermissionCheck
.
setOnClickListener
{
dialog
.
dismiss
()
val
newIntent
=
Intent
(
this
,
PermissionManagerActivity
::
class
.
java
)
val
json
=
appBeanGson
.
toJson
(
appBean
)
newIntent
.
putExtra
(
"AppBean"
,
json
)
startActivity
(
newIntent
)
}
binding
.
tvUninstall
.
setOnClickListener
{
binding
.
tvUninstall
.
setOnClickListener
{
dialog
.
dismiss
()
dialog
.
dismiss
()
...
...
app/src/main/res/layout/activity_setting.xml
View file @
f299164f
...
@@ -65,37 +65,6 @@
...
@@ -65,37 +65,6 @@
app:trackTint=
"@color/color_switch_track_selector"
/>
app:trackTint=
"@color/color_switch_track_selector"
/>
</androidx.cardview.widget.CardView>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width=
"match_parent"
android:layout_height=
"60dp"
android:layout_marginHorizontal=
"16dp"
android:layout_marginTop=
"20dp"
app:cardBackgroundColor=
"@color/white"
app:cardCornerRadius=
"15dp"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_marginStart=
"12dp"
android:text=
"All Notification Messages"
android:textColor=
"@color/black"
android:textSize=
"16sp"
tools:ignore=
"HardcodedText"
/>
<androidx.appcompat.widget.SwitchCompat
android:id=
"@+id/switch_all_notification"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical|end"
android:layout_marginEnd=
"15dp"
android:layout_marginBottom=
"5dp"
android:thumb=
"@drawable/bg_switch_thumb_ffffff"
app:thumbTint=
"@color/white"
app:track=
"@drawable/bg_switch_track"
app:trackTint=
"@color/color_switch_track_selector"
/>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
<androidx.cardview.widget.CardView
...
...
app/src/main/res/layout/dialog_app_detail.xml
View file @
f299164f
...
@@ -195,20 +195,6 @@
...
@@ -195,20 +195,6 @@
android:textSize=
"14sp"
/>
android:textSize=
"14sp"
/>
<TextView
android:id=
"@+id/tv_permission_check"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"?android:attr/selectableItemBackground"
android:clickable=
"true"
android:focusable=
"true"
android:paddingHorizontal=
"20dp"
android:paddingVertical=
"10dp"
android:text=
"@string/permission_check"
android:textColor=
"#000000"
android:textSize=
"14sp"
/>
<TextView
<TextView
android:id=
"@+id/tv_uninstall"
android:id=
"@+id/tv_uninstall"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
...
...
app/src/main/res/layout/fragment_layout_home.xml
View file @
f299164f
...
@@ -309,6 +309,7 @@
...
@@ -309,6 +309,7 @@
<com.noober.background.view.BLLinearLayout
<com.noober.background.view.BLLinearLayout
android:id=
"@+id/id_app_manager"
android:id=
"@+id/id_app_manager"
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:visibility=
"invisible"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
android:layout_weight=
"1"
android:gravity=
"center_horizontal"
android:gravity=
"center_horizontal"
...
@@ -355,6 +356,7 @@
...
@@ -355,6 +356,7 @@
<com.noober.background.view.BLLinearLayout
<com.noober.background.view.BLLinearLayout
android:id=
"@+id/id_battery_info"
android:id=
"@+id/id_battery_info"
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:visibility=
"invisible"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:layout_weight=
"1"
android:gravity=
"center_horizontal"
android:gravity=
"center_horizontal"
...
@@ -402,153 +404,6 @@
...
@@ -402,153 +404,6 @@
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.appcompat.widget.LinearLayoutCompat>
</com.noober.background.view.BLLinearLayout>
</com.noober.background.view.BLLinearLayout>
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"17dp"
android:layout_marginTop=
"17dp"
android:layout_marginBottom=
"17dp"
android:gravity=
"center_vertical"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"More Tools"
android:textColor=
"#000000"
android:textSize=
"19sp"
android:textStyle=
"bold"
tools:ignore=
"HardcodedText"
/>
</androidx.appcompat.widget.LinearLayoutCompat>
<com.noober.background.view.BLLinearLayout
android:id=
"@+id/id_home_network"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginHorizontal=
"12dp"
android:layout_marginBottom=
"12dp"
android:elevation=
"0dp"
android:gravity=
"center_vertical"
android:paddingHorizontal=
"12dp"
android:paddingVertical=
"16dp"
android:visibility=
"visible"
app:bl_corners_radius=
"10dp"
app:bl_solid_color=
"#F8F8F8"
>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:maxHeight=
"27dp"
android:minHeight=
"27dp"
android:src=
"@mipmap/h_network"
tools:ignore=
"ContentDescription"
/>
<TextView
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"10dp"
android:layout_weight=
"1"
android:text=
"Network Traffic"
android:textColor=
"#000000"
android:textSize=
"13sp"
android:textStyle=
"bold"
tools:ignore=
"HardcodedText"
/>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:src=
"@mipmap/h_jiantou"
tools:ignore=
"ContentDescription"
/>
</com.noober.background.view.BLLinearLayout>
<com.noober.background.view.BLLinearLayout
android:id=
"@+id/id_home_recent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginHorizontal=
"12dp"
android:layout_marginBottom=
"12dp"
android:elevation=
"0dp"
android:gravity=
"center_vertical"
android:paddingHorizontal=
"12dp"
android:paddingVertical=
"16dp"
android:visibility=
"visible"
app:bl_corners_radius=
"10dp"
app:bl_solid_color=
"#F8F8F8"
>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:minWidth=
"27dp"
android:minHeight=
"27dp"
android:src=
"@mipmap/h_recentapp"
tools:ignore=
"ContentDescription"
/>
<TextView
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"10dp"
android:layout_weight=
"1"
android:text=
"Recent App Usage"
android:textColor=
"#000000"
android:textSize=
"13sp"
android:textStyle=
"bold"
tools:ignore=
"HardcodedText"
/>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:src=
"@mipmap/h_jiantou"
tools:ignore=
"ContentDescription"
/>
</com.noober.background.view.BLLinearLayout>
<com.noober.background.view.BLLinearLayout
android:id=
"@+id/id_notification_cleaner"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginHorizontal=
"12dp"
android:layout_marginBottom=
"12dp"
android:elevation=
"0dp"
android:gravity=
"center_vertical"
android:paddingHorizontal=
"12dp"
android:paddingVertical=
"16dp"
android:visibility=
"visible"
app:bl_corners_radius=
"10dp"
app:bl_solid_color=
"#F8F8F8"
>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:minWidth=
"27dp"
android:minHeight=
"27dp"
android:src=
"@mipmap/h_notification"
tools:ignore=
"ContentDescription"
/>
<TextView
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"10dp"
android:layout_weight=
"1"
android:text=
"Notification Cleaner"
android:textColor=
"#000000"
android:textSize=
"13sp"
android:textStyle=
"bold"
tools:ignore=
"HardcodedText"
/>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:src=
"@mipmap/h_jiantou"
tools:ignore=
"ContentDescription"
/>
</com.noober.background.view.BLLinearLayout>
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.core.widget.NestedScrollView>
</androidx.core.widget.NestedScrollView>
...
...
app/src/main/res/layout/reminder_layout_notification_big_notify.xml
View file @
f299164f
...
@@ -33,85 +33,6 @@
...
@@ -33,85 +33,6 @@
tools:ignore=
"HardcodedText"
/>
tools:ignore=
"HardcodedText"
/>
</LinearLayout>
</LinearLayout>
<!--病毒-->
<LinearLayout
android:id=
"@+id/id_ll_virus"
android:layout_width=
"0dp"
android:visibility=
"gone"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:gravity=
"center"
android:orientation=
"vertical"
tools:ignore=
"UseCompoundDrawables"
>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"8dp"
android:src=
"@drawable/saomiao"
tools:ignore=
"ContentDescription"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"Virus"
android:textColor=
"#666666"
android:textSize=
"12sp"
tools:ignore=
"HardcodedText"
/>
</LinearLayout>
<!--app管理-->
<LinearLayout
android:id=
"@+id/id_app_manager"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:gravity=
"center"
android:orientation=
"vertical"
tools:ignore=
"UseCompoundDrawables"
>
<ImageView
android:layout_width=
"30dp"
android:layout_height=
"30dp"
android:layout_marginBottom=
"8dp"
android:src=
"@drawable/guanli"
tools:ignore=
"ContentDescription"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"Manager"
android:textColor=
"#666666"
android:textSize=
"12sp"
tools:ignore=
"HardcodedText"
/>
</LinearLayout>
<!--电池-->
<LinearLayout
android:id=
"@+id/id_battery"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:gravity=
"center"
android:orientation=
"vertical"
tools:ignore=
"UseCompoundDrawables"
>
<ImageView
android:layout_width=
"30dp"
android:layout_height=
"30dp"
android:layout_marginBottom=
"8dp"
android:src=
"@drawable/dianchi"
tools:ignore=
"ContentDescription"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"Battery"
android:textColor=
"#666666"
android:textSize=
"12sp"
tools:ignore=
"HardcodedText"
/>
</LinearLayout>
<!--手电-->
<!--手电-->
<LinearLayout
<LinearLayout
android:id=
"@+id/id_lighit"
android:id=
"@+id/id_lighit"
...
...
app/src/main/res/layout/reminder_layout_notification_notify.xml
View file @
f299164f
...
@@ -24,58 +24,6 @@
...
@@ -24,58 +24,6 @@
tools:ignore=
"ContentDescription"
/>
tools:ignore=
"ContentDescription"
/>
</LinearLayout>
</LinearLayout>
<!--病毒-->
<LinearLayout
android:id=
"@+id/id_ll_virus"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:visibility=
"gone"
android:gravity=
"center"
android:orientation=
"vertical"
>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"4dp"
android:src=
"@drawable/saomiao"
/>
</LinearLayout>
<!--app管理-->
<LinearLayout
android:id=
"@+id/id_app_manager"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:gravity=
"center"
android:orientation=
"vertical"
>
<ImageView
android:layout_width=
"30dp"
android:layout_height=
"30dp"
android:layout_marginBottom=
"4dp"
android:src=
"@drawable/guanli"
tools:ignore=
"ContentDescription"
/>
</LinearLayout>
<!--电池-->
<LinearLayout
android:id=
"@+id/id_battery"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:gravity=
"center"
android:orientation=
"vertical"
>
<ImageView
android:layout_width=
"30dp"
android:layout_height=
"30dp"
android:layout_marginBottom=
"4dp"
android:src=
"@drawable/dianchi"
tools:ignore=
"ContentDescription"
/>
</LinearLayout>
<!--手电-->
<!--手电-->
<LinearLayout
<LinearLayout
android:id=
"@+id/id_lighit"
android:id=
"@+id/id_lighit"
...
...
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