You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
@@ -4,7 +4,7 @@ import android.os.Bundle
|
||||
import android.view.*
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.arch.BaseUIFragment
|
||||
import com.topjohnwu.magisk.core.download.BaseDownloadService
|
||||
import com.topjohnwu.magisk.core.download.BaseDownloader
|
||||
import com.topjohnwu.magisk.databinding.FragmentHomeMd2Binding
|
||||
import com.topjohnwu.magisk.events.RebootEvent
|
||||
import com.topjohnwu.superuser.Shell
|
||||
@@ -19,7 +19,7 @@ class HomeFragment : BaseUIFragment<HomeViewModel, FragmentHomeMd2Binding>() {
|
||||
super.onStart()
|
||||
activity.title = resources.getString(R.string.section_home)
|
||||
setHasOptionsMenu(true)
|
||||
BaseDownloadService.observeProgress(this, viewModel::onProgressUpdate)
|
||||
BaseDownloader.observeProgress(this, viewModel::onProgressUpdate)
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
|
||||
@@ -4,7 +4,7 @@ import android.content.Intent
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.arch.BaseUIFragment
|
||||
import com.topjohnwu.magisk.core.download.BaseDownloadService
|
||||
import com.topjohnwu.magisk.core.download.BaseDownloader
|
||||
import com.topjohnwu.magisk.databinding.FragmentInstallMd2Binding
|
||||
import com.topjohnwu.magisk.events.RequestFileEvent
|
||||
import com.topjohnwu.magisk.ktx.coroutineScope
|
||||
@@ -26,7 +26,7 @@ class InstallFragment : BaseUIFragment<InstallViewModel, FragmentInstallMd2Bindi
|
||||
|
||||
// Allow markwon to run in viewmodel scope
|
||||
binding.releaseNotes.coroutineScope = viewModel.viewModelScope
|
||||
BaseDownloadService.observeProgress(this, viewModel::onProgressUpdate)
|
||||
BaseDownloader.observeProgress(this, viewModel::onProgressUpdate)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -78,17 +78,16 @@ class InstallViewModel(
|
||||
step = nextStep
|
||||
}
|
||||
|
||||
fun install() = DownloadService(get()) {
|
||||
subject = Subject.Magisk(resolveConfiguration())
|
||||
}.also { state = State.LOADING }
|
||||
fun install() =
|
||||
DownloadService(get(), Subject.Magisk(resolveAction())).also { state = State.LOADING }
|
||||
|
||||
// ---
|
||||
|
||||
private fun resolveConfiguration() = when (method) {
|
||||
private fun resolveAction() = when (method) {
|
||||
R.id.method_download -> Action.Download
|
||||
R.id.method_patch -> Action.Patch(data!!)
|
||||
R.id.method_direct -> Action.Flash.Primary
|
||||
R.id.method_inactive_slot -> Action.Flash.Secondary
|
||||
else -> throw IllegalArgumentException("Unknown value")
|
||||
else -> error("Unknown value")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.arch.BaseUIFragment
|
||||
import com.topjohnwu.magisk.arch.ReselectionTarget
|
||||
import com.topjohnwu.magisk.arch.ViewEvent
|
||||
import com.topjohnwu.magisk.core.download.BaseDownloadService
|
||||
import com.topjohnwu.magisk.core.download.BaseDownloader
|
||||
import com.topjohnwu.magisk.databinding.FragmentModuleMd2Binding
|
||||
import com.topjohnwu.magisk.events.InstallExternalModuleEvent
|
||||
import com.topjohnwu.magisk.ktx.hideKeyboard
|
||||
@@ -51,7 +51,7 @@ class ModuleFragment : BaseUIFragment<ModuleViewModel, FragmentModuleMd2Binding>
|
||||
super.onStart()
|
||||
setHasOptionsMenu(true)
|
||||
activity.title = resources.getString(R.string.modules)
|
||||
BaseDownloadService.observeProgress(this, viewModel::onProgressUpdate)
|
||||
BaseDownloader.observeProgress(this, viewModel::onProgressUpdate)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
|
||||
@@ -145,9 +145,7 @@ class SettingsViewModel(
|
||||
}
|
||||
|
||||
private fun restoreManager() {
|
||||
DownloadService(get()) {
|
||||
subject = Subject.Manager(Action.APK.Restore)
|
||||
}
|
||||
DownloadService(get(), Subject.Manager(Action.APK.Restore))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user