mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-12-28 21:46:23 +00:00
Added versions to home screen
To overview (when updatable)
- It is very hard to spot a difference in versions so versions are now regarded as commit messages (after dash [-]) when applicable
- This will result in more clear, understandable text
- Bleeding edge (canary) user would see:
ffed229 > ffe02ed or 19.4 > ffe02ed
as opposed to:
19.4-ffed229 (19404)
19.5-ffe02ed (19501)
- Regular beta+ user would see:
19.4 > 19.5
To bottom of the screen
- This change is with respect to regular user. They don't care which version they run as long as they know that "up-to-date" is a gold standard
- It takes tons of real-estate on the screen which takes away the glance-ability from the overview.
This commit is contained in:
@@ -6,8 +6,10 @@ import com.topjohnwu.superuser.ShellUtils
|
||||
|
||||
object Info {
|
||||
|
||||
@JvmStatic
|
||||
var magiskVersionCode = -1
|
||||
|
||||
@JvmStatic
|
||||
var magiskVersionString = ""
|
||||
|
||||
var remote = UpdateInfo()
|
||||
|
||||
@@ -44,6 +44,10 @@ class HomeViewModel(
|
||||
MagiskState.OBSOLETE -> R.string.obsolete_md2.res()
|
||||
}
|
||||
}
|
||||
val stateVersionMagisk = Info.magiskVersionString
|
||||
val stateVersionManager = BuildConfig.VERSION_NAME
|
||||
val stateVersionUpdateMagisk = KObservableField("")
|
||||
val stateVersionUpdateManager = KObservableField("")
|
||||
|
||||
val stateHideManagerName = R.string.manager.res().let {
|
||||
val result = R.string.manager.res()
|
||||
@@ -80,6 +84,22 @@ class HomeViewModel(
|
||||
info.app.isObsolete -> MagiskState.OBSOLETE
|
||||
else -> MagiskState.UP_TO_DATE
|
||||
}
|
||||
|
||||
stateVersionUpdateMagisk.value = when {
|
||||
info.magisk.isObsolete -> "%s > %s".format(
|
||||
Info.magiskVersionString.clipVersion(),
|
||||
info.magisk.version.clipVersion()
|
||||
)
|
||||
else -> ""
|
||||
}
|
||||
|
||||
stateVersionUpdateManager.value = when {
|
||||
info.app.isObsolete -> "%s > %s".format(
|
||||
BuildConfig.VERSION_NAME.clipVersion(),
|
||||
info.app.version.clipVersion()
|
||||
)
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun onDeletePressed() {}
|
||||
@@ -97,6 +117,8 @@ val ManagerJson.isUpdateChannelCorrect
|
||||
val ManagerJson.isObsolete
|
||||
get() = BuildConfig.VERSION_CODE < versionCode
|
||||
|
||||
fun String.clipVersion() = substringAfter('-')
|
||||
|
||||
inline fun <T : ComparableRvItem<T>> itemBindingOf(
|
||||
crossinline body: (ItemBinding<*>) -> Unit = {}
|
||||
) = OnItemBind<T> { itemBinding, _, item ->
|
||||
|
||||
Reference in New Issue
Block a user