Added navigation endpoints

This commit is contained in:
Viktor De Pasquale 2019-04-11 20:09:37 +02:00
parent 2d58c725e0
commit 94ba7cb0c5
3 changed files with 58 additions and 1 deletions

View File

@ -1,4 +1,34 @@
package com.topjohnwu.magisk.model.navigation package com.topjohnwu.magisk.model.navigation
import com.skoumal.teanity.viewevents.NavigationEvent
import com.topjohnwu.magisk.R
object Navigation
object Navigation {
fun home() = NavigationEvent {
navDirections { destination = R.id.magiskFragment }
navOptions { popUpTo = R.id.magiskFragment }
}
fun superuser() = NavigationEvent {
navDirections { destination = R.id.superuserFragment }
}
fun modules() = NavigationEvent {
navDirections { destination = R.id.modulesFragment }
}
fun repos() = NavigationEvent {
navDirections { destination = R.id.reposFragment }
}
fun hide() = NavigationEvent {
navDirections { destination = R.id.magiskHideFragment }
}
fun log() = NavigationEvent {
navDirections { destination = R.id.logFragment }
}
}

View File

@ -115,6 +115,7 @@ open class MainActivity : MagiskActivity<MainViewModel, ActivityMainBinding>(),
menu.findItem(R.id.superuser).isVisible = Utils.showSuperUser() menu.findItem(R.id.superuser).isVisible = Utils.showSuperUser()
} }
@Deprecated("Will be replaced by navigation components")
fun navigate(item: String?) { fun navigate(item: String?) {
var itemId = R.id.magisk var itemId = R.id.magisk
if (item != null) { if (item != null) {
@ -130,6 +131,7 @@ open class MainActivity : MagiskActivity<MainViewModel, ActivityMainBinding>(),
navigate(itemId) navigate(itemId)
} }
@Deprecated("Will be replaced by navigation components")
fun navigate(itemId: Int) { fun navigate(itemId: Int) {
mDrawerItem = itemId mDrawerItem = itemId
binding.navView.setCheckedItem(itemId) binding.navView.setCheckedItem(itemId)

View File

@ -10,5 +10,30 @@
android:name="com.topjohnwu.magisk.ui.home.MagiskFragment" android:name="com.topjohnwu.magisk.ui.home.MagiskFragment"
android:label="fragment_magisk" android:label="fragment_magisk"
tools:layout="@layout/fragment_magisk" /> tools:layout="@layout/fragment_magisk" />
<fragment
android:id="@+id/superuserFragment"
android:name="com.topjohnwu.magisk.ui.superuser.SuperuserFragment"
android:label="fragment_superuser"
tools:layout="@layout/fragment_superuser" />
<fragment
android:id="@+id/modulesFragment"
android:name="com.topjohnwu.magisk.ui.module.ModulesFragment"
android:label="fragment_modules"
tools:layout="@layout/fragment_modules" />
<fragment
android:id="@+id/reposFragment"
android:name="com.topjohnwu.magisk.ui.module.ReposFragment"
android:label="fragment_repos"
tools:layout="@layout/fragment_repos" />
<fragment
android:id="@+id/magiskHideFragment"
android:name="com.topjohnwu.magisk.ui.hide.MagiskHideFragment"
android:label="fragment_magisk_hide"
tools:layout="@layout/fragment_magisk_hide" />
<fragment
android:id="@+id/logFragment"
android:name="com.topjohnwu.magisk.ui.log.LogFragment"
android:label="fragment_log"
tools:layout="@layout/fragment_log" />
</navigation> </navigation>