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