Fixed clipping version string so it better shows the update's impact

Incremental canary bugfix will be:
b4b2c4 > f5d2e6
Version bump will be always:
20.2 > 20.3 (regardless of canary/beta/stable)
This commit is contained in:
Viktor De Pasquale 2019-11-16 20:21:09 +01:00
parent 1c77e26c05
commit f972f02fff

View File

@ -114,16 +114,16 @@ class HomeViewModel(
stateVersionUpdateMagisk.value = when { stateVersionUpdateMagisk.value = when {
info.magisk.isObsolete -> "%s > %s".format( info.magisk.isObsolete -> "%s > %s".format(
Info.env.magiskVersionString.clipVersion(), Info.env.magiskVersionString.clipVersion(info.magisk.version),
info.magisk.version.clipVersion() info.magisk.version.clipVersion(Info.env.magiskVersionString)
) )
else -> "" else -> ""
} }
stateVersionUpdateManager.value = when { stateVersionUpdateManager.value = when {
info.app.isObsolete -> "%s > %s".format( info.app.isObsolete -> "%s > %s".format(
BuildConfig.VERSION_NAME.clipVersion(), BuildConfig.VERSION_NAME.clipVersion(info.app.version),
info.app.version.clipVersion() info.app.version.clipVersion(BuildConfig.VERSION_NAME)
) )
else -> "" else -> ""
} }
@ -184,7 +184,11 @@ val ManagerJson.isUpdateChannelCorrect
val ManagerJson.isObsolete val ManagerJson.isObsolete
get() = BuildConfig.VERSION_CODE < versionCode get() = BuildConfig.VERSION_CODE < versionCode
fun String.clipVersion() = substringAfter('-') fun String.clipVersion(other: String = ""): String {
val thisVersion = substringBefore('-')
val otherVersion = other.substringBefore('-')
return if (thisVersion != otherVersion) thisVersion else substringAfter('-')
}
inline fun <T : ComparableRvItem<*>> itemBindingOf( inline fun <T : ComparableRvItem<*>> itemBindingOf(
crossinline body: (ItemBinding<*>) -> Unit = {} crossinline body: (ItemBinding<*>) -> Unit = {}