From 94ba7cb0c56963a33ef275a6e5b59ddddec3d60b Mon Sep 17 00:00:00 2001 From: Viktor De Pasquale Date: Thu, 11 Apr 2019 20:09:37 +0200 Subject: [PATCH] Added navigation endpoints --- .../magisk/model/navigation/Navigation.kt | 32 ++++++++++++++++++- .../com/topjohnwu/magisk/ui/MainActivity.kt | 2 ++ .../main/res/navigation/navigation_main.xml | 25 +++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/model/navigation/Navigation.kt b/app/src/main/java/com/topjohnwu/magisk/model/navigation/Navigation.kt index 133bb88fe..a1893db53 100644 --- a/app/src/main/java/com/topjohnwu/magisk/model/navigation/Navigation.kt +++ b/app/src/main/java/com/topjohnwu/magisk/model/navigation/Navigation.kt @@ -1,4 +1,34 @@ 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 } + } + +} 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 33040ba88..3dd4d1b08 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.kt @@ -115,6 +115,7 @@ open class MainActivity : MagiskActivity(), menu.findItem(R.id.superuser).isVisible = Utils.showSuperUser() } + @Deprecated("Will be replaced by navigation components") fun navigate(item: String?) { var itemId = R.id.magisk if (item != null) { @@ -130,6 +131,7 @@ open class MainActivity : MagiskActivity(), navigate(itemId) } + @Deprecated("Will be replaced by navigation components") fun navigate(itemId: Int) { mDrawerItem = itemId binding.navView.setCheckedItem(itemId) diff --git a/app/src/main/res/navigation/navigation_main.xml b/app/src/main/res/navigation/navigation_main.xml index ee4201d1b..83313cb43 100644 --- a/app/src/main/res/navigation/navigation_main.xml +++ b/app/src/main/res/navigation/navigation_main.xml @@ -10,5 +10,30 @@ android:name="com.topjohnwu.magisk.ui.home.MagiskFragment" android:label="fragment_magisk" tools:layout="@layout/fragment_magisk" /> + + + + +