Commit 3cc5cb31 authored by Viktor De Pasquale's avatar Viktor De Pasquale

Updated the install flow

Now the binary is downloaded after user selects a method. It also shows download progress as the file's being downloaded
parent 8a2872af
...@@ -4,6 +4,7 @@ import com.topjohnwu.magisk.redesign.MainViewModel ...@@ -4,6 +4,7 @@ import com.topjohnwu.magisk.redesign.MainViewModel
import com.topjohnwu.magisk.redesign.flash.FlashViewModel import com.topjohnwu.magisk.redesign.flash.FlashViewModel
import com.topjohnwu.magisk.redesign.hide.HideViewModel import com.topjohnwu.magisk.redesign.hide.HideViewModel
import com.topjohnwu.magisk.redesign.home.HomeViewModel import com.topjohnwu.magisk.redesign.home.HomeViewModel
import com.topjohnwu.magisk.redesign.install.InstallViewModel
import com.topjohnwu.magisk.redesign.log.LogViewModel import com.topjohnwu.magisk.redesign.log.LogViewModel
import com.topjohnwu.magisk.redesign.module.ModuleViewModel import com.topjohnwu.magisk.redesign.module.ModuleViewModel
import com.topjohnwu.magisk.redesign.request.RequestViewModel import com.topjohnwu.magisk.redesign.request.RequestViewModel
...@@ -11,7 +12,6 @@ import com.topjohnwu.magisk.redesign.safetynet.SafetynetViewModel ...@@ -11,7 +12,6 @@ import com.topjohnwu.magisk.redesign.safetynet.SafetynetViewModel
import com.topjohnwu.magisk.redesign.settings.SettingsViewModel import com.topjohnwu.magisk.redesign.settings.SettingsViewModel
import com.topjohnwu.magisk.redesign.superuser.SuperuserViewModel import com.topjohnwu.magisk.redesign.superuser.SuperuserViewModel
import com.topjohnwu.magisk.redesign.theme.ThemeViewModel import com.topjohnwu.magisk.redesign.theme.ThemeViewModel
import com.topjohnwu.magisk.ui.install.InstallViewModel
import org.koin.androidx.viewmodel.dsl.viewModel import org.koin.androidx.viewmodel.dsl.viewModel
import org.koin.dsl.module import org.koin.dsl.module
......
...@@ -128,6 +128,10 @@ abstract class RemoteFileService : NotificationService() { ...@@ -128,6 +128,10 @@ abstract class RemoteFileService : NotificationService() {
fun send(progress: Float, subject: DownloadSubject) { fun send(progress: Float, subject: DownloadSubject) {
internalProgressBroadcast.postValue(progress to subject) internalProgressBroadcast.postValue(progress to subject)
} }
fun reset() {
internalProgressBroadcast.value = null
}
} }
} }
\ No newline at end of file
...@@ -6,11 +6,11 @@ import android.os.Build ...@@ -6,11 +6,11 @@ import android.os.Build
import com.topjohnwu.magisk.ClassMap import com.topjohnwu.magisk.ClassMap
import com.topjohnwu.magisk.Config import com.topjohnwu.magisk.Config
import com.topjohnwu.magisk.Const import com.topjohnwu.magisk.Const
import com.topjohnwu.magisk.redesign.install.InstallFragment
import com.topjohnwu.magisk.redesign.safetynet.SafetynetFragment import com.topjohnwu.magisk.redesign.safetynet.SafetynetFragment
import com.topjohnwu.magisk.ui.MainActivity import com.topjohnwu.magisk.ui.MainActivity
import com.topjohnwu.magisk.ui.hide.MagiskHideFragment import com.topjohnwu.magisk.ui.hide.MagiskHideFragment
import com.topjohnwu.magisk.ui.home.HomeFragment import com.topjohnwu.magisk.ui.home.HomeFragment
import com.topjohnwu.magisk.ui.install.InstallFragment
import com.topjohnwu.magisk.ui.log.LogFragment import com.topjohnwu.magisk.ui.log.LogFragment
import com.topjohnwu.magisk.ui.module.ModulesFragment import com.topjohnwu.magisk.ui.module.ModulesFragment
import com.topjohnwu.magisk.ui.module.ReposFragment import com.topjohnwu.magisk.ui.module.ReposFragment
......
...@@ -8,7 +8,9 @@ import com.topjohnwu.magisk.utils.KObservableField ...@@ -8,7 +8,9 @@ import com.topjohnwu.magisk.utils.KObservableField
import io.reactivex.disposables.Disposable import io.reactivex.disposables.Disposable
import org.koin.core.KoinComponent import org.koin.core.KoinComponent
abstract class CompatViewModel : BaseViewModel(), KoinComponent { abstract class CompatViewModel(
initialState: State = State.LOADING
) : BaseViewModel(initialState), KoinComponent {
val insets = KObservableField(Insets.NONE) val insets = KObservableField(Insets.NONE)
......
...@@ -81,7 +81,7 @@ class HomeViewModel( ...@@ -81,7 +81,7 @@ class HomeViewModel(
init { init {
RemoteFileService.progressBroadcast.observeForever { RemoteFileService.progressBroadcast.observeForever {
when (it.second) { when (it?.second) {
is Magisk.Download, is Magisk.Download,
is Magisk.Flash -> stateMagiskProgress.value = it.first.times(100f).roundToInt() is Magisk.Flash -> stateMagiskProgress.value = it.first.times(100f).roundToInt()
is Manager -> stateManagerProgress.value = it.first.times(100f).roundToInt() is Manager -> stateManagerProgress.value = it.first.times(100f).roundToInt()
......
package com.topjohnwu.magisk.ui.install package com.topjohnwu.magisk.redesign.install
import android.content.Intent import android.content.Intent
import android.graphics.Insets import android.graphics.Insets
......
package com.topjohnwu.magisk.ui.install package com.topjohnwu.magisk.redesign.install
import android.net.Uri import android.net.Uri
import com.topjohnwu.magisk.R import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.extensions.addOnPropertyChangedCallback import com.topjohnwu.magisk.extensions.addOnPropertyChangedCallback
import com.topjohnwu.magisk.model.download.DownloadService import com.topjohnwu.magisk.model.download.DownloadService
import com.topjohnwu.magisk.model.download.RemoteFileService
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
...@@ -12,8 +13,9 @@ import com.topjohnwu.magisk.utils.KObservableField ...@@ -12,8 +13,9 @@ import com.topjohnwu.magisk.utils.KObservableField
import com.topjohnwu.superuser.Shell import com.topjohnwu.superuser.Shell
import com.topjohnwu.superuser.ShellUtils import com.topjohnwu.superuser.ShellUtils
import org.koin.core.get import org.koin.core.get
import kotlin.math.roundToInt
class InstallViewModel : CompatViewModel() { class InstallViewModel : CompatViewModel(State.LOADED) {
val isRooted = Shell.rootAccess() val isRooted = Shell.rootAccess()
val isAB = isABDevice() val isAB = isABDevice()
...@@ -21,9 +23,23 @@ class InstallViewModel : CompatViewModel() { ...@@ -21,9 +23,23 @@ class InstallViewModel : CompatViewModel() {
val step = KObservableField(0) val step = KObservableField(0)
val method = KObservableField(-1) val method = KObservableField(-1)
val progress = KObservableField(0)
var data = KObservableField<Uri?>(null) var data = KObservableField<Uri?>(null)
init { init {
RemoteFileService.reset()
RemoteFileService.progressBroadcast.observeForever {
val (progress, subject) = it ?: return@observeForever
if (subject !is DownloadSubject.Magisk) {
return@observeForever
}
this.progress.value = progress.times(100).roundToInt()
if (this.progress.value >= 100) {
// this might cause issues if the flash activity launches on top of this sooner
back()
}
}
method.addOnPropertyChangedCallback { method.addOnPropertyChangedCallback {
if (method.value == R.id.method_patch) { if (method.value == R.id.method_patch) {
RequestFileEvent().publish() RequestFileEvent().publish()
...@@ -37,7 +53,7 @@ class InstallViewModel : CompatViewModel() { ...@@ -37,7 +53,7 @@ class InstallViewModel : CompatViewModel() {
fun install() = DownloadService(get()) { fun install() = DownloadService(get()) {
subject = DownloadSubject.Magisk(resolveConfiguration()) subject = DownloadSubject.Magisk(resolveConfiguration())
} }.also { state = State.LOADING }
// --- // ---
......
<?xml version="1.0" encoding="utf-8"?>
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt">
<aapt:attr name="android:drawable">
<vector
android:name="vector"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<group
android:name="group"
android:pivotX="12"
android:pivotY="12">
<path
android:name="path"
android:fillColor="#000"
android:pathData="M 12 2 C 9.349 2 6.804 3.054 4.929 4.929 C 3.054 6.804 2 9.349 2 12 C 2 14.651 3.054 17.196 4.929 19.071 C 6.804 20.946 9.349 22 12 22 C 13.755 22 15.48 21.538 17 20.66 C 18.52 19.783 19.783 18.52 20.66 17 C 21.538 15.48 22 13.755 22 12 C 22 10.245 21.538 8.52 20.66 7 C 19.783 5.48 18.52 4.217 17 3.34 C 15.48 2.462 13.755 2 12 2 Z" />
</group>
</vector>
</aapt:attr>
<target android:name="group">
<aapt:attr name="android:animation">
<set>
<objectAnimator
android:duration="200"
android:interpolator="@android:anim/overshoot_interpolator"
android:propertyName="scaleX"
android:valueFrom="1"
android:valueTo="0.8"
android:valueType="floatType" />
<objectAnimator
android:duration="200"
android:interpolator="@android:anim/overshoot_interpolator"
android:propertyName="scaleY"
android:valueFrom="1"
android:valueTo="0.8"
android:valueType="floatType" />
<objectAnimator
android:duration="200"
android:interpolator="@android:anim/anticipate_overshoot_interpolator"
android:propertyName="scaleX"
android:startOffset="200"
android:valueFrom="0.8"
android:valueTo="1"
android:valueType="floatType" />
<objectAnimator
android:duration="200"
android:interpolator="@android:anim/anticipate_overshoot_interpolator"
android:propertyName="scaleY"
android:startOffset="200"
android:valueFrom="0.8"
android:valueTo="1"
android:valueType="floatType" />
</set>
</aapt:attr>
</target>
<target android:name="path">
<aapt:attr name="android:animation">
<objectAnimator
android:duration="100"
android:interpolator="@android:interpolator/fast_out_slow_in"
android:propertyName="fillAlpha"
android:startOffset="200"
android:valueFrom="0.3"
android:valueTo="1"
android:valueType="floatType" />
</aapt:attr>
</target>
</animated-vector>
<?xml version="1.0" encoding="utf-8"?>
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt">
<aapt:attr name="android:drawable">
<vector
android:name="vector"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<group
android:name="group"
android:pivotX="12"
android:pivotY="12">
<path
android:name="path"
android:fillAlpha="0.7"
android:fillColor="#000"
android:pathData="M 12 2 C 9.349 2 6.804 3.054 4.929 4.929 C 3.054 6.804 2 9.349 2 12 C 2 14.651 3.054 17.196 4.929 19.071 C 6.804 20.946 9.349 22 12 22 C 13.755 22 15.48 21.538 17 20.66 C 18.52 19.783 19.783 18.52 20.66 17 C 21.538 15.48 22 13.755 22 12 C 22 10.245 21.538 8.52 20.66 7 C 19.783 5.48 18.52 4.217 17 3.34 C 15.48 2.462 13.755 2 12 2 Z" />
</group>
</vector>
</aapt:attr>
<target android:name="group">
<aapt:attr name="android:animation">
<set>
<objectAnimator
android:duration="200"
android:interpolator="@android:anim/overshoot_interpolator"
android:propertyName="scaleX"
android:valueFrom="1"
android:valueTo="0.8"
android:valueType="floatType" />
<objectAnimator
android:duration="200"
android:interpolator="@android:anim/overshoot_interpolator"
android:propertyName="scaleY"
android:valueFrom="1"
android:valueTo="0.8"
android:valueType="floatType" />
<objectAnimator
android:duration="200"
android:interpolator="@android:anim/anticipate_overshoot_interpolator"
android:propertyName="scaleX"
android:startOffset="200"
android:valueFrom="0.8"
android:valueTo="1"
android:valueType="floatType" />
<objectAnimator
android:duration="200"
android:interpolator="@android:anim/anticipate_overshoot_interpolator"
android:propertyName="scaleY"
android:startOffset="200"
android:valueFrom="0.8"
android:valueTo="1"
android:valueType="floatType" />
</set>
</aapt:attr>
</target>
<target android:name="path">
<aapt:attr name="android:animation">
<objectAnimator
android:duration="100"
android:interpolator="@android:interpolator/fast_out_slow_in"
android:propertyName="fillAlpha"
android:startOffset="200"
android:valueFrom="1"
android:valueTo="0.3"
android:valueType="floatType" />
</aapt:attr>
</target>
</animated-vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<group
android:name="forth"
android:pivotX="12"
android:pivotY="12"
android:rotation="180">
<path
android:fillColor="#000"
android:pathData="M20,11H6.83l2.88,-2.88c0.39,-0.39 0.39,-1.02 0,-1.41 -0.39,-0.39 -1.02,-0.39 -1.41,0L3.71,11.3c-0.39,0.39 -0.39,1.02 0,1.41L8.3,17.3c0.39,0.39 1.02,0.39 1.41,0 0.39,-0.39 0.39,-1.02 0,-1.41L6.83,13H20c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1z" />
</group>
</vector>
<?xml version="1.0" encoding="utf-8"?>
<animated-selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/collapsed"
android:state_checked="true">
<vector
android:name="vector"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<group
android:name="group"
android:pivotX="12"
android:pivotY="12">
<path
android:name="path"
android:fillColor="#000"
android:pathData="M 12 2 C 9.349 2 6.804 3.054 4.929 4.929 C 3.054 6.804 2 9.349 2 12 C 2 14.651 3.054 17.196 4.929 19.071 C 6.804 20.946 9.349 22 12 22 C 13.755 22 15.48 21.538 17 20.66 C 18.52 19.783 19.783 18.52 20.66 17 C 21.538 15.48 22 13.755 22 12 C 22 10.245 21.538 8.52 20.66 7 C 19.783 5.48 18.52 4.217 17 3.34 C 15.48 2.462 13.755 2 12 2 Z" />
</group>
</vector>
</item>
<item android:id="@+id/expanded">
<vector
android:name="vector"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<group
android:name="group"
android:pivotX="12"
android:pivotY="12">
<path
android:name="path"
android:fillAlpha="0.3"
android:fillColor="#000"
android:pathData="M 12 2 C 9.349 2 6.804 3.054 4.929 4.929 C 3.054 6.804 2 9.349 2 12 C 2 14.651 3.054 17.196 4.929 19.071 C 6.804 20.946 9.349 22 12 22 C 13.755 22 15.48 21.538 17 20.66 C 18.52 19.783 19.783 18.52 20.66 17 C 21.538 15.48 22 13.755 22 12 C 22 10.245 21.538 8.52 20.66 7 C 19.783 5.48 18.52 4.217 17 3.34 C 15.48 2.462 13.755 2 12 2 Z" />
</group>
</vector>
</item>
<transition
android:drawable="@drawable/avd_circle_from_filled"
android:fromId="@+id/expanded"
android:toId="@+id/collapsed" />
<transition
android:drawable="@drawable/avd_circle_to_filled"
android:fromId="@+id/collapsed"
android:toId="@id/expanded" />
</animated-selector>
\ No newline at end of file
...@@ -136,6 +136,7 @@ variant. Make sure to use style referenced by attribute defined it attrs.xml. ...@@ -136,6 +136,7 @@ variant. Make sure to use style referenced by attribute defined it attrs.xml.
<item name="android:paddingStart">@dimen/l1</item> <item name="android:paddingStart">@dimen/l1</item>
<item name="android:paddingEnd">@dimen/l1</item> <item name="android:paddingEnd">@dimen/l1</item>
<item name="tint">?colorPrimary</item> <item name="tint">?colorPrimary</item>
<item name="buttonCompat">@drawable/ic_radio_check_button</item>
</style> </style>
<style name="WidgetFoundation.RadioButton" parent="Widget.AppCompat.CompoundButton.RadioButton"> <style name="WidgetFoundation.RadioButton" parent="Widget.AppCompat.CompoundButton.RadioButton">
...@@ -144,6 +145,7 @@ variant. Make sure to use style referenced by attribute defined it attrs.xml. ...@@ -144,6 +145,7 @@ variant. Make sure to use style referenced by attribute defined it attrs.xml.
<item name="android:paddingStart">@dimen/l1</item> <item name="android:paddingStart">@dimen/l1</item>
<item name="android:paddingEnd">@dimen/l1</item> <item name="android:paddingEnd">@dimen/l1</item>
<item name="tint">?colorPrimary</item> <item name="tint">?colorPrimary</item>
<item name="buttonCompat">@drawable/ic_radio_check_button</item>
</style> </style>
<style name="WidgetFoundation.ProgressBar" parent="Widget.AppCompat.ProgressBar.Horizontal"> <style name="WidgetFoundation.ProgressBar" parent="Widget.AppCompat.ProgressBar.Horizontal">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment