├── .gitignore
├── LICENSE
├── README.md
├── art
└── sample.gif
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── library
├── .gitignore
├── build.gradle
├── gradle.properties
├── maven-push.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── andremion
│ │ └── floatingnavigationview
│ │ ├── CircularRevealNavigationView.java
│ │ └── FloatingNavigationView.java
│ └── res
│ ├── animator
│ ├── close_to_menu.xml
│ └── menu_to_close.xml
│ ├── drawable
│ ├── ic_close_animated.xml
│ ├── ic_close_vector.xml
│ ├── ic_menu_animated.xml
│ └── ic_menu_vector.xml
│ └── values
│ ├── attrs.xml
│ └── strings.xml
├── sample
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── andremion
│ │ └── floatingnavigationview
│ │ └── sample
│ │ └── MainActivity.java
│ └── res
│ ├── drawable
│ ├── ic_menu_camera.xml
│ ├── ic_menu_gallery.xml
│ ├── ic_menu_manage.xml
│ ├── ic_menu_send.xml
│ ├── ic_menu_share.xml
│ └── ic_menu_slideshow.xml
│ ├── layout
│ ├── activity_main.xml
│ ├── content_main.xml
│ └── navigation_view_header.xml
│ ├── menu
│ └── navigation_view.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxxhdpi
│ └── ic_launcher.png
│ ├── values-v19
│ └── styles.xml
│ ├── values-v21
│ └── styles.xml
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
└── settings.gradle
/.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 | .gradle/
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 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | # Android Studio captures folder
33 | captures/
34 |
35 | # Intellij
36 | *.iml
37 | .idea/
38 |
39 | # Keystore files
40 | *.jks
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](http://www.apache.org/licenses/LICENSE-2.0)
2 | 
3 | 
4 | [](https://search.maven.org/#artifactdetails%7Ccom.github.andremion%7Cfloatingnavigationview%7C1.3.0%7Caar)
5 |
6 | [](https://android-arsenal.com/details/1/4134)
7 | [](https://www.uplabs.com/posts/floating-navigation-view)
8 | [](http://androidweekly.net/issues/issue-224)
9 | [](https://androidsweets.ongoodbits.com/2016/09/29/issue-38)
10 | [](https://kmshack.github.io/AndroidUICollection/page2/)
11 | [](https://github.com/JStumpp/awesome-android#navigation)
12 |
13 | # Floating Navigation View
14 |
15 | A simple Floating Action Button that shows an anchored Navigation View and was inspired by [Menu Material Fixed](http://www.uplabs.com/posts/menu-material-fixed) created by [Tommaso Poletti](http://www.uplabs.com/tomma5o)
16 |
17 | 
18 |
19 | ## Installation
20 |
21 | Include the library in your `build.gradle`
22 |
23 | ```groovy
24 | dependencies{
25 | compile 'com.github.andremion:floatingnavigationview:1.3.0'
26 | }
27 | ```
28 |
29 | or in your `pom.xml` if you are using Maven
30 |
31 | ```xml
32 |
33 | com.github.andremion
34 | floatingnavigationview
35 | 1.3.0
36 | aar
37 |
38 | ```
39 |
40 | ## Usage example
41 |
42 | ```xml
43 |
44 |
49 |
50 |
54 |
55 | ...
56 |
57 |
68 |
69 |
70 | ```
71 |
72 | ### Custom attributes
73 |
74 | - The menu resource to inflate and populate items from
75 | ``
76 |
77 | - Layout resource to inflate as the header
78 | ``
79 |
80 | - Item text customizations
81 | ``
82 | ``
83 | ``
84 | ``
85 |
86 | - If menu must be drawn below the FAB
87 | ``
88 |
89 | The recommended way to customize the background color is by using the `app:backgroundTint` attribute in `xml` or `setBackgroundTintList` in `Java`
90 |
91 | ```xml
92 |
97 | ```
98 |
99 | ```java
100 | mNavigationView.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#009688")));
101 | ```
102 |
103 | You can also set the button icon color according to the theme by setting the `android:tint` to a theme attribute:
104 |
105 | ```xml
106 |
111 | ```
112 |
113 | See more at the [sample](https://github.com/andremion/Floating-Navigation-View/tree/master/sample)
114 |
115 | ## Libraries and tools used in the project
116 |
117 | * [Design Support Library](http://developer.android.com/intl/pt-br/tools/support-library/features.html#design)
118 | The Design package provides APIs to support adding material design components and patterns to your apps.
119 | * [VectAlign](https://github.com/bonnyfone/vectalign)
120 | VectAlign is a developer's tool which aligns two VectorDrawable "pathData" strings (or SVG images) in order to allow morphing animations between them using an AnimatedVectorDrawable.
121 |
122 | ## License
123 |
124 | Copyright 2019 André Mion
125 |
126 | Licensed under the Apache License, Version 2.0 (the "License");
127 | you may not use this file except in compliance with the License.
128 | You may obtain a copy of the License at
129 |
130 | http://www.apache.org/licenses/LICENSE-2.0
131 |
132 | Unless required by applicable law or agreed to in writing, software
133 | distributed under the License is distributed on an "AS IS" BASIS,
134 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
135 | See the License for the specific language governing permissions and
136 | limitations under the License.
137 |
--------------------------------------------------------------------------------
/art/sample.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andremion/Floating-Navigation-View/9c18a511042c4f5339cc0333f00c7ab48682732c/art/sample.gif
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | google()
4 | jcenter()
5 | }
6 | dependencies {
7 | classpath 'com.android.tools.build:gradle:4.0.1'
8 | }
9 | }
10 |
11 | allprojects {
12 | repositories {
13 | google()
14 | jcenter()
15 | }
16 | ext {
17 | compileSdkVersion = 30
18 | minSdkVersion = 19
19 | targetSdkVersion = 30
20 | materialDesignVersion = '1.2.1'
21 | junitVersion = '4.12'
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | android.useAndroidX=true
2 |
3 | VERSION_NAME=1.3.0
4 | VERSION_CODE=6
5 | GROUP=com.github.andremion
6 |
7 | POM_DESCRIPTION=A simple Floating Action Button that shows an anchored Navigation View
8 | POM_URL=https://github.com/andremion/Floating-Navigation-View
9 | POM_SCM_URL=https://github.com/andremion/Floating-Navigation-View
10 | POM_SCM_CONNECTION=scm:git@github.com:andremion/Floating-Navigation-View.git
11 | POM_SCM_DEV_CONNECTION=scm:git@github.com:andremion/Floating-Navigation-View.git
12 | POM_LICENCE_NAME=The Apache Software License, Version 2.0
13 | POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
14 | POM_LICENCE_DIST=repo
15 | POM_DEVELOPER_ID=andremion
16 | POM_DEVELOPER_NAME=Andre Mion
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andremion/Floating-Navigation-View/9c18a511042c4f5339cc0333f00c7ab48682732c/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Feb 14 13:34:27 WET 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/library/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply from: 'maven-push.gradle'
3 |
4 | android {
5 | compileSdkVersion project.ext.compileSdkVersion
6 |
7 | defaultConfig {
8 | minSdkVersion project.ext.minSdkVersion
9 | targetSdkVersion project.ext.targetSdkVersion
10 | versionCode = VERSION_CODE
11 | versionName = VERSION_NAME
12 | vectorDrawables.useSupportLibrary = true
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | implementation fileTree(dir: 'libs', include: ['*.jar'])
24 | implementation "com.google.android.material:material:$materialDesignVersion"
25 | }
26 |
--------------------------------------------------------------------------------
/library/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_NAME=Floating Navigation View
2 | POM_ARTIFACT_ID=floatingnavigationview
3 | POM_PACKAGING=aar
4 |
--------------------------------------------------------------------------------
/library/maven-push.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013 Chris Banes
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 | apply plugin: 'maven'
18 | apply plugin: 'signing'
19 |
20 | def isReleaseBuild() {
21 | return VERSION_NAME.contains("SNAPSHOT") == false
22 | }
23 |
24 | def getReleaseRepositoryUrl() {
25 | return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
26 | : "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
27 | }
28 |
29 | def getSnapshotRepositoryUrl() {
30 | return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
31 | : "https://oss.sonatype.org/content/repositories/snapshots/"
32 | }
33 |
34 | def getRepositoryUsername() {
35 | return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
36 | }
37 |
38 | def getRepositoryPassword() {
39 | return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : ""
40 | }
41 |
42 | afterEvaluate { project ->
43 | uploadArchives {
44 | repositories {
45 | mavenDeployer {
46 | beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
47 |
48 | pom.groupId = GROUP
49 | pom.artifactId = POM_ARTIFACT_ID
50 | pom.version = VERSION_NAME
51 |
52 | repository(url: getReleaseRepositoryUrl()) {
53 | authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
54 | }
55 | snapshotRepository(url: getSnapshotRepositoryUrl()) {
56 | authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
57 | }
58 |
59 | pom.project {
60 | name POM_NAME
61 | packaging POM_PACKAGING
62 | description POM_DESCRIPTION
63 | url POM_URL
64 |
65 | scm {
66 | url POM_SCM_URL
67 | connection POM_SCM_CONNECTION
68 | developerConnection POM_SCM_DEV_CONNECTION
69 | }
70 |
71 | licenses {
72 | license {
73 | name POM_LICENCE_NAME
74 | url POM_LICENCE_URL
75 | distribution POM_LICENCE_DIST
76 | }
77 | }
78 |
79 | developers {
80 | developer {
81 | id POM_DEVELOPER_ID
82 | name POM_DEVELOPER_NAME
83 | }
84 | }
85 | }
86 | }
87 | }
88 | }
89 |
90 | signing {
91 | required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
92 | sign configurations.archives
93 | }
94 |
95 | //task androidJavadocs(type: Javadoc) {
96 | //source = android.sourceSets.main.allJava
97 | //}
98 |
99 | //task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
100 | //classifier = 'javadoc'
101 | //from androidJavadocs.destinationDir
102 | //}
103 |
104 | task androidSourcesJar(type: Jar) {
105 | classifier = 'sources'
106 | from android.sourceSets.main.java.sourceFiles
107 | }
108 |
109 | artifacts {
110 | archives androidSourcesJar
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/library/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 C:\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 |
--------------------------------------------------------------------------------
/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/library/src/main/java/com/andremion/floatingnavigationview/CircularRevealNavigationView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019. André Mion
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.andremion.floatingnavigationview;
18 |
19 | import android.annotation.SuppressLint;
20 | import android.content.Context;
21 | import android.graphics.Canvas;
22 | import android.graphics.drawable.Drawable;
23 | import android.util.AttributeSet;
24 |
25 | import com.google.android.material.circularreveal.CircularRevealHelper;
26 | import com.google.android.material.circularreveal.CircularRevealWidget;
27 | import com.google.android.material.navigation.NavigationView;
28 |
29 | import androidx.annotation.NonNull;
30 | import androidx.annotation.Nullable;
31 |
32 | @SuppressWarnings("JavaDoc")
33 | class CircularRevealNavigationView extends NavigationView implements CircularRevealWidget {
34 |
35 | private final CircularRevealHelper helper;
36 |
37 | public CircularRevealNavigationView(Context context) {
38 | this(context, null);
39 | }
40 |
41 | public CircularRevealNavigationView(Context context, AttributeSet attrs) {
42 | this(context, attrs, 0);
43 | }
44 |
45 | public CircularRevealNavigationView(Context context, AttributeSet attrs, int defStyleAttr) {
46 | super(context, attrs, defStyleAttr);
47 | helper = new CircularRevealHelper(this);
48 | }
49 |
50 | @Override public void buildCircularRevealCache() {
51 | helper.buildCircularRevealCache();
52 | }
53 |
54 | @Override public void destroyCircularRevealCache() {
55 | helper.destroyCircularRevealCache();
56 | }
57 |
58 | @Nullable @Override public RevealInfo getRevealInfo() {
59 | return helper.getRevealInfo();
60 | }
61 |
62 | @Override public void setRevealInfo(@Nullable RevealInfo revealInfo) {
63 | helper.setRevealInfo(revealInfo);
64 | }
65 |
66 | @Override public int getCircularRevealScrimColor() {
67 | return helper.getCircularRevealScrimColor();
68 | }
69 |
70 | @Override public void setCircularRevealScrimColor(int color) {
71 | helper.setCircularRevealScrimColor(color);
72 | }
73 |
74 | @Nullable @Override public Drawable getCircularRevealOverlayDrawable() {
75 | return helper.getCircularRevealOverlayDrawable();
76 | }
77 |
78 | @Override public void setCircularRevealOverlayDrawable(@Nullable Drawable drawable) {
79 | helper.setCircularRevealOverlayDrawable(drawable);
80 | }
81 |
82 | @SuppressLint("MissingSuperCall") @Override public void draw(@NonNull Canvas canvas) {
83 | helper.draw(canvas);
84 | }
85 |
86 | @SuppressLint("RestrictedApi") @Override public void actualDraw(Canvas canvas) {
87 | super.draw(canvas);
88 | }
89 |
90 | @Override public boolean actualIsOpaque() {
91 | return isOpaque();
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/library/src/main/java/com/andremion/floatingnavigationview/FloatingNavigationView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019. André Mion
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.andremion.floatingnavigationview;
18 |
19 | import android.animation.Animator;
20 | import android.animation.AnimatorListenerAdapter;
21 | import android.animation.AnimatorSet;
22 | import android.animation.ObjectAnimator;
23 | import android.annotation.SuppressLint;
24 | import android.content.Context;
25 | import android.content.res.ColorStateList;
26 | import android.content.res.TypedArray;
27 | import android.graphics.PixelFormat;
28 | import android.graphics.Rect;
29 | import android.graphics.drawable.ColorDrawable;
30 | import android.graphics.drawable.Drawable;
31 | import android.os.Parcel;
32 | import android.os.Parcelable;
33 | import android.util.AttributeSet;
34 | import android.util.SparseArray;
35 | import android.view.Gravity;
36 | import android.view.Menu;
37 | import android.view.MotionEvent;
38 | import android.view.View;
39 | import android.view.ViewTreeObserver;
40 | import android.view.WindowManager;
41 | import android.widget.FrameLayout;
42 | import android.widget.ImageView;
43 |
44 | import androidx.annotation.ColorInt;
45 | import androidx.annotation.IdRes;
46 | import androidx.annotation.LayoutRes;
47 | import androidx.annotation.MenuRes;
48 | import androidx.annotation.NonNull;
49 | import androidx.annotation.Nullable;
50 | import androidx.appcompat.app.AppCompatDelegate;
51 | import androidx.coordinatorlayout.widget.CoordinatorLayout;
52 | import androidx.core.os.ParcelableCompat;
53 | import androidx.core.os.ParcelableCompatCreatorCallbacks;
54 | import androidx.core.view.MotionEventCompat;
55 | import androidx.core.view.ViewCompat;
56 | import androidx.customview.view.AbsSavedState;
57 | import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat;
58 |
59 | import com.google.android.material.circularreveal.CircularRevealCompat;
60 | import com.google.android.material.floatingactionbutton.FloatingActionButton;
61 | import com.google.android.material.internal.NavigationMenuView;
62 | import com.google.android.material.navigation.NavigationView;
63 |
64 | @SuppressWarnings({"FieldCanBeLocal", "InflateParams", "RtlHardcoded", "unused", "WeakerAccess"})
65 | public class FloatingNavigationView extends FloatingActionButton {
66 |
67 | private final WindowManager mWindowManager;
68 |
69 | private final CircularRevealNavigationView mNavigationView;
70 | private final NavigationMenuView mNavigationMenuView;
71 | private final ImageView mFabView;
72 |
73 | private final Rect mFabRect = new Rect();
74 | private final Rect mNavigationRect = new Rect();
75 |
76 | private final boolean mDrawMenuBelowFab;
77 | private final OnTouchListener mNavigationTouchListener = new OnTouchListener() {
78 | @Override
79 | public boolean onTouch(@NonNull View v, @NonNull MotionEvent event) {
80 | final int x = (int) event.getX();
81 | final int y = (int) event.getY();
82 | if ((MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN)
83 | && ((x < 0) || (x >= mNavigationView.getWidth())
84 | || (y < 0) || (y >= mNavigationView.getHeight()))) {
85 | close();
86 | return true;
87 | } else if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_OUTSIDE) {
88 | close();
89 | return true;
90 | }
91 | return false;
92 | }
93 | };
94 | private final OnClickListener mFabClickListener = new OnClickListener() {
95 | @Override
96 | public void onClick(View v) {
97 | close();
98 | }
99 | };
100 |
101 | public FloatingNavigationView(Context context) {
102 | this(context, null);
103 | }
104 |
105 | public FloatingNavigationView(Context context, AttributeSet attrs) {
106 | this(context, attrs, 0);
107 | }
108 |
109 | public FloatingNavigationView(Context context, AttributeSet attrs, int defStyleAttr) {
110 | super(context, attrs, defStyleAttr);
111 | AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
112 | setImageResource(R.drawable.ic_menu_vector);
113 |
114 | mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
115 |
116 | mNavigationView = new CircularRevealNavigationView(context, attrs, defStyleAttr);
117 | setupNavigationView(context, attrs);
118 | mNavigationMenuView = mNavigationView.findViewById(R.id.design_navigation_view);
119 |
120 | mFabView = new ImageView(context, attrs, defStyleAttr);
121 | setupFabView(context, attrs);
122 |
123 | // Custom attributes
124 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FloatingNavigationView);
125 | mDrawMenuBelowFab = a.getBoolean(R.styleable.FloatingNavigationView_drawMenuBelowFab, false);
126 | a.recycle();
127 | }
128 |
129 | @SuppressLint("ClickableViewAccessibility")
130 | private void setupNavigationView(Context context, AttributeSet attrs) {
131 | mNavigationView.setBackground(new ColorDrawable(getBackgroundColor()));
132 | mNavigationView.setOnTouchListener(mNavigationTouchListener);
133 | }
134 |
135 | @SuppressLint("PrivateResource")
136 | private void setupFabView(Context context, AttributeSet attrs) {
137 | TypedArray a = context.obtainStyledAttributes(attrs, new int[]{R.attr.selectableItemBackgroundBorderless});
138 | mFabView.setScaleType(ScaleType.CENTER);
139 | mFabView.setBackground(a.getDrawable(0));
140 | mFabView.setOnClickListener(mFabClickListener);
141 | mFabView.setContentDescription(getContentDescription());
142 | mFabView.bringToFront();
143 | a.recycle();
144 | mNavigationView.addView(mFabView, new FrameLayout.LayoutParams(
145 | getResources().getDimensionPixelSize(R.dimen.design_fab_size_normal),
146 | getResources().getDimensionPixelSize(R.dimen.design_fab_size_normal)
147 | ));
148 | }
149 |
150 | private @ColorInt int getBackgroundColor() {
151 | ColorStateList colorStateList = getBackgroundTintList();
152 | if (colorStateList != null) {
153 | return colorStateList.getDefaultColor();
154 | }
155 | Drawable background = getBackground();
156 | if (background instanceof ColorDrawable) {
157 | return ((ColorDrawable) background).getColor();
158 | }
159 | return getSolidColor();
160 | }
161 |
162 | @Override
163 | public void setBackgroundTintList(@Nullable ColorStateList tint) {
164 | super.setBackgroundTintList(tint);
165 | ViewCompat.setBackgroundTintList(mNavigationView, tint);
166 | }
167 |
168 | @NonNull
169 | private static WindowManager.LayoutParams createLayoutParams(int gravity) {
170 | WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(
171 | WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.MATCH_PARENT,
172 | WindowManager.LayoutParams.TYPE_APPLICATION_PANEL,
173 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
174 | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
175 | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
176 | PixelFormat.TRANSLUCENT);
177 | layoutParams.gravity = gravity;
178 | return layoutParams;
179 | }
180 |
181 | @Override
182 | protected void onDetachedFromWindow() {
183 | super.onDetachedFromWindow();
184 | detachNavigationView(); // Prevent Leaked Window when configuration changes
185 | }
186 |
187 | public void open() {
188 | if (isOpened()) {
189 | return;
190 | }
191 | attachNavigationView();
192 | mNavigationMenuView.scrollToPosition(0);
193 | mNavigationView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
194 | @Override
195 | public void onGlobalLayout() {
196 | mNavigationView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
197 | updateFabBounds();
198 | drawMenuBelowFab();
199 | startOpenAnimations();
200 | }
201 | });
202 | }
203 |
204 | public void close() {
205 | if (!isOpened()) {
206 | return;
207 | }
208 | startCloseAnimations();
209 | }
210 |
211 | public boolean isOpened() {
212 | return mNavigationView.getParent() != null;
213 | }
214 |
215 | private void attachNavigationView() {
216 |
217 | CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) getLayoutParams();
218 | int gravity = Gravity.LEFT;
219 | if (layoutParams.getAnchorId() != View.NO_ID && layoutParams.anchorGravity != Gravity.NO_GRAVITY) {
220 | if (Gravity.isHorizontal(layoutParams.anchorGravity)) {
221 | gravity = layoutParams.anchorGravity;
222 | }
223 | } else if (layoutParams.gravity != Gravity.NO_GRAVITY) {
224 | if (Gravity.isHorizontal(layoutParams.gravity)) {
225 | gravity = layoutParams.gravity;
226 | }
227 | }
228 |
229 | // Gravity.START and Gravity.END don't work for views added in WindowManager with RTL.
230 | // We need to convert script specific gravity to absolute horizontal value
231 | // If horizontal direction is LTR, then START will set LEFT and END will set RIGHT.
232 | // If horizontal direction is RTL, then START will set RIGHT and END will set LEFT.
233 | gravity = Gravity.getAbsoluteGravity(gravity, ViewCompat.getLayoutDirection(this));
234 |
235 | mWindowManager.addView(mNavigationView, createLayoutParams(gravity));
236 | }
237 |
238 | private void detachNavigationView() {
239 | if (isOpened()) {
240 | mWindowManager.removeViewImmediate(mNavigationView);
241 | }
242 | }
243 |
244 | private void startOpenAnimations() {
245 |
246 | // Icon
247 | AnimatedVectorDrawableCompat menuIcon = AnimatedVectorDrawableCompat.create(getContext(),
248 | R.drawable.ic_menu_animated);
249 | mFabView.setImageDrawable(menuIcon);
250 | menuIcon.start();
251 |
252 | // Reveal
253 | int centerX = mFabRect.centerX();
254 | int centerY = mFabRect.centerY();
255 | float startRadius = getMinRadius();
256 | float endRadius = getMaxRadius();
257 | Animator reveal = CircularRevealCompat.createCircularReveal(
258 | mNavigationView, centerX, centerY, startRadius, endRadius
259 | );
260 |
261 | // Fade in
262 | mNavigationMenuView.setAlpha(0);
263 | Animator fade = ObjectAnimator.ofFloat(mNavigationMenuView, View.ALPHA, 0, 1);
264 |
265 | // Animations
266 | AnimatorSet set = new AnimatorSet();
267 | set.playSequentially(reveal, fade);
268 | set.start();
269 | }
270 |
271 | private void startCloseAnimations() {
272 |
273 | // Icon
274 | AnimatedVectorDrawableCompat closeIcon = AnimatedVectorDrawableCompat.create(getContext(),
275 | R.drawable.ic_close_animated);
276 | mFabView.setImageDrawable(closeIcon);
277 | closeIcon.start();
278 |
279 | // Unreveal
280 | int centerX = mFabRect.centerX();
281 | int centerY = mFabRect.centerY();
282 | float startRadius = getMaxRadius();
283 | float endRadius = getMinRadius();
284 | Animator reveal = CircularRevealCompat.createCircularReveal(
285 | mNavigationView, centerX, centerY, startRadius, endRadius
286 | );
287 | reveal.addListener(new AnimatorListenerAdapter() {
288 | @Override
289 | public void onAnimationEnd(Animator animation) {
290 | detachNavigationView();
291 | }
292 | });
293 |
294 | // Fade out
295 | Animator fade = ObjectAnimator.ofFloat(mNavigationMenuView, View.ALPHA, 1, 0);
296 |
297 | // Animations
298 | AnimatorSet set = new AnimatorSet();
299 | set.playTogether(fade, reveal);
300 | set.start();
301 | }
302 |
303 | private void updateFabBounds() {
304 | updateFabRect();
305 | updateNavigationRect();
306 | FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) mFabView.getLayoutParams();
307 | layoutParams.width = getWidth();
308 | layoutParams.height = getHeight();
309 | layoutParams.topMargin = mFabRect.top;
310 | if (ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL) {
311 | layoutParams.rightMargin = mNavigationView.getWidth() - mFabRect.right;
312 | } else {
313 | layoutParams.leftMargin = mFabRect.left;
314 | }
315 | mFabView.setLayoutParams(layoutParams);
316 | }
317 |
318 | private void updateFabRect() {
319 | getGlobalVisibleRect(mFabRect);
320 | int[] offset = new int[2];
321 | mNavigationView.getLocationOnScreen(offset);
322 | mFabRect.offset(-offset[0], -offset[1]);
323 | }
324 |
325 | private void updateNavigationRect() {
326 | mNavigationView.getGlobalVisibleRect(mNavigationRect);
327 | }
328 |
329 | private void drawMenuBelowFab() {
330 | if (mDrawMenuBelowFab) {
331 | // Add padding top to positioning menu below the FAB
332 | mNavigationMenuView.setPadding(
333 | mNavigationMenuView.getPaddingLeft(),
334 | mFabRect.bottom,
335 | mNavigationMenuView.getPaddingRight(),
336 | mNavigationMenuView.getPaddingBottom());
337 | }
338 | }
339 |
340 | private float getMinRadius() {
341 | return mFabRect.width() / 2f;
342 | }
343 |
344 | private float getMaxRadius() {
345 | return (float) Math.hypot(mNavigationRect.width(), mNavigationRect.height());
346 | }
347 |
348 | /**
349 | * Set a listener that will be notified when a menu item is clicked.
350 | *
351 | * @param listener The listener to notify
352 | */
353 | public void setNavigationItemSelectedListener(@Nullable NavigationView.OnNavigationItemSelectedListener listener) {
354 | mNavigationView.setNavigationItemSelectedListener(listener);
355 | }
356 |
357 | /*
358 | {@link NavigationView} methods
359 | */
360 |
361 | /**
362 | * Inflate a menu resource into this navigation view.
363 | *
364 | * Existing items in the menu will not be modified or removed.
365 | *
366 | * @param resId ID of a menu resource to inflate
367 | */
368 | public void inflateMenu(@MenuRes int resId) {
369 | mNavigationView.inflateMenu(resId);
370 | }
371 |
372 | /**
373 | * Returns the {@link Menu} instance associated with this navigation view.
374 | */
375 | public Menu getMenu() {
376 | return mNavigationView.getMenu();
377 | }
378 |
379 | /**
380 | * Inflates a View and add it as a header of the navigation menu.
381 | *
382 | * @param res The layout resource ID.
383 | * @return a newly inflated View.
384 | */
385 | public View inflateHeaderView(@LayoutRes int res) {
386 | return mNavigationView.inflateHeaderView(res);
387 | }
388 |
389 | /**
390 | * Adds a View as a header of the navigation menu.
391 | *
392 | * @param view The view to be added as a header of the navigation menu.
393 | */
394 | public void addHeaderView(@NonNull View view) {
395 | mNavigationView.addHeaderView(view);
396 | }
397 |
398 | /**
399 | * Removes a previously-added header view.
400 | *
401 | * @param view The view to remove
402 | */
403 | public void removeHeaderView(@NonNull View view) {
404 | mNavigationView.removeHeaderView(view);
405 | }
406 |
407 | /**
408 | * Gets the number of headers in this NavigationView.
409 | *
410 | * @return A positive integer representing the number of headers.
411 | */
412 | public int getHeaderCount() {
413 | return mNavigationView.getHeaderCount();
414 | }
415 |
416 | /**
417 | * Gets the header view at the specified position.
418 | *
419 | * @param index The position at which to get the view from.
420 | * @return The header view the specified position or null if the position does not exist in this
421 | * NavigationView.
422 | */
423 | public View getHeaderView(int index) {
424 | return mNavigationView.getHeaderView(index);
425 | }
426 |
427 | /**
428 | * Sets the currently checked item in this navigation menu.
429 | *
430 | * @param id The item ID of the currently checked item.
431 | */
432 | public void setCheckedItem(@IdRes int id) {
433 | mNavigationView.setCheckedItem(id);
434 | }
435 |
436 | /**
437 | * {@link SavedState} methods
438 | */
439 |
440 | @Override
441 | protected Parcelable onSaveInstanceState() {
442 | Parcelable superState = super.onSaveInstanceState();
443 | SavedState ss = new SavedState(superState);
444 | ss.navigationViewState = new SparseArray();
445 | //noinspection unchecked
446 | mNavigationView.saveHierarchyState(ss.navigationViewState);
447 | ss.opened = isOpened();
448 | return ss;
449 | }
450 |
451 | @Override
452 | protected void onRestoreInstanceState(Parcelable state) {
453 | SavedState ss = (SavedState) state;
454 | super.onRestoreInstanceState(ss.getSuperState());
455 | //noinspection unchecked
456 | mNavigationView.restoreHierarchyState(ss.navigationViewState);
457 | if (ss.opened) {
458 | mFabView.setImageResource(R.drawable.ic_close_vector);
459 | // Run on post to prevent "unable to add window -- token null is not valid" error
460 | post(new Runnable() {
461 | @Override
462 | public void run() {
463 | attachNavigationView();
464 | mNavigationView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
465 | @Override
466 | public void onGlobalLayout() {
467 | mNavigationView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
468 | updateFabBounds();
469 | drawMenuBelowFab();
470 | }
471 | });
472 | }
473 | });
474 | }
475 | }
476 |
477 | public static class SavedState extends AbsSavedState {
478 |
479 | private SparseArray navigationViewState;
480 | private boolean opened;
481 |
482 | private SavedState(Parcel in, ClassLoader loader) {
483 | super(in, loader);
484 | navigationViewState = in.readSparseArray(loader);
485 | opened = (Boolean) in.readValue(loader);
486 | }
487 |
488 | private SavedState(Parcelable superState) {
489 | super(superState);
490 | }
491 |
492 | @Override
493 | public void writeToParcel(@NonNull Parcel dest, int flags) {
494 | super.writeToParcel(dest, flags);
495 | //noinspection unchecked
496 | dest.writeSparseArray(navigationViewState);
497 | dest.writeValue(opened);
498 | }
499 |
500 | @Override
501 | public String toString() {
502 | return FloatingNavigationView.class.getSimpleName() + "." + SavedState.class.getSimpleName() + "{"
503 | + Integer.toHexString(System.identityHashCode(this))
504 | + " opened=" + opened + "}";
505 | }
506 |
507 | public static final Parcelable.Creator CREATOR
508 | = ParcelableCompat.newCreator(new ParcelableCompatCreatorCallbacks() {
509 | @Override
510 | public SavedState createFromParcel(Parcel parcel, ClassLoader loader) {
511 | return new SavedState(parcel, loader);
512 | }
513 |
514 | @Override
515 | public SavedState[] newArray(int size) {
516 | return new SavedState[size];
517 | }
518 | });
519 | }
520 | }
521 |
--------------------------------------------------------------------------------
/library/src/main/res/animator/close_to_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
18 |
19 |
24 |
25 |
--------------------------------------------------------------------------------
/library/src/main/res/animator/menu_to_close.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
18 |
19 |
24 |
25 |
30 |
31 |
--------------------------------------------------------------------------------
/library/src/main/res/drawable/ic_close_animated.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
18 |
21 |
--------------------------------------------------------------------------------
/library/src/main/res/drawable/ic_close_vector.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
21 |
25 |
26 |
--------------------------------------------------------------------------------
/library/src/main/res/drawable/ic_menu_animated.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
18 |
21 |
--------------------------------------------------------------------------------
/library/src/main/res/drawable/ic_menu_vector.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
21 |
25 |
26 |
--------------------------------------------------------------------------------
/library/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/library/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 | M3,8 L21,8 21,6 3,6z M3,18 L21,18 21,16 3,16z M3,13 L21,13 21,11 3,11z
18 | M3,13 L21,13 21,11 3,11z M3,13 L21,13 21,11 3,11z M3,12 L21,12 21,12 3,12z
19 | M5,6.41 L17.59,19 19,17.59 6.41,5z M6.41,19 L19,6.41 17.59,5 5,17.59z M12,12 L12,12 12,12 12,12z
20 |
21 |
--------------------------------------------------------------------------------
/sample/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/sample/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion project.ext.compileSdkVersion
5 |
6 | defaultConfig {
7 | applicationId "com.andremion.floatingnavigationview.sample"
8 | minSdkVersion project.ext.minSdkVersion
9 | targetSdkVersion project.ext.targetSdkVersion
10 | versionCode = VERSION_CODE
11 | versionName = VERSION_NAME
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | implementation fileTree(dir: 'libs', include: ['*.jar'])
23 | implementation project(':library')
24 | implementation "com.google.android.material:material:$materialDesignVersion"
25 | }
26 |
--------------------------------------------------------------------------------
/sample/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 C:\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 |
--------------------------------------------------------------------------------
/sample/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/andremion/floatingnavigationview/sample/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.andremion.floatingnavigationview.sample;
2 |
3 | import android.os.Bundle;
4 | import android.view.MenuItem;
5 | import android.view.View;
6 |
7 | import com.andremion.floatingnavigationview.FloatingNavigationView;
8 | import com.google.android.material.navigation.NavigationView;
9 | import com.google.android.material.snackbar.Snackbar;
10 |
11 | import androidx.appcompat.app.AppCompatActivity;
12 | import androidx.appcompat.widget.Toolbar;
13 |
14 | public class MainActivity extends AppCompatActivity {
15 |
16 | private FloatingNavigationView mFloatingNavigationView;
17 |
18 | @Override
19 | protected void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | setContentView(R.layout.activity_main);
22 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
23 | setSupportActionBar(toolbar);
24 |
25 | mFloatingNavigationView = (FloatingNavigationView) findViewById(R.id.floating_navigation_view);
26 | mFloatingNavigationView.setOnClickListener(new View.OnClickListener() {
27 | @Override
28 | public void onClick(View view) {
29 | mFloatingNavigationView.open();
30 | }
31 | });
32 | mFloatingNavigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
33 | @Override
34 | public boolean onNavigationItemSelected(MenuItem item) {
35 | Snackbar.make((View) mFloatingNavigationView.getParent(), item.getTitle() + " Selected!", Snackbar.LENGTH_SHORT).show();
36 | mFloatingNavigationView.close();
37 | return true;
38 | }
39 | });
40 | }
41 |
42 | @Override
43 | public void onBackPressed() {
44 | if (mFloatingNavigationView.isOpened()) {
45 | mFloatingNavigationView.close();
46 | } else {
47 | super.onBackPressed();
48 | }
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_menu_camera.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
13 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_menu_gallery.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_menu_manage.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_menu_send.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_menu_share.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_menu_slideshow.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
21 |
22 |
23 |
24 |
25 |
26 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
15 |
19 |
20 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/navigation_view_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
17 |
18 |
24 |
25 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/sample/src/main/res/menu/navigation_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
37 |
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andremion/Floating-Navigation-View/9c18a511042c4f5339cc0333f00c7ab48682732c/sample/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andremion/Floating-Navigation-View/9c18a511042c4f5339cc0333f00c7ab48682732c/sample/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andremion/Floating-Navigation-View/9c18a511042c4f5339cc0333f00c7ab48682732c/sample/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andremion/Floating-Navigation-View/9c18a511042c4f5339cc0333f00c7ab48682732c/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andremion/Floating-Navigation-View/9c18a511042c4f5339cc0333f00c7ab48682732c/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/values-v19/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
--------------------------------------------------------------------------------
/sample/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
--------------------------------------------------------------------------------
/sample/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 16dp
6 |
7 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Floating Navigation View
3 | André Mion
4 | https://github.com/andremion
5 | Import
6 | Gallery
7 | Slideshow
8 | Tools
9 | Communicate
10 | Share
11 | Send
12 |
13 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':sample', ':library'
2 |
--------------------------------------------------------------------------------