mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-28 04:25:27 +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:
parent
72eb584e65
commit
e595937740
@ -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 ->
|
||||
|
@ -5,6 +5,10 @@
|
||||
|
||||
<data>
|
||||
|
||||
<import type="com.topjohnwu.magisk.Info" />
|
||||
|
||||
<import type="com.topjohnwu.magisk.BuildConfig" />
|
||||
|
||||
<import type="com.topjohnwu.magisk.ui.home.MagiskState" />
|
||||
|
||||
<variable
|
||||
@ -20,7 +24,7 @@
|
||||
android:paddingStart="@dimen/l1"
|
||||
android:paddingTop="@{viewModel.insets.top + (int) @dimen/internal_action_bar_size + (int) @dimen/l1}"
|
||||
android:paddingEnd="@dimen/l1"
|
||||
android:paddingBottom="@{viewModel.insets.bottom + (int) @dimen/margin_fab}"
|
||||
android:paddingBottom="@{viewModel.insets.bottom + (int) @dimen/margin_fab + (int) @dimen/l1}"
|
||||
tools:layout_marginTop="24dp">
|
||||
|
||||
<LinearLayout
|
||||
@ -78,6 +82,15 @@
|
||||
app:layout_constraintStart_toStartOf="@+id/home_magisk_title"
|
||||
app:layout_constraintTop_toBottomOf="@+id/home_magisk_title" />
|
||||
|
||||
<TextSwitcher
|
||||
android:id="@+id/home_magisk_version"
|
||||
textCaptionVariant="@{viewModel.stateVersionUpdateMagisk}"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="@+id/home_magisk_title"
|
||||
app:layout_constraintStart_toStartOf="@+id/home_magisk_title"
|
||||
app:layout_constraintTop_toBottomOf="@+id/home_magisk_status" />
|
||||
|
||||
<FrameLayout
|
||||
gone="@{viewModel.stateMagisk == MagiskState.LOADING || !viewModel.isConnected}"
|
||||
android:layout_width="0dp"
|
||||
@ -86,7 +99,7 @@
|
||||
android:animateLayoutChanges="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/home_magisk_status">
|
||||
app:layout_constraintTop_toBottomOf="@+id/home_magisk_version">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
style="?styleButtonDefault"
|
||||
@ -170,12 +183,21 @@
|
||||
app:layout_constraintStart_toStartOf="@+id/home_manager_title"
|
||||
app:layout_constraintTop_toBottomOf="@+id/home_manager_title" />
|
||||
|
||||
<TextSwitcher
|
||||
android:id="@+id/home_manager_version"
|
||||
textCaptionVariant="@{viewModel.stateVersionUpdateManager}"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="@+id/home_manager_title"
|
||||
app:layout_constraintStart_toStartOf="@+id/home_manager_title"
|
||||
app:layout_constraintTop_toBottomOf="@+id/home_manager_status" />
|
||||
|
||||
<FrameLayout
|
||||
gone="@{viewModel.stateManager == MagiskState.LOADING || !viewModel.isConnected}"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/l1"
|
||||
app:layout_constraintTop_toBottomOf="@+id/home_manager_status">
|
||||
app:layout_constraintTop_toBottomOf="@+id/home_manager_version">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
style="?styleButtonDefault"
|
||||
@ -338,16 +360,10 @@
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginTop="@dimen/l1"
|
||||
android:layout_marginBottom="@dimen/l1"
|
||||
android:background="?colorSurfaceVariant" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/l1">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/support_icon_common"
|
||||
@ -403,6 +419,23 @@
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/l2"
|
||||
android:gravity="center"
|
||||
android:text="@{String.format(`%s (%s)`, BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE)}"
|
||||
android:textAppearance="?appearanceTextCaptionVariant"
|
||||
tools:text="7.3.4 (12345)" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@{String.format(`%s (%s)`, Info.magiskVersionString, Info.magiskVersionCode)}"
|
||||
android:textAppearance="?appearanceTextCaptionVariant"
|
||||
tools:text="19.5 (12345)" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
Loading…
Reference in New Issue
Block a user