Added "advanced" install options for installing magisk

This commit is contained in:
Viktor De Pasquale 2019-10-19 22:14:23 +02:00
parent ddf40df649
commit d713ad3499
7 changed files with 78 additions and 2 deletions

View File

@ -14,8 +14,11 @@ object Info {
var remote = UpdateInfo() var remote = UpdateInfo()
@JvmStatic
var keepVerity = false var keepVerity = false
@JvmStatic
var keepEnc = false var keepEnc = false
@JvmStatic
var recovery = false var recovery = false
fun loadMagiskInfo() { fun loadMagiskInfo() {

View File

@ -1,7 +1,9 @@
package com.topjohnwu.magisk.model.events.dialog package com.topjohnwu.magisk.model.events.dialog
import android.view.LayoutInflater
import com.topjohnwu.magisk.Info import com.topjohnwu.magisk.Info
import com.topjohnwu.magisk.R import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.databinding.IncludeInstallOptionsBinding
import com.topjohnwu.magisk.extensions.res import com.topjohnwu.magisk.extensions.res
import com.topjohnwu.magisk.model.events.OpenInappLinkEvent import com.topjohnwu.magisk.model.events.OpenInappLinkEvent
import com.topjohnwu.magisk.view.MagiskDialog import com.topjohnwu.magisk.view.MagiskDialog
@ -13,7 +15,6 @@ class MagiskInstallDialog : DialogEvent() {
override fun build(dialog: MagiskDialog) { override fun build(dialog: MagiskDialog) {
with(dialog) { with(dialog) {
val filename = val filename =
"Magisk v${Info.remote.magisk.version}(${Info.remote.magisk.versionCode})" "Magisk v${Info.remote.magisk.version}(${Info.remote.magisk.versionCode})"
applyTitle(R.string.repo_install_title.res(R.string.magisk.res())) applyTitle(R.string.repo_install_title.res(R.string.magisk.res()))
@ -44,6 +45,7 @@ class MagiskInstallDialog : DialogEvent() {
with(dialog) { with(dialog) {
applyTitle(R.string.select_method) applyTitle(R.string.select_method)
applyMessage("") applyMessage("")
applyView(IncludeInstallOptionsBinding.inflate(LayoutInflater.from(dialog.context)))
applyButton(MagiskDialog.ButtonType.POSITIVE) { applyButton(MagiskDialog.ButtonType.POSITIVE) {
titleRes = R.string.download_zip_only titleRes = R.string.download_zip_only
onClick { onClick {

View File

@ -129,7 +129,7 @@ class MagiskDialog @JvmOverloads constructor(
setCancelable(isCancellable) setCancelable(isCancellable)
} }
fun <Binding : ViewDataBinding> applyView(binding: Binding, body: Binding.() -> Unit) = fun <Binding : ViewDataBinding> applyView(binding: Binding, body: Binding.() -> Unit = {}) =
apply { apply {
this.binding.dialogBaseContainer.removeAllViews() this.binding.dialogBaseContainer.removeAllViews()
this.binding.dialogBaseContainer.addView(binding.root) this.binding.dialogBaseContainer.addView(binding.root)

View File

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<import type="com.topjohnwu.magisk.Info" />
</data>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:paddingTop="@dimen/l1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:layout_gravity="center">
<com.google.android.material.checkbox.MaterialCheckBox
style="?styleCheckboxNormal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:checked="@={Info.keepVerity}"
android:gravity="center"
android:text="@string/keep_dm_verity"
tools:checked="true" />
<com.google.android.material.checkbox.MaterialCheckBox
style="?styleCheckboxNormal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:checked="@={Info.keepEnc}"
android:gravity="center"
android:text="@string/keep_force_encryption"
app:tint="?colorPrimary" />
<com.google.android.material.checkbox.MaterialCheckBox
style="?styleCheckboxNormal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:checked="@={Info.recovery}"
android:gravity="center"
android:text="@string/recovery_mode"
app:tint="?colorPrimary" />
</LinearLayout>
</ScrollView>
</layout>

View File

@ -41,6 +41,9 @@
<attr name="styleImageNormal" format="reference" /> <attr name="styleImageNormal" format="reference" />
<attr name="styleImageSmall" format="reference" /> <attr name="styleImageSmall" format="reference" />
<!--Checkbox-->
<attr name="styleCheckboxNormal" format="reference" />
<!--endregion--> <!--endregion-->
<!--region Texts--> <!--region Texts-->

View File

@ -51,6 +51,8 @@
<item name="styleImageNormal">@style/WidgetFoundation.Image</item> <item name="styleImageNormal">@style/WidgetFoundation.Image</item>
<item name="styleImageSmall">@style/WidgetFoundation.Image.Small</item> <item name="styleImageSmall">@style/WidgetFoundation.Image.Small</item>
<item name="styleCheckboxNormal">@style/WidgetFoundation.Checkbox</item>
<!--///--> <!--///-->
<item name="appearanceTextDisplayNormal">@style/AppearanceFoundation.Display</item> <item name="appearanceTextDisplayNormal">@style/AppearanceFoundation.Display</item>

View File

@ -124,4 +124,11 @@ variant. Make sure to use style referenced by attribute defined it attrs.xml.
<item name="tint">?colorErrorTransient</item> <item name="tint">?colorErrorTransient</item>
</style> </style>
<style name="WidgetFoundation.Checkbox" parent="Widget.AppCompat.CompoundButton.CheckBox">
<item name="android:textAppearance">?appearanceTextBodyNormal</item>
<item name="android:paddingStart">@dimen/l1</item>
<item name="android:paddingEnd">@dimen/l1</item>
<item name="tint">?colorPrimary</item>
</style>
</resources> </resources>