Fixed magisk version
Added refreshing versions before and after the request to remote
This commit is contained in:
parent
021994c9f3
commit
39e9622205
@ -14,7 +14,9 @@ import io.reactivex.Observable
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
|
||||
|
||||
abstract class MagiskViewModel : LoadingViewModel() {
|
||||
abstract class MagiskViewModel(
|
||||
initialState: State = State.LOADING
|
||||
) : LoadingViewModel(initialState) {
|
||||
|
||||
val isConnected = KObservableField(true)
|
||||
|
||||
|
@ -31,7 +31,7 @@ enum class MagiskItem {
|
||||
|
||||
class HomeViewModel(
|
||||
private val magiskRepo: MagiskRepository
|
||||
) : MagiskViewModel() {
|
||||
) : MagiskViewModel(State.LOADED) {
|
||||
|
||||
val hasGMS = runCatching {
|
||||
get<PackageManager>().getPackageInfo("com.google.android.gms", 0); true
|
||||
@ -177,14 +177,7 @@ class HomeViewModel(
|
||||
}
|
||||
|
||||
fun refresh() {
|
||||
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)
|
||||
refreshVersions()
|
||||
|
||||
magiskRepo.fetchUpdate()
|
||||
.applyViewModel(this)
|
||||
@ -198,13 +191,24 @@ class HomeViewModel(
|
||||
.subscribeK {
|
||||
updateSelf()
|
||||
ensureEnv()
|
||||
refreshVersions()
|
||||
}
|
||||
|
||||
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() {
|
||||
state = State.LOADED
|
||||
_magiskState.value = when (Info.magiskVersionCode) {
|
||||
in Int.MIN_VALUE until 0 -> MagiskState.NOT_INSTALLED
|
||||
!in Info.remote.magisk.versionCode..Int.MAX_VALUE -> MagiskState.OBSOLETE
|
||||
|
Loading…
Reference in New Issue
Block a user