Skip to content

Commit

Permalink
Merge branch 'release/v7.0.0-rc07'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikepenz committed Sep 13, 2019
2 parents 143eb10 + 1b11039 commit 8f4a394
Show file tree
Hide file tree
Showing 13 changed files with 63 additions and 31 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
3 changes: 1 addition & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@
<activity
android:name=".NavControllerActivity"
android:label="NavControllerExample"
android:theme="@style/MaterialDrawerTheme.Light.DarkToolbar">
</activity>
android:theme="@style/MaterialDrawerTheme.Light.DarkToolbar"></activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -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")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
15 changes: 14 additions & 1 deletion app/src/main/res/layout/fragment_message_sample.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
Expand Down Expand Up @@ -78,4 +77,18 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btnFragment2" />

<Button
android:id="@+id/btnPopup"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:text="Pop to Home"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btnFragment3" />
</androidx.constraintlayout.widget.ConstraintLayout>
4 changes: 2 additions & 2 deletions app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
<background android:drawable="@color/ic_launcher_background" />
<foreground android:drawable="@mipmap/ic_launcher_foreground" />
</adaptive-icon>
4 changes: 2 additions & 2 deletions app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
<background android:drawable="@color/ic_launcher_background" />
<foreground android:drawable="@mipmap/ic_launcher_foreground" />
</adaptive-icon>
3 changes: 3 additions & 0 deletions app/src/main/res/navigation/navigation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,8 @@
android:defaultValue="Fragment3"
app:argType="string" />
</fragment>
<action
android:id="@+id/action_global_fragmentHome"
app:popUpTo="@id/fragmentHome" />

</navigation>
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ buildscript {
kotlin_version = '1.3.50'

release = [
versionName: "7.0.0-rc06",
versionName: "7.0.0-rc07",
versionCode: 7000
]

Expand All @@ -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"
]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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<VH : RecyclerView.ViewHolder> (val destination: Int, item: IDrawerItem<VH>) : IDrawerItem<VH> by item
class NavigationDrawerItem<VH : RecyclerView.ViewHolder>(
@IdRes val resId: Int,
item: IDrawerItem<VH>,
val args: Bundle? = null,
val options: NavOptions? = defaultOptions
) : IDrawerItem<VH> 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()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -64,7 +63,13 @@ object DrawerNavigationUI {
navController.removeOnDestinationChangedListener(this)
}
drawerWeak?.drawerItems?.filterIsInstance<NavigationDrawerItem<*>>()?.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)
}
}
})
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,9 @@ abstract class AbstractDrawerItem<T, VH : RecyclerView.ViewHolder> : 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())
}

/**
Expand Down

0 comments on commit 8f4a394

Please sign in to comment.