Allow download modules when Magisk is not installed
This commit is contained in:
parent
fa3865e962
commit
de4e26b488
@ -1,6 +1,7 @@
|
|||||||
package com.topjohnwu.magisk.events.dialog
|
package com.topjohnwu.magisk.events.dialog
|
||||||
|
|
||||||
import com.topjohnwu.magisk.R
|
import com.topjohnwu.magisk.R
|
||||||
|
import com.topjohnwu.magisk.core.Info
|
||||||
import com.topjohnwu.magisk.core.download.Action
|
import com.topjohnwu.magisk.core.download.Action
|
||||||
import com.topjohnwu.magisk.core.download.DownloadService
|
import com.topjohnwu.magisk.core.download.DownloadService
|
||||||
import com.topjohnwu.magisk.core.download.Subject
|
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))
|
applyTitle(context.getString(R.string.repo_install_title, item.name))
|
||||||
.applyMessage(context.getString(R.string.repo_install_msg, item.downloadFilename))
|
.applyMessage(context.getString(R.string.repo_install_msg, item.downloadFilename))
|
||||||
.cancellable(true)
|
.cancellable(true)
|
||||||
.applyButton(MagiskDialog.ButtonType.POSITIVE) {
|
|
||||||
titleRes = R.string.install
|
|
||||||
icon = R.drawable.ic_install
|
|
||||||
onClick { download(true) }
|
|
||||||
}
|
|
||||||
.applyButton(MagiskDialog.ButtonType.NEGATIVE) {
|
.applyButton(MagiskDialog.ButtonType.NEGATIVE) {
|
||||||
titleRes = R.string.download
|
titleRes = R.string.download
|
||||||
icon = R.drawable.ic_download_md2
|
icon = R.drawable.ic_download_md2
|
||||||
onClick { download(false) }
|
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()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,9 +116,8 @@ open class MainActivity : BaseUIActivity<MainViewModel, ActivityMainMd2Binding>(
|
|||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
binding.mainNavigation.menu.apply {
|
binding.mainNavigation.menu.apply {
|
||||||
val isRoot = Shell.rootAccess()
|
findItem(R.id.superuserFragment)?.isEnabled = Info.env.isActive
|
||||||
findItem(R.id.modulesFragment)?.isEnabled = isRoot
|
findItem(R.id.logFragment)?.isEnabled = Info.env.isActive
|
||||||
findItem(R.id.superuserFragment)?.isEnabled = isRoot
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import com.topjohnwu.magisk.BR
|
|||||||
import com.topjohnwu.magisk.R
|
import com.topjohnwu.magisk.R
|
||||||
import com.topjohnwu.magisk.arch.*
|
import com.topjohnwu.magisk.arch.*
|
||||||
import com.topjohnwu.magisk.core.Config
|
import com.topjohnwu.magisk.core.Config
|
||||||
|
import com.topjohnwu.magisk.core.Info
|
||||||
import com.topjohnwu.magisk.core.download.Subject
|
import com.topjohnwu.magisk.core.download.Subject
|
||||||
import com.topjohnwu.magisk.core.model.module.Module
|
import com.topjohnwu.magisk.core.model.module.Module
|
||||||
import com.topjohnwu.magisk.core.tasks.RepoUpdater
|
import com.topjohnwu.magisk.core.tasks.RepoUpdater
|
||||||
@ -100,11 +101,13 @@ class ModuleViewModel(
|
|||||||
|
|
||||||
val adapter = adapterOf<RvItem>()
|
val adapter = adapterOf<RvItem>()
|
||||||
val items = MergeObservableList<RvItem>()
|
val items = MergeObservableList<RvItem>()
|
||||||
.insertItem(InstallModule)
|
.also { if (Info.env.isActive) {
|
||||||
|
it.insertItem(InstallModule)
|
||||||
.insertList(updatableSectionList)
|
.insertList(updatableSectionList)
|
||||||
.insertList(itemsUpdatable)
|
.insertList(itemsUpdatable)
|
||||||
.insertList(installSectionList)
|
.insertList(installSectionList)
|
||||||
.insertList(itemsInstalled)
|
.insertList(itemsInstalled)
|
||||||
|
} }
|
||||||
.insertItem(sectionOnline)
|
.insertItem(sectionOnline)
|
||||||
.insertList(itemsOnline)
|
.insertList(itemsOnline)
|
||||||
val itemBinding = itemBindingOf<RvItem> {
|
val itemBinding = itemBindingOf<RvItem> {
|
||||||
|
Loading…
Reference in New Issue
Block a user