diff --git a/app/src/main/java/com/topjohnwu/magisk/Info.kt b/app/src/main/java/com/topjohnwu/magisk/Info.kt index f226ae5cf..7ff76faff 100644 --- a/app/src/main/java/com/topjohnwu/magisk/Info.kt +++ b/app/src/main/java/com/topjohnwu/magisk/Info.kt @@ -6,8 +6,10 @@ import com.topjohnwu.superuser.ShellUtils object Info { + @JvmStatic var magiskVersionCode = -1 + @JvmStatic var magiskVersionString = "" var remote = UpdateInfo() diff --git a/app/src/main/java/com/topjohnwu/magisk/redesign/home/HomeViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/redesign/home/HomeViewModel.kt index 2eb5b60cb..3c61fbf9f 100644 --- a/app/src/main/java/com/topjohnwu/magisk/redesign/home/HomeViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/redesign/home/HomeViewModel.kt @@ -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 > itemBindingOf( crossinline body: (ItemBinding<*>) -> Unit = {} ) = OnItemBind { itemBinding, _, item -> diff --git a/app/src/main/res/layout/fragment_home_md2.xml b/app/src/main/res/layout/fragment_home_md2.xml index 136edee2b..df173d3fd 100644 --- a/app/src/main/res/layout/fragment_home_md2.xml +++ b/app/src/main/res/layout/fragment_home_md2.xml @@ -5,6 +5,10 @@ + + + + + + + app:layout_constraintTop_toBottomOf="@+id/home_magisk_version"> + + + app:layout_constraintTop_toBottomOf="@+id/home_manager_version"> - - + android:layout_height="wrap_content" + android:layout_marginTop="@dimen/l1"> + + + +