├── .editorconfig ├── .github ├── CODEOWNERS ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── Bug_report.md │ └── Feature_request.md ├── pull_request_template.md └── workflows │ ├── android.yml │ ├── publish-snapshot.yml │ └── publish.yml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── skydoves │ │ └── powermenudemo │ │ ├── MainActivity.java │ │ ├── PowerMenuUtils.java │ │ ├── customs │ │ ├── adapters │ │ │ ├── CenterMenuAdapter.java │ │ │ └── CustomDialogMenuAdapter.java │ │ └── items │ │ │ └── NameCardMenuItem.java │ │ └── kotlin │ │ ├── KotlinActivity.kt │ │ └── MoreMenuFactory.kt │ └── res │ ├── drawable-v24 │ └── ic_launcher_foreground.xml │ ├── drawable │ ├── face1.jpeg │ ├── face2.jpeg │ ├── face3.jpeg │ ├── ic_facebook.png │ ├── ic_hamburger.png │ ├── ic_launcher_background.xml │ ├── ic_line.png │ ├── ic_pencil.png │ ├── ic_twitter.png │ ├── ic_user.png │ ├── ic_wechat.png │ └── icon_share.png │ ├── layout │ ├── activity_main.xml │ ├── activity_test.xml │ ├── item_name_card.xml │ ├── item_title_header.xml │ ├── item_title_menu.xml │ ├── layout_custom_dialog_footer.xml │ ├── layout_custom_dialog_header.xml │ ├── layout_dialog_footer.xml │ ├── layout_dialog_header.xml │ └── layout_main_body.xml │ ├── mipmap-anydpi-v26 │ ├── ic_launcher.xml │ └── ic_launcher_round.xml │ ├── mipmap-hdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── buildSrc ├── build.gradle.kts └── src │ └── main │ └── kotlin │ └── com │ └── skydoves │ └── powermenu │ ├── Configuration.kt │ └── Dependencies.kt ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── powermenu ├── .gitignore ├── api │ └── powermenu.api ├── build.gradle └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── skydoves │ │ └── powermenu │ │ ├── AbstractMenuBuilder.java │ │ ├── AbstractPowerMenu.java │ │ ├── CircularEffect.java │ │ ├── ConvertUtil.java │ │ ├── CustomPowerMenu.java │ │ ├── IMenuItem.java │ │ ├── IPowerMenuAdapter.java │ │ ├── MenuAnimation.java │ │ ├── MenuBaseAdapter.java │ │ ├── MenuListAdapter.java │ │ ├── MenuPreferenceManager.java │ │ ├── OnDismissedListener.java │ │ ├── OnMenuItemClickListener.java │ │ ├── PowerMenu.java │ │ ├── PowerMenuItem.kt │ │ ├── ResourceUtil.java │ │ ├── annotations │ │ ├── Dp.kt │ │ └── Sp.kt │ │ └── kotlin │ │ ├── ActivityPowerMenuLazy.kt │ │ ├── ContextExtensions.kt │ │ ├── FragmentPowerMenuLazy.kt │ │ ├── PowerMenuExtension.kt │ │ ├── PowerMenuKotlinDsl.kt │ │ ├── PowerMenuLazyExtension.kt │ │ └── ViewPowerMenuLazy.kt │ └── res │ ├── anim │ ├── menu_elastic_bl.xml │ ├── menu_elastic_br.xml │ ├── menu_elastic_center.xml │ ├── menu_elastic_tl.xml │ ├── menu_elastic_tr.xml │ ├── menu_fade_in.xml │ ├── menu_fade_out.xml │ ├── menu_show_down_bl.xml │ ├── menu_show_down_br.xml │ ├── menu_show_down_center.xml │ ├── menu_show_down_tl.xml │ ├── menu_show_down_tr.xml │ ├── menu_show_up_bl.xml │ ├── menu_show_up_br.xml │ ├── menu_show_up_center.xml │ ├── menu_show_up_tl.xml │ └── menu_show_up_tr.xml │ ├── layout │ ├── item_power_menu_library_skydoves.xml │ ├── layout_material_power_menu_library_skydoves.xml │ ├── layout_power_background_library_skydoves.xml │ └── layout_power_menu_library_skydoves.xml │ └── values │ └── styles.xml ├── scripts ├── publish-module.gradle └── publish-root.gradle ├── settings.gradle └── spotless ├── spotless.gradle ├── spotless.license.java ├── spotless.license.kt └── spotless.license.xml /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | [*] 3 | # Most of the standard properties are supported 4 | indent_size=2 5 | max_line_length=100 -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Lines starting with '#' are comments. 2 | # Each line is a file pattern followed by one or more owners. 3 | 4 | # More details are here: https://help.github.com/articles/about-codeowners/ 5 | 6 | # The '*' pattern is global owners. 7 | # Not adding in this PR, but I'd like to try adding a global owner set with the entire team. 8 | # One interpretation of their docs is that global owners are added only if not removed 9 | # by a more local rule. 10 | 11 | # Order is important. The last matching pattern has the most precedence. 12 | # The folders are ordered as follows: 13 | 14 | # In each subsection folders are ordered first by depth, then alphabetically. 15 | # This should make it easy to add new rules without breaking existing ones. 16 | * @skydoves -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: skydoves 2 | custom: ["https://www.paypal.me/skydoves", "https://www.buymeacoffee.com/skydoves"] 3 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/Bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Something is crashing or not working as intended 4 | 5 | --- 6 | 7 | **Please complete the following information:** 8 | - Library Version [e.g. v1.0.0] 9 | - Affected Device(s) [e.g. Samsung Galaxy s10 with Android 9.0] 10 | 11 | **Describe the Bug:** 12 | 13 | Add a clear description about the problem. 14 | 15 | **Expected Behavior:** 16 | 17 | A clear description of what you expected to happen. 18 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/Feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | 5 | --- 6 | 7 | **Is your feature request related to a problem?** 8 | 9 | A clear and concise description of what the problem is. 10 | 11 | **Describe the solution you'd like:** 12 | 13 | A clear and concise description of what you want to happen. 14 | 15 | **Describe alternatives you've considered:** 16 | 17 | A clear description of any alternative solutions you've considered. 18 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ### 🎯 Goal 2 | Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue. 3 | 4 | ### 🛠 Implementation details 5 | Describe the implementation details for this Pull Request. 6 | 7 | ### ✍️ Explain examples 8 | Explain examples with code for these updates. 9 | 10 | ### Preparing a pull request for review 11 | Ensure your change is properly formatted by running: 12 | 13 | ```bash 14 | $ ./gradlew spotlessApply 15 | ``` 16 | 17 | Then dump binary APIs of this library that is public in sense of Kotlin visibilities and ensures that the public binary API wasn't changed in a way that makes this change binary incompatible. 18 | 19 | ```bash 20 | ./gradlew apiDump 21 | ``` 22 | 23 | Please correct any failures before requesting a review. 24 | 25 | ## Code reviews 26 | All submissions, including submissions by project members, require review. We use GitHub pull requests for this purpose. Consult [GitHub Help](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests) for more information on using pull requests. 27 | -------------------------------------------------------------------------------- /.github/workflows/android.yml: -------------------------------------------------------------------------------- 1 | name: Android CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | branches: 9 | - main 10 | 11 | jobs: 12 | lint: 13 | name: Spotless check 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Check out code 17 | uses: actions/checkout@v3.1.0 18 | - name: Set up JDK 19 | uses: actions/setup-java@v3.5.1 20 | with: 21 | distribution: adopt 22 | java-version: 11 23 | - name: spotless 24 | run: ./gradlew spotlessCheck 25 | 26 | build: 27 | runs-on: ubuntu-latest 28 | steps: 29 | - uses: actions/checkout@v3.1.0 30 | 31 | - name: set up JDK 32 | uses: actions/setup-java@v3.5.1 33 | with: 34 | distribution: adopt 35 | java-version: 11 36 | 37 | - name: Cache Gradle and wrapper 38 | uses: actions/cache@v2 39 | with: 40 | path: | 41 | ~/.gradle/caches 42 | ~/.gradle/wrapper 43 | key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} 44 | restore-keys: | 45 | ${{ runner.os }}-gradle- 46 | 47 | - name: Make Gradle executable 48 | run: chmod +x ./gradlew 49 | 50 | - name: Build with Gradle 51 | run: ./gradlew build 52 | -------------------------------------------------------------------------------- /.github/workflows/publish-snapshot.yml: -------------------------------------------------------------------------------- 1 | name: Publish Snapshot builds 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | workflow_dispatch: 8 | 9 | jobs: 10 | publish: 11 | name: Snapshot build and publish 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Check out code 15 | uses: actions/checkout@v3.1.0 16 | - name: Set up JDK 11 17 | uses: actions/setup-java@v3.5.1 18 | with: 19 | distribution: adopt 20 | java-version: 11 21 | - name: Release build 22 | run: ./gradlew assemble --scan 23 | - name: Source jar and dokka 24 | run: ./gradlew androidSourcesJar javadocJar --scan 25 | - name: Publish to MavenCentral 26 | run: ./gradlew publishReleasePublicationToSonatypeRepository --scan 27 | env: 28 | OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} 29 | OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} 30 | SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} 31 | SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} 32 | SIGNING_KEY: ${{ secrets.SIGNING_KEY }} 33 | SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} 34 | SNAPSHOT: true 35 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish 2 | 3 | on: 4 | release: 5 | types: [released] 6 | 7 | jobs: 8 | publish: 9 | name: Release build and publish 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Check out code 13 | uses: actions/checkout@v3.1.0 14 | - name: Set up JDK 11 15 | uses: actions/setup-java@v3.5.1 16 | with: 17 | distribution: adopt 18 | java-version: 11 19 | - name: Release build 20 | run: ./gradlew assemble --scan 21 | - name: Source jar and dokka 22 | run: ./gradlew androidSourcesJar javadocJar --scan 23 | - name: Publish to MavenCentral 24 | run: ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository --scan 25 | env: 26 | OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} 27 | OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} 28 | SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} 29 | SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} 30 | SIGNING_KEY: ${{ secrets.SIGNING_KEY }} 31 | SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | /.idea 18 | .gradle/ 19 | build/ 20 | 21 | # Local configuration file (sdk path, etc) 22 | local.properties 23 | 24 | # Proguard folder generated by Eclipse 25 | proguard/ 26 | 27 | # Log Files 28 | *.log 29 | 30 | # Android Studio Navigation editor temp files 31 | .navigation/ 32 | 33 | # Android Studio captures folder 34 | captures/ 35 | 36 | # Intellij 37 | *.iml 38 | .idea/workspace.xml 39 | .idea/tasks.xml 40 | .idea/gradle.xml 41 | .idea/dictionaries 42 | .idea/libraries 43 | 44 | # Mac 45 | *.DS_Store 46 | 47 | # Keystore files 48 | *.jks 49 | 50 | # External native build folder generated in Android Studio 2.2 and later 51 | .externalNativeBuild 52 | 53 | # Google Services (e.g. APIs or Firebase) 54 | google-services.json 55 | 56 | # Freeline 57 | freeline.py 58 | freeline/ 59 | freeline_project_description.json -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, religion, or sexual identity 10 | and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | * Demonstrating empathy and kindness toward other people 21 | * Being respectful of differing opinions, viewpoints, and experiences 22 | * Giving and gracefully accepting constructive feedback 23 | * Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | * Focusing on what is best not just for us as individuals, but for the 26 | overall community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | * The use of sexualized language or imagery, and sexual attention or 31 | advances of any kind 32 | * Trolling, insulting or derogatory comments, and personal or political attacks 33 | * Public or private harassment 34 | * Publishing others' private information, such as a physical or email 35 | address, without their explicit permission 36 | * Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at 63 | skydoves2@gmail.com. 64 | All complaints will be reviewed and investigated promptly and fairly. 65 | 66 | All community leaders are obligated to respect the privacy and security of the 67 | reporter of any incident. 68 | 69 | ## Enforcement Guidelines 70 | 71 | Community leaders will follow these Community Impact Guidelines in determining 72 | the consequences for any action they deem in violation of this Code of Conduct: 73 | 74 | ### 1. Correction 75 | 76 | **Community Impact**: Use of inappropriate language or other behavior deemed 77 | unprofessional or unwelcome in the community. 78 | 79 | **Consequence**: A private, written warning from community leaders, providing 80 | clarity around the nature of the violation and an explanation of why the 81 | behavior was inappropriate. A public apology may be requested. 82 | 83 | ### 2. Warning 84 | 85 | **Community Impact**: A violation through a single incident or series 86 | of actions. 87 | 88 | **Consequence**: A warning with consequences for continued behavior. No 89 | interaction with the people involved, including unsolicited interaction with 90 | those enforcing the Code of Conduct, for a specified period of time. This 91 | includes avoiding interactions in community spaces as well as external channels 92 | like social media. Violating these terms may lead to a temporary or 93 | permanent ban. 94 | 95 | ### 3. Temporary Ban 96 | 97 | **Community Impact**: A serious violation of community standards, including 98 | sustained inappropriate behavior. 99 | 100 | **Consequence**: A temporary ban from any sort of interaction or public 101 | communication with the community for a specified period of time. No public or 102 | private interaction with the people involved, including unsolicited interaction 103 | with those enforcing the Code of Conduct, is allowed during this period. 104 | Violating these terms may lead to a permanent ban. 105 | 106 | ### 4. Permanent Ban 107 | 108 | **Community Impact**: Demonstrating a pattern of violation of community 109 | standards, including sustained inappropriate behavior, harassment of an 110 | individual, or aggression toward or disparagement of classes of individuals. 111 | 112 | **Consequence**: A permanent ban from any sort of public interaction within 113 | the community. 114 | 115 | ## Attribution 116 | 117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 118 | version 2.0, available at 119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 120 | 121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct 122 | enforcement ladder](https://github.com/mozilla/diversity). 123 | 124 | [homepage]: https://www.contributor-covenant.org 125 | 126 | For answers to common questions about this code of conduct, see the FAQ at 127 | https://www.contributor-covenant.org/faq. Translations are available at 128 | https://www.contributor-covenant.org/translations. 129 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## How to contribute 2 | We'd love to accept your patches and contributions to this project. There are just a few small guidelines you need to follow. 3 | 4 | ## Preparing a pull request for review 5 | Ensure your change is properly formatted by running: 6 | 7 | ```gradle 8 | ./gradlew spotlessApply 9 | ``` 10 | 11 | Then dump binary API of this library that is public in sense of Kotlin visibilities and ensures that the public binary API wasn't changed in a way that make this change binary incompatible. 12 | 13 | ```gradle 14 | ./gradlew apiDump 15 | ``` 16 | 17 | Please correct any failures before requesting a review. 18 | 19 | ## Code reviews 20 | All submissions, including submissions by project members, require review. We use GitHub pull requests for this purpose. Consult [GitHub Help](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests) for more information on using pull requests. 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android' 3 | 4 | import com.skydoves.powermenu.Configuration 5 | import com.skydoves.powermenu.Dependencies 6 | 7 | android { 8 | compileSdkVersion Configuration.compileSdk 9 | defaultConfig { 10 | applicationId "com.skydoves.powermenudemo" 11 | minSdkVersion Configuration.minSdk 12 | targetSdkVersion Configuration.targetSdk 13 | versionCode Configuration.versionCode 14 | versionName Configuration.versionName 15 | } 16 | 17 | lintOptions { 18 | abortOnError false 19 | } 20 | 21 | compileOptions { 22 | sourceCompatibility JavaVersion.VERSION_11 23 | targetCompatibility JavaVersion.VERSION_11 24 | } 25 | 26 | kotlinOptions { 27 | jvmTarget = "11" 28 | } 29 | 30 | buildFeatures { 31 | viewBinding true 32 | } 33 | } 34 | 35 | dependencies { 36 | implementation Dependencies.material 37 | implementation project(":powermenu") 38 | } 39 | 40 | apply from: "$rootDir/spotless/spotless.gradle" 41 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 20 | 21 | 29 | 30 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /app/src/main/java/com/skydoves/powermenudemo/MainActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 skydoves (Jaewoong Eum) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.skydoves.powermenudemo; 18 | 19 | import android.os.Bundle; 20 | import android.util.Log; 21 | import android.view.View; 22 | import android.widget.TextView; 23 | import android.widget.Toast; 24 | import androidx.appcompat.app.AppCompatActivity; 25 | import com.skydoves.powermenu.CustomPowerMenu; 26 | import com.skydoves.powermenu.OnDismissedListener; 27 | import com.skydoves.powermenu.OnMenuItemClickListener; 28 | import com.skydoves.powermenu.PowerMenu; 29 | import com.skydoves.powermenu.PowerMenuItem; 30 | import com.skydoves.powermenudemo.customs.adapters.CenterMenuAdapter; 31 | import com.skydoves.powermenudemo.customs.adapters.CustomDialogMenuAdapter; 32 | import com.skydoves.powermenudemo.customs.items.NameCardMenuItem; 33 | import com.skydoves.powermenudemo.databinding.ActivityMainBinding; 34 | 35 | public class MainActivity extends AppCompatActivity { 36 | 37 | private PowerMenu hamburgerMenu; 38 | private PowerMenu profileMenu; 39 | private CustomPowerMenu writeMenu; 40 | private CustomPowerMenu alertMenu; 41 | private PowerMenu dialogMenu; 42 | private CustomPowerMenu customDialogMenu; 43 | private PowerMenu iconMenu; 44 | private final OnMenuItemClickListener onHamburgerItemClickListener = 45 | new OnMenuItemClickListener<>() { 46 | @Override 47 | public void onItemClick(int position, PowerMenuItem item) { 48 | Toast.makeText(getBaseContext(), item.title, Toast.LENGTH_SHORT).show(); 49 | hamburgerMenu.setSelectedPosition(position); 50 | } 51 | }; 52 | private final OnDismissedListener onHamburgerMenuDismissedListener = 53 | () -> Log.d("Test", "onDismissed hamburger menu"); 54 | private final OnMenuItemClickListener onProfileItemClickListener = 55 | new OnMenuItemClickListener<>() { 56 | @Override 57 | public void onItemClick(int position, PowerMenuItem item) { 58 | Toast.makeText(getBaseContext(), item.title, Toast.LENGTH_SHORT).show(); 59 | profileMenu.dismiss(); 60 | } 61 | }; 62 | private final OnMenuItemClickListener onWriteItemClickListener = 63 | new OnMenuItemClickListener<>() { 64 | @Override 65 | public void onItemClick(int position, String title) { 66 | Toast.makeText(getBaseContext(), title, Toast.LENGTH_SHORT).show(); 67 | writeMenu.dismiss(); 68 | } 69 | }; 70 | private final OnMenuItemClickListener onAlertItemClickListener = 71 | new OnMenuItemClickListener<>() { 72 | @Override 73 | public void onItemClick(int position, String title) { 74 | Toast.makeText(getBaseContext(), title, Toast.LENGTH_SHORT).show(); 75 | alertMenu.dismiss(); 76 | } 77 | }; 78 | private final OnMenuItemClickListener onIconMenuItemClickListener = 79 | new OnMenuItemClickListener<>() { 80 | @Override 81 | public void onItemClick(int position, PowerMenuItem item) { 82 | Toast.makeText(getBaseContext(), item.title, Toast.LENGTH_SHORT).show(); 83 | iconMenu.dismiss(); 84 | } 85 | }; 86 | 87 | private ActivityMainBinding binding; 88 | 89 | @Override 90 | protected void onCreate(Bundle savedInstanceState) { 91 | super.onCreate(savedInstanceState); 92 | 93 | binding = ActivityMainBinding.inflate(getLayoutInflater()); 94 | 95 | setContentView(binding.getRoot()); 96 | 97 | hamburgerMenu = 98 | PowerMenuUtils.getHamburgerPowerMenu( 99 | this, this, onHamburgerItemClickListener, onHamburgerMenuDismissedListener); 100 | profileMenu = PowerMenuUtils.getProfilePowerMenu(this, this, onProfileItemClickListener); 101 | writeMenu = PowerMenuUtils.getWritePowerMenu(this, this, onWriteItemClickListener); 102 | alertMenu = PowerMenuUtils.getAlertPowerMenu(this, this, onAlertItemClickListener); 103 | iconMenu = PowerMenuUtils.getIconPowerMenu(this, this, onIconMenuItemClickListener); 104 | 105 | initializeDialogMenu(); 106 | initializeCustomDialogMenu(); 107 | } 108 | 109 | private void initializeDialogMenu() { 110 | dialogMenu = PowerMenuUtils.getDialogPowerMenu(this, this); 111 | View footerView = dialogMenu.getFooterView(); 112 | TextView textView_yes = footerView.findViewById(R.id.textView_yes); 113 | textView_yes.setOnClickListener( 114 | view -> { 115 | Toast.makeText(getBaseContext(), "Yes", Toast.LENGTH_SHORT).show(); 116 | dialogMenu.dismiss(); 117 | }); 118 | TextView textView_no = footerView.findViewById(R.id.textView_no); 119 | textView_no.setOnClickListener( 120 | view -> { 121 | Toast.makeText(getBaseContext(), "No", Toast.LENGTH_SHORT).show(); 122 | dialogMenu.dismiss(); 123 | }); 124 | } 125 | 126 | private void initializeCustomDialogMenu() { 127 | customDialogMenu = PowerMenuUtils.getCustomDialogPowerMenu(this, this); 128 | View footerView = customDialogMenu.getFooterView(); 129 | TextView textView_yes = footerView.findViewById(R.id.textView_yes); 130 | textView_yes.setOnClickListener( 131 | view -> { 132 | Toast.makeText(getBaseContext(), "Read More", Toast.LENGTH_SHORT).show(); 133 | customDialogMenu.dismiss(); 134 | }); 135 | TextView textView_no = footerView.findViewById(R.id.textView_no); 136 | textView_no.setOnClickListener( 137 | view -> { 138 | Toast.makeText(getBaseContext(), "Close", Toast.LENGTH_SHORT).show(); 139 | customDialogMenu.dismiss(); 140 | }); 141 | } 142 | 143 | public void onHamburger(View view) { 144 | if (hamburgerMenu.isShowing()) { 145 | hamburgerMenu.dismiss(); 146 | return; 147 | } 148 | hamburgerMenu.showAsDropDown(view); 149 | } 150 | 151 | public void onProfile(View view) { 152 | profileMenu.showAsDropDown(view, -370, 0); 153 | } 154 | 155 | public void onDialog(View view) { 156 | if (dialogMenu.isShowing()) { 157 | dialogMenu.dismiss(); 158 | return; 159 | } 160 | View layout = binding.getRoot(); 161 | dialogMenu.showAtCenter(layout); 162 | } 163 | 164 | public void onCustomDialog(View view) { 165 | if (customDialogMenu.isShowing()) { 166 | customDialogMenu.dismiss(); 167 | return; 168 | } 169 | View layout = binding.getRoot(); 170 | customDialogMenu.showAtCenter(layout); 171 | } 172 | 173 | public void onWrite(View view) { 174 | if (writeMenu.isShowing()) { 175 | writeMenu.dismiss(); 176 | return; 177 | } 178 | View layout = binding.getRoot(); 179 | writeMenu.showAtCenter(layout); 180 | } 181 | 182 | public void onAlert(View view) { 183 | if (alertMenu.isShowing()) { 184 | alertMenu.dismiss(); 185 | return; 186 | } 187 | View layout = binding.getRoot(); 188 | alertMenu.showAtCenter(layout); 189 | } 190 | 191 | public void onShare(View view) { 192 | if (iconMenu.isShowing()) { 193 | iconMenu.dismiss(); 194 | return; 195 | } 196 | iconMenu.showAsDropDown(view, -370, 0); 197 | } 198 | 199 | @Override 200 | public void onBackPressed() { 201 | if (hamburgerMenu.isShowing()) { 202 | hamburgerMenu.dismiss(); 203 | } else if (profileMenu.isShowing()) { 204 | profileMenu.dismiss(); 205 | } else if (writeMenu.isShowing()) { 206 | writeMenu.dismiss(); 207 | } else if (alertMenu.isShowing()) { 208 | alertMenu.dismiss(); 209 | } else if (dialogMenu.isShowing()) { 210 | dialogMenu.dismiss(); 211 | } else if (customDialogMenu.isShowing()) { 212 | customDialogMenu.dismiss(); 213 | } else if (iconMenu.isShowing()) { 214 | iconMenu.dismiss(); 215 | } else { 216 | super.onBackPressed(); 217 | } 218 | } 219 | } 220 | -------------------------------------------------------------------------------- /app/src/main/java/com/skydoves/powermenudemo/PowerMenuUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 skydoves (Jaewoong Eum) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.skydoves.powermenudemo; 18 | 19 | import android.content.Context; 20 | import android.graphics.Color; 21 | import android.graphics.Typeface; 22 | import android.graphics.drawable.ColorDrawable; 23 | import android.view.Gravity; 24 | import androidx.appcompat.view.ContextThemeWrapper; 25 | import androidx.core.content.ContextCompat; 26 | import androidx.lifecycle.Lifecycle; 27 | import androidx.lifecycle.LifecycleOwner; 28 | import com.skydoves.powermenu.CircularEffect; 29 | import com.skydoves.powermenu.CustomPowerMenu; 30 | import com.skydoves.powermenu.MenuAnimation; 31 | import com.skydoves.powermenu.OnDismissedListener; 32 | import com.skydoves.powermenu.OnMenuItemClickListener; 33 | import com.skydoves.powermenu.PowerMenu; 34 | import com.skydoves.powermenu.PowerMenuItem; 35 | import com.skydoves.powermenudemo.customs.adapters.CenterMenuAdapter; 36 | import com.skydoves.powermenudemo.customs.adapters.CustomDialogMenuAdapter; 37 | import com.skydoves.powermenudemo.customs.items.NameCardMenuItem; 38 | 39 | public class PowerMenuUtils { 40 | 41 | public static PowerMenu getHamburgerPowerMenu( 42 | Context context, 43 | LifecycleOwner lifecycleOwner, 44 | OnMenuItemClickListener onMenuItemClickListener, 45 | OnDismissedListener onDismissedListener) { 46 | return new PowerMenu.Builder(context) 47 | .addItem(new PowerMenuItem("Novel", true)) 48 | .addItem(new PowerMenuItem("Poetry", false)) 49 | .addItem(new PowerMenuItem("Art", false)) 50 | .addItem(new PowerMenuItem("Journals", false)) 51 | .addItem(new PowerMenuItem("Travel", false)) 52 | .setAutoDismiss(true) 53 | .setLifecycleOwner(lifecycleOwner) 54 | .setAnimation(MenuAnimation.SHOWUP_TOP_LEFT) 55 | .setCircularEffect(CircularEffect.BODY) 56 | .setMenuRadius(10f) 57 | .setMenuShadow(10f) 58 | .setTextColor(ContextCompat.getColor(context, R.color.md_grey_800)) 59 | .setTextSize(12) 60 | .setTextGravity(Gravity.CENTER) 61 | .setTextTypeface(Typeface.create("sans-serif-medium", Typeface.BOLD)) 62 | .setSelectedTextColor(Color.WHITE) 63 | .setMenuColor(Color.WHITE) 64 | .setSelectedMenuColor(ContextCompat.getColor(context, R.color.colorPrimary)) 65 | .setOnMenuItemClickListener(onMenuItemClickListener) 66 | .setOnDismissListener(onDismissedListener) 67 | .setPreferenceName("HamburgerPowerMenu") 68 | .setInitializeRule(Lifecycle.Event.ON_CREATE, 0) 69 | .build(); 70 | } 71 | 72 | public static PowerMenu getProfilePowerMenu( 73 | Context context, 74 | LifecycleOwner lifecycleOwner, 75 | OnMenuItemClickListener onMenuItemClickListener) { 76 | return new PowerMenu.Builder(context) 77 | .setHeaderView(R.layout.item_title_header) 78 | .addItem(new PowerMenuItem("Profile", false)) 79 | .addItem(new PowerMenuItem("Board", false)) 80 | .addItem(new PowerMenuItem("Logout", false)) 81 | .setLifecycleOwner(lifecycleOwner) 82 | .setAnimation(MenuAnimation.SHOWUP_TOP_RIGHT) 83 | .setMenuRadius(10f) 84 | .setMenuShadow(10f) 85 | .setTextColor(ContextCompat.getColor(context, R.color.md_grey_800)) 86 | .setTextGravity(Gravity.CENTER) 87 | .setMenuColor(Color.WHITE) 88 | .setSelectedEffect(false) 89 | .setShowBackground(false) 90 | .setFocusable(true) 91 | .setOnMenuItemClickListener(onMenuItemClickListener) 92 | .build(); 93 | } 94 | 95 | public static CustomPowerMenu getWritePowerMenu( 96 | Context context, 97 | LifecycleOwner lifecycleOwner, 98 | OnMenuItemClickListener onMenuItemClickListener) { 99 | ColorDrawable drawable = 100 | new ColorDrawable(ContextCompat.getColor(context, R.color.md_blue_grey_300)); 101 | return new CustomPowerMenu.Builder<>(context, new CenterMenuAdapter()) 102 | .addItem("Novel") 103 | .addItem("Poetry") 104 | .addItem("Art") 105 | .addItem("Journals") 106 | .addItem("Travel") 107 | .setLifecycleOwner(lifecycleOwner) 108 | .setAnimation(MenuAnimation.FADE) 109 | .setCircularEffect(CircularEffect.BODY) 110 | .setMenuRadius(10f) 111 | .setMenuShadow(10f) 112 | .setDivider(drawable) 113 | .setDividerHeight(1) 114 | .setOnMenuItemClickListener(onMenuItemClickListener) 115 | .build(); 116 | } 117 | 118 | public static CustomPowerMenu getAlertPowerMenu( 119 | Context context, 120 | LifecycleOwner lifecycleOwner, 121 | OnMenuItemClickListener onMenuItemClickListener) { 122 | return new CustomPowerMenu.Builder<>(context, new CenterMenuAdapter()) 123 | .addItem("You need to login!") 124 | .addItem("You need to login2!") 125 | .addItem("You need to login3!") 126 | .setLifecycleOwner(lifecycleOwner) 127 | .setAnimation(MenuAnimation.ELASTIC_CENTER) 128 | .setMenuRadius(context.getResources().getDimensionPixelSize(R.dimen.menu_corner_radius)) 129 | .setMenuShadow(context.getResources().getDimensionPixelSize(R.dimen.menu_elevation)) 130 | .setIsMaterial(true) 131 | .setFocusable(true) 132 | .setAutoDismiss(true) 133 | .setShowBackground(false) 134 | .setOnMenuItemClickListener(onMenuItemClickListener) 135 | .build(); 136 | } 137 | 138 | public static PowerMenu getIconPowerMenu( 139 | Context context, 140 | LifecycleOwner lifecycleOwner, 141 | OnMenuItemClickListener onMenuItemClickListener) { 142 | 143 | Context styledContext = new ContextThemeWrapper(context, R.style.PopupCardThemeOverlay); 144 | 145 | return new PowerMenu.Builder(styledContext) 146 | .addItem(new PowerMenuItem("WeChat", false, R.drawable.ic_wechat)) 147 | .addItem(new PowerMenuItem("Facebook", false, R.drawable.ic_facebook)) 148 | .addItem(new PowerMenuItem("Twitter", false, R.drawable.ic_twitter)) 149 | .addItem(new PowerMenuItem("Line", false, R.drawable.ic_line)) 150 | .addItem(new PowerMenuItem("Other")) 151 | .setLifecycleOwner(lifecycleOwner) 152 | .setOnMenuItemClickListener(onMenuItemClickListener) 153 | .setAnimation(MenuAnimation.FADE) 154 | .setMenuRadius(context.getResources().getDimensionPixelSize(R.dimen.menu_corner_radius)) 155 | .setMenuShadow(context.getResources().getDimensionPixelSize(R.dimen.menu_elevation)) 156 | .setIsMaterial(true) 157 | .build(); 158 | } 159 | 160 | public static PowerMenu getDialogPowerMenu(Context context, LifecycleOwner lifecycleOwner) { 161 | return new PowerMenu.Builder(context) 162 | .setHeaderView(R.layout.layout_dialog_header) 163 | .setFooterView(R.layout.layout_dialog_footer) 164 | .addItem(new PowerMenuItem("This is DialogPowerMenu", false)) 165 | .setLifecycleOwner(lifecycleOwner) 166 | .setAnimation(MenuAnimation.SHOW_UP_CENTER) 167 | .setMenuRadius(10f) 168 | .setMenuShadow(10f) 169 | .setPadding(14) 170 | .setWidth(600) 171 | .setSelectedEffect(false) 172 | .build(); 173 | } 174 | 175 | public static CustomPowerMenu getCustomDialogPowerMenu( 176 | Context context, LifecycleOwner lifecycleOwner) { 177 | return new CustomPowerMenu.Builder<>(context, new CustomDialogMenuAdapter()) 178 | .setHeaderView(R.layout.layout_custom_dialog_header) 179 | .setFooterView(R.layout.layout_custom_dialog_footer) 180 | .addItem( 181 | new NameCardMenuItem( 182 | ContextCompat.getDrawable(context, R.drawable.face3), 183 | "Sophie", 184 | context.getString(R.string.board3))) 185 | .setLifecycleOwner(lifecycleOwner) 186 | .setAnimation(MenuAnimation.SHOW_UP_CENTER) 187 | .setWidth(800) 188 | .setMenuRadius(10f) 189 | .setMenuShadow(10f) 190 | .build(); 191 | } 192 | } 193 | -------------------------------------------------------------------------------- /app/src/main/java/com/skydoves/powermenudemo/customs/adapters/CenterMenuAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 skydoves (Jaewoong Eum) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.skydoves.powermenudemo.customs.adapters; 18 | 19 | import android.content.Context; 20 | import android.view.LayoutInflater; 21 | import android.view.View; 22 | import android.view.ViewGroup; 23 | import android.widget.TextView; 24 | import androidx.core.content.ContextCompat; 25 | import com.skydoves.powermenu.MenuBaseAdapter; 26 | import com.skydoves.powermenudemo.R; 27 | 28 | public class CenterMenuAdapter extends MenuBaseAdapter { 29 | 30 | public CenterMenuAdapter() { 31 | super(); 32 | } 33 | 34 | @Override 35 | public View getView(int index, View view, ViewGroup viewGroup) { 36 | final Context context = viewGroup.getContext(); 37 | 38 | if (view == null) { 39 | LayoutInflater inflater = LayoutInflater.from(context); 40 | assert inflater != null; 41 | view = inflater.inflate(R.layout.item_title_menu, viewGroup, false); 42 | } 43 | 44 | String item = (String) getItem(index); 45 | final TextView title = view.findViewById(R.id.item_title); 46 | title.setText(item); 47 | title.setTextColor(ContextCompat.getColor(context, R.color.md_grey_800)); 48 | return super.getView(index, view, viewGroup); 49 | } 50 | 51 | @Override 52 | public void setSelectedPosition(int position) { 53 | notifyDataSetChanged(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /app/src/main/java/com/skydoves/powermenudemo/customs/adapters/CustomDialogMenuAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 skydoves (Jaewoong Eum) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.skydoves.powermenudemo.customs.adapters; 18 | 19 | import android.content.Context; 20 | import android.view.LayoutInflater; 21 | import android.view.View; 22 | import android.view.ViewGroup; 23 | import android.widget.ImageView; 24 | import android.widget.TextView; 25 | import com.skydoves.powermenu.MenuBaseAdapter; 26 | import com.skydoves.powermenudemo.R; 27 | import com.skydoves.powermenudemo.customs.items.NameCardMenuItem; 28 | 29 | @SuppressWarnings("ConstantConditions") 30 | public class CustomDialogMenuAdapter extends MenuBaseAdapter { 31 | 32 | public CustomDialogMenuAdapter() { 33 | super(); 34 | } 35 | 36 | @Override 37 | public View getView(int index, View view, ViewGroup viewGroup) { 38 | final Context context = viewGroup.getContext(); 39 | 40 | if (view == null) { 41 | LayoutInflater inflater = LayoutInflater.from(context); 42 | view = inflater.inflate(R.layout.item_name_card, viewGroup, false); 43 | } 44 | 45 | NameCardMenuItem item = (NameCardMenuItem) getItem(index); 46 | final ImageView icon = view.findViewById(R.id.item_name_card_profile); 47 | icon.setImageDrawable(item.getIcon()); 48 | final TextView name = view.findViewById(R.id.item_name_card_name); 49 | name.setText(item.getName()); 50 | final TextView content = view.findViewById(R.id.item_name_card_board); 51 | content.setText(item.getContent()); 52 | return super.getView(index, view, viewGroup); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /app/src/main/java/com/skydoves/powermenudemo/customs/items/NameCardMenuItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 skydoves (Jaewoong Eum) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.skydoves.powermenudemo.customs.items; 18 | 19 | import android.graphics.drawable.Drawable; 20 | 21 | @SuppressWarnings("unused") 22 | public class NameCardMenuItem { 23 | private Drawable icon; 24 | private String name; 25 | private String content; 26 | 27 | public NameCardMenuItem(Drawable icon, String name, String content) { 28 | this.icon = icon; 29 | this.name = name; 30 | this.content = content; 31 | } 32 | 33 | public Drawable getIcon() { 34 | return this.icon; 35 | } 36 | 37 | public void setIcon(Drawable drawable) { 38 | this.icon = drawable; 39 | } 40 | 41 | public String getName() { 42 | return this.name; 43 | } 44 | 45 | public void setName(String name) { 46 | this.name = name; 47 | } 48 | 49 | public String getContent() { 50 | return content; 51 | } 52 | 53 | public void setContent(String content) { 54 | this.content = content; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /app/src/main/java/com/skydoves/powermenudemo/kotlin/KotlinActivity.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 skydoves (Jaewoong Eum) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.skydoves.powermenudemo.kotlin 18 | 19 | import android.os.Bundle 20 | import android.widget.Toast 21 | import androidx.appcompat.app.AppCompatActivity 22 | import com.skydoves.powermenu.kotlin.powerMenu 23 | import com.skydoves.powermenudemo.databinding.ActivityTestBinding 24 | 25 | class KotlinActivity : AppCompatActivity() { 26 | 27 | private val moreMenu by powerMenu() 28 | 29 | override fun onCreate(savedInstanceState: Bundle?) { 30 | super.onCreate(savedInstanceState) 31 | 32 | val binding = ActivityTestBinding.inflate(layoutInflater) 33 | setContentView(binding.root) 34 | 35 | moreMenu.showAsDropDown(binding.button) 36 | binding.button.setOnClickListener { 37 | moreMenu.showAsDropDown(it) 38 | } 39 | 40 | moreMenu.setOnMenuItemClickListener { position, item -> 41 | moreMenu.selectedPosition = position 42 | Toast.makeText(this, item.title, Toast.LENGTH_SHORT).show() 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/java/com/skydoves/powermenudemo/kotlin/MoreMenuFactory.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 skydoves (Jaewoong Eum) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.skydoves.powermenudemo.kotlin 18 | 19 | import android.content.Context 20 | import android.graphics.Color 21 | import android.graphics.Typeface 22 | import android.view.Gravity 23 | import androidx.lifecycle.Lifecycle 24 | import androidx.lifecycle.LifecycleOwner 25 | import com.skydoves.powermenu.CircularEffect 26 | import com.skydoves.powermenu.MenuAnimation 27 | import com.skydoves.powermenu.PowerMenu 28 | import com.skydoves.powermenu.PowerMenuItem 29 | import com.skydoves.powermenu.kotlin.createPowerMenu 30 | import com.skydoves.powermenudemo.R 31 | 32 | class MoreMenuFactory : PowerMenu.Factory() { 33 | 34 | override fun create(context: Context, lifecycle: LifecycleOwner): PowerMenu { 35 | return createPowerMenu(context) { 36 | addItem(PowerMenuItem("Novel", true)) 37 | addItem(PowerMenuItem("Poetry", false)) 38 | addItem(PowerMenuItem("Art", false)) 39 | addItem(PowerMenuItem("Journals", false)) 40 | addItem(PowerMenuItem("Travel", false)) 41 | setAutoDismiss(true) 42 | setLifecycleOwner(lifecycle) 43 | setAnimation(MenuAnimation.SHOWUP_TOP_LEFT) 44 | setCircularEffect(CircularEffect.BODY) 45 | setMenuRadius(10f) 46 | setMenuShadow(10f) 47 | setTextColorResource(R.color.md_grey_800) 48 | setTextSize(12) 49 | setTextGravity(Gravity.CENTER) 50 | setTextTypeface(Typeface.create("sans-serif-medium", Typeface.BOLD)) 51 | setSelectedTextColor(Color.WHITE) 52 | setMenuColor(Color.WHITE) 53 | setSelectedMenuColorResource(R.color.colorPrimary) 54 | setPreferenceName("HamburgerPowerMenu") 55 | setInitializeRule(Lifecycle.Event.ON_CREATE, 0) 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 23 | 28 | 29 | 35 | 38 | 41 | 42 | 43 | 44 | 50 | 51 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/face1.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/PowerMenu/0dab20dae71a4f452095b85e22a1c7dcb52e8081/app/src/main/res/drawable/face1.jpeg -------------------------------------------------------------------------------- /app/src/main/res/drawable/face2.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/PowerMenu/0dab20dae71a4f452095b85e22a1c7dcb52e8081/app/src/main/res/drawable/face2.jpeg -------------------------------------------------------------------------------- /app/src/main/res/drawable/face3.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/PowerMenu/0dab20dae71a4f452095b85e22a1c7dcb52e8081/app/src/main/res/drawable/face3.jpeg -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_facebook.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/PowerMenu/0dab20dae71a4f452095b85e22a1c7dcb52e8081/app/src/main/res/drawable/ic_facebook.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_hamburger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/PowerMenu/0dab20dae71a4f452095b85e22a1c7dcb52e8081/app/src/main/res/drawable/ic_hamburger.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 22 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 175 | 180 | 185 | 186 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/PowerMenu/0dab20dae71a4f452095b85e22a1c7dcb52e8081/app/src/main/res/drawable/ic_line.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_pencil.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/PowerMenu/0dab20dae71a4f452095b85e22a1c7dcb52e8081/app/src/main/res/drawable/ic_pencil.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_twitter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/PowerMenu/0dab20dae71a4f452095b85e22a1c7dcb52e8081/app/src/main/res/drawable/ic_twitter.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/PowerMenu/0dab20dae71a4f452095b85e22a1c7dcb52e8081/app/src/main/res/drawable/ic_user.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_wechat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/PowerMenu/0dab20dae71a4f452095b85e22a1c7dcb52e8081/app/src/main/res/drawable/ic_wechat.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/icon_share.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/PowerMenu/0dab20dae71a4f452095b85e22a1c7dcb52e8081/app/src/main/res/drawable/icon_share.png -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 22 | 23 | 26 | 27 | 30 | 31 | 37 | 38 | 46 | 47 | 48 | 49 | 50 | 51 | 60 | 61 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_test.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 20 | 21 |