diff --git a/README.md b/README.md
index 0fe355be1..a6408be07 100644
--- a/README.md
+++ b/README.md
@@ -53,9 +53,9 @@ You can find some frequently asked questions and other resources in the [WIKI /
## Latest releases
-- Kotlin | [v7.0.0-rc06](https://github.com/mikepenz/MaterialDrawer/tree/v7.0.0-rc06)
+- Kotlin | [v7.0.0-rc07](https://github.com/mikepenz/MaterialDrawer/tree/v7.0.0-rc07)
- Java && AndroidX | [v6.1.2](https://github.com/mikepenz/MaterialDrawer/tree/v6.1.2)
-- Java && AppCompat |[v6.0.9](https://github.com/mikepenz/MaterialDrawer/tree/v6.0.9)
+- Java && AppCompat | [v6.0.9](https://github.com/mikepenz/MaterialDrawer/tree/v6.0.9)
## 1. Provide the gradle dependency
diff --git a/app/build.gradle b/app/build.gradle
index 2ea4da966..a7ecedcc8 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -68,7 +68,6 @@ dependencies {
// used to showcase how to load images
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.github.bumptech.glide:glide:4.9.0'
- implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
kapt 'com.github.bumptech.glide:compiler:4.9.0'
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 37f18e1b9..3c87cc8b8 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -70,8 +70,7 @@
-
+ android:theme="@style/MaterialDrawerTheme.Light.DarkToolbar">
\ No newline at end of file
diff --git a/app/src/main/java/com/mikepenz/materialdrawer/app/NavControllerActivity.kt b/app/src/main/java/com/mikepenz/materialdrawer/app/NavControllerActivity.kt
index 8aa1f0e8f..fc224976e 100644
--- a/app/src/main/java/com/mikepenz/materialdrawer/app/NavControllerActivity.kt
+++ b/app/src/main/java/com/mikepenz/materialdrawer/app/NavControllerActivity.kt
@@ -26,7 +26,7 @@ class NavControllerActivity : AppCompatActivity() {
.withActivity(this)
.withToolbar(toolbar)
.addDrawerItems(
- NavigationDrawerItem(R.id.fragmentHome, PrimaryDrawerItem().withName("Home")),
+ NavigationDrawerItem(R.id.action_global_fragmentHome, PrimaryDrawerItem().withName("Home"), null, null),
DividerDrawerItem(),
NavigationDrawerItem(R.id.messageFragment1, PrimaryDrawerItem().withName("Fragment1")),
NavigationDrawerItem(R.id.messageFragment2, PrimaryDrawerItem().withName("Fragment2")),
diff --git a/app/src/main/java/com/mikepenz/materialdrawer/app/fragment/DemoMessageFragment.kt b/app/src/main/java/com/mikepenz/materialdrawer/app/fragment/DemoMessageFragment.kt
index 22adc15b2..029590f51 100644
--- a/app/src/main/java/com/mikepenz/materialdrawer/app/fragment/DemoMessageFragment.kt
+++ b/app/src/main/java/com/mikepenz/materialdrawer/app/fragment/DemoMessageFragment.kt
@@ -29,6 +29,7 @@ class DemoMessageFragment : Fragment() {
btnFragment1.setOnClickListener { navigateTo(R.id.messageFragment1) }
btnFragment2.setOnClickListener { navigateTo(R.id.messageFragment2) }
btnFragment3.setOnClickListener { navigateTo(R.id.messageFragment3) }
+ btnPopup.setOnClickListener { navigateTo(R.id.action_global_fragmentHome) }
}
private fun navigateTo(destination: Int) {
diff --git a/app/src/main/res/layout/fragment_message_sample.xml b/app/src/main/res/layout/fragment_message_sample.xml
index 61160aaba..a9c9a6c99 100644
--- a/app/src/main/res/layout/fragment_message_sample.xml
+++ b/app/src/main/res/layout/fragment_message_sample.xml
@@ -1,7 +1,6 @@
@@ -78,4 +77,18 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btnFragment2" />
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
index 036d09bc5..c9ad5f98f 100644
--- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
+++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
@@ -1,5 +1,5 @@
-
-
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
index 036d09bc5..c9ad5f98f 100644
--- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
+++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
@@ -1,5 +1,5 @@
-
-
+
+
\ No newline at end of file
diff --git a/app/src/main/res/navigation/navigation.xml b/app/src/main/res/navigation/navigation.xml
index a347ca7dc..43c2763e9 100644
--- a/app/src/main/res/navigation/navigation.xml
+++ b/app/src/main/res/navigation/navigation.xml
@@ -54,5 +54,8 @@
android:defaultValue="Fragment3"
app:argType="string" />
+
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 10e7bad44..b63456d9f 100644
--- a/build.gradle
+++ b/build.gradle
@@ -3,7 +3,7 @@ buildscript {
kotlin_version = '1.3.50'
release = [
- versionName: "7.0.0-rc06",
+ versionName: "7.0.0-rc07",
versionCode: 7000
]
@@ -18,16 +18,16 @@ buildscript {
multiDex : '2.0.1',
androidX : '1.0.0',
annotation : '1.1.0',
- recyclerView : '1.1.0-beta03',
- material : '1.1.0-alpha09',
- appcompat : '1.1.0-rc01',
+ recyclerView : '1.1.0-beta04',
+ material : '1.1.0-alpha10',
+ appcompat : '1.1.0',
drawerlayout : '1.1.0-alpha03',
constraintLayout : '2.0.0-beta2',
cardview : '1.0.0',
kotlin : "1.3.50",
fastadapter : "4.1.0-b02",
iconics : "4.0.1-b02",
- navigation : "2.0.0",
+ navigation : "2.1.0",
slidingpaneLayout: "1.0.0"
]
}
diff --git a/library-nav/src/main/java/com/mikepenz/materialdrawer/model/NavigationDrawerItem.kt b/library-nav/src/main/java/com/mikepenz/materialdrawer/model/NavigationDrawerItem.kt
index 07d811191..5ca3d36e8 100644
--- a/library-nav/src/main/java/com/mikepenz/materialdrawer/model/NavigationDrawerItem.kt
+++ b/library-nav/src/main/java/com/mikepenz/materialdrawer/model/NavigationDrawerItem.kt
@@ -1,8 +1,27 @@
package com.mikepenz.materialdrawer.model
+import android.os.Bundle
+import androidx.annotation.IdRes
+import androidx.navigation.NavOptions
import androidx.recyclerview.widget.RecyclerView
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem
import com.mikepenz.materialdrawer.util.ExperimentalNavController
@ExperimentalNavController
-class NavigationDrawerItem (val destination: Int, item: IDrawerItem) : IDrawerItem by item
\ No newline at end of file
+class NavigationDrawerItem(
+ @IdRes val resId: Int,
+ item: IDrawerItem,
+ val args: Bundle? = null,
+ val options: NavOptions? = defaultOptions
+) : IDrawerItem by item {
+
+ companion object {
+ val defaultOptions = NavOptions.Builder()
+ .setLaunchSingleTop(true)
+ .setEnterAnim(androidx.navigation.ui.R.anim.nav_default_enter_anim)
+ .setExitAnim(androidx.navigation.ui.R.anim.nav_default_exit_anim)
+ .setPopEnterAnim(androidx.navigation.ui.R.anim.nav_default_pop_enter_anim)
+ .setPopExitAnim(androidx.navigation.ui.R.anim.nav_default_pop_exit_anim)
+ .build()
+ }
+}
\ No newline at end of file
diff --git a/library-nav/src/main/java/com/mikepenz/materialdrawer/util/DrawerNavigationUI.kt b/library-nav/src/main/java/com/mikepenz/materialdrawer/util/DrawerNavigationUI.kt
index eddca0b78..1f2c74b2e 100644
--- a/library-nav/src/main/java/com/mikepenz/materialdrawer/util/DrawerNavigationUI.kt
+++ b/library-nav/src/main/java/com/mikepenz/materialdrawer/util/DrawerNavigationUI.kt
@@ -5,7 +5,6 @@ import android.view.View
import androidx.annotation.IdRes
import androidx.navigation.NavController
import androidx.navigation.NavDestination
-import androidx.navigation.NavOptions
import com.mikepenz.materialdrawer.Drawer
import com.mikepenz.materialdrawer.model.NavigationDrawerItem
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem
@@ -64,7 +63,13 @@ object DrawerNavigationUI {
navController.removeOnDestinationChangedListener(this)
}
drawerWeak?.drawerItems?.filterIsInstance>()?.forEach {
- if (matchDestination(destination, it.destination)) drawerWeak.setSelection(it, false)
+ // A ResId may refers to 3 intents.
+ val destinationId = controller.graph.getAction(it.resId)?.let { action ->
+ if (action.destinationId != 0) action.destinationId // an action navigate to a destination
+ else action.navOptions?.popUpTo // an action pop to a destination
+ } ?: it.resId // a destination
+
+ if (matchDestination(destination, destinationId)) drawerWeak.setSelection(it, false)
}
}
})
@@ -74,7 +79,7 @@ object DrawerNavigationUI {
* Try to perform a navigation using the NavController to destination associated to IDrawerItem.
*
* Importantly, it assumes that the item type's is {@link NavigationDrawerItem} and that
- * the destination matches a valid {@link NavDestination#getAction(int) action id} or {@link NavDestination#getId() destination id}
+ * the resId matches a valid {@link NavDestination#getAction(int) action id} or {@link NavDestination#getId() destination id}
* to be navigated to.
*
* @param item The selected drawer item
@@ -84,15 +89,8 @@ object DrawerNavigationUI {
private fun performNavigation(item: IDrawerItem<*>, navController: NavController): Boolean {
return when (item) {
is NavigationDrawerItem -> {
- val builder = NavOptions.Builder()
- .setLaunchSingleTop(true)
- .setEnterAnim(androidx.navigation.ui.R.anim.nav_default_enter_anim)
- .setExitAnim(androidx.navigation.ui.R.anim.nav_default_exit_anim)
- .setPopEnterAnim(androidx.navigation.ui.R.anim.nav_default_pop_enter_anim)
- .setPopExitAnim(androidx.navigation.ui.R.anim.nav_default_pop_exit_anim)
- val options = builder.build()
try {
- navController.navigate(item.destination, null, options)
+ navController.navigate(item.resId, item.args, item.options)
true
} catch (e: IllegalArgumentException) {
false
diff --git a/library/src/main/java/com/mikepenz/materialdrawer/model/AbstractDrawerItem.kt b/library/src/main/java/com/mikepenz/materialdrawer/model/AbstractDrawerItem.kt
index fce3e2b01..c0e464784 100644
--- a/library/src/main/java/com/mikepenz/materialdrawer/model/AbstractDrawerItem.kt
+++ b/library/src/main/java/com/mikepenz/materialdrawer/model/AbstractDrawerItem.kt
@@ -415,9 +415,9 @@ abstract class AbstractDrawerItem : IDrawerItem
*/
protected fun getShapeAppearanceModel(ctx: Context): ShapeAppearanceModel {
val cornerRadius = ctx.resources.getDimensionPixelSize(R.dimen.material_drawer_item_corner_radius)
- val shapeAppearanceModel = ShapeAppearanceModel()
- shapeAppearanceModel.setCornerRadius(cornerRadius.toFloat())
- return shapeAppearanceModel
+
+ return ShapeAppearanceModel()
+ .withCornerRadius(cornerRadius.toFloat())
}
/**