Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
S
scanqrwhitecopy
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
scanqrwhitecopy
Commits
afaef8d1
Commit
afaef8d1
authored
Jan 22, 2025
by
wanglei
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
817b40e3
34704608
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
41 deletions
+43
-41
ActivityJumpHelps.kt
.../main/java/com/base/scanqrclear/luma/ActivityJumpHelps.kt
+1
-1
HomeFragment.kt
app/src/main/java/com/base/scanqrclear/luma/HomeFragment.kt
+41
-39
item_function_2.xml
app/src/main/res/layout/item_function_2.xml
+1
-1
No files found.
app/src/main/java/com/base/scanqrclear/luma/ActivityJumpHelps.kt
View file @
afaef8d1
...
@@ -73,7 +73,7 @@ object ActivityJumpHelps {
...
@@ -73,7 +73,7 @@ object ActivityJumpHelps {
fun
requestPermission
(
fun
requestPermission
(
context
:
Context
,
context
:
Context
,
launcher
:
ActivityLauncher
,
launcher
:
ActivityLauncher
,
block
:
(()
->
Unit
?
)?
=
null
block
:
(()
->
Unit
)?
=
null
)
{
)
{
if
(
PermissionHelps
.
checkFilesAccessPermission
(
context
))
{
if
(
PermissionHelps
.
checkFilesAccessPermission
(
context
))
{
block
?.
invoke
()
block
?.
invoke
()
...
...
app/src/main/java/com/base/scanqrclear/luma/HomeFragment.kt
View file @
afaef8d1
...
@@ -124,47 +124,49 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(FragmentHomeBinding::infl
...
@@ -124,47 +124,49 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(FragmentHomeBinding::infl
}
}
private
fun
initData
()
{
private
fun
initData
()
{
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
ActivityJumpHelps
.
requestPermission
(
requireContext
(),
launcher
)
{
val
totalStorage
=
async
{
AppHelps
.
getTotalExternalSize
()
}
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
val
availableStorage
=
async
{
AppHelps
.
getAvailableExternalSize
()
}
val
totalStorage
=
async
{
AppHelps
.
getTotalExternalSize
()
}
val
totalStorageSize
=
totalStorage
.
await
()
val
availableStorage
=
async
{
AppHelps
.
getAvailableExternalSize
()
}
val
availableStorageSize
=
availableStorage
.
await
()
val
totalStorageSize
=
totalStorage
.
await
()
val
usedMemoryStorageSize
=
totalStorageSize
-
availableStorageSize
val
availableStorageSize
=
availableStorage
.
await
()
val
usedMemoryStorageScale
=
usedMemoryStorageSize
*
100
/
totalStorageSize
val
usedMemoryStorageSize
=
totalStorageSize
-
availableStorageSize
val
usedMemoryStorageScale
=
usedMemoryStorageSize
*
100
/
totalStorageSize
val
totalMemoryUsed
=
async
{
AppHelps
.
getMemTotal
(
requireContext
())
}
val
totalMemoryUsed
=
async
{
AppHelps
.
getMemTotal
(
requireContext
())
}
val
availableMemoryUsed
=
async
{
AppHelps
.
getMemAvailable
(
requireContext
())
}
val
availableMemoryUsed
=
async
{
AppHelps
.
getMemAvailable
(
requireContext
())
}
val
totalMemoryUsedSize
=
totalMemoryUsed
.
await
()
val
totalMemoryUsedSize
=
totalMemoryUsed
.
await
()
val
availableMemoryUsedSize
=
availableMemoryUsed
.
await
()
val
availableMemoryUsedSize
=
availableMemoryUsed
.
await
()
val
usedMemoryUsedSize
=
totalMemoryUsedSize
-
availableMemoryUsedSize
val
usedMemoryUsedSize
=
totalMemoryUsedSize
-
availableMemoryUsedSize
val
usedMemoryUsedScale
:
Long
=
usedMemoryUsedSize
*
100
/
totalMemoryUsedSize
val
usedMemoryUsedScale
:
Long
=
usedMemoryUsedSize
*
100
/
totalMemoryUsedSize
withContext
(
Dispatchers
.
Main
)
{
withContext
(
Dispatchers
.
Main
)
{
binding
.
tvStorageUsed
.
text
=
"${usedMemoryStorageScale.toInt()}%"
binding
.
tvStorageUsed
.
text
=
"${usedMemoryStorageScale.toInt()}%"
binding
.
tvMemoryUsed
.
text
=
"${usedMemoryUsedScale.toInt()}%"
binding
.
tvMemoryUsed
.
text
=
"${usedMemoryUsedScale.toInt()}%"
binding
.
llStorageUsed
.
visibility
=
View
.
VISIBLE
binding
.
llStorageUsed
.
visibility
=
View
.
VISIBLE
binding
.
llMemoryUsed
.
visibility
=
View
.
VISIBLE
binding
.
llMemoryUsed
.
visibility
=
View
.
VISIBLE
AnimationHelps
.
progress
(
binding
.
pbStorageUsed
,
usedMemoryStorageScale
.
toInt
())
AnimationHelps
.
progress
(
binding
.
pbStorageUsed
,
usedMemoryStorageScale
.
toInt
())
AnimationHelps
.
progress
(
binding
.
pbMemoryUsed
,
usedMemoryUsedScale
.
toInt
())
AnimationHelps
.
progress
(
binding
.
pbMemoryUsed
,
usedMemoryUsedScale
.
toInt
())
}
}
}
}
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
val
emptyFoldersDeferred
=
async
{
FileHelps
.
findEmptyFolders
(
lifecycleScope
)
}
val
emptyFoldersDeferred
=
async
{
FileHelps
.
findEmptyFolders
(
lifecycleScope
)
}
val
filesDeferred
=
async
{
MediaHelps
.
findSpecifiedFiles
(
requireContext
()
)
}
val
filesDeferred
=
async
{
MediaHelps
.
findSpecifiedFiles
(
requireContext
())
}
val
emptyFolder
=
emptyFoldersDeferred
.
await
()
val
emptyFolder
=
emptyFolder
sDeferred
.
await
()
val
files
=
file
sDeferred
.
await
()
val
files
=
filesDeferred
.
await
()
val
emptyLength
=
emptyFolder
.
sumOf
{
it
.
length
}
val
emptyLength
=
emptyFolder
.
sumOf
{
it
.
length
}
val
filesLength
=
files
.
sumOf
{
it
.
length
}
val
filesLength
=
files
.
sumOf
{
it
.
length
}
val
totalLength
=
emptyLength
+
filesLength
val
totalLength
=
emptyLength
+
filesLength
val
totalSize
=
Utils
.
getSize
(
totalLength
)
val
totalSize
=
Utils
.
getSize
(
totalLength
)
withContext
(
Dispatchers
.
Main
)
{
withContext
(
Dispatchers
.
Main
)
{
val
sp
=
SpannableString
(
"$totalSize\n${getString(R.string.junk_files)}"
)
val
sp
=
SpannableString
(
"$totalSize\n${getString(R.string.junk_files)}"
)
sp
.
setSpan
(
sp
.
setSpan
(
AbsoluteSizeSpan
(
16
,
true
),
AbsoluteSizeSpan
(
16
,
true
),
sp
.
indexOf
(
"\n"
),
sp
.
indexOf
(
"\n"
)
,
sp
.
length
,
sp
.
length
,
SpannableString
.
SPAN_EXCLUSIVE_EXCLUSIVE
SpannableString
.
SPAN_EXCLUSIVE_EXCLUSIVE
)
)
binding
.
tvJunkFiles
.
text
=
sp
binding
.
tvJunkFiles
.
text
=
sp
}
}
}
}
}
}
}
...
...
app/src/main/res/layout/item_function_2.xml
View file @
afaef8d1
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
android:id=
"@+id/iv_icon"
android:id=
"@+id/iv_icon"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"1
5
dp"
android:layout_marginTop=
"1
0
dp"
android:src=
"@mipmap/icon_junk_scan"
android:src=
"@mipmap/icon_junk_scan"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
...
...
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