├── demo
├── .gitignore
├── src
│ └── main
│ │ ├── res
│ │ ├── drawable-hdpi
│ │ │ ├── content.png
│ │ │ ├── ic_menu.png
│ │ │ ├── ic_close.png
│ │ │ └── ic_search.png
│ │ ├── drawable-mdpi
│ │ │ ├── content.png
│ │ │ ├── ic_menu.png
│ │ │ ├── ic_close.png
│ │ │ └── ic_search.png
│ │ ├── drawable-xhdpi
│ │ │ ├── content.png
│ │ │ ├── ic_close.png
│ │ │ ├── ic_menu.png
│ │ │ └── ic_search.png
│ │ ├── drawable-xxhdpi
│ │ │ ├── content.png
│ │ │ ├── ic_close.png
│ │ │ ├── ic_menu.png
│ │ │ └── ic_search.png
│ │ ├── drawable-xxxhdpi
│ │ │ ├── content.png
│ │ │ ├── ic_menu.png
│ │ │ ├── ic_close.png
│ │ │ └── ic_search.png
│ │ ├── 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
│ │ │ ├── strings.xml
│ │ │ ├── dimens.xml
│ │ │ ├── colors.xml
│ │ │ └── styles.xml
│ │ ├── layout
│ │ │ ├── edit_text.xml
│ │ │ └── activity_main.xml
│ │ └── values-w820dp
│ │ │ └── dimens.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ └── com
│ │ └── yalantis
│ │ └── jellyanimation
│ │ └── demo
│ │ └── MainActivity.java
├── proguard-rules.pro
└── build.gradle
├── library
├── .gitignore
├── src
│ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── res
│ │ ├── values
│ │ │ ├── strings.xml
│ │ │ ├── dimens.xml
│ │ │ ├── styles.xml
│ │ │ └── attrs.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
│ │ └── layout
│ │ │ ├── jelly_toolbar.xml
│ │ │ └── layout_content.xml
│ │ └── java
│ │ └── com
│ │ └── yalantis
│ │ └── jellytoolbar
│ │ ├── Constant.kt
│ │ ├── widget
│ │ ├── JellyWidget.kt
│ │ ├── ContentLayout.kt
│ │ ├── JellyToolbar.kt
│ │ └── JellyView.kt
│ │ ├── extensions.kt
│ │ ├── interpolator
│ │ ├── JellyInterpolator.kt
│ │ └── BounceInterpolator.kt
│ │ └── listener
│ │ ├── JellyListener.kt
│ │ └── AnimationListener.kt
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── gif.gif
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── gradlew.bat
├── README.md
└── gradlew
/demo/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/library/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':library', ':demo'
2 |
--------------------------------------------------------------------------------
/gif.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/JellyToolbar/develop/gif.gif
--------------------------------------------------------------------------------
/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/library/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | JellyToolbar
3 |
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/JellyToolbar/develop/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-hdpi/content.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/JellyToolbar/develop/demo/src/main/res/drawable-hdpi/content.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-hdpi/ic_menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/JellyToolbar/develop/demo/src/main/res/drawable-hdpi/ic_menu.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-mdpi/content.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/JellyToolbar/develop/demo/src/main/res/drawable-mdpi/content.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-mdpi/ic_menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/JellyToolbar/develop/demo/src/main/res/drawable-mdpi/ic_menu.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-hdpi/ic_close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/JellyToolbar/develop/demo/src/main/res/drawable-hdpi/ic_close.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-hdpi/ic_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/JellyToolbar/develop/demo/src/main/res/drawable-hdpi/ic_search.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-mdpi/ic_close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/JellyToolbar/develop/demo/src/main/res/drawable-mdpi/ic_close.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-mdpi/ic_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/JellyToolbar/develop/demo/src/main/res/drawable-mdpi/ic_search.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/content.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/JellyToolbar/develop/demo/src/main/res/drawable-xhdpi/content.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/ic_close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/JellyToolbar/develop/demo/src/main/res/drawable-xhdpi/ic_close.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/ic_menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/JellyToolbar/develop/demo/src/main/res/drawable-xhdpi/ic_menu.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/ic_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/JellyToolbar/develop/demo/src/main/res/drawable-xhdpi/ic_search.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xxhdpi/content.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/JellyToolbar/develop/demo/src/main/res/drawable-xxhdpi/content.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xxhdpi/ic_close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/JellyToolbar/develop/demo/src/main/res/drawable-xxhdpi/ic_close.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xxhdpi/ic_menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/JellyToolbar/develop/demo/src/main/res/drawable-xxhdpi/ic_menu.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xxxhdpi/content.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/JellyToolbar/develop/demo/src/main/res/drawable-xxxhdpi/content.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xxxhdpi/ic_menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/JellyToolbar/develop/demo/src/main/res/drawable-xxxhdpi/ic_menu.png
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/JellyToolbar/develop/demo/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/JellyToolbar/develop/demo/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/JellyToolbar/develop/demo/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xxhdpi/ic_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/JellyToolbar/develop/demo/src/main/res/drawable-xxhdpi/ic_search.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xxxhdpi/ic_close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/JellyToolbar/develop/demo/src/main/res/drawable-xxxhdpi/ic_close.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xxxhdpi/ic_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/JellyToolbar/develop/demo/src/main/res/drawable-xxxhdpi/ic_search.png
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/JellyToolbar/develop/demo/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/JellyToolbar/develop/demo/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/library/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/JellyToolbar/develop/library/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/library/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/JellyToolbar/develop/library/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/library/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/JellyToolbar/develop/library/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/library/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/JellyToolbar/develop/library/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/library/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/JellyToolbar/develop/library/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/demo/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | JellyToolbar
3 | News feed
4 |
5 |
--------------------------------------------------------------------------------
/library/src/main/java/com/yalantis/jellytoolbar/Constant.kt:
--------------------------------------------------------------------------------
1 | package com.yalantis.jellytoolbar
2 |
3 | /**
4 | * Created by irinagalata on 11/24/16.
5 | */
6 | object Constant {
7 |
8 | const val ANIMATION_DURATION = 1100L
9 |
10 | }
--------------------------------------------------------------------------------
/demo/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 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.14.1-all.zip
7 |
--------------------------------------------------------------------------------
/library/src/main/java/com/yalantis/jellytoolbar/widget/JellyWidget.kt:
--------------------------------------------------------------------------------
1 | package com.yalantis.jellytoolbar.widget
2 |
3 | /**
4 | * Created by irinagalata on 11/23/16.
5 | */
6 | interface JellyWidget {
7 |
8 | fun collapse()
9 |
10 | fun expand()
11 |
12 | fun init() {}
13 |
14 | fun expandImmediately()
15 |
16 | }
--------------------------------------------------------------------------------
/library/src/main/java/com/yalantis/jellytoolbar/extensions.kt:
--------------------------------------------------------------------------------
1 | package com.yalantis.jellytoolbar
2 |
3 | import android.support.annotation.DimenRes
4 | import android.view.View
5 |
6 | /**
7 | * Created by irinagalata on 11/23/16.
8 | */
9 |
10 | fun View.getDimen(@DimenRes res: Int) = context.resources.getDimensionPixelOffset(res).toFloat()
--------------------------------------------------------------------------------
/demo/src/main/res/layout/edit_text.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/library/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 120dp
4 | 3dp
5 | 32dp
6 | 64dp
7 | 56dp
8 | 16dp
9 |
--------------------------------------------------------------------------------
/library/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/demo/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/demo/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #7e6fe2
4 | #8a53cf
5 | #FF4081
6 | #00ffffff
7 | #cb5ed9
8 | #8463d4
9 |
10 |
--------------------------------------------------------------------------------
/library/src/main/java/com/yalantis/jellytoolbar/interpolator/JellyInterpolator.kt:
--------------------------------------------------------------------------------
1 | package com.yalantis.jellytoolbar.interpolator
2 |
3 | import android.view.animation.Interpolator
4 |
5 | /**
6 | * Created by irinagalata on 11/8/16.
7 | */
8 | class JellyInterpolator : Interpolator {
9 |
10 | override fun getInterpolation(t: Float) = (Math.min(1.0, Math.sin(28 * t - 6.16) / (5 * t - 1.1))).toFloat()
11 |
12 | }
--------------------------------------------------------------------------------
/library/src/main/java/com/yalantis/jellytoolbar/listener/JellyListener.kt:
--------------------------------------------------------------------------------
1 | package com.yalantis.jellytoolbar.listener
2 |
3 | /**
4 | * Created by irinagalata on 11/25/16.
5 | */
6 | abstract class JellyListener {
7 |
8 | open fun onToolbarExpandingStarted() = Unit
9 |
10 | open fun onToolbarCollapsingStarted() = Unit
11 |
12 | open fun onToolbarExpanded() = Unit
13 |
14 | open fun onToolbarCollapsed() = Unit
15 |
16 | abstract fun onCancelIconClicked()
17 |
18 | }
--------------------------------------------------------------------------------
/library/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/library/src/main/java/com/yalantis/jellytoolbar/listener/AnimationListener.kt:
--------------------------------------------------------------------------------
1 | package com.yalantis.jellytoolbar.listener
2 |
3 | import android.animation.Animator
4 |
5 | /**
6 | * Created by irinagalata on 11/8/16.
7 | */
8 | abstract class AnimationListener : Animator.AnimatorListener {
9 |
10 | override fun onAnimationRepeat(animation: Animator?) = Unit
11 |
12 | override fun onAnimationStart(animation: Animator?) = Unit
13 |
14 | override fun onAnimationCancel(animation: Animator?) = Unit
15 |
16 | override abstract fun onAnimationEnd(animation: Animator?)
17 |
18 | }
--------------------------------------------------------------------------------
/demo/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/demo/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 /Users/irinagalata/Library/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/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 /Users/irinagalata/Library/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 |
--------------------------------------------------------------------------------
/demo/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/jelly_toolbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
15 |
16 |
21 |
22 |
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 |
5 | android {
6 | compileSdkVersion 24
7 | buildToolsVersion '25.0.2'
8 | defaultConfig {
9 | minSdkVersion 16
10 | targetSdkVersion 24
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 | sourceSets {
21 | main.java.srcDirs += 'src/main/kotlin'
22 | }
23 | }
24 |
25 | dependencies {
26 | compile fileTree(dir: 'libs', include: ['*.jar'])
27 | compile 'com.android.support:appcompat-v7:24.2.1'
28 | compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
29 | }
30 | repositories {
31 | mavenCentral()
32 | }
33 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | RELEASE_STORE_FILE=keys/release.jks
15 | RELEASE_KEYSTORE_PASSWORD=jellytoolbar
16 | RELEASE_KEY_ALIAS_NAME=android
17 | RELEASE_KEY_ALIAS_PASSWORD=jellytoolbar
--------------------------------------------------------------------------------
/library/src/main/java/com/yalantis/jellytoolbar/interpolator/BounceInterpolator.kt:
--------------------------------------------------------------------------------
1 | package com.yalantis.jellytoolbar.interpolator
2 |
3 | import android.view.animation.Interpolator
4 |
5 | /**
6 | * Created by irinagalata on 11/23/16.
7 | */
8 | class BounceInterpolator : Interpolator {
9 | val MOVE_TIME = 0.46667f
10 | val FIRST_BOUNCE_TIME = 0.26666f
11 |
12 | override fun getInterpolation(t: Float): Float = when {
13 | t < MOVE_TIME ->
14 | move(t)
15 | t < MOVE_TIME + FIRST_BOUNCE_TIME ->
16 | firstBounce(t)
17 | else ->
18 | secondBounce(t)
19 | }
20 |
21 | private fun move(t: Float): Float {
22 | return 4.592f * t * t
23 | }
24 |
25 | private fun firstBounce(t: Float): Float {
26 | return 2.5f * t * t - 3f * t + 1.85556f
27 | }
28 |
29 | private fun secondBounce(t: Float): Float {
30 | return 0.625f * t * t - 1.083f * t + 1.458f
31 | }
32 |
33 | }
--------------------------------------------------------------------------------
/demo/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 24
5 | buildToolsVersion '25.0.2'
6 |
7 | defaultConfig {
8 | applicationId "com.yalantis.jellyanimation.demo"
9 | minSdkVersion 16
10 | targetSdkVersion 24
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | }
15 | signingConfigs {
16 | release {
17 | storeFile file(RELEASE_STORE_FILE)
18 | storePassword RELEASE_KEYSTORE_PASSWORD
19 | keyAlias RELEASE_KEY_ALIAS_NAME
20 | keyPassword RELEASE_KEY_ALIAS_PASSWORD
21 | }
22 | }
23 | buildTypes {
24 | release {
25 | minifyEnabled false
26 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
27 | signingConfig signingConfigs.release
28 | }
29 | }
30 | }
31 |
32 | dependencies {
33 | compile fileTree(include: ['*.jar'], dir: 'libs')
34 | compile 'com.android.support:appcompat-v7:24.2.1'
35 | compile project(':library')
36 | }
37 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/layout_content.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
12 |
17 |
18 |
29 |
30 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
19 |
20 |
23 |
24 |
28 |
29 |
34 |
35 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/demo/src/main/java/com/yalantis/jellyanimation/demo/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.yalantis.jellyanimation.demo;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.support.v7.widget.AppCompatEditText;
6 | import android.text.TextUtils;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 |
10 | import com.yalantis.jellytoolbar.listener.JellyListener;
11 | import com.yalantis.jellytoolbar.widget.JellyToolbar;
12 |
13 | public class MainActivity extends AppCompatActivity {
14 |
15 | private static final String TEXT_KEY = "text";
16 |
17 | private JellyToolbar toolbar;
18 | private AppCompatEditText editText;
19 | private JellyListener jellyListener = new JellyListener() {
20 | @Override
21 | public void onCancelIconClicked() {
22 | if (TextUtils.isEmpty(editText.getText())) {
23 | toolbar.collapse();
24 | } else {
25 | editText.getText().clear();
26 | }
27 | }
28 | };
29 |
30 | @Override
31 | protected void onCreate(Bundle savedInstanceState) {
32 | super.onCreate(savedInstanceState);
33 | setContentView(R.layout.activity_main);
34 |
35 | toolbar = (JellyToolbar) findViewById(R.id.toolbar);
36 | toolbar.getToolbar().setNavigationIcon(R.drawable.ic_menu);
37 | toolbar.setJellyListener(jellyListener);
38 | toolbar.getToolbar().setPadding(0, getStatusBarHeight(), 0, 0);
39 |
40 | editText = (AppCompatEditText) LayoutInflater.from(this).inflate(R.layout.edit_text, null);
41 | editText.setBackgroundResource(R.color.colorTransparent);
42 | toolbar.setContentView(editText);
43 |
44 | getWindow().getDecorView().setSystemUiVisibility(
45 | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
46 | | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
47 | }
48 |
49 | private int getStatusBarHeight() {
50 | int result = 0;
51 | int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
52 | if (resourceId > 0) {
53 | result = getResources().getDimensionPixelSize(resourceId);
54 | }
55 | return result;
56 | }
57 |
58 | @Override
59 | protected void onSaveInstanceState(Bundle outState) {
60 | outState.putString(TEXT_KEY, editText.getText().toString());
61 | super.onSaveInstanceState(outState);
62 | }
63 |
64 | @Override
65 | protected void onRestoreInstanceState(Bundle savedInstanceState) {
66 | super.onRestoreInstanceState(savedInstanceState);
67 | editText.setText(savedInstanceState.getString(TEXT_KEY));
68 | editText.setSelection(editText.getText().length());
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/library/src/main/java/com/yalantis/jellytoolbar/widget/ContentLayout.kt:
--------------------------------------------------------------------------------
1 | package com.yalantis.jellytoolbar.widget
2 |
3 | import android.animation.ValueAnimator
4 | import android.content.Context
5 | import android.support.annotation.DrawableRes
6 | import android.util.AttributeSet
7 | import android.view.LayoutInflater
8 | import android.view.View
9 | import android.widget.RelativeLayout
10 | import com.yalantis.jellytoolbar.Constant
11 | import com.yalantis.jellytoolbar.R
12 | import com.yalantis.jellytoolbar.getDimen
13 | import com.yalantis.jellytoolbar.interpolator.BounceInterpolator
14 | import kotlinx.android.synthetic.main.layout_content.view.*
15 |
16 | /**
17 | * Created by irinagalata on 11/23/16.
18 | */
19 | class ContentLayout : RelativeLayout, JellyWidget {
20 |
21 | var contentView: View? = null
22 | set(value) {
23 | value?.let {
24 | container.removeAllViews()
25 | container.addView(it)
26 | field = value
27 | }
28 | }
29 | @DrawableRes var iconRes: Int? = null
30 | set(value) {
31 | value?.let {
32 | icon.setBackgroundResource(it)
33 | field = value
34 | }
35 | }
36 | @DrawableRes var cancelIconRes: Int? = null
37 | set(value) {
38 | value?.let {
39 | cancelIcon.setBackgroundResource(it)
40 | field = value
41 | }
42 | }
43 |
44 | internal var onIconClickListener: OnClickListener? = null
45 | set(value) {
46 | icon.setOnClickListener(value)
47 | field = value
48 | }
49 | internal var onCancelIconClickListener: OnClickListener? = null
50 | set(value) {
51 | cancelIcon.setOnClickListener(value)
52 | field = value
53 | }
54 |
55 | private var startPosition = 0f
56 | private var endPosition = 0f
57 | private var isInitialized = false
58 | private val iconFullSize = getDimen(R.dimen.icon_full_size)
59 | private val iconPadding = getDimen(R.dimen.icon_padding)
60 |
61 | constructor(context: Context?) : this(context, null)
62 | constructor(context: Context?, attrs: AttributeSet?) : this(context, attrs, 0)
63 | constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
64 | LayoutInflater.from(context).inflate(R.layout.layout_content, this)
65 | }
66 |
67 | override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {
68 | super.onLayout(changed, l, t, r, b)
69 |
70 | if (!isInitialized) {
71 | init()
72 | isInitialized = true
73 | }
74 | }
75 |
76 | override fun init() {
77 | translationX = width.toFloat() - iconFullSize
78 | startPosition = width.toFloat() - iconFullSize
79 | endPosition = -height.toFloat() + iconFullSize - iconPadding * 0.5f
80 | }
81 |
82 | override fun collapse() {
83 | ValueAnimator.ofFloat(endPosition, startPosition).apply {
84 | startDelay = 50
85 | translationX = endPosition
86 | duration = Constant.ANIMATION_DURATION / 3
87 | interpolator = BounceInterpolator()
88 | addUpdateListener {
89 | translationX = animatedValue as Float
90 | icon.alpha = 0.5f + 0.5f * animatedFraction
91 |
92 | with(cancelIcon) {
93 | rotation = 360 * animatedFraction
94 | scaleX = 1 - animatedFraction
95 | scaleY = 1 - animatedFraction
96 | alpha = 1 - animatedFraction
97 | translationX = endPosition - animatedValue as Float
98 | }
99 | }
100 | }.start()
101 | }
102 |
103 | override fun expand() {
104 | ValueAnimator.ofFloat(startPosition, endPosition).apply {
105 | startDelay = 50
106 | translationX = startPosition
107 | duration = Constant.ANIMATION_DURATION / 3
108 | interpolator = BounceInterpolator()
109 |
110 | with(cancelIcon) {
111 | translationX = 0f
112 | alpha = 1f
113 | scaleX = 1f
114 | scaleY = 1f
115 | }
116 | addUpdateListener {
117 | translationX = animatedValue as Float
118 | icon.alpha = 1f - 0.5f * animatedFraction
119 | }
120 | }.start()
121 | }
122 |
123 | override fun expandImmediately() {
124 | expand()
125 | }
126 |
127 | }
--------------------------------------------------------------------------------
/library/src/main/java/com/yalantis/jellytoolbar/widget/JellyToolbar.kt:
--------------------------------------------------------------------------------
1 | package com.yalantis.jellytoolbar.widget
2 |
3 | import android.content.Context
4 | import android.os.Bundle
5 | import android.os.Parcelable
6 | import android.support.annotation.ColorInt
7 | import android.support.annotation.DrawableRes
8 | import android.support.v7.widget.Toolbar
9 | import android.text.TextUtils
10 | import android.util.AttributeSet
11 | import android.view.LayoutInflater
12 | import android.view.View
13 | import android.widget.FrameLayout
14 | import com.yalantis.jellytoolbar.Constant
15 | import com.yalantis.jellytoolbar.R
16 | import com.yalantis.jellytoolbar.listener.JellyListener
17 | import kotlinx.android.synthetic.main.jelly_toolbar.view.*
18 |
19 | /**
20 | * Created by irinagalata on 11/23/16.
21 | */
22 | class JellyToolbar : FrameLayout, JellyWidget {
23 |
24 | companion object {
25 | private const val KEY_IS_EXPANDED = "key_is_expanded"
26 | private const val KEY_SUPER_STATE = "key_super_state"
27 | }
28 |
29 | var toolbar: Toolbar? = null
30 | private set
31 | get() {
32 | return defaultToolbar
33 | }
34 | var contentView: View? = null
35 | set(value) {
36 | contentLayout.contentView = value
37 | field = value
38 | }
39 | @DrawableRes var iconRes: Int? = null
40 | set(value) {
41 | contentLayout.iconRes = value
42 | field = value
43 | }
44 | @DrawableRes var cancelIconRes: Int? = null
45 | set(value) {
46 | contentLayout.cancelIconRes = value
47 | field = value
48 | }
49 | @ColorInt var startColor: Int? = null
50 | set(value) {
51 | value?.let {
52 | jellyView.startColor = value
53 | field = value
54 | }
55 | }
56 | @ColorInt var endColor: Int? = null
57 | set(value) {
58 | value?.let {
59 | jellyView.endColor = value
60 | field = value
61 | }
62 | }
63 | var jellyListener: JellyListener? = null
64 |
65 | private var isExpanded = false
66 |
67 | constructor(context: Context?) : this(context, null)
68 | constructor(context: Context?, attrs: AttributeSet?) : this(context, attrs, 0)
69 | constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
70 | LayoutInflater.from(context).inflate(R.layout.jelly_toolbar, this)
71 |
72 | attrs?.let { retrieveAttributes(attrs) }
73 |
74 | contentLayout.onIconClickListener = View.OnClickListener { expand() }
75 | contentLayout.onCancelIconClickListener = View.OnClickListener { jellyListener?.onCancelIconClicked() }
76 | }
77 |
78 | private fun retrieveAttributes(attrs: AttributeSet) {
79 | val typedArray = context.obtainStyledAttributes(attrs, R.styleable.JellyToolbar)
80 |
81 | val startColorAttr = typedArray.getColor(R.styleable.JellyToolbar_startColor, 0)
82 | if (startColorAttr != 0) startColor = startColorAttr
83 |
84 | val endColorAttr = typedArray.getColor(R.styleable.JellyToolbar_endColor, 0)
85 | if (endColorAttr != 0) endColor = endColorAttr
86 |
87 | val iconResAttr = typedArray.getResourceId(R.styleable.JellyToolbar_icon, 0)
88 | if (iconResAttr != 0) iconRes = iconResAttr
89 |
90 | val cancelIconResAttr = typedArray.getResourceId(R.styleable.JellyToolbar_cancelIcon, 0)
91 | if (cancelIconResAttr != 0) cancelIconRes = cancelIconResAttr
92 |
93 | val title = typedArray.getString(R.styleable.JellyToolbar_title)
94 | if (!TextUtils.isEmpty(title)) toolbar?.title = title
95 |
96 | val titleColor = typedArray.getColor(R.styleable.JellyToolbar_titleTextColor, 0)
97 | if (titleColor != 0) toolbar?.setTitleTextColor(titleColor)
98 |
99 | typedArray.recycle()
100 | }
101 |
102 | override fun collapse() {
103 | if (!isExpanded) return
104 |
105 | jellyView.collapse()
106 | contentLayout.collapse()
107 | isExpanded = false
108 | jellyListener?.onToolbarCollapsingStarted()
109 | postDelayed({ jellyListener?.onToolbarCollapsed() }, Constant.ANIMATION_DURATION)
110 | }
111 |
112 | override fun expand() {
113 | if (isExpanded) return
114 |
115 | jellyView.expand()
116 | contentLayout.expand()
117 | isExpanded = true
118 | jellyListener?.onToolbarExpandingStarted()
119 | postDelayed({ jellyListener?.onToolbarExpanded() }, Constant.ANIMATION_DURATION)
120 | }
121 |
122 | override fun onSaveInstanceState(): Parcelable {
123 | return Bundle().apply {
124 | putBoolean(KEY_IS_EXPANDED, isExpanded)
125 | putParcelable(KEY_SUPER_STATE, super.onSaveInstanceState())
126 | }
127 | }
128 |
129 | override fun onRestoreInstanceState(state: Parcelable?) {
130 | if (state is Bundle) {
131 | super.onRestoreInstanceState(state.getParcelable(KEY_SUPER_STATE))
132 | val isExpanded = state.getBoolean(KEY_IS_EXPANDED)
133 | init()
134 | if (isExpanded) {
135 | expandImmediately()
136 | }
137 | }
138 | }
139 |
140 | override fun expandImmediately() {
141 | if (isExpanded) return
142 |
143 | jellyView.expandImmediately()
144 | contentLayout.expandImmediately()
145 | isExpanded = true
146 | }
147 |
148 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # JellyToolbar
2 |
3 | []()
4 | [](https://jitpack.io/#yalantis/jellytoolbar)
5 | [](https://yalantis.com/?utm_source=github)
6 |
7 |
8 |
9 | Check this [project on dribbble](https://dribbble.com/shots/2092541-Search-Bar-Animation)
10 |
11 |
12 |
13 | ## Requirements
14 | - Android SDK 16+
15 |
16 | ## Usage
17 |
18 | Add to your root build.gradle:
19 | ```Groovy
20 | allprojects {
21 | repositories {
22 | ...
23 | maven { url "https://jitpack.io" }
24 | }
25 | }
26 | ```
27 |
28 | Add the dependency:
29 | ```Groovy
30 | dependencies {
31 | compile 'com.github.yalantis:jellytoolbar:v1.0'
32 | }
33 | ```
34 |
35 | ## How to use this library in your project?
36 |
37 | First of all, add `JellyToolbar` to the xml layout of your activity, so it looks like that:
38 |
39 | ```xml
40 |
41 |
46 |
47 |
60 |
61 |
62 | ```
63 |
64 |
65 | After that pass an instance of the `JellyListener` and content view
66 | (the view which would be inserted to the toolbar) to the `JellyToolbar`.
67 | `JellyToolbar` has `getToolbar()` method to let you use all the methods of the standard `Toolbar`.
68 |
69 |
70 | ```Java
71 | public class MainActivity extends AppCompatActivity {
72 |
73 | private JellyToolbar toolbar;
74 | private AppCompatEditText editText;
75 |
76 | @Override
77 | protected void onCreate(Bundle savedInstanceState) {
78 | super.onCreate(savedInstanceState);
79 | setContentView(R.layout.activity_main);
80 |
81 | toolbar = (JellyToolbar) findViewById(R.id.toolbar);
82 | toolbar.getToolbar().setNavigationIcon(R.drawable.ic_menu);
83 | toolbar.setJellyListener(jellyListener);
84 |
85 | editText = (AppCompatEditText) LayoutInflater.from(this).inflate(R.layout.edit_text, null);
86 | editText.setBackgroundResource(R.color.colorTransparent);
87 | toolbar.setContentView(editText);
88 | }
89 |
90 | private JellyListener jellyListener = new JellyListener() {
91 | @Override
92 | public void onCancelIconClicked() {
93 | if (TextUtils.isEmpty(editText.getText())) {
94 | toolbar.collapse();
95 | } else {
96 | editText.getText().clear();
97 | }
98 | }
99 | };
100 |
101 | }
102 | ```
103 |
104 | To control the animation flow use `collapse()` and `expand()` methods.
105 |
106 | Override `onToolbarExpandingStarted()`, `onToolbarCollapsingStarted()`, `onToolbarExpanded()` and `onToolbarCollapsed()`
107 | methods of the `JellyListener` to get all the animation events.
108 |
109 | ## Let us know!
110 |
111 | We’d be really happy if you sent us links to your projects where you use our component. Just send an email to github@yalantis.com And do let us know if you have any questions or suggestion regarding the animation.
112 |
113 | P.S. We’re going to publish more awesomeness wrapped in code and a tutorial on how to make UI for iOS (Android) better than better. Stay tuned!
114 |
115 | ## License
116 |
117 | The MIT License (MIT)
118 |
119 | Copyright © 2017 Yalantis, https://yalantis.com
120 |
121 | Permission is hereby granted, free of charge, to any person obtaining a copy
122 | of this software and associated documentation files (the "Software"), to deal
123 | in the Software without restriction, including without limitation the rights
124 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
125 | copies of the Software, and to permit persons to whom the Software is
126 | furnished to do so, subject to the following conditions:
127 |
128 | The above copyright notice and this permission notice shall be included in
129 | all copies or substantial portions of the Software.
130 |
131 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
132 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
133 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
134 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
135 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
136 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
137 | THE SOFTWARE.
138 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/library/src/main/java/com/yalantis/jellytoolbar/widget/JellyView.kt:
--------------------------------------------------------------------------------
1 | package com.yalantis.jellytoolbar.widget
2 |
3 | import android.animation.Animator
4 | import android.animation.ValueAnimator
5 | import android.content.Context
6 | import android.graphics.*
7 | import android.util.AttributeSet
8 | import android.view.View
9 | import android.view.animation.BounceInterpolator
10 | import android.widget.FrameLayout
11 | import com.yalantis.jellytoolbar.Constant
12 | import com.yalantis.jellytoolbar.R
13 | import com.yalantis.jellytoolbar.getDimen
14 | import com.yalantis.jellytoolbar.interpolator.JellyInterpolator
15 | import com.yalantis.jellytoolbar.listener.AnimationListener
16 |
17 | /**
18 | * Created by irinagalata on 11/15/16.
19 | */
20 | class JellyView : View, JellyWidget {
21 |
22 | var isExpanded = false
23 | var startColor: Int = android.R.color.transparent
24 | var endColor: Int = android.R.color.transparent
25 |
26 | private var isInitialized = false
27 | private var difference = 0f
28 | private var startPosition = 0f
29 | private var endPosition = 0f
30 | private val paint = Paint()
31 | private val path = Path()
32 | private var gradient: LinearGradient? = null
33 | private val jellyViewSize = getDimen(R.dimen.jelly_view_size)
34 | private val jellyViewWidth = getDimen(R.dimen.jelly_view_width)
35 | private val jellyViewOffset = getDimen(R.dimen.jelly_view_offset)
36 |
37 | constructor(context: Context?) : this(context, null)
38 | constructor(context: Context?, attrs: AttributeSet?) : this(context, attrs, 0)
39 | constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
40 |
41 | override fun onDraw(canvas: Canvas?) {
42 | super.onDraw(canvas)
43 |
44 | if (!isInitialized) {
45 | init()
46 | }
47 | redraw(canvas)
48 | }
49 |
50 | override fun init() {
51 | layoutParams = FrameLayout.LayoutParams(width + jellyViewWidth.toInt() * 2, height)
52 | translationX = width - jellyViewSize
53 | startPosition = translationX
54 | endPosition = -jellyViewWidth
55 | isInitialized = true
56 | gradient = createGradient()
57 | }
58 |
59 | private fun redraw(canvas: Canvas?) {
60 | paint.shader = gradient
61 | path.apply {
62 | moveTo(jellyViewWidth, 0f)
63 | lineTo(width.toFloat(), 0f)
64 | lineTo(width.toFloat(), height.toFloat())
65 | lineTo(jellyViewWidth, height.toFloat())
66 | quadTo(jellyViewWidth - difference, height / 2f, jellyViewWidth, 0f)
67 | }
68 | canvas?.drawPath(path, paint)
69 | path.reset()
70 | path.close()
71 | }
72 |
73 | private fun createGradient(): LinearGradient? {
74 | return LinearGradient(0f, 0f, width.toFloat(), 0f, startColor,
75 | endColor,
76 | Shader.TileMode.CLAMP)
77 | }
78 |
79 | override fun collapse() {
80 | isExpanded = false
81 | animateJellyCollapsing()
82 | moveBack()
83 | }
84 |
85 | override fun expand() {
86 | isExpanded = true
87 | animateJellyExpanding()
88 | moveForward(true)
89 | }
90 |
91 | override fun expandImmediately() {
92 | isExpanded = true
93 |
94 | animateJelly(1, true, 0)
95 | translationX = width - jellyViewSize
96 | startPosition = translationX
97 | endPosition = -jellyViewWidth
98 | moveForward(false)
99 | }
100 |
101 | private fun animateJellyExpanding() {
102 | animateJelly(1, true, Constant.ANIMATION_DURATION)
103 | }
104 |
105 | private fun animateJellyCollapsing() {
106 | animateJelly(-1, false, Constant.ANIMATION_DURATION)
107 | }
108 |
109 | private fun animateJelly(coefficient: Int, moveOffset: Boolean, animDuration: Long) {
110 | ValueAnimator.ofFloat(0f, jellyViewWidth / 2).apply {
111 | duration = animDuration
112 | interpolator = JellyInterpolator()
113 | addUpdateListener {
114 | difference = animatedValue as Float * coefficient
115 | invalidate()
116 | }
117 | addListener(object : AnimationListener() {
118 | override fun onAnimationEnd(animation: Animator?) {
119 | difference = 0f
120 | invalidate()
121 |
122 | if (moveOffset && isExpanded) {
123 | moveOffset()
124 | }
125 | }
126 | })
127 | }.start()
128 | }
129 |
130 | private fun moveOffset() {
131 | ValueAnimator.ofFloat(0f, jellyViewOffset).apply {
132 | duration = 150
133 | interpolator = BounceInterpolator()
134 | addUpdateListener {
135 | translationX -= animatedValue as Float
136 | }
137 | }.start()
138 | }
139 |
140 | private fun moveForward(offset: Boolean) {
141 | var endPosition = endPosition
142 | if (offset) endPosition += jellyViewOffset
143 | ValueAnimator.ofFloat(startPosition, endPosition).apply {
144 | translationX = startPosition
145 | duration = Constant.ANIMATION_DURATION / 3
146 | addUpdateListener {
147 | translationX = animatedValue as Float
148 | }
149 | }.start()
150 | }
151 |
152 | private fun moveBack() {
153 | ValueAnimator.ofFloat(endPosition, startPosition).apply {
154 | translationX = endPosition
155 | duration = Constant.ANIMATION_DURATION / 3
156 | addUpdateListener {
157 | translationX = animatedValue as Float
158 | }
159 | }.start()
160 | }
161 |
162 | }
--------------------------------------------------------------------------------