Directly use MagiskJson

This commit is contained in:
topjohnwu
2025-05-19 10:40:58 -07:00
parent adbea7e313
commit 4c89c7e2b3
11 changed files with 34 additions and 34 deletions

View File

@@ -3,7 +3,6 @@ package com.topjohnwu.magisk.dialog
import com.topjohnwu.magisk.core.AppContext
import com.topjohnwu.magisk.core.Info
import com.topjohnwu.magisk.core.R
import com.topjohnwu.magisk.core.di.ServiceLocator
import com.topjohnwu.magisk.core.download.DownloadEngine
import com.topjohnwu.magisk.core.download.Subject
import com.topjohnwu.magisk.view.MagiskDialog
@@ -12,9 +11,9 @@ import java.io.File
class ManagerInstallDialog : MarkDownDialog() {
override suspend fun getMarkdownText(): String {
val text = Info.remote.magisk.note
val text = Info.update.note
// Cache the changelog
File(AppContext.cacheDir, "${Info.remote.magisk.versionCode}.md").writeText(text)
File(AppContext.cacheDir, "${Info.update.versionCode}.md").writeText(text)
return text
}

View File

@@ -91,16 +91,15 @@ class HomeViewModel(
override suspend fun doLoadWork() {
appState = State.LOADING
Info.getRemote(svc)?.apply {
Info.fetchUpdate(svc)?.apply {
appState = when {
BuildConfig.APP_VERSION_CODE < magisk.versionCode -> State.OUTDATED
BuildConfig.APP_VERSION_CODE < versionCode -> State.OUTDATED
else -> State.UP_TO_DATE
}
val isDebug = Config.updateChannel == Config.Value.DEBUG_CHANNEL
managerRemoteVersion =
("${magisk.version} (${magisk.versionCode})" +
if (isDebug) " (D)" else "").asText()
("$version (${versionCode})" + if (isDebug) " (D)" else "").asText()
} ?: run {
appState = State.INVALID
managerRemoteVersion = CoreR.string.not_available.asText()

View File

@@ -74,7 +74,7 @@ class InstallViewModel(svc: NetworkService, markwon: Markwon) : BaseViewModel()
val text = when {
file.exists() -> file.readText()
else -> {
val str = if (Const.APP_IS_CANARY) Info.remote.magisk.note
val str = if (Const.APP_IS_CANARY) Info.update.note
else svc.fetchString(Const.Url.CHANGELOG_URL)
file.writeText(str)
str

View File

@@ -147,7 +147,7 @@ object UpdateChannel : BaseSettingsItem.Selector() {
get() = Config.updateChannel
set(value) {
Config.updateChannel = value
Info.remote = Info.EMPTY_REMOTE
Info.resetUpdate()
}
override val title = CoreR.string.settings_update_channel_title.asText()
@@ -169,7 +169,7 @@ object UpdateChannelUrl : BaseSettingsItem.Input() {
get() = Config.customChannelUrl
set(value) {
Config.customChannelUrl = value
Info.remote = Info.EMPTY_REMOTE
Info.resetUpdate()
notifyPropertyChanged(BR.description)
}