Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
761a8dde
Commit
761a8dde
authored
Jan 21, 2022
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Slightly change update UI logic
parent
a73acfb9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
14 deletions
+25
-14
LocalModule.kt
...ava/com/topjohnwu/magisk/core/model/module/LocalModule.kt
+13
-9
ModuleRvItem.kt
.../main/java/com/topjohnwu/magisk/ui/module/ModuleRvItem.kt
+9
-3
ModuleViewModel.kt
...in/java/com/topjohnwu/magisk/ui/module/ModuleViewModel.kt
+2
-1
item_module_md2.xml
app/src/main/res/layout/item_module_md2.xml
+1
-1
No files found.
app/src/main/java/com/topjohnwu/magisk/core/model/module/LocalModule.kt
View file @
761a8dde
...
@@ -14,15 +14,18 @@ import java.util.*
...
@@ -14,15 +14,18 @@ import java.util.*
data class
LocalModule
(
data class
LocalModule
(
private
val
path
:
String
,
private
val
path
:
String
,
)
:
Module
()
{
)
:
Module
()
{
private
val
svc
get
()
=
ServiceLocator
.
networkService
override
var
id
:
String
=
""
override
var
id
:
String
=
""
override
var
name
:
String
=
""
override
var
name
:
String
=
""
override
var
version
:
String
=
""
override
var
version
:
String
=
""
override
var
versionCode
:
Int
=
-
1
override
var
versionCode
:
Int
=
-
1
var
author
:
String
=
""
var
author
:
String
=
""
var
description
:
String
=
""
var
description
:
String
=
""
var
updateJson
:
String
=
""
var
updateInfo
:
OnlineModule
?
=
null
var
updateInfo
:
OnlineModule
?
=
null
var
outdated
=
false
private
var
updateUrl
:
String
=
""
private
val
removeFile
=
SuFile
(
path
,
"remove"
)
private
val
removeFile
=
SuFile
(
path
,
"remove"
)
private
val
disableFile
=
SuFile
(
path
,
"disable"
)
private
val
disableFile
=
SuFile
(
path
,
"disable"
)
private
val
updateFile
=
SuFile
(
path
,
"update"
)
private
val
updateFile
=
SuFile
(
path
,
"update"
)
...
@@ -93,7 +96,7 @@ data class LocalModule(
...
@@ -93,7 +96,7 @@ data class LocalModule(
"versionCode"
->
versionCode
=
value
.
toInt
()
"versionCode"
->
versionCode
=
value
.
toInt
()
"author"
->
author
=
value
"author"
->
author
=
value
"description"
->
description
=
value
"description"
->
description
=
value
"updateJson"
->
update
Json
=
value
"updateJson"
->
update
Url
=
value
}
}
}
}
}
}
...
@@ -113,20 +116,21 @@ data class LocalModule(
...
@@ -113,20 +116,21 @@ data class LocalModule(
}
}
}
}
suspend
fun
load
():
Boolean
{
suspend
fun
fetch
():
Boolean
{
if
(
updateJson
.
isEmpty
())
return
false
if
(
updateUrl
.
isEmpty
())
return
false
try
{
try
{
val
json
=
ServiceLocator
.
networkService
.
fetchModuleJson
(
updateJson
)
val
json
=
svc
.
fetchModuleJson
(
updateUrl
)
if
(
json
.
versionCode
>
versionCode
)
{
updateInfo
=
OnlineModule
(
this
,
json
)
updateInfo
=
OnlineModule
(
this
,
json
)
outdated
=
json
.
versionCode
>
versionCode
return
true
return
true
}
}
catch
(
e
:
IOException
)
{
}
catch
(
e
:
IOException
)
{
Timber
.
w
(
e
)
Timber
.
w
(
e
)
}
catch
(
e
:
JsonDataException
)
{
}
catch
(
e
:
JsonDataException
)
{
Timber
.
w
(
e
)
Timber
.
w
(
e
)
}
}
return
false
return
false
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleRvItem.kt
View file @
761a8dde
...
@@ -54,12 +54,18 @@ class LocalModuleRvItem(
...
@@ -54,12 +54,18 @@ class LocalModuleRvItem(
}
}
@get
:
Bindable
@get
:
Bindable
var
updateReady
:
Boolean
val
showUpdate
get
()
=
item
.
updateInfo
!=
null
get
()
=
item
.
updateInfo
!=
null
&&
!
isRemoved
&&
isEnabled
set
(
_
)
=
notifyPropertyChanged
(
BR
.
updateReady
)
@get
:
Bindable
val
updateReady
get
()
=
item
.
outdated
&&
!
isRemoved
&&
isEnabled
val
isUpdated
=
item
.
updated
val
isUpdated
=
item
.
updated
fun
fetchedUpdateInfo
()
{
notifyPropertyChanged
(
BR
.
showUpdate
)
notifyPropertyChanged
(
BR
.
updateReady
)
}
fun
delete
()
{
fun
delete
()
{
isRemoved
=
!
isRemoved
isRemoved
=
!
isRemoved
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleViewModel.kt
View file @
761a8dde
...
@@ -59,7 +59,8 @@ class ModuleViewModel : BaseViewModel() {
...
@@ -59,7 +59,8 @@ class ModuleViewModel : BaseViewModel() {
private
suspend
fun
loadUpdateInfo
()
{
private
suspend
fun
loadUpdateInfo
()
{
withContext
(
Dispatchers
.
IO
)
{
withContext
(
Dispatchers
.
IO
)
{
itemsInstalled
.
forEach
{
itemsInstalled
.
forEach
{
it
.
updateReady
=
it
.
item
.
load
()
if
(
it
.
item
.
fetch
())
it
.
fetchedUpdateInfo
()
}
}
}
}
}
}
...
...
app/src/main/res/layout/item_module_md2.xml
View file @
761a8dde
...
@@ -130,7 +130,7 @@
...
@@ -130,7 +130,7 @@
<Button
<Button
android:id=
"@+id/module_update"
android:id=
"@+id/module_update"
style=
"@style/WidgetFoundation.Button.Text"
style=
"@style/WidgetFoundation.Button.Text"
gone
=
"@{item.item.updateJson.length == 0
}"
gone
Unless=
"@{item.showUpdate
}"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:clickable=
"true"
android:clickable=
"true"
...
...
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