mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-25 08:47:38 +00:00
Fixed items in navView not being checked
This commit is contained in:
parent
0beb08b687
commit
63055818ec
@ -71,6 +71,20 @@ open class MainActivity : MagiskActivity<MainViewModel, ActivityMainBinding>() {
|
|||||||
supportActionBar?.setTitle(titleId)
|
supportActionBar?.setTitle(titleId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onTabTransaction(fragment: Fragment?, index: Int) {
|
||||||
|
val fragmentId = when (fragment) {
|
||||||
|
is HomeFragment -> R.id.magiskFragment
|
||||||
|
is SuperuserFragment -> R.id.superuserFragment
|
||||||
|
is MagiskHideFragment -> R.id.magiskHideFragment
|
||||||
|
is ModulesFragment -> R.id.modulesFragment
|
||||||
|
is ReposFragment -> R.id.reposFragment
|
||||||
|
is LogFragment -> R.id.logFragment
|
||||||
|
is SettingsFragment -> R.id.settings
|
||||||
|
else -> return
|
||||||
|
}
|
||||||
|
binding.navView.setCheckedItem(fragmentId)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
if (binding.drawerLayout.isDrawerOpen(binding.navView)) {
|
if (binding.drawerLayout.isDrawerOpen(binding.navView)) {
|
||||||
binding.drawerLayout.closeDrawer(binding.navView)
|
binding.drawerLayout.closeDrawer(binding.navView)
|
||||||
@ -88,7 +102,7 @@ open class MainActivity : MagiskActivity<MainViewModel, ActivityMainBinding>() {
|
|||||||
|
|
||||||
private fun openNav() = binding.drawerLayout.openDrawer(GravityCompat.START)
|
private fun openNav() = binding.drawerLayout.openDrawer(GravityCompat.START)
|
||||||
|
|
||||||
fun checkHideSection() {
|
private fun checkHideSection() {
|
||||||
val menu = binding.navView.menu
|
val menu = binding.navView.menu
|
||||||
menu.findItem(R.id.magiskHideFragment).isVisible =
|
menu.findItem(R.id.magiskHideFragment).isVisible =
|
||||||
Shell.rootAccess() && Config.get<Any>(Config.Key.MAGISKHIDE) as Boolean
|
Shell.rootAccess() && Config.get<Any>(Config.Key.MAGISKHIDE) as Boolean
|
||||||
|
@ -31,7 +31,7 @@ import kotlin.reflect.KClass
|
|||||||
|
|
||||||
abstract class MagiskActivity<ViewModel : MagiskViewModel, Binding : ViewDataBinding> :
|
abstract class MagiskActivity<ViewModel : MagiskViewModel, Binding : ViewDataBinding> :
|
||||||
MagiskLeanbackActivity<ViewModel, Binding>(), FragNavController.RootFragmentListener,
|
MagiskLeanbackActivity<ViewModel, Binding>(), FragNavController.RootFragmentListener,
|
||||||
Navigator {
|
Navigator, FragNavController.TransactionListener {
|
||||||
|
|
||||||
override val numberOfRootFragments: Int get() = baseFragments.size
|
override val numberOfRootFragments: Int get() = baseFragments.size
|
||||||
override val baseFragments: List<KClass<out Fragment>> = listOf()
|
override val baseFragments: List<KClass<out Fragment>> = listOf()
|
||||||
@ -62,6 +62,7 @@ abstract class MagiskActivity<ViewModel : MagiskViewModel, Binding : ViewDataBin
|
|||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
navigationController?.apply {
|
navigationController?.apply {
|
||||||
rootFragmentListener = this@MagiskActivity
|
rootFragmentListener = this@MagiskActivity
|
||||||
|
transactionListener = this@MagiskActivity
|
||||||
initialize(defaultPosition, savedInstanceState)
|
initialize(defaultPosition, savedInstanceState)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -162,6 +163,13 @@ abstract class MagiskActivity<ViewModel : MagiskViewModel, Binding : ViewDataBin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onFragmentTransaction(
|
||||||
|
fragment: Fragment?,
|
||||||
|
transactionType: FragNavController.TransactionType
|
||||||
|
) = Unit
|
||||||
|
|
||||||
|
override fun onTabTransaction(fragment: Fragment?, index: Int) = Unit
|
||||||
|
|
||||||
fun openUrl(url: String) = Utils.openLink(this, url.toUri())
|
fun openUrl(url: String) = Utils.openLink(this, url.toUri())
|
||||||
|
|
||||||
fun withPermissions(vararg permissions: String, builder: PermissionRequestBuilder.() -> Unit) {
|
fun withPermissions(vararg permissions: String, builder: PermissionRequestBuilder.() -> Unit) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user