Add release notes to the install fragment
This commit is contained in:
parent
f6a2b1c882
commit
706eba329d
@ -25,7 +25,7 @@ val viewModelModules = module {
|
||||
viewModel { SettingsViewModel(get()) }
|
||||
viewModel { SuperuserViewModel(get(), get(), get()) }
|
||||
viewModel { ThemeViewModel() }
|
||||
viewModel { InstallViewModel() }
|
||||
viewModel { InstallViewModel(get(), get()) }
|
||||
viewModel { MainViewModel() }
|
||||
|
||||
// Legacy
|
||||
|
@ -1,13 +1,17 @@
|
||||
package com.topjohnwu.magisk.ui.install
|
||||
|
||||
import android.net.Uri
|
||||
import android.text.SpannableString
|
||||
import android.text.Spanned
|
||||
import android.widget.Toast
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.core.Info
|
||||
import com.topjohnwu.magisk.core.download.DownloadService
|
||||
import com.topjohnwu.magisk.core.download.RemoteFileService
|
||||
import com.topjohnwu.magisk.core.utils.Utils
|
||||
import com.topjohnwu.magisk.data.repository.StringRepository
|
||||
import com.topjohnwu.magisk.extensions.addOnPropertyChangedCallback
|
||||
import com.topjohnwu.magisk.extensions.subscribeK
|
||||
import com.topjohnwu.magisk.model.entity.internal.Configuration
|
||||
import com.topjohnwu.magisk.model.entity.internal.DownloadSubject
|
||||
import com.topjohnwu.magisk.model.events.RequestFileEvent
|
||||
@ -15,20 +19,23 @@ import com.topjohnwu.magisk.model.events.dialog.SecondSlotWarningDialog
|
||||
import com.topjohnwu.magisk.ui.base.BaseViewModel
|
||||
import com.topjohnwu.magisk.utils.KObservableField
|
||||
import com.topjohnwu.superuser.Shell
|
||||
import io.noties.markwon.Markwon
|
||||
import org.koin.core.get
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
class InstallViewModel : BaseViewModel(State.LOADED) {
|
||||
class InstallViewModel(
|
||||
stringRepo: StringRepository,
|
||||
markwon: Markwon
|
||||
) : BaseViewModel(State.LOADED) {
|
||||
|
||||
val isRooted get() = Shell.rootAccess()
|
||||
val isAB get() = Info.isAB
|
||||
|
||||
val step = KObservableField(0)
|
||||
val method = KObservableField(-1)
|
||||
|
||||
val progress = KObservableField(0)
|
||||
|
||||
var data = KObservableField<Uri?>(null)
|
||||
val data = KObservableField<Uri?>(null)
|
||||
val notes = KObservableField<Spanned>(SpannableString(""))
|
||||
|
||||
init {
|
||||
RemoteFileService.reset()
|
||||
@ -42,8 +49,13 @@ class InstallViewModel : BaseViewModel(State.LOADED) {
|
||||
state = State.LOADED
|
||||
}
|
||||
}
|
||||
stringRepo.getString(Info.remote.magisk.note).map {
|
||||
markwon.toMarkdown(it)
|
||||
}.subscribeK {
|
||||
notes.value = it
|
||||
}
|
||||
method.addOnPropertyChangedCallback {
|
||||
when (method.value) {
|
||||
when (it!!) {
|
||||
R.id.method_patch -> {
|
||||
Utils.toast(R.string.patch_file_msg, Toast.LENGTH_LONG)
|
||||
RequestFileEvent().publish()
|
||||
|
@ -50,7 +50,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?listPreferredItemHeightSmall">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
<ImageView
|
||||
android:id="@+id/install_step_options_icon"
|
||||
style="@style/WidgetFoundation.Icon"
|
||||
isSelected="@{viewModel.step > 0}"
|
||||
@ -60,7 +60,7 @@
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/ic_check_circle_md2" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
<TextView
|
||||
android:id="@+id/install_step_options_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
@ -129,7 +129,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?listPreferredItemHeightSmall">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
<ImageView
|
||||
android:id="@+id/install_step_method_icon"
|
||||
style="@style/WidgetFoundation.Icon"
|
||||
isSelected="@{viewModel.step > 1}"
|
||||
@ -139,7 +139,7 @@
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/ic_check_circle_md2" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
<TextView
|
||||
android:id="@+id/install_step_method_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
@ -217,6 +217,25 @@
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
style="@style/WidgetFoundation.Card.Variant"
|
||||
gone="@{viewModel.step != 0}"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/l1"
|
||||
android:layout_marginStart="@dimen/l1"
|
||||
android:layout_marginEnd="@dimen/l1"
|
||||
app:strokeWidth="@{viewModel.step != 0 ? 0f : @dimen/l_125}">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="15dp"
|
||||
android:textAppearance="@style/AppearanceFoundation.Caption"
|
||||
android:text="@{viewModel.notes}"/>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
style="@style/WidgetFoundation.Button.Text"
|
||||
gone="@{viewModel.step != 2}"
|
||||
@ -241,7 +260,7 @@
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
@ -279,7 +298,7 @@
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
|
Loading…
Reference in New Issue
Block a user