Allow download modules when Magisk is not installed

This commit is contained in:
vvb2060 2020-09-24 04:53:40 +08:00 committed by John Wu
parent fa3865e962
commit de4e26b488
3 changed files with 21 additions and 14 deletions

View File

@ -1,6 +1,7 @@
package com.topjohnwu.magisk.events.dialog
import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.core.Info
import com.topjohnwu.magisk.core.download.Action
import com.topjohnwu.magisk.core.download.DownloadService
import com.topjohnwu.magisk.core.download.Subject
@ -21,17 +22,21 @@ class ModuleInstallDialog(private val item: Repo) : DialogEvent() {
applyTitle(context.getString(R.string.repo_install_title, item.name))
.applyMessage(context.getString(R.string.repo_install_msg, item.downloadFilename))
.cancellable(true)
.applyButton(MagiskDialog.ButtonType.POSITIVE) {
titleRes = R.string.install
icon = R.drawable.ic_install
onClick { download(true) }
}
.applyButton(MagiskDialog.ButtonType.NEGATIVE) {
titleRes = R.string.download
icon = R.drawable.ic_download_md2
onClick { download(false) }
}
.reveal()
if (Info.env.isActive) {
applyButton(MagiskDialog.ButtonType.POSITIVE) {
titleRes = R.string.install
icon = R.drawable.ic_install
onClick { download(true) }
}
}
reveal()
}
}

View File

@ -116,9 +116,8 @@ open class MainActivity : BaseUIActivity<MainViewModel, ActivityMainMd2Binding>(
override fun onResume() {
super.onResume()
binding.mainNavigation.menu.apply {
val isRoot = Shell.rootAccess()
findItem(R.id.modulesFragment)?.isEnabled = isRoot
findItem(R.id.superuserFragment)?.isEnabled = isRoot
findItem(R.id.superuserFragment)?.isEnabled = Info.env.isActive
findItem(R.id.logFragment)?.isEnabled = Info.env.isActive
}
}

View File

@ -7,6 +7,7 @@ import com.topjohnwu.magisk.BR
import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.arch.*
import com.topjohnwu.magisk.core.Config
import com.topjohnwu.magisk.core.Info
import com.topjohnwu.magisk.core.download.Subject
import com.topjohnwu.magisk.core.model.module.Module
import com.topjohnwu.magisk.core.tasks.RepoUpdater
@ -100,11 +101,13 @@ class ModuleViewModel(
val adapter = adapterOf<RvItem>()
val items = MergeObservableList<RvItem>()
.insertItem(InstallModule)
.insertList(updatableSectionList)
.insertList(itemsUpdatable)
.insertList(installSectionList)
.insertList(itemsInstalled)
.also { if (Info.env.isActive) {
it.insertItem(InstallModule)
.insertList(updatableSectionList)
.insertList(itemsUpdatable)
.insertList(installSectionList)
.insertList(itemsInstalled)
} }
.insertItem(sectionOnline)
.insertList(itemsOnline)
val itemBinding = itemBindingOf<RvItem> {