mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-30 21:45:27 +00:00
Added disabled state for sections where unrooted user shouldn't have access
This commit is contained in:
parent
37fa227fb5
commit
51247d36c5
@ -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()
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="?colorDisabledVariant" android:state_enabled="false" />
|
||||
<item android:color="?colorSecondary" android:state_checked="true" />
|
||||
<item android:color="?colorOnSurfaceVariant" />
|
||||
</selector>
|
@ -17,6 +17,7 @@
|
||||
<item name="colorOnSurface">#BABABA</item>
|
||||
<item name="colorOnSurfaceVariant">#80BABABA</item>
|
||||
<item name="colorDisabled">#808080</item>
|
||||
<item name="colorDisabledVariant">#66808080</item>
|
||||
<item name="colorTextTransient">@color/color_text_transient</item>
|
||||
<item name="colorPrimaryTransient">@color/color_primary_transient</item>
|
||||
<item name="colorErrorTransient">@color/color_error_transient</item>
|
||||
|
@ -81,6 +81,7 @@
|
||||
|
||||
<!--Static-->
|
||||
<attr name="colorDisabled" format="color" />
|
||||
<attr name="colorDisabledVariant" format="color" />
|
||||
<attr name="colorSurfaceVariant" format="color" />
|
||||
<attr name="colorOnPrimaryVariant" format="color" />
|
||||
<attr name="colorOnSurfaceVariant" format="color" />
|
||||
|
@ -100,6 +100,7 @@
|
||||
<item name="colorOnSurface">#444444</item>
|
||||
<item name="colorOnSurfaceVariant">#80444444</item>
|
||||
<item name="colorDisabled">#808080</item>
|
||||
<item name="colorDisabledVariant">#66808080</item>
|
||||
<item name="colorTextTransient">@color/color_text_transient</item>
|
||||
<item name="colorPrimaryTransient">@color/color_primary_transient</item>
|
||||
<item name="colorErrorTransient">@color/color_error_transient</item>
|
||||
|
Loading…
Reference in New Issue
Block a user