├── .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 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/embedded.xml:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/example_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/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 |
37 |
--------------------------------------------------------------------------------
/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | alias(baseLibs.plugins.conventionPlugin)
3 |
4 | alias(baseLibs.plugins.kotlinAndroid) apply false
5 | alias(baseLibs.plugins.androidApplication) apply false
6 | alias(baseLibs.plugins.androidLibrary) apply false
7 |
8 | alias(baseLibs.plugins.dokka)
9 | alias(baseLibs.plugins.aboutLibraries) apply false
10 | alias(baseLibs.plugins.mavenPublish) apply false
11 |
12 | alias(libs.plugins.navSafeArgs) apply false
13 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Maven stuff
2 | GROUP=com.mikepenz
3 | VERSION_NAME=10.0.0-b01
4 | VERSION_CODE=10000
5 |
6 | POM_URL=https://github.com/mikepenz/MaterialDrawer
7 | POM_SCM_URL=https://github.com/mikepenz/MaterialDrawer
8 | POM_SCM_CONNECTION=scm:git@github.com:mikepenz/MaterialDrawer.git
9 | POM_SCM_DEV_CONNECTION=scm:git@github.com:mikepenz/MaterialDrawer.git
10 | POM_SCM_URL_ISSUES=https://github.com/mikepenz/MaterialDrawer/issues
11 | POM_GITHUB_REPO=mikepenz/MaterialDrawer
12 | POM_GITHUB_README=README.md
13 | POM_LICENCE_NAME=Apache-2.0
14 | POM_LICENCE_URL=https://www.apache.org/licenses/LICENSE-2.0.txt
15 | POM_LICENCE_DIST=repo
16 | POM_DEVELOPER_ID=mikepenz
17 | POM_DEVELOPER_NAME=Mike Penz
18 | # Project-wide Gradle settings.
19 | org.gradle.jvmargs=-Xmx1536m
20 | android.useAndroidX=true
21 | android.enableJetifier=false
22 | org.gradle.caching=true
23 | org.gradle.configuration-cache=false
24 | android.suppressUnsupportedCompileSdk=34
25 | # Dokka
26 | org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
27 | org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true
28 | # convention plugin
29 | com.mikepenz.kotlin.warningsAsErrors.enabled=false
--------------------------------------------------------------------------------
/gradle/libs.versions.toml:
--------------------------------------------------------------------------------
1 | [versions]
2 | # androidx
3 | appcompat = "1.7.0"
4 | cardview = "1.0.0"
5 | constraintLayout = "2.2.0"
6 | core = "1.15.0"
7 | drawerlayout = "1.2.0"
8 | navigation = "2.8.6"
9 | recyclerView = "1.4.0"
10 | # google
11 | material = "1.12.0"
12 | # other
13 | fastAdapter = "5.7.0"
14 | iconics = "5.4.0"
15 | itemAnimators = "1.1.0"
16 |
17 | [plugins]
18 | navSafeArgs = { id = "androidx.navigation.safeargs", version.ref = "navigation" }
19 |
20 | [libraries]
21 | # androidx
22 | androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" }
23 | androidx-cardView = { module = "androidx.cardview:cardview", version.ref = "cardview" }
24 | androidx-constraintLayout = { module = "androidx.constraintlayout:constraintlayout", version.ref = "constraintLayout" }
25 | androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "core" }
26 | androidx-drawerlayout = { module = "androidx.drawerlayout:drawerlayout", version.ref = "drawerlayout" }
27 | androidx-navigation-fragment = { module = "androidx.navigation:navigation-fragment", version.ref = "navigation" }
28 | androidx-navigation-runtime = { module = "androidx.navigation:navigation-runtime-ktx", version.ref = "navigation" }
29 | androidx-navigation-ui = { module = "androidx.navigation:navigation-ui-ktx", version.ref = "navigation" }
30 | androidx-recyclerView = { module = "androidx.recyclerview:recyclerview", version.ref = "recyclerView" }
31 | # google
32 | google-material = { module = "com.google.android.material:material", version.ref = "material" }
33 | # other
34 | fastAdapter-core = { module = "com.mikepenz:fastadapter", version.ref = "fastAdapter" }
35 | fastAdapter-expandable = { module = "com.mikepenz:fastadapter-extensions-expandable", version.ref = "fastAdapter" }
36 | iconics-core = { module = "com.mikepenz:iconics-core", version.ref = "iconics" }
37 | itemAnimators-core = { module = "com.mikepenz:itemanimators", version.ref = "itemAnimators" }
38 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
4 | networkTimeout=10000
5 | validateDistributionUrl=true
6 | zipStoreBase=GRADLE_USER_HOME
7 | zipStorePath=wrapper/dists
8 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 | @rem SPDX-License-Identifier: Apache-2.0
17 | @rem
18 |
19 | @if "%DEBUG%"=="" @echo off
20 | @rem ##########################################################################
21 | @rem
22 | @rem Gradle startup script for Windows
23 | @rem
24 | @rem ##########################################################################
25 |
26 | @rem Set local scope for the variables with windows NT shell
27 | if "%OS%"=="Windows_NT" setlocal
28 |
29 | set DIRNAME=%~dp0
30 | if "%DIRNAME%"=="" set DIRNAME=.
31 | @rem This is normally unused
32 | set APP_BASE_NAME=%~n0
33 | set APP_HOME=%DIRNAME%
34 |
35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
37 |
38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
40 |
41 | @rem Find java.exe
42 | if defined JAVA_HOME goto findJavaFromJavaHome
43 |
44 | set JAVA_EXE=java.exe
45 | %JAVA_EXE% -version >NUL 2>&1
46 | if %ERRORLEVEL% equ 0 goto execute
47 |
48 | echo. 1>&2
49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50 | echo. 1>&2
51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52 | echo location of your Java installation. 1>&2
53 |
54 | goto fail
55 |
56 | :findJavaFromJavaHome
57 | set JAVA_HOME=%JAVA_HOME:"=%
58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
59 |
60 | if exist "%JAVA_EXE%" goto execute
61 |
62 | echo. 1>&2
63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64 | echo. 1>&2
65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66 | echo location of your Java installation. 1>&2
67 |
68 | goto fail
69 |
70 | :execute
71 | @rem Setup the command line
72 |
73 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
74 |
75 |
76 | @rem Execute Gradle
77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
78 |
79 | :end
80 | @rem End local scope for the variables with windows NT shell
81 | if %ERRORLEVEL% equ 0 goto mainEnd
82 |
83 | :fail
84 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
85 | rem the _cmd.exe /c_ return code!
86 | set EXIT_CODE=%ERRORLEVEL%
87 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
88 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
89 | exit /b %EXIT_CODE%
90 |
91 | :mainEnd
92 | if "%OS%"=="Windows_NT" endlocal
93 |
94 | :omega
95 |
--------------------------------------------------------------------------------
/materialdrawer-iconics/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/materialdrawer-iconics/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id("com.mikepenz.convention.android-library")
3 | id("com.mikepenz.convention.kotlin")
4 | id("com.mikepenz.convention.publishing")
5 | }
6 |
7 | android {
8 | namespace = "com.mikepenz.materialdrawer.iconics"
9 | }
10 |
11 | dependencies {
12 | implementation(project(":materialdrawer"))
13 |
14 | // used to provide out of the box icon font support. simplifies development,
15 | // and provides scalable icons. the core is very very light
16 | // https://github.com/mikepenz/Android-Iconics
17 | implementation(libs.iconics.core)
18 | }
--------------------------------------------------------------------------------
/materialdrawer-iconics/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_NAME=MaterialDrawer Iconics-Extension
2 | POM_DESCRIPTION=Extension for the MaterialDrawer library to add Android-Iconics support.
3 | POM_ARTIFACT_ID=materialdrawer-iconics
4 | POM_PACKAGING=aar
--------------------------------------------------------------------------------
/materialdrawer-iconics/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/materialdrawer-iconics/src/main/java/com/mikepenz/materialdrawer/iconics/IconicsExtension.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.iconics
2 |
3 | import android.os.Build
4 | import com.mikepenz.iconics.typeface.IIcon
5 | import com.mikepenz.materialdrawer.model.BaseDrawerItem
6 | import com.mikepenz.materialdrawer.model.interfaces.Iconable
7 | import com.mikepenz.materialdrawer.model.interfaces.withIconTintingEnabled
8 |
9 | var > T.iconicsIcon: IIcon
10 | @Deprecated(level = DeprecationLevel.ERROR, message = "Not readable")
11 | get() = throw UnsupportedOperationException("Please use the direct property")
12 | set(value) {
13 | this.iconicsIconHolder = IconicsImageHolder(value)
14 | }
15 |
16 | var > T.iconicsIconHolder: IconicsImageHolder?
17 | get() = icon as? IconicsImageHolder
18 | set(value) {
19 | this.icon = value
20 | //if we are on api 21 or higher we use the IconicsDrawable for selection too and color it with the correct color
21 | //else we use just the one drawable and enable tinting on press
22 | if (Build.VERSION.SDK_INT >= 21) {
23 | this.selectedIcon = value
24 | } else if (value != null) {
25 | this.withIconTintingEnabled(true)
26 | }
27 | }
28 |
29 | @Deprecated("Please consider to replace with the actual property setter")
30 | fun > T.withIcon(icon: IIcon): T {
31 | this.iconicsIconHolder = IconicsImageHolder(icon)
32 | return this
33 | }
34 |
35 | var T.iconicsIcon: IIcon
36 | @Deprecated(level = DeprecationLevel.ERROR, message = "Not readable")
37 | get() = throw UnsupportedOperationException("Please use the direct property")
38 | set(value) {
39 | this.icon = IconicsImageHolder(value)
40 | }
41 |
42 | @Deprecated("Please consider to replace with the actual property setter")
43 | fun T.withIcon(icon: IIcon): T {
44 | this.icon = IconicsImageHolder(icon)
45 | return this
46 | }
--------------------------------------------------------------------------------
/materialdrawer-iconics/src/main/java/com/mikepenz/materialdrawer/iconics/IconicsImageHolder.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.iconics
2 |
3 | import android.content.Context
4 | import android.content.res.ColorStateList
5 | import android.graphics.PorterDuff
6 | import android.graphics.drawable.Drawable
7 | import android.widget.ImageView
8 | import androidx.appcompat.content.res.AppCompatResources
9 | import com.mikepenz.iconics.IconicsDrawable
10 | import com.mikepenz.iconics.typeface.IIcon
11 | import com.mikepenz.iconics.utils.actionBar
12 | import com.mikepenz.iconics.utils.paddingDp
13 | import com.mikepenz.iconics.utils.sizeDp
14 | import com.mikepenz.materialdrawer.holder.ImageHolder
15 | import com.mikepenz.materialdrawer.util.DrawerImageLoader
16 | import java.io.FileNotFoundException
17 |
18 | class IconicsImageHolder(iicon: IIcon) : ImageHolder() {
19 |
20 | var iicon: IIcon? = iicon
21 | internal set
22 |
23 |
24 | /**
25 | * sets an existing image to the imageView
26 | *
27 | * @param imageView
28 | * @param tag used to identify imageViews and define different placeholders
29 | * @return true if an image was set
30 | */
31 | override fun applyTo(imageView: ImageView, tag: String?): Boolean {
32 | val ii = iicon
33 | val uri = uri
34 |
35 | if (uri != null) {
36 | val consumed = DrawerImageLoader.instance.setImage(imageView, uri, tag)
37 | if (!consumed) {
38 | imageView.setImageURI(uri)
39 | }
40 | } else if (icon != null) {
41 | imageView.setImageDrawable(icon)
42 | } else if (bitmap != null) {
43 | imageView.setImageBitmap(bitmap)
44 | } else if (iconRes != -1) {
45 | imageView.setImageResource(iconRes)
46 | } else if (ii != null) {
47 | imageView.setImageDrawable(IconicsDrawable(imageView.context, ii).actionBar())
48 | } else {
49 | imageView.setImageBitmap(null)
50 | return false
51 | }
52 | return true
53 | }
54 |
55 | /**
56 | * this only handles Drawables
57 | *
58 | * @param ctx
59 | * @param iconColor
60 | * @param tint
61 | * @return
62 | */
63 | override fun decideIcon(ctx: Context, iconColor: ColorStateList, tint: Boolean, paddingDp: Int): Drawable? {
64 | var icon: Drawable? = icon
65 | val ii = iicon
66 | val uri = uri
67 |
68 | when {
69 | ii != null -> icon = IconicsDrawable(ctx, ii).apply {
70 | colorList = iconColor
71 | sizeDp = 24
72 | this.paddingDp = paddingDp
73 | }
74 | iconRes != -1 -> icon = AppCompatResources.getDrawable(ctx, iconRes)
75 | uri != null -> try {
76 | val inputStream = ctx.contentResolver.openInputStream(uri)
77 | icon = Drawable.createFromStream(inputStream, uri.toString())
78 | } catch (e: FileNotFoundException) {
79 | //no need to handle this
80 | }
81 | }
82 | //if we got an icon AND we have auto tinting enabled AND it is no IIcon, tint it ;)
83 | if (icon != null && tint && iicon == null) {
84 | icon = icon.mutate()
85 | icon.setColorFilter(iconColor.defaultColor, PorterDuff.Mode.SRC_IN)
86 | }
87 | return icon
88 | }
89 | }
--------------------------------------------------------------------------------
/materialdrawer-nav/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/materialdrawer-nav/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id("com.mikepenz.convention.android-library")
3 | id("com.mikepenz.convention.kotlin")
4 | id("com.mikepenz.convention.publishing")
5 | id("androidx.navigation.safeargs.kotlin")
6 | }
7 |
8 | android {
9 | namespace = "com.mikepenz.materialdrawer.nav"
10 | }
11 |
12 | dependencies {
13 | implementation(project(":materialdrawer"))
14 |
15 | implementation(libs.androidx.navigation.runtime)
16 | implementation(libs.androidx.navigation.ui)
17 | }
--------------------------------------------------------------------------------
/materialdrawer-nav/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/materialdrawer-nav/consumer-rules.pro
--------------------------------------------------------------------------------
/materialdrawer-nav/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_NAME=MaterialDrawer NavController-Extension
2 | POM_DESCRIPTION=Extension for the MaterialDrawer library to add NavController support.
3 | POM_ARTIFACT_ID=materialdrawer-nav
4 | POM_PACKAGING=aar
--------------------------------------------------------------------------------
/materialdrawer-nav/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/materialdrawer-nav/proguard-rules.txt:
--------------------------------------------------------------------------------
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 ProGuard
5 | # include property in project.properties.
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 | #}
--------------------------------------------------------------------------------
/materialdrawer-nav/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/materialdrawer-nav/src/main/java/com/mikepenz/materialdrawer/model/NavigationDrawerItem.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.model
2 |
3 | import android.content.Context
4 | import android.os.Bundle
5 | import android.view.LayoutInflater
6 | import android.view.View
7 | import android.view.ViewGroup
8 | import androidx.annotation.CallSuper
9 | import androidx.annotation.IdRes
10 | import androidx.navigation.NavOptions
11 | import androidx.recyclerview.widget.RecyclerView
12 | import com.mikepenz.materialdrawer.R
13 | import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem
14 |
15 | class NavigationDrawerItem(
16 | @IdRes val resId: Int,
17 | val item: IDrawerItem,
18 | val args: Bundle? = null,
19 | val options: NavOptions? = defaultOptions
20 | ) : IDrawerItem by item {
21 |
22 | init {
23 | item.identifier = resId.toLong()
24 | }
25 |
26 | /**
27 | * generates a view by the defined LayoutRes
28 | */
29 | override fun generateView(ctx: Context): View {
30 | val viewHolder = getViewHolder(LayoutInflater.from(ctx).inflate(layoutRes, null, false) as ViewGroup)
31 | bindView(viewHolder, mutableListOf())
32 | return viewHolder.itemView
33 | }
34 |
35 | /**
36 | * generates a view by the defined LayoutRes and pass the LayoutParams from the parent
37 | */
38 | override fun generateView(ctx: Context, parent: ViewGroup): View {
39 | val viewHolder = getViewHolder(LayoutInflater.from(ctx).inflate(layoutRes, parent, false) as ViewGroup)
40 | bindView(viewHolder, mutableListOf())
41 | return viewHolder.itemView
42 | }
43 |
44 | @CallSuper
45 | override fun bindView(holder: VH, payloads: List) {
46 | item.bindView(holder, payloads)
47 | holder.itemView.setTag(R.id.material_drawer_item, this)
48 | }
49 |
50 | companion object {
51 | val defaultOptions = NavOptions.Builder()
52 | .setLaunchSingleTop(true)
53 | .setEnterAnim(androidx.navigation.ui.R.anim.nav_default_enter_anim)
54 | .setExitAnim(androidx.navigation.ui.R.anim.nav_default_exit_anim)
55 | .setPopEnterAnim(androidx.navigation.ui.R.anim.nav_default_pop_enter_anim)
56 | .setPopExitAnim(androidx.navigation.ui.R.anim.nav_default_pop_exit_anim)
57 | .build()
58 | }
59 | }
--------------------------------------------------------------------------------
/materialdrawer/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/materialdrawer/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id("com.mikepenz.convention.android-library")
3 | id("com.mikepenz.convention.kotlin")
4 | id("com.mikepenz.convention.publishing")
5 | }
6 |
7 | android {
8 | namespace = "com.mikepenz.materialdrawer"
9 | }
10 |
11 | dependencies {
12 | implementation(libs.androidx.appcompat)
13 | implementation(libs.androidx.core.ktx)
14 |
15 | api(libs.androidx.drawerlayout)
16 | api(libs.androidx.recyclerView)
17 | implementation(libs.androidx.cardView)
18 | implementation(libs.google.material)
19 |
20 | // add the constraintLayout used to create the items and headers
21 | implementation(libs.androidx.constraintLayout)
22 |
23 | // used to fill the RecyclerView with the items
24 | // and provides single and multi selection, expandable items
25 | // https://github.com/mikepenz/FastAdapter
26 | api(libs.fastAdapter.core)
27 | api(libs.fastAdapter.expandable)
28 | }
--------------------------------------------------------------------------------
/materialdrawer/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_NAME=MaterialDrawer Library
2 | POM_DESCRIPTION=The flexible, easy to use, all in one drawer library for your Android project.
3 | POM_ARTIFACT_ID=materialdrawer
4 | POM_PACKAGING=aar
--------------------------------------------------------------------------------
/materialdrawer/proguard-rules.txt:
--------------------------------------------------------------------------------
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 ProGuard
5 | # include property in project.properties.
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 | #}
--------------------------------------------------------------------------------
/materialdrawer/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/java/com/mikepenz/materialdrawer/holder/DimenHolder.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.holder
2 |
3 | import android.content.Context
4 | import android.content.res.Resources
5 | import android.util.DisplayMetrics
6 | import androidx.annotation.DimenRes
7 | import androidx.annotation.Dimension
8 | import androidx.annotation.Dimension.Companion.DP
9 | import androidx.annotation.Dimension.Companion.PX
10 |
11 |
12 | /**
13 | * Defines a custom holder class to support providing dimension either as pixel, dp or dimensRes. Does not require a [Context] and will resolve the value when applying.
14 | */
15 | open class DimenHolder {
16 | /** Defines the pixel dimension */
17 | var pixel = Int.MIN_VALUE
18 | internal set
19 | /** Defines the dp dimension */
20 | var dp = Int.MIN_VALUE
21 | internal set
22 | /** Defines the resource dimension */
23 | var resource = Int.MIN_VALUE
24 | internal set
25 |
26 | /** Resturns this [DimenHolder]`s dimension as pixel value */
27 | open fun asPixel(ctx: Context): Int {
28 | return when {
29 | pixel != Int.MIN_VALUE -> pixel
30 | dp != Int.MIN_VALUE -> ctx.convertDpToPixel(dp)
31 | resource != Int.MIN_VALUE -> ctx.resources.getDimensionPixelSize(resource)
32 | else -> 0
33 | }
34 | }
35 |
36 | companion object {
37 | /**
38 | * Constructs a [DimenHolder] given a pixel value
39 | */
40 | fun fromPixel(@Dimension(unit = PX) pixel: Int): DimenHolder {
41 | val dimenHolder = DimenHolder()
42 | dimenHolder.pixel = pixel
43 | return dimenHolder
44 | }
45 |
46 | /**
47 | * Constructs a [DimenHolder] given a dp value
48 | */
49 | fun fromDp(@Dimension(unit = DP) dp: Int): DimenHolder {
50 | val dimenHolder = DimenHolder()
51 | dimenHolder.dp = dp
52 | return dimenHolder
53 | }
54 |
55 | /**
56 | * Constructs a [DimenHolder] given a resource id
57 | */
58 | fun fromResource(@DimenRes resource: Int): DimenHolder {
59 | val dimenHolder = DimenHolder()
60 | dimenHolder.resource = resource
61 | return dimenHolder
62 | }
63 | }
64 | }
65 |
66 |
67 | /**
68 | * This method converts dp unit to equivalent pixels, depending on device density.
69 | */
70 | private fun Context.convertDpToPixel(dp: Int): Int {
71 | val resources: Resources = resources
72 | val metrics: DisplayMetrics = resources.displayMetrics
73 | return (dp * (metrics.densityDpi / 160.0)).toInt()
74 | }
75 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/java/com/mikepenz/materialdrawer/holder/StringHolder.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.holder
2 |
3 | import android.content.Context
4 | import android.view.View
5 | import android.widget.TextView
6 | import androidx.annotation.StringRes
7 |
8 | /**
9 | * Defines a custom holder class to support providing strings either as string or resource. Does not require a [Context] and will resolve the value when applying.
10 | */
11 | open class StringHolder {
12 | /** Defines the string text */
13 | var textString: CharSequence? = null
14 | internal set
15 | /** Defines the string resource */
16 | var textRes = -1
17 | internal set
18 |
19 | constructor(text: CharSequence?) {
20 | this.textString = text
21 | }
22 |
23 | constructor(@StringRes textRes: Int) {
24 | this.textRes = textRes
25 | }
26 |
27 | /**
28 | * Applies the text to a [TextView]
29 | */
30 | open fun applyTo(textView: TextView?) {
31 | when {
32 | textString != null -> textView?.text = textString
33 | textRes != -1 -> textView?.setText(textRes)
34 | else -> textView?.text = ""
35 | }
36 | }
37 |
38 | /**
39 | * Applies the [TextView] if no text given, hide the textView
40 | */
41 | open fun applyToOrHide(textView: TextView?): Boolean {
42 | textView ?: return false
43 | return when {
44 | textString != null -> {
45 | textView.text = textString
46 | textView.visibility = View.VISIBLE
47 | true
48 | }
49 | textRes != -1 -> {
50 | textView.setText(textRes)
51 | textView.visibility = View.VISIBLE
52 | true
53 | }
54 | else -> {
55 | textView.visibility = View.GONE
56 | false
57 | }
58 | }
59 | }
60 |
61 | /**
62 | * Returns the text as [String]
63 | */
64 | open fun getText(ctx: Context): String? {
65 | if (textString != null) {
66 | return textString.toString()
67 | } else if (textRes != -1) {
68 | return ctx.getString(textRes)
69 | }
70 | return null
71 | }
72 |
73 | companion object {
74 | /**
75 | * Helper to apply the text to a [TextView]
76 | */
77 | fun applyTo(text: StringHolder?, textView: TextView?) {
78 | text?.applyTo(textView)
79 | }
80 |
81 | /**
82 | * Helper to apply the text to a [TextView] or hide if null
83 | */
84 | fun applyToOrHide(text: StringHolder?, textView: TextView?): Boolean {
85 | return if (text != null) {
86 | text.applyToOrHide(textView)
87 | } else {
88 | textView?.visibility = View.GONE
89 | false
90 | }
91 | }
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/java/com/mikepenz/materialdrawer/interfaces/ICrossfader.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.interfaces
2 |
3 | /**
4 | * Helper interface to allow providing crossfade functionality with different implementations to the drawer
5 | */
6 | interface ICrossfader {
7 |
8 | /**
9 | * returns true if currently crossfaded
10 | */
11 | val isCrossfaded: Boolean
12 |
13 | /**
14 | * allows to toggle the crossfade state
15 | */
16 | fun crossfade()
17 | }
18 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/java/com/mikepenz/materialdrawer/interfaces/OnCheckedChangeListener.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.interfaces
2 |
3 | import android.widget.CompoundButton
4 |
5 | import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem
6 |
7 | /**
8 | * Interface definition for a callback to be invoked when the checked state
9 | * of a compound button changed.
10 | */
11 | interface OnCheckedChangeListener {
12 | /**
13 | * Called when the checked state of a compound button has changed.
14 | */
15 | fun onCheckedChanged(drawerItem: IDrawerItem<*>, buttonView: CompoundButton, isChecked: Boolean)
16 | }
--------------------------------------------------------------------------------
/materialdrawer/src/main/java/com/mikepenz/materialdrawer/interfaces/OnPostBindViewListener.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.interfaces
2 |
3 | import android.view.View
4 | import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem
5 |
6 | /**
7 | * Defines the listener fired after binding a view
8 | */
9 | interface OnPostBindViewListener {
10 | /**
11 | * allows you to hook in the BindView method and modify the view after binding
12 | */
13 | fun onBindView(drawerItem: IDrawerItem<*>, view: View)
14 | }
15 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/java/com/mikepenz/materialdrawer/model/AbstractBadgeableDrawerItem.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.model
2 |
3 | import android.view.View
4 | import android.widget.TextView
5 | import androidx.annotation.LayoutRes
6 | import com.mikepenz.materialdrawer.R
7 | import com.mikepenz.materialdrawer.holder.BadgeStyle
8 | import com.mikepenz.materialdrawer.holder.StringHolder
9 | import com.mikepenz.materialdrawer.model.interfaces.ColorfulBadgeable
10 | import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem
11 |
12 | /**
13 | * An abstract [IDrawerItem] implementation describing an element which supports badges
14 | */
15 | abstract class AbstractBadgeableDrawerItem- > : BaseDescribeableDrawerItem
- (), ColorfulBadgeable {
16 | override var badge: StringHolder? = null
17 | override var badgeStyle: BadgeStyle? = BadgeStyle()
18 |
19 | override/*"PRIMARY_ITEM"*/ val type: Int
20 | get() = R.id.material_drawer_item_primary
21 |
22 | override val layoutRes: Int
23 | @LayoutRes
24 | get() = R.layout.material_drawer_item_primary
25 |
26 | override fun bindView(holder: ViewHolder, payloads: List) {
27 | super.bindView(holder, payloads)
28 |
29 | val ctx = holder.itemView.context
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 | open class ViewHolder(view: View) : BaseViewHolder(view) {
57 | internal val badge: TextView = view.findViewById(R.id.material_drawer_badge)
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/java/com/mikepenz/materialdrawer/model/BaseDrawerItem.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.model
2 |
3 | import android.content.Context
4 | import android.content.res.ColorStateList
5 | import androidx.recyclerview.widget.RecyclerView
6 | import com.mikepenz.materialdrawer.holder.ImageHolder
7 | import com.mikepenz.materialdrawer.holder.StringHolder
8 | import com.mikepenz.materialdrawer.model.interfaces.*
9 | import com.mikepenz.materialdrawer.util.getPrimaryDrawerIconColor
10 |
11 | /**
12 | * An abstract [IDrawerItem] implementation providing the base properties with their default value
13 | */
14 | abstract class BaseDrawerItem : AbstractDrawerItem(), Nameable, NameableColor, Iconable, SelectIconable, Tagable {
15 | override var icon: ImageHolder? = null
16 | override var iconColor: ColorStateList? = null
17 | override var selectedIcon: ImageHolder? = null
18 | override var name: StringHolder? = null
19 | override var textColor: ColorStateList? = null
20 | override var isIconTinted = false
21 |
22 | /** Allows to set the 'level' of this item */
23 | var level = 1
24 |
25 | @Deprecated("Please consider to replace with the actual property setter")
26 | fun withLevel(level: Int): T {
27 | this.level = level
28 | return this as T
29 | }
30 |
31 | /**
32 | * helper method to decide for the correct color
33 | *
34 | * @param ctx
35 | * @return
36 | */
37 | open fun getIconColor(ctx: Context): ColorStateList {
38 | return ctx.getPrimaryDrawerIconColor()
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/java/com/mikepenz/materialdrawer/model/BaseViewHolder.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.model
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.R
8 |
9 | /**
10 | *the base [RecyclerView.ViewHolder] for drawerItems
11 | */
12 | open class BaseViewHolder(internal var view: View) : RecyclerView.ViewHolder(view) {
13 | internal var icon: ImageView = view.findViewById(R.id.material_drawer_icon)
14 | internal var name: TextView = view.findViewById(R.id.material_drawer_name)
15 | internal var description: TextView = view.findViewById(R.id.material_drawer_description)
16 | }
--------------------------------------------------------------------------------
/materialdrawer/src/main/java/com/mikepenz/materialdrawer/model/DividerDrawerItem.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.model
2 |
3 | import android.view.View
4 | import androidx.annotation.LayoutRes
5 | import androidx.core.view.ViewCompat
6 | import androidx.recyclerview.widget.RecyclerView
7 | import com.mikepenz.materialdrawer.R
8 | import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem
9 | import com.mikepenz.materialdrawer.util.getDividerColor
10 |
11 | /**
12 | * Describes a [IDrawerItem] acting as a divider in between items
13 | */
14 | open class DividerDrawerItem : AbstractDrawerItem() {
15 | override val type: Int
16 | get() = R.id.material_drawer_item_divider
17 |
18 | override val layoutRes: Int
19 | @LayoutRes
20 | get() = R.layout.material_drawer_item_divider
21 |
22 | override fun bindView(holder: ViewHolder, payloads: List) {
23 | super.bindView(holder, payloads)
24 |
25 | val ctx = holder.itemView.context
26 |
27 | //set the identifier from the drawerItem here. It can be used to run tests
28 | holder.itemView.id = hashCode()
29 |
30 | //define how the divider should look like
31 | holder.itemView.isClickable = false
32 | holder.itemView.isEnabled = false
33 | holder.itemView.minimumHeight = 1
34 | ViewCompat.setImportantForAccessibility(holder.itemView, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO)
35 |
36 | //set the color for the divider
37 | holder.itemView.setBackgroundColor(ctx.getDividerColor())
38 |
39 | //call the onPostBindView method to trigger post bind view actions (like the listener to modify the item if required)
40 | onPostBindView(this, holder.itemView)
41 | }
42 |
43 | override fun getViewHolder(v: View): ViewHolder {
44 | return ViewHolder(v)
45 | }
46 |
47 | class ViewHolder internal constructor(view: View) : RecyclerView.ViewHolder(view)
48 | }
49 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/java/com/mikepenz/materialdrawer/model/PrimaryDrawerItem.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.model
2 |
3 | import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem
4 |
5 | /**
6 | * Describes the main [IDrawerItem] bing used as primary item, following the guidelines
7 | */
8 | open class PrimaryDrawerItem : AbstractBadgeableDrawerItem()
9 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/java/com/mikepenz/materialdrawer/model/SecondaryDrawerItem.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.model
2 |
3 | import android.content.Context
4 | import android.content.res.ColorStateList
5 | import androidx.annotation.LayoutRes
6 | import com.mikepenz.materialdrawer.R
7 | import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem
8 | import com.mikepenz.materialdrawer.util.getSecondaryDrawerIconColor
9 | import com.mikepenz.materialdrawer.util.getSecondaryDrawerTextColor
10 |
11 | /**
12 | * Describes the secondary [IDrawerItem] bing used as primary item. Slightly smaller than the primary items
13 | */
14 | open class SecondaryDrawerItem : AbstractBadgeableDrawerItem() {
15 |
16 | override val type: Int
17 | get() = R.id.material_drawer_item_secondary
18 |
19 | override val layoutRes: Int
20 | @LayoutRes
21 | get() = R.layout.material_drawer_item_secondary
22 |
23 | override fun getColor(ctx: Context): ColorStateList {
24 | return ctx.getSecondaryDrawerTextColor()
25 | }
26 |
27 | override fun getIconColor(ctx: Context): ColorStateList {
28 | return ctx.getSecondaryDrawerIconColor()
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/java/com/mikepenz/materialdrawer/model/SecondarySwitchDrawerItem.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.model
2 |
3 | import android.content.Context
4 | import android.content.res.ColorStateList
5 | import androidx.annotation.LayoutRes
6 | import com.mikepenz.materialdrawer.R
7 | import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem
8 | import com.mikepenz.materialdrawer.util.getSecondaryDrawerIconColor
9 | import com.mikepenz.materialdrawer.util.getSecondaryDrawerTextColor
10 |
11 | /**
12 | * Describes a [IDrawerItem] bing used as secondary item, offering a switch.
13 | */
14 | open class SecondarySwitchDrawerItem : AbstractSwitchableDrawerItem() {
15 |
16 | override val type: Int
17 | get() = R.id.material_drawer_item_secondary_switch
18 |
19 | override val layoutRes: Int
20 | @LayoutRes
21 | get() = R.layout.material_drawer_item_secondary_switch
22 |
23 | override fun getColor(ctx: Context): ColorStateList {
24 | return ctx.getSecondaryDrawerTextColor()
25 | }
26 |
27 | override fun getIconColor(ctx: Context): ColorStateList {
28 | return ctx.getSecondaryDrawerIconColor()
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/java/com/mikepenz/materialdrawer/model/SecondaryToggleDrawerItem.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.model
2 |
3 | import android.content.Context
4 | import android.content.res.ColorStateList
5 | import androidx.annotation.LayoutRes
6 | import com.mikepenz.materialdrawer.R
7 | import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem
8 | import com.mikepenz.materialdrawer.util.getSecondaryDrawerIconColor
9 | import com.mikepenz.materialdrawer.util.getSecondaryDrawerTextColor
10 |
11 | /**
12 | * Describes a [IDrawerItem] bing used as secondary item, offering a toggle.
13 | */
14 | open class SecondaryToggleDrawerItem : AbstractToggleableDrawerItem() {
15 |
16 | override val type: Int
17 | get() = R.id.material_drawer_item_secondary_toggle
18 |
19 | override val layoutRes: Int
20 | @LayoutRes
21 | get() = R.layout.material_drawer_item_secondary_toggle
22 |
23 | override fun getColor(ctx: Context): ColorStateList {
24 | return ctx.getSecondaryDrawerTextColor()
25 | }
26 |
27 | override fun getIconColor(ctx: Context): ColorStateList {
28 | return ctx.getSecondaryDrawerIconColor()
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/java/com/mikepenz/materialdrawer/model/SwitchDrawerItem.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.model
2 |
3 | import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem
4 |
5 | /**
6 | * Describes the main [IDrawerItem] bing used as primary item, offering a switch.
7 | */
8 | open class SwitchDrawerItem : AbstractSwitchableDrawerItem()
9 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/java/com/mikepenz/materialdrawer/model/ToggleDrawerItem.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.model
2 |
3 | import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem
4 |
5 | /**
6 | * Describes the main [IDrawerItem] bing used as primary item, offering a toggle.
7 | */
8 | open class ToggleDrawerItem : AbstractToggleableDrawerItem()
9 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/java/com/mikepenz/materialdrawer/model/interfaces/Badgeable.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.model.interfaces
2 |
3 | import com.mikepenz.materialdrawer.holder.StringHolder
4 |
5 | /**
6 | * Defines a [IDrawerItem] which allows to have a badge
7 | */
8 | interface Badgeable {
9 | /** the badge text to show for this item */
10 | var badge: StringHolder?
11 | }
12 |
13 | @Deprecated("Please consider to replace with the actual property setter")
14 | fun T.withBadge(badge: String): T {
15 | this.badge = StringHolder(badge)
16 | return this
17 | }
18 |
19 | @Deprecated("Please consider to replace with the actual property setter")
20 | fun T.withBadge(badgeRes: Int): T {
21 | this.badge = StringHolder(badgeRes)
22 | return this
23 | }
24 |
25 | @Deprecated("Please consider to replace with the actual property setter")
26 | fun T.withBadge(badge: StringHolder?): T {
27 | this.badge = badge
28 | return this
29 | }
30 |
31 | /** Set the badge name */
32 | var Badgeable.badgeRes: Int
33 | @Deprecated(level = DeprecationLevel.ERROR, message = "Not readable")
34 | get() = throw UnsupportedOperationException("Please use the direct property")
35 | set(value) {
36 | badge = StringHolder(value)
37 | }
38 |
39 | /** Set the badge name */
40 | var Badgeable.badgeText: CharSequence
41 | @Deprecated(level = DeprecationLevel.ERROR, message = "Not readable")
42 | get() = throw UnsupportedOperationException("Please use the direct property")
43 | set(value) {
44 | badge = StringHolder(value)
45 | }
46 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/java/com/mikepenz/materialdrawer/model/interfaces/Checkable.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.model.interfaces
2 |
3 | /**
4 | * Defines a [IDrawerItem] with support for being selected
5 | */
6 | interface Checkable : Selectable {
7 | var isChecked: Boolean
8 | }
9 |
10 | @Deprecated("Please consider to replace with the actual property setter")
11 | fun T.withChecked(checked: Boolean): T {
12 | this.isChecked = checked
13 | return this
14 | }
15 |
16 |
17 | @Deprecated("Please consider to replace with the actual property setter")
18 | fun T.withCheckable(checkable: Boolean): T {
19 | this.isSelectable = checkable
20 | return this
21 | }
22 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/java/com/mikepenz/materialdrawer/model/interfaces/ColorfulBadgeable.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.model.interfaces
2 |
3 | import com.mikepenz.materialdrawer.holder.BadgeStyle
4 |
5 | /**
6 | * Defines a [IDrawerItem] which allows to have a colorful badge
7 | */
8 | interface ColorfulBadgeable : Badgeable {
9 | /** defines the style for the badge in the item */
10 | var badgeStyle: BadgeStyle?
11 | }
12 |
13 | @Deprecated("Please consider to replace with the actual property setter")
14 | fun T.withBadgeStyle(badgeStyle: BadgeStyle?): T {
15 | this.badgeStyle = badgeStyle
16 | return this
17 | }
--------------------------------------------------------------------------------
/materialdrawer/src/main/java/com/mikepenz/materialdrawer/model/interfaces/Describable.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.model.interfaces
2 |
3 | import androidx.annotation.StringRes
4 | import com.mikepenz.materialdrawer.holder.StringHolder
5 |
6 | /**
7 | * Defines a [IDrawerItem] with support for defining a description
8 | */
9 | interface Describable {
10 | /** The text to show as description */
11 | var description: StringHolder?
12 | }
13 |
14 | @Deprecated("Please consider to replace with the actual property setter")
15 | fun T.withDescription(description: String): T {
16 | this.description = StringHolder(description)
17 | return this
18 | }
19 |
20 | @Deprecated("Please consider to replace with the actual property setter")
21 | fun T.withDescription(@StringRes descriptionRes: Int): T {
22 | this.description = StringHolder(descriptionRes)
23 | return this
24 | }
25 |
26 | /** Set the description */
27 | var Describable.descriptionRes: Int
28 | @Deprecated(level = DeprecationLevel.ERROR, message = "Not readable")
29 | get() = throw UnsupportedOperationException("Please use the direct property")
30 | set(value) {
31 | description = StringHolder(value)
32 | }
33 |
34 | /** Set the description */
35 | var Describable.descriptionText: CharSequence
36 | @Deprecated(level = DeprecationLevel.ERROR, message = "Not readable")
37 | get() = throw UnsupportedOperationException("Please use the direct property")
38 | set(value) {
39 | description = StringHolder(value)
40 | }
--------------------------------------------------------------------------------
/materialdrawer/src/main/java/com/mikepenz/materialdrawer/model/interfaces/DescribableColor.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.model.interfaces
2 |
3 | import android.content.res.ColorStateList
4 | import androidx.annotation.ColorInt
5 | import androidx.annotation.ColorRes
6 |
7 | /**
8 | * Defines a [IDrawerItem] with support for defining a description
9 | */
10 | interface DescribableColor {
11 | /** The color for the description text */
12 | var descriptionTextColor: ColorStateList?
13 | }
14 |
15 | /**
16 | * Set the description color as color resource.
17 | *
18 | * This method is deprecated and no-op.
19 | *
20 | * @deprecated
21 | */
22 | var DescribableColor.descriptionTextColorRes: Int
23 | @Deprecated(level = DeprecationLevel.ERROR, message = "Not readable")
24 | get() = throw UnsupportedOperationException("Please use the direct property")
25 | @Deprecated(
26 | "Please use `descriptionTextColor` directly, as [ColorStateList] can't be resolved without [Context].",
27 | level = DeprecationLevel.WARNING,
28 | replaceWith = ReplaceWith("descriptionTextColor")
29 | )
30 | set(@ColorRes value) {
31 | // no-op
32 | }
33 |
34 | /** Set the description color as color int */
35 | var DescribableColor.descriptionTextColorInt: Int
36 | @Deprecated(level = DeprecationLevel.ERROR, message = "Not readable")
37 | get() = throw UnsupportedOperationException("Please use the direct property")
38 | set(@ColorInt value) {
39 | descriptionTextColor = ColorStateList.valueOf(value)
40 | }
41 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/java/com/mikepenz/materialdrawer/model/interfaces/IDrawerItem.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.model.interfaces
2 |
3 | import android.content.Context
4 | import android.view.View
5 | import android.view.ViewGroup
6 | import androidx.recyclerview.widget.RecyclerView
7 | import com.mikepenz.fastadapter.*
8 |
9 | /**
10 | * Defines a general [IDrawerItem] to be displayed in the [com.mikepenz.materialdrawer.widget.MaterialDrawerSliderView]
11 | */
12 | interface IDrawerItem : IItem, IItemVHFactory, IItemViewGenerator, IExpandable, IIdentifyable, Selectable, Tagable {
13 |
14 | override var isEnabled: Boolean
15 |
16 | override var isSelected: Boolean
17 |
18 | override val type: Int
19 |
20 | val layoutRes: Int
21 |
22 | override var identifier: Long
23 |
24 | override var isExpanded: Boolean
25 |
26 | override val isAutoExpanding: Boolean
27 |
28 | override fun generateView(ctx: Context): View
29 |
30 | override fun generateView(ctx: Context, parent: ViewGroup): View
31 |
32 | override fun getViewHolder(parent: ViewGroup): VH
33 |
34 | override fun unbindView(holder: VH)
35 |
36 | override fun bindView(holder: VH, payloads: List)
37 |
38 | fun equals(id: Long): Boolean
39 | }
40 |
41 | @Deprecated("Please consider to replace with the actual property setter")
42 | fun > T.withIdentifier(identifier: Long): T {
43 | this.identifier = identifier
44 | return this
45 | }
46 |
47 | @Deprecated("Please consider to replace with the actual property setter")
48 | fun > T.withEnabled(enabled: Boolean): T {
49 | this.isEnabled = enabled
50 | return this
51 | }
52 |
53 | @Deprecated("Please consider to replace with the actual property setter")
54 | fun > T.withSelected(selected: Boolean): T {
55 | this.isSelected = selected
56 | return this
57 | }
--------------------------------------------------------------------------------
/materialdrawer/src/main/java/com/mikepenz/materialdrawer/model/interfaces/IProfile.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.model.interfaces
2 |
3 | import androidx.annotation.StringRes
4 | import com.mikepenz.fastadapter.IIdentifyable
5 | import com.mikepenz.materialdrawer.holder.StringHolder
6 |
7 | /**
8 | * Defines a general [IProfile] to be displayed in the [com.mikepenz.materialdrawer.widget.MaterialDrawerSliderView] with the [com.mikepenz.materialdrawer.widget.AccountHeaderView]
9 | */
10 | interface IProfile : IIdentifyable, Nameable, Iconable, Selectable, Tagable, Describable
11 |
12 | @Deprecated("Please consider to replace with the actual property setter")
13 | fun T.withEmail(@StringRes emailRes: Int): T {
14 | this.description = StringHolder(emailRes)
15 | return this
16 | }
17 |
18 | @Deprecated("Please consider to replace with the actual property setter")
19 | fun T.withEmail(email: String?): T {
20 | this.description = StringHolder(email)
21 | return this
22 | }
23 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/java/com/mikepenz/materialdrawer/model/interfaces/Iconable.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.model.interfaces
2 |
3 | import android.content.res.ColorStateList
4 | import android.graphics.Bitmap
5 | import android.graphics.drawable.Drawable
6 | import android.net.Uri
7 | import androidx.annotation.DrawableRes
8 | import com.mikepenz.materialdrawer.holder.ImageHolder
9 |
10 | /**
11 | * Defines a [IDrawerItem] with support for an icon
12 | */
13 | interface Iconable {
14 | /** the icon to show in the drawer */
15 | var icon: ImageHolder?
16 |
17 | /** the color of the icon */
18 | var iconColor: ColorStateList?
19 | }
20 |
21 | @Deprecated("Please consider to replace with the actual property setter")
22 | fun T.withIconColor(iconColor: ColorStateList): T {
23 | this.iconColor = iconColor
24 | return this
25 | }
26 |
27 | var T.iconDrawable: Drawable?
28 | @Deprecated(level = DeprecationLevel.ERROR, message = "Not readable")
29 | get() = throw UnsupportedOperationException("Please use the direct property")
30 | set(value) {
31 | if (value != null) {
32 | this.icon = ImageHolder(value)
33 | } else {
34 | this.icon = null
35 | }
36 | }
37 |
38 | var T.iconBitmap: Bitmap
39 | @Deprecated(level = DeprecationLevel.ERROR, message = "Not readable")
40 | get() = throw UnsupportedOperationException("Please use the direct property")
41 | set(value) {
42 | this.icon = ImageHolder(value)
43 | }
44 |
45 | var T.iconRes: Int
46 | @Deprecated(level = DeprecationLevel.ERROR, message = "Not readable")
47 | get() = throw UnsupportedOperationException("Please use the direct property")
48 | set(@DrawableRes value) {
49 | this.icon = ImageHolder(value)
50 | }
51 |
52 | var T.iconUrl: String
53 | @Deprecated(level = DeprecationLevel.ERROR, message = "Not readable")
54 | get() = throw UnsupportedOperationException("Please use the direct property")
55 | set(value) {
56 | this.icon = ImageHolder(value)
57 | }
58 |
59 | @Deprecated("Please consider to replace with the actual property setter")
60 | fun T.withIcon(icon: Drawable?): T {
61 | this.icon = ImageHolder(icon)
62 | return this
63 | }
64 |
65 | @Deprecated("Please consider to replace with the actual property setter")
66 | fun T.withIcon(icon: Bitmap): T {
67 | this.icon = ImageHolder(icon)
68 | return this
69 | }
70 |
71 | @Deprecated("Please consider to replace with the actual property setter")
72 | fun T.withIcon(@DrawableRes imageRes: Int): T {
73 | this.icon = ImageHolder(imageRes)
74 | return this
75 | }
76 |
77 | @Deprecated("Please consider to replace with the actual property setter")
78 | fun T.withIcon(url: String): T {
79 | this.icon = ImageHolder(url)
80 | return this
81 | }
82 |
83 | @Deprecated("Please consider to replace with the actual property setter")
84 | fun T.withIcon(uri: Uri): T {
85 | this.icon = ImageHolder(uri)
86 | return this
87 | }
88 |
89 | @Deprecated("Please consider to replace with the actual property setter")
90 | fun T.withIcon(icon: ImageHolder?): T {
91 | this.icon = icon
92 | return this
93 | }
94 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/java/com/mikepenz/materialdrawer/model/interfaces/Nameable.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.model.interfaces
2 |
3 | import androidx.annotation.StringRes
4 | import com.mikepenz.materialdrawer.holder.StringHolder
5 |
6 | /**
7 | * Defines a [IDrawerItem] with support for defining a name
8 | */
9 | interface Nameable {
10 | /** the name to show for the item */
11 | var name: StringHolder?
12 | }
13 |
14 | @Deprecated("Please consider to replace with the actual property setter")
15 | fun T.withName(name: String?): T {
16 | this.name = StringHolder(name)
17 | return this
18 | }
19 |
20 | @Deprecated("Please consider to replace with the actual property setter")
21 | fun T.withName(@StringRes name: Int): T {
22 | this.name = StringHolder(name)
23 | return this
24 | }
25 |
26 | @Deprecated("Please consider to replace with the actual property setter")
27 | fun T.withName(name: StringHolder?): T {
28 | this.name = name
29 | return this
30 | }
31 |
32 | /** Set the name */
33 | var Nameable.nameRes: Int
34 | @Deprecated(level = DeprecationLevel.ERROR, message = "Not readable")
35 | get() = throw UnsupportedOperationException("Please use the direct property")
36 | set(value) {
37 | name = StringHolder(value)
38 | }
39 |
40 | /** Set the name */
41 | var Nameable.nameText: CharSequence
42 | @Deprecated(level = DeprecationLevel.ERROR, message = "Not readable")
43 | get() = throw UnsupportedOperationException("Please use the direct property")
44 | set(value) {
45 | name = StringHolder(value)
46 | }
47 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/java/com/mikepenz/materialdrawer/model/interfaces/NameableColor.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.model.interfaces
2 |
3 | import android.content.res.ColorStateList
4 | import androidx.annotation.ColorInt
5 | import androidx.annotation.ColorRes
6 |
7 | /**
8 | * Defines a [IDrawerItem] with support for defining a name
9 | */
10 | interface NameableColor {
11 | /** defines the color for the text */
12 | var textColor: ColorStateList?
13 | }
14 |
15 | /**
16 | * Set the selected text color as color resource.
17 | *
18 | * This method is deprecated and no-op.
19 | *
20 | * @deprecated
21 | */
22 | var NameableColor.textColorRes: Int
23 | @Deprecated(level = DeprecationLevel.ERROR, message = "Not readable")
24 | get() = throw UnsupportedOperationException("Please use the direct property")
25 | @Deprecated(
26 | "Please use `textColor` directly, as [ColorStateList] can't be resolved without [Context].",
27 | level = DeprecationLevel.WARNING,
28 | replaceWith = ReplaceWith("descriptionTextColor")
29 | )
30 | set(@ColorRes value) {
31 | // no-op
32 | }
33 |
34 | /** Set the selected text color as color int */
35 | var NameableColor.textColorInt: Int
36 | @Deprecated(level = DeprecationLevel.ERROR, message = "Not readable")
37 | get() = throw UnsupportedOperationException("Please use the direct property")
38 | set(@ColorInt value) {
39 | textColor = ColorStateList.valueOf(value)
40 | }
41 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/java/com/mikepenz/materialdrawer/model/interfaces/SelectIconable.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.model.interfaces
2 |
3 | import android.graphics.Bitmap
4 | import android.graphics.drawable.Drawable
5 | import androidx.annotation.DrawableRes
6 | import com.mikepenz.materialdrawer.holder.ImageHolder
7 |
8 | /**
9 | * Defines a [IDrawerItem] with support for an icon
10 | */
11 | interface SelectIconable {
12 | /** the icon to show when this item gets selected */
13 | var selectedIcon: ImageHolder?
14 |
15 | /** defines if the icon should get proper tinting with the defined color */
16 | var isIconTinted: Boolean
17 | }
18 |
19 | var T.selectedIconDrawable: Drawable
20 | @Deprecated(level = DeprecationLevel.ERROR, message = "Not readable")
21 | get() = throw UnsupportedOperationException("Please use the direct property")
22 | set(value) {
23 | this.icon = ImageHolder(value)
24 | }
25 |
26 | var T.selectedIconBitmap: Bitmap
27 | @Deprecated(level = DeprecationLevel.ERROR, message = "Not readable")
28 | get() = throw UnsupportedOperationException("Please use the direct property")
29 | set(value) {
30 | this.icon = ImageHolder(value)
31 | }
32 |
33 | var T.selectedIconRes: Int
34 | @Deprecated(level = DeprecationLevel.ERROR, message = "Not readable")
35 | get() = throw UnsupportedOperationException("Please use the direct property")
36 | set(@DrawableRes value) {
37 | this.icon = ImageHolder(value)
38 | }
39 |
40 | var T.selectedIconUrl: String
41 | @Deprecated(level = DeprecationLevel.ERROR, message = "Not readable")
42 | get() = throw UnsupportedOperationException("Please use the direct property")
43 | set(value) {
44 | this.icon = ImageHolder(value)
45 | }
46 |
47 | @Deprecated("Please consider to replace with the actual property setter")
48 | fun T.withSelectedIcon(selectedIcon: Drawable): T {
49 | this.selectedIcon = ImageHolder(selectedIcon)
50 | return this as T
51 | }
52 |
53 | @Deprecated("Please consider to replace with the actual property setter")
54 | fun T.withSelectedIcon(@DrawableRes selectedIconRes: Int): T {
55 | this.selectedIcon = ImageHolder(selectedIconRes)
56 | return this as T
57 | }
58 |
59 | /** will tint the icon with the default (or set) colors (default and selected state) */
60 | @Deprecated("Please consider to replace with the actual property setter")
61 | fun T.withIconTintingEnabled(iconTintingEnabled: Boolean): T {
62 | this.isIconTinted = iconTintingEnabled
63 | return this as T
64 | }
65 |
66 | /** will tint the icon with the default (or set) colors (default and selected state) */
67 | @Deprecated("Please consider to replace with the actual property setter")
68 | fun T.withIconTinted(iconTintingEnabled: Boolean): T {
69 | this.isIconTinted = iconTintingEnabled
70 | return this as T
71 | }
--------------------------------------------------------------------------------
/materialdrawer/src/main/java/com/mikepenz/materialdrawer/model/interfaces/Selectable.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.model.interfaces
2 |
3 | /**
4 | * Defines a [IDrawerItem] with support for being selected
5 | */
6 | interface Selectable {
7 | /** If the item is selectable */
8 | var isSelectable: Boolean
9 | }
10 |
11 | @Deprecated("Please consider to replace with the actual property setter")
12 | fun T.withSelectable(selectable: Boolean): T {
13 | this.isSelectable = selectable
14 | return this
15 | }
16 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/java/com/mikepenz/materialdrawer/model/interfaces/SelectableColor.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.model.interfaces
2 |
3 | import androidx.annotation.ColorInt
4 | import androidx.annotation.ColorRes
5 | import com.mikepenz.materialdrawer.holder.ColorHolder
6 |
7 | /**
8 | * Defines a [IDrawerItem] with support for having a different color when selected
9 | */
10 | interface SelectableColor {
11 | /** The background color of a selectable item */
12 | var selectedColor: ColorHolder?
13 | }
14 |
15 |
16 | @Deprecated("Please consider to replace with the actual property setter")
17 | fun T.withSelectedColor(@ColorInt selectedColor: Int): T {
18 | this.selectedColor = ColorHolder.fromColor(selectedColor)
19 | return this
20 | }
21 |
22 | @Deprecated("Please consider to replace with the actual property setter")
23 | fun T.withSelectedColorRes(@ColorRes selectedColorRes: Int): T {
24 | this.selectedColor = ColorHolder.fromColorRes(selectedColorRes)
25 | return this
26 | }
27 |
28 | /** Set the selected color as color resource */
29 | var SelectableColor.selectedColorRes: Int
30 | @Deprecated(level = DeprecationLevel.ERROR, message = "Not readable")
31 | get() = throw UnsupportedOperationException("Please use the direct property")
32 | set(@ColorRes value) {
33 | selectedColor = ColorHolder.fromColorRes(value)
34 | }
35 |
36 | /** Set the selected color as color int */
37 | var SelectableColor.selectedColorInt: Int
38 | @Deprecated(level = DeprecationLevel.ERROR, message = "Not readable")
39 | get() = throw UnsupportedOperationException("Please use the direct property")
40 | set(@ColorInt value) {
41 | selectedColor = ColorHolder.fromColor(value)
42 | }
43 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/java/com/mikepenz/materialdrawer/model/interfaces/Tagable.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.model.interfaces
2 |
3 | /**
4 | * Defines a [IDrawerItem] with support for being tagged
5 | */
6 | interface Tagable {
7 | /** specify a tag attached to the item to use for different situations */
8 | var tag: Any?
9 | }
10 |
11 | @Deprecated("Please consider to replace with the actual property setter")
12 | fun T.withTag(tag: Any?): T {
13 | this.tag = tag
14 | return this
15 | }
--------------------------------------------------------------------------------
/materialdrawer/src/main/java/com/mikepenz/materialdrawer/model/interfaces/Typefaceable.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.model.interfaces
2 |
3 | import android.graphics.Typeface
4 |
5 | /**
6 | * Defines a [IDrawerItem] with support for defining the [Typeface]
7 | */
8 | interface Typefaceable {
9 | /** the typeface used for texts */
10 | var typeface: Typeface?
11 | }
12 |
13 | @Deprecated("Please consider to replace with the actual property setter")
14 | fun T.withTypeface(typeface: Typeface?): T {
15 | this.typeface = typeface
16 | return this
17 | }
18 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/java/com/mikepenz/materialdrawer/model/utils/BadgeDrawableBuilder.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.model.utils
2 |
3 | import android.content.Context
4 | import android.graphics.drawable.GradientDrawable
5 | import android.graphics.drawable.StateListDrawable
6 | import android.util.StateSet
7 | import androidx.appcompat.content.res.AppCompatResources
8 | import com.mikepenz.materialdrawer.holder.BadgeStyle
9 | import com.mikepenz.materialdrawer.holder.ColorHolder
10 |
11 | /**
12 | * Builder to construct the [StateListDrawable] given a [BadgeStyle]
13 | */
14 | class BadgeDrawableBuilder(private val style: BadgeStyle) {
15 |
16 | /** creates the [StateListDrawable] given the provided [BadgeStyle] */
17 | fun build(ctx: Context): StateListDrawable {
18 | val stateListDrawable = StateListDrawable()
19 | val normal = AppCompatResources.getDrawable(ctx, style.gradientDrawable) as GradientDrawable?
20 | val selected = normal?.constantState?.newDrawable()?.mutate() as GradientDrawable?
21 |
22 | ColorHolder.applyToOrTransparent(style.color, ctx, normal)
23 | if (style.colorPressed == null) {
24 | ColorHolder.applyToOrTransparent(style.color, ctx, selected)
25 | } else {
26 | ColorHolder.applyToOrTransparent(style.colorPressed, ctx, selected)
27 | }
28 |
29 | style.corners?.let {
30 | normal?.cornerRadius = it.asPixel(ctx).toFloat()
31 | selected?.cornerRadius = it.asPixel(ctx).toFloat()
32 | }
33 |
34 | stateListDrawable.addState(intArrayOf(android.R.attr.state_pressed), selected)
35 | stateListDrawable.addState(StateSet.WILD_CARD, normal)
36 |
37 | return stateListDrawable
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/java/com/mikepenz/materialdrawer/model/utils/DrawerItemExtensions.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.model.utils
2 |
3 | import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem
4 |
5 | /** Define tags associated to specific tag items */
6 | private val drawerItemTags = mutableMapOf()
7 |
8 | /** Define if this IDrawerItem should / can be shown inside the MiniDrawer */
9 | var > T.hiddenInMiniDrawer: Boolean
10 | get() = drawerItemTags[this] as? Boolean == true
11 | set(value) {
12 | drawerItemTags[this] = value
13 | }
14 |
15 | @Deprecated("Please consider to replace with the actual property setter")
16 | fun > T.withIsHiddenInMiniDrawer(hidden: Boolean): T {
17 | hiddenInMiniDrawer = hidden
18 | return this
19 | }
20 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/java/com/mikepenz/materialdrawer/util/AbstractDrawerImageLoader.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.util
2 |
3 | import android.content.Context
4 | import android.graphics.drawable.Drawable
5 | import android.net.Uri
6 | import android.util.Log
7 | import android.widget.ImageView
8 |
9 | /**
10 | * This abstract class provides functionality to add custom image loader implementations, based on the image loader used in the app.
11 | */
12 | abstract class AbstractDrawerImageLoader : DrawerImageLoader.IDrawerImageLoader {
13 | /**
14 | * Start loading the image [uri] for the given [imageView] providing the [placeholder], allowing to identify the location it is gonna be used via the [tag]
15 | */
16 | override fun set(imageView: ImageView, uri: Uri, placeholder: Drawable, tag: String?) {
17 | //this won't do anything
18 | Log.i("MaterialDrawer", "You have not specified a ImageLoader implementation through the DrawerImageLoader.init() method, or you are still overriding the deprecated method set(ImageView iv, Uri u, Drawable d) instead of set(ImageView iv, Uri u, Drawable d, String tag)")
19 | }
20 |
21 | /**
22 | * Cancel loading images for the imageView
23 | */
24 | override fun cancel(imageView: ImageView) {}
25 |
26 | /**
27 | * Retrieve the placeholder to display
28 | */
29 | override fun placeholder(ctx: Context): Drawable {
30 | return getPlaceHolder(ctx)
31 | }
32 |
33 | /**
34 | * Retrieve the placeholder to display, using the [tag] to identify the location it is gonna be used
35 | */
36 | override fun placeholder(ctx: Context, tag: String?): Drawable {
37 | return placeholder(ctx)
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/java/com/mikepenz/materialdrawer/util/DrawerImageLoader.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.util
2 |
3 | import android.content.Context
4 | import android.graphics.drawable.Drawable
5 | import android.net.Uri
6 | import android.widget.ImageView
7 | import com.mikepenz.materialdrawer.util.DrawerImageLoader.IDrawerImageLoader
8 |
9 | /**
10 | * The general management class for the [IDrawerImageLoader] support, to offer support for any image loading library.
11 | */
12 | open class DrawerImageLoader private constructor(var imageLoader: IDrawerImageLoader?) {
13 |
14 | /**
15 | * defines if we accept any protocol
16 | */
17 | var handleAllProtocols = false
18 |
19 | /**
20 | * supported protocols
21 | */
22 | var handledProtocols = listOf("http", "https")
23 |
24 | /**
25 | * The possible tags we currently support.
26 | */
27 | enum class Tags {
28 | PRIMARY_ITEM,
29 | MINI_ITEM,
30 | PROFILE,
31 | PROFILE_DRAWER_ITEM,
32 | ACCOUNT_HEADER
33 | }
34 |
35 | /**
36 | * @param imageView
37 | * @param uri
38 | * @param tag
39 | * @return false if not consumed
40 | */
41 | open fun setImage(imageView: ImageView, uri: Uri, tag: String?): Boolean {
42 | // If we do not handle this protocol we keep the original behavior
43 | return if (handleAllProtocols || uri.scheme in handledProtocols) {
44 | imageLoader?.let {
45 | val placeHolder = it.placeholder(imageView.context, tag)
46 | it[imageView, uri, placeHolder] = tag
47 | }
48 | true
49 | } else false
50 | }
51 |
52 | /**
53 | * Cancel loading for the given [ImageView]
54 | */
55 | fun cancelImage(imageView: ImageView) {
56 | imageLoader?.cancel(imageView)
57 | }
58 |
59 | interface IDrawerImageLoader {
60 | /**
61 | * Start loading the image [uri] for the given [imageView] providing the [placeholder], allowing to identify the location it is gonna be used via the [tag]
62 | */
63 | operator fun set(imageView: ImageView, uri: Uri, placeholder: Drawable, tag: String?)
64 |
65 | /**
66 | * Cancel loading images for the imageView
67 | */
68 | fun cancel(imageView: ImageView)
69 |
70 | @Deprecated("Please use the placeholder method with the provided tag instead")
71 | fun placeholder(ctx: Context): Drawable
72 |
73 | /**
74 | * Retrieve the placeholder to display, using the [tag] to identify the location it is gonna be used
75 | */
76 | fun placeholder(ctx: Context, tag: String?): Drawable
77 | }
78 |
79 | companion object {
80 |
81 | private var SINGLETON: DrawerImageLoader? = null
82 |
83 | fun init(loaderImpl: IDrawerImageLoader): DrawerImageLoader {
84 | SINGLETON = DrawerImageLoader(loaderImpl)
85 | return SINGLETON as DrawerImageLoader
86 | }
87 |
88 | val instance: DrawerImageLoader
89 | get() {
90 | if (SINGLETON == null) {
91 | SINGLETON = DrawerImageLoader(object : AbstractDrawerImageLoader() {})
92 | }
93 | return SINGLETON as DrawerImageLoader
94 | }
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/java/com/mikepenz/materialdrawer/util/DrawerItemViewHelper.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.util
2 |
3 | import android.content.Context
4 | import android.view.View
5 | import android.view.ViewGroup
6 | import android.widget.LinearLayout
7 | import com.mikepenz.materialdrawer.R
8 | import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem
9 | import java.util.*
10 |
11 | /**
12 | * Custom helper class allowing to construct a view hierarchy just by using [IDrawerItem]s
13 | */
14 | open class DrawerItemViewHelper(private val context: Context) {
15 |
16 | val drawerItems = ArrayList>()
17 | var divider = true
18 | var onDrawerItemClickListener: ((View, IDrawerItem<*>) -> Unit)? = null
19 |
20 | fun build(): View {
21 | //create the container view
22 | val linearLayout = LinearLayout(context)
23 | linearLayout.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
24 | linearLayout.orientation = LinearLayout.VERTICAL
25 |
26 | //create the divider
27 | if (divider) {
28 | val divider = LinearLayout(context)
29 | divider.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
30 | divider.minimumHeight = context.resources.getDimensionPixelSize(R.dimen.material_drawer_sticky_footer_divider)
31 | divider.orientation = LinearLayout.VERTICAL
32 | divider.setBackgroundColor(context.getDividerColor())
33 | linearLayout.addView(divider)
34 | }
35 |
36 | //add all drawer items
37 | for (drawerItem in drawerItems) {
38 | val view = drawerItem.generateView(context)
39 | view.tag = drawerItem
40 |
41 | if (drawerItem.isEnabled) {
42 | view.setBackgroundResource(context.getSelectableBackgroundRes())
43 | view.setOnClickListener { v ->
44 | onDrawerItemClickListener?.invoke(v, v.getTag(R.id.material_drawer_item) as IDrawerItem<*>)
45 | }
46 | }
47 |
48 | linearLayout.addView(view)
49 | }
50 |
51 | return linearLayout
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/java/com/mikepenz/materialdrawer/util/FixStateListDrawable.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.util
2 |
3 | import android.R
4 | import android.annotation.SuppressLint
5 | import android.content.res.ColorStateList
6 | import android.graphics.PorterDuff
7 | import android.graphics.drawable.Drawable
8 | import android.graphics.drawable.StateListDrawable
9 |
10 | /**
11 | * http://stackoverflow.com/questions/7979440/android-cloning-a-drawable-in-order-to-make-a-statelistdrawable-with-filters
12 | * http://stackoverflow.com/users/2075875/malachiasz
13 | */
14 | @SuppressLint("InlinedApi")
15 | class FixStateListDrawable : StateListDrawable {
16 | var color: ColorStateList?
17 |
18 | constructor(drawable: Drawable, color: ColorStateList?) : super() {
19 | var drawable = drawable
20 | drawable = drawable.mutate()
21 | addState(intArrayOf(R.attr.state_selected), drawable)
22 | addState(intArrayOf(), drawable)
23 | this.color = color
24 | }
25 |
26 | constructor(drawable: Drawable, selectedDrawable: Drawable, color: ColorStateList?) : super() {
27 | var drawable = drawable
28 | var selectedDrawable = selectedDrawable
29 | drawable = drawable.mutate()
30 | selectedDrawable = selectedDrawable.mutate()
31 | addState(intArrayOf(R.attr.state_selected), selectedDrawable)
32 | addState(intArrayOf(), drawable)
33 | this.color = color
34 | }
35 |
36 | override fun onStateChange(states: IntArray): Boolean {
37 | val color = color
38 | if (color != null) {
39 | super.setColorFilter(color.getColorForState(states, color.defaultColor), PorterDuff.Mode.SRC_IN)
40 | }
41 | return super.onStateChange(states)
42 | }
43 |
44 | override fun isStateful(): Boolean {
45 | return true
46 | }
47 | }
--------------------------------------------------------------------------------
/materialdrawer/src/main/java/com/mikepenz/materialdrawer/util/MenuDrawerUtils.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.materialdrawer.util
2 |
3 | import android.annotation.SuppressLint
4 | import android.view.Menu
5 | import androidx.annotation.MenuRes
6 | import androidx.appcompat.view.SupportMenuInflater
7 | import androidx.appcompat.view.menu.MenuBuilder
8 | import com.mikepenz.materialdrawer.R
9 | import com.mikepenz.materialdrawer.model.DividerDrawerItem
10 | import com.mikepenz.materialdrawer.model.PrimaryDrawerItem
11 | import com.mikepenz.materialdrawer.model.SecondaryDrawerItem
12 | import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem
13 | import com.mikepenz.materialdrawer.model.interfaces.iconDrawable
14 | import com.mikepenz.materialdrawer.model.interfaces.nameText
15 | import com.mikepenz.materialdrawer.widget.MaterialDrawerSliderView
16 |
17 | /**
18 | * Inflates the DrawerItems from a menu.xml
19 | */
20 | @SuppressLint("RestrictedApi")
21 | fun MaterialDrawerSliderView.inflateMenu(@MenuRes menuRes: Int) {
22 | val menuInflater = SupportMenuInflater(context)
23 | val mMenu = MenuBuilder(context)
24 |
25 | menuInflater.inflate(menuRes, mMenu)
26 |
27 | addMenuItems(mMenu, false)
28 | }
29 |
30 | /**
31 | * helper method to init the drawerItems from a menu
32 | */
33 | private fun MaterialDrawerSliderView.addMenuItems(mMenu: Menu?, subMenu: Boolean) {
34 | mMenu ?: return
35 | var groupId = R.id.material_drawer_menu_default_group
36 | for (i in 0 until mMenu.size()) {
37 | val mMenuItem = mMenu.getItem(i)
38 | var iDrawerItem: IDrawerItem<*>
39 | if (!subMenu && mMenuItem.groupId != groupId && mMenuItem.groupId != 0) {
40 | groupId = mMenuItem.groupId
41 | iDrawerItem = DividerDrawerItem()
42 | itemAdapter.add(iDrawerItem)
43 | }
44 | if (mMenuItem.hasSubMenu()) {
45 | iDrawerItem = PrimaryDrawerItem().apply {
46 | nameText = mMenuItem.title ?: ""
47 | iconDrawable = mMenuItem.icon
48 | identifier = mMenuItem.itemId.toLong()
49 | isEnabled = mMenuItem.isEnabled
50 | isSelectable = false
51 | }
52 | itemAdapter.add(iDrawerItem)
53 | addMenuItems(mMenuItem.subMenu, true)
54 | } else if (mMenuItem.groupId != 0 || subMenu) {
55 | iDrawerItem = SecondaryDrawerItem().apply {
56 | nameText = mMenuItem.title ?: ""
57 | iconDrawable = mMenuItem.icon
58 | identifier = mMenuItem.itemId.toLong()
59 | isEnabled = mMenuItem.isEnabled
60 | }
61 | itemAdapter.add(iDrawerItem)
62 | } else {
63 | iDrawerItem = PrimaryDrawerItem().apply {
64 | nameText = mMenuItem.title ?: ""
65 | iconDrawable = mMenuItem.icon
66 | identifier = mMenuItem.itemId.toLong()
67 | isEnabled = mMenuItem.isEnabled
68 | }
69 | itemAdapter.add(iDrawerItem)
70 | }
71 | }
72 | }
--------------------------------------------------------------------------------
/materialdrawer/src/main/res/color/color_drawer_item_text.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/res/drawable-v21/material_drawer_ico_account.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/res/drawable/material_drawer_badge.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/res/drawable/material_drawer_circle_mask.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
19 |
20 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/res/drawable/material_drawer_ico_account.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/materialdrawer/src/main/res/drawable/material_drawer_ico_account.png
--------------------------------------------------------------------------------
/materialdrawer/src/main/res/drawable/material_drawer_ico_account_layer.xml:
--------------------------------------------------------------------------------
1 |
2 | -
3 |
4 |
5 |
6 |
7 |
11 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/res/drawable/material_drawer_ico_chevron_down.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
12 |
15 |
16 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/res/drawable/material_drawer_ico_menu_down.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
16 |
17 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/res/drawable/material_drawer_rectangle_mask.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/res/drawable/material_drawer_shadow_bottom.xml:
--------------------------------------------------------------------------------
1 |
3 |
7 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/res/drawable/material_drawer_shadow_left.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/materialdrawer/src/main/res/drawable/material_drawer_shadow_left.9.png
--------------------------------------------------------------------------------
/materialdrawer/src/main/res/drawable/material_drawer_shadow_right.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikepenz/MaterialDrawer/8ea711404d90b5cb6bc851530292c3c54d68aa8d/materialdrawer/src/main/res/drawable/material_drawer_shadow_right.9.png
--------------------------------------------------------------------------------
/materialdrawer/src/main/res/drawable/material_drawer_shadow_top.xml:
--------------------------------------------------------------------------------
1 |
3 |
7 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/res/layout/material_drawer.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/res/layout/material_drawer_fits_not.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/res/layout/material_drawer_inner_shadow.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/res/layout/material_drawer_item_container.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/res/layout/material_drawer_item_divider.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/res/layout/material_drawer_item_mini.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
20 |
21 |
35 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/res/layout/material_drawer_item_mini_profile.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
20 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/res/layout/material_drawer_item_section.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
26 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/res/layout/material_drawer_recycler_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/res/values-fr/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Ouvrir
4 | Fermer
5 | Profile icon
6 |
7 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/res/values-pt/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Abrir
4 | Fechar
5 | Profile icon
6 |
7 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/res/values-sw600dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 24dp
4 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | #1F000000
5 |
6 | #1F2196F3
7 |
8 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/res/values/ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Open
4 | Close
5 | Profile icon
6 |
7 |
--------------------------------------------------------------------------------
/materialdrawer/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
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")
--------------------------------------------------------------------------------