Added disabled state for sections where unrooted user shouldn't have access

This commit is contained in:
Viktor De Pasquale
2019-10-16 15:47:41 +02:00
parent 37fa227fb5
commit 51247d36c5
5 changed files with 15 additions and 0 deletions

View File

@@ -16,6 +16,7 @@ import com.topjohnwu.magisk.ui.log.LogFragment
import com.topjohnwu.magisk.ui.module.ModulesFragment
import com.topjohnwu.magisk.ui.settings.SettingsFragment
import com.topjohnwu.magisk.ui.superuser.SuperuserFragment
import com.topjohnwu.superuser.Shell
import org.koin.androidx.viewmodel.ext.android.viewModel
import kotlin.reflect.KClass
@@ -66,6 +67,16 @@ open class MainActivity : CompatActivity<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.logFragment)?.isEnabled = isRoot
}
}
override fun onDestroy() {
binding.mainNavigation.viewTreeObserver.removeOnGlobalLayoutListener(navObserver)
super.onDestroy()