Skip to content

Commit

Permalink
Merge pull request #2775 from mikepenz/develop
Browse files Browse the repository at this point in the history
dev -> main
  • Loading branch information
mikepenz committed Apr 15, 2022
2 parents 8619a29 + 21e62da commit e549e06
Show file tree
Hide file tree
Showing 36 changed files with 310 additions and 219 deletions.
26 changes: 15 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@

## Latest releases 🛠

- Kotlin && New | [v8.4.5](https://github.com/mikepenz/MaterialDrawer/tree/v8.4.5)
- Kotlin | [v7.0.0](https://github.com/mikepenz/MaterialDrawer/tree/v7.0.0) | (Builder approach like v6.x)
- Kotlin && Material 3 | [v9.0.0](https://github.com/mikepenz/MaterialDrawer/tree/v9.0.0)
- Kotlin | [v8.4.5](https://github.com/mikepenz/MaterialDrawer/tree/v8.4.5)
- 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)

Expand All @@ -64,7 +64,7 @@ implementation "com.mikepenz:materialdrawer:${lastestMaterialDrawerRelease}"
implementation "androidx.appcompat:appcompat:${versions.appcompat}"
implementation "androidx.recyclerview:recyclerview:${versions.recyclerView}"
implementation "androidx.annotation:annotation:${versions.annotation}"
implementation "com.google.android.material:material:${versions.material}"
implementation "com.google.android.material:material:1.5.0-alpha05" // requires at least 1.5.0-x
implementation "androidx.constraintlayout:constraintlayout:${versions.constraintLayout}"
// Add for NavController support
Expand Down Expand Up @@ -100,7 +100,7 @@ The `MaterialDrawerSliderView` has to be provided as child of the `DrawerLayout`
### 3. Add the `DrawerStyle` to your theme

```xml
<style name="SampleApp.DayNight" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<style name="SampleApp.DayNight" parent="Theme.Material3.DayNight.NoActionBar">
...
<item name="materialDrawerStyle">@style/Widget.MaterialDrawerStyle</item>
<item name="materialDrawerHeaderStyle">@style/Widget.MaterialDrawerHeaderStyle</item>
Expand All @@ -110,6 +110,10 @@ The `MaterialDrawerSliderView` has to be provided as child of the `DrawerLayout`

Great. Your drawer is now ready to use.

### Note

> Using v9.x with Material 3 theming requires a `Material3` theme as base for the activity.
# Additional Setup
### Add items and adding some functionality

Expand Down Expand Up @@ -273,12 +277,12 @@ Create your custom style. If you don't need a custom theme see the next section,
<item name="materialDrawerInsetForeground">#4000</item>
<!-- MaterialDrawer specific values -->
<item name="materialDrawerBackground">?colorSurface</item>
<item name="materialDrawerPrimaryText">?android:textColorPrimary</item>
<item name="materialDrawerPrimaryIcon">?android:textColorSecondary</item>
<item name="materialDrawerSecondaryText">?android:textColorSecondary</item>
<item name="materialDrawerSecondaryIcon">?android:textColorSecondary</item>
<item name="materialDrawerDividerColor">?android:textColorHint</item>
<item name="materialDrawerSelectedBackgroundColor">?colorPrimary</item>
<item name="materialDrawerPrimaryText">@color/color_drawer_item_text</item>
<item name="materialDrawerPrimaryIcon">@color/color_drawer_item_text</item>
<item name="materialDrawerSecondaryText">@color/color_drawer_item_text</item>
<item name="materialDrawerSecondaryIcon">@color/color_drawer_item_text</item>
<item name="materialDrawerDividerColor">?colorOutline</item>
<item name="materialDrawerSelectedBackgroundColor">?colorSecondaryContainer</item>
</style>

// define a custom header style
Expand All @@ -289,7 +293,7 @@ Create your custom style. If you don't need a custom theme see the next section,
</style>

// define the custom styles for the theme
<style name="SampleApp" parent="Theme.MaterialComponents.Light.NoActionBar">
<style name="SampleApp" parent="Theme.Material3.Light.NoActionBar">
...
<item name="materialDrawerStyle">@style/Widget.MaterialDrawerStyleCustom</item>
<item name="materialDrawerHeaderStyle">@style/Widget.MaterialDrawerHeaderStyleCustom</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.widget.ImageView
import androidx.multidex.MultiDexApplication
import coil.clear
import coil.load
import com.google.android.material.color.DynamicColors
import com.mikepenz.iconics.Iconics
import com.mikepenz.iconics.IconicsDrawable
import com.mikepenz.iconics.utils.backgroundColorRes
Expand All @@ -24,6 +25,8 @@ class CustomApplication : MultiDexApplication() {

Iconics.init(this)

DynamicColors.applyToActivitiesIfAvailable(this)

//initialize and create the image loader logic
/*
DrawerImageLoader.init(object : AbstractDrawerImageLoader() {
Expand Down
147 changes: 106 additions & 41 deletions app/src/main/java/com/mikepenz/materialdrawer/app/DrawerActivity.kt

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions app/src/main/res/layout/activity_mini_drawer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.MaterialComponents.Dark" />
android:theme="@style/ThemeOverlay.Material3.Dark" />

<FrameLayout
android:layout_width="match_parent"
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/layout/activity_sample.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
android:id="@+id/toolbar"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.MaterialComponents.Dark"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/layout/activity_sample_crossfader.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
android:id="@+id/toolbar"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.MaterialComponents.Dark"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout/activity_sample_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.MaterialComponents.Dark" />
android:theme="@style/ThemeOverlay.Material3.Dark" />

<FrameLayout
android:id="@+id/fragment_container"
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout/activity_sample_fullscreen.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
android:id="@+id/toolbar"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.MaterialComponents.Dark"
android:theme="@style/ThemeOverlay.Material3.Dark"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout/activity_sample_nav.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
android:id="@+id/toolbar"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.MaterialComponents.Dark"
android:theme="@style/ThemeOverlay.Material3.Dark"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/material_drawer_padding"
android:layout_marginLeft="@dimen/material_drawer_padding"
android:layout_marginEnd="0dp"
android:layout_marginRight="0dp"
android:layout_marginEnd="@dimen/material_drawer_padding"
android:layout_marginRight="@dimen/material_drawer_padding"
android:fontFamily="sans-serif"
android:gravity="center"
android:lines="1"
Expand Down
28 changes: 4 additions & 24 deletions app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
<resources>

<!-- LIGHT -->
<style name="SampleApp.DayNight" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- ...and here we setting appcompat’s color theming attrs -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>

<style name="SampleApp.DayNight" parent="Theme.Material3.DayNight.NoActionBar">
<item name="materialDrawerStyle">@style/Widget.MaterialDrawerStyle</item>
<item name="materialDrawerHeaderStyle">@style/Widget.MaterialDrawerHeaderStyle</item>

Expand All @@ -17,12 +12,7 @@
<item name="windowActionModeOverlay">true</item>
</style>

<style name="SampleApp.DayNight.Compact" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- ...and here we setting appcompat’s color theming attrs -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>

<style name="SampleApp.DayNight.Compact" parent="Theme.Material3.Light.NoActionBar">
<item name="materialDrawerStyle">@style/Widget.MaterialDrawerStyle</item>
<item name="materialDrawerHeaderStyle">@style/Widget.MaterialDrawerHeaderStyleCustom</item>

Expand All @@ -32,12 +22,7 @@
<item name="windowActionModeOverlay">true</item>
</style>

<style name="SampleApp.DayNight.Persistent" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- ...and here we setting appcompat’s color theming attrs -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>

<style name="SampleApp.DayNight.Persistent" parent="Theme.Material3.Light.NoActionBar">
<item name="materialDrawerStyle">@style/Widget.MaterialDrawerStyle</item>
<item name="materialDrawerHeaderStyle">@style/Widget.MaterialDrawerHeaderStylePersistent</item>

Expand All @@ -48,10 +33,5 @@
</style>


<style name="SampleApp.DayNight.DarkActionBar" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- ...and here we setting appcompat’s color theming attrs -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="SampleApp.DayNight.DarkActionBar" parent="Theme.Material3.DayNight" />
</resources>
32 changes: 17 additions & 15 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,45 @@ buildscript {

ext {
release = [
versionName: "8.4.5",
versionCode: 8045
versionName: "9.0.0",
versionCode: 9000
]

setup = [
compileSdk: 31,
minSdk : 16,
minSdk : 21,
targetSdk : 30
]

versions = [
multiDex : '2.0.1',
annotation : '1.1.0',
recyclerView : '1.2.1',
core : '1.6.0',
material : '1.4.0',
appcompat : '1.3.1',
core : '1.7.0',
material : '1.5.0',
appcompat : '1.4.1',
drawerlayout : '1.1.1',
constraintLayout : '2.1.1',
constraintLayout : '2.1.3',
cardview : '1.0.0',
kotlin : "1.5.31",
fastadapter : "5.5.1",
iconics : "5.3.2",
aboutLibs : "8.9.4",
navigation : "2.3.5",
kotlin : "1.6.20",
fastadapter : "5.6.0",
iconics : "5.3.3",
aboutLibs : "10.1.0",
navigation : "2.4.2",
detekt : '1.18.1',
slidingpaneLayout : "1.1.0",
slidingpaneLayout : "1.1.0", // no plans to upgrade to 1.2.0 anymore
swiperefreshLayout: "1.1.0"
]
}

repositories {
maven { url "https://plugins.gradle.org/m2/" }
gradlePluginPortal()
google()
mavenCentral()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.0-alpha02'
classpath 'com.android.tools.build:gradle:7.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:${versions.navigation}"
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:${versions.detekt}"
Expand All @@ -54,6 +55,7 @@ allprojects {
repositories {
google()
mavenCentral()
mavenLocal()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
10 changes: 5 additions & 5 deletions gradlew
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

#
# Copyright ? 2015-2021 the original authors.
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -32,10 +32,10 @@
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions ?$var?, ?${var}?, ?${var:-default}?, ?${var+SET}?,
# ?${var#prefix}?, ?${var%suffix}?, and ?$( cmd )?;
# * compound commands having a testable exit status, especially ?case?;
# * various built-in commands including ?command?, ?set?, and ?ulimit?.
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,30 @@ import java.lang.ref.WeakReference
* @param fallBackListener the listener to handle no navigationDrawerItems
* @return
*/
@Deprecated("Added new successListener", ReplaceWith("setupWithNavController(navController, null, fallBackListener)"))
fun MaterialDrawerSliderView.setupWithNavController(
navController: NavController,
fallBackListener: ((v: View?, item: IDrawerItem<*>, position: Int) -> Boolean)? = null,
) {
setupWithNavController(navController, null, fallBackListener)
}

/**
* Sets up a {@link Drawer} for use with a {@link NavController}.
* The selected item in the Drawer will automatically be updated when the destination
* changes.
*
* @param navController The NavController that hosts the destination
* @param successListener listener to retrieve a notification on successful navigation
* @param fallBackListener the listener to handle no navigationDrawerItems
* @return
*/
fun MaterialDrawerSliderView.setupWithNavController(
navController: NavController,
fallBackListener: ((v: View?, item: IDrawerItem<*>, position: Int) -> Boolean)? = null
successListener: ((v: View?, item: IDrawerItem<*>, position: Int) -> Boolean)? = null,
fallBackListener: ((v: View?, item: IDrawerItem<*>, position: Int) -> Boolean)? = null,
) {
DrawerNavigationUI.setupWithNavController(this, navController, fallBackListener)
DrawerNavigationUI.setupWithNavController(this, navController, successListener, fallBackListener)
}

/**
Expand All @@ -47,11 +66,13 @@ object DrawerNavigationUI {
fun setupWithNavController(
drawer: MaterialDrawerSliderView,
navController: NavController,
successListener: ((v: View?, item: IDrawerItem<*>, position: Int) -> Boolean)? = null,
fallBackListener: ((v: View?, item: IDrawerItem<*>, position: Int) -> Boolean)? = null
) {
drawer.onDrawerItemClickListener = { v, item, position ->
val success = performNavigation(item, navController)
if (success) {
successListener?.invoke(v, item, position)
drawer.drawerLayout?.closeDrawer(drawer)
} else {
fallBackListener?.invoke(v, item, position)
Expand All @@ -72,7 +93,7 @@ object DrawerNavigationUI {
// A ResId may refers to 3 intents.
val destinationId = controller.graph.getAction(element.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
else action.navOptions?.popUpToId // an action pop to a destination
} ?: element.resId // a destination

if (matchDestination(destination, destinationId)) {
Expand Down Expand Up @@ -132,4 +153,4 @@ object DrawerNavigationUI {
}
return currentDestination.id == destId
}
}
}
Loading

0 comments on commit e549e06

Please sign in to comment.