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
7602108d
Commit
7602108d
authored
Jul 19, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
b3324d55
0ff270d3
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
8 deletions
+7
-8
MeidaContentObserver.kt
...eryrecyclebin/activity/recyclebin/MeidaContentObserver.kt
+1
-2
MyFileObserver.kt
...erecoveryrecyclebin/activity/recyclebin/MyFileObserver.kt
+1
-2
RecycleBinFragment.kt
...ase/filerecoveryrecyclebin/fragment/RecycleBinFragment.kt
+3
-1
StayNotificationService.kt
...filerecoveryrecyclebin/service/StayNotificationService.kt
+2
-3
No files found.
app/src/main/java/com/base/filerecoveryrecyclebin/activity/recyclebin/MeidaContentObserver.kt
View file @
7602108d
...
@@ -16,7 +16,7 @@ import java.io.File
...
@@ -16,7 +16,7 @@ import java.io.File
/**
/**
* Observer MediaContent add
* Observer MediaContent add
*/
*/
class
MediaContentObserver
(
val
context
:
Context
,
val
handler
:
Handler
?
=
null
)
:
ContentObserver
(
null
)
{
class
MediaContentObserver
(
val
context
:
Context
)
:
ContentObserver
(
null
)
{
private
val
TAG
=
"MediaContentObserver"
private
val
TAG
=
"MediaContentObserver"
...
@@ -84,7 +84,6 @@ class MediaContentObserver(val context: Context, val handler: Handler? = null) :
...
@@ -84,7 +84,6 @@ class MediaContentObserver(val context: Context, val handler: Handler? = null) :
binFile
.
createNewFile
()
binFile
.
createNewFile
()
binFile
.
writeText
(
Gson
().
toJson
(
binBean
))
binFile
.
writeText
(
Gson
().
toJson
(
binBean
))
LogEx
.
logDebug
(
TAG
,
"RecycleBin backup"
)
LogEx
.
logDebug
(
TAG
,
"RecycleBin backup"
)
handler
?.
sendEmptyMessage
(
99
)
}
}
}
}
}
}
app/src/main/java/com/base/filerecoveryrecyclebin/activity/recyclebin/MyFileObserver.kt
View file @
7602108d
...
@@ -13,7 +13,7 @@ import com.google.gson.Gson
...
@@ -13,7 +13,7 @@ import com.google.gson.Gson
import
java.io.File
import
java.io.File
@RequiresApi
(
Build
.
VERSION_CODES
.
Q
)
@RequiresApi
(
Build
.
VERSION_CODES
.
Q
)
class
MyFileObserver
(
val
handler
:
Handler
?
=
null
,
files
:
List
<
File
>)
:
FileObserver
(
files
,
ALL_EVENTS
)
{
class
MyFileObserver
(
files
:
List
<
File
>)
:
FileObserver
(
files
,
ALL_EVENTS
)
{
private
val
TAG
=
"MyFileObserver"
private
val
TAG
=
"MyFileObserver"
...
@@ -75,7 +75,6 @@ class MyFileObserver(val handler: Handler? = null, files: List<File>) : FileObse
...
@@ -75,7 +75,6 @@ class MyFileObserver(val handler: Handler? = null, files: List<File>) : FileObse
val
wJson
=
Gson
().
toJson
(
bean
)
val
wJson
=
Gson
().
toJson
(
bean
)
recycleBinJsonFile
.
writeText
(
wJson
)
recycleBinJsonFile
.
writeText
(
wJson
)
LogEx
.
logDebug
(
TAG
,
"writeText wJson=$wJson"
)
LogEx
.
logDebug
(
TAG
,
"writeText wJson=$wJson"
)
handler
?.
sendEmptyMessage
(
100
)
}
}
}
}
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/fragment/RecycleBinFragment.kt
View file @
7602108d
...
@@ -111,9 +111,11 @@ class RecycleBinFragment : BaseFragment<FragmentRecycleBinBinding>() {
...
@@ -111,9 +111,11 @@ class RecycleBinFragment : BaseFragment<FragmentRecycleBinBinding>() {
super
.
onResume
()
super
.
onResume
()
LogEx
.
logDebug
(
TAG
,
"onResume"
)
LogEx
.
logDebug
(
TAG
,
"onResume"
)
if
(
requireContext
().
checkStorePermission
())
{
if
(
requireContext
().
checkStorePermission
())
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
Q
)
{
initData
()
initData
()
}
}
}
}
}
override
fun
onPause
()
{
override
fun
onPause
()
{
super
.
onPause
()
super
.
onPause
()
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/service/StayNotificationService.kt
View file @
7602108d
...
@@ -46,7 +46,6 @@ class StayNotificationService : Service() {
...
@@ -46,7 +46,6 @@ class StayNotificationService : Service() {
const
val
FILE_OBSERVER_ACTION
=
"file_observer_action"
const
val
FILE_OBSERVER_ACTION
=
"file_observer_action"
var
isRunning
=
false
var
isRunning
=
false
var
mainHandler
:
Handler
?
=
null
fun
Context
.
startStayNotification
()
{
fun
Context
.
startStayNotification
()
{
if
(
Build
.
VERSION
.
SDK_INT
>
Build
.
VERSION_CODES
.
TIRAMISU
)
{
if
(
Build
.
VERSION
.
SDK_INT
>
Build
.
VERSION_CODES
.
TIRAMISU
)
{
...
@@ -88,7 +87,7 @@ class StayNotificationService : Service() {
...
@@ -88,7 +87,7 @@ class StayNotificationService : Service() {
private
fun
observerMediaContentObserver
()
{
private
fun
observerMediaContentObserver
()
{
if
(
mediaContentObserver
==
null
)
{
if
(
mediaContentObserver
==
null
)
{
LogEx
.
logDebug
(
TAG
,
"observerMediaContentObserver"
)
LogEx
.
logDebug
(
TAG
,
"observerMediaContentObserver"
)
mediaContentObserver
=
MediaContentObserver
(
this
,
mainHandler
)
mediaContentObserver
=
MediaContentObserver
(
this
)
mediaContentObserver
?.
let
{
mediaContentObserver
?.
let
{
this
.
contentResolver
.
registerContentObserver
(
this
.
contentResolver
.
registerContentObserver
(
MediaStore
.
Images
.
Media
.
EXTERNAL_CONTENT_URI
,
true
,
it
MediaStore
.
Images
.
Media
.
EXTERNAL_CONTENT_URI
,
true
,
it
...
@@ -122,7 +121,7 @@ class StayNotificationService : Service() {
...
@@ -122,7 +121,7 @@ class StayNotificationService : Service() {
watchList
.
forEach
{
watchList
.
forEach
{
LogEx
.
logDebug
(
TAG
,
"watchList=${it.absolutePath}"
)
LogEx
.
logDebug
(
TAG
,
"watchList=${it.absolutePath}"
)
}
}
myFileObserver
=
MyFileObserver
(
handler
=
mainHandler
,
watchList
)
myFileObserver
=
MyFileObserver
(
watchList
)
LogEx
.
logDebug
(
TAG
,
"watchList=${dcimList.size}"
)
LogEx
.
logDebug
(
TAG
,
"watchList=${dcimList.size}"
)
myFileObserver
?.
startWatching
()
myFileObserver
?.
startWatching
()
}
}
...
...
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