├── FABToolbar
├── .gitignore
├── .idea
│ ├── .name
│ ├── compiler.xml
│ ├── copyright
│ │ └── profiles_settings.xml
│ ├── encodings.xml
│ ├── gradle.xml
│ ├── misc.xml
│ ├── modules.xml
│ ├── runConfigurations.xml
│ └── vcs.xml
├── FABToolbar.iml
├── app
│ ├── .gitignore
│ ├── app.iml
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ │ ├── androidTest
│ │ └── java
│ │ │ └── com
│ │ │ └── github
│ │ │ └── fafaldo
│ │ │ └── fabtoolbar
│ │ │ └── ApplicationTest.java
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ └── com
│ │ │ └── github
│ │ │ └── fafaldo
│ │ │ └── fabtoolbar
│ │ │ └── sample
│ │ │ └── MainActivity.java
│ │ └── res
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ └── values
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── library
│ ├── .gitignore
│ ├── build.gradle
│ ├── gradle.properties
│ ├── library.iml
│ ├── proguard-rules.pro
│ └── src
│ │ ├── androidTest
│ │ └── java
│ │ │ └── com
│ │ │ └── github
│ │ │ └── fafaldo
│ │ │ └── fabtoolbar
│ │ │ └── ApplicationTest.java
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ └── com
│ │ │ └── github
│ │ │ └── fafaldo
│ │ │ └── fabtoolbar
│ │ │ ├── util
│ │ │ └── ExpandAnimationUtils.java
│ │ │ └── widget
│ │ │ └── FABToolbarLayout.java
│ │ └── res
│ │ ├── drawable
│ │ └── empty_drawable.xml
│ │ └── values
│ │ ├── strings.xml
│ │ └── styles.xml
└── settings.gradle
├── LICENSE
├── README.md
└── fabtoolbar.gif
/FABToolbar/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea/workspace.xml
4 | /.idea/libraries
5 | .DS_Store
6 | /build
7 | /captures
8 |
--------------------------------------------------------------------------------
/FABToolbar/.idea/.name:
--------------------------------------------------------------------------------
1 | FABToolbar
--------------------------------------------------------------------------------
/FABToolbar/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/FABToolbar/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/FABToolbar/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/FABToolbar/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
19 |
20 |
--------------------------------------------------------------------------------
/FABToolbar/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/FABToolbar/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/FABToolbar/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/FABToolbar/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/FABToolbar/FABToolbar.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/FABToolbar/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/FABToolbar/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | generateDebugAndroidTestSources
19 | generateDebugSources
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/FABToolbar/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.1"
6 |
7 | defaultConfig {
8 | applicationId "com.github.fafaldo.fabtoolbar"
9 | minSdkVersion 16
10 | targetSdkVersion 23
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(include: ['*.jar'], dir: 'libs')
24 | compile 'com.android.support:appcompat-v7:23.0.1'
25 | compile 'com.android.support:design:23.0.1'
26 | compile project(':library')
27 | }
28 |
--------------------------------------------------------------------------------
/FABToolbar/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\programy\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 |
--------------------------------------------------------------------------------
/FABToolbar/app/src/androidTest/java/com/github/fafaldo/fabtoolbar/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.github.fafaldo.fabtoolbar;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/FABToolbar/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/FABToolbar/app/src/main/java/com/github/fafaldo/fabtoolbar/sample/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.github.fafaldo.fabtoolbar.sample;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.view.View;
6 | import android.widget.AdapterView;
7 | import android.widget.ArrayAdapter;
8 | import android.widget.ListView;
9 | import android.widget.Toast;
10 |
11 | import com.github.fafaldo.fabtoolbar.widget.FABToolbarLayout;
12 |
13 |
14 | public class MainActivity extends AppCompatActivity implements View.OnClickListener{
15 | private FABToolbarLayout layout;
16 | private View one, two, three, four;
17 | private ListView list;
18 | private View fab;
19 |
20 | @Override
21 | protected void onCreate(Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 | setContentView(R.layout.activity_main);
24 |
25 | layout = (FABToolbarLayout) findViewById(R.id.fabtoolbar);
26 | one = findViewById(R.id.one);
27 | two = findViewById(R.id.two);
28 | three = findViewById(R.id.three);
29 | four = findViewById(R.id.four);
30 | list = (ListView) findViewById(R.id.list);
31 | fab = findViewById(R.id.fabtoolbar_fab);
32 |
33 | one.setOnClickListener(this);
34 | two.setOnClickListener(this);
35 | three.setOnClickListener(this);
36 | four.setOnClickListener(this);
37 |
38 | String[] data = new String[30];
39 | for(int i = 0; i < 30; i++) {
40 | data[i] = "Test " + i;
41 | }
42 | ArrayAdapter adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, data);
43 | list.setAdapter(adapter);
44 | list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
45 | @Override
46 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
47 | layout.show();
48 | }
49 | });
50 |
51 | fab.setOnClickListener(new View.OnClickListener() {
52 | @Override
53 | public void onClick(View v) {
54 | layout.show();
55 | }
56 | });
57 | }
58 |
59 | @Override
60 | public void onBackPressed() {
61 | layout.hide();
62 | }
63 |
64 | @Override
65 | public void onClick(View v) {
66 | Toast.makeText(this, "Element clicked", Toast.LENGTH_SHORT).show();
67 | }
68 | }
69 |
70 |
--------------------------------------------------------------------------------
/FABToolbar/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
18 |
19 |
23 |
24 |
28 |
29 |
36 |
37 |
38 |
39 |
45 |
46 |
53 |
54 |
61 |
62 |
69 |
70 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/FABToolbar/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fafaldo-zz/FABToolbar/bc39a912d214eb8ba399b3610809eed10ce2d098/FABToolbar/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/FABToolbar/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fafaldo-zz/FABToolbar/bc39a912d214eb8ba399b3610809eed10ce2d098/FABToolbar/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/FABToolbar/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fafaldo-zz/FABToolbar/bc39a912d214eb8ba399b3610809eed10ce2d098/FABToolbar/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/FABToolbar/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fafaldo-zz/FABToolbar/bc39a912d214eb8ba399b3610809eed10ce2d098/FABToolbar/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/FABToolbar/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/FABToolbar/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | FABToolbar
3 |
4 | Hello world!
5 | Settings
6 |
7 |
--------------------------------------------------------------------------------
/FABToolbar/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/FABToolbar/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:1.3.0'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/FABToolbar/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/FABToolbar/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fafaldo-zz/FABToolbar/bc39a912d214eb8ba399b3610809eed10ce2d098/FABToolbar/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/FABToolbar/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun Sep 27 16:33:48 CEST 2015
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-2.4-all.zip
7 |
--------------------------------------------------------------------------------
/FABToolbar/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 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/FABToolbar/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 |
--------------------------------------------------------------------------------
/FABToolbar/library/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/FABToolbar/library/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.2"
6 |
7 | defaultConfig {
8 | minSdkVersion 15
9 | targetSdkVersion 23
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | compile fileTree(dir: 'libs', include: ['*.jar'])
23 | compile 'com.android.support:appcompat-v7:23.1.1'
24 | }
25 |
26 | apply from: 'https://raw.github.com/fafaldo/gradle-mvn-push/master/gradle-mvn-push.gradle'
--------------------------------------------------------------------------------
/FABToolbar/library/gradle.properties:
--------------------------------------------------------------------------------
1 | VERSION_NAME=1.1.0
2 | VERSION_CODE=3
3 | GROUP=com.github.fafaldo
4 |
5 | POM_DESCRIPTION=An implementation of Google design, with Floating Action Button transforming into toolbar
6 | POM_URL=https://github.com/fafaldo/FABToolbar
7 | POM_SCM_URL=https://github.com/fafaldo/FABToolbar
8 | POM_SCM_CONNECTION=scm:git@github.com:fafaldo/FABToolbar.git
9 | POM_SCM_DEV_CONNECTION=scm:git@github.com:fafaldo/FABToolbar.git
10 | POM_LICENCE_NAME=The MIT License (MIT)
11 | POM_LICENCE_URL=https://opensource.org/licenses/MIT
12 | POM_LICENCE_DIST=repo
13 | POM_DEVELOPER_ID=fafaldo
14 | POM_DEVELOPER_NAME=Rafal Tulaza
15 |
16 | POM_NAME=FABToolbar Library
17 | POM_ARTIFACT_ID=fab-toolbar
18 | POM_PACKAGING=jar
--------------------------------------------------------------------------------
/FABToolbar/library/library.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | generateDebugAndroidTestSources
19 | generateDebugSources
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/FABToolbar/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 D:\programy\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 |
--------------------------------------------------------------------------------
/FABToolbar/library/src/androidTest/java/com/github/fafaldo/fabtoolbar/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.github.fafaldo.fabtoolbar;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/FABToolbar/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/FABToolbar/library/src/main/java/com/github/fafaldo/fabtoolbar/util/ExpandAnimationUtils.java:
--------------------------------------------------------------------------------
1 | package com.github.fafaldo.fabtoolbar.util;
2 |
3 | import android.animation.Animator;
4 | import android.animation.AnimatorListenerAdapter;
5 | import android.animation.ObjectAnimator;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 |
9 | import java.util.ArrayList;
10 | import java.util.List;
11 |
12 | /**
13 | * Created by fafik on 2015-07-31.
14 | */
15 | public class ExpandAnimationUtils {
16 |
17 | public static List build(final ViewGroup view, int pivotX, int pivotY, float fraction, int duration, int delay) {
18 | List animatorList = new ArrayList<>();
19 |
20 | for(int i = 0; i < view.getChildCount(); i++) {
21 | View childView = view.getChildAt(i);
22 |
23 | int deltaX = pivotX - (childView.getLeft() + childView.getWidth()/2);
24 | int deltaY = pivotY - (childView.getTop() + childView.getHeight()/2);
25 |
26 | ObjectAnimator xAnim = ObjectAnimator.ofFloat(childView, "translationX", fraction * deltaX, 0);
27 | ObjectAnimator yAnim = ObjectAnimator.ofFloat(childView, "translationY", fraction * deltaY, 0);
28 |
29 | xAnim.setDuration(duration);
30 | xAnim.setStartDelay(delay);
31 | yAnim.setDuration(duration);
32 | yAnim.setStartDelay(delay);
33 |
34 | animatorList.add(xAnim);
35 | animatorList.add(yAnim);
36 | }
37 |
38 | ObjectAnimator alphaAnim = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f);
39 | alphaAnim.addListener(new AnimatorListenerAdapter() {
40 | @Override
41 | public void onAnimationStart(Animator animation) {
42 | view.setVisibility(View.VISIBLE);
43 | }
44 | });
45 |
46 | alphaAnim.setDuration(duration);
47 | alphaAnim.setStartDelay(delay);
48 |
49 | animatorList.add(alphaAnim);
50 |
51 | return animatorList;
52 | }
53 |
54 | public static List buildReversed(final ViewGroup view, int pivotX, int pivotY, float fraction, int duration, int delay) {
55 | List animatorList = new ArrayList<>();
56 |
57 | for(int i = 0; i < view.getChildCount(); i++) {
58 | View childView = view.getChildAt(i);
59 |
60 | int deltaX = pivotX - (childView.getLeft() + childView.getWidth()/2);
61 | int deltaY = pivotY - (childView.getTop() + childView.getHeight()/2);
62 |
63 | ObjectAnimator xAnim = ObjectAnimator.ofFloat(childView, "translationX", 0, fraction * deltaX);
64 | ObjectAnimator yAnim = ObjectAnimator.ofFloat(childView, "translationY", 0, fraction * deltaY);
65 |
66 | xAnim.setDuration(duration);
67 | xAnim.setStartDelay(delay);
68 | yAnim.setDuration(duration);
69 | yAnim.setStartDelay(delay);
70 |
71 | animatorList.add(xAnim);
72 | animatorList.add(yAnim);
73 | }
74 |
75 | ObjectAnimator alphaAnim = ObjectAnimator.ofFloat(view, "alpha", 1f, 0f);
76 | alphaAnim.addListener(new AnimatorListenerAdapter() {
77 | @Override
78 | public void onAnimationEnd(Animator animation) {
79 | view.setVisibility(View.INVISIBLE);
80 | }
81 | });
82 |
83 | alphaAnim.setDuration(duration);
84 | alphaAnim.setStartDelay(delay);
85 |
86 | animatorList.add(alphaAnim);
87 |
88 | return animatorList;
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/FABToolbar/library/src/main/java/com/github/fafaldo/fabtoolbar/widget/FABToolbarLayout.java:
--------------------------------------------------------------------------------
1 | package com.github.fafaldo.fabtoolbar.widget;
2 |
3 | import android.animation.Animator;
4 | import android.animation.AnimatorListenerAdapter;
5 | import android.animation.AnimatorSet;
6 | import android.animation.ObjectAnimator;
7 | import android.animation.ValueAnimator;
8 | import android.annotation.SuppressLint;
9 | import android.content.Context;
10 | import android.content.res.TypedArray;
11 | import android.graphics.Point;
12 | import android.graphics.drawable.Drawable;
13 | import android.graphics.drawable.TransitionDrawable;
14 | import android.os.Build;
15 | import android.util.AttributeSet;
16 | import android.view.View;
17 | import android.view.ViewGroup;
18 | import android.view.ViewTreeObserver;
19 | import android.view.animation.AccelerateInterpolator;
20 | import android.view.animation.DecelerateInterpolator;
21 | import android.widget.ImageView;
22 | import android.widget.RelativeLayout;
23 |
24 | import com.github.fafaldo.fabtoolbar.R;
25 | import com.github.fafaldo.fabtoolbar.util.ExpandAnimationUtils;
26 |
27 | import java.util.ArrayList;
28 | import java.util.List;
29 |
30 |
31 |
32 | /**
33 | * Created by rtulaza on 2015-07-30.
34 | */
35 | public class FABToolbarLayout extends RelativeLayout {
36 |
37 | // anim timing
38 | //
39 | // 0 1/4 1/3 1/2 2/3 3/4 1
40 | // |---------------|-----|----------|----------|-----|---------------|
41 | // |<------------------------------>|
42 | // xAnim, yAnim
43 | // |<------------------->|
44 | // drawable
45 | // |<------------------------------->|
46 | // sizeAnim
47 | // |<------------------->|
48 | // expand
49 | //
50 |
51 | private int SHOW_ANIM_DURATION = 600;
52 | private int HIDE_ANIM_DURATION = 600;
53 | private int HORIZONTAL_MARGIN = 100;
54 | private int VERTICAL_MARGIN = 100;
55 |
56 | private int pivotX = -1;
57 | private int pivotY = -1;
58 | private float fraction = 0.2f;
59 |
60 | private int fabId = -1;
61 | private int containerId = -1;
62 | private int toolbarId = -1;
63 |
64 | private View toolbarLayout;
65 | private ImageView fab;
66 | private TransitionDrawable fabDrawable;
67 | private Drawable fabNormalDrawable;
68 | private RelativeLayout fabContainer;
69 |
70 | private Point toolbarPos = new Point();
71 | private Point toolbarSize = new Point();
72 | private Point fabPos = new Point();
73 | private Point fabSize = new Point();
74 |
75 | private boolean isFab = true;
76 | private boolean isToolbar = false;
77 | private boolean isInit = true;
78 |
79 | private boolean fabDrawableAnimationEnabled = true;
80 |
81 | private int originalToolbarSize = -1;
82 | private int originalFABSize;
83 |
84 | public FABToolbarLayout(Context context) {
85 | super(context);
86 | }
87 |
88 | public FABToolbarLayout(Context context, AttributeSet attrs) {
89 | super(context, attrs);
90 | parseAttrs(attrs);
91 | }
92 |
93 | public FABToolbarLayout(Context context, AttributeSet attrs, int defStyleAttr) {
94 | super(context, attrs, defStyleAttr);
95 | parseAttrs(attrs);
96 | }
97 |
98 | private void parseAttrs(AttributeSet attrs) {
99 | TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.FABToolbarLayout);
100 |
101 | SHOW_ANIM_DURATION = a.getInt(R.styleable.FABToolbarLayout_showDuration, SHOW_ANIM_DURATION);
102 | HIDE_ANIM_DURATION = a.getInt(R.styleable.FABToolbarLayout_hideDuration, HIDE_ANIM_DURATION);
103 | VERTICAL_MARGIN = a.getDimensionPixelSize(R.styleable.FABToolbarLayout_verticalMargin, VERTICAL_MARGIN);
104 | HORIZONTAL_MARGIN = a.getDimensionPixelSize(R.styleable.FABToolbarLayout_horizontalMargin, HORIZONTAL_MARGIN);
105 | pivotX = a.getDimensionPixelSize(R.styleable.FABToolbarLayout_fadeInPivotX, -1);
106 | pivotY = a.getDimensionPixelSize(R.styleable.FABToolbarLayout_fadeInPivotY, -1);
107 | fraction = a.getFloat(R.styleable.FABToolbarLayout_fadeInFraction, fraction);
108 | fabId = a.getResourceId(R.styleable.FABToolbarLayout_fabId, -1);
109 | containerId = a.getResourceId(R.styleable.FABToolbarLayout_containerId, -1);
110 | toolbarId = a.getResourceId(R.styleable.FABToolbarLayout_fabToolbarId, -1);
111 | fabDrawableAnimationEnabled = a.getBoolean(R.styleable.FABToolbarLayout_fabDrawableAnimationEnabled, true);
112 |
113 | a.recycle();
114 | }
115 |
116 | @SuppressLint("DrawAllocation")
117 | @Override
118 | protected void onLayout(boolean changed, int l, int t, int r, int b) {
119 | super.onLayout(changed, l, t, r, b);
120 |
121 | if(!isInit) {
122 | return;
123 | }
124 |
125 | toolbarLayout = findViewById(toolbarId);
126 | if (toolbarLayout == null) {
127 | throw new IllegalStateException("You have to place a view with id = R.id.fabtoolbar_toolbar inside FABToolbarLayout");
128 | }
129 |
130 | fabContainer = (RelativeLayout) findViewById(containerId);
131 | if (fabContainer == null) {
132 | throw new IllegalStateException("You have to place a FABContainer view with id = R.id.fabtoolbar_container inside FABToolbarLayout");
133 | }
134 |
135 | fab = (ImageView) fabContainer.findViewById(fabId);
136 | if (fab == null) {
137 | throw new IllegalStateException("You have to place a FAB view with id = R.id.fabtoolbar_fab inside FABContainer");
138 | }
139 |
140 | fab.setVisibility(INVISIBLE);
141 |
142 | Drawable tempDrawable = fab.getDrawable();
143 | fabNormalDrawable = tempDrawable;
144 | if(fabDrawableAnimationEnabled) {
145 | TransitionDrawable transitionDrawable;
146 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
147 | transitionDrawable = new TransitionDrawable(new Drawable[]{tempDrawable, getResources().getDrawable(R.drawable.empty_drawable, getContext().getTheme())});
148 | } else {
149 | transitionDrawable = new TransitionDrawable(new Drawable[]{tempDrawable, getResources().getDrawable(R.drawable.empty_drawable)});
150 | }
151 | transitionDrawable.setCrossFadeEnabled(fabDrawableAnimationEnabled);
152 | fabDrawable = transitionDrawable;
153 | fab.setImageDrawable(transitionDrawable);
154 | }
155 |
156 | toolbarLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
157 | @Override
158 | public void onGlobalLayout() {
159 | if (toolbarLayout.getWidth() != 0 || toolbarLayout.getHeight() != 0) {
160 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
161 | toolbarLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
162 | } else {
163 | toolbarLayout.getViewTreeObserver().removeGlobalOnLayoutListener(this);
164 | }
165 |
166 | int[] pos = new int[2];
167 |
168 | toolbarSize.set(toolbarLayout.getWidth(), toolbarLayout.getHeight());
169 | toolbarLayout.getLocationOnScreen(pos);
170 | toolbarPos.set(pos[0], pos[1]);
171 |
172 | int[] fabContainerPos = new int[2];
173 | fabContainer.getLocationOnScreen(fabContainerPos);
174 |
175 | RelativeLayout.LayoutParams fabParams = (RelativeLayout.LayoutParams) fab.getLayoutParams();
176 | RelativeLayout.LayoutParams fabContainerParams = (RelativeLayout.LayoutParams) fabContainer.getLayoutParams();
177 |
178 | int distanceVertical = (toolbarSize.y - fab.getHeight())/2;
179 | int verticalMarginToSet = VERTICAL_MARGIN - distanceVertical;
180 |
181 | if(fabParams.getRules()[ALIGN_PARENT_LEFT] == RelativeLayout.TRUE) {
182 | fabParams.leftMargin = HORIZONTAL_MARGIN;
183 | } else {
184 | fabParams.addRule(ALIGN_PARENT_RIGHT);
185 | fabParams.rightMargin = HORIZONTAL_MARGIN;
186 | }
187 |
188 | fab.setLayoutParams(fabParams);
189 |
190 | fabContainer.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
191 | @Override
192 | public void onGlobalLayout() {
193 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
194 | toolbarLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
195 | } else {
196 | toolbarLayout.getViewTreeObserver().removeGlobalOnLayoutListener(this);
197 | }
198 |
199 | fab.setVisibility(VISIBLE);
200 | }
201 | });
202 |
203 | fabContainerParams.height = toolbarSize.y;
204 | if(originalToolbarSize == -1) {
205 | originalToolbarSize = toolbarSize.y;
206 | }
207 | if(fabContainerParams.getRules()[ALIGN_PARENT_TOP] == RelativeLayout.TRUE) {
208 | fabContainerParams.topMargin = verticalMarginToSet;
209 | } else {
210 | fabContainerParams.addRule(ALIGN_PARENT_BOTTOM);
211 | fabContainerParams.bottomMargin = verticalMarginToSet;
212 | }
213 |
214 | fabContainer.setLayoutParams(fabContainerParams);
215 |
216 | toolbarLayout.setVisibility(INVISIBLE);
217 | toolbarLayout.setAlpha(0f);
218 | }
219 | }
220 | });
221 |
222 | fab.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
223 | @Override
224 | public void onGlobalLayout() {
225 | if (fab.getWidth() != 0 || fab.getHeight() != 0) {
226 | if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
227 | fab.getViewTreeObserver().removeOnGlobalLayoutListener(this);
228 | } else {
229 | fab.getViewTreeObserver().removeGlobalOnLayoutListener(this);
230 | }
231 |
232 | fabSize.set(fab.getWidth(), fab.getHeight());
233 |
234 | RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) fab.getLayoutParams();
235 | layoutParams.addRule(CENTER_VERTICAL);
236 | fab.setLayoutParams(layoutParams);
237 | }
238 | }
239 | });
240 |
241 | toolbarLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
242 | @Override
243 | public void onGlobalLayout() {
244 | RelativeLayout.LayoutParams fabContainerParams = (RelativeLayout.LayoutParams) fabContainer.getLayoutParams();
245 | fabContainerParams.height = toolbarLayout.getHeight();
246 | fabContainer.setLayoutParams(fabContainerParams);
247 |
248 |
249 | int[] pos = new int[2];
250 | toolbarSize.set(toolbarLayout.getWidth(), toolbarLayout.getHeight());
251 | toolbarLayout.getLocationOnScreen(pos);
252 | toolbarPos.set(pos[0], pos[1]);
253 | }
254 | });
255 |
256 | fab.setLayerType(LAYER_TYPE_SOFTWARE, null);
257 |
258 | setClipChildren(false);
259 |
260 | isInit = false;
261 | }
262 |
263 | public void show() {
264 | //TODO better handling of fast clicks
265 | if(!isFab) {
266 | return;
267 | }
268 | isFab = false;
269 |
270 | setClipChildren(true);
271 |
272 | int[] fabP = new int[2];
273 | fab.getLocationOnScreen(fabP);
274 | fabPos.set(fabP[0], fabP[1]);
275 | originalFABSize = fab.getWidth();
276 |
277 | List animators = new ArrayList<>();
278 |
279 |
280 | // TRANSLATION ANIM
281 | int xDest = toolbarPos.x + (toolbarSize.x - fabSize.x) / 2;
282 |
283 |
284 | int[] fabConPos = new int[2];
285 | fabContainer.getLocationOnScreen(fabConPos);
286 |
287 | int xDelta = xDest - fabPos.x;
288 | final int yDelta = toolbarPos.y - fabConPos[1];
289 |
290 | ObjectAnimator xAnim = ObjectAnimator.ofFloat(fab, "translationX", fab.getTranslationX(), fab.getTranslationX() + xDelta);
291 | ObjectAnimator yAnim = ObjectAnimator.ofFloat(fabContainer, "translationY", fabContainer.getTranslationY(), fabContainer.getTranslationY() + yDelta);
292 |
293 | xAnim.setInterpolator(new AccelerateInterpolator());
294 | yAnim.setInterpolator(new DecelerateInterpolator(3f));
295 |
296 | xAnim.setDuration(SHOW_ANIM_DURATION / 2);
297 | yAnim.setDuration(SHOW_ANIM_DURATION / 2);
298 |
299 | animators.add(xAnim);
300 | animators.add(yAnim);
301 |
302 |
303 | // DRAWABLE ANIM
304 | if (fabDrawable != null && fabDrawableAnimationEnabled) {
305 | fabDrawable.startTransition(SHOW_ANIM_DURATION / 3);
306 | }
307 | if(!fabDrawableAnimationEnabled) {
308 | fab.setImageDrawable(null);
309 | }
310 |
311 |
312 | // SIZE ANIM
313 | // real size is 55x55 instead of 84x98
314 | final int startRadius = fabSize.x / 2;
315 | int finalRadius = (int)(Math.sqrt(Math.pow(toolbarSize.x, 2) + Math.pow(toolbarSize.y, 2))/2);
316 | int realRadius = (int)(98f * finalRadius / 55f);
317 | final ValueAnimator sizeAnim = ValueAnimator.ofFloat(startRadius, realRadius);
318 | sizeAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
319 | @Override
320 | public void onAnimationUpdate(ValueAnimator valueAnimator) {
321 | float valFloat = (Float) valueAnimator.getAnimatedValue();
322 |
323 | fab.setScaleX(valFloat / startRadius);
324 | fab.setScaleY(valFloat / startRadius);
325 | }
326 | });
327 | sizeAnim.setDuration(SHOW_ANIM_DURATION / 2);
328 | sizeAnim.setStartDelay(SHOW_ANIM_DURATION / 4);
329 |
330 | animators.add(sizeAnim);
331 |
332 |
333 | // EXPAND AND SHOW MENU ANIM
334 | ViewGroup toolbarLayoutViewGroup = (ViewGroup) toolbarLayout;
335 | List expandAnim = ExpandAnimationUtils.build(toolbarLayoutViewGroup, pivotX != -1 ? pivotX : toolbarLayout.getWidth() / 2, pivotY != -1 ? pivotY : toolbarLayout.getHeight() / 2, fraction, SHOW_ANIM_DURATION / 3, 2 * SHOW_ANIM_DURATION / 3);
336 |
337 | animators.addAll(expandAnim);
338 |
339 |
340 | // PLAY SHOW ANIMATION
341 | final AnimatorSet animatorSet = new AnimatorSet();
342 | animatorSet.playTogether(animators);
343 | animatorSet.addListener(new AnimatorListenerAdapter() {
344 | @Override
345 | public void onAnimationEnd(Animator animation) {
346 | isToolbar = true;
347 | }
348 | });
349 |
350 | animatorSet.start();
351 | }
352 |
353 | public void hide() {
354 | //TODO better handling of fast clicks
355 | if(!isToolbar) {
356 | return;
357 | }
358 | isToolbar = false;
359 |
360 | int[] fabP = new int[2];
361 | fab.getLocationOnScreen(fabP);
362 | Point tempFABPos = new Point();
363 | tempFABPos.set(fabP[0], fabP[1]);
364 |
365 | List reverseAnimators = new ArrayList<>();
366 |
367 |
368 | // REVERSE TRANSLATION ANIM
369 | int xSource = toolbarPos.x + (toolbarSize.x - originalFABSize) / 2;
370 | int distanceVertical = (toolbarSize.y - fab.getHeight())/2;
371 | int verticalMarginToSet = VERTICAL_MARGIN - distanceVertical;
372 | int yDest = toolbarPos.y - verticalMarginToSet;
373 |
374 | int[] fabConPos = new int[2];
375 | fabContainer.getLocationOnScreen(fabConPos);
376 |
377 | int xDelta = fabPos.x - xSource;
378 | final int yDelta = yDest - fabConPos[1];
379 |
380 | ObjectAnimator xAnimR = ObjectAnimator.ofFloat(fab, "translationX", fab.getTranslationX(), fab.getTranslationX() + xDelta);
381 | ObjectAnimator yAnimR = ObjectAnimator.ofFloat(fabContainer, "translationY", fabContainer.getTranslationY(), fabContainer.getTranslationY() + yDelta);
382 |
383 | xAnimR.setInterpolator(new DecelerateInterpolator());
384 | yAnimR.setInterpolator(new AccelerateInterpolator());
385 |
386 | xAnimR.setDuration(HIDE_ANIM_DURATION / 2);
387 | yAnimR.setDuration(HIDE_ANIM_DURATION / 2);
388 |
389 | xAnimR.setStartDelay(HIDE_ANIM_DURATION / 2);
390 | yAnimR.setStartDelay(HIDE_ANIM_DURATION / 2);
391 |
392 | reverseAnimators.add(xAnimR);
393 | reverseAnimators.add(yAnimR);
394 |
395 | // REVERSE DRAWABLE ANIM
396 | ValueAnimator drawableAnimR = ValueAnimator.ofFloat(0, 0);
397 |
398 | drawableAnimR.setDuration(2* HIDE_ANIM_DURATION /3);
399 | drawableAnimR.addListener(new AnimatorListenerAdapter() {
400 | @Override
401 | public void onAnimationEnd(Animator animation) {
402 | if(fabDrawableAnimationEnabled) {
403 | fabDrawable.reverseTransition(HIDE_ANIM_DURATION / 3);
404 | } else {
405 | fab.setImageDrawable(fabNormalDrawable);
406 | }
407 | }
408 | });
409 |
410 | reverseAnimators.add(drawableAnimR);
411 |
412 |
413 | // REVERSE SIZE ANIM
414 | // real size is 55x55 instead of 84x98
415 | final int startRadius = originalToolbarSize / 2;
416 | int finalRadius = (int)(Math.sqrt(Math.pow(toolbarSize.x, 2) + Math.pow(toolbarSize.y, 2))/2);
417 | int realRadius = (int)(98f * finalRadius / 55f);
418 | final ValueAnimator sizeAnimR = ValueAnimator.ofFloat(realRadius, startRadius);
419 | sizeAnimR.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
420 | @Override
421 | public void onAnimationUpdate(ValueAnimator valueAnimator) {
422 | float valFloat = (Float) valueAnimator.getAnimatedValue();
423 |
424 | fab.setScaleX(valFloat / startRadius);
425 | fab.setScaleY(valFloat / startRadius);
426 | }
427 | });
428 | sizeAnimR.setDuration(HIDE_ANIM_DURATION / 2);
429 | sizeAnimR.setStartDelay(HIDE_ANIM_DURATION / 4);
430 |
431 | reverseAnimators.add(sizeAnimR);
432 |
433 |
434 | // REVERSE EXPAND AND SHOW MENU ANIM
435 | ViewGroup toolbarLayoutViewGroup = (ViewGroup) toolbarLayout;
436 | List expandAnimR = ExpandAnimationUtils.buildReversed(toolbarLayoutViewGroup, pivotX != -1 ? pivotX : toolbarLayout.getWidth()/2, pivotY != -1 ? pivotY : toolbarLayout.getHeight()/2, fraction, HIDE_ANIM_DURATION /3, 0);
437 |
438 | reverseAnimators.addAll(expandAnimR);
439 |
440 |
441 | // PLAY SHOW ANIMATION
442 | final AnimatorSet animatorSet = new AnimatorSet();
443 | animatorSet.playTogether(reverseAnimators);
444 | animatorSet.addListener(new AnimatorListenerAdapter() {
445 | @Override
446 | public void onAnimationEnd(Animator animation) {
447 | isFab = true;
448 |
449 | setClipChildren(false);
450 | }
451 | });
452 |
453 | animatorSet.start();
454 | }
455 |
456 | public boolean isFab() {
457 | return isFab;
458 | }
459 |
460 | public boolean isToolbar() {
461 | return isToolbar;
462 | }
463 |
464 | public boolean isFabDrawableAnimationEnabled() {
465 | return fabDrawableAnimationEnabled;
466 | }
467 |
468 | public void setFabDrawableAnimationEnabled(boolean fabDrawableAnimationEnabled) {
469 | this.fabDrawableAnimationEnabled = fabDrawableAnimationEnabled;
470 | }
471 | }
472 |
--------------------------------------------------------------------------------
/FABToolbar/library/src/main/res/drawable/empty_drawable.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
--------------------------------------------------------------------------------
/FABToolbar/library/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | fab-toolbar
3 |
4 |
--------------------------------------------------------------------------------
/FABToolbar/library/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/FABToolbar/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':library'
2 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Rafał Tułaza
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | FABToolbar
2 | ================
3 |
4 | [](https://maven-badges.herokuapp.com/maven-central/com.github.fafaldo/fab-toolbar) [](https://android-arsenal.com/details/1/2592)
5 |
6 | An implementation of Google design, with Floating Action Button transforming into toolbar.
7 |
8 | 
9 |
10 |
11 | Features:
12 | --------------
13 |
14 | - morphing Floating Action Button (or any other view that extends ImageView) into custom toolbar
15 | - FAB image fade-out animation
16 | - toolbar elements fade-in animation
17 | - toolbar elements translation animation
18 |
19 |
20 | How to use
21 | ----------
22 |
23 | Import dependency using Gradle:
24 |
25 | ```
26 | compile 'com.github.fafaldo:fab-toolbar:1.2.0'
27 | ```
28 |
29 |
30 | In order to use FABToolbar you need to implement following view hierarchy in your XML layout file:
31 |
32 | ```
33 | |
34 | |->FABToolbarLayout
35 | |
36 | |-> Some container (that is, or extends RelativeLayout)
37 | | |
38 | | |-> Your FAB (or other view that extends ImageView)
39 | |
40 | |-> Your Toolbar (view that extends ViewGroup)
41 | |
42 | |-> Your elements
43 | ...
44 | ```
45 |
46 | Starting from version 1.1.0 views do NOT have to be assigned a static ID. Instead try referencing them in XML attributes in FABToolbarLayout, as shown below.
47 |
48 | Example implementation:
49 |
50 | ```xml
51 |
63 |
64 | ...
65 |
66 |
72 |
73 |
79 |
80 |
81 |
82 |
88 |
89 |
96 | ...
97 |
98 |
99 |
100 |
101 | ```
102 |
103 | To open toolbar call method
104 | ```
105 | show();
106 | ```
107 |
108 | To close toolbar call method
109 | ```
110 | hide();
111 | ```
112 |
113 | In case of other problems with implementation see example included in this repository.
114 |
115 |
116 | Parameters:
117 | -----
118 |
119 | You can control these parameters via XML:
120 |
121 | ```
122 | //show animation duration (in ms), default: 600 ms
123 | //hide animation duration (in ms), default: 600 ms
124 | //FAB vertical margin (in dp), default: 100 px
125 | //FAB horizontal margin (in dp), default: 100 px
126 | //toolbar elements translation animation pivot X (in dp), default: 1/2 toolbar width
127 | //toolbar elements translation animation pivot Y (in dp), default: 1/2 toolbar height
128 | //percent of translation animation, between element position and pivot point (float 0.0-1.0), default: 0.2
129 | //reference to the FAB view
130 | //reference to the FAB container view
131 | //reference to the FAB toolbar view
132 | //enable or disable FAB cross-fade animation, default: true
133 | ```
134 |
135 |
136 | Changelog
137 | ---------
138 |
139 | * 1.2.0 - most of the issues reported by users fixed - toolbar shadow, wrap_content height, side alignment, OnClickListener etc.
140 | * 1.1.0 - view id constraints removed, removed container layout, fixed FAB shadow problems
141 | * 1.0 - initial release
142 |
143 |
144 | License
145 | ----
146 |
147 | FABToolbar for Android
148 |
149 | The MIT License (MIT)
150 |
151 | Copyright (c) 2015 Rafał Tułaza
152 |
153 | Permission is hereby granted, free of charge, to any person obtaining a copy
154 | of this software and associated documentation files (the "Software"), to deal
155 | in the Software without restriction, including without limitation the rights
156 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
157 | copies of the Software, and to permit persons to whom the Software is
158 | furnished to do so, subject to the following conditions:
159 |
160 | The above copyright notice and this permission notice shall be included in all
161 | copies or substantial portions of the Software.
162 |
163 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
164 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
165 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
166 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
167 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
168 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
169 | SOFTWARE.
--------------------------------------------------------------------------------
/fabtoolbar.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fafaldo-zz/FABToolbar/bc39a912d214eb8ba399b3610809eed10ce2d098/fabtoolbar.gif
--------------------------------------------------------------------------------