Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
D
Data Recovery White
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
Data Recovery White
Commits
801e9303
Commit
801e9303
authored
Jul 03, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...ui
parent
894540ad
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
154 additions
and
114 deletions
+154
-114
FileRecoveryActivity.kt
...va/com/base/datarecovery/activity/FileRecoveryActivity.kt
+57
-22
FileMediaColumnsAdapter.kt
.../com/base/datarecovery/adapter/FileMediaColumnsAdapter.kt
+5
-1
TimeUtils.kt
app/src/main/java/com/base/datarecovery/utils/TimeUtils.kt
+49
-0
PopupWindowViews.kt
.../main/java/com/base/datarecovery/view/PopupWindowViews.kt
+0
-51
activity_file_recovery.xml
app/src/main/res/layout/activity_file_recovery.xml
+41
-38
item_media_columns4.xml
app/src/main/res/layout/item_media_columns4.xml
+2
-2
No files found.
app/src/main/java/com/base/datarecovery/activity/FileRecoveryActivity.kt
View file @
801e9303
...
...
@@ -4,8 +4,6 @@ import android.annotation.SuppressLint
import
android.graphics.BitmapFactory
import
android.graphics.Color
import
android.view.View
import
android.widget.PopupWindow
import
android.widget.Toast
import
androidx.activity.addCallback
import
androidx.core.content.ContextCompat
import
androidx.core.view.isVisible
...
...
@@ -20,7 +18,9 @@ import com.base.datarecovery.databinding.ActivityFileRecoveryBinding
import
com.base.datarecovery.help.BaseActivity
import
com.base.datarecovery.help.KotlinExt.toFormatTime
import
com.base.datarecovery.utils.BarUtils
import
com.base.datarecovery.view.PopupWindowViews.showRecoveryFilterPopupWindow
import
com.base.datarecovery.utils.TimeUtils.isWithinOneMonth
import
com.base.datarecovery.utils.TimeUtils.isWithinSixMonths
import
com.base.datarecovery.utils.TimeUtils.isWithinTwentyFourMonths
import
com.google.gson.Gson
import
java.io.File
...
...
@@ -36,20 +36,20 @@ class FileRecoveryActivity : BaseActivity<ActivityFileRecoveryBinding>() {
private
lateinit
var
filterAdapter
:
RecoveryFilterAdapter
private
val
dateFilter
=
arrayListOf
(
private
val
dateFilter
List
=
arrayListOf
(
RecoveryFilterBean
(
"All"
,
"Size"
,
true
),
RecoveryFilterBean
(
"With 1 month"
,
"Date"
),
RecoveryFilterBean
(
"With 6 months"
,
"Date"
),
RecoveryFilterBean
(
"With 24 months"
,
"Date"
),
)
private
var
sizeFilter
=
arrayListOf
(
private
var
sizeFilter
List
=
arrayListOf
(
RecoveryFilterBean
(
"All"
,
"Size"
,
true
),
RecoveryFilterBean
(
"0 - 1 M"
,
"Size"
),
RecoveryFilterBean
(
"1 - 5 M"
,
"Size"
),
RecoveryFilterBean
(
"> 5 M"
,
"Size"
),
)
private
val
layoutFilter
=
arrayListOf
(
private
val
layoutFilter
List
=
arrayListOf
(
RecoveryFilterBean
(
"2 columns"
,
"Layout"
,
true
),
RecoveryFilterBean
(
"3 columns"
,
"Layout"
),
RecoveryFilterBean
(
"4 columns"
,
"Layout"
),
...
...
@@ -88,7 +88,7 @@ class FileRecoveryActivity : BaseActivity<ActivityFileRecoveryBinding>() {
}
adapter
=
FileMediaColumnsAdapter
(
2
,
adapter
=
FileMediaColumnsAdapter
(
select
=
{
all
,
size
->
binding
.
ivSelectAll
.
isSelected
=
all
binding
.
tvRecover
.
text
=
"Recover($size)"
...
...
@@ -143,19 +143,19 @@ class FileRecoveryActivity : BaseActivity<ActivityFileRecoveryBinding>() {
if
(
filter
==
R
.
id
.
ll_date
)
{
binding
.
ivDate
.
setImageResource
(
R
.
mipmap
.
zhankai
)
filterAdapter
.
setData
(
dateFilter
)
filterAdapter
.
setData
(
dateFilter
List
)
}
else
{
binding
.
ivDate
.
setImageResource
(
R
.
mipmap
.
shouqi
)
}
if
(
filter
==
R
.
id
.
ll_size
)
{
binding
.
ivSize
.
setImageResource
(
R
.
mipmap
.
zhankai
)
filterAdapter
.
setData
(
sizeFilter
)
filterAdapter
.
setData
(
sizeFilter
List
)
}
else
{
binding
.
ivSize
.
setImageResource
(
R
.
mipmap
.
shouqi
)
}
if
(
filter
==
R
.
id
.
ll_layout
)
{
binding
.
ivLayout
.
setImageResource
(
R
.
mipmap
.
zhankai
)
filterAdapter
.
setData
(
layoutFilter
)
filterAdapter
.
setData
(
layoutFilter
List
)
}
else
{
binding
.
ivLayout
.
setImageResource
(
R
.
mipmap
.
shouqi
)
}
...
...
@@ -170,18 +170,29 @@ class FileRecoveryActivity : BaseActivity<ActivityFileRecoveryBinding>() {
recoveryFilterBean
?.
let
{
bean
->
if
(
bean
.
type
==
"Date"
)
{
dateFilter
.
find
{
it
.
isSelect
}
?.
isSelect
=
false
dateFilter
.
find
{
it
==
bean
}
?.
isSelect
=
true
dateFilterList
.
find
{
it
.
isSelect
}
?.
isSelect
=
false
dateFilterList
.
find
{
it
==
bean
}
?.
isSelect
=
true
initData
()
return
}
if
(
bean
.
type
==
"Size"
)
{
sizeFilter
.
find
{
it
.
isSelect
}
?.
isSelect
=
false
sizeFilter
.
find
{
it
==
bean
}
?.
isSelect
=
true
sizeFilterList
.
find
{
it
.
isSelect
}
?.
isSelect
=
false
sizeFilterList
.
find
{
it
==
bean
}
?.
isSelect
=
true
initData
()
return
}
if
(
bean
.
type
==
"Layout"
)
{
layoutFilter
.
find
{
it
.
isSelect
}
?.
isSelect
=
false
layoutFilter
.
find
{
it
==
bean
}
?.
isSelect
=
true
layoutFilterList
.
find
{
it
.
isSelect
}
?.
isSelect
=
false
layoutFilterList
.
find
{
it
==
bean
}
?.
isSelect
=
true
val
index
=
layoutFilterList
.
indexOf
(
bean
)
val
columns
=
when
(
index
)
{
0
->
2
1
->
3
2
->
4
else
->
2
}
adapter
.
changeColumns
(
columns
)
}
}
...
...
@@ -190,11 +201,11 @@ class FileRecoveryActivity : BaseActivity<ActivityFileRecoveryBinding>() {
private
fun
initData
()
{
val
hash
=
HashMap
<
String
,
ArrayList
<
RecoveryBean
>>()
folderBean
?.
let
{
it
.
recoveryList
.
forEach
{
recoveryBean
->
if
(
dateFilter
(
recoveryBean
)
&&
sizeFilter
(
recoveryBean
))
{
val
file
=
File
(
recoveryBean
.
path
)
val
time
=
file
.
lastModified
().
toFormatTime
()
if
(
hash
[
time
].
isNullOrEmpty
())
{
...
...
@@ -202,6 +213,8 @@ class FileRecoveryActivity : BaseActivity<ActivityFileRecoveryBinding>() {
}
hash
[
time
]
?.
add
(
recoveryBean
)
}
}
}
val
list
=
arrayListOf
<
FolderBean
>()
hash
.
forEach
{
(
key
,
value
)
->
...
...
@@ -210,4 +223,26 @@ class FileRecoveryActivity : BaseActivity<ActivityFileRecoveryBinding>() {
adapter
.
setData
(
list
)
}
private
fun
dateFilter
(
recoveryBean
:
RecoveryBean
):
Boolean
{
val
index
=
dateFilterList
.
indexOfFirst
{
it
.
isSelect
}
return
when
(
index
)
{
1
->
isWithinOneMonth
(
File
(
recoveryBean
.
path
).
lastModified
())
2
->
isWithinSixMonths
(
File
(
recoveryBean
.
path
).
lastModified
())
3
->
isWithinTwentyFourMonths
(
File
(
recoveryBean
.
path
).
lastModified
())
else
->
true
}
}
private
fun
sizeFilter
(
recoveryBean
:
RecoveryBean
):
Boolean
{
val
oneMegabyte
=
1024
*
1024L
val
index
=
sizeFilterList
.
indexOfFirst
{
it
.
isSelect
}
return
when
(
index
)
{
1
->
File
(
recoveryBean
.
path
).
length
()
in
0L
..
oneMegabyte
2
->
File
(
recoveryBean
.
path
).
length
()
in
oneMegabyte
..
oneMegabyte
*
5
3
->
File
(
recoveryBean
.
path
).
length
()
>
oneMegabyte
*
5
else
->
true
}
}
}
\ No newline at end of file
app/src/main/java/com/base/datarecovery/adapter/FileMediaColumnsAdapter.kt
View file @
801e9303
...
...
@@ -18,12 +18,12 @@ import com.bumptech.glide.Glide
import
java.io.File
class
FileMediaColumnsAdapter
(
val
columns
:
Int
,
val
select
:
(
all
:
Boolean
,
size
:
Int
)
->
Unit
,
)
:
RecyclerView
.
Adapter
<
FileMediaColumnsAdapter
.
MCV
>()
{
private
val
beanList
=
arrayListOf
<
FolderBean
>()
private
var
hideThumbnails
:
Boolean
=
false
private
var
columns
:
Int
=
2
class
MCV
(
view
:
View
)
:
ViewHolder
(
view
)
...
...
@@ -177,4 +177,8 @@ class FileMediaColumnsAdapter(
notifyDataSetChanged
()
}
fun
changeColumns
(
columns
:
Int
)
{
this
.
columns
=
columns
notifyDataSetChanged
()
}
}
\ No newline at end of file
app/src/main/java/com/base/datarecovery/utils/TimeUtils.kt
0 → 100644
View file @
801e9303
package
com.base.datarecovery.utils
import
java.util.Calendar
object
TimeUtils
{
fun
isWithinOneMonth
(
pastTimestamp
:
Long
):
Boolean
{
val
calendar
=
Calendar
.
getInstance
()
val
currentTime
=
System
.
currentTimeMillis
()
// 将当前时间减去一个月
calendar
.
timeInMillis
=
currentTime
calendar
.
add
(
Calendar
.
MONTH
,
-
1
)
val
oneMonthAgo
=
calendar
.
timeInMillis
// 检查过去的时间戳是否在当前时间与一个月前之间
return
pastTimestamp
in
oneMonthAgo
..
currentTime
}
fun
isWithinSixMonths
(
pastTimestamp
:
Long
):
Boolean
{
val
calendar
=
Calendar
.
getInstance
()
// 获取当前时间的Calendar实例
val
currentTime
=
System
.
currentTimeMillis
()
// 获取当前时间的时间戳
// 设置calendar到当前时间
calendar
.
timeInMillis
=
currentTime
// 减去6个月
calendar
.
add
(
Calendar
.
MONTH
,
-
6
)
val
sixMonthsAgo
=
calendar
.
timeInMillis
// 计算6个月前的日期
// 检查过去的时间戳是否在6个月的范围内
return
pastTimestamp
in
sixMonthsAgo
..
currentTime
}
fun
isWithinTwentyFourMonths
(
timestamp
:
Long
):
Boolean
{
val
calendar
=
Calendar
.
getInstance
()
// 获取当前时间的Calendar实例
val
currentTime
=
System
.
currentTimeMillis
()
// 获取当前时间的时间戳
// 设置calendar到当前时间
calendar
.
timeInMillis
=
currentTime
// 减去24个月
calendar
.
add
(
Calendar
.
MONTH
,
-
24
)
val
twentyFourMonthsAgo
=
calendar
.
timeInMillis
// 计算24个月前的日期
// 检查时间戳是否在24个月的范围内
return
timestamp
in
twentyFourMonthsAgo
..
currentTime
}
}
\ No newline at end of file
app/src/main/java/com/base/datarecovery/view/PopupWindowViews.kt
deleted
100644 → 0
View file @
894540ad
package
com.base.datarecovery.view
import
android.graphics.Color
import
android.graphics.drawable.ColorDrawable
import
android.view.View
import
android.widget.FrameLayout
import
android.widget.PopupWindow
import
androidx.recyclerview.widget.RecyclerView.Adapter
import
androidx.recyclerview.widget.RecyclerView.ViewHolder
import
com.base.datarecovery.R
import
com.base.datarecovery.adapter.RecoveryFilterAdapter
import
com.base.datarecovery.bean.RecoveryFilterBean
import
com.base.datarecovery.databinding.PopupwindowRecoveryFilterBinding
import
com.base.datarecovery.view.XmlEx.inflate
object
PopupWindowViews
{
fun
showRecoveryFilterPopupWindow
(
view
:
View
,
list
:
List
<
RecoveryFilterBean
>,
click
:
(
bean
:
RecoveryFilterBean
)
->
Unit
,
dismiss
:
()
->
Unit
):
PopupWindow
{
val
popupWindowView
=
R
.
layout
.
popupwindow_recovery_filter
.
inflate
(
view
.
context
)
val
popupWindowHeight
=
FrameLayout
.
LayoutParams
.
WRAP_CONTENT
val
binding
=
PopupwindowRecoveryFilterBinding
.
bind
(
popupWindowView
)
val
popupWindow
=
PopupWindow
(
popupWindowView
,
view
.
width
,
popupWindowHeight
,
true
)
popupWindow
.
setBackgroundDrawable
(
ColorDrawable
(
Color
.
TRANSPARENT
))
popupWindow
.
isOutsideTouchable
=
false
popupWindow
.
isTouchable
=
true
val
adapter
=
RecoveryFilterAdapter
{
click
.
invoke
(
it
)
popupWindow
.
dismiss
()
}
binding
.
rv
.
adapter
=
adapter
adapter
.
setData
(
list
)
popupWindow
.
showAsDropDown
(
view
)
popupWindow
.
setOnDismissListener
{
dismiss
.
invoke
()
}
return
popupWindow
}
}
\ No newline at end of file
app/src/main/res/layout/activity_file_recovery.xml
View file @
801e9303
...
...
@@ -161,13 +161,8 @@
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/cl_top"
>
<LinearLayout
android:id=
"@+id/ll_all_select"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginHorizontal=
"16dp"
...
...
@@ -175,6 +170,7 @@
android:orientation=
"horizontal"
android:paddingTop=
"20dp"
android:paddingBottom=
"10dp"
app:layout_constraintTop_toBottomOf=
"@id/cl_top"
app:layout_scrollFlags=
"scroll|enterAlways"
>
<ImageView
...
...
@@ -205,6 +201,13 @@
tools:ignore=
"ContentDescription"
/>
</LinearLayout>
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/ll_all_select"
>
<com.google.android.material.appbar.AppBarLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
...
...
app/src/main/res/layout/item_media_columns4.xml
View file @
801e9303
...
...
@@ -2,8 +2,8 @@
<androidx.cardview.widget.CardView
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"
android:layout_width=
"
10
5dp"
android:layout_height=
"
10
5dp"
android:layout_width=
"
8
5dp"
android:layout_height=
"
8
5dp"
android:layout_margin=
"8dp"
app:cardCornerRadius=
"12.5dp"
>
...
...
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