diff --git a/app/src/main/java/com/topjohnwu/magisk/events/dialog/ModuleInstallDialog.kt b/app/src/main/java/com/topjohnwu/magisk/events/dialog/ModuleInstallDialog.kt index 56f679d8f..c0b42664e 100644 --- a/app/src/main/java/com/topjohnwu/magisk/events/dialog/ModuleInstallDialog.kt +++ b/app/src/main/java/com/topjohnwu/magisk/events/dialog/ModuleInstallDialog.kt @@ -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() } } diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.kt b/app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.kt index 9e6a2114f..0457834a7 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.kt @@ -116,9 +116,8 @@ open class MainActivity : BaseUIActivity( 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 } } diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleViewModel.kt index 965ee602f..c83e2fbd2 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleViewModel.kt @@ -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() val items = MergeObservableList() - .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 {