Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
android_cleaner
Project
Project
Details
Activity
Releases
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
android
android_cleaner
Commits
622a8d13
Commit
622a8d13
authored
Sep 14, 2020
by
jyx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
压缩包、安装包清理
parent
3435ddb3
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
615 additions
and
142 deletions
+615
-142
AndroidManifest.xml
cleaner/app/src/main/AndroidManifest.xml
+16
-9
AlbumCleanAdapter.kt
...com/mints/cleaner/adapter/albumClean/AlbumCleanAdapter.kt
+1
-1
HomeAdapter.kt
...c/main/java/com/mints/cleaner/adapter/home/HomeAdapter.kt
+9
-3
HomeMultiItem.kt
...main/java/com/mints/cleaner/adapter/home/HomeMultiItem.kt
+9
-1
FileBean.kt
...pp/src/main/java/com/mints/cleaner/model/bean/FileBean.kt
+0
-1
MainRepository.kt
...java/com/mints/cleaner/model/repository/MainRepository.kt
+23
-5
HomeFragment.kt
...p/src/main/java/com/mints/cleaner/ui/home/HomeFragment.kt
+18
-12
ApkUtils.kt
...src/main/java/com/mints/cleaner/ui/multiClean/ApkUtils.kt
+91
-2
FileScanModel.kt
...ain/java/com/mints/cleaner/ui/multiClean/FileScanModel.kt
+32
-4
MultiCleanActivity.kt
...ava/com/mints/cleaner/ui/multiClean/MultiCleanActivity.kt
+369
-87
MultiCleanModel.kt
...n/java/com/mints/cleaner/ui/multiClean/MultiCleanModel.kt
+0
-6
FileUtils.kt
...ner/app/src/main/java/com/mints/cleaner/util/FileUtils.kt
+13
-1
IntentUtils.kt
...r/app/src/main/java/com/mints/cleaner/util/IntentUtils.kt
+22
-0
item_clean_bottom.xml
cleaner/app/src/main/res/layout/item_clean_bottom.xml
+10
-10
strings.xml
cleaner/app/src/main/res/values/strings.xml
+2
-0
No files found.
cleaner/app/src/main/AndroidManifest.xml
View file @
622a8d13
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
<uses-permission
android:name=
"android.permission.WRITE_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.WRITE_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.REQUEST_INSTALL_PACKAGES"
/>
<application
<application
android:name=
".App"
android:name=
".App"
...
@@ -12,10 +13,11 @@
...
@@ -12,10 +13,11 @@
android:icon=
"@mipmap/ic_launcher"
android:icon=
"@mipmap/ic_launcher"
android:label=
"@string/app_name"
android:label=
"@string/app_name"
android:networkSecurityConfig=
"@xml/network_security_config"
android:networkSecurityConfig=
"@xml/network_security_config"
android:roundIcon=
"@mipmap/ic_launcher_round"
android:requestLegacyExternalStorage=
"true"
android:requestLegacyExternalStorage=
"true"
android:roundIcon=
"@mipmap/ic_launcher_round"
android:supportsRtl=
"true"
android:supportsRtl=
"true"
android:theme=
"@style/AppTheme"
>
android:theme=
"@style/AppTheme"
>
<activity
android:name=
".ui.setting.SettingActivity"
></activity>
<activity
android:name=
".ui.setting.SettingActivity"
></activity>
<activity
android:name=
".ui.albumClean.AlbumCleanActivity"
/>
<activity
android:name=
".ui.albumClean.AlbumCleanActivity"
/>
...
@@ -23,15 +25,9 @@
...
@@ -23,15 +25,9 @@
android:name=
".ui.multiClean.MultiCleanActivity"
android:name=
".ui.multiClean.MultiCleanActivity"
android:configChanges=
"orientation|keyboardHidden|screenSize"
android:configChanges=
"orientation|keyboardHidden|screenSize"
android:excludeFromRecents=
"true"
android:excludeFromRecents=
"true"
android:noHistory=
"true"
android:launchMode=
"singleTop"
android:launchMode=
"singleTop"
android:screenOrientation=
"portrait"
>
android:noHistory=
"true"
<intent-filter>
android:screenOrientation=
"portrait"
></activity>
<action
android:name=
"android.intent.action.MAIN"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
<!-- 屏幕适配 -->
<!-- 屏幕适配 -->
<meta-data
<meta-data
...
@@ -46,6 +42,16 @@
...
@@ -46,6 +42,16 @@
android:launchMode=
"singleTop"
android:launchMode=
"singleTop"
android:theme=
"@style/CustomerTransparentTheme"
/>
android:theme=
"@style/CustomerTransparentTheme"
/>
<activity
android:name=
".ui.NavigationActivity"
android:launchMode=
"singleTask"
>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
<provider
<provider
android:name=
"androidx.core.content.FileProvider"
android:name=
"androidx.core.content.FileProvider"
...
@@ -64,6 +70,7 @@
...
@@ -64,6 +70,7 @@
<service
<service
android:name=
".service.keep.KeepLiveManager$GrayInnerService"
android:name=
".service.keep.KeepLiveManager$GrayInnerService"
android:process=
":screen"
/>
android:process=
":screen"
/>
<activity
<activity
android:name=
".service.keep.PixelActivity"
android:name=
".service.keep.PixelActivity"
android:excludeFromRecents=
"true"
android:excludeFromRecents=
"true"
...
...
cleaner/app/src/main/java/com/mints/cleaner/adapter/albumClean/AlbumCleanAdapter.kt
View file @
622a8d13
...
@@ -33,7 +33,7 @@ class AlbumCleanAdapter(layoutResId: Int, data: List<Image>) :
...
@@ -33,7 +33,7 @@ class AlbumCleanAdapter(layoutResId: Int, data: List<Image>) :
.
centerCrop
()
.
centerCrop
()
.
placeholder
(
drawable
)
.
placeholder
(
drawable
)
.
dontAnimate
()
.
dontAnimate
()
.
diskCacheStrategy
(
DiskCacheStrategy
.
NONE
)
.
diskCacheStrategy
(
DiskCacheStrategy
.
AUTOMATIC
)
)
)
.
into
(
this
)
.
into
(
this
)
...
...
cleaner/app/src/main/java/com/mints/cleaner/adapter/home/HomeAdapter.kt
View file @
622a8d13
package
com.mints.cleaner.adapter.home
package
com.mints.cleaner.adapter.home
import
android.widget.GridView
import
android.widget.GridView
import
android.widget.ImageView
import
android.widget.SimpleAdapter
import
android.widget.SimpleAdapter
import
com.bumptech.glide.Glide
import
com.chad.library.adapter.base.BaseMultiItemQuickAdapter
import
com.chad.library.adapter.base.BaseMultiItemQuickAdapter
import
com.chad.library.adapter.base.BaseViewHolder
import
com.chad.library.adapter.base.BaseViewHolder
import
com.mints.cleaner.R
import
com.mints.cleaner.R
import
com.mints.cleaner.util.LogUtil
class
HomeAdapter
:
BaseMultiItemQuickAdapter
<
HomeMultiItem
,
BaseViewHolder
>
{
class
HomeAdapter
:
BaseMultiItemQuickAdapter
<
HomeMultiItem
,
BaseViewHolder
>
{
...
@@ -14,11 +17,10 @@ class HomeAdapter : BaseMultiItemQuickAdapter<HomeMultiItem, BaseViewHolder> {
...
@@ -14,11 +17,10 @@ class HomeAdapter : BaseMultiItemQuickAdapter<HomeMultiItem, BaseViewHolder> {
addItemType
(
HomeMultiItem
.
ITEM_BOTTOM
,
R
.
layout
.
item_clean_bottom
)
addItemType
(
HomeMultiItem
.
ITEM_BOTTOM
,
R
.
layout
.
item_clean_bottom
)
}
}
override
fun
convert
(
helper
:
BaseViewHolder
,
item
:
HomeMultiItem
?
)
{
override
fun
convert
(
helper
:
BaseViewHolder
,
item
:
HomeMultiItem
)
{
when
(
helper
.
itemViewType
)
{
when
(
helper
.
itemViewType
)
{
HomeMultiItem
.
ITEM_TOP
->
{
HomeMultiItem
.
ITEM_TOP
->
{
helper
.
addOnClickListener
(
R
.
id
.
btn_clean
)
helper
.
addOnClickListener
(
R
.
id
.
btn_clean
)
}
}
HomeMultiItem
.
ITEM_MID
->
{
HomeMultiItem
.
ITEM_MID
->
{
val
gridView
=
helper
.
getView
<
GridView
>(
R
.
id
.
gv_clean
)
val
gridView
=
helper
.
getView
<
GridView
>(
R
.
id
.
gv_clean
)
...
@@ -37,7 +39,11 @@ class HomeAdapter : BaseMultiItemQuickAdapter<HomeMultiItem, BaseViewHolder> {
...
@@ -37,7 +39,11 @@ class HomeAdapter : BaseMultiItemQuickAdapter<HomeMultiItem, BaseViewHolder> {
}
}
}
}
HomeMultiItem
.
ITEM_BOTTOM
->
{
HomeMultiItem
.
ITEM_BOTTOM
->
{
item
.
itemData
?.
let
{
helper
.
setText
(
R
.
id
.
tv_title
,
it
.
title
)
helper
.
setText
(
R
.
id
.
tv_info
,
it
.
info
)
helper
.
getView
<
ImageView
>(
R
.
id
.
iv
).
setImageResource
(
it
.
image
)
}
}
}
}
}
}
}
...
...
cleaner/app/src/main/java/com/mints/cleaner/adapter/home/HomeMultiItem.kt
View file @
622a8d13
...
@@ -5,13 +5,19 @@ import com.chad.library.adapter.base.entity.MultiItemEntity
...
@@ -5,13 +5,19 @@ import com.chad.library.adapter.base.entity.MultiItemEntity
class
HomeMultiItem
:
MultiItemEntity
{
class
HomeMultiItem
:
MultiItemEntity
{
private
var
itemType
:
Int
=
0
private
var
itemType
:
Int
=
0
lateinit
var
itemData
:
BottomData
var
gvDataList
:
MutableList
<
Map
<
String
,
Any
>>
=
ArrayList
()
lateinit
var
gvDataList
:
MutableList
<
Map
<
String
,
Any
>>
constructor
(
itemType
:
Int
)
{
constructor
(
itemType
:
Int
)
{
this
.
itemType
=
itemType
this
.
itemType
=
itemType
}
}
constructor
(
itemType
:
Int
,
itemData
:
BottomData
)
{
this
.
itemType
=
itemType
this
.
itemData
=
itemData
}
constructor
(
itemType
:
Int
,
gvDataList
:
MutableList
<
Map
<
String
,
Any
>>)
{
constructor
(
itemType
:
Int
,
gvDataList
:
MutableList
<
Map
<
String
,
Any
>>)
{
this
.
itemType
=
itemType
this
.
itemType
=
itemType
this
.
gvDataList
=
gvDataList
this
.
gvDataList
=
gvDataList
...
@@ -31,4 +37,6 @@ class HomeMultiItem : MultiItemEntity {
...
@@ -31,4 +37,6 @@ class HomeMultiItem : MultiItemEntity {
override
fun
getItemType
():
Int
{
override
fun
getItemType
():
Int
{
return
itemType
return
itemType
}
}
data class
BottomData
(
val
title
:
String
,
val
info
:
String
,
val
image
:
Int
)
}
}
\ No newline at end of file
cleaner/app/src/main/java/com/mints/cleaner/model/bean/FileBean.kt
View file @
622a8d13
...
@@ -4,7 +4,6 @@ data class FileBean(
...
@@ -4,7 +4,6 @@ data class FileBean(
val
image
:
Any
,
val
image
:
Any
,
val
path
:
String
,
val
path
:
String
,
val
time
:
String
,
val
time
:
String
,
val
modifyTime
:
Long
,
val
name
:
String
,
val
name
:
String
,
val
size
:
Long
val
size
:
Long
)
)
\ No newline at end of file
cleaner/app/src/main/java/com/mints/cleaner/model/repository/MainRepository.kt
View file @
622a8d13
...
@@ -18,6 +18,15 @@ class MainRepository(val service: ApiService) : BaseRepository() {
...
@@ -18,6 +18,15 @@ class MainRepository(val service: ApiService) : BaseRepository() {
R
.
mipmap
.
ic_launcher
R
.
mipmap
.
ic_launcher
)
)
private
val
itemBottomTitle
=
arrayOf
(
"文件清理"
,
"安装包清理"
,
"音乐清理"
,
"压缩包清理"
)
private
val
itemBottomInfo
=
arrayOf
(
"释放更多空间"
,
"清理无用的安装包"
,
"清理不喜欢的音乐"
,
"清理无用的压缩包"
)
private
val
itemBottomImage
=
arrayOf
(
R
.
mipmap
.
ic_launcher
,
R
.
mipmap
.
ic_launcher
,
R
.
mipmap
.
ic_launcher
,
R
.
mipmap
.
ic_launcher
)
private
var
multiItemList
:
ArrayList
<
HomeMultiItem
>
=
arrayListOf
()
private
var
multiItemList
:
ArrayList
<
HomeMultiItem
>
=
arrayListOf
()
private
val
gvDataList
:
MutableList
<
Map
<
String
,
Any
>>
=
ArrayList
()
private
val
gvDataList
:
MutableList
<
Map
<
String
,
Any
>>
=
ArrayList
()
...
@@ -32,13 +41,22 @@ class MainRepository(val service: ApiService) : BaseRepository() {
...
@@ -32,13 +41,22 @@ class MainRepository(val service: ApiService) : BaseRepository() {
multiItemList
=
arrayListOf
(
multiItemList
=
arrayListOf
(
HomeMultiItem
(
HomeMultiItem
.
ITEM_TOP
),
HomeMultiItem
(
HomeMultiItem
.
ITEM_TOP
),
HomeMultiItem
(
HomeMultiItem
.
ITEM_MID
,
gvDataList
),
HomeMultiItem
(
HomeMultiItem
.
ITEM_MID
,
gvDataList
)
HomeMultiItem
(
HomeMultiItem
.
ITEM_BOTTOM
),
HomeMultiItem
(
HomeMultiItem
.
ITEM_BOTTOM
),
HomeMultiItem
(
HomeMultiItem
.
ITEM_BOTTOM
),
HomeMultiItem
(
HomeMultiItem
.
ITEM_BOTTOM
)
)
)
for
(
i
in
itemBottomTitle
.
indices
)
{
multiItemList
.
add
(
HomeMultiItem
(
HomeMultiItem
.
ITEM_BOTTOM
,
HomeMultiItem
.
BottomData
(
itemBottomTitle
[
i
],
itemBottomInfo
[
i
],
itemBottomImage
[
i
]
)
)
)
}
return
multiItemList
return
multiItemList
}
}
...
...
cleaner/app/src/main/java/com/mints/cleaner/ui/home/HomeFragment.kt
View file @
622a8d13
...
@@ -7,8 +7,12 @@ import com.mints.cleaner.R
...
@@ -7,8 +7,12 @@ import com.mints.cleaner.R
import
com.mints.cleaner.adapter.home.HomeAdapter
import
com.mints.cleaner.adapter.home.HomeAdapter
import
com.mints.cleaner.databinding.FragmentCleanBinding
import
com.mints.cleaner.databinding.FragmentCleanBinding
import
com.mints.cleaner.model.bean.HeaderTitle
import
com.mints.cleaner.model.bean.HeaderTitle
import
com.mints.cleaner.ui.PreviewActivity
import
com.mints.cleaner.ui.albumClean.AlbumCleanActivity
import
com.mints.cleaner.ui.main.MainViewModel
import
com.mints.cleaner.ui.main.MainViewModel
import
com.mints.cleaner.ui.multiClean.MultiCleanActivity
import
com.mints.core.base.BaseVMFragment
import
com.mints.core.base.BaseVMFragment
import
com.mints.ktx.ext.startKtxActivity
import
com.mints.ktx.ext.toast
import
com.mints.ktx.ext.toast
import
org.koin.androidx.viewmodel.ext.android.viewModel
import
org.koin.androidx.viewmodel.ext.android.viewModel
...
@@ -53,19 +57,19 @@ class HomeFragment : BaseVMFragment<FragmentCleanBinding>(R.layout.fragment_clea
...
@@ -53,19 +57,19 @@ class HomeFragment : BaseVMFragment<FragmentCleanBinding>(R.layout.fragment_clea
when
(
position
)
{
when
(
position
)
{
2
->
{
2
->
{
// 文件清理
// 文件清理
activity
?.
let
{
toast
(
it
,
"文件清理"
,
Toast
.
LENGTH_SHORT
)
}
}
}
3
->
{
3
->
{
//
音乐
清理
//
安装包
清理
activity
?.
let
{
toast
(
it
,
"音乐清理"
,
Toast
.
LENGTH_SHORT
)
}
startKtxActivity
<
MultiCleanActivity
>(
value
=
MultiCleanActivity
.
MULTI_TYPE
to
MultiCleanActivity
.
MULTI_TYPE_APK
)
}
}
4
->
{
4
->
{
//
安装包
清理
//
音乐
清理
activity
?.
let
{
toast
(
it
,
"安装包清理"
,
Toast
.
LENGTH_SHORT
)
}
startKtxActivity
<
MultiCleanActivity
>(
value
=
MultiCleanActivity
.
MULTI_TYPE_AUDIO
to
MultiCleanActivity
.
MULTI_TYPE_AUDIO
)
}
}
5
->
{
5
->
{
// 压缩包清理
// 压缩包清理
activity
?.
let
{
toast
(
it
,
"压缩包清理"
,
Toast
.
LENGTH_SHORT
)
}
startKtxActivity
<
MultiCleanActivity
>(
value
=
MultiCleanActivity
.
MULTI_TYPE_ZIP
to
MultiCleanActivity
.
MULTI_TYPE_ZIP
)
}
}
}
}
}
}
...
@@ -75,22 +79,24 @@ class HomeFragment : BaseVMFragment<FragmentCleanBinding>(R.layout.fragment_clea
...
@@ -75,22 +79,24 @@ class HomeFragment : BaseVMFragment<FragmentCleanBinding>(R.layout.fragment_clea
override
fun
onGridViewItemClick
(
position
:
Int
)
{
override
fun
onGridViewItemClick
(
position
:
Int
)
{
when
(
position
)
{
when
(
position
)
{
0
->
{
0
->
{
activity
?.
let
{
toast
(
it
,
"0"
,
Toast
.
LENGTH_SHORT
)
}
// 手机加速
}
}
1
->
{
1
->
{
activity
?.
let
{
toast
(
it
,
"1"
,
Toast
.
LENGTH_SHORT
)
}
// 微信清理
}
}
2
->
{
2
->
{
activity
?.
let
{
toast
(
it
,
"2"
,
Toast
.
LENGTH_SHORT
)
}
// QQ清理
}
}
3
->
{
3
->
{
activity
?.
let
{
toast
(
it
,
"3"
,
Toast
.
LENGTH_SHORT
)
}
// 软件管理
}
}
4
->
{
4
->
{
activity
?.
let
{
toast
(
it
,
"4"
,
Toast
.
LENGTH_SHORT
)
}
// 相册清理
startKtxActivity
<
AlbumCleanActivity
>()
}
}
5
->
{
5
->
{
activity
?.
let
{
toast
(
it
,
"5"
,
Toast
.
LENGTH_SHORT
)
}
// 视频清理
startKtxActivity
<
MultiCleanActivity
>(
value
=
MultiCleanActivity
.
MULTI_TYPE_VIDEO
to
MultiCleanActivity
.
MULTI_TYPE_VIDEO
)
}
}
}
}
...
...
cleaner/app/src/main/java/com/mints/cleaner/ui/multiClean/ApkUtils.kt
View file @
622a8d13
...
@@ -3,16 +3,19 @@ package com.mints.cleaner.ui.multiClean
...
@@ -3,16 +3,19 @@ package com.mints.cleaner.ui.multiClean
import
android.content.Context
import
android.content.Context
import
android.content.pm.PackageManager
import
android.content.pm.PackageManager
import
android.graphics.drawable.Drawable
import
android.graphics.drawable.Drawable
import
android.media.MediaPlayer
import
com.mints.cleaner.R
import
com.mints.cleaner.R
import
com.mints.cleaner.model.bean.FileBean
import
com.mints.cleaner.model.bean.FileBean
import
com.mints.cleaner.util.FileUtils
import
com.mints.cleaner.util.FormatUtils
import
com.mints.cleaner.util.FormatUtils
import
com.mints.cleaner.util.LogUtil
import
com.mints.cleaner.util.LogUtil
import
java.io.File
import
java.io.File
object
ApkUtils
{
object
ApkUtils
{
/**
/**
* 根据apk存储路径获取apk
图标
* 根据apk存储路径获取apk
信息
*/
*/
fun
getApkInfo
(
fun
getApkInfo
(
context
:
Context
,
apkPath
:
String
context
:
Context
,
apkPath
:
String
...
@@ -41,7 +44,93 @@ object ApkUtils {
...
@@ -41,7 +44,93 @@ object ApkUtils {
val
size
=
apkFile
.
length
()
val
size
=
apkFile
.
length
()
val
modifiedTime
=
FormatUtils
.
formatTime
(
apkFile
.
lastModified
())
val
modifiedTime
=
FormatUtils
.
formatTime
(
apkFile
.
lastModified
())
return
FileBean
(
apkIcon
,
apkPath
,
modifiedTime
,
0L
,
apkLabel
,
size
)
return
FileBean
(
apkIcon
,
apkPath
,
modifiedTime
,
apkLabel
,
size
)
}
/**
* 获取压缩包信息
*/
fun
getZipInfo
(
filePath
:
String
):
FileBean
{
val
file
=
File
(
filePath
)
val
name
=
file
.
name
val
modifiedTime
=
FormatUtils
.
formatTime
(
file
.
lastModified
())
val
size
=
file
.
length
()
return
FileBean
(
""
,
filePath
,
modifiedTime
,
name
,
size
)
}
/**
* 获取大文件信息
*/
fun
getBigFileInfo
(
context
:
Context
,
filePath
:
String
):
FileBean
{
val
file
=
File
(
filePath
)
val
name
=
file
.
name
var
modifiedTime
:
String
val
extensionName
=
FileUtils
.
getExtensionName
(
name
)
val
size
=
file
.
length
()
val
image
:
String
when
(
extensionName
)
{
"apk"
->
{
return
getApkInfo
(
context
,
filePath
)
}
"mp3"
->
{
val
mediaPlayer
=
MediaPlayer
()
mediaPlayer
.
setDataSource
(
filePath
)
mediaPlayer
.
prepare
()
modifiedTime
=
FormatUtils
.
formatDuration
(
mediaPlayer
.
duration
.
toLong
())
image
=
filePath
}
"mp4"
->
{
val
mediaPlayer
=
MediaPlayer
()
mediaPlayer
.
setDataSource
(
filePath
)
mediaPlayer
.
prepare
()
modifiedTime
=
FormatUtils
.
formatDuration
(
mediaPlayer
.
duration
.
toLong
())
image
=
filePath
}
"txt"
->
{
modifiedTime
=
FormatUtils
.
formatTime
(
file
.
lastModified
())
image
=
filePath
}
"jpeg"
->
{
modifiedTime
=
FormatUtils
.
formatTime
(
file
.
lastModified
())
image
=
filePath
}
"jpg"
->
{
modifiedTime
=
FormatUtils
.
formatTime
(
file
.
lastModified
())
image
=
filePath
}
"png"
->
{
modifiedTime
=
FormatUtils
.
formatTime
(
file
.
lastModified
())
image
=
filePath
}
"gif"
->
{
modifiedTime
=
FormatUtils
.
formatTime
(
file
.
lastModified
())
image
=
filePath
}
"zip"
->
{
modifiedTime
=
FormatUtils
.
formatTime
(
file
.
lastModified
())
image
=
""
}
"rar"
->
{
modifiedTime
=
FormatUtils
.
formatTime
(
file
.
lastModified
())
image
=
""
}
"7z"
->
{
modifiedTime
=
FormatUtils
.
formatTime
(
file
.
lastModified
())
image
=
""
}
else
->
{
modifiedTime
=
FormatUtils
.
formatTime
(
file
.
lastModified
())
image
=
""
}
}
return
FileBean
(
image
,
filePath
,
modifiedTime
,
name
,
size
)
}
}
}
}
\ No newline at end of file
cleaner/app/src/main/java/com/mints/cleaner/ui/multiClean/FileScanModel.kt
View file @
622a8d13
...
@@ -7,6 +7,7 @@ import java.util.*
...
@@ -7,6 +7,7 @@ import java.util.*
object
FileScanModel
{
object
FileScanModel
{
private
val
mEligibleFiles
:
ArrayList
<
String
>
by
lazy
{
arrayListOf
<
String
>()
}
private
val
mEligibleFiles
:
ArrayList
<
String
>
by
lazy
{
arrayListOf
<
String
>()
}
private
val
mBigFiles
:
ArrayList
<
String
>
by
lazy
{
arrayListOf
<
String
>()
}
/**
/**
* Java文件操作 根据文件后缀获取全部文件
* Java文件操作 根据文件后缀获取全部文件
...
@@ -29,14 +30,41 @@ object FileScanModel {
...
@@ -29,14 +30,41 @@ object FileScanModel {
getSuffixFile
(
file
.
listFiles
(),
*
suffixs
)
getSuffixFile
(
file
.
listFiles
(),
*
suffixs
)
}
else
{
}
else
{
val
fileName
=
file
.
name
val
fileName
=
file
.
name
suffixs
.
forEach
{
it
->
suffixs
.
forEach
{
if
(
fileName
.
endsWith
(
".$it"
))
{
if
(
fileName
.
endsWith
(
".$it"
))
{
mEligibleFiles
?.
let
{
mEligibleFiles
.
add
(
file
.
absolutePath
)
it
.
add
(
file
.
absolutePath
)
}
}
}
}
}
}
}
}
}
/**
* Java文件操作 根据文件大小获取文件
*/
fun
getBigFiles
(
callback
:
DataCallback
)
{
Thread
(
Runnable
{
val
sdDir
=
Environment
.
getExternalStorageDirectory
()
val
listFiles
=
sdDir
.
listFiles
()
getBigFile
(
listFiles
)
callback
.
onSuccess
(
mBigFiles
)
}).
start
()
}
private
fun
getBigFile
(
files
:
Array
<
File
>)
{
files
?.
let
{
for
(
file
in
files
)
{
if
(
file
.
isDirectory
)
{
getBigFile
(
file
.
listFiles
())
}
else
{
// 大于10MB即视为大文件
if
(
file
.
length
()
>
1024
*
1024
*
10
)
{
mBigFiles
.
add
(
file
.
absolutePath
)
}
}
}
}
}
}
}
...
...
cleaner/app/src/main/java/com/mints/cleaner/ui/multiClean/MultiCleanActivity.kt
View file @
622a8d13
...
@@ -11,7 +11,6 @@ import com.mints.cleaner.adapter.multiClean.MultiCleanAdapter
...
@@ -11,7 +11,6 @@ import com.mints.cleaner.adapter.multiClean.MultiCleanAdapter
import
com.mints.cleaner.databinding.ActivityMultiCleanBinding
import
com.mints.cleaner.databinding.ActivityMultiCleanBinding
import
com.mints.cleaner.model.bean.CleanHeaderTitle
import
com.mints.cleaner.model.bean.CleanHeaderTitle
import
com.mints.cleaner.model.bean.FileBean
import
com.mints.cleaner.model.bean.FileBean
import
com.mints.cleaner.service.ScreenService
import
com.mints.cleaner.util.FileUtils
import
com.mints.cleaner.util.FileUtils
import
com.mints.cleaner.util.FormatUtils
import
com.mints.cleaner.util.FormatUtils
import
com.mints.cleaner.util.IntentUtils
import
com.mints.cleaner.util.IntentUtils
...
@@ -20,13 +19,17 @@ import kotlinx.android.synthetic.main.activity_album_clean.btn_clean
...
@@ -20,13 +19,17 @@ import kotlinx.android.synthetic.main.activity_album_clean.btn_clean
import
kotlinx.android.synthetic.main.activity_multi_clean.*
import
kotlinx.android.synthetic.main.activity_multi_clean.*
import
java.io.File
import
java.io.File
import
java.util.*
import
java.util.*
import
kotlin.concurrent.schedule
/**
* 视频、音频、压缩包、安装包、大文件清理
*/
class
MultiCleanActivity
:
BaseVMActivity
(),
MultiCleanAdapter
.
OnImageSelectListener
,
class
MultiCleanActivity
:
BaseVMActivity
(),
MultiCleanAdapter
.
OnImageSelectListener
,
MultiCleanAdapter
.
OnItemClickListener
{
MultiCleanAdapter
.
OnItemClickListener
{
private
val
binding
by
binding
<
ActivityMultiCleanBinding
>(
R
.
layout
.
activity_multi_clean
)
private
val
binding
by
binding
<
ActivityMultiCleanBinding
>(
R
.
layout
.
activity_multi_clean
)
private
va
l
dataList
=
mutableListOf
<
FileBean
>()
private
va
r
dataList
=
mutableListOf
<
FileBean
>()
private
val
multiAdapter
:
MultiCleanAdapter
by
lazy
{
private
val
multiAdapter
:
MultiCleanAdapter
by
lazy
{
MultiCleanAdapter
(
MultiCleanAdapter
(
...
@@ -35,13 +38,37 @@ class MultiCleanActivity : BaseVMActivity(), MultiCleanAdapter.OnImageSelectList
...
@@ -35,13 +38,37 @@ class MultiCleanActivity : BaseVMActivity(), MultiCleanAdapter.OnImageSelectList
)
)
}
}
companion
object
{
const
val
MULTI_TYPE
=
"VIDEO"
// 视频清理
const
val
MULTI_TYPE_VIDEO
=
"VIDEO"
// 音频清理
const
val
MULTI_TYPE_AUDIO
=
"AUDIO"
// 压缩包清理
const
val
MULTI_TYPE_ZIP
=
"ZIP"
// 安装包清理
const
val
MULTI_TYPE_APK
=
"APK"
// 大文件清理
const
val
MULTI_TYPE_BIGFILE
=
"OTHERS"
}
private
val
mMultiType
:
String
by
lazy
{
intent
.
getStringExtra
(
MULTI_TYPE
)
}
// 是否全选
// 是否全选
private
var
flag
=
false
private
var
flag
=
false
private
var
sIsScrolling
=
false
private
var
sIsScrolling
=
false
override
fun
initView
()
{
override
fun
initView
()
{
binding
.
run
{
binding
.
run
{
title
=
CleanHeaderTitle
(
title
=
when
(
mMultiType
)
{
MULTI_TYPE_VIDEO
->
{
CleanHeaderTitle
(
getString
(
R
.
string
.
video_clean
),
getString
(
R
.
string
.
video_clean
),
R
.
mipmap
.
ic_activity_arrow
,
R
.
mipmap
.
ic_activity_arrow
,
{
{
...
@@ -65,11 +92,125 @@ class MultiCleanActivity : BaseVMActivity(), MultiCleanAdapter.OnImageSelectList
...
@@ -65,11 +92,125 @@ class MultiCleanActivity : BaseVMActivity(), MultiCleanAdapter.OnImageSelectList
R
.
color
.
theme
R
.
color
.
theme
)
)
}
}
MULTI_TYPE_AUDIO
->
{
CleanHeaderTitle
(
getString
(
R
.
string
.
music_clean
),
R
.
mipmap
.
ic_activity_arrow
,
{
onBackPressed
()
},
View
.
VISIBLE
,
getString
(
R
.
string
.
full_choice
),
{
if
(!
flag
)
{
multiAdapter
.
fullSelectImage
()
title
?.
rightInfo
=
getString
(
R
.
string
.
cancel_full_choice
)
title
?.
title
=
"已选中"
+
multiAdapter
.
getSelectImageList
().
size
+
"项"
}
else
{
multiAdapter
.
cancelFullSelectImage
()
title
?.
rightInfo
=
getString
(
R
.
string
.
full_choice
)
title
?.
title
=
getString
(
R
.
string
.
album_clean
)
}
flag
=
!
flag
},
R
.
color
.
theme
)
}
MULTI_TYPE_ZIP
->
{
CleanHeaderTitle
(
getString
(
R
.
string
.
zip_clean
),
R
.
mipmap
.
ic_activity_arrow
,
{
onBackPressed
()
},
View
.
VISIBLE
,
getString
(
R
.
string
.
full_choice
),
{
if
(!
flag
)
{
multiAdapter
.
fullSelectImage
()
title
?.
rightInfo
=
getString
(
R
.
string
.
cancel_full_choice
)
title
?.
title
=
"已选中"
+
multiAdapter
.
getSelectImageList
().
size
+
"项"
}
else
{
multiAdapter
.
cancelFullSelectImage
()
title
?.
rightInfo
=
getString
(
R
.
string
.
full_choice
)
title
?.
title
=
getString
(
R
.
string
.
album_clean
)
}
flag
=
!
flag
},
R
.
color
.
theme
)
}
MULTI_TYPE_APK
->
{
CleanHeaderTitle
(
getString
(
R
.
string
.
apk_clean
),
R
.
mipmap
.
ic_activity_arrow
,
{
onBackPressed
()
},
View
.
VISIBLE
,
getString
(
R
.
string
.
full_choice
),
{
if
(!
flag
)
{
multiAdapter
.
fullSelectImage
()
title
?.
rightInfo
=
getString
(
R
.
string
.
cancel_full_choice
)
title
?.
title
=
"已选中"
+
multiAdapter
.
getSelectImageList
().
size
+
"项"
}
else
{
multiAdapter
.
cancelFullSelectImage
()
title
?.
rightInfo
=
getString
(
R
.
string
.
full_choice
)
title
?.
title
=
getString
(
R
.
string
.
album_clean
)
}
flag
=
!
flag
},
R
.
color
.
theme
)
}
MULTI_TYPE_BIGFILE
->
{
CleanHeaderTitle
(
getString
(
R
.
string
.
bigFile_clean
),
R
.
mipmap
.
ic_activity_arrow
,
{
onBackPressed
()
},
View
.
VISIBLE
,
getString
(
R
.
string
.
full_choice
),
{
if
(!
flag
)
{
multiAdapter
.
fullSelectImage
()
title
?.
rightInfo
=
getString
(
R
.
string
.
cancel_full_choice
)
title
?.
title
=
"已选中"
+
multiAdapter
.
getSelectImageList
().
size
+
"项"
}
else
{
multiAdapter
.
cancelFullSelectImage
()
title
?.
rightInfo
=
getString
(
R
.
string
.
full_choice
)
title
?.
title
=
getString
(
R
.
string
.
album_clean
)
}
flag
=
!
flag
},
R
.
color
.
theme
)
}
else
->
{
CleanHeaderTitle
(
getString
(
R
.
string
.
unknown
),
R
.
mipmap
.
ic_activity_arrow
,
{
onBackPressed
()
},
View
.
GONE
,
""
,
{},
R
.
color
.
theme
)
}
}
}
clv_loading
.
showLoading
()
clv_loading
.
showLoading
()
initRecyclerView
()
initRecyclerView
()
btn_clean
.
setOnClickListener
{
btn_clean
.
setOnClickListener
{
val
selectImageList
=
multiAdapter
.
getSelectImageList
()
val
selectImageList
=
multiAdapter
.
getSelectImageList
()
if
(
selectImageList
.
isEmpty
())
return
@setOnClickListener
if
(
selectImageList
.
isEmpty
())
return
@setOnClickListener
...
@@ -100,7 +241,7 @@ class MultiCleanActivity : BaseVMActivity(), MultiCleanAdapter.OnImageSelectList
...
@@ -100,7 +241,7 @@ class MultiCleanActivity : BaseVMActivity(), MultiCleanAdapter.OnImageSelectList
sIsScrolling
=
true
sIsScrolling
=
true
Glide
.
with
(
this
@MultiCleanActivity
).
pauseRequests
()
Glide
.
with
(
this
@MultiCleanActivity
).
pauseRequests
()
}
else
if
(
newState
==
RecyclerView
.
SCROLL_STATE_IDLE
)
{
}
else
if
(
newState
==
RecyclerView
.
SCROLL_STATE_IDLE
)
{
if
(
sIsScrolling
===
true
)
{
if
(
sIsScrolling
)
{
Glide
.
with
(
this
@MultiCleanActivity
).
resumeRequests
()
Glide
.
with
(
this
@MultiCleanActivity
).
resumeRequests
()
}
}
sIsScrolling
=
false
sIsScrolling
=
false
...
@@ -112,67 +253,138 @@ class MultiCleanActivity : BaseVMActivity(), MultiCleanAdapter.OnImageSelectList
...
@@ -112,67 +253,138 @@ class MultiCleanActivity : BaseVMActivity(), MultiCleanAdapter.OnImageSelectList
}
}
override
fun
initData
()
{
override
fun
initData
()
{
when
(
mMultiType
)
{
MULTI_TYPE_VIDEO
->
{
MultiCleanModel
.
loadVideoForSDCard
(
this
,
object
:
MultiCleanModel
.
DataCallback
{
MultiCleanModel
.
loadVideoForSDCard
(
this
,
object
:
MultiCleanModel
.
DataCallback
{
override
fun
onSuccess
(
files
:
ArrayList
<
FileBean
>?)
{
override
fun
onSuccess
(
files
:
ArrayList
<
FileBean
>?)
{
files
?.
let
{
files
?.
let
{
dataList
.
addAll
(
it
)
dataList
.
addAll
(
it
)
}
}
// Timer().schedule(1000) {
Timer
().
schedule
(
1000
)
{
// runOnUiThread {
runOnUiThread
{
// multiAdapter.notifyDataSetChanged()
multiAdapter
.
notifyDataSetChanged
()
// }
}
// }
}
runOnUiThread
{
multiAdapter
.
notifyDataSetChanged
()
}
}
})
}
MULTI_TYPE_AUDIO
->
{
MultiCleanModel
.
loadMusicForSDCard
(
this
,
object
:
MultiCleanModel
.
DataCallback
{
override
fun
onSuccess
(
files
:
ArrayList
<
FileBean
>?)
{
files
?.
let
{
dataList
.
addAll
(
it
)
}
runOnUiThread
{
multiAdapter
.
notifyDataSetChanged
()
}
}
})
}
MULTI_TYPE_APK
->
{
FileScanModel
.
getSuffixFiles
(
object
:
FileScanModel
.
DataCallback
{
override
fun
onSuccess
(
filePaths
:
ArrayList
<
String
>?)
{
filePaths
?.
let
{
it
->
it
.
forEach
{
dataList
.
add
(
ApkUtils
.
getApkInfo
(
this
@MultiCleanActivity
,
it
))
}
dataList
.
sortWith
(
Comparator
{
file
,
t1
->
when
{
file
.
size
<
t1
.
size
->
{
1
}
file
.
size
>
t1
.
size
->
{
-
1
}
else
->
{
0
}
}
})
}
runOnUiThread
{
multiAdapter
.
notifyDataSetChanged
()
}
}
},
"apk"
)
}
MULTI_TYPE_ZIP
->
{
// 压缩包数据
FileScanModel
.
getSuffixFiles
(
object
:
FileScanModel
.
DataCallback
{
override
fun
onSuccess
(
filePaths
:
ArrayList
<
String
>?)
{
filePaths
?.
let
{
it
->
dataList
.
clear
()
it
.
forEach
{
dataList
.
add
(
ApkUtils
.
getZipInfo
(
it
))
}
dataList
.
sortWith
(
Comparator
{
file
,
t1
->
when
{
file
.
size
<
t1
.
size
->
{
1
}
file
.
size
>
t1
.
size
->
{
-
1
}
else
->
{
0
}
}
})
}
runOnUiThread
{
runOnUiThread
{
multiAdapter
.
notifyDataSetChanged
()
multiAdapter
.
notifyDataSetChanged
()
}
}
}
},
"7z"
,
"zip"
)
}
MULTI_TYPE_BIGFILE
->
{
// 大文件数据
FileScanModel
.
getBigFiles
(
object
:
FileScanModel
.
DataCallback
{
override
fun
onSuccess
(
filePaths
:
ArrayList
<
String
>?)
{
filePaths
?.
let
{
it
->
dataList
.
clear
()
it
.
forEach
{
dataList
.
add
(
ApkUtils
.
getBigFileInfo
(
this
@MultiCleanActivity
,
it
))
}
}
dataList
.
sortWith
(
Comparator
{
file
,
t1
->
when
{
file
.
size
<
t1
.
size
->
{
1
}
file
.
size
>
t1
.
size
->
{
-
1
}
else
->
{
0
}
}
})
})
}
// MultiCleanModel.loadMusicForSDCard(this, object : MultiCleanModel.DataCallback {
runOnUiThread
{
// override fun onSuccess(files: ArrayList<FileBean>?) {
multiAdapter
.
notifyDataSetChanged
()
// files?.let {
}
// dataList.addAll(it)
// }
}
//
})
// runOnUiThread {
}
// multiAdapter.notifyDataSetChanged()
else
->
{
// }
}
// }
}
//
// })
// FileScanModel.getSuffixFiles(object : FileScanModel.DataCallback {
// override fun onSuccess(filePaths: ArrayList<String>?) {
// filePaths?.let { it ->
// it.forEach {
// dataList.add(ApkUtils.getApkInfo(this@MultiCleanActivity, it))
// }
//
// dataList.sortWith(Comparator { file, t1 ->
// when {
// file.size < t1.size -> {
// 1
// }
// file.size > t1.size -> {
// -1
// }
// else -> {
// 0
// }
// }
// })
// }
//
// runOnUiThread {
// multiAdapter.notifyDataSetChanged()
// }
//
// }
// }, "apk")
}
}
...
@@ -193,11 +405,81 @@ class MultiCleanActivity : BaseVMActivity(), MultiCleanAdapter.OnImageSelectList
...
@@ -193,11 +405,81 @@ class MultiCleanActivity : BaseVMActivity(), MultiCleanAdapter.OnImageSelectList
}
}
override
fun
onItemClick
(
fileBean
:
FileBean
,
position
:
Int
)
{
override
fun
onItemClick
(
fileBean
:
FileBean
,
position
:
Int
)
{
val
videoFileIntent
=
IntentUtils
.
getVideoFileIntent
(
this
,
fileBean
.
path
)
// 根据不同类型跳转系统自带的文件打开器
startActivity
(
videoFileIntent
)
var
multiIntent
:
Intent
?
when
(
mMultiType
)
{
MULTI_TYPE_AUDIO
->
{
multiIntent
=
IntentUtils
.
getAudioFileIntent
(
this
,
fileBean
.
path
)
startActivity
(
multiIntent
)
}
MULTI_TYPE_VIDEO
->
{
multiIntent
=
IntentUtils
.
getVideoFileIntent
(
this
,
fileBean
.
path
)
startActivity
(
multiIntent
)
}
MULTI_TYPE_ZIP
->
{
multiIntent
=
IntentUtils
.
getZipFileIntent
(
this
,
fileBean
.
path
)
startActivity
(
multiIntent
)
}
MULTI_TYPE_APK
->
{
multiIntent
=
IntentUtils
.
getApkFileIntent
(
this
,
fileBean
.
path
)
startActivity
(
multiIntent
)
}
else
->
{
when
(
FileUtils
.
getExtensionName
(
fileBean
.
path
))
{
"apk"
->
{
// multiIntent = IntentUtils.getApkFileIntent(this, fileBean.path)
// startActivity(multiIntent)
}
"jpg"
->
{
multiIntent
=
IntentUtils
.
getImageFileIntent
(
this
,
fileBean
.
path
)
startActivity
(
multiIntent
)
}
"png"
->
{
multiIntent
=
IntentUtils
.
getImageFileIntent
(
this
,
fileBean
.
path
)
startActivity
(
multiIntent
)
}
"jpeg"
->
{
multiIntent
=
IntentUtils
.
getImageFileIntent
(
this
,
fileBean
.
path
)
startActivity
(
multiIntent
)
}
"jpg"
->
{
multiIntent
=
IntentUtils
.
getImageFileIntent
(
this
,
fileBean
.
path
)
startActivity
(
multiIntent
)
}
"txt"
->
{
multiIntent
=
IntentUtils
.
getTextFileIntent
(
fileBean
.
path
,
false
)
startActivity
(
multiIntent
)
}
"mp3"
->
{
multiIntent
=
IntentUtils
.
getAudioFileIntent
(
this
,
fileBean
.
path
)
startActivity
(
multiIntent
)
}
"mp4"
->
{
multiIntent
=
IntentUtils
.
getVideoFileIntent
(
this
,
fileBean
.
path
)
startActivity
(
multiIntent
)
}
"rar"
->
{
multiIntent
=
IntentUtils
.
getZipFileIntent
(
this
,
fileBean
.
path
)
startActivity
(
multiIntent
)
}
"zip"
->
{
multiIntent
=
IntentUtils
.
getZipFileIntent
(
this
,
fileBean
.
path
)
startActivity
(
multiIntent
)
}
"7z"
->
{
multiIntent
=
IntentUtils
.
getZipFileIntent
(
this
,
fileBean
.
path
)
startActivity
(
multiIntent
)
}
else
->
{
}
}
}
}
}
}
// 删除后更新手机
// 删除后更新手机
资源文件
private
fun
updateFile
(
imgPath
:
String
?)
{
private
fun
updateFile
(
imgPath
:
String
?)
{
val
intent
=
Intent
(
Intent
.
ACTION_MEDIA_SCANNER_SCAN_FILE
)
val
intent
=
Intent
(
Intent
.
ACTION_MEDIA_SCANNER_SCAN_FILE
)
intent
.
data
=
Uri
.
fromFile
(
File
(
imgPath
))
intent
.
data
=
Uri
.
fromFile
(
File
(
imgPath
))
...
...
cleaner/app/src/main/java/com/mints/cleaner/ui/multiClean/MultiCleanModel.kt
View file @
622a8d13
...
@@ -6,20 +6,16 @@ import android.content.pm.PackageManager
...
@@ -6,20 +6,16 @@ import android.content.pm.PackageManager
import
android.database.ContentObserver
import
android.database.ContentObserver
import
android.database.Cursor
import
android.database.Cursor
import
android.net.Uri
import
android.net.Uri
import
android.os.Environment
import
android.provider.MediaStore
import
android.provider.MediaStore
import
androidx.core.content.ContextCompat
import
androidx.core.content.ContextCompat
import
com.mints.cleaner.model.bean.FileBean
import
com.mints.cleaner.model.bean.FileBean
import
com.mints.cleaner.ui.albumClean.AlbumCleanModel
import
com.mints.cleaner.ui.albumClean.AlbumCleanModel
import
com.mints.cleaner.util.FormatUtils
import
com.mints.cleaner.util.FormatUtils
import
com.mints.cleaner.util.UriUtils
import
java.io.File
import
java.io.File
import
java.lang.ref.WeakReference
import
java.lang.ref.WeakReference
import
java.util.*
import
kotlin.Comparator
import
kotlin.Comparator
import
kotlin.collections.ArrayList
import
kotlin.collections.ArrayList
object
MultiCleanModel
{
object
MultiCleanModel
{
/**
/**
...
@@ -203,7 +199,6 @@ object MultiCleanModel {
...
@@ -203,7 +199,6 @@ object MultiCleanModel {
thumbPath
,
thumbPath
,
path
,
path
,
formatDuration
,
formatDuration
,
modifyTime
,
displayName
,
displayName
,
size
size
)
)
...
@@ -342,7 +337,6 @@ object MultiCleanModel {
...
@@ -342,7 +337,6 @@ object MultiCleanModel {
thumbPath
,
thumbPath
,
path
,
path
,
formatDuration
,
formatDuration
,
modifyTime
,
displayName
,
displayName
,
size
size
)
)
...
...
cleaner/app/src/main/java/com/mints/cleaner/util/FileUtils.kt
View file @
622a8d13
...
@@ -6,7 +6,6 @@ import android.content.Context
...
@@ -6,7 +6,6 @@ import android.content.Context
import
android.database.Cursor
import
android.database.Cursor
import
android.net.Uri
import
android.net.Uri
import
android.provider.MediaStore
import
android.provider.MediaStore
import
java.text.DecimalFormat
object
FileUtils
{
object
FileUtils
{
...
@@ -51,4 +50,17 @@ object FileUtils {
...
@@ -51,4 +50,17 @@ object FileUtils {
return
result
return
result
}
}
/*
* Java文件操作 获取文件扩展名
* */
fun
getExtensionName
(
filename
:
String
?):
String
?
{
filename
?.
let
{
val
dot
=
filename
.
lastIndexOf
(
'.'
)
if
(
dot
>
-
1
&&
dot
<
filename
.
length
-
1
)
{
return
filename
.
substring
(
dot
+
1
)
}
}
return
filename
}
}
}
\ No newline at end of file
cleaner/app/src/main/java/com/mints/cleaner/util/IntentUtils.kt
View file @
622a8d13
...
@@ -86,6 +86,28 @@ object IntentUtils {
...
@@ -86,6 +86,28 @@ object IntentUtils {
return
intent
return
intent
}
}
//Android获取一个用于打开APK文件的intent
fun
getZipFileIntent
(
context
:
Context
,
param
:
String
?):
Intent
?
{
val
intent
=
Intent
()
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
)
intent
.
action
=
Intent
.
ACTION_VIEW
var
uri
:
Uri
?
uri
=
if
(
isAndroidN
)
{
intent
.
addFlags
(
Intent
.
FLAG_GRANT_READ_URI_PERMISSION
)
FileProvider
.
getUriForFile
(
context
,
context
.
packageName
+
".fileprovider"
,
File
(
param
)
)
}
else
{
Uri
.
fromFile
(
File
(
param
))
}
intent
.
setDataAndType
(
uri
,
"application/x-gzip"
)
return
intent
}
//Android获取一个用于打开VIDEO文件的intent
//Android获取一个用于打开VIDEO文件的intent
fun
getVideoFileIntent
(
context
:
Context
,
param
:
String
?):
Intent
?
{
fun
getVideoFileIntent
(
context
:
Context
,
param
:
String
?):
Intent
?
{
val
intent
=
Intent
(
"android.intent.action.VIEW"
)
val
intent
=
Intent
(
"android.intent.action.VIEW"
)
...
...
cleaner/app/src/main/res/layout/item_clean_bottom.xml
View file @
622a8d13
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"80dp"
>
android:paddingStart=
"20dp"
android:paddingTop=
"20dp"
android:paddingEnd=
"20dp"
>
<ImageView
<ImageView
android:id=
"@+id/iv"
android:id=
"@+id/iv"
android:layout_width=
"wrap_content"
android:layout_width=
"60dp"
android:layout_height=
"wrap_content"
android:layout_height=
"60dp"
android:layout_marginEnd=
"10dp"
android:layout_centerVertical=
"true"
android:layout_marginStart=
"20dp"
android:layout_marginEnd=
"20dp"
android:src=
"@mipmap/ic_launcher"
/>
android:src=
"@mipmap/ic_launcher"
/>
<TextView
<TextView
android:id=
"@+id/tv_title"
android:id=
"@+id/tv_title"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"16dp"
android:layout_toEndOf=
"@id/iv"
android:layout_toEndOf=
"@id/iv"
android:text=
"@string/file_clean"
android:text=
"@string/file_clean"
android:textColor=
"@color/black"
android:textColor=
"@color/black"
android:textSize=
"
18
sp"
android:textSize=
"
20
sp"
android:textStyle=
"bold"
/>
android:textStyle=
"bold"
/>
<TextView
<TextView
...
@@ -36,8 +36,7 @@
...
@@ -36,8 +36,7 @@
<View
<View
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"1dp"
android:layout_height=
"1dp"
android:layout_below=
"@id/iv"
android:layout_alignParentBottom=
"true"
android:layout_marginTop=
"20dp"
android:background=
"@color/gray_01"
/>
android:background=
"@color/gray_01"
/>
<TextView
<TextView
...
@@ -45,6 +44,7 @@
...
@@ -45,6 +44,7 @@
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentEnd=
"true"
android:layout_alignParentEnd=
"true"
android:layout_centerVertical=
"true"
android:layout_centerVertical=
"true"
android:layout_marginEnd=
"20dp"
android:text=
">"
android:text=
">"
android:textSize=
"30sp"
/>
android:textSize=
"30sp"
/>
...
...
cleaner/app/src/main/res/values/strings.xml
View file @
622a8d13
...
@@ -21,7 +21,9 @@
...
@@ -21,7 +21,9 @@
<string
name=
"wifi"
>
wifi
</string>
<string
name=
"wifi"
>
wifi
</string>
<string
name=
"my"
>
我的
</string>
<string
name=
"my"
>
我的
</string>
<string
name=
"unknown"
>
未知
</string>
<string
name=
"file_clean"
>
文件清理
</string>
<string
name=
"file_clean"
>
文件清理
</string>
<string
name=
"bigFile_clean"
>
大文件清理
</string>
<string
name=
"music_clean"
>
音乐清理
</string>
<string
name=
"music_clean"
>
音乐清理
</string>
<string
name=
"album_clean"
>
相册清理
</string>
<string
name=
"album_clean"
>
相册清理
</string>
<string
name=
"apk_clean"
>
安装包清理
</string>
<string
name=
"apk_clean"
>
安装包清理
</string>
...
...
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