Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
F
File Recovery RecycleBin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wanglei
File Recovery RecycleBin
Commits
fbf33e18
Commit
fbf33e18
authored
Jul 17, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
cc2dbc40
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
96 additions
and
28 deletions
+96
-28
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+3
-1
MainActivity.kt
.../com/base/filerecoveryrecyclebin/activity/MainActivity.kt
+2
-1
MeidaContentObserver.kt
...eryrecyclebin/activity/recyclebin/MeidaContentObserver.kt
+19
-9
RecycleBinAdapter.kt
.../base/filerecoveryrecyclebin/adapter/RecycleBinAdapter.kt
+3
-4
RecycleBinFragment.kt
...ase/filerecoveryrecyclebin/fragment/RecycleBinFragment.kt
+23
-2
StayNotificationService.kt
...filerecoveryrecyclebin/service/StayNotificationService.kt
+0
-1
fragment_home_3.xml
app/src/main/res/layout/fragment_home_3.xml
+0
-5
fragment_recycle_bin.xml
app/src/main/res/layout/fragment_recycle_bin.xml
+46
-5
gengduo.png
app/src/main/res/mipmap-xxhdpi/gengduo.png
+0
-0
No files found.
app/src/main/AndroidManifest.xml
View file @
fbf33e18
...
@@ -195,7 +195,9 @@
...
@@ -195,7 +195,9 @@
<receiver
<receiver
android:name=
".fcm.CloseNotificationReceiver"
android:name=
".fcm.CloseNotificationReceiver"
android:exported=
"false"
/>
<!-- 添加以下接收器 -->
android:exported=
"false"
/>
<!-- 添加以下接收器 -->
<!-- 注册广播 -->
<!-- 注册广播 -->
<receiver
<receiver
android:name=
".fcm.FcmReceiver"
android:name=
".fcm.FcmReceiver"
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/activity/MainActivity.kt
View file @
fbf33e18
...
@@ -2,6 +2,7 @@ package com.base.filerecoveryrecyclebin.activity
...
@@ -2,6 +2,7 @@ package com.base.filerecoveryrecyclebin.activity
import
android.graphics.Color
import
android.graphics.Color
import
android.graphics.Typeface
import
android.graphics.Typeface
import
androidx.core.view.updatePadding
import
androidx.fragment.app.Fragment
import
androidx.fragment.app.Fragment
import
androidx.lifecycle.lifecycleScope
import
androidx.lifecycle.lifecycleScope
import
androidx.viewpager2.adapter.FragmentStateAdapter
import
androidx.viewpager2.adapter.FragmentStateAdapter
...
@@ -40,7 +41,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
...
@@ -40,7 +41,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
override
fun
initView
()
{
override
fun
initView
()
{
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
())
// showRateStarPopDialog()
// showRateStarPopDialog()
// showExitFunctionDialog()
// showExitFunctionDialog()
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/activity/recyclebin/MeidaContentObserver.kt
View file @
fbf33e18
...
@@ -20,6 +20,7 @@ class MediaContentObserver(val context: Context, val handler: Handler? = null) :
...
@@ -20,6 +20,7 @@ class MediaContentObserver(val context: Context, val handler: Handler? = null) :
override
fun
onChange
(
selfChange
:
Boolean
,
uri
:
Uri
?)
{
override
fun
onChange
(
selfChange
:
Boolean
,
uri
:
Uri
?)
{
super
.
onChange
(
selfChange
,
uri
)
super
.
onChange
(
selfChange
,
uri
)
LogEx
.
logDebug
(
TAG
,
"uri=${uri.toString()}"
)
uri
?.
let
{
queryNewMediaFiles
(
it
)
}
uri
?.
let
{
queryNewMediaFiles
(
it
)
}
}
}
...
@@ -30,6 +31,7 @@ class MediaContentObserver(val context: Context, val handler: Handler? = null) :
...
@@ -30,6 +31,7 @@ class MediaContentObserver(val context: Context, val handler: Handler? = null) :
MediaStore
.
MediaColumns
.
DISPLAY_NAME
,
MediaStore
.
MediaColumns
.
DISPLAY_NAME
,
MediaStore
.
MediaColumns
.
DATA
,
MediaStore
.
MediaColumns
.
DATA
,
MediaStore
.
MediaColumns
.
MIME_TYPE
,
MediaStore
.
MediaColumns
.
MIME_TYPE
,
MediaStore
.
MediaColumns
.
SIZE
,
)
)
val
cursor
:
Cursor
?
=
context
.
contentResolver
.
query
(
uri
,
projection
,
null
,
null
,
null
)
val
cursor
:
Cursor
?
=
context
.
contentResolver
.
query
(
uri
,
projection
,
null
,
null
,
null
)
...
@@ -39,6 +41,7 @@ class MediaContentObserver(val context: Context, val handler: Handler? = null) :
...
@@ -39,6 +41,7 @@ class MediaContentObserver(val context: Context, val handler: Handler? = null) :
val
name
=
cursor
.
getString
(
cursor
.
getColumnIndex
(
MediaStore
.
MediaColumns
.
DISPLAY_NAME
))
val
name
=
cursor
.
getString
(
cursor
.
getColumnIndex
(
MediaStore
.
MediaColumns
.
DISPLAY_NAME
))
val
path
=
cursor
.
getString
(
cursor
.
getColumnIndex
(
MediaStore
.
MediaColumns
.
DATA
))
val
path
=
cursor
.
getString
(
cursor
.
getColumnIndex
(
MediaStore
.
MediaColumns
.
DATA
))
val
mimeType
=
cursor
.
getString
(
cursor
.
getColumnIndex
(
MediaStore
.
MediaColumns
.
MIME_TYPE
))
val
mimeType
=
cursor
.
getString
(
cursor
.
getColumnIndex
(
MediaStore
.
MediaColumns
.
MIME_TYPE
))
val
size
=
cursor
.
getString
(
cursor
.
getColumnIndex
(
MediaStore
.
MediaColumns
.
SIZE
))
// 处理新文件路径
// 处理新文件路径
backupRecycleBinFile
(
name
,
path
,
mimeType
)
backupRecycleBinFile
(
name
,
path
,
mimeType
)
}
}
...
@@ -52,7 +55,9 @@ class MediaContentObserver(val context: Context, val handler: Handler? = null) :
...
@@ -52,7 +55,9 @@ class MediaContentObserver(val context: Context, val handler: Handler? = null) :
}
}
private
fun
backupRecycleBinFile
(
name
:
String
,
path
:
String
,
mimeType
:
String
)
{
private
fun
backupRecycleBinFile
(
name
:
String
,
path
:
String
,
mimeType
:
String
)
{
LogEx
.
logDebug
(
TAG
,
"name=$name path=$path mimeType=$mimeType"
)
val
src
=
File
(
path
)
LogEx
.
logDebug
(
TAG
,
"name=$name path=$path mimeType=$mimeType size=${src.length()}"
)
val
file
=
context
.
filesDir
val
file
=
context
.
filesDir
val
recycleBinDir
=
File
(
file
,
"RecycleBin"
)
val
recycleBinDir
=
File
(
file
,
"RecycleBin"
)
...
@@ -60,16 +65,21 @@ class MediaContentObserver(val context: Context, val handler: Handler? = null) :
...
@@ -60,16 +65,21 @@ class MediaContentObserver(val context: Context, val handler: Handler? = null) :
recycleBinDir
.
mkdirs
()
recycleBinDir
.
mkdirs
()
}
}
val
src
=
File
(
path
)
val
recycleBinFile
=
File
(
recycleBinDir
,
".$name"
)
val
recycleBinFile
=
File
(
recycleBinDir
,
".$name"
)
if
(!
recycleBinFile
.
exists
())
{
if
(!
recycleBinFile
.
exists
())
{
src
.
copyTo
(
recycleBinFile
,
true
)
recycleBinFile
.
createNewFile
()
val
binBean
=
RecycleBinBean
(
src
.
path
,
0
,
src
.
length
(),
mimeType
)
}
else
{
val
binFile
=
File
(
recycleBinDir
,
".$name.bin"
)
if
(
recycleBinFile
.
length
()==
0L
){
binFile
.
createNewFile
()
src
.
copyTo
(
recycleBinFile
,
true
)
binFile
.
writeText
(
Gson
().
toJson
(
binBean
))
LogEx
.
logDebug
(
TAG
,
"size=${src.length()}"
)
LogEx
.
logDebug
(
TAG
,
"回收站备份成功"
)
val
binBean
=
RecycleBinBean
(
src
.
path
,
0
,
src
.
length
(),
mimeType
)
handler
?.
sendEmptyMessage
(
99
)
val
binFile
=
File
(
recycleBinDir
,
".$name.bin"
)
binFile
.
createNewFile
()
binFile
.
writeText
(
Gson
().
toJson
(
binBean
))
LogEx
.
logDebug
(
TAG
,
"回收站备份成功"
)
handler
?.
sendEmptyMessage
(
99
)
}
}
}
}
}
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/adapter/RecycleBinAdapter.kt
View file @
fbf33e18
...
@@ -7,9 +7,8 @@ import androidx.recyclerview.widget.RecyclerView
...
@@ -7,9 +7,8 @@ import androidx.recyclerview.widget.RecyclerView
import
androidx.recyclerview.widget.RecyclerView.ViewHolder
import
androidx.recyclerview.widget.RecyclerView.ViewHolder
import
com.base.filerecoveryrecyclebin.R
import
com.base.filerecoveryrecyclebin.R
import
com.base.filerecoveryrecyclebin.bean.RecycleBinBean
import
com.base.filerecoveryrecyclebin.bean.RecycleBinBean
import
com.base.filerecoveryrecyclebin.databinding.ItemMediaFileBinding
import
com.base.filerecoveryrecyclebin.databinding.ItemRecycleBinBeanBinding
import
com.base.filerecoveryrecyclebin.databinding.ItemRecyclebinFileBinding
import
com.base.filerecoveryrecyclebin.databinding.ItemRecyclebinFileBinding
import
com.base.filerecoveryrecyclebin.help.KotlinExt.toFormatSize
import
com.base.filerecoveryrecyclebin.help.KotlinExt.toFormatTime
import
com.base.filerecoveryrecyclebin.help.KotlinExt.toFormatTime
import
com.base.filerecoveryrecyclebin.view.XmlEx.inflate
import
com.base.filerecoveryrecyclebin.view.XmlEx.inflate
import
com.bumptech.glide.Glide
import
com.bumptech.glide.Glide
...
@@ -40,8 +39,8 @@ class RecycleBinAdapter : RecyclerView.Adapter<RecycleBinAdapter.RBAV>() {
...
@@ -40,8 +39,8 @@ class RecycleBinAdapter : RecyclerView.Adapter<RecycleBinAdapter.RBAV>() {
val
context
=
holder
.
itemView
.
context
val
context
=
holder
.
itemView
.
context
Glide
.
with
(
context
).
load
(
bean
.
path
).
centerCrop
().
into
(
binding
.
iv
)
Glide
.
with
(
context
).
load
(
bean
.
path
).
centerCrop
().
into
(
binding
.
iv
)
binding
.
tvName
.
text
=
file
.
name
binding
.
tvName
.
text
=
file
.
name
binding
.
tvTime
.
text
=
"delete time:"
+
bean
.
deleteTime
.
to
String
()
binding
.
tvTime
.
text
=
"delete time:"
+
bean
.
deleteTime
.
to
FormatTime
()
binding
.
tvSize
.
text
=
bean
.
size
.
toFormat
Tim
e
()
binding
.
tvSize
.
text
=
bean
.
size
.
toFormat
Siz
e
()
}
}
@SuppressLint
(
"NotifyDataSetChanged"
)
@SuppressLint
(
"NotifyDataSetChanged"
)
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/fragment/RecycleBinFragment.kt
View file @
fbf33e18
...
@@ -18,6 +18,7 @@ import com.base.filerecoveryrecyclebin.utils.LogEx
...
@@ -18,6 +18,7 @@ import com.base.filerecoveryrecyclebin.utils.LogEx
import
com.base.filerecoveryrecyclebin.view.DialogViews.showGerPermission
import
com.base.filerecoveryrecyclebin.view.DialogViews.showGerPermission
import
com.google.gson.Gson
import
com.google.gson.Gson
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.delay
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.launch
import
java.io.File
import
java.io.File
...
@@ -36,9 +37,11 @@ class RecycleBinFragment : BaseFragment<FragmentRecycleBinBinding>() {
...
@@ -36,9 +37,11 @@ class RecycleBinFragment : BaseFragment<FragmentRecycleBinBinding>() {
handler
=
Handler
(
requireActivity
().
mainLooper
)
{
message
->
handler
=
Handler
(
requireActivity
().
mainLooper
)
{
message
->
if
(
message
.
what
==
99
)
{
if
(
message
.
what
==
99
)
{
// LogEx.logDebug(TAG, "媒体库更新了")
// LogEx.logDebug(TAG, "媒体库更新了")
initData
()
}
}
if
(
message
.
what
==
100
)
{
if
(
message
.
what
==
100
)
{
// LogEx.logDebug(TAG, "回收站数据更新了")
// LogEx.logDebug(TAG, "回收站数据更新了")
initData
()
}
}
true
true
}
}
...
@@ -68,6 +71,21 @@ class RecycleBinFragment : BaseFragment<FragmentRecycleBinBinding>() {
...
@@ -68,6 +71,21 @@ class RecycleBinFragment : BaseFragment<FragmentRecycleBinBinding>() {
}
}
}
}
override
fun
setListener
()
{
super
.
setListener
()
binding
.
flGengduo
.
setOnClickListener
{
}
binding
.
swipeRefreshLayout
.
setOnRefreshListener
{
binding
.
swipeRefreshLayout
.
isRefreshing
=
true
initData
()
lifecycleScope
.
launch
(
Dispatchers
.
Main
)
{
delay
(
1000
)
binding
.
swipeRefreshLayout
.
isRefreshing
=
false
}
}
}
private
fun
initData
()
{
private
fun
initData
()
{
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
val
file
=
requireActivity
().
filesDir
val
file
=
requireActivity
().
filesDir
...
@@ -78,12 +96,15 @@ class RecycleBinFragment : BaseFragment<FragmentRecycleBinBinding>() {
...
@@ -78,12 +96,15 @@ class RecycleBinFragment : BaseFragment<FragmentRecycleBinBinding>() {
val
binList
=
recycleBinDir
.
listFiles
()
?.
filter
{
it
.
name
.
contains
(
".bin"
)
}
val
binList
=
recycleBinDir
.
listFiles
()
?.
filter
{
it
.
name
.
contains
(
".bin"
)
}
val
beanList
=
arrayListOf
<
RecycleBinBean
>()
val
beanList
=
arrayListOf
<
RecycleBinBean
>()
binList
?.
forEach
{
binList
?.
forEach
{
LogEx
.
logDebug
(
TAG
,
it
.
absolutePath
)
val
bean
=
Gson
().
fromJson
(
it
.
readText
(),
RecycleBinBean
::
class
.
java
)
val
bean
=
Gson
().
fromJson
(
it
.
readText
(),
RecycleBinBean
::
class
.
java
)
beanList
.
add
(
bean
)
beanList
.
add
(
bean
)
}
}
val
deleteFile
=
beanList
.
filter
{
it
.
deleted
}
// val deleteFile = beanList
launch
(
Dispatchers
.
Main
)
{
launch
(
Dispatchers
.
Main
)
{
binding
.
rv
.
isVisible
=
!
binList
.
isNullOr
Empty
()
binding
.
rv
.
isVisible
=
deleteFile
.
isNot
Empty
()
binding
.
llEmpty
.
isVisible
=
binList
.
isNullOr
Empty
()
binding
.
llEmpty
.
isVisible
=
deleteFile
.
is
Empty
()
recycleBinAdapter
.
setData
(
beanList
)
recycleBinAdapter
.
setData
(
beanList
)
}
}
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/service/StayNotificationService.kt
View file @
fbf33e18
...
@@ -111,7 +111,6 @@ class StayNotificationService : Service() {
...
@@ -111,7 +111,6 @@ class StayNotificationService : Service() {
if
(
myFileObserver
==
null
)
{
if
(
myFileObserver
==
null
)
{
val
dcimList
=
FileHelp
.
getFileFolder
(
Environment
.
getExternalStoragePublicDirectory
(
Environment
.
DIRECTORY_DCIM
))
val
dcimList
=
FileHelp
.
getFileFolder
(
Environment
.
getExternalStoragePublicDirectory
(
Environment
.
DIRECTORY_DCIM
))
val
watchList
=
arrayListOf
<
File
>()
val
watchList
=
arrayListOf
<
File
>()
watchList
.
addAll
(
dcimList
)
watchList
.
addAll
(
dcimList
)
watchList
.
forEach
{
watchList
.
forEach
{
...
...
app/src/main/res/layout/fragment_home_3.xml
View file @
fbf33e18
...
@@ -8,11 +8,6 @@
...
@@ -8,11 +8,6 @@
android:orientation=
"vertical"
android:orientation=
"vertical"
tools:context=
".fragment.HomeFragment"
>
tools:context=
".fragment.HomeFragment"
>
<View
android:layout_width=
"match_parent"
android:layout_height=
"40dp"
app:layout_constraintTop_toTopOf=
"parent"
/>
<androidx.core.widget.NestedScrollView
<androidx.core.widget.NestedScrollView
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
android:layout_height=
"wrap_content"
>
...
...
app/src/main/res/layout/fragment_recycle_bin.xml
View file @
fbf33e18
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<FrameLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
...
@@ -7,13 +8,53 @@
...
@@ -7,13 +8,53 @@
<LinearLayout
<LinearLayout
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
>
<androidx.recyclerview.widget.RecyclerView
<FrameLayout
android:id=
"@+id/rv"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"wrap_content"
>
tools:listitem=
"@layout/item_media_file"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_marginStart=
"18dp"
android:text=
"RecycleBin"
android:textColor=
"@color/black"
android:textSize=
"19sp"
android:textStyle=
"bold"
tools:ignore=
"HardcodedText"
/>
<FrameLayout
android:id=
"@+id/fl_gengduo"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical|end"
android:padding=
"18dp"
>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:src=
"@mipmap/gengduo"
tools:ignore=
"ContentDescription"
/>
</FrameLayout>
</FrameLayout>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id=
"@+id/swipeRefreshLayout"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rv"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
app:layoutManager=
"androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem=
"@layout/item_media_file"
/>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</LinearLayout>
</LinearLayout>
...
...
app/src/main/res/mipmap-xxhdpi/gengduo.png
0 → 100644
View file @
fbf33e18
1.32 KB
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment