├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE.md ├── ci-gradle.properties ├── config │ └── configuration.json ├── dependabot.yml └── workflows │ ├── ci.yml │ └── gradle-dependency-submission.yml ├── .gitignore ├── DEV ├── functiongraphic │ └── functiongraphic.jpg ├── github │ ├── 2018-08-18 20.14.34.jpg │ ├── 2018-08-18 20.14.36.jpg │ ├── 2018-08-18 20.14.38.jpg │ ├── 2018-08-18 20.14.42.jpg │ ├── 2018-08-18 20.14.47.jpg │ ├── 2018-08-18 20.14.49.jpg │ ├── banner.png │ ├── screenshots1.png │ ├── screenshots2.png │ └── screenshots_combined.jpg └── screenshots │ ├── screenshot1.png │ ├── screenshot1_small.png │ ├── screenshot2.png │ ├── screenshot2_small.png │ ├── screenshot3.png │ ├── screenshot3_small.png │ ├── screenshot4.png │ └── screenshot4_small.png ├── Dangerfile ├── FAQ.md ├── FAQ ├── accountheader_single_profile_without_dropdown.md ├── howto_modify_add_custom_draweritems.md ├── howto_use_different_sub_library_version.md ├── opening-drawer-from-espresso.md └── when_to_use_this_library.md ├── Gemfile ├── Gemfile.lock ├── LICENSE ├── MIGRATION.md ├── README.md ├── app ├── .gitignore ├── build.gradle.kts ├── gradle.properties ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── ic_launcher-web.png │ ├── java │ └── com │ │ └── mikepenz │ │ └── materialdrawer │ │ └── app │ │ ├── ActionBarActivity.kt │ │ ├── AdvancedActivity.kt │ │ ├── CollapsingToolbarActivity.kt │ │ ├── CompactHeaderDrawerActivity.kt │ │ ├── CrossfadeDrawerLayoutActvitiy.kt │ │ ├── CustomApplication.kt │ │ ├── DrawerActivity.kt │ │ ├── EmbeddedDrawerActivity.kt │ │ ├── FragmentActivity.kt │ │ ├── FullscreenDrawerActivity.kt │ │ ├── MenuDrawerActivity.kt │ │ ├── MiniDrawerActivity.kt │ │ ├── MultiDrawerActivity.kt │ │ ├── NavControllerActivity.kt │ │ ├── PersistentDrawerActivity.kt │ │ ├── drawerItems │ │ ├── AccountDividerDrawerItem.kt │ │ ├── CustomBaseViewHolder.kt │ │ ├── CustomCenteredPrimaryDrawerItem.kt │ │ ├── CustomPrimaryDrawerItem.kt │ │ ├── CustomUrlBasePrimaryDrawerItem.kt │ │ ├── CustomUrlPrimaryDrawerItem.kt │ │ ├── GmailDrawerItem.kt │ │ ├── IconDrawerItem.kt │ │ └── OverflowMenuDrawerItem.kt │ │ ├── fragment │ │ ├── DemoFragment.kt │ │ ├── DemoMessageFragment.kt │ │ ├── DrawerFragment.kt │ │ └── SecondDrawerFragment.kt │ │ ├── utils │ │ ├── CrossfadeWrapper.kt │ │ ├── SystemUtils.kt │ │ └── UIUtils.kt │ │ └── widget │ │ └── CrossfadeDrawerLayout.kt │ └── res │ ├── drawable │ ├── header.jpg │ ├── profile.jpg │ ├── profile2.jpg │ ├── profile3.jpg │ ├── profile4.jpg │ ├── profile5.jpg │ └── profile6.jpg │ ├── layout │ ├── activity_embedded.xml │ ├── activity_mini_drawer.xml │ ├── activity_multi_sample.xml │ ├── activity_persistent_drawer.xml │ ├── activity_sample.xml │ ├── activity_sample_actionbar.xml │ ├── activity_sample_collapsing_toolbar.xml │ ├── activity_sample_crossfader.xml │ ├── activity_sample_fragment.xml │ ├── activity_sample_fullscreen.xml │ ├── activity_sample_nav.xml │ ├── footer.xml │ ├── fragment_message_sample.xml │ ├── fragment_sample.xml │ ├── fragment_simple_sample.xml │ ├── header.xml │ ├── material_drawer_compact_persistent_header.xml │ ├── material_drawer_item_icon_only.xml │ ├── material_drawer_item_overflow_menu_primary.xml │ └── material_drawer_item_primary_centered.xml │ ├── menu │ ├── cab.xml │ ├── embedded.xml │ ├── example_menu.xml │ ├── fragment_menu.xml │ └── main.xml │ ├── mipmap-anydpi-v26 │ ├── ic_launcher.xml │ └── ic_launcher_round.xml │ ├── mipmap-hdpi │ ├── ic_launcher.png │ ├── ic_launcher_foreground.png │ └── ic_launcher_round.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ ├── ic_launcher_foreground.png │ └── ic_launcher_round.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ ├── ic_launcher_foreground.png │ └── ic_launcher_round.png │ ├── mipmap-xxhdpi │ ├── ic_launcher.png │ ├── ic_launcher_foreground.png │ └── ic_launcher_round.png │ ├── mipmap-xxxhdpi │ ├── ic_launcher.png │ ├── ic_launcher_foreground.png │ └── ic_launcher_round.png │ ├── navigation │ └── navigation.xml │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── ic_launcher_background.xml │ ├── ids.xml │ ├── strings.xml │ ├── styles.xml │ └── themes.xml ├── build.gradle.kts ├── gradle.properties ├── gradle ├── libs.versions.toml └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── materialdrawer-iconics ├── .gitignore ├── build.gradle.kts ├── gradle.properties └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── com │ └── mikepenz │ └── materialdrawer │ └── iconics │ ├── IconicsExtension.kt │ └── IconicsImageHolder.kt ├── materialdrawer-nav ├── .gitignore ├── build.gradle.kts ├── consumer-rules.pro ├── gradle.properties ├── proguard-rules.pro ├── proguard-rules.txt └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── com │ └── mikepenz │ └── materialdrawer │ ├── model │ └── NavigationDrawerItem.kt │ └── util │ └── DrawerNavigationUI.kt ├── materialdrawer ├── .gitignore ├── build.gradle.kts ├── gradle.properties ├── proguard-rules.txt └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── mikepenz │ │ └── materialdrawer │ │ ├── holder │ │ ├── BadgeStyle.kt │ │ ├── ColorHolder.kt │ │ ├── DimenHolder.kt │ │ ├── ImageHolder.kt │ │ └── StringHolder.kt │ │ ├── interfaces │ │ ├── ICrossfader.kt │ │ ├── OnCheckedChangeListener.kt │ │ └── OnPostBindViewListener.kt │ │ ├── model │ │ ├── AbstractBadgeableDrawerItem.kt │ │ ├── AbstractDrawerItem.kt │ │ ├── AbstractSwitchableDrawerItem.kt │ │ ├── AbstractToggleableDrawerItem.kt │ │ ├── BaseDescribeableDrawerItem.kt │ │ ├── BaseDrawerItem.kt │ │ ├── BaseViewHolder.kt │ │ ├── ContainerDrawerItem.kt │ │ ├── DividerDrawerItem.kt │ │ ├── ExpandableBadgeDrawerItem.kt │ │ ├── ExpandableDrawerItem.kt │ │ ├── MiniDrawerItem.kt │ │ ├── MiniProfileDrawerItem.kt │ │ ├── PrimaryDrawerItem.kt │ │ ├── ProfileDrawerItem.kt │ │ ├── ProfileSettingDrawerItem.kt │ │ ├── SecondaryDrawerItem.kt │ │ ├── SecondarySwitchDrawerItem.kt │ │ ├── SecondaryToggleDrawerItem.kt │ │ ├── SectionDrawerItem.kt │ │ ├── SwitchDrawerItem.kt │ │ ├── ToggleDrawerItem.kt │ │ ├── interfaces │ │ │ ├── Badgeable.kt │ │ │ ├── Checkable.kt │ │ │ ├── ColorfulBadgeable.kt │ │ │ ├── Describable.kt │ │ │ ├── DescribableColor.kt │ │ │ ├── IDrawerItem.kt │ │ │ ├── IProfile.kt │ │ │ ├── Iconable.kt │ │ │ ├── Nameable.kt │ │ │ ├── NameableColor.kt │ │ │ ├── SelectIconable.kt │ │ │ ├── Selectable.kt │ │ │ ├── SelectableColor.kt │ │ │ ├── Tagable.kt │ │ │ └── Typefaceable.kt │ │ └── utils │ │ │ ├── BadgeDrawableBuilder.kt │ │ │ └── DrawerItemExtensions.kt │ │ ├── util │ │ ├── AbstractDrawerImageLoader.kt │ │ ├── DrawerImageLoader.kt │ │ ├── DrawerItemViewHelper.kt │ │ ├── DrawerUtils.kt │ │ ├── Extensions.kt │ │ ├── FixStateListDrawable.kt │ │ ├── MaterialDrawerSliderViewExtensions.kt │ │ ├── MenuDrawerUtils.kt │ │ └── Utils.kt │ │ ├── view │ │ └── BezelImageView.kt │ │ └── widget │ │ ├── AccountHeaderView.kt │ │ ├── MaterialDrawerSliderView.kt │ │ └── MiniDrawerSliderView.kt │ └── res │ ├── color │ └── color_drawer_item_text.xml │ ├── drawable-v21 │ └── material_drawer_ico_account.xml │ ├── drawable │ ├── material_drawer_badge.xml │ ├── material_drawer_circle_mask.xml │ ├── material_drawer_ico_account.png │ ├── material_drawer_ico_account_layer.xml │ ├── material_drawer_ico_chevron_down.xml │ ├── material_drawer_ico_menu_down.xml │ ├── material_drawer_rectangle_mask.xml │ ├── material_drawer_shadow_bottom.xml │ ├── material_drawer_shadow_left.9.png │ ├── material_drawer_shadow_right.9.png │ └── material_drawer_shadow_top.xml │ ├── layout │ ├── material_drawer.xml │ ├── material_drawer_compact_header.xml │ ├── material_drawer_fits_not.xml │ ├── material_drawer_header.xml │ ├── material_drawer_inner_shadow.xml │ ├── material_drawer_item_container.xml │ ├── material_drawer_item_divider.xml │ ├── material_drawer_item_expandable.xml │ ├── material_drawer_item_expandable_badge.xml │ ├── material_drawer_item_mini.xml │ ├── material_drawer_item_mini_profile.xml │ ├── material_drawer_item_primary.xml │ ├── material_drawer_item_profile.xml │ ├── material_drawer_item_profile_setting.xml │ ├── material_drawer_item_secondary.xml │ ├── material_drawer_item_secondary_switch.xml │ ├── material_drawer_item_secondary_toggle.xml │ ├── material_drawer_item_section.xml │ ├── material_drawer_item_switch.xml │ ├── material_drawer_item_toggle.xml │ └── material_drawer_recycler_view.xml │ ├── values-fr │ └── strings.xml │ ├── values-pt │ └── strings.xml │ ├── values-sw600dp │ └── dimens.xml │ └── values │ ├── attrs.xml │ ├── colors.xml │ ├── dimens.xml │ ├── ids.xml │ ├── strings.xml │ └── styles.xml └── settings.gradle.kts /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [mikepenz] 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## About this issue 2 | 3 | - Briefly describe the issue 4 | - How can the issue be reproduced / sample code 5 | 6 | ## Details 7 | - [ ] Used library version 8 | - [ ] Used support library version 9 | - [ ] Used gradle build tools version 10 | - [ ] Used tooling / Android Studio version 11 | - [ ] Other used libraries, potential conflicting libraries 12 | 13 | ## Checklist 14 | 15 | - [ ] Searched for [similar issues](https://github.com/mikepenz/MaterialDrawer/issues) 16 | - [ ] Checked out the [sample application](https://github.com/mikepenz/MaterialDrawer/tree/develop/app) 17 | - [ ] Read the [README](https://github.com/mikepenz/MaterialDrawer/blob/develop/README.md) 18 | - [ ] Checked out the [CHANGELOG](https://github.com/mikepenz/MaterialDrawer/releases) 19 | - [ ] Read the [FAQ](https://github.com/mikepenz/MaterialDrawer/blob/develop/FAQ.md) 20 | - [ ] Checked out the [MIGRATION GUIDE](https://github.com/mikepenz/MaterialDrawer/blob/develop/MIGRATION.md) 21 | -------------------------------------------------------------------------------- /.github/ci-gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.daemon=true 2 | org.gradle.parallel=true 3 | org.gradle.workers.max=2 4 | org.gradle.jvmargs=-Xmx6G 5 | org.gradle.caching=true 6 | org.gradle.configureondemand=true 7 | # parallel kapt 8 | kapt.use.worker.api=true 9 | -------------------------------------------------------------------------------- /.github/config/configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "categories": [ 3 | { 4 | "title": "## 🚀 Features", 5 | "labels": [ 6 | "feature" 7 | ] 8 | }, 9 | { 10 | "title": "## 🐛 Fixes", 11 | "labels": [ 12 | "fix" 13 | ] 14 | }, 15 | { 16 | "title": "## 🧪 Tests", 17 | "labels": [ 18 | "test" 19 | ] 20 | }, 21 | { 22 | "title": "## 💬 Other", 23 | "labels": [ 24 | "other", 25 | "dependencies" 26 | ] 27 | } 28 | ] 29 | } -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" 5 | schedule: 6 | interval: "weekly" -------------------------------------------------------------------------------- /.github/workflows/gradle-dependency-submission.yml: -------------------------------------------------------------------------------- 1 | name: Gradle Dependency Submission 2 | on: 3 | push: 4 | branches: 5 | - develop 6 | 7 | jobs: 8 | gradle-dependency-detection: 9 | runs-on: ubuntu-latest 10 | # The Dependency Submission API requires write permission 11 | permissions: 12 | contents: write 13 | steps: 14 | - name: 'Checkout Repository' 15 | uses: actions/checkout@v4 16 | 17 | - uses: actions/setup-java@v4 18 | with: 19 | distribution: 'zulu' 20 | java-version: | 21 | 11 22 | 15 23 | 17 24 | 25 | - name: Copy CI gradle.properties 26 | run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties 27 | 28 | - name: Checkout Gradle Build Cache 29 | uses: actions/cache@v4 30 | with: 31 | path: | 32 | ~/.gradle/caches 33 | ~/.gradle/wrapper 34 | !~/.gradle/wrapper/dists/**/gradle*.zip 35 | key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} 36 | restore-keys: | 37 | gradle-${{ runner.os }}- 38 | 39 | - name: Submit Dependency Graph 40 | uses: mikepenz/gradle-dependency-submission@main 41 | with: 42 | gradle-build-module: :app 43 | gradle-build-configuration: debugCompileClasspath 44 | sub-module-mode: INDIVIDUAL_DEEP -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | 15 | # Gradle files 16 | .gradle/ 17 | build/ 18 | /*/build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | #IntelliJ files 30 | *.iml 31 | .idea/ 32 | functiongraphic.psd 33 | 34 | /.kotlin -------------------------------------------------------------------------------- /DEV/functiongraphic/functiongraphic.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/DEV/functiongraphic/functiongraphic.jpg -------------------------------------------------------------------------------- /DEV/github/2018-08-18 20.14.34.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/DEV/github/2018-08-18 20.14.34.jpg -------------------------------------------------------------------------------- /DEV/github/2018-08-18 20.14.36.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/DEV/github/2018-08-18 20.14.36.jpg -------------------------------------------------------------------------------- /DEV/github/2018-08-18 20.14.38.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/DEV/github/2018-08-18 20.14.38.jpg -------------------------------------------------------------------------------- /DEV/github/2018-08-18 20.14.42.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/DEV/github/2018-08-18 20.14.42.jpg -------------------------------------------------------------------------------- /DEV/github/2018-08-18 20.14.47.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/DEV/github/2018-08-18 20.14.47.jpg -------------------------------------------------------------------------------- /DEV/github/2018-08-18 20.14.49.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/DEV/github/2018-08-18 20.14.49.jpg -------------------------------------------------------------------------------- /DEV/github/banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/DEV/github/banner.png -------------------------------------------------------------------------------- /DEV/github/screenshots1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/DEV/github/screenshots1.png -------------------------------------------------------------------------------- /DEV/github/screenshots2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/DEV/github/screenshots2.png -------------------------------------------------------------------------------- /DEV/github/screenshots_combined.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/DEV/github/screenshots_combined.jpg -------------------------------------------------------------------------------- /DEV/screenshots/screenshot1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/DEV/screenshots/screenshot1.png -------------------------------------------------------------------------------- /DEV/screenshots/screenshot1_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/DEV/screenshots/screenshot1_small.png -------------------------------------------------------------------------------- /DEV/screenshots/screenshot2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/DEV/screenshots/screenshot2.png -------------------------------------------------------------------------------- /DEV/screenshots/screenshot2_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/DEV/screenshots/screenshot2_small.png -------------------------------------------------------------------------------- /DEV/screenshots/screenshot3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/DEV/screenshots/screenshot3.png -------------------------------------------------------------------------------- /DEV/screenshots/screenshot3_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/DEV/screenshots/screenshot3_small.png -------------------------------------------------------------------------------- /DEV/screenshots/screenshot4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/DEV/screenshots/screenshot4.png -------------------------------------------------------------------------------- /DEV/screenshots/screenshot4_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/DEV/screenshots/screenshot4_small.png -------------------------------------------------------------------------------- /Dangerfile: -------------------------------------------------------------------------------- 1 | github.dismiss_out_of_range_messages 2 | 3 | # Make it more obvious that a PR is a work in progress and shouldn't be merged yet. 4 | has_wip_label = github.pr_labels.any? { |label| label.include? "Engineers at work" } 5 | has_wip_title = github.pr_title.include? "[WIP]" 6 | 7 | if has_wip_label || has_wip_title 8 | warn("PR is marked as Work in Progress") 9 | end 10 | 11 | # Ensure the PR is not marked as DO NOT MERGE 12 | fail("PR specifies label DO NOT MERGE") if github.pr_labels.any? { |label| label.include? "DO NOT MERGE" } 13 | 14 | # Warn when there is a big PR 15 | warn("Big PR") if git.lines_of_code > 5000 16 | 17 | File.open("settings.gradle.kts", "r") do |file_handle| 18 | file_handle.each_line do |setting| 19 | if setting.include? "include" 20 | gradleModule = setting[10, setting.length-13] 21 | 22 | # AndroidLint 23 | androidLintFile = String.new(gradleModule + "/build/reports/lint-results.xml") 24 | androidLintDebugFile = String.new(gradleModule + "/build/reports/lint-results-debug.xml") 25 | if File.file?(androidLintFile) || File.file?(androidLintDebugFile) 26 | android_lint.skip_gradle_task = true 27 | android_lint.severity = "Warning" 28 | if File.file?(androidLintFile) 29 | android_lint.report_file = androidLintFile 30 | else 31 | android_lint.report_file = androidLintDebugFile 32 | end 33 | android_lint.filtering = true 34 | android_lint.lint(inline_mode: true) 35 | end 36 | 37 | # Detekt 38 | detektFile = String.new(gradleModule + "/build/reports/detekt.xml") 39 | if File.file?(detektFile) 40 | kotlin_detekt.report_file = detektFile 41 | kotlin_detekt.skip_gradle_task = true 42 | kotlin_detekt.severity = "warning" 43 | kotlin_detekt.filtering = true 44 | kotlin_detekt.detekt(inline_mode: true) 45 | end 46 | end 47 | end 48 | end -------------------------------------------------------------------------------- /FAQ.md: -------------------------------------------------------------------------------- 1 | # FAQ / WIKI 2 | 3 | This is the official **MaterialDrawer** FAQ/Wiki. People can contribute to it through pull requests. 4 | Each question and it's answer is hosted in a separate file within the FAQ folder. 5 | 6 | ## MaterialDrawer 7 | 8 | * [Should I use this library or Material Drawer from the Support library?](FAQ/when_to_use_this_library.md) 9 | * [How do I make the drawer appear underneath the Toolbar?](FAQ/howto_show_drawer_under_toolbar.md) 10 | * [How do I create a Multi-pane layout with MaterialDrawer for tablets?](FAQ/howto_show_drawer_in_tablet_multipane.md) 11 | * [Why is there whitespace where the status bar should be while my theme is set as fullscreen ?](FAQ/status_bar_whitespace.md) 12 | * [How do I change existing or add my own CustomDrawerItems to the MaterialDrawer?](FAQ/howto_modify_add_custom_draweritems.md) 13 | * [How to use different dependency library versions](FAQ/howto_use_different_sub_library_version.md) 14 | 15 | ## AccountHeader 16 | 17 | * [How can I use the AccountHeader with just one profile and disable the dropdown?](FAQ/accountheader_single_profile_without_dropdown.md) 18 | 19 | ## Testing 20 | 21 | * [How can I open the drawer from an instrumental test written with Espresso?](FAQ/opening-drawer-from-espresso.md) 22 | 23 | 24 | ## CustomDrawerItem's 25 | 26 | * [A custom SecondaryDrawerItem that takes different name when its on disabled state](https://gist.github.com/AngleV/400377184386193c985d905bd97f2d40) 27 | 28 | ## Asked super frequently 29 | 30 | ### How can i create a drawer without a default selection 31 | ```kotlin 32 | //just set the selection to -1 33 | slider.setSelectionAtPosition(-1) 34 | ``` 35 | 36 | ### Can I lock the Drawer 37 | As the MaterialDrawer will just create a normal DrawerLayout (with some magic around it) everything a normal 38 | DrawerLayout can do is also available in the MaterialDrawer. 39 | ```kotlin 40 | drawerLayout.setDrawerLockMode(int lockMode); //or (int lockMode, int edgeGravity) 41 | ``` -------------------------------------------------------------------------------- /FAQ/accountheader_single_profile_without_dropdown.md: -------------------------------------------------------------------------------- 1 | # How can i use the AccountHeader with just one profile and disable the dropdown? 2 | 3 | This can be simply achieved by adding `headerView.selectionListEnabledForSingleProfile = false` to the 4 | `Builder` of the `AccountHeader`. This will then disable the dropdown and hide the arrow from the 5 | header. 6 | 7 | ## Sample code 8 | 9 | ```kotlin 10 | headerView.selectionListEnabledForSingleProfile = false 11 | ``` 12 | 13 | ## Links 14 | * https://github.com/mikepenz/MaterialDrawer/issues/615 15 | * https://github.com/mikepenz/MaterialDrawer/issues/454 16 | * https://github.com/mikepenz/MaterialDrawer/issues/443 17 | * https://github.com/mikepenz/MaterialDrawer/issues/350 18 | -------------------------------------------------------------------------------- /FAQ/howto_modify_add_custom_draweritems.md: -------------------------------------------------------------------------------- 1 | # How do I change existing or add my own CustomDrawerItems to the MaterialDrawer? 2 | 3 | Please head over here on how to implement a proper CustomDrawerItem: 4 | - http://stackoverflow.com/a/32543209/325479 5 | - http://stackoverflow.com/a/32542999/325479 6 | 7 | Or you check out custom drawer item implementations here: 8 | - https://github.com/mikepenz/MaterialDrawer/tree/develop/app/src/main/java/com/mikepenz/materialdrawer/app/drawerItems 9 | 10 | You might also find some answers here: 11 | - https://github.com/mikepenz/MaterialDrawer/issues?utf8=%E2%9C%93&q=CustomDrawerItem 12 | -------------------------------------------------------------------------------- /FAQ/howto_use_different_sub_library_version.md: -------------------------------------------------------------------------------- 1 | # How do I use different versions of the sub dependencies like the support libraries? 2 | 3 | This can be really easy achieved by providing a resolutionStrategy to your build. 4 | 5 | ## Sample code 6 | Simple add the following to your modules build.gradle. It allows you to define whatever version you need for the sub dependencies. 7 | 8 | ```xml 9 | 10 | configurations.all { 11 | resolutionStrategy.force "com.android.support:support-v4:${versions.androidX}" 12 | resolutionStrategy.force "com.android.support:appcompat-v7:${versions.androidX}" 13 | resolutionStrategy.force "com.android.support:cardview-v7:${versions.androidX}" 14 | resolutionStrategy.force "com.android.support:recyclerview-v7:${versions.androidX}" 15 | resolutionStrategy.force "com.android.support:design:${versions.androidX}" 16 | resolutionStrategy.force "com.android.support:support-annotations:${versions.androidX}" 17 | } 18 | ``` 19 | 20 | https://github.com/mikepenz/MaterialDrawer/blob/develop/app/build.gradle 21 | -------------------------------------------------------------------------------- /FAQ/opening-drawer-from-espresso.md: -------------------------------------------------------------------------------- 1 | ### Q: How to open the drawer from an instrumental test written with Espresso? 2 | ### A: 3 | 4 | First, you need a add `espresso-contrib` to your project. It has the needed `DrawerActions` class. 5 | 6 | `androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2.2'` 7 | 8 | Then, you need to open the drawer with his `openDrawer()` method and the drawer layout ID. The generated one is `R.id.material_drawer_layout` 9 | 10 | `onView(withId(R.id.material_drawer_layout)).perform(DrawerActions.open());` 11 | -------------------------------------------------------------------------------- /FAQ/when_to_use_this_library.md: -------------------------------------------------------------------------------- 1 | ### Developer: 2 | Since there is MaterialDrawer in Support Library, could you give a couple of points why to use your library instead of from Support Library one? 3 | 4 | ### Author: 5 | Well, that really depends on the use case of the drawer in this project, and which functionalities + which customizations are needed. 6 | The MaterialDrawer was created long before Google came up with their drawer in the design support libraries. 7 | 8 | Basically, the one of Google is definitely great and I recommend it to being used in all cases where it is enough. I am a fan of keeping 9 | things as simple as possible, as it will have the great effect on the user experience. So if this project only needs a very minimal drawer 10 | implementation, with just `Main` items, no `profile` functionality, and no great flexibility (no custom items, no custom styles, ... no advanced API for doing stuff programmatically) then you should definitely consider using the one from the design library. 11 | 12 | If you have a more advanced use case, like using the profile switcher, the profile page, custom items like different sizes, or checkboxes, etc then you might want to stay with my library. 13 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source "https://rubygems.org" 4 | 5 | git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } 6 | 7 | gem 'danger' 8 | gem 'danger-android_lint' 9 | gem 'danger-kotlin_detekt' -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | addressable (2.8.7) 5 | public_suffix (>= 2.0.2, < 7.0) 6 | ansi (1.5.0) 7 | ast (2.4.2) 8 | base64 (0.2.0) 9 | claide (1.1.0) 10 | claide-plugins (0.9.2) 11 | cork 12 | nap 13 | open4 (~> 1.3) 14 | colored2 (3.1.2) 15 | cork (0.3.0) 16 | colored2 (~> 3.1) 17 | danger (9.5.1) 18 | base64 (~> 0.2) 19 | claide (~> 1.0) 20 | claide-plugins (>= 0.9.2) 21 | colored2 (~> 3.1) 22 | cork (~> 0.1) 23 | faraday (>= 0.9.0, < 3.0) 24 | faraday-http-cache (~> 2.0) 25 | git (~> 1.13) 26 | kramdown (~> 2.3) 27 | kramdown-parser-gfm (~> 1.0) 28 | octokit (>= 4.0) 29 | pstore (~> 0.1) 30 | terminal-table (>= 1, < 4) 31 | danger-android_lint (0.0.12) 32 | danger-plugin-api (~> 1.0) 33 | oga 34 | danger-kotlin_detekt (0.0.3) 35 | danger-plugin-api (~> 1.0) 36 | danger-plugin-api (1.0.0) 37 | danger (> 2.0) 38 | faraday (2.12.2) 39 | faraday-net_http (>= 2.0, < 3.5) 40 | json 41 | logger 42 | faraday-http-cache (2.5.1) 43 | faraday (>= 0.8) 44 | faraday-net_http (3.4.0) 45 | net-http (>= 0.5.0) 46 | git (1.19.1) 47 | addressable (~> 2.8) 48 | rchardet (~> 1.8) 49 | json (2.9.1) 50 | kramdown (2.5.1) 51 | rexml (>= 3.3.9) 52 | kramdown-parser-gfm (1.1.0) 53 | kramdown (~> 2.0) 54 | logger (1.6.4) 55 | nap (1.1.0) 56 | net-http (0.6.0) 57 | uri 58 | octokit (9.2.0) 59 | faraday (>= 1, < 3) 60 | sawyer (~> 0.9) 61 | oga (3.4) 62 | ast 63 | ruby-ll (~> 2.1) 64 | open4 (1.3.4) 65 | pstore (0.1.4) 66 | public_suffix (6.0.1) 67 | rchardet (1.8.0) 68 | rexml (3.4.0) 69 | ruby-ll (2.1.3) 70 | ansi 71 | ast 72 | sawyer (0.9.2) 73 | addressable (>= 2.3.5) 74 | faraday (>= 0.17.3, < 3) 75 | terminal-table (3.0.2) 76 | unicode-display_width (>= 1.1.1, < 3) 77 | unicode-display_width (2.6.0) 78 | uri (1.0.2) 79 | 80 | PLATFORMS 81 | ruby 82 | 83 | DEPENDENCIES 84 | danger 85 | danger-android_lint 86 | danger-kotlin_detekt 87 | 88 | BUNDLED WITH 89 | 2.6.2 90 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.mikepenz.convention.android-application") 3 | id("com.mikepenz.convention.kotlin") 4 | id("com.mikepenz.aboutlibraries.plugin") 5 | id("androidx.navigation.safeargs.kotlin") 6 | } 7 | 8 | android { 9 | namespace = "com.mikepenz.materialdrawer.app" 10 | 11 | defaultConfig { 12 | multiDexEnabled = true 13 | setProperty("archivesBaseName", "MaterialDrawer-v$versionName-c$versionCode") 14 | } 15 | 16 | productFlavors { 17 | } 18 | 19 | buildFeatures { 20 | viewBinding = true 21 | } 22 | 23 | packaging { 24 | resources { 25 | excludes.add("META-INF/library-core_release.kotlin_module") 26 | excludes.add("META-INF/library_release.kotlin_module") 27 | } 28 | } 29 | } 30 | 31 | dependencies { 32 | implementation(project(":materialdrawer")) 33 | implementation(project(":materialdrawer-iconics")) 34 | implementation(project(":materialdrawer-nav")) 35 | 36 | implementation(libs.google.material) 37 | 38 | implementation(libs.androidx.cardView) 39 | implementation(libs.androidx.recyclerView) 40 | implementation(libs.androidx.navigation.fragment) 41 | implementation(libs.androidx.navigation.ui) 42 | 43 | // used to showcase how to load images 44 | implementation("io.coil-kt:coil:2.7.0") 45 | 46 | //used to provide different itemAnimators for the RecyclerView 47 | //https://github.com/mikepenz/ItemAnimators 48 | implementation(libs.itemAnimators.core) 49 | 50 | // used to provide out of the box icon font support. simplifies development, 51 | // and provides scalable icons. the core is very very light 52 | // https://github.com/mikepenz/Android-Iconics 53 | implementation(libs.iconics.core) 54 | 55 | // used to generate the Open Source section 56 | // https://github.com/mikepenz/AboutLibraries 57 | implementation(baseLibs.aboutlibraries.view) 58 | 59 | // used to provide the MiniDrawer to normal Drawer crossfade effect via a SlidingPane layout 60 | // --> https://github.com/mikepenz/MaterialDrawer/blob/develop/app/src/main/java/com/mikepenz/materialdrawer/app/MiniDrawerActivity.java 61 | // https://github.com/mikepenz/Crossfader 62 | implementation("com.mikepenz:crossfader:1.6.0@aar") 63 | // used to provide the two step crossfade DrawerLayout. Which allows to have a mini layout which transforms to a normal layout within the drawer 64 | // --> https://github.com/mikepenz/MaterialDrawer/blob/develop/app/src/main/java/com/mikepenz/materialdrawer/app/CrossfadeDrawerLayoutActvitiy.java 65 | // https://github.com/mikepenz/CrossfadeDrawerLayout 66 | implementation("com.mikepenz:crossfadedrawerlayout:1.1.0@aar") 67 | 68 | // icon fonts used inside the sample 69 | // https://github.com/mikepenz/Android-Iconics 70 | implementation("com.mikepenz:google-material-typeface:4.0.0.2-kotlin@aar") 71 | implementation("com.mikepenz:fontawesome-typeface:5.13.3.0-kotlin@aar") 72 | implementation("com.mikepenz:octicons-typeface:11.1.0.0-kotlin@aar") 73 | 74 | 75 | implementation("androidx.multidex:multidex:2.0.1") 76 | 77 | implementation("androidx.slidingpanelayout:slidingpanelayout:1.1.0") { 78 | version { 79 | strictly("1.1.0") 80 | } 81 | } 82 | implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0") 83 | 84 | 85 | } 86 | 87 | configurations.configureEach { 88 | resolutionStrategy.force(libs.fastAdapter.core) 89 | resolutionStrategy.force(libs.iconics.core) 90 | } -------------------------------------------------------------------------------- /app/gradle.properties: -------------------------------------------------------------------------------- 1 | com.mikepenz.compose.enabled=false -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Entwicklung/android-sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 15 | 16 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 31 | 35 | 38 | 41 | 44 | 47 | 50 | 53 | 56 | 59 | 62 | 65 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /app/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/app/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /app/src/main/java/com/mikepenz/materialdrawer/app/ActionBarActivity.kt: -------------------------------------------------------------------------------- 1 | package com.mikepenz.materialdrawer.app 2 | 3 | import android.os.Bundle 4 | import android.view.MenuItem 5 | import android.widget.Toast 6 | import androidx.appcompat.app.AppCompatActivity 7 | import com.mikepenz.iconics.typeface.library.fontawesome.FontAwesome 8 | import com.mikepenz.materialdrawer.app.databinding.ActivitySampleActionbarBinding 9 | import com.mikepenz.materialdrawer.iconics.iconicsIcon 10 | import com.mikepenz.materialdrawer.model.PrimaryDrawerItem 11 | import com.mikepenz.materialdrawer.model.SecondaryDrawerItem 12 | import com.mikepenz.materialdrawer.model.interfaces.Nameable 13 | import com.mikepenz.materialdrawer.model.interfaces.nameRes 14 | 15 | class ActionBarActivity : AppCompatActivity() { 16 | private lateinit var binding: ActivitySampleActionbarBinding 17 | 18 | override fun onCreate(savedInstanceState: Bundle?) { 19 | //supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); 20 | super.onCreate(savedInstanceState) 21 | binding = ActivitySampleActionbarBinding.inflate(layoutInflater).also { 22 | setContentView(it.root) 23 | } 24 | setTitle(R.string.drawer_item_action_bar_drawer) 25 | 26 | binding.slider.apply { 27 | itemAdapter.add( 28 | PrimaryDrawerItem().apply { 29 | nameRes = R.string.drawer_item_home 30 | iconicsIcon = FontAwesome.Icon.faw_home 31 | }, 32 | SecondaryDrawerItem().apply { 33 | nameRes = R.string.drawer_item_settings 34 | iconicsIcon = FontAwesome.Icon.faw_cog 35 | } 36 | ) 37 | onDrawerItemClickListener = { _, drawerItem, _ -> 38 | if (drawerItem is Nameable) { 39 | Toast.makeText(this@ActionBarActivity, (drawerItem as Nameable).name!!.getText(this@ActionBarActivity), Toast.LENGTH_SHORT).show() 40 | } 41 | false 42 | } 43 | setSavedInstance(savedInstanceState) 44 | } 45 | 46 | supportActionBar?.setDisplayHomeAsUpEnabled(true) 47 | supportActionBar?.setHomeButtonEnabled(false) 48 | } 49 | 50 | override fun onSaveInstanceState(_outState: Bundle) { 51 | //add the values which need to be saved from the drawer to the bundle 52 | super.onSaveInstanceState(binding.slider.saveInstanceState(_outState)) 53 | } 54 | 55 | override fun onOptionsItemSelected(item: MenuItem): Boolean { 56 | return when (item.itemId) { 57 | android.R.id.home -> { 58 | onBackPressed() 59 | true 60 | } 61 | else -> super.onOptionsItemSelected(item) 62 | } 63 | } 64 | 65 | override fun onBackPressed() { 66 | //handle the back press :D close the drawer first and if the drawer is closed close the activity 67 | if (binding.root.isDrawerOpen(binding.slider)) { 68 | binding.root.closeDrawer(binding.slider) 69 | } else { 70 | super.onBackPressed() 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /app/src/main/java/com/mikepenz/materialdrawer/app/CustomApplication.kt: -------------------------------------------------------------------------------- 1 | package com.mikepenz.materialdrawer.app 2 | 3 | import android.content.Context 4 | import android.graphics.drawable.Drawable 5 | import android.net.Uri 6 | import android.widget.ImageView 7 | import androidx.multidex.MultiDexApplication 8 | import coil.dispose 9 | import coil.load 10 | import com.google.android.material.color.DynamicColors 11 | import com.mikepenz.iconics.Iconics 12 | import com.mikepenz.iconics.IconicsDrawable 13 | import com.mikepenz.iconics.utils.backgroundColorRes 14 | import com.mikepenz.iconics.utils.sizeDp 15 | import com.mikepenz.materialdrawer.util.AbstractDrawerImageLoader 16 | import com.mikepenz.materialdrawer.util.DrawerImageLoader 17 | import com.mikepenz.materialdrawer.util.getPlaceHolder 18 | 19 | /** 20 | * Created by mikepenz on 27.03.15. 21 | */ 22 | class CustomApplication : MultiDexApplication() { 23 | override fun onCreate() { 24 | super.onCreate() 25 | 26 | Iconics.init(this) 27 | 28 | DynamicColors.applyToActivitiesIfAvailable(this) 29 | 30 | //initialize and create the image loader logic 31 | /* 32 | DrawerImageLoader.init(object : AbstractDrawerImageLoader() { 33 | override fun set(imageView: ImageView, uri: Uri, placeholder: Drawable) { 34 | Picasso.get().load(uri).placeholder(placeholder).into(imageView) 35 | } 36 | 37 | override fun cancel(imageView: ImageView) { 38 | Picasso.get().cancelRequest(imageView) 39 | } 40 | }) 41 | */ 42 | 43 | //initialize and create the image loader logic 44 | DrawerImageLoader.init(object : AbstractDrawerImageLoader() { 45 | override fun set(imageView: ImageView, uri: Uri, placeholder: Drawable, tag: String?) { 46 | imageView.load(uri) { 47 | allowHardware(false) 48 | placeholder(placeholder) 49 | } 50 | } 51 | 52 | override fun cancel(imageView: ImageView) { 53 | imageView.dispose() 54 | } 55 | 56 | override fun placeholder(ctx: Context, tag: String?): Drawable { 57 | //define different placeholders for different imageView targets 58 | //default tags are accessible via the DrawerImageLoader.Tags 59 | //custom ones can be checked via string. see the CustomUrlBasePrimaryDrawerItem LINE 111 60 | return when (tag) { 61 | DrawerImageLoader.Tags.PROFILE.name -> getPlaceHolder(ctx) 62 | DrawerImageLoader.Tags.ACCOUNT_HEADER.name -> IconicsDrawable(ctx, " ").apply { backgroundColorRes = R.color.colorPrimary; sizeDp = 56 } 63 | "customUrlItem" -> IconicsDrawable(ctx, " ").apply { backgroundColorRes = R.color.colorAccent; sizeDp = 56 } 64 | //we use the default one for 65 | //DrawerImageLoader.Tags.PROFILE_DRAWER_ITEM.name() 66 | else -> super.placeholder(ctx, tag) 67 | } 68 | } 69 | }) 70 | } 71 | } 72 | 73 | -------------------------------------------------------------------------------- /app/src/main/java/com/mikepenz/materialdrawer/app/FragmentActivity.kt: -------------------------------------------------------------------------------- 1 | package com.mikepenz.materialdrawer.app 2 | 3 | import android.os.Bundle 4 | import android.view.Menu 5 | import android.view.MenuItem 6 | import androidx.appcompat.app.AppCompatActivity 7 | import com.mikepenz.materialdrawer.app.databinding.ActivitySampleFragmentBinding 8 | import com.mikepenz.materialdrawer.app.fragment.DrawerFragment 9 | import com.mikepenz.materialdrawer.app.fragment.SecondDrawerFragment 10 | 11 | class FragmentActivity : AppCompatActivity() { 12 | private lateinit var binding: ActivitySampleFragmentBinding 13 | 14 | override fun onCreate(savedInstanceState: Bundle?) { 15 | super.onCreate(savedInstanceState) 16 | binding = ActivitySampleFragmentBinding.inflate(layoutInflater).also { 17 | setContentView(it.root) 18 | } 19 | 20 | // Handle Toolbar 21 | setSupportActionBar(binding.toolbar) 22 | supportActionBar?.setTitle(R.string.drawer_item_fragment_drawer) 23 | 24 | //ignore the DemoFragment and it's layout it's just to showcase the handle with an keyboard 25 | if (savedInstanceState == null) { 26 | val f = DrawerFragment.newInstance("Demo") 27 | supportFragmentManager.beginTransaction().replace(R.id.fragment_container, f).commit() 28 | } 29 | } 30 | 31 | override fun onCreateOptionsMenu(menu: Menu): Boolean { 32 | val inflater = menuInflater 33 | inflater.inflate(R.menu.fragment_menu, menu) 34 | return true 35 | } 36 | 37 | override fun onOptionsItemSelected(item: MenuItem): Boolean { 38 | //handle the click on the back arrow click 39 | when (item.itemId) { 40 | R.id.menu_1 -> { 41 | val f = DrawerFragment.newInstance("Demo") 42 | supportFragmentManager.beginTransaction().replace(R.id.fragment_container, f).commit() 43 | return true 44 | } 45 | R.id.menu_2 -> { 46 | val f2 = SecondDrawerFragment.newInstance("Demo 2") 47 | supportFragmentManager.beginTransaction().replace(R.id.fragment_container, f2).commit() 48 | return true 49 | } 50 | android.R.id.home -> { 51 | onBackPressed() 52 | return true 53 | } 54 | else -> return super.onOptionsItemSelected(item) 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /app/src/main/java/com/mikepenz/materialdrawer/app/MenuDrawerActivity.kt: -------------------------------------------------------------------------------- 1 | package com.mikepenz.materialdrawer.app 2 | 3 | import android.content.res.Configuration 4 | import android.os.Bundle 5 | import android.view.MenuItem 6 | import android.widget.Toast 7 | import androidx.appcompat.app.ActionBarDrawerToggle 8 | import androidx.appcompat.app.AppCompatActivity 9 | import com.mikepenz.materialdrawer.app.databinding.ActivitySampleBinding 10 | import com.mikepenz.materialdrawer.model.interfaces.Nameable 11 | import com.mikepenz.materialdrawer.util.inflateMenu 12 | 13 | class MenuDrawerActivity : AppCompatActivity() { 14 | private lateinit var binding: ActivitySampleBinding 15 | private lateinit var actionBarDrawerToggle: ActionBarDrawerToggle 16 | 17 | override fun onCreate(savedInstanceState: Bundle?) { 18 | super.onCreate(savedInstanceState) 19 | binding = ActivitySampleBinding.inflate(layoutInflater).also { 20 | setContentView(it.root) 21 | } 22 | 23 | // Handle Toolbar 24 | setSupportActionBar(binding.toolbar) 25 | supportActionBar?.setTitle(R.string.drawer_item_menu_drawer) 26 | supportActionBar?.setDisplayHomeAsUpEnabled(true) 27 | supportActionBar?.setHomeButtonEnabled(true) 28 | 29 | actionBarDrawerToggle = ActionBarDrawerToggle(this, binding.root, binding.toolbar, com.mikepenz.materialdrawer.R.string.material_drawer_open, com.mikepenz.materialdrawer.R.string.material_drawer_close) 30 | 31 | binding.slider.apply { 32 | inflateMenu(R.menu.example_menu) 33 | onDrawerItemClickListener = { v, drawerItem, position -> 34 | if (drawerItem is Nameable) { 35 | Toast.makeText(this@MenuDrawerActivity, (drawerItem as Nameable).name!!.getText(this@MenuDrawerActivity), Toast.LENGTH_SHORT).show() 36 | } 37 | false 38 | } 39 | setSavedInstance(savedInstanceState) 40 | } 41 | 42 | // set the selection to the item with the identifier 5 43 | if (savedInstanceState == null) { 44 | binding.slider.setSelection(5, false) 45 | } 46 | } 47 | 48 | override fun onConfigurationChanged(newConfig: Configuration) { 49 | super.onConfigurationChanged(newConfig) 50 | actionBarDrawerToggle.onConfigurationChanged(newConfig) 51 | } 52 | 53 | override fun onPostCreate(savedInstanceState: Bundle?) { 54 | super.onPostCreate(savedInstanceState) 55 | actionBarDrawerToggle.syncState() 56 | } 57 | 58 | override fun onOptionsItemSelected(item: MenuItem): Boolean { 59 | if (actionBarDrawerToggle.onOptionsItemSelected(item)) { 60 | return true 61 | } 62 | return super.onOptionsItemSelected(item) 63 | } 64 | 65 | override fun onSaveInstanceState(_outState: Bundle) { 66 | var outState = _outState 67 | //add the values which need to be saved from the drawer to the bundle 68 | outState = binding.slider.saveInstanceState(outState) 69 | super.onSaveInstanceState(outState) 70 | } 71 | 72 | override fun onBackPressed() { 73 | //handle the back press :D close the drawer first and if the drawer is closed close the activity 74 | if (binding.root.isDrawerOpen(binding.slider)) { 75 | binding.root.closeDrawer(binding.slider) 76 | } else { 77 | super.onBackPressed() 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /app/src/main/java/com/mikepenz/materialdrawer/app/NavControllerActivity.kt: -------------------------------------------------------------------------------- 1 | package com.mikepenz.materialdrawer.app 2 | 3 | import android.os.Bundle 4 | import androidx.appcompat.app.AppCompatActivity 5 | import androidx.appcompat.widget.Toolbar 6 | import androidx.core.os.bundleOf 7 | import androidx.navigation.findNavController 8 | import com.mikepenz.aboutlibraries.LibsBuilder 9 | import com.mikepenz.materialdrawer.app.databinding.ActivitySampleNavBinding 10 | import com.mikepenz.materialdrawer.model.DividerDrawerItem 11 | import com.mikepenz.materialdrawer.model.NavigationDrawerItem 12 | import com.mikepenz.materialdrawer.model.PrimaryDrawerItem 13 | import com.mikepenz.materialdrawer.model.interfaces.withName 14 | import com.mikepenz.materialdrawer.util.addItems 15 | import com.mikepenz.materialdrawer.util.addStickyDrawerItems 16 | import com.mikepenz.materialdrawer.util.setupWithNavController 17 | import java.io.Serializable 18 | 19 | class NavControllerActivity : AppCompatActivity() { 20 | private lateinit var binding: ActivitySampleNavBinding 21 | 22 | override fun onCreate(savedInstanceState: Bundle?) { 23 | super.onCreate(savedInstanceState) 24 | binding = ActivitySampleNavBinding.inflate(layoutInflater).also { 25 | setContentView(it.root) 26 | } 27 | val toolbar = findViewById(R.id.toolbar) 28 | setSupportActionBar(toolbar) 29 | 30 | val navController = findNavController(R.id.nav_host_fragment) 31 | 32 | binding.slider.apply { 33 | addItems( 34 | NavigationDrawerItem(R.id.action_global_fragmentHome, PrimaryDrawerItem().withName("Home"), null, null), 35 | DividerDrawerItem(), 36 | NavigationDrawerItem(R.id.messageFragment1, PrimaryDrawerItem().withName("Fragment1")), 37 | NavigationDrawerItem(R.id.messageFragment2, PrimaryDrawerItem().withName("Fragment2")) 38 | ) 39 | addStickyDrawerItems( 40 | NavigationDrawerItem(R.id.messageFragment3, PrimaryDrawerItem().withName("Fragment3")), 41 | NavigationDrawerItem(R.id.about_libraries, PrimaryDrawerItem().withName("AboutLibs"), bundleOf("data" to (LibsBuilder() as Serializable))) 42 | ) 43 | } 44 | 45 | 46 | // setup the drawer with navigation controller 47 | binding.slider.setupWithNavController(navController) 48 | } 49 | } -------------------------------------------------------------------------------- /app/src/main/java/com/mikepenz/materialdrawer/app/drawerItems/AccountDividerDrawerItem.kt: -------------------------------------------------------------------------------- 1 | package com.mikepenz.materialdrawer.app.drawerItems 2 | 3 | import android.content.res.ColorStateList 4 | import android.view.View 5 | import androidx.annotation.LayoutRes 6 | import androidx.core.view.ViewCompat 7 | import androidx.recyclerview.widget.RecyclerView 8 | import com.mikepenz.materialdrawer.app.R 9 | import com.mikepenz.materialdrawer.holder.ImageHolder 10 | import com.mikepenz.materialdrawer.holder.StringHolder 11 | import com.mikepenz.materialdrawer.model.AbstractDrawerItem 12 | import com.mikepenz.materialdrawer.model.interfaces.IProfile 13 | import com.mikepenz.materialdrawer.util.getDividerColor 14 | 15 | class AccountDividerDrawerItem : AbstractDrawerItem(), IProfile { 16 | override val type: Int 17 | get() = R.id.material_drawer_profile_item_divider 18 | 19 | override val layoutRes: Int 20 | @LayoutRes 21 | get() = com.mikepenz.materialdrawer.R.layout.material_drawer_item_divider 22 | 23 | override var name: StringHolder? = null 24 | override var description: StringHolder? = null 25 | override var icon: ImageHolder? = null 26 | override var iconColor: ColorStateList? = null 27 | 28 | override fun bindView(holder: ViewHolder, payloads: List) { 29 | super.bindView(holder, payloads) 30 | 31 | val ctx = holder.itemView.context 32 | 33 | //set the identifier from the drawerItem here. It can be used to run tests 34 | holder.itemView.id = hashCode() 35 | 36 | //define how the divider should look like 37 | holder.view.isClickable = false 38 | holder.view.isEnabled = false 39 | holder.view.minimumHeight = 1 40 | ViewCompat.setImportantForAccessibility(holder.view, 41 | ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO) 42 | 43 | //set the color for the divider 44 | holder.divider.setBackgroundColor(ctx.getDividerColor()) 45 | 46 | //call the onPostBindView method to trigger post bind view actions (like the listener to modify the item if required) 47 | onPostBindView(this, holder.itemView) 48 | } 49 | 50 | override fun getViewHolder(v: View): ViewHolder { 51 | return ViewHolder(v) 52 | } 53 | 54 | class ViewHolder internal constructor(internal val view: View) : RecyclerView.ViewHolder(view) { 55 | internal val divider: View = view.findViewById(com.mikepenz.materialdrawer.R.id.material_drawer_divider) 56 | } 57 | } -------------------------------------------------------------------------------- /app/src/main/java/com/mikepenz/materialdrawer/app/drawerItems/CustomBaseViewHolder.kt: -------------------------------------------------------------------------------- 1 | package com.mikepenz.materialdrawer.app.drawerItems 2 | 3 | import android.view.View 4 | import android.widget.ImageView 5 | import android.widget.TextView 6 | import androidx.recyclerview.widget.RecyclerView 7 | import com.mikepenz.materialdrawer.app.R 8 | 9 | open class CustomBaseViewHolder(var view: View) : RecyclerView.ViewHolder(view) { 10 | var icon: ImageView = view.findViewById(R.id.material_drawer_icon) 11 | var name: TextView = view.findViewById(R.id.material_drawer_name) 12 | var description: TextView = view.findViewById(R.id.material_drawer_description) 13 | } -------------------------------------------------------------------------------- /app/src/main/java/com/mikepenz/materialdrawer/app/drawerItems/CustomCenteredPrimaryDrawerItem.kt: -------------------------------------------------------------------------------- 1 | package com.mikepenz.materialdrawer.app.drawerItems 2 | 3 | import com.mikepenz.materialdrawer.app.R 4 | import com.mikepenz.materialdrawer.model.PrimaryDrawerItem 5 | 6 | class CustomCenteredPrimaryDrawerItem : PrimaryDrawerItem() { 7 | 8 | override val layoutRes: Int 9 | get() = R.layout.material_drawer_item_primary_centered 10 | 11 | override val type: Int 12 | get() = R.id.material_drawer_item_centered_primary 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/java/com/mikepenz/materialdrawer/app/drawerItems/CustomPrimaryDrawerItem.kt: -------------------------------------------------------------------------------- 1 | package com.mikepenz.materialdrawer.app.drawerItems 2 | 3 | import com.mikepenz.materialdrawer.holder.ColorHolder 4 | import com.mikepenz.materialdrawer.model.AbstractBadgeableDrawerItem 5 | 6 | class CustomPrimaryDrawerItem : AbstractBadgeableDrawerItem() { 7 | 8 | var background: ColorHolder? = null 9 | 10 | fun withBackgroundColor(backgroundColor: Int): CustomPrimaryDrawerItem { 11 | this.background = ColorHolder.fromColor(backgroundColor) 12 | return this 13 | } 14 | 15 | fun withBackgroundRes(backgroundRes: Int): CustomPrimaryDrawerItem { 16 | this.background = ColorHolder.fromColorRes(backgroundRes) 17 | return this 18 | } 19 | 20 | override fun bindView(holder: AbstractBadgeableDrawerItem.ViewHolder, payloads: List) { 21 | super.bindView(holder, payloads) 22 | background?.applyToBackground(holder.itemView) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/mikepenz/materialdrawer/app/drawerItems/CustomUrlPrimaryDrawerItem.kt: -------------------------------------------------------------------------------- 1 | package com.mikepenz.materialdrawer.app.drawerItems 2 | 3 | import android.view.View 4 | import android.widget.TextView 5 | import androidx.annotation.LayoutRes 6 | import com.mikepenz.materialdrawer.app.R 7 | import com.mikepenz.materialdrawer.holder.BadgeStyle 8 | import com.mikepenz.materialdrawer.holder.StringHolder 9 | import com.mikepenz.materialdrawer.model.interfaces.ColorfulBadgeable 10 | 11 | /** 12 | * Created by mikepenz on 03.02.15. 13 | */ 14 | class CustomUrlPrimaryDrawerItem : CustomUrlBasePrimaryDrawerItem(), ColorfulBadgeable { 15 | override var badge: StringHolder? = null 16 | override var badgeStyle: BadgeStyle? = BadgeStyle() 17 | 18 | override val type: Int 19 | get() = R.id.material_drawer_item_custom_url_item 20 | 21 | override val layoutRes: Int 22 | @LayoutRes 23 | get() = com.mikepenz.materialdrawer.R.layout.material_drawer_item_primary 24 | 25 | override fun bindView(holder: ViewHolder, payloads: List) { 26 | super.bindView(holder, payloads) 27 | 28 | val ctx = holder.itemView.context 29 | 30 | //bind the basic view parts 31 | bindViewHelper(holder) 32 | 33 | //set the text for the badge or hide 34 | val badgeVisible = StringHolder.applyToOrHide(badge, holder.badge) 35 | //style the badge if it is visible 36 | if (badgeVisible) { 37 | badgeStyle!!.style(holder.badge, getColor(ctx)) 38 | holder.badge.visibility = View.VISIBLE 39 | } else { 40 | holder.badge.visibility = View.GONE 41 | } 42 | 43 | //define the typeface for our textViews 44 | if (typeface != null) { 45 | holder.badge.typeface = typeface 46 | } 47 | 48 | //call the onPostBindView method to trigger post bind view actions (like the listener to modify the item if required) 49 | onPostBindView(this, holder.itemView) 50 | } 51 | 52 | override fun getViewHolder(v: View): ViewHolder { 53 | return ViewHolder(v) 54 | } 55 | 56 | class ViewHolder(view: View) : CustomBaseViewHolder(view) { 57 | internal val badge: TextView = view.findViewById(R.id.material_drawer_badge) 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /app/src/main/java/com/mikepenz/materialdrawer/app/drawerItems/GmailDrawerItem.kt: -------------------------------------------------------------------------------- 1 | package com.mikepenz.materialdrawer.app.drawerItems 2 | 3 | import android.content.Context 4 | import android.view.View 5 | import com.google.android.material.shape.CornerFamily 6 | import com.google.android.material.shape.ShapeAppearanceModel 7 | import com.mikepenz.materialdrawer.app.R 8 | import com.mikepenz.materialdrawer.model.PrimaryDrawerItem 9 | import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem 10 | import com.mikepenz.materialdrawer.util.themeDrawerItem 11 | 12 | /** 13 | * Describes the main [IDrawerItem] bing used as primary item, following the guidelines 14 | */ 15 | open class GmailDrawerItem : PrimaryDrawerItem() { 16 | 17 | override val type: Int 18 | get() = R.id.material_drawer_item_gmail_item 19 | 20 | override fun applyDrawerItemTheme(ctx: Context, view: View, selected_color: Int, animate: Boolean, shapeAppearanceModel: ShapeAppearanceModel) { 21 | themeDrawerItem(ctx, view, selected_color, animate, shapeAppearanceModel, R.dimen.gmail_material_drawer_item_background_padding_top_bottom, R.dimen.gmail_material_drawer_item_background_padding_start, R.dimen.gmail_material_drawer_item_background_padding_end, isSelected = isSelected) 22 | } 23 | 24 | override fun getShapeAppearanceModel(ctx: Context): ShapeAppearanceModel { 25 | val cornerRadius = ctx.resources.getDimensionPixelSize(R.dimen.gmail_material_drawer_item_corner_radius) 26 | return ShapeAppearanceModel.builder() 27 | .setTopRightCorner(CornerFamily.ROUNDED, cornerRadius.toFloat()) 28 | .setBottomRightCorner(CornerFamily.ROUNDED, cornerRadius.toFloat()) 29 | .build() 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/mikepenz/materialdrawer/app/drawerItems/IconDrawerItem.kt: -------------------------------------------------------------------------------- 1 | package com.mikepenz.materialdrawer.app.drawerItems 2 | 3 | import android.content.Context 4 | import android.content.res.ColorStateList 5 | import android.view.View 6 | import android.widget.ImageView 7 | import androidx.annotation.LayoutRes 8 | import androidx.recyclerview.widget.RecyclerView 9 | import com.mikepenz.materialdrawer.app.R 10 | import com.mikepenz.materialdrawer.holder.ImageHolder 11 | import com.mikepenz.materialdrawer.model.AbstractDrawerItem 12 | import com.mikepenz.materialdrawer.model.interfaces.Iconable 13 | import com.mikepenz.materialdrawer.model.interfaces.SelectIconable 14 | import com.mikepenz.materialdrawer.util.createDrawerItemColorStateList 15 | 16 | /** 17 | * Created by mikepenz on 03.02.15. 18 | */ 19 | class IconDrawerItem : AbstractDrawerItem(), Iconable, SelectIconable { 20 | override var icon: ImageHolder? = null 21 | override var iconColor: ColorStateList? = null 22 | override var selectedIcon: ImageHolder? = null 23 | override var isIconTinted = false 24 | 25 | override val type: Int 26 | get() = R.id.material_drawer_item_icon_only 27 | 28 | override val layoutRes: Int 29 | @LayoutRes 30 | get() = R.layout.material_drawer_item_icon_only 31 | 32 | override fun bindView(holder: ViewHolder, payloads: List) { 33 | super.bindView(holder, payloads) 34 | 35 | val ctx = holder.itemView.context 36 | 37 | //set the identifier from the drawerItem here. It can be used to run tests 38 | holder.itemView.id = hashCode() 39 | 40 | //get the correct color for the icon 41 | val iconColor = this.iconColor ?: ctx.getPrimaryDrawerIconColor() 42 | 43 | //get the drawables for our icon and set it) 44 | val icon = ImageHolder.decideIcon(icon, ctx, iconColor, isIconTinted, 1) 45 | val selectedIcon = ImageHolder.decideIcon(selectedIcon, ctx, iconColor, isIconTinted, 1) 46 | ImageHolder.applyMultiIconTo(icon, selectedIcon, iconColor, isIconTinted, holder.icon) 47 | 48 | //call the onPostBindView method to trigger post bind view actions (like the listener to modify the item if required) 49 | onPostBindView(this, holder.itemView) 50 | } 51 | 52 | override fun getViewHolder(v: View): ViewHolder { 53 | return ViewHolder(v) 54 | } 55 | 56 | class ViewHolder internal constructor(private val view: View) : RecyclerView.ViewHolder(view) { 57 | var icon: ImageView = view.findViewById(R.id.material_drawer_icon) 58 | } 59 | } 60 | 61 | internal fun Context.getPrimaryDrawerIconColor(): ColorStateList { 62 | return createDrawerItemColorStateList(this, com.mikepenz.materialdrawer.R.styleable.MaterialDrawerSliderView_materialDrawerPrimaryIcon)!! 63 | } -------------------------------------------------------------------------------- /app/src/main/java/com/mikepenz/materialdrawer/app/drawerItems/OverflowMenuDrawerItem.kt: -------------------------------------------------------------------------------- 1 | package com.mikepenz.materialdrawer.app.drawerItems 2 | 3 | import android.view.View 4 | import android.widget.ImageButton 5 | import androidx.annotation.LayoutRes 6 | import androidx.appcompat.widget.PopupMenu 7 | import com.mikepenz.iconics.IconicsDrawable 8 | import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial 9 | import com.mikepenz.iconics.utils.sizeDp 10 | import com.mikepenz.materialdrawer.app.R 11 | import com.mikepenz.materialdrawer.model.BaseDescribeableDrawerItem 12 | import com.mikepenz.materialdrawer.model.BaseViewHolder 13 | 14 | /** 15 | * Created by mikepenz on 03.02.15. 16 | */ 17 | class OverflowMenuDrawerItem : BaseDescribeableDrawerItem() { 18 | var menu: Int = 0 19 | var onMenuItemClickListener: PopupMenu.OnMenuItemClickListener? = null 20 | var onDismissListener: PopupMenu.OnDismissListener? = null 21 | 22 | override val type: Int 23 | get() = R.id.material_drawer_item_overflow_menu 24 | 25 | override val layoutRes: Int 26 | @LayoutRes 27 | get() = R.layout.material_drawer_item_overflow_menu_primary 28 | 29 | @Deprecated("Use property setter instead") 30 | fun withMenu(menu: Int): OverflowMenuDrawerItem { 31 | this.menu = menu 32 | return this 33 | } 34 | 35 | @Deprecated("Use property setter instead") 36 | fun withOnMenuItemClickListener(onMenuItemClickListener: PopupMenu.OnMenuItemClickListener): OverflowMenuDrawerItem { 37 | this.onMenuItemClickListener = onMenuItemClickListener 38 | return this 39 | } 40 | 41 | @Deprecated("Use property setter instead") 42 | fun withOnDismissListener(onDismissListener: PopupMenu.OnDismissListener): OverflowMenuDrawerItem { 43 | this.onDismissListener = onDismissListener 44 | return this 45 | } 46 | 47 | override fun bindView(holder: ViewHolder, payloads: List) { 48 | super.bindView(holder, payloads) 49 | 50 | val ctx = holder.itemView.context 51 | 52 | //bind the basic view parts 53 | bindViewHelper(holder) 54 | 55 | //handle menu click 56 | holder.menu.setOnClickListener { view -> 57 | val popup = PopupMenu(view.context, view) 58 | val inflater = popup.menuInflater 59 | inflater.inflate(menu, popup.menu) 60 | 61 | popup.setOnMenuItemClickListener(onMenuItemClickListener) 62 | popup.setOnDismissListener(onDismissListener) 63 | 64 | popup.show() 65 | } 66 | 67 | //handle image 68 | holder.menu.setImageDrawable(IconicsDrawable(ctx, GoogleMaterial.Icon.gmd_more_vert).apply { sizeDp = 12; colorList = getIconColor(ctx) }) 69 | 70 | //call the onPostBindView method to trigger post bind view actions (like the listener to modify the item if required) 71 | onPostBindView(this, holder.itemView) 72 | } 73 | 74 | override fun getViewHolder(v: View): ViewHolder { 75 | return ViewHolder(v) 76 | } 77 | 78 | class ViewHolder(view: View) : BaseViewHolder(view) { 79 | internal val menu: ImageButton = view.findViewById(R.id.material_drawer_menu_overflow) 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /app/src/main/java/com/mikepenz/materialdrawer/app/fragment/DemoFragment.kt: -------------------------------------------------------------------------------- 1 | package com.mikepenz.materialdrawer.app.fragment 2 | 3 | 4 | import android.os.Bundle 5 | import android.view.LayoutInflater 6 | import android.view.View 7 | import android.view.ViewGroup 8 | import androidx.fragment.app.Fragment 9 | import com.mikepenz.materialdrawer.app.databinding.FragmentSampleBinding 10 | 11 | 12 | /** 13 | * A simple [Fragment] subclass. 14 | * This is just a demo fragment with a long scrollable view of editTexts. Don't see this as a reference for anything 15 | */ 16 | class DemoFragment : Fragment() { 17 | private var _binding: FragmentSampleBinding? = null 18 | private val binding get() = _binding!! 19 | 20 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { 21 | // Inflate the layout for this fragment 22 | // don't look at this layout it's just a listView to show how to handle the keyboard 23 | _binding = FragmentSampleBinding.inflate(inflater, container, false) 24 | binding.title.text = arguments?.getString(KEY_TITLE) 25 | return binding.root 26 | } 27 | 28 | companion object { 29 | private val KEY_TITLE = "title" 30 | fun newInstance(title: String): DemoFragment { 31 | return DemoFragment().apply { 32 | arguments = Bundle().apply { putString(KEY_TITLE, title) } 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/mikepenz/materialdrawer/app/fragment/DemoMessageFragment.kt: -------------------------------------------------------------------------------- 1 | package com.mikepenz.materialdrawer.app.fragment 2 | 3 | import android.os.Bundle 4 | import android.view.LayoutInflater 5 | import android.view.View 6 | import android.view.ViewGroup 7 | import androidx.fragment.app.Fragment 8 | import androidx.navigation.fragment.findNavController 9 | import com.mikepenz.materialdrawer.app.R 10 | import com.mikepenz.materialdrawer.app.databinding.FragmentMessageSampleBinding 11 | 12 | class DemoMessageFragment : Fragment() { 13 | 14 | private var _binding: FragmentMessageSampleBinding? = null 15 | private val binding get() = _binding!! 16 | 17 | private var message: String? = null 18 | 19 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { 20 | message = arguments?.let { DemoMessageFragmentArgs.fromBundle(it).message } 21 | _binding = FragmentMessageSampleBinding.inflate(inflater, container, false) 22 | return binding.root 23 | } 24 | 25 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 26 | super.onViewCreated(view, savedInstanceState) 27 | binding.messageTextView.text = "$message" 28 | binding.btnFragmentHome.setOnClickListener { navigateTo(R.id.fragmentHome) } 29 | binding.btnFragment1.setOnClickListener { navigateTo(R.id.messageFragment1) } 30 | binding.btnFragment2.setOnClickListener { navigateTo(R.id.messageFragment2) } 31 | binding.btnFragment3.setOnClickListener { navigateTo(R.id.messageFragment3) } 32 | binding.btnPopup.setOnClickListener { navigateTo(R.id.action_global_fragmentHome) } 33 | } 34 | 35 | private fun navigateTo(destination: Int) { 36 | findNavController().navigate(destination) 37 | } 38 | } -------------------------------------------------------------------------------- /app/src/main/java/com/mikepenz/materialdrawer/app/fragment/SecondDrawerFragment.kt: -------------------------------------------------------------------------------- 1 | package com.mikepenz.materialdrawer.app.fragment 2 | 3 | 4 | import android.os.Bundle 5 | import android.view.LayoutInflater 6 | import android.view.View 7 | import android.view.ViewGroup 8 | import androidx.fragment.app.Fragment 9 | import com.mikepenz.iconics.typeface.library.fontawesome.FontAwesome 10 | import com.mikepenz.materialdrawer.app.R 11 | import com.mikepenz.materialdrawer.app.databinding.FragmentSimpleSampleBinding 12 | import com.mikepenz.materialdrawer.iconics.withIcon 13 | import com.mikepenz.materialdrawer.model.PrimaryDrawerItem 14 | import com.mikepenz.materialdrawer.model.interfaces.withIdentifier 15 | import com.mikepenz.materialdrawer.model.interfaces.withName 16 | 17 | 18 | /** 19 | * A simple [Fragment] subclass. 20 | * This is just a demo fragment with a long scrollable view of editTexts. Don't see this as a reference for anything 21 | */ 22 | class SecondDrawerFragment : Fragment() { 23 | private var _binding: FragmentSimpleSampleBinding? = null 24 | private val binding get() = _binding!! 25 | 26 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { 27 | // Inflate the layout for this fragment 28 | // don't look at this layout it's just a listView to show how to handle the keyboard 29 | _binding = FragmentSimpleSampleBinding.inflate(inflater, container, false) 30 | binding.title.text = arguments?.getString(KEY_TITLE) 31 | return binding.root 32 | } 33 | 34 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 35 | super.onViewCreated(view, savedInstanceState) 36 | 37 | binding.slider.apply { 38 | itemAdapter.add( 39 | PrimaryDrawerItem().withName(R.string.drawer_item_home).withIcon(FontAwesome.Icon.faw_home).withIdentifier(1), 40 | PrimaryDrawerItem().withName(R.string.drawer_item_free_play).withIcon(FontAwesome.Icon.faw_gamepad), 41 | PrimaryDrawerItem().withName(R.string.drawer_item_custom).withIcon(FontAwesome.Icon.faw_eye) 42 | ) 43 | setSavedInstance(savedInstanceState) 44 | setSelection(1) 45 | } 46 | } 47 | 48 | override fun onSaveInstanceState(_outState: Bundle) { 49 | var outState = _outState 50 | //add the values which need to be saved from the drawer to the bundle 51 | outState = binding.slider.saveInstanceState(outState) 52 | super.onSaveInstanceState(outState) 53 | } 54 | 55 | companion object { 56 | private val KEY_TITLE = "title" 57 | 58 | fun newInstance(title: String): SecondDrawerFragment { 59 | return SecondDrawerFragment().apply { 60 | arguments = Bundle().apply { putString(KEY_TITLE, title) } 61 | } 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /app/src/main/java/com/mikepenz/materialdrawer/app/utils/CrossfadeWrapper.kt: -------------------------------------------------------------------------------- 1 | package com.mikepenz.materialdrawer.app.utils 2 | 3 | import com.mikepenz.crossfader.Crossfader 4 | import com.mikepenz.materialdrawer.interfaces.ICrossfader 5 | 6 | /** 7 | * Created by mikepenz on 18.07.15. 8 | */ 9 | class CrossfadeWrapper(private val crossfader: Crossfader<*>) : ICrossfader { 10 | 11 | override val isCrossfaded: Boolean 12 | get() = crossfader.isCrossFaded() 13 | 14 | override fun crossfade() { 15 | crossfader.crossFade() 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/mikepenz/materialdrawer/app/utils/SystemUtils.kt: -------------------------------------------------------------------------------- 1 | package com.mikepenz.materialdrawer.app.utils 2 | 3 | import android.content.res.Resources 4 | 5 | object SystemUtils { 6 | val screenOrientation: Int 7 | get() = Resources.getSystem().configuration.orientation 8 | } 9 | -------------------------------------------------------------------------------- /app/src/main/java/com/mikepenz/materialdrawer/app/utils/UIUtils.kt: -------------------------------------------------------------------------------- 1 | package com.mikepenz.materialdrawer.app.utils 2 | 3 | import android.content.Context 4 | import android.content.res.Resources 5 | import android.util.DisplayMetrics 6 | 7 | 8 | /** 9 | * This method converts dp unit to equivalent pixels, depending on device density. 10 | * 11 | * @param dp A value in dp (density independent pixels) unit. Which we need to convert into pixels 12 | * @param context Context to get resources and device specific display metrics 13 | * @return A float value to represent px equivalent to dp depending on device density 14 | */ 15 | fun convertDpToPixel(dp: Float, context: Context): Float { 16 | val resources: Resources = context.resources 17 | val metrics: DisplayMetrics = resources.displayMetrics 18 | return dp * (metrics.densityDpi / 160f) 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/header.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/app/src/main/res/drawable/header.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/profile.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/app/src/main/res/drawable/profile.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/profile2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/app/src/main/res/drawable/profile2.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/profile3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/app/src/main/res/drawable/profile3.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/profile4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/app/src/main/res/drawable/profile4.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/profile5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/app/src/main/res/drawable/profile5.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/profile6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/app/src/main/res/drawable/profile6.jpg -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_embedded.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 18 | 19 | 27 | 28 | 32 | 33 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_mini_drawer.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 13 | 14 | 18 | 19 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_multi_sample.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 12 | 13 | 23 | 24 | 33 | 34 | 41 | 42 | 43 | 44 | 50 | 51 | 57 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_persistent_drawer.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 14 | 15 | 24 | 25 | 32 | 33 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_sample.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 12 | 13 | 21 | 22 | 30 | 31 | 38 | 39 | 40 | 41 | 47 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_sample_actionbar.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 11 | 12 | 19 | 20 | 21 | 27 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_sample_crossfader.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 12 | 13 | 21 | 22 | 30 | 31 | 38 | 39 | 40 | 41 | 47 | 48 | 57 | 58 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_sample_fragment.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 13 | 14 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_sample_fullscreen.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 12 | 13 | 22 | 23 | 33 | 34 | 41 | 42 | 43 | 44 | 50 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_sample_nav.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 12 | 13 | 22 | 23 | 24 | 35 | 36 | 37 | 43 | -------------------------------------------------------------------------------- /app/src/main/res/layout/footer.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_simple_sample.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 24 | 25 | 26 | 27 | 33 | -------------------------------------------------------------------------------- /app/src/main/res/layout/header.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/layout/material_drawer_item_icon_only.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/layout/material_drawer_item_overflow_menu_primary.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 23 | 24 | 30 | 31 | 42 | 43 | 54 | 55 | 56 | 67 | -------------------------------------------------------------------------------- /app/src/main/res/layout/material_drawer_item_primary_centered.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 24 | 25 | 30 | 31 | 42 | 43 | 54 | 55 | 56 | 73 | 74 | -------------------------------------------------------------------------------- /app/src/main/res/menu/cab.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/menu/embedded.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/menu/example_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | 11 | 15 | 16 | 20 | 24 | 28 | 29 | 30 | 34 | 38 | 39 | 43 | 47 | 48 | 49 | 50 | 51 | 56 | 57 | -------------------------------------------------------------------------------- /app/src/main/res/menu/fragment_menu.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 9 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/menu/main.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 9 | 14 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/navigation/navigation.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 17 | 20 | 23 | 26 | 29 | 30 | 35 | 39 | 40 | 45 | 49 | 50 | 55 | 59 | 60 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | #039be5 10 | #006db3 11 | #63ccff 12 | #2196F3 13 | 14 | #039be5 15 | #039be5 16 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4dp 4 | 48dp 5 | 32dp 6 | 7 | 20dp 8 | 0dp 9 | 8dp 10 | 4dp 11 | -------------------------------------------------------------------------------- /app/src/main/res/values/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/ids.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | 22 | 23 | 28 | 29 | 36 | -------------------------------------------------------------------------------- /app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 14 | 15 | 24 | 25 | 34 | 35 | 36 | 15 | 16 | 21 | 22 | 23 | 29 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "MaterialDrawer" 2 | 3 | // enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") 4 | 5 | pluginManagement { 6 | repositories { 7 | google() 8 | gradlePluginPortal() 9 | mavenCentral() 10 | mavenLocal() 11 | } 12 | } 13 | 14 | dependencyResolutionManagement { 15 | repositories { 16 | google() 17 | mavenCentral() 18 | mavenLocal() 19 | } 20 | 21 | versionCatalogs { 22 | create("baseLibs") { 23 | from("com.mikepenz:version-catalog:0.1.3") 24 | } 25 | } 26 | } 27 | 28 | 29 | include(":app") 30 | include(":materialdrawer") 31 | include(":materialdrawer-iconics") 32 | include(":materialdrawer-nav") --------------------------------------------------------------------------------