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
9a31a1ee
Commit
9a31a1ee
authored
Jun 23, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/free-master' into free-master
parents
e5ae3fd0
1013ec9c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
31 additions
and
1397 deletions
+31
-1397
MyApplication.kt
.../main/java/com/test/easy/easycleanerjunk/MyApplication.kt
+0
-12
CleanGuestActivity.kt
.../test/easy/easycleanerjunk/activity/CleanGuestActivity.kt
+2
-2
CleanJunkActivity.kt
...m/test/easy/easycleanerjunk/activity/CleanJunkActivity.kt
+0
-1
DeviceScanActivity.kt
.../test/easy/easycleanerjunk/activity/DeviceScanActivity.kt
+2
-5
NewMainActivity.kt
...est/easy/easycleanerjunk/activity/home/NewMainActivity.kt
+0
-5
BottomSheetManager.kt
...erjunk/activity/photocompress/photo/BottomSheetManager.kt
+6
-0
PhotoListManager.kt
...anerjunk/activity/photocompress/photo/PhotoListManager.kt
+6
-0
StartCompressionPhotoActivity.kt
...vity/photocompress/photo/StartCompressionPhotoActivity.kt
+2
-1
NewSplashActivity.kt
...easy/easycleanerjunk/activity/splash/NewSplashActivity.kt
+0
-1
AppBean.kt
...c/main/java/com/test/easy/easycleanerjunk/bean/AppBean.kt
+0
-44
PermissionBean.kt
...java/com/test/easy/easycleanerjunk/bean/PermissionBean.kt
+0
-138
TrafficBean.kt
...in/java/com/test/easy/easycleanerjunk/bean/TrafficBean.kt
+0
-3
NotificationUtils.kt
...om/test/easy/easycleanerjunk/display/NotificationUtils.kt
+0
-74
PushStrategy.kt
...ava/com/test/easy/easycleanerjunk/display/PushStrategy.kt
+0
-98
RamMemoryEx.kt
...java/com/test/easy/easycleanerjunk/display/RamMemoryEx.kt
+0
-17
UserChancelEx.kt
...va/com/test/easy/easycleanerjunk/display/UserChancelEx.kt
+0
-47
AppSizeUtils.kt
.../java/com/test/easy/easycleanerjunk/helps/AppSizeUtils.kt
+0
-135
ComUtils.kt
...main/java/com/test/easy/easycleanerjunk/helps/ComUtils.kt
+0
-60
NetWorkSpeed.kt
.../java/com/test/easy/easycleanerjunk/helps/NetWorkSpeed.kt
+0
-68
NetworkStatsHelper.java
...m/test/easy/easycleanerjunk/helps/NetworkStatsHelper.java
+0
-156
LaunchTimeStat.kt
...st/easy/easycleanerjunk/helps/recentapp/LaunchTimeStat.kt
+0
-50
RecentBean.kt
...m/test/easy/easycleanerjunk/helps/recentapp/RecentBean.kt
+0
-3
ScreenTimeStat.kt
...st/easy/easycleanerjunk/helps/recentapp/ScreenTimeStat.kt
+0
-105
FlashlightService.kt
...om/test/easy/easycleanerjunk/service/FlashlightService.kt
+0
-1
AppUtils.java
...in/java/com/test/easy/easycleanerjunk/utils/AppUtils.java
+0
-82
AdPreparationPop.kt
...va/com/test/easy/easycleanerjunk/view/AdPreparationPop.kt
+0
-46
AppDetailDialog.kt
...ava/com/test/easy/easycleanerjunk/view/AppDetailDialog.kt
+0
-130
NotificationOpenDialog.kt
.../test/easy/easycleanerjunk/view/NotificationOpenDialog.kt
+0
-18
PermissionFilterDialog.kt
.../test/easy/easycleanerjunk/view/PermissionFilterDialog.kt
+0
-39
TimeSelectDialog.kt
...va/com/test/easy/easycleanerjunk/view/TimeSelectDialog.kt
+0
-56
activity_compression_photo_list.xml
app/src/main/res/layout/activity_compression_photo_list.xml
+13
-0
No files found.
app/src/main/java/com/test/easy/easycleanerjunk/MyApplication.kt
View file @
9a31a1ee
...
@@ -48,17 +48,6 @@ class MyApplication : BaseApplication() {
...
@@ -48,17 +48,6 @@ class MyApplication : BaseApplication() {
InstallHelps
.
init
()
InstallHelps
.
init
()
}
}
MobileAds
.
initialize
(
this
)
{
initializationStatus
->
MobileAds
.
initialize
(
this
)
{
initializationStatus
->
val
statusMap
=
initializationStatus
.
adapterStatusMap
for
(
adapterClass
in
statusMap
.
keys
)
{
val
status
=
statusMap
[
adapterClass
]
Log
.
d
(
"MyApp"
,
String
.
format
(
"Adapter name: %s, Description: %s, Latency: %d"
,
adapterClass
,
status
!!
.
description
,
status
.
latency
)
)
}
}
}
}
}
initLifeListener
()
initLifeListener
()
...
@@ -66,7 +55,6 @@ class MyApplication : BaseApplication() {
...
@@ -66,7 +55,6 @@ class MyApplication : BaseApplication() {
private
fun
initNotificationWork
()
{
private
fun
initNotificationWork
()
{
FirebaseApp
.
initializeApp
(
this
)
FirebaseApp
.
initializeApp
(
this
)
Log
.
d
(
"MyService"
,
"startService:"
+
Process
.
myPid
());
}
}
@SuppressLint
(
"UnspecifiedRegisterReceiverFlag"
)
@SuppressLint
(
"UnspecifiedRegisterReceiverFlag"
)
...
...
app/src/main/java/com/test/easy/easycleanerjunk/activity/CleanGuestActivity.kt
View file @
9a31a1ee
...
@@ -23,9 +23,9 @@ class CleanGuestActivity : BaseActivity<ActivityLayoutCleanGuestBinding>() {
...
@@ -23,9 +23,9 @@ class CleanGuestActivity : BaseActivity<ActivityLayoutCleanGuestBinding>() {
BarUtils
.
setStatusBarLightMode
(
this
,
true
)
BarUtils
.
setStatusBarLightMode
(
this
,
true
)
BarUtils
.
setStatusBarColor
(
this
,
Color
.
TRANSPARENT
)
BarUtils
.
setStatusBarColor
(
this
,
Color
.
TRANSPARENT
)
binding
.
root
.
updatePadding
(
top
=
BarUtils
.
getStatusBarHeight
())
binding
.
root
.
updatePadding
(
top
=
BarUtils
.
getStatusBarHeight
())
binding
.
root
.
postDelayed
({
//
binding.root.postDelayed({
binding
.
idTvSkip
.
isVisible
=
true
binding
.
idTvSkip
.
isVisible
=
true
},
3000
)
//
}, 3000)
binding
.
idTvSkip
.
setOnClickListener
{
binding
.
idTvSkip
.
setOnClickListener
{
finishToMain
()
finishToMain
()
}
}
...
...
app/src/main/java/com/test/easy/easycleanerjunk/activity/CleanJunkActivity.kt
View file @
9a31a1ee
...
@@ -185,7 +185,6 @@ class CleanJunkActivity : BaseActivity<ActivityLayoutCleanJunkBinding>() {
...
@@ -185,7 +185,6 @@ class CleanJunkActivity : BaseActivity<ActivityLayoutCleanJunkBinding>() {
@SuppressLint
(
"NotifyDataSetChanged"
)
@SuppressLint
(
"NotifyDataSetChanged"
)
private
fun
addData
(
index
:
Int
)
{
private
fun
addData
(
index
:
Int
)
{
if
(
parentList
.
isNotEmpty
())
{
if
(
parentList
.
isNotEmpty
())
{
Log
.
e
(
"MXL"
,
"addData: $index"
)
parentList
[
index
].
isfinish
=
true
parentList
[
index
].
isfinish
=
true
parentList
[
index
].
parentSize
=
sizes
[
index
]
parentList
[
index
].
parentSize
=
sizes
[
index
]
mAdapter
.
notifyDataSetChanged
()
mAdapter
.
notifyDataSetChanged
()
...
...
app/src/main/java/com/test/easy/easycleanerjunk/activity/DeviceScanActivity.kt
View file @
9a31a1ee
...
@@ -70,17 +70,14 @@ class DeviceScanActivity : BaseActivity<ActivityDeviceScanBinding>() {
...
@@ -70,17 +70,14 @@ class DeviceScanActivity : BaseActivity<ActivityDeviceScanBinding>() {
}
}
}
}
// speedFactor越大, 那速度越慢
//https://zhuanlan.zhihu.com/p/654289405
private
fun
RecyclerView
.
smoothScrollEquallyTo
(
pos
:
Int
,
speedFactor
:
Int
=
50
)
{
private
fun
RecyclerView
.
smoothScrollEquallyTo
(
pos
:
Int
,
speedFactor
:
Int
=
50
)
{
val
scroller
=
object
:
LinearSmoothScroller
(
context
)
{
val
scroller
=
object
:
LinearSmoothScroller
(
context
)
{
override
fun
calculateSpeedPerPixel
(
displayMetrics
:
DisplayMetrics
):
Float
{
override
fun
calculateSpeedPerPixel
(
displayMetrics
:
DisplayMetrics
):
Float
{
// 源码是: return 25f / displayMetrics.densityDpi;
val
layoutMgr
=
this
.
layoutManager
val
layoutMgr
=
this
.
layoutManager
if
(
layoutMgr
!
is
LinearLayoutManager
)
return
super
.
calculateSpeedPerPixel
(
displayMetrics
)
if
(
layoutMgr
!
is
LinearLayoutManager
)
return
super
.
calculateSpeedPerPixel
(
displayMetrics
)
val
first
=
layoutMgr
.
findFirstVisibleItemPosition
()
val
first
=
layoutMgr
.
findFirstVisibleItemPosition
()
val
diff
=
abs
(
pos
-
first
)
//来看这个远不远
val
diff
=
abs
(
pos
-
first
)
val
speed
=
25f
/
diff
*
speedFactor
//diff越大, 那25f/diff就越小, 那速度就越快.
val
speed
=
25f
/
diff
*
speedFactor
val
ret
=
speed
/
displayMetrics
.
densityDpi
val
ret
=
speed
/
displayMetrics
.
densityDpi
return
ret
return
ret
}
}
...
...
app/src/main/java/com/test/easy/easycleanerjunk/activity/home/NewMainActivity.kt
View file @
9a31a1ee
...
@@ -64,11 +64,6 @@ class NewMainActivity : BaseActivity<ActivityMainBinding>() {
...
@@ -64,11 +64,6 @@ class NewMainActivity : BaseActivity<ActivityMainBinding>() {
binding
.
idBottom2
.
setOnClickListener
{
binding
.
idBottom2
.
setOnClickListener
{
binding
.
idVp
.
currentItem
=
1
binding
.
idVp
.
currentItem
=
1
}
}
MediaStoreUtils
.
updateMediaStore
(
this
,
Environment
.
getExternalStoragePublicDirectory
(
Environment
.
DIRECTORY_DOWNLOADS
).
listFiles
()
?.
map
{
it
.
absolutePath
}
?.
toTypedArray
()
)
}
}
private
fun
setPage
(
p
:
Int
)
{
private
fun
setPage
(
p
:
Int
)
{
...
...
app/src/main/java/com/test/easy/easycleanerjunk/activity/photocompress/photo/BottomSheetManager.kt
View file @
9a31a1ee
...
@@ -21,6 +21,7 @@ class BottomSheetManager : BottomSheetBehavior.BottomSheetCallback, OnClickListe
...
@@ -21,6 +21,7 @@ class BottomSheetManager : BottomSheetBehavior.BottomSheetCallback, OnClickListe
private
val
bottomSheetBehavior
:
BottomSheetBehavior
<
LinearLayout
>
private
val
bottomSheetBehavior
:
BottomSheetBehavior
<
LinearLayout
>
private
val
listener
:
AlbumsSelectListener
private
val
listener
:
AlbumsSelectListener
private
val
mNoText
:
TextView
constructor
(
mContext
:
Activity
,
listener
:
AlbumsSelectListener
)
{
constructor
(
mContext
:
Activity
,
listener
:
AlbumsSelectListener
)
{
this
.
mContext
=
mContext
this
.
mContext
=
mContext
...
@@ -30,6 +31,8 @@ class BottomSheetManager : BottomSheetBehavior.BottomSheetCallback, OnClickListe
...
@@ -30,6 +31,8 @@ class BottomSheetManager : BottomSheetBehavior.BottomSheetCallback, OnClickListe
val
bottomSheet
=
mContext
.
findViewById
<
LinearLayout
>(
R
.
id
.
bottom_sheet
)
val
bottomSheet
=
mContext
.
findViewById
<
LinearLayout
>(
R
.
id
.
bottom_sheet
)
bottomSheetBehavior
=
BottomSheetBehavior
.
from
(
bottomSheet
)
bottomSheetBehavior
=
BottomSheetBehavior
.
from
(
bottomSheet
)
mAlbumName
=
mContext
.
findViewById
(
R
.
id
.
albumname
)
mAlbumName
=
mContext
.
findViewById
(
R
.
id
.
albumname
)
mNoText
=
mContext
.
findViewById
(
R
.
id
.
no_data
)
init
()
init
()
}
}
...
@@ -44,6 +47,9 @@ class BottomSheetManager : BottomSheetBehavior.BottomSheetCallback, OnClickListe
...
@@ -44,6 +47,9 @@ class BottomSheetManager : BottomSheetBehavior.BottomSheetCallback, OnClickListe
mRecycleView
.
adapter
=
mAdapter
mRecycleView
.
adapter
=
mAdapter
if
(
mList
.
isNotEmpty
())
{
if
(
mList
.
isNotEmpty
())
{
onItemClick
(
0
,
mList
[
0
])
onItemClick
(
0
,
mList
[
0
])
mNoText
.
visibility
=
View
.
GONE
}
else
{
mNoText
.
visibility
=
View
.
VISIBLE
}
}
}
}
...
...
app/src/main/java/com/test/easy/easycleanerjunk/activity/photocompress/photo/PhotoListManager.kt
View file @
9a31a1ee
...
@@ -20,6 +20,7 @@ class PhotoListManager(context: Activity) : OnItemClickListener<PhotoBean>, Span
...
@@ -20,6 +20,7 @@ class PhotoListManager(context: Activity) : OnItemClickListener<PhotoBean>, Span
private
var
mBtnContinue
:
TextView
?
=
null
private
var
mBtnContinue
:
TextView
?
=
null
private
val
mSelectAll
:
TextView
private
val
mSelectAll
:
TextView
private
val
mNoText
:
TextView
private
val
mContext
:
Context
=
context
private
val
mContext
:
Context
=
context
...
@@ -30,6 +31,7 @@ class PhotoListManager(context: Activity) : OnItemClickListener<PhotoBean>, Span
...
@@ -30,6 +31,7 @@ class PhotoListManager(context: Activity) : OnItemClickListener<PhotoBean>, Span
mRecycleView
=
context
.
findViewById
(
R
.
id
.
content
)
mRecycleView
=
context
.
findViewById
(
R
.
id
.
content
)
mBtnContinue
=
context
.
findViewById
(
R
.
id
.
btn_continue
)
mBtnContinue
=
context
.
findViewById
(
R
.
id
.
btn_continue
)
mSelectAll
=
context
.
findViewById
(
R
.
id
.
selectAll
)
mSelectAll
=
context
.
findViewById
(
R
.
id
.
selectAll
)
mNoText
=
context
.
findViewById
(
R
.
id
.
no_data
)
init
()
init
()
}
}
...
@@ -62,6 +64,7 @@ class PhotoListManager(context: Activity) : OnItemClickListener<PhotoBean>, Span
...
@@ -62,6 +64,7 @@ class PhotoListManager(context: Activity) : OnItemClickListener<PhotoBean>, Span
}
}
override
fun
onItemClick
(
position
:
Int
,
entity
:
PhotoBean
)
{
override
fun
onItemClick
(
position
:
Int
,
entity
:
PhotoBean
)
{
}
}
fun
onSelectAlbum
(
album
:
AlbumBean
)
{
fun
onSelectAlbum
(
album
:
AlbumBean
)
{
...
@@ -70,6 +73,9 @@ class PhotoListManager(context: Activity) : OnItemClickListener<PhotoBean>, Span
...
@@ -70,6 +73,9 @@ class PhotoListManager(context: Activity) : OnItemClickListener<PhotoBean>, Span
PhotoCache
.
getInstance
().
clearCache
()
PhotoCache
.
getInstance
().
clearCache
()
mCompressionPhotoListAdapter
?.
updateData
(
list
)
mCompressionPhotoListAdapter
?.
updateData
(
list
)
updateBtnContinue
()
updateBtnContinue
()
mNoText
.
visibility
=
View
.
GONE
}
else
{
mNoText
.
visibility
=
View
.
VISIBLE
}
}
}
}
...
...
app/src/main/java/com/test/easy/easycleanerjunk/activity/photocompress/photo/StartCompressionPhotoActivity.kt
View file @
9a31a1ee
...
@@ -60,7 +60,8 @@ class StartCompressionPhotoActivity : BaseActivity<ActivityStartCompressionPhoto
...
@@ -60,7 +60,8 @@ class StartCompressionPhotoActivity : BaseActivity<ActivityStartCompressionPhoto
startActivity
(
Intent
(
this
,
CompressionPhotoListActivity
::
class
.
java
))
startActivity
(
Intent
(
this
,
CompressionPhotoListActivity
::
class
.
java
))
finish
()
finish
()
}
else
{
}
else
{
Toast
.
makeText
(
this
,
"Album photos not detected, no compression required."
,
Toast
.
LENGTH_SHORT
).
show
()
startActivity
(
Intent
(
this
,
CompressionPhotoListActivity
::
class
.
java
))
finish
()
}
}
}
}
},
Random
.
nextLong
(
2500
,
4000
))
},
Random
.
nextLong
(
2500
,
4000
))
...
...
app/src/main/java/com/test/easy/easycleanerjunk/activity/splash/NewSplashActivity.kt
View file @
9a31a1ee
...
@@ -95,7 +95,6 @@ class NewSplashActivity : BaseActivity<ActivityLayoutSplashBinding>(),
...
@@ -95,7 +95,6 @@ class NewSplashActivity : BaseActivity<ActivityLayoutSplashBinding>(),
mProgressManager
?.
pauseProgress
()
mProgressManager
?.
pauseProgress
()
runOnUiThread
{
runOnUiThread
{
AdmobUtils
.
showAppOpenAd
(
this
@NewSplashActivity
)
{
AdmobUtils
.
showAppOpenAd
(
this
@NewSplashActivity
)
{
Log
.
d
(
"glc"
,
"showAppOpenAd"
)
mProgressManager
?.
maxProgress
()
mProgressManager
?.
maxProgress
()
}
}
}
}
...
...
app/src/main/java/com/test/easy/easycleanerjunk/bean/AppBean.kt
deleted
100644 → 0
View file @
e5ae3fd0
package
com.test.easy.easycleanerjunk.bean
import
android.app.usage.UsageEvents
import
android.app.usage.UsageStats
import
android.graphics.drawable.Drawable
import
com.google.gson.ExclusionStrategy
import
com.google.gson.FieldAttributes
import
com.google.gson.GsonBuilder
data class
AppBean
(
val
icIcon
:
Drawable
,
//Drawable会导致序列化失败
val
appName
:
String
,
val
pkg
:
String
,
var
isSelected
:
Boolean
=
false
,
var
installTime
:
Long
=
0
,
var
appSize
:
Long
=
-
1L
,
//0 没有大小 -1没有权限
var
lastUsedTime
:
Long
=
-
1L
,
//-1没有权限 -2超过30没用
)
{
var
pinYin
:
String
=
""
var
usageEvents
:
List
<
UsageEvents
.
Event
>?
=
null
var
usageStats
:
List
<
UsageStats
>?
=
null
var
launchTimes
=
0
var
foregroundTimes
=
0
var
backgroundTimes
=
0
var
isRunning
=
false
var
screenTime
:
Long
=
0
companion
object
{
val
appBeanGson
=
GsonBuilder
().
setExclusionStrategies
(
object
:
ExclusionStrategy
{
override
fun
shouldSkipField
(
f
:
FieldAttributes
):
Boolean
{
val
skipField
=
arrayOf
(
"icIcon"
)
return
skipField
.
contains
(
f
.
name
)
}
override
fun
shouldSkipClass
(
clazz
:
Class
<
*
>):
Boolean
{
// val skipClass = arrayOf("List")
// skipClass.contains(clazz.name)
return
false
}
}).
create
()
}
}
app/src/main/java/com/test/easy/easycleanerjunk/bean/PermissionBean.kt
deleted
100644 → 0
View file @
e5ae3fd0
This diff is collapsed.
Click to expand it.
app/src/main/java/com/test/easy/easycleanerjunk/bean/TrafficBean.kt
deleted
100644 → 0
View file @
e5ae3fd0
package
com.test.easy.easycleanerjunk.bean
data class
TrafficBean
(
var
type
:
Int
,
val
packageName
:
String
,
var
wifiUsed
:
Long
,
var
mobileUsed
:
Long
)
\ No newline at end of file
app/src/main/java/com/test/easy/easycleanerjunk/display/NotificationUtils.kt
View file @
9a31a1ee
...
@@ -20,82 +20,8 @@ import com.test.easy.easycleanerjunk.service.FlashlightService
...
@@ -20,82 +20,8 @@ import com.test.easy.easycleanerjunk.service.FlashlightService
object
NotificationUtils
{
object
NotificationUtils
{
private
val
TAG
=
"NotificationUtils"
const
val
NOTIFICATION_TAG
=
"SmartCleanNotification"
const
val
NOTIFICATION_TAG
=
"SmartCleanNotification"
private
const
val
CHANNEL_ID
=
"Misc"
fun
showNotification
(
context
:
Context
,
notificationId
:
Int
,
remoteViews
:
RemoteViews
,
closeViewId
:
Int
,
pendingIntent
:
PendingIntent
,
pushStayTime
:
Long
)
{
if
(
closeViewId
!=
0
)
{
val
closeIntent
=
Intent
(
context
,
CloseNotificationReceiver
::
class
.
java
).
apply
{
putExtra
(
"notificationId"
,
notificationId
)
}
val
closePendingIntent
=
PendingIntent
.
getBroadcast
(
context
,
0
,
closeIntent
,
PendingIntent
.
FLAG_MUTABLE
)
remoteViews
.
setOnClickPendingIntent
(
closeViewId
,
closePendingIntent
)
}
val
builder
=
createNotificationBuilder
(
context
,
remoteViews
,
pendingIntent
,
pushStayTime
)
sendNotification
(
context
,
notificationId
,
builder
)
}
private
fun
createNotificationBuilder
(
context
:
Context
,
remoteViews
:
RemoteViews
,
pendingIntent
:
PendingIntent
,
pushStayTime
:
Long
):
NotificationCompat
.
Builder
{
val
notificationManager
=
context
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
)
as
NotificationManager
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
val
channel
=
NotificationChannel
(
CHANNEL_ID
,
CHANNEL_ID
,
NotificationManager
.
IMPORTANCE_HIGH
)
channel
.
lockscreenVisibility
=
NotificationCompat
.
VISIBILITY_PUBLIC
notificationManager
.
createNotificationChannel
(
channel
)
}
val
deleteIntent
=
Intent
(
context
,
CloseNotificationReceiver
::
class
.
java
).
apply
{
action
=
"DELETE_NOTIFICATION"
}
val
deletePendingIntent
=
PendingIntent
.
getBroadcast
(
context
,
0
,
deleteIntent
,
PendingIntent
.
FLAG_MUTABLE
)
return
NotificationCompat
.
Builder
(
context
,
CHANNEL_ID
)
.
setSmallIcon
(
R
.
mipmap
.
logo
)
.
setPriority
(
NotificationCompat
.
PRIORITY_MAX
)
.
setCategory
(
NotificationCompat
.
CATEGORY_ALARM
)
.
setWhen
(
System
.
currentTimeMillis
())
.
setAutoCancel
(
true
)
.
setDeleteIntent
(
deletePendingIntent
)
.
setContentIntent
(
pendingIntent
)
.
setContent
(
remoteViews
)
.
setCustomHeadsUpContentView
(
remoteViews
)
.
setCustomBigContentView
(
remoteViews
)
.
setCustomContentView
(
remoteViews
)
.
setStyle
(
NotificationCompat
.
BigTextStyle
())
.
setVisibility
(
NotificationCompat
.
VISIBILITY_PUBLIC
)
.
setTimeoutAfter
(
pushStayTime
)
.
setSound
(
null
)
.
setLights
(
0
,
0
,
0
)
.
setVibrate
(
null
)
.
setAllowSystemGeneratedContextualActions
(
true
)
.
setBubbleMetadata
(
null
)
}
private
fun
sendNotification
(
context
:
Context
,
notificationId
:
Int
,
builder
:
NotificationCompat
.
Builder
)
{
val
notificationManager
=
context
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
)
as
NotificationManager
val
notification
=
builder
.
build
()
notificationManager
.
notify
(
NOTIFICATION_TAG
,
notificationId
,
notification
)
}
fun
createPermanentNotification
(
context
:
Context
):
Notification
{
fun
createPermanentNotification
(
context
:
Context
):
Notification
{
...
...
app/src/main/java/com/test/easy/easycleanerjunk/display/PushStrategy.kt
deleted
100644 → 0
View file @
e5ae3fd0
package
com.test.easy.easycleanerjunk.display
import
android.os.Process
import
com.test.easy.easycleanerjunk.MyApplication
import
com.test.easy.easycleanerjunk.bean.ConfigBean
import
com.test.easy.easycleanerjunk.bean.ConfigBean.Companion.getActionPushInterval
import
com.test.easy.easycleanerjunk.helps.ComUtils
import
com.test.easy.easycleanerjunk.helps.LogEx
import
com.test.easy.easycleanerjunk.utils.SPUtils
/**
* 推送的配置类,定义了是否推送的判断条件
*/
object
PushStrategy
{
private
val
TAG
=
"PushStrategy"
/**
* 新用户是否显示
*/
fun
newUserPush
(
newUserAvoidTime
:
Int
):
Boolean
{
val
firstLaunchTime
=
SPUtils
.
getInstance
().
getLong
(
"install_info"
,
0
)
val
haveFirstLaunchTime
=
(
System
.
currentTimeMillis
()
-
firstLaunchTime
)
/
1000
val
flag
=
haveFirstLaunchTime
>
newUserAvoidTime
return
flag
}
/**
* 所有推送是否推送大于间隔时间
* @param interval 秒,目前默认自然和渠道用户都配的 60s
*/
fun
canPushNextTime
(
interval
:
Int
):
Boolean
{
val
lastPushTime
=
SPUtils
.
getInstance
().
getLong
(
"all_last_push_time"
,
0
)
val
haveInterval
=
(
System
.
currentTimeMillis
()
-
lastPushTime
)
/
1000
return
haveInterval
>
interval
}
/**
* 所有的推送条件过滤
* 根据id判断通知是否可推送
* @param actionId 功能或者场景的id
*/
fun
isPush
(
actionId
:
Int
):
Boolean
{
val
configBean
:
ConfigBean
=
ComUtils
.
getSpConfigBean
()
// 新用户是否显示
if
(!
newUserPush
(
configBean
.
newuser_avoid_time
))
{
LogEx
.
logDebug
(
TAG
,
"================================新用户推送拦截==============================="
)
return
false
}
// 渠道用户是否推送
// if (!UserChancelEx.getUserChancelSwitch(pushManagement.push_show)) {
// LogEx.logDebug(TAG, "================================渠道用户拦截===============================")
// return false
// }
//是否上次推送间隔大于配置间隔
// val isOganic = UserChancelEx.isOrganicUser()
// val interval = if (isOganic) pushManagement.o_push_interval else pushManagement.all_push_interval
val
interval
=
configBean
.
all_push_interval
if
(!
canPushNextTime
(
interval
))
{
LogEx
.
logDebug
(
TAG
,
"================================总间隔拦截==============================="
)
return
false
}
//当前类型通知推送间隔是否大于配置间隔
val
pushInterval
=
configBean
.
getActionPushInterval
(
actionId
)
if
(!
actionTypeCanPsh
(
actionId
,
pushInterval
))
{
LogEx
.
logDebug
(
TAG
,
"================================当前通知类型间隔拦截==============================="
)
return
false
}
//是否在前台推送
val
isResumed
=
MyApplication
.
PAUSED_VALUE
==
1
LogEx
.
logDebug
(
TAG
,
"isResumed=$isResumed"
)
if
(
isResumed
)
{
LogEx
.
logDebug
(
TAG
,
"================================app在前台拦截==============================="
)
return
false
}
val
pid
=
Process
.
myPid
()
LogEx
.
logDebug
(
TAG
,
"可以发送通知了。。。"
)
return
true
}
/**
* 当前类型通知推送间隔是否大于配置间隔
*/
private
fun
actionTypeCanPsh
(
actionId
:
Int
,
pushInterval
:
Int
=
0
):
Boolean
{
val
lastTypePushTime
=
SPUtils
.
getInstance
().
getLong
(
actionId
.
toString
(),
0L
)
val
actionInterval
=
(
System
.
currentTimeMillis
()
-
lastTypePushTime
)
/
1000
LogEx
.
logDebug
(
TAG
,
"actionId=$actionId actionInterval=$actionInterval pushInterval=$pushInterval"
)
return
actionInterval
>
pushInterval
}
}
\ No newline at end of file
app/src/main/java/com/test/easy/easycleanerjunk/display/RamMemoryEx.kt
deleted
100644 → 0
View file @
e5ae3fd0
package
com.test.easy.easycleanerjunk.display
import
android.app.ActivityManager
import
android.content.Context
object
RamMemoryEx
{
fun
getMemoryUsage
(
context
:
Context
):
Float
{
val
activityManager
:
ActivityManager
=
context
.
getSystemService
(
Context
.
ACTIVITY_SERVICE
)
as
ActivityManager
val
memoryInfo
:
ActivityManager
.
MemoryInfo
=
ActivityManager
.
MemoryInfo
()
activityManager
.
getMemoryInfo
(
memoryInfo
)
val
totalMemory
:
Long
=
memoryInfo
.
totalMem
val
availableMemory
:
Long
=
memoryInfo
.
availMem
val
usedMemory
=
(
totalMemory
-
availableMemory
).
toDouble
()
return
((
usedMemory
/
totalMemory
)
*
100
).
toFloat
()
}
}
app/src/main/java/com/test/easy/easycleanerjunk/display/UserChancelEx.kt
deleted
100644 → 0
View file @
e5ae3fd0
package
com.test.easy.easycleanerjunk.display
import
android.content.Context
import
android.telephony.TelephonyManager
import
com.test.easy.easycleanerjunk.helps.BaseApplication
import
com.test.easy.easycleanerjunk.utils.SPUtils
/**
* 判断用户渠道的方法
*/
object
UserChancelEx
{
fun
getUserChancelSwitch
(
int
:
Int
):
Boolean
{
val
isOrganic
=
isOrganicUser
()
val
isHasSim
=
isSimCardAvailable
()
return
l
(
int
,
isHasSim
,
isOrganic
)
}
fun
l
(
i2
:
Int
,
isHasSim
:
Boolean
,
isOrganic
:
Boolean
):
Boolean
{
return
if
(!
isOrganic
&&
!
k
(
i2
,
3
))
{
false
}
else
if
(
isOrganic
&&
!
k
(
i2
,
2
))
{
false
}
else
if
(!
isHasSim
&&
!
k
(
i2
,
1
))
{
false
}
else
if
(
isHasSim
&&
!
k
(
i2
,
0
))
{
false
}
else
k
(
i2
,
4
)
}
fun
k
(
i2
:
Int
,
i3
:
Int
):
Boolean
{
return
i2
shr
i3
and
1
==
1
}
/**
* 是否是自然用户
*/
fun
isOrganicUser
():
Boolean
{
val
source
:
String
=
SPUtils
.
getInstance
().
getString
(
"install_info_source"
,
""
)
return
!(
source
.
contains
(
"gclid"
)
||
source
.
contains
(
"facebook"
))
}
fun
isSimCardAvailable
():
Boolean
{
val
telephonyManager
=
BaseApplication
.
context
.
getSystemService
(
Context
.
TELEPHONY_SERVICE
)
as
TelephonyManager
return
telephonyManager
.
simState
!=
TelephonyManager
.
SIM_STATE_ABSENT
}
}
\ No newline at end of file
app/src/main/java/com/test/easy/easycleanerjunk/helps/AppSizeUtils.kt
deleted
100644 → 0
View file @
e5ae3fd0
package
com.test.easy.easycleanerjunk.helps
import
android.app.usage.StorageStats
import
android.app.usage.StorageStatsManager
import
android.content.Context
import
android.content.pm.IPackageStatsObserver
import
android.content.pm.PackageManager
import
android.content.pm.PackageStats
import
android.os.Build
import
android.os.storage.StorageManager
import
android.text.format.Formatter
import
androidx.annotation.RequiresApi
import
java.io.IOException
import
java.util.UUID
/**
*获取APP应用 缓存大小 数据大小 应用大小
* aidl的方式反射系统api
*/
class
AppSizeUtils
private
constructor
()
{
private
val
TAG
=
"AppSizeUtils"
/**
* 打印大小
*/
@RequiresApi
(
Build
.
VERSION_CODES
.
O
)
fun
printStorageStats
(
context
:
Context
,
packageName
:
String
,
storageStats
:
StorageStats
?)
{
if
(
storageStats
!=
null
)
{
val
cacheBytesF
=
Formatter
.
formatFileSize
(
context
,
storageStats
.
cacheBytes
)
val
dataBytesF
=
Formatter
.
formatFileSize
(
context
,
storageStats
.
cacheBytes
)
val
appBytesF
=
Formatter
.
formatFileSize
(
context
,
storageStats
.
cacheBytes
)
val
size
=
storageStats
.
cacheBytes
+
storageStats
.
dataBytes
+
storageStats
.
appBytes
val
total
=
Formatter
.
formatFileSize
(
context
,
size
)
val
log
=
"$packageName StorageStats cacheBytesF=$cacheBytesF dataBytesF=$dataBytesF appBytesF=$appBytesF total=$total"
LogEx
.
logDebug
(
TAG
,
log
)
}
}
fun
printPackageStats
(
context
:
Context
,
packageName
:
String
,
packageStats
:
PackageStats
?)
{
if
(
packageStats
!=
null
)
{
val
cacheSizeF
=
Formatter
.
formatFileSize
(
context
,
packageStats
.
cacheSize
)
val
dataSizeF
=
Formatter
.
formatFileSize
(
context
,
packageStats
.
dataSize
)
val
codeSizeF
=
Formatter
.
formatFileSize
(
context
,
packageStats
.
codeSize
)
val
size
=
packageStats
.
cacheSize
+
packageStats
.
dataSize
+
packageStats
.
codeSize
val
total
=
Formatter
.
formatFileSize
(
context
,
size
)
val
log
=
"$packageName PackageStats cacheSizeF=$cacheSizeF dataSizeF=$dataSizeF codeSizeF=$codeSizeF total=$total"
LogEx
.
logDebug
(
TAG
,
log
)
}
}
/**
* 获取应用的大小
*/
@RequiresApi
(
api
=
Build
.
VERSION_CODES
.
O
)
fun
getAppSizeO
(
context
:
Context
,
packageName
:
String
):
Long
{
val
storageStatsManager
=
context
.
getSystemService
(
Context
.
STORAGE_STATS_SERVICE
)
as
StorageStatsManager
val
storageManager
=
context
.
getSystemService
(
Context
.
STORAGE_SERVICE
)
as
StorageManager
//获取所有应用的StorageVolume列表
val
storageVolumes
=
storageManager
.
getStorageVolumes
()
for
(
item
in
storageVolumes
)
{
val
uuidStr
=
item
.
uuid
val
uuid
:
UUID
=
if
(
uuidStr
==
null
)
{
StorageManager
.
UUID_DEFAULT
}
else
{
UUID
.
fromString
(
uuidStr
)
}
val
uid
=
getUid
(
context
,
packageName
)
//通过包名获取uid
var
storageStats
:
StorageStats
?
=
null
try
{
storageStats
=
storageStatsManager
.
queryStatsForUid
(
uuid
,
uid
)
}
catch
(
e
:
IOException
)
{
e
.
printStackTrace
()
}
if
(
storageStats
!=
null
)
{
val
size
=
storageStats
.
cacheBytes
+
storageStats
.
dataBytes
+
storageStats
.
appBytes
printStorageStats
(
context
,
packageName
,
storageStats
)
return
size
}
}
return
0
}
/**
* 根据应用包名获取对应uid
*/
fun
getUid
(
context
:
Context
,
pakName
:
String
?):
Int
{
try
{
return
context
.
packageManager
.
getApplicationInfo
(
pakName
!!
,
PackageManager
.
GET_META_DATA
).
uid
}
catch
(
e
:
PackageManager
.
NameNotFoundException
)
{
e
.
printStackTrace
()
}
return
-
1
}
/**
* 获取应用大小8.0以下
*/
fun
getAppSize
(
context
:
Context
,
packageName
:
String
):
Long
{
var
size
=
0L
try
{
val
method
=
PackageManager
::
class
.
java
.
getMethod
(
"getPackageSizeInfo"
,
String
::
class
.
java
,
IPackageStatsObserver
::
class
.
java
)
// 调用 getPackageSizeInfo 方法,需要两个参数:1、需要检测的应用包名;2、回调
method
.
invoke
(
context
.
packageManager
,
packageName
,
object
:
IPackageStatsObserver
.
Stub
()
{
override
fun
onGetStatsCompleted
(
pStats
:
PackageStats
,
succeeded
:
Boolean
)
{
size
=
pStats
.
cacheSize
+
pStats
.
dataSize
+
pStats
.
codeSize
printPackageStats
(
context
,
packageName
,
pStats
)
}
})
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
}
return
size
}
companion
object
{
private
var
mApiUrl
:
AppSizeUtils
?
=
null
val
instance
:
AppSizeUtils
?
get
()
{
if
(
mApiUrl
==
null
)
{
synchronized
(
AppSizeUtils
::
class
.
java
)
{
if
(
mApiUrl
==
null
)
{
mApiUrl
=
AppSizeUtils
()
}
}
}
return
mApiUrl
}
}
}
app/src/main/java/com/test/easy/easycleanerjunk/helps/ComUtils.kt
deleted
100644 → 0
View file @
e5ae3fd0
package
com.test.easy.easycleanerjunk.helps
import
com.test.easy.easycleanerjunk.BuildConfig
import
com.test.easy.easycleanerjunk.bean.ConfigBean
import
com.test.easy.easycleanerjunk.helps.ads.AdmobUtils
import
com.test.easy.easycleanerjunk.utils.GsonUtils
import
com.test.easy.easycleanerjunk.utils.SPUtils
import
okhttp3.Call
import
okhttp3.Callback
import
okhttp3.OkHttpClient
import
okhttp3.Request
import
okhttp3.Response
import
okhttp3.logging.HttpLoggingInterceptor
import
java.io.IOException
object
ComUtils
{
private
val
TAG
=
"ComUtils"
val
localConfig
=
"{\"open_time_out\":15,\"inter_show_limit\":80,\"native_show_limit\":40,\"newuser_avoid_time\":0,\"all_push_interval\":60,\"loop_interval\":600,\"isNowPlayAd\":0,\"adClickCount\":15,\"nativeAdClickCount\":15,\"push_interval_11001\":30,\"push_interval_11004\":30,\"push_interval_11006\":30,\"push_interval_11008\":30,\"push_interval_11009\":30,\"push_interval_11010\":30,\"push_interval_12000\":30,\"push_interval_22001\":30,\"push_interval_22003\":30,\"push_interval_22002\":30,\"push_interval_22005\":30,\"push_interval_22004\":30,\"push_interval_22007\":30,\"push_circle_order\":[11001,11004,11006,11008,11009,11010,12000]}"
var
configSp
=
""
get
()
{
return
SPUtils
.
getInstance
().
getString
(
"configSp"
,
field
)
}
set
(
value
)
{
field
=
value
SPUtils
.
getInstance
().
put
(
"configSp"
,
value
,
true
)
}
fun
getLocalConfigBean
():
ConfigBean
{
val
json
=
localConfig
LogEx
.
logDebug
(
TAG
,
"Local json=$json"
)
val
configBean
=
GsonUtils
.
fromJson
(
json
,
ConfigBean
::
class
.
java
)
LogEx
.
logDebug
(
TAG
,
"Local configBean=$configBean"
)
return
configBean
}
fun
getSpConfigBean
():
ConfigBean
{
var
configBean
:
ConfigBean
?
=
null
try
{
configBean
=
GsonUtils
.
fromJson
(
configSp
,
ConfigBean
::
class
.
java
)
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
}
finally
{
if
(
configBean
==
null
)
{
LogEx
.
logDebug
(
TAG
,
"Sp configBean=$configBean"
)
configBean
=
getLocalConfigBean
()
}
}
AdmobUtils
.
adShowCount
=
configBean
.
inter_show_limit
AdmobUtils
.
nativeAdShowCount
=
configBean
.
native_show_limit
AdmobUtils
.
isNowPlayAd
=
configBean
.
isNowPlayAd
SPUtils
.
getInstance
().
put
(
"loading_page_time"
,
configBean
.
open_time_out
)
LogEx
.
logDebug
(
TAG
,
"Sp configBean=$configBean"
)
return
configBean
}
}
app/src/main/java/com/test/easy/easycleanerjunk/helps/NetWorkSpeed.kt
deleted
100644 → 0
View file @
e5ae3fd0
package
com.test.easy.easycleanerjunk.helps
import
android.net.TrafficStats
import
android.os.SystemClock
import
android.util.Log
object
NetWorkSpeed
{
var
monitorSwitch
=
false
@Volatile
var
preElapsedRealtime
:
Long
=
0
@Volatile
var
totalRxBytes
:
Long
=
0
@Volatile
var
totalTxBytes
:
Long
=
0
@Volatile
var
totalRxSpeed
:
Long
=
0
//下载
@Volatile
var
totalTxSpeed
:
Long
=
0
//上传
// 开启网速监控
fun
startMoritor
()
{
monitorSwitch
=
true
if
(
preElapsedRealtime
==
0L
)
{
preElapsedRealtime
=
SystemClock
.
elapsedRealtime
()
totalRxBytes
=
TrafficStats
.
getTotalRxBytes
()
totalTxBytes
=
TrafficStats
.
getTotalTxBytes
()
}
while
(
monitorSwitch
)
{
try
{
val
totalRxBytes
=
TrafficStats
.
getTotalRxBytes
()
val
totalTxBytes
=
TrafficStats
.
getTotalTxBytes
()
// SystemClock.elapsedRealtime() 的计时起点是系统启动时间,即在开机后第一次调用该方法时返回0. 此处使用 SystemClock.elapsedRealtime() 来计算时间间隔
val
elapsedRealtime
=
SystemClock
.
elapsedRealtime
()
val
j10
=
(
elapsedRealtime
-
preElapsedRealtime
)
/
1000
val
totalTxSpeed
=
((
totalTxBytes
-
this
.
totalTxBytes
)
/
j10
)
val
totalRxSpeed
=
((
totalRxBytes
-
this
.
totalRxBytes
)
/
j10
)
this
.
totalRxBytes
=
totalRxBytes
this
.
totalTxBytes
=
totalTxBytes
this
.
totalTxSpeed
=
totalTxSpeed
this
.
totalRxSpeed
=
totalRxSpeed
preElapsedRealtime
=
elapsedRealtime
Log
.
i
(
"networkSpeedMonitor"
,
"Tx: $totalTxSpeed, Rx: $totalRxSpeed"
)
}
catch
(
e10
:
Exception
)
{
}
waitAMoment
(
4000L
)
}
}
// 停止网速监控
fun
stopMonitor
()
{
monitorSwitch
=
false
}
fun
waitAMoment
(
j10
:
Long
)
{
try
{
Thread
.
sleep
(
j10
)
}
catch
(
e10
:
InterruptedException
)
{
}
}
}
\ No newline at end of file
app/src/main/java/com/test/easy/easycleanerjunk/helps/NetworkStatsHelper.java
deleted
100644 → 0
View file @
e5ae3fd0
package
com
.
test
.
easy
.
easycleanerjunk
.
helps
;
import
android.annotation.SuppressLint
;
import
android.app.usage.NetworkStats
;
import
android.app.usage.NetworkStatsManager
;
import
android.content.Context
;
import
android.content.pm.PackageInfo
;
import
android.content.pm.PackageManager
;
import
android.net.ConnectivityManager
;
import
android.os.RemoteException
;
import
android.telephony.TelephonyManager
;
import
java.util.Calendar
;
public
class
NetworkStatsHelper
{
NetworkStatsManager
networkStatsManager
;
int
packageUid
;
public
NetworkStatsHelper
(
NetworkStatsManager
networkStatsManager
)
{
this
.
networkStatsManager
=
networkStatsManager
;
}
/**
* 本机使用的 wifi 总流量
*/
public
long
getAllBytesWifi
()
{
NetworkStats
.
Bucket
bucket
;
try
{
bucket
=
networkStatsManager
.
querySummaryForDevice
(
ConnectivityManager
.
TYPE_WIFI
,
null
,
getTimesMonthmorning
(),
System
.
currentTimeMillis
());
}
catch
(
RemoteException
e
)
{
return
-
1
;
}
//这里可以区分发送和接收
return
bucket
.
getTxBytes
()
+
bucket
.
getRxBytes
();
}
/**
* 本机使用的 mobile 总流量
*/
public
long
getAllBytesMobile
(
Context
context
)
{
NetworkStats
.
Bucket
bucket
;
try
{
bucket
=
networkStatsManager
.
querySummaryForDevice
(
ConnectivityManager
.
TYPE_MOBILE
,
getSubscriberId
(
context
,
ConnectivityManager
.
TYPE_MOBILE
),
0
,
System
.
currentTimeMillis
());
}
catch
(
RemoteException
e
)
{
return
-
1
;
}
//这里可以区分发送和接收
return
bucket
.
getTxBytes
()
+
bucket
.
getRxBytes
();
}
//这里要用到
@SuppressLint
({
"HardwareIds"
,
"MissingPermission"
})
private
String
getSubscriberId
(
Context
context
,
int
networkType
)
{
if
(
ConnectivityManager
.
TYPE_MOBILE
==
networkType
)
{
TelephonyManager
tm
=
(
TelephonyManager
)
context
.
getSystemService
(
Context
.
TELEPHONY_SERVICE
);
return
tm
.
getSubscriberId
();
}
return
""
;
}
/**
* 获取指定应用 wifi 发送的当天总流量
*
* @param packageUid 应用的uid
* @return
*/
public
long
getPackageTxDayBytesWifi
(
int
packageUid
)
{
NetworkStats
networkStats
=
null
;
networkStats
=
networkStatsManager
.
queryDetailsForUid
(
ConnectivityManager
.
TYPE_WIFI
,
""
,
getTimesmorning
(),
System
.
currentTimeMillis
(),
packageUid
);
NetworkStats
.
Bucket
bucket
=
new
NetworkStats
.
Bucket
();
networkStats
.
getNextBucket
(
bucket
);
return
bucket
.
getTxBytes
();
}
/**
* 获取当天的零点时间
*
* @return
*/
public
static
long
getTimesmorning
()
{
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
set
(
Calendar
.
HOUR_OF_DAY
,
0
);
cal
.
set
(
Calendar
.
SECOND
,
0
);
cal
.
set
(
Calendar
.
MINUTE
,
0
);
cal
.
set
(
Calendar
.
MILLISECOND
,
0
);
return
(
cal
.
getTimeInMillis
());
}
//获得本月第一天0点时间
public
static
long
getTimesMonthmorning
()
{
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
set
(
cal
.
get
(
Calendar
.
YEAR
),
cal
.
get
(
Calendar
.
MONDAY
),
cal
.
get
(
Calendar
.
DAY_OF_MONTH
),
0
,
0
,
0
);
cal
.
set
(
Calendar
.
DAY_OF_MONTH
,
cal
.
getActualMinimum
(
Calendar
.
DAY_OF_MONTH
));
return
(
cal
.
getTimeInMillis
());
}
public
static
Long
getNeedTime
(
int
i
)
{
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
set
(
11
,
0
);
calendar
.
set
(
12
,
0
);
calendar
.
set
(
13
,
0
);
calendar
.
set
(
14
,
0
);
return
calendar
.
getTimeInMillis
()
-
((
i
-
1
)
*
86400000L
);
}
/**
* 根据包名获取uid
*
* @param context 上下文
* @param packageName 包名
*/
public
static
int
getUidByPackageName
(
Context
context
,
String
packageName
)
{
int
uid
=
-
1
;
PackageManager
packageManager
=
context
.
getPackageManager
();
try
{
PackageInfo
packageInfo
=
packageManager
.
getPackageInfo
(
packageName
,
PackageManager
.
GET_META_DATA
);
uid
=
packageInfo
.
applicationInfo
.
uid
;
}
catch
(
PackageManager
.
NameNotFoundException
e
)
{
e
.
printStackTrace
();
}
return
uid
;
}
public
static
Boolean
canStop
(
Context
context
,
String
packageName
)
{
boolean
z11
=
false
;
if
(
packageName
!=
null
&&
!
packageName
.
contains
(
"com.android.vending"
)
&&
!
packageName
.
toLowerCase
().
contains
(
"google"
)
&&
!
isSystemApp
(
context
,
packageName
))
{
z11
=
true
;
}
else
{
z11
=
false
;
}
return
z11
;
}
public
static
boolean
isSystemApp
(
Context
context
,
String
str
)
{
try
{
if
((
context
.
getApplicationContext
().
getPackageManager
().
getApplicationInfo
(
str
,
0
).
flags
&
129
)
==
0
)
{
return
false
;
}
return
true
;
}
catch
(
PackageManager
.
NameNotFoundException
unused
)
{
return
false
;
}
}
}
app/src/main/java/com/test/easy/easycleanerjunk/helps/recentapp/LaunchTimeStat.kt
deleted
100644 → 0
View file @
e5ae3fd0
package
com.test.easy.easycleanerjunk.helps.recentapp
import
android.app.usage.UsageEvents
import
android.app.usage.UsageStatsManager
import
android.content.Context
import
java.util.LinkedList
class
LaunchTimeStat
(
val
beginTs
:
Long
,
val
ends
:
Long
)
{
var
a
=
0
fun
run
(
context
:
Context
):
HashMap
<
String
,
MutableList
<
UsageEvents
.
Event
>>
{
val
usageStatsManager
=
context
.
getSystemService
(
Context
.
USAGE_STATS_SERVICE
)
as
UsageStatsManager
val
hashMap
=
HashMap
<
String
,
MutableList
<
UsageEvents
.
Event
>>()
val
linkedList
=
LinkedList
<
LinkedList
<
UsageEvents
.
Event
>>()
val
queryEvents
=
usageStatsManager
.
queryEvents
(
beginTs
,
ends
)
var
event
:
UsageEvents
.
Event
?
=
null
while
(
queryEvents
!=
null
&&
queryEvents
.
hasNextEvent
())
{
val
event2
=
UsageEvents
.
Event
()
if
(
queryEvents
.
getNextEvent
(
event2
)
&&
event2
.
eventType
!=
23
&&
event2
.
eventType
!=
11
)
{
if
(!
linkedList
.
isEmpty
()
&&
linkedList
.
getLast
().
getLast
().
packageName
==
event2
.
packageName
)
{
linkedList
.
getLast
().
addLast
(
event2
)
}
else
{
val
linkedList2
=
LinkedList
<
UsageEvents
.
Event
>()
linkedList2
.
addLast
(
event2
)
linkedList
.
addLast
(
linkedList2
)
}
if
((
event
==
null
||
event
.
packageName
!=
event2
.
packageName
)
&&
(
event
==
null
||
event
.
eventType
==
2
)
&&
event2
.
eventType
==
1
)
{
var
list
=
hashMap
[
event2
.
packageName
]
if
(
list
==
null
)
{
list
=
ArrayList
()
}
list
.
add
(
event2
)
hashMap
[
event2
.
packageName
]
=
list
}
event
=
event2
}
}
return
hashMap
}
companion
object
{
fun
c
(
context
:
Context
,
str
:
String
?):
String
?
{
val
packageManager
=
context
.
packageManager
return
try
{
packageManager
.
getApplicationLabel
(
packageManager
.
getApplicationInfo
(
str
!!
,
0
)).
toString
()
}
catch
(
e10
:
Exception
)
{
null
}
}
}
}
\ No newline at end of file
app/src/main/java/com/test/easy/easycleanerjunk/helps/recentapp/RecentBean.kt
deleted
100644 → 0
View file @
e5ae3fd0
package
com.test.easy.easycleanerjunk.helps.recentapp
class
RecentBean
(
val
name
:
String
,
val
packageName
:
String
,
var
c
:
Long
)
\ No newline at end of file
app/src/main/java/com/test/easy/easycleanerjunk/helps/recentapp/ScreenTimeStat.kt
deleted
100644 → 0
View file @
e5ae3fd0
package
com.test.easy.easycleanerjunk.helps.recentapp
import
android.app.usage.UsageEvents
import
android.app.usage.UsageStatsManager
import
android.content.Context
import
java.util.LinkedList
class
ScreenTimeStat
(
val
beginTs
:
Long
,
val
endTs
:
Long
)
{
private
val
TAG
=
"ScreenTimeStat"
fun
run
(
context
:
Context
):
Map
<
String
,
RecentBean
>
{
var
obj
:
UsageEvents
.
Event
?
var
obj2
:
UsageEvents
.
Event
?
val
usageStatsManager
=
context
.
getSystemService
(
Context
.
USAGE_STATS_SERVICE
)
as
UsageStatsManager
val
hashMap
=
HashMap
<
String
,
RecentBean
>()
var
j12
:
Long
=
0
if
(
endTs
-
beginTs
>
259200000
)
{
val
queryUsageStats
=
usageStatsManager
.
queryUsageStats
(
0
,
beginTs
,
endTs
)
if
(
queryUsageStats
!=
null
)
{
for
(
usageStats
in
queryUsageStats
)
{
if
(
usageStats
.
totalTimeInForeground
>
j12
&&
usageStats
.
lastTimeUsed
>
beginTs
)
{
val
bVar
=
hashMap
[
usageStats
.
packageName
]
if
(
bVar
==
null
)
{
hashMap
[
usageStats
.
packageName
]
=
RecentBean
(
getAppName
(
context
,
usageStats
.
packageName
),
usageStats
.
packageName
,
usageStats
.
totalTimeInForeground
)
}
else
{
bVar
.
c
+=
usageStats
.
totalTimeInForeground
}
}
j12
=
0
}
}
}
else
{
val
linkedList
=
LinkedList
<
LinkedList
<
UsageEvents
.
Event
>>()
val
queryEvents
=
usageStatsManager
.
queryEvents
(
beginTs
,
endTs
)
while
(
queryEvents
!=
null
&&
queryEvents
.
hasNextEvent
())
{
val
event
=
UsageEvents
.
Event
()
if
(
queryEvents
.
getNextEvent
(
event
)
&&
event
.
eventType
!=
23
&&
event
.
eventType
!=
11
)
{
if
(!
linkedList
.
isEmpty
()
&&
linkedList
.
getLast
().
getLast
().
packageName
==
event
.
packageName
)
{
linkedList
.
getLast
().
addLast
(
event
)
}
else
{
val
linkedList2
=
LinkedList
<
UsageEvents
.
Event
>()
linkedList2
.
addLast
(
event
)
linkedList
.
addLast
(
linkedList2
)
}
}
}
for
(
linkedList3
in
linkedList
)
{
val
packageName
=
linkedList3
.
getFirst
().
packageName
val
it2
:
Iterator
<
UsageEvents
.
Event
>
=
linkedList3
.
iterator
()
while
(
true
)
{
obj
=
null
if
(
it2
.
hasNext
())
{
obj2
=
it2
.
next
()
if
(
obj2
.
eventType
==
1
)
{
break
}
}
else
{
obj2
=
null
break
}
}
val
event2
=
obj2
val
listIterator
:
ListIterator
<
UsageEvents
.
Event
>
=
linkedList3
.
listIterator
(
linkedList3
.
size
)
while
(
true
)
{
if
(
listIterator
.
hasPrevious
())
{
val
previous
=
listIterator
.
previous
()
if
(
previous
.
eventType
==
2
)
{
obj
=
previous
}
}
else
{
break
}
}
val
event3
=
obj
if
(
event2
!=
null
&&
event3
!=
null
&&
event2
.
timeStamp
<
event3
.
timeStamp
)
{
var
bVar2
=
hashMap
[
packageName
]
if
(
bVar2
==
null
)
{
bVar2
=
RecentBean
(
getAppName
(
context
,
packageName
),
packageName
,
0L
)
}
bVar2
.
c
+=
event3
.
timeStamp
-
event2
.
timeStamp
hashMap
[
packageName
]
=
bVar2
}
}
}
// hashMap.forEach { (key, value) ->
// LogEx.logDebug(TAG, "key=$key value=$value")
// }
return
hashMap
}
companion
object
{
fun
getAppName
(
context
:
Context
,
str
:
String
?):
String
{
val
packageManager
=
context
.
packageManager
return
try
{
packageManager
.
getApplicationLabel
(
packageManager
.
getApplicationInfo
(
str
!!
,
0
)).
toString
()
}
catch
(
e10
:
Exception
)
{
""
}
}
}
}
\ No newline at end of file
app/src/main/java/com/test/easy/easycleanerjunk/service/FlashlightService.kt
View file @
9a31a1ee
...
@@ -15,7 +15,6 @@ class FlashlightService : Service() {
...
@@ -15,7 +15,6 @@ class FlashlightService : Service() {
private
var
flashlightOn
=
false
private
var
flashlightOn
=
false
override
fun
onCreate
()
{
override
fun
onCreate
()
{
super
.
onCreate
()
super
.
onCreate
()
Log
.
e
(
"MXL"
,
"SerciveonCreate: "
)
cameraManager
=
getSystemService
(
Context
.
CAMERA_SERVICE
)
as
CameraManager
?
cameraManager
=
getSystemService
(
Context
.
CAMERA_SERVICE
)
as
CameraManager
?
}
}
...
...
app/src/main/java/com/test/easy/easycleanerjunk/utils/AppUtils.java
deleted
100644 → 0
View file @
e5ae3fd0
package
com
.
test
.
easy
.
easycleanerjunk
.
utils
;
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.drawable.Drawable
;
import
android.net.Uri
;
import
android.provider.Settings
;
import
android.util.Log
;
import
com.test.easy.easycleanerjunk.MyApplication
;
import
com.test.easy.easycleanerjunk.bean.AppInfo
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
AppUtils
{
public
static
List
<
AppInfo
>
getAppsInfo
()
{
List
<
AppInfo
>
list
=
new
ArrayList
<>();
PackageManager
pm
=
MyApplication
.
context
.
getPackageManager
();
if
(
pm
==
null
)
return
list
;
List
<
PackageInfo
>
installedPackages
=
pm
.
getInstalledPackages
(
0
);
for
(
PackageInfo
pi
:
installedPackages
)
{
AppInfo
ai
=
getBean
(
pm
,
pi
);
list
.
add
(
ai
);
}
return
list
;
}
private
static
AppInfo
getBean
(
final
PackageManager
pm
,
final
PackageInfo
pi
)
{
if
(
pi
==
null
)
return
null
;
String
versionName
=
pi
.
versionName
;
int
versionCode
=
pi
.
versionCode
;
String
packageName
=
pi
.
packageName
;
ApplicationInfo
ai
=
pi
.
applicationInfo
;
if
(
ai
==
null
)
{
return
new
AppInfo
(
packageName
,
""
,
null
,
""
,
versionName
,
versionCode
,
-
1
,
-
1
,
false
);
}
String
name
=
ai
.
loadLabel
(
pm
).
toString
();
Drawable
icon
=
ai
.
loadIcon
(
pm
);
String
packagePath
=
ai
.
sourceDir
;
int
minSdkVersion
=
-
1
;
minSdkVersion
=
ai
.
minSdkVersion
;
int
targetSdkVersion
=
ai
.
targetSdkVersion
;
boolean
isSystem
=
(
ApplicationInfo
.
FLAG_SYSTEM
&
ai
.
flags
)
!=
0
;
return
new
AppInfo
(
packageName
,
name
,
icon
,
packagePath
,
versionName
,
versionCode
,
minSdkVersion
,
targetSdkVersion
,
isSystem
);
}
public
static
void
jumpToAppSettings
(
Context
context
,
String
packageName
)
{
Intent
intent
=
new
Intent
();
intent
.
setAction
(
Settings
.
ACTION_APPLICATION_DETAILS_SETTINGS
);
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
Uri
uri
=
Uri
.
fromParts
(
"package"
,
packageName
,
null
);
intent
.
setData
(
uri
);
context
.
startActivity
(
intent
);
}
public
static
String
getAppVersionName
(
Context
context
,
String
packageName
)
{
PackageManager
pm
=
context
.
getPackageManager
();
try
{
PackageInfo
pi
=
pm
.
getPackageInfo
(
packageName
,
0
);
return
pi
.
versionName
;
}
catch
(
PackageManager
.
NameNotFoundException
e
)
{
Log
.
e
(
"TAG"
,
"getAppVersionName: "
,
e
);
}
return
null
;
}
public
static
int
getAppVersionCode
(
Context
context
,
String
packageName
)
{
PackageManager
pm
=
context
.
getPackageManager
();
try
{
PackageInfo
pi
=
pm
.
getPackageInfo
(
packageName
,
0
);
return
pi
.
versionCode
;
}
catch
(
PackageManager
.
NameNotFoundException
e
)
{
Log
.
e
(
"TAG"
,
"getAppVersionCode: "
,
e
);
}
return
-
1
;
}
}
app/src/main/java/com/test/easy/easycleanerjunk/view/AdPreparationPop.kt
deleted
100644 → 0
View file @
e5ae3fd0
package
com.test.easy.easycleanerjunk.view
import
android.app.Activity
import
android.view.Gravity
import
android.view.ViewGroup
import
android.widget.PopupWindow
import
androidx.core.view.updatePadding
import
com.test.easy.easycleanerjunk.databinding.PopupLayoutAdPreparBinding
import
com.test.easy.easycleanerjunk.utils.BarUtils
import
kotlin.random.Random
class
AdPreparationPop
(
private
val
activity
:
Activity
,
val
onDismiss
:
()
->
Unit
)
:
PopupWindow
()
{
init
{
width
=
ViewGroup
.
LayoutParams
.
MATCH_PARENT
height
=
ViewGroup
.
LayoutParams
.
MATCH_PARENT
isOutsideTouchable
=
false
isFocusable
=
true
isClippingEnabled
=
false
}
private
val
binding
by
lazy
{
PopupLayoutAdPreparBinding
.
inflate
(
activity
.
layoutInflater
)
}
fun
show
()
{
contentView
=
binding
.
root
activity
.
window
.
decorView
.
post
{
binding
.
root
.
updatePadding
(
top
=
BarUtils
.
getStatusBarHeight
())
BarUtils
.
setStatusBarLightMode
(
activity
,
false
)
showAtLocation
(
activity
.
window
.
decorView
,
Gravity
.
CENTER
,
0
,
0
)
}
binding
.
root
.
postDelayed
({
dismiss
()
onDismiss
.
invoke
()
},
Random
.
nextLong
(
2500
,
4000
))
}
override
fun
dismiss
()
{
super
.
dismiss
()
BarUtils
.
setStatusBarLightMode
(
activity
,
true
)
}
}
\ No newline at end of file
app/src/main/java/com/test/easy/easycleanerjunk/view/AppDetailDialog.kt
deleted
100644 → 0
View file @
e5ae3fd0
package
com.test.easy.easycleanerjunk.view
import
android.annotation.SuppressLint
import
android.app.Activity
import
android.content.Context
import
android.content.Intent
import
android.content.pm.PackageManager
import
android.net.Uri
import
android.os.Build
import
android.provider.Settings
import
android.text.format.Formatter
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
com.google.android.material.bottomsheet.BottomSheetDialog
import
com.test.easy.easycleanerjunk.R
import
com.test.easy.easycleanerjunk.bean.AppBean
import
com.test.easy.easycleanerjunk.bean.AppBean.Companion.appBeanGson
import
com.test.easy.easycleanerjunk.databinding.DialogAppDetailBinding
import
com.test.easy.easycleanerjunk.helps.ActivityLauncher
import
com.test.easy.easycleanerjunk.helps.BaseApplication
import
com.test.easy.easycleanerjunk.utils.AppUtils
import
java.text.SimpleDateFormat
object
AppDetailDialog
{
private
val
TAG
=
"AppDetailDialog"
@SuppressLint
(
"SimpleDateFormat"
)
fun
Activity
.
showAppDetailDialog
(
appBean
:
AppBean
,
launcher
:
ActivityLauncher
,
unInstallAction
:
((
unInstalled
:
Boolean
)
->
Unit
)?
=
null
)
{
val
dialog
=
BottomSheetDialog
(
this
)
val
binding
=
DialogAppDetailBinding
.
inflate
(
LayoutInflater
.
from
(
this
))
dialog
.
setContentView
(
binding
.
root
)
dialog
.
setCanceledOnTouchOutside
(
true
)
dialog
.
show
()
binding
.
tvAppName
.
text
=
appBean
.
appName
binding
.
tvPkg
.
text
=
appBean
.
pkg
binding
.
ivIcon
.
setImageDrawable
(
appBean
.
icIcon
)
binding
.
tvVersion
.
text
=
AppUtils
.
getAppVersionName
(
BaseApplication
.
context
,
appBean
.
pkg
)
val
size
=
Formatter
.
formatFileSize
(
this
,
appBean
.
appSize
)
binding
.
tvSize
.
text
=
size
val
dateFormat
=
SimpleDateFormat
(
"MM-dd"
)
val
installTime
=
dateFormat
.
format
(
appBean
.
installTime
)
binding
.
tvInstall
.
text
=
installTime
//应用来源逻辑
try
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
R
)
{
val
installSourceInfo
=
packageManager
.
getInstallSourceInfo
(
appBean
.
pkg
)
// binding.tvInstaller.text = installSourceInfo.installingPackageName
if
(
"com.android.vending"
==
installSourceInfo
.
installingPackageName
)
{
binding
.
tvInstaller
.
text
=
getString
(
R
.
string
.
google_play
)
}
else
{
binding
.
llInstaller
.
visibility
=
View
.
GONE
}
}
else
{
binding
.
llInstaller
.
visibility
=
View
.
GONE
}
}
catch
(
e
:
PackageManager
.
NameNotFoundException
)
{
e
.
printStackTrace
()
}
//修改dialog的尺寸
val
lp
=
dialog
.
window
?.
attributes
lp
?.
width
=
ViewGroup
.
LayoutParams
.
MATCH_PARENT
lp
?.
height
=
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
dialog
.
window
?.
attributes
=
lp
dialog
.
window
?.
setBackgroundDrawableResource
(
android
.
R
.
color
.
transparent
)
binding
.
tvDetail
.
setOnClickListener
{
val
intent
=
Intent
()
intent
.
setAction
(
Settings
.
ACTION_APPLICATION_DETAILS_SETTINGS
)
intent
.
setData
(
Uri
.
parse
(
"package:"
+
appBean
.
pkg
))
startActivity
(
intent
)
dialog
.
dismiss
()
}
binding
.
tvShare
.
setOnClickListener
{
dialog
.
dismiss
()
val
uri
=
"https://play.google.com/store/apps/details?id=${appBean.pkg}&referrer=share"
//浏览器
val
intentView
=
Intent
(
Intent
.
ACTION_VIEW
)
intentView
.
setData
(
Uri
.
parse
(
uri
))
// 检查是否有可以处理Intent的应用
if
(
intentView
.
resolveActivity
(
packageManager
)
!=
null
)
{
// 启动Intent,打开浏览器
startActivity
(
intentView
)
}
else
{
//分享文本
val
intent
=
Intent
()
intent
.
setAction
(
Intent
.
ACTION_SEND
)
intent
.
putExtra
(
Intent
.
EXTRA_TEXT
,
uri
)
intent
.
setType
(
"text/plain"
)
startActivity
(
intent
)
}
}
binding
.
tvUninstall
.
setOnClickListener
{
dialog
.
dismiss
()
val
intent
=
Intent
(
Intent
.
ACTION_DELETE
,
Uri
.
parse
(
"package:${appBean.pkg}"
))
launcher
.
launch
(
intent
)
{
unInstallAction
?.
invoke
(!
isInstalled
(
this
,
appBean
.
pkg
))
}
}
}
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
}
}
}
\ No newline at end of file
app/src/main/java/com/test/easy/easycleanerjunk/view/NotificationOpenDialog.kt
deleted
100644 → 0
View file @
e5ae3fd0
package
com.test.easy.easycleanerjunk.view
import
android.content.Context
import
android.view.LayoutInflater
import
androidx.appcompat.app.AlertDialog
import
com.test.easy.easycleanerjunk.databinding.DialogNotificationOpenAlertBinding
object
NotificationOpenDialog
{
fun
Context
.
showNotificationOpenDialog
()
{
val
binding
=
DialogNotificationOpenAlertBinding
.
inflate
(
LayoutInflater
.
from
(
this
))
val
dialog
=
AlertDialog
.
Builder
(
this
).
setView
(
binding
.
root
).
create
()
dialog
.
setContentView
(
binding
.
root
)
dialog
.
setCanceledOnTouchOutside
(
true
)
dialog
.
show
()
}
}
\ No newline at end of file
app/src/main/java/com/test/easy/easycleanerjunk/view/PermissionFilterDialog.kt
deleted
100644 → 0
View file @
e5ae3fd0
package
com.test.easy.easycleanerjunk.view
import
android.content.Context
import
android.view.LayoutInflater
import
android.view.ViewGroup
import
androidx.appcompat.app.AlertDialog
import
com.test.easy.easycleanerjunk.R
import
com.test.easy.easycleanerjunk.databinding.DialogPermissionFilterBinding
object
PermissionFilterDialog
{
fun
Context
.
showPermissionFilterDialog
(
allClick
:
()
->
Unit
,
authorizedClick
:
()
->
Unit
,
)
{
val
binding
=
DialogPermissionFilterBinding
.
inflate
(
LayoutInflater
.
from
(
this
))
val
dialog
=
AlertDialog
.
Builder
(
this
).
setView
(
binding
.
root
).
create
()
dialog
.
setContentView
(
binding
.
root
)
dialog
.
setCanceledOnTouchOutside
(
true
)
dialog
.
show
()
//修改dialog的尺寸
val
lp
=
dialog
.
window
?.
attributes
lp
?.
width
=
resources
.
getDimensionPixelOffset
(
R
.
dimen
.
dp_360
)
lp
?.
height
=
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
dialog
.
window
?.
attributes
=
lp
dialog
.
window
?.
setBackgroundDrawableResource
(
android
.
R
.
color
.
transparent
)
binding
.
tvAll
.
setOnClickListener
{
dialog
.
dismiss
()
allClick
.
invoke
()
}
binding
.
tvAuthorized
.
setOnClickListener
{
dialog
.
dismiss
()
authorizedClick
.
invoke
()
}
}
}
\ No newline at end of file
app/src/main/java/com/test/easy/easycleanerjunk/view/TimeSelectDialog.kt
deleted
100644 → 0
View file @
e5ae3fd0
package
com.test.easy.easycleanerjunk.view
import
android.annotation.SuppressLint
import
android.content.Context
import
android.view.LayoutInflater
import
android.view.ViewGroup
import
com.google.android.material.bottomsheet.BottomSheetDialog
import
com.test.easy.easycleanerjunk.databinding.DialogTimeSelectBinding
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
java.text.SimpleDateFormat
import
kotlin.time.Duration.Companion.days
import
kotlin.time.DurationUnit
object
TimeSelectDialog
{
@SuppressLint
(
"SimpleDateFormat"
,
"SetTextI18n"
)
fun
Context
.
showTimeSelectDialog
(
click
:
(
mode
:
Int
)
->
Unit
)
{
val
dialog
=
BottomSheetDialog
(
this
)
val
binding
=
DialogTimeSelectBinding
.
inflate
(
LayoutInflater
.
from
(
this
))
dialog
.
setContentView
(
binding
.
root
)
dialog
.
setCanceledOnTouchOutside
(
true
)
dialog
.
show
()
//修改dialog的尺寸
val
lp
=
dialog
.
window
?.
attributes
lp
?.
width
=
ViewGroup
.
LayoutParams
.
MATCH_PARENT
lp
?.
height
=
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
dialog
.
window
?.
attributes
=
lp
dialog
.
window
?.
setBackgroundDrawableResource
(
android
.
R
.
color
.
transparent
)
val
simpleDateFormat2
=
SimpleDateFormat
(
"(yyyy/MM/dd)"
)
binding
.
tvToday
.
text
=
"Today "
+
simpleDateFormat2
.
format
(
System
.
currentTimeMillis
())
binding
.
tvYesterday
.
text
=
"Yesterday "
+
simpleDateFormat2
.
format
(
System
.
currentTimeMillis
()
-
1
.
days
.
toLong
(
DurationUnit
.
MILLISECONDS
))
binding
.
tv60
.
setOnClickListener
{
dialog
.
dismiss
()
click
.
invoke
(
PAST_60_MINUS_QUERY
)
}
binding
.
tvToday
.
setOnClickListener
{
dialog
.
dismiss
()
click
.
invoke
(
TODAY_QUERY
)
}
binding
.
tvYesterday
.
setOnClickListener
{
dialog
.
dismiss
()
click
.
invoke
(
YESTERDAY_QUERY
)
}
binding
.
tv7Days
.
setOnClickListener
{
dialog
.
dismiss
()
click
.
invoke
(
SEVEN_DAYS_QUERY
)
}
}
}
\ No newline at end of file
app/src/main/res/layout/activity_compression_photo_list.xml
View file @
9a31a1ee
...
@@ -50,6 +50,19 @@
...
@@ -50,6 +50,19 @@
android:layout_marginLeft=
"14dp"
android:layout_marginLeft=
"14dp"
android:layout_marginRight=
"14dp"
/>
android:layout_marginRight=
"14dp"
/>
<TextView
android:id=
"@+id/no_data"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_centerHorizontal=
"true"
android:drawableTop=
"@mipmap/sada"
android:layout_centerVertical=
"true"
android:drawablePadding=
"10dp"
android:visibility=
"gone"
android:gravity=
"center"
android:text=
"No photos found"
android:textColor=
"#666666"
android:textSize=
"13sp"
/>
<LinearLayout
<LinearLayout
android:id=
"@+id/btn_continue_layout"
android:id=
"@+id/btn_continue_layout"
...
...
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