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
39e96222
Commit
39e96222
authored
Aug 22, 2019
by
Viktor De Pasquale
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed magisk version
Added refreshing versions before and after the request to remote
parent
021994c9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
11 deletions
+17
-11
MagiskViewModel.kt
...main/java/com/topjohnwu/magisk/ui/base/MagiskViewModel.kt
+3
-1
HomeViewModel.kt
...c/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt
+14
-10
No files found.
app/src/main/java/com/topjohnwu/magisk/ui/base/MagiskViewModel.kt
View file @
39e96222
...
@@ -14,7 +14,9 @@ import io.reactivex.Observable
...
@@ -14,7 +14,9 @@ import io.reactivex.Observable
import
io.reactivex.subjects.PublishSubject
import
io.reactivex.subjects.PublishSubject
abstract
class
MagiskViewModel
:
LoadingViewModel
()
{
abstract
class
MagiskViewModel
(
initialState
:
State
=
State
.
LOADING
)
:
LoadingViewModel
(
initialState
)
{
val
isConnected
=
KObservableField
(
true
)
val
isConnected
=
KObservableField
(
true
)
...
...
app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt
View file @
39e96222
...
@@ -31,7 +31,7 @@ enum class MagiskItem {
...
@@ -31,7 +31,7 @@ enum class MagiskItem {
class
HomeViewModel
(
class
HomeViewModel
(
private
val
magiskRepo
:
MagiskRepository
private
val
magiskRepo
:
MagiskRepository
)
:
MagiskViewModel
()
{
)
:
MagiskViewModel
(
State
.
LOADED
)
{
val
hasGMS
=
runCatching
{
val
hasGMS
=
runCatching
{
get
<
PackageManager
>().
getPackageInfo
(
"com.google.android.gms"
,
0
);
true
get
<
PackageManager
>().
getPackageInfo
(
"com.google.android.gms"
,
0
);
true
...
@@ -177,14 +177,7 @@ class HomeViewModel(
...
@@ -177,14 +177,7 @@ class HomeViewModel(
}
}
fun
refresh
()
{
fun
refresh
()
{
magiskCurrentVersion
.
value
=
if
(
magiskState
.
value
!=
MagiskState
.
NOT_INSTALLED
)
{
refreshVersions
()
version
.
format
(
Info
.
magiskVersionString
,
Info
.
magiskVersionCode
)
}
else
{
""
}
managerCurrentVersion
.
value
=
version
.
format
(
BuildConfig
.
VERSION_NAME
,
BuildConfig
.
VERSION_CODE
)
magiskRepo
.
fetchUpdate
()
magiskRepo
.
fetchUpdate
()
.
applyViewModel
(
this
)
.
applyViewModel
(
this
)
...
@@ -198,13 +191,24 @@ class HomeViewModel(
...
@@ -198,13 +191,24 @@ class HomeViewModel(
.
subscribeK
{
.
subscribeK
{
updateSelf
()
updateSelf
()
ensureEnv
()
ensureEnv
()
refreshVersions
()
}
}
hasRoot
.
value
=
Shell
.
rootAccess
()
hasRoot
.
value
=
Shell
.
rootAccess
()
}
}
private
fun
refreshVersions
()
{
magiskCurrentVersion
.
value
=
if
(
magiskState
.
value
!=
MagiskState
.
NOT_INSTALLED
)
{
version
.
format
(
Info
.
magiskVersionString
,
Info
.
magiskVersionCode
)
}
else
{
""
}
managerCurrentVersion
.
value
=
version
.
format
(
BuildConfig
.
VERSION_NAME
,
BuildConfig
.
VERSION_CODE
)
}
private
fun
updateSelf
()
{
private
fun
updateSelf
()
{
state
=
State
.
LOADED
_magiskState
.
value
=
when
(
Info
.
magiskVersionCode
)
{
_magiskState
.
value
=
when
(
Info
.
magiskVersionCode
)
{
in
Int
.
MIN_VALUE
until
0
->
MagiskState
.
NOT_INSTALLED
in
Int
.
MIN_VALUE
until
0
->
MagiskState
.
NOT_INSTALLED
!
in
Info
.
remote
.
magisk
.
versionCode
..
Int
.
MAX_VALUE
->
MagiskState
.
OBSOLETE
!
in
Info
.
remote
.
magisk
.
versionCode
..
Int
.
MAX_VALUE
->
MagiskState
.
OBSOLETE
...
...
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