├── .gitignore ├── LICENSE ├── README.md ├── art ├── transform_to_player.gif ├── transform_to_sheet.gif └── transform_to_toolbar.gif ├── build.gradle ├── example ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── konifar │ │ └── example │ │ └── fabtransformation │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── konifar │ │ └── example │ │ └── fabtransformation │ │ ├── AppUtil.java │ │ ├── BaseActivity.java │ │ ├── MainActivity.java │ │ ├── TransformToPlayerActivity.java │ │ ├── TransformToSheetActivity.java │ │ ├── TransformToToolbarActivity.java │ │ ├── adapters │ │ ├── BaseArrayAdapter.java │ │ └── MenuArrayAdapter.java │ │ └── models │ │ └── SampleMenu.java │ └── res │ ├── anim │ ├── activity_scale_finish_enter.xml │ ├── activity_scale_start_exit.xml │ ├── activity_slide_finish_exit.xml │ └── activity_slide_start_enter.xml │ ├── drawable-hdpi │ ├── ic_account_balance_white_24dp.png │ ├── ic_add_black_24dp.png │ ├── ic_content_copy_white_24dp.png │ ├── ic_edit_grey_900_24dp.png │ ├── ic_email_white_24dp.png │ ├── ic_folder_shared_white_24dp.png │ ├── ic_location_on_white_24dp.png │ ├── ic_play_arrow_white_24dp.png │ └── ic_share_white_24dp.png │ ├── drawable-mdpi │ ├── ic_account_balance_white_24dp.png │ ├── ic_add_black_24dp.png │ ├── ic_content_copy_white_24dp.png │ ├── ic_edit_grey_900_24dp.png │ ├── ic_email_white_24dp.png │ ├── ic_folder_shared_white_24dp.png │ ├── ic_location_on_white_24dp.png │ ├── ic_play_arrow_white_24dp.png │ └── ic_share_white_24dp.png │ ├── drawable-nodpi │ ├── img_dora.jpg │ ├── img_thumb_player.png │ ├── img_thumb_sheet.png │ └── img_thumb_toolbar.png │ ├── drawable-xhdpi │ ├── ic_account_balance_white_24dp.png │ ├── ic_add_black_24dp.png │ ├── ic_content_copy_white_24dp.png │ ├── ic_edit_grey_900_24dp.png │ ├── ic_email_white_24dp.png │ ├── ic_folder_shared_white_24dp.png │ ├── ic_location_on_white_24dp.png │ ├── ic_play_arrow_white_24dp.png │ └── ic_share_white_24dp.png │ ├── drawable-xxhdpi │ ├── ic_account_balance_white_24dp.png │ ├── ic_add_black_24dp.png │ ├── ic_content_copy_white_24dp.png │ ├── ic_edit_grey_900_24dp.png │ ├── ic_email_white_24dp.png │ ├── ic_folder_shared_white_24dp.png │ ├── ic_location_on_white_24dp.png │ ├── ic_play_arrow_white_24dp.png │ └── ic_share_white_24dp.png │ ├── drawable-xxxhdpi │ ├── ic_account_balance_white_24dp.png │ ├── ic_add_black_24dp.png │ ├── ic_content_copy_white_24dp.png │ ├── ic_edit_grey_900_24dp.png │ ├── ic_email_white_24dp.png │ ├── ic_folder_shared_white_24dp.png │ ├── ic_location_on_white_24dp.png │ ├── ic_play_arrow_white_24dp.png │ └── ic_share_white_24dp.png │ ├── drawable │ └── bg_feedback.xml │ ├── layout │ ├── activity_main.xml │ ├── activity_transform_to_player.xml │ ├── activity_transform_to_sheet.xml │ ├── activity_transform_to_toolbar.xml │ ├── item_menu.xml │ ├── part_sheet_list.xml │ └── part_user_list.xml │ ├── menu │ └── menu_main.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── mipmap-xxxhdpi │ └── ic_launcher.png │ ├── values-v21 │ └── styles.xml │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ ├── styles.xml │ └── themes.xml ├── fab-transformation ├── .gitignore ├── build.gradle ├── gradle.properties ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── konifar │ │ └── fab_transformation │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ └── java │ ├── com │ └── konifar │ │ └── fab_transformation │ │ ├── FabTransformation.java │ │ └── animation │ │ ├── FabAnimator.java │ │ ├── FabAnimatorLollipop.java │ │ ├── FabAnimatorPreL.java │ │ └── ViewUtil.java │ └── io │ └── codetail │ ├── animation │ ├── RevealAnimator.java │ ├── SupportAnimator.java │ ├── SupportAnimatorLollipop.java │ ├── SupportAnimatorPreL.java │ └── ViewAnimationUtils.java │ └── widget │ ├── RevealFrameLayout.java │ └── RevealLinearLayout.java ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # OS X files 2 | .DS_Store 3 | Thumbs.db 4 | 5 | # gradle files 6 | .gradle 7 | 8 | # Intellij project files 9 | .idea 10 | *.iml 11 | 12 | # generated files 13 | bin/ 14 | gen/ 15 | obj/ 16 | apk/ 17 | target/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | com_crashlytics_export_strings.xml 27 | crashlytics-build.properties -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Yusuke Konishi 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 | [![GitHub license](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://github.com/konifar/fab-transformation/blob/master/LICENSE) 2 | [ ![Download](https://api.bintray.com/packages/konifar/maven/fab-transformation/images/download.svg) ](https://bintray.com/konifar/maven/fab-transformation/_latestVersion) 3 | 4 | # Fab Transformation 5 | This library supports Floating Action Button transformation in [Material Design Guideline](https://www.google.com/design/spec/components/buttons-floating-action-button.html). 6 | 7 | # Screenshot 8 | ![Demo1](art/transform_to_toolbar.gif) 9 | ![Demo2](art/transform_to_sheet.gif) 10 | 11 | # Sample App 12 | 13 | Get it on Google Play 15 | 16 | 17 | # Installation 18 | Add the dependency (jcenter) to your `build.gradle`. 19 | ```groovy 20 | dependencies { 21 | compile 'konifar:fab-transformation:1.0.0' 22 | } 23 | ``` 24 | 25 | # How to use 26 | This is footer toolbar transformation example. 27 | 28 | ## Layout 29 | 1. Put Floating Action Button and transform view in your layout. 30 | 2. Wrap transform view in Circular reveal container. 31 | 32 | ```xml 33 | 36 | 37 | 38 | 48 | 49 | 50 | 54 | 55 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | ``` 68 | 69 | ## Java 70 | ### Transform fab to other view. 71 | ```java 72 | 73 | FabTransformation.with(fab) 74 | .transformTo(toolbarFooter); 75 | ``` 76 | 77 | ### Transform other view to fab. 78 | ```java 79 | FabTransformation.with(fab) 80 | .transformFrom(toolbarFooter); 81 | ``` 82 | 83 | ## Options 84 | ```java 85 | FabTransformation.with(fab) 86 | .overlay(overlayView) 87 | .duration(500) 88 | .setListener(new FabTransformation.OnTransformListener() { 89 | @Override 90 | public void onStartTransform() { 91 | // 92 | } 93 | 94 | @Override 95 | public void onEndTransform() { 96 | // 97 | } 98 | }) 99 | .transformFrom(toolbarFooter); 100 | ``` 101 | 102 | # Requirements 103 | Android 2.3+ 104 | 105 | # Credits 106 | This library use following libraries. 107 | * [CircularReveal](https://github.com/ozodrukh/CircularReveal) 108 | * [NineOldAndroids](https://github.com/JakeWharton/NineOldAndroids) 109 | 110 | # Developed By 111 | Yusuke Konishi (konifar) - 112 | 113 | # License 114 | ``` 115 | The MIT License (MIT) 116 | 117 | Copyright (c) 2015 Yusuke Konishi 118 | 119 | Permission is hereby granted, free of charge, to any person obtaining a copy 120 | of this software and associated documentation files (the "Software"), to deal 121 | in the Software without restriction, including without limitation the rights 122 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 123 | copies of the Software, and to permit persons to whom the Software is 124 | furnished to do so, subject to the following conditions: 125 | 126 | The above copyright notice and this permission notice shall be included in all 127 | copies or substantial portions of the Software. 128 | 129 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 130 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 131 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 132 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 133 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 134 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 135 | SOFTWARE. 136 | ``` 137 | -------------------------------------------------------------------------------- /art/transform_to_player.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/art/transform_to_player.gif -------------------------------------------------------------------------------- /art/transform_to_sheet.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/art/transform_to_sheet.gif -------------------------------------------------------------------------------- /art/transform_to_toolbar.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/art/transform_to_toolbar.gif -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | } 5 | dependencies { 6 | classpath 'com.android.tools.build:gradle:1.3.0-beta4' 7 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2' 8 | } 9 | } 10 | 11 | allprojects { 12 | repositories { 13 | jcenter() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /example/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion COMPILE_SDK_VERSION as int 5 | buildToolsVersion BUILD_TOOLS_VERSION 6 | 7 | defaultConfig { 8 | minSdkVersion MIN_SDK_VERSION as int 9 | targetSdkVersion TARGET_SDK_VERSION as int 10 | versionCode VERSION_CODE as int 11 | versionName VERSION_NAME 12 | 13 | renderscriptTargetApi RENDERSCRIPT_TARGET_API as int 14 | renderscriptSupportModeEnabled true 15 | } 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 20 | } 21 | } 22 | } 23 | 24 | dependencies { 25 | compile project(':fab-transformation') 26 | compile "com.android.support:appcompat-v7:${SUPPORT_PACKAGE_VERSION}" 27 | compile "com.android.support:cardview-v7:${SUPPORT_PACKAGE_VERSION}" 28 | compile 'de.hdodenhof:circleimageview:1.3.0' 29 | compile 'com.android.support:design:22.2.1' 30 | compile 'com.jakewharton:butterknife:6.1.0' 31 | } 32 | -------------------------------------------------------------------------------- /example/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/konifar/AndroidSdk/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 | -------------------------------------------------------------------------------- /example/src/androidTest/java/com/konifar/example/fabtransformation/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.konifar.example.fabtransformation; 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 | } -------------------------------------------------------------------------------- /example/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 24 | 25 | 29 | 30 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /example/src/main/java/com/konifar/example/fabtransformation/AppUtil.java: -------------------------------------------------------------------------------- 1 | package com.konifar.example.fabtransformation; 2 | 3 | import android.content.Context; 4 | import android.view.Gravity; 5 | import android.widget.Toast; 6 | 7 | public class AppUtil { 8 | public static void showToast(String message, Context context, int duration) { 9 | if (message == null || message.length() == 0) return; 10 | 11 | try { 12 | Toast toast = Toast.makeText(context, message, duration); 13 | toast.setGravity(Gravity.CENTER, 0, 0); 14 | toast.show(); 15 | } catch (Exception e) { 16 | // 17 | } 18 | } 19 | 20 | public static void showToast(int stringResId, Context context, int duration) { 21 | showToast(context.getResources().getString(stringResId), context, duration); 22 | } 23 | 24 | public static void showToast(String message, Context context) { 25 | showToast(message, context, Toast.LENGTH_SHORT); 26 | } 27 | 28 | public static void showToast(int stringResId, Context context) { 29 | showToast(context.getResources().getString(stringResId), context); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /example/src/main/java/com/konifar/example/fabtransformation/BaseActivity.java: -------------------------------------------------------------------------------- 1 | package com.konifar.example.fabtransformation; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.ActionBar; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.support.v7.widget.Toolbar; 7 | import android.view.MenuItem; 8 | 9 | import butterknife.ButterKnife; 10 | import butterknife.InjectView; 11 | 12 | abstract class BaseActivity extends AppCompatActivity { 13 | 14 | static final String EXTRA_TITLE = "extra_title"; 15 | 16 | @InjectView(R.id.toolbar) 17 | Toolbar toolbar; 18 | 19 | @Override 20 | protected void onCreate(Bundle savedInstanceState) { 21 | super.onCreate(savedInstanceState); 22 | setContentView(getLayoutResId()); 23 | ButterKnife.inject(this); 24 | setSupportActionBar(toolbar); 25 | 26 | String title = getIntent().getStringExtra(EXTRA_TITLE); 27 | ActionBar bar = getSupportActionBar(); 28 | if (title != null && bar != null) { 29 | bar.setTitle(title); 30 | bar.setDisplayHomeAsUpEnabled(true); 31 | bar.setDisplayShowHomeEnabled(true); 32 | bar.setHomeButtonEnabled(true); 33 | toolbar.setTitle(title); 34 | } 35 | 36 | initView(); 37 | 38 | overrideSlideEnterTransition(); 39 | } 40 | 41 | @Override 42 | public boolean onOptionsItemSelected(MenuItem item) { 43 | if (item.getItemId() == android.R.id.home) { 44 | finish(); 45 | } 46 | return super.onOptionsItemSelected(item); 47 | } 48 | 49 | void overrideSlideEnterTransition() { 50 | overridePendingTransition(R.anim.activity_slide_start_enter, R.anim.activity_scale_start_exit); 51 | } 52 | 53 | void overrideSlideExitTransition() { 54 | overridePendingTransition(R.anim.activity_scale_finish_enter, R.anim.activity_slide_finish_exit); 55 | } 56 | 57 | @Override 58 | public void finish() { 59 | super.finish(); 60 | overrideSlideExitTransition(); 61 | } 62 | 63 | abstract int getLayoutResId(); 64 | 65 | protected abstract void initView(); 66 | 67 | } 68 | -------------------------------------------------------------------------------- /example/src/main/java/com/konifar/example/fabtransformation/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.konifar.example.fabtransformation; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.net.Uri; 6 | import android.text.TextUtils; 7 | import android.view.Menu; 8 | import android.view.MenuItem; 9 | import android.widget.ListView; 10 | 11 | import com.konifar.example.fabtransformation.adapters.MenuArrayAdapter; 12 | import com.konifar.example.fabtransformation.models.SampleMenu; 13 | 14 | import java.util.ArrayList; 15 | import java.util.List; 16 | 17 | import butterknife.InjectView; 18 | import butterknife.OnItemClick; 19 | 20 | public class MainActivity extends BaseActivity { 21 | 22 | private static final String SPEC_URL = "http://www.google.com/design/spec/components/buttons-floating-action-button.html#"; 23 | 24 | @InjectView(R.id.list_view) 25 | ListView listView; 26 | 27 | private MenuArrayAdapter adapter; 28 | 29 | private static void showWebPage(String url, Context context) { 30 | if (TextUtils.isEmpty(url)) return; 31 | 32 | Uri uri = Uri.parse(url); 33 | Intent intent = new Intent(Intent.ACTION_VIEW, uri); 34 | context.startActivity(intent); 35 | } 36 | 37 | @Override 38 | int getLayoutResId() { 39 | return R.layout.activity_main; 40 | } 41 | 42 | @Override 43 | protected void initView() { 44 | adapter = new MenuArrayAdapter(this); 45 | listView.setAdapter(adapter); 46 | adapter.addAll(createMenuList()); 47 | } 48 | 49 | private List createMenuList() { 50 | List menuList = new ArrayList<>(2); 51 | menuList.add(new SampleMenu(getString(R.string.description_sheet), R.drawable.img_thumb_sheet)); 52 | menuList.add(new SampleMenu(getString(R.string.description_toolbar), R.drawable.img_thumb_toolbar)); 53 | menuList.add(new SampleMenu(getString(R.string.description_player), R.drawable.img_thumb_player)); 54 | return menuList; 55 | } 56 | 57 | @OnItemClick(R.id.list_view) 58 | void onItemClickListView(int position) { 59 | SampleMenu sampleMenu = adapter.getItem(position); 60 | switch (position) { 61 | case 0: 62 | TransformToSheetActivity.start(this, sampleMenu.getTitle()); 63 | break; 64 | case 1: 65 | TransformToToolbarActivity.start(this, sampleMenu.getTitle()); 66 | break; 67 | case 2: 68 | TransformToPlayerActivity.start(this, sampleMenu.getTitle()); 69 | break; 70 | } 71 | } 72 | 73 | @Override 74 | public boolean onCreateOptionsMenu(Menu menu) { 75 | getMenuInflater().inflate(R.menu.menu_main, menu); 76 | return true; 77 | } 78 | 79 | @Override 80 | public boolean onOptionsItemSelected(MenuItem item) { 81 | int id = item.getItemId(); 82 | 83 | switch (id) { 84 | case R.id.action_link: 85 | showWebPage(SPEC_URL, this); 86 | break; 87 | } 88 | 89 | return super.onOptionsItemSelected(item); 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /example/src/main/java/com/konifar/example/fabtransformation/TransformToPlayerActivity.java: -------------------------------------------------------------------------------- 1 | package com.konifar.example.fabtransformation; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.support.design.widget.FloatingActionButton; 6 | import android.view.View; 7 | 8 | import com.konifar.fab_transformation.FabTransformation; 9 | 10 | import butterknife.InjectView; 11 | import butterknife.OnClick; 12 | 13 | public class TransformToPlayerActivity extends BaseActivity { 14 | 15 | @InjectView(R.id.fab) 16 | FloatingActionButton fab; 17 | @InjectView(R.id.container_player) 18 | View containerPlayer; 19 | 20 | public static void start(Context context, String title) { 21 | Intent intent = new Intent(context, TransformToPlayerActivity.class); 22 | intent.putExtra(EXTRA_TITLE, title); 23 | context.startActivity(intent); 24 | } 25 | 26 | @Override 27 | int getLayoutResId() { 28 | return R.layout.activity_transform_to_player; 29 | } 30 | 31 | @Override 32 | protected void initView() { 33 | // 34 | } 35 | 36 | @OnClick(R.id.fab) 37 | void onClickFab() { 38 | if (fab.getVisibility() == View.VISIBLE) { 39 | FabTransformation.with(fab).transformTo(containerPlayer); 40 | } 41 | } 42 | 43 | @OnClick(R.id.container_player) 44 | void onClickSheet() { 45 | if (fab.getVisibility() != View.VISIBLE) { 46 | FabTransformation.with(fab).transformFrom(containerPlayer); 47 | } 48 | } 49 | 50 | @Override 51 | public void onBackPressed() { 52 | if (fab.getVisibility() != View.VISIBLE) { 53 | FabTransformation.with(fab).transformFrom(containerPlayer); 54 | return; 55 | } 56 | super.onBackPressed(); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /example/src/main/java/com/konifar/example/fabtransformation/TransformToSheetActivity.java: -------------------------------------------------------------------------------- 1 | package com.konifar.example.fabtransformation; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.support.design.widget.FloatingActionButton; 6 | import android.view.View; 7 | 8 | import com.konifar.fab_transformation.FabTransformation; 9 | 10 | import butterknife.InjectView; 11 | import butterknife.OnClick; 12 | 13 | public class TransformToSheetActivity extends BaseActivity { 14 | 15 | @InjectView(R.id.fab) 16 | FloatingActionButton fab; 17 | @InjectView(R.id.sheet) 18 | View sheet; 19 | @InjectView(R.id.overlay) 20 | View overlay; 21 | 22 | public static void start(Context context, String title) { 23 | Intent intent = new Intent(context, TransformToSheetActivity.class); 24 | intent.putExtra(EXTRA_TITLE, title); 25 | context.startActivity(intent); 26 | } 27 | 28 | @Override 29 | int getLayoutResId() { 30 | return R.layout.activity_transform_to_sheet; 31 | } 32 | 33 | @Override 34 | protected void initView() { 35 | // 36 | } 37 | 38 | @OnClick(R.id.fab) 39 | void onClickFab() { 40 | if (fab.getVisibility() == View.VISIBLE) { 41 | FabTransformation.with(fab).setOverlay(overlay).transformTo(sheet); 42 | } 43 | } 44 | 45 | @OnClick(R.id.row_1) 46 | void onClickRow1() { 47 | AppUtil.showToast("Row 1 clicked!", this); 48 | } 49 | 50 | @OnClick(R.id.row_2) 51 | void onClickRow2() { 52 | AppUtil.showToast("Row 2 clicked!", this); 53 | } 54 | 55 | @OnClick(R.id.row_3) 56 | void onClickRow3() { 57 | AppUtil.showToast("Row 3 clicked!", this); 58 | } 59 | 60 | @OnClick(R.id.row_4) 61 | void onClickRow4() { 62 | AppUtil.showToast("Row 4 clicked!", this); 63 | } 64 | 65 | @OnClick(R.id.row_5) 66 | void onClickRow5() { 67 | AppUtil.showToast("Row 5 clicked!", this); 68 | } 69 | 70 | @OnClick(R.id.overlay) 71 | void onClickOverlay() { 72 | if (fab.getVisibility() != View.VISIBLE) { 73 | FabTransformation.with(fab).setOverlay(overlay).transformFrom(sheet); 74 | } 75 | } 76 | 77 | @Override 78 | public void onBackPressed() { 79 | if (fab.getVisibility() != View.VISIBLE) { 80 | FabTransformation.with(fab).setOverlay(overlay).transformFrom(sheet); 81 | return; 82 | } 83 | super.onBackPressed(); 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /example/src/main/java/com/konifar/example/fabtransformation/TransformToToolbarActivity.java: -------------------------------------------------------------------------------- 1 | package com.konifar.example.fabtransformation; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.support.design.widget.FloatingActionButton; 6 | import android.view.View; 7 | import android.view.ViewTreeObserver; 8 | import android.widget.ScrollView; 9 | 10 | import com.konifar.fab_transformation.FabTransformation; 11 | 12 | import butterknife.InjectView; 13 | import butterknife.OnClick; 14 | 15 | public class TransformToToolbarActivity extends BaseActivity { 16 | 17 | @InjectView(R.id.fab) 18 | FloatingActionButton fab; 19 | @InjectView(R.id.toolbar_footer) 20 | View toolbarFooter; 21 | @InjectView(R.id.scroll_view) 22 | ScrollView scrollView; 23 | 24 | private boolean isTransforming; 25 | 26 | public static void start(Context context, String title) { 27 | Intent intent = new Intent(context, TransformToToolbarActivity.class); 28 | intent.putExtra(EXTRA_TITLE, title); 29 | context.startActivity(intent); 30 | } 31 | 32 | @Override 33 | int getLayoutResId() { 34 | return R.layout.activity_transform_to_toolbar; 35 | } 36 | 37 | @Override 38 | protected void initView() { 39 | scrollView.getViewTreeObserver().addOnScrollChangedListener( 40 | new ViewTreeObserver.OnScrollChangedListener() { 41 | @Override 42 | public void onScrollChanged() { 43 | if (fab.getVisibility() != View.VISIBLE && !isTransforming) { 44 | FabTransformation.with(fab) 45 | .setListener(new FabTransformation.OnTransformListener() { 46 | @Override 47 | public void onStartTransform() { 48 | isTransforming = true; 49 | } 50 | 51 | @Override 52 | public void onEndTransform() { 53 | isTransforming = false; 54 | } 55 | }) 56 | .transformFrom(toolbarFooter); 57 | } 58 | } 59 | }); 60 | } 61 | 62 | @OnClick(R.id.fab) 63 | void onClickFab() { 64 | if (fab.getVisibility() == View.VISIBLE) { 65 | FabTransformation.with(fab).transformTo(toolbarFooter); 66 | } 67 | } 68 | 69 | @Override 70 | public void onBackPressed() { 71 | if (fab.getVisibility() != View.VISIBLE) { 72 | FabTransformation.with(fab).transformFrom(toolbarFooter); 73 | return; 74 | } 75 | super.onBackPressed(); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /example/src/main/java/com/konifar/example/fabtransformation/adapters/BaseArrayAdapter.java: -------------------------------------------------------------------------------- 1 | package com.konifar.example.fabtransformation.adapters; 2 | 3 | import android.content.Context; 4 | import android.os.Build; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.ArrayAdapter; 8 | 9 | import java.util.Collection; 10 | import java.util.List; 11 | 12 | public abstract class BaseArrayAdapter extends ArrayAdapter { 13 | 14 | private int mLastPosition = -1; 15 | 16 | public BaseArrayAdapter(Context context, int resId, List items) { 17 | super(context, resId, items); 18 | } 19 | 20 | @SuppressWarnings("unchecked") 21 | @Override 22 | public void addAll(Collection items) { 23 | if (items == null) return; 24 | 25 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { 26 | super.addAll(items); 27 | } else { 28 | for (Object item : items) { 29 | super.add((T) item); 30 | } 31 | } 32 | } 33 | 34 | @SuppressWarnings("unchecked") 35 | @Override 36 | public void addAll(T... items) { 37 | if (items == null) return; 38 | 39 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { 40 | super.addAll(items); 41 | } else { 42 | for (Object item : items) { 43 | super.add((T) item); 44 | } 45 | } 46 | } 47 | 48 | @Override 49 | public abstract View getView(int pos, View view, ViewGroup parent); 50 | 51 | } 52 | -------------------------------------------------------------------------------- /example/src/main/java/com/konifar/example/fabtransformation/adapters/MenuArrayAdapter.java: -------------------------------------------------------------------------------- 1 | package com.konifar.example.fabtransformation.adapters; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.ImageView; 8 | import android.widget.TextView; 9 | 10 | import com.konifar.example.fabtransformation.R; 11 | import com.konifar.example.fabtransformation.models.SampleMenu; 12 | 13 | import java.util.ArrayList; 14 | 15 | import butterknife.ButterKnife; 16 | import butterknife.InjectView; 17 | 18 | public class MenuArrayAdapter extends BaseArrayAdapter { 19 | 20 | public MenuArrayAdapter(Context context) { 21 | super(context, R.layout.item_menu, new ArrayList()); 22 | } 23 | 24 | @Override 25 | public View getView(int pos, View view, ViewGroup parent) { 26 | ViewHolder holder; 27 | 28 | if (view == null) { 29 | view = LayoutInflater.from(getContext()).inflate(R.layout.item_menu, parent, false); 30 | holder = new ViewHolder(view); 31 | view.setTag(holder); 32 | } else { 33 | holder = (ViewHolder) view.getTag(); 34 | } 35 | 36 | SampleMenu menu = getItem(pos); 37 | holder.imgThumb.setImageResource(menu.getDrawableResId()); 38 | holder.txtTitle.setText(menu.getTitle()); 39 | 40 | return view; 41 | } 42 | 43 | static class ViewHolder { 44 | @InjectView(R.id.img_thmub) 45 | ImageView imgThumb; 46 | @InjectView(R.id.txt_title) 47 | TextView txtTitle; 48 | 49 | ViewHolder(View view) { 50 | ButterKnife.inject(this, view); 51 | } 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /example/src/main/java/com/konifar/example/fabtransformation/models/SampleMenu.java: -------------------------------------------------------------------------------- 1 | package com.konifar.example.fabtransformation.models; 2 | 3 | public class SampleMenu { 4 | private String title; 5 | private int drawableResId; 6 | 7 | public SampleMenu(String title, int drawableResId) { 8 | this.title = title; 9 | this.drawableResId = drawableResId; 10 | } 11 | 12 | public String getTitle() { 13 | return title; 14 | } 15 | 16 | public int getDrawableResId() { 17 | return drawableResId; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /example/src/main/res/anim/activity_scale_finish_enter.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /example/src/main/res/anim/activity_scale_start_exit.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /example/src/main/res/anim/activity_slide_finish_exit.xml: -------------------------------------------------------------------------------- 1 | 4 | 11 | -------------------------------------------------------------------------------- /example/src/main/res/anim/activity_slide_start_enter.xml: -------------------------------------------------------------------------------- 1 | 4 | 11 | -------------------------------------------------------------------------------- /example/src/main/res/drawable-hdpi/ic_account_balance_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-hdpi/ic_account_balance_white_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-hdpi/ic_add_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-hdpi/ic_add_black_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-hdpi/ic_content_copy_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-hdpi/ic_content_copy_white_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-hdpi/ic_edit_grey_900_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-hdpi/ic_edit_grey_900_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-hdpi/ic_email_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-hdpi/ic_email_white_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-hdpi/ic_folder_shared_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-hdpi/ic_folder_shared_white_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-hdpi/ic_location_on_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-hdpi/ic_location_on_white_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-hdpi/ic_play_arrow_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-hdpi/ic_play_arrow_white_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-hdpi/ic_share_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-hdpi/ic_share_white_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-mdpi/ic_account_balance_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-mdpi/ic_account_balance_white_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-mdpi/ic_add_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-mdpi/ic_add_black_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-mdpi/ic_content_copy_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-mdpi/ic_content_copy_white_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-mdpi/ic_edit_grey_900_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-mdpi/ic_edit_grey_900_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-mdpi/ic_email_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-mdpi/ic_email_white_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-mdpi/ic_folder_shared_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-mdpi/ic_folder_shared_white_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-mdpi/ic_location_on_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-mdpi/ic_location_on_white_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-mdpi/ic_play_arrow_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-mdpi/ic_play_arrow_white_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-mdpi/ic_share_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-mdpi/ic_share_white_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-nodpi/img_dora.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-nodpi/img_dora.jpg -------------------------------------------------------------------------------- /example/src/main/res/drawable-nodpi/img_thumb_player.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-nodpi/img_thumb_player.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-nodpi/img_thumb_sheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-nodpi/img_thumb_sheet.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-nodpi/img_thumb_toolbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-nodpi/img_thumb_toolbar.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xhdpi/ic_account_balance_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-xhdpi/ic_account_balance_white_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xhdpi/ic_add_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-xhdpi/ic_add_black_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xhdpi/ic_content_copy_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-xhdpi/ic_content_copy_white_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xhdpi/ic_edit_grey_900_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-xhdpi/ic_edit_grey_900_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xhdpi/ic_email_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-xhdpi/ic_email_white_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xhdpi/ic_folder_shared_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-xhdpi/ic_folder_shared_white_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xhdpi/ic_location_on_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-xhdpi/ic_location_on_white_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xhdpi/ic_play_arrow_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-xhdpi/ic_play_arrow_white_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xhdpi/ic_share_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-xhdpi/ic_share_white_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxhdpi/ic_account_balance_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-xxhdpi/ic_account_balance_white_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxhdpi/ic_add_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-xxhdpi/ic_add_black_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxhdpi/ic_content_copy_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-xxhdpi/ic_content_copy_white_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxhdpi/ic_edit_grey_900_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-xxhdpi/ic_edit_grey_900_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxhdpi/ic_email_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-xxhdpi/ic_email_white_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxhdpi/ic_folder_shared_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-xxhdpi/ic_folder_shared_white_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxhdpi/ic_location_on_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-xxhdpi/ic_location_on_white_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxhdpi/ic_play_arrow_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-xxhdpi/ic_play_arrow_white_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxhdpi/ic_share_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-xxhdpi/ic_share_white_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxxhdpi/ic_account_balance_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-xxxhdpi/ic_account_balance_white_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxxhdpi/ic_add_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-xxxhdpi/ic_add_black_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxxhdpi/ic_content_copy_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-xxxhdpi/ic_content_copy_white_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxxhdpi/ic_edit_grey_900_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-xxxhdpi/ic_edit_grey_900_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxxhdpi/ic_email_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-xxxhdpi/ic_email_white_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxxhdpi/ic_folder_shared_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-xxxhdpi/ic_folder_shared_white_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxxhdpi/ic_location_on_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-xxxhdpi/ic_location_on_white_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxxhdpi/ic_play_arrow_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-xxxhdpi/ic_play_arrow_white_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxxhdpi/ic_share_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/drawable-xxxhdpi/ic_share_white_24dp.png -------------------------------------------------------------------------------- /example/src/main/res/drawable/bg_feedback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /example/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 | 21 | 22 | 23 | 24 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /example/src/main/res/layout/activity_transform_to_player.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 49 | 50 | 54 | 55 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /example/src/main/res/layout/activity_transform_to_sheet.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 22 | 23 | 24 | 25 | 33 | 34 | 44 | 45 | 50 | 51 | 58 | 59 | 63 | 64 | 67 | 68 | 71 | 72 | 75 | 76 | 79 | 80 | 89 | 90 | 96 | 97 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /example/src/main/res/layout/activity_transform_to_toolbar.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 22 | 23 | 24 | 25 | 30 | 31 | 35 | 36 | 37 | 38 | 43 | 44 | 45 | 46 | 51 | 52 | 53 | 54 | 59 | 60 | 61 | 62 | 67 | 68 | 69 | 70 | 75 | 76 | 77 | 78 | 83 | 84 | 85 | 86 | 91 | 92 | 93 | 94 | 99 | 100 | 101 | 102 | 107 | 108 | 109 | 110 | 115 | 116 | 117 | 118 | 123 | 124 | 125 | 126 | 131 | 132 | 133 | 134 | 139 | 140 | 141 | 142 | 147 | 148 | 149 | 150 | 155 | 156 | 157 | 158 | 163 | 164 | 165 | 166 | 167 | 168 | 178 | 179 | 183 | 184 | 190 | 191 | 196 | 197 | 206 | 207 | 216 | 217 | 226 | 227 | 236 | 237 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | -------------------------------------------------------------------------------- /example/src/main/res/layout/item_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /example/src/main/res/layout/part_sheet_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 18 | 19 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /example/src/main/res/layout/part_user_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 13 | 14 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /example/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /example/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/example/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | #00BCD4 7 | #00ACC1 8 | #FFFF00 9 | 10 | 11 | #EEEEEE 12 | #757575 13 | #000000 14 | #FFFFFF 15 | #1F000000 16 | #4D000000 17 | 18 | 19 | #2979FF 20 | #009688 21 | 22 | -------------------------------------------------------------------------------- /example/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8dp 4 | 16dp 5 | 20dp 6 | 7 | 8 | 14sp 9 | 16sp 10 | 20sp 11 | 12 | 13 | 1sp 14 | 15 | 16 | 40dp 17 | 100dp 18 | 64dp 19 | 20 | -------------------------------------------------------------------------------- /example/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | FabTransformation 3 | 4 | Design Guideline 5 | 6 | To Sheet 7 | To Toolbar 8 | To Player 9 | 10 | Transform to Sheet 11 | Transform to Toolbar 12 | Transform to Player 13 | 14 | 200 15 | 16 | -------------------------------------------------------------------------------- /example/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 15 | 16 | 22 | 23 | 30 | 31 | 41 | 42 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /example/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /fab-transformation/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /fab-transformation/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | mavenCentral() 5 | } 6 | dependencies { 7 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0' 8 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' 9 | } 10 | } 11 | 12 | apply plugin: 'com.android.library' 13 | 14 | android { 15 | compileSdkVersion COMPILE_SDK_VERSION as int 16 | buildToolsVersion BUILD_TOOLS_VERSION 17 | 18 | defaultConfig { 19 | minSdkVersion MIN_SDK_VERSION as int 20 | targetSdkVersion TARGET_SDK_VERSION as int 21 | versionCode VERSION_CODE as int 22 | versionName VERSION_NAME 23 | } 24 | } 25 | 26 | apply plugin: 'com.github.dcendents.android-maven' 27 | apply plugin: 'com.jfrog.bintray' 28 | 29 | group = 'konifar' 30 | version = '1.0.0' 31 | def siteUrl = 'https://github.com/konifar/fab-transformation' 32 | def gitUrl = 'https://github.com/konifar/fab-transformation.git' 33 | 34 | bintray { 35 | user = '' 36 | key = '' 37 | 38 | configurations = ['archives'] 39 | pkg { 40 | repo = 'maven' 41 | name = 'fab-transformation' 42 | desc = 'Support Floating Action Button transformation for Android.' 43 | websiteUrl = siteUrl 44 | issueTrackerUrl = 'https://github.com/konifar/fab-transformation/issues' 45 | vcsUrl = gitUrl 46 | licenses = ['MIT'] 47 | labels = ['android'] 48 | publicDownloadNumbers = true 49 | } 50 | } 51 | 52 | install { 53 | repositories.mavenInstaller { 54 | pom { 55 | project { 56 | packaging 'aar' 57 | name 'fab-transformation' 58 | url siteUrl 59 | artifactId 'fab-transformation' 60 | licenses { 61 | license { 62 | name 'MIT' 63 | url 'http://opensource.org/licenses/mit-license.php' 64 | } 65 | } 66 | developers { 67 | developer { 68 | id 'konifar' 69 | name 'Yusuke Konishi' 70 | email 'yahpeycoy0403@gmail.com' 71 | } 72 | } 73 | scm { 74 | connection 'https://github.com/konifar/fab-transformation.git' 75 | developerConnection 'https://github.com/konifar/fab-transformation.git' 76 | url siteUrl 77 | } 78 | } 79 | } 80 | } 81 | } 82 | 83 | dependencies { 84 | compile 'com.nineoldandroids:library:2.4.0+' 85 | } 86 | 87 | task sourcesJar(type: Jar) { 88 | from android.sourceSets.main.java.srcDirs 89 | classifier = 'sources' 90 | } 91 | 92 | task javadoc(type: Javadoc) { 93 | source = android.sourceSets.main.java.srcDirs 94 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) 95 | } 96 | 97 | task javadocJar(type: Jar, dependsOn: javadoc) { 98 | classifier = 'javadoc' 99 | from javadoc.destinationDir 100 | } 101 | artifacts { 102 | archives javadocJar 103 | archives sourcesJar 104 | } 105 | 106 | task findConventions << { 107 | println project.getConvention() 108 | } -------------------------------------------------------------------------------- /fab-transformation/gradle.properties: -------------------------------------------------------------------------------- 1 | POM_NAME=Support Floating Action Button transformation for Android 2 | POM_ARTIFACT_ID=FabTransformation 3 | POM_PACKAGING=aar -------------------------------------------------------------------------------- /fab-transformation/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/konifar/AndroidSdk/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 | -------------------------------------------------------------------------------- /fab-transformation/src/androidTest/java/com/konifar/fab_transformation/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.konifar.fab_transformation; 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 | } -------------------------------------------------------------------------------- /fab-transformation/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /fab-transformation/src/main/java/com/konifar/fab_transformation/FabTransformation.java: -------------------------------------------------------------------------------- 1 | package com.konifar.fab_transformation; 2 | 3 | import android.os.Build; 4 | import android.view.View; 5 | 6 | import com.konifar.fab_transformation.animation.FabAnimator; 7 | import com.konifar.fab_transformation.animation.FabAnimatorLollipop; 8 | import com.konifar.fab_transformation.animation.FabAnimatorPreL; 9 | 10 | public class FabTransformation { 11 | 12 | private static final boolean IS_PRE_LOLLIPOP = Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP; 13 | private static final long DEFAULT_DURATION = 300; 14 | 15 | public static Builder with(View fab) { 16 | return new Builder(fab); 17 | } 18 | 19 | public interface OnTransformListener { 20 | void onStartTransform(); 21 | 22 | void onEndTransform(); 23 | } 24 | 25 | public static class Builder { 26 | private View fab; 27 | private View overlay; 28 | private FabAnimator animator; 29 | private long duration; 30 | private OnTransformListener listener; 31 | 32 | public Builder(View fab) { 33 | this.fab = fab; 34 | this.animator = IS_PRE_LOLLIPOP ? new FabAnimatorPreL() : new FabAnimatorLollipop(); 35 | this.duration = DEFAULT_DURATION; 36 | } 37 | 38 | public Builder duration(long millsecond) { 39 | this.duration = millsecond; 40 | return this; 41 | } 42 | 43 | public Builder setListener(OnTransformListener listener) { 44 | this.listener = listener; 45 | return this; 46 | } 47 | 48 | public Builder setOverlay(View overlay) { 49 | this.overlay = overlay; 50 | return this; 51 | } 52 | 53 | public void transformTo(View transformView) { 54 | if (transformView == null) { 55 | throw new IllegalStateException("transformView is not set."); 56 | } 57 | if (fab.getVisibility() == View.VISIBLE) { 58 | animator.transformTo(fab, transformView, duration, overlay, listener); 59 | } 60 | } 61 | 62 | public void transformFrom(View transformView) { 63 | if (transformView == null) { 64 | throw new IllegalStateException("transformView is not set."); 65 | } 66 | if (fab.getVisibility() != View.VISIBLE) { 67 | animator.transformOut(fab, transformView, duration, overlay, listener); 68 | } 69 | } 70 | 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /fab-transformation/src/main/java/com/konifar/fab_transformation/animation/FabAnimator.java: -------------------------------------------------------------------------------- 1 | package com.konifar.fab_transformation.animation; 2 | 3 | import android.view.View; 4 | import android.view.animation.AccelerateDecelerateInterpolator; 5 | import android.view.animation.AccelerateInterpolator; 6 | import android.view.animation.DecelerateInterpolator; 7 | import android.view.animation.Interpolator; 8 | 9 | import com.konifar.fab_transformation.FabTransformation; 10 | 11 | public abstract class FabAnimator { 12 | 13 | static final float FAB_SCALE = 1.2f; 14 | static final Interpolator REVEAL_INTERPOLATOR = new DecelerateInterpolator(); 15 | static final Interpolator FAB_INTERPOLATOR = new AccelerateInterpolator(); 16 | static final Interpolator OVERLAY_INTERPOLATOR = new AccelerateDecelerateInterpolator(); 17 | private long fabAnimationDuration; 18 | private long revealAnimationDuration; 19 | 20 | abstract void fabMoveIn(View fab, View transformView, FabAnimationCallback callback); 21 | 22 | abstract void fabMoveOut(View fab, View transformView, FabAnimationCallback callback); 23 | 24 | abstract void revealOn(View fab, View transformView, RevealCallback callback); 25 | 26 | abstract void revealOff(View fab, View transformView, RevealCallback callback); 27 | 28 | abstract void showOverlay(final View overlay); 29 | 30 | abstract void hideOverlay(final View overlay); 31 | 32 | private void calculateDuration(View fab, View transformView, long duration) { 33 | int fabTranslationX = getTranslationX(fab, transformView); 34 | int fabTranslationY = getTranslationY(fab, transformView); 35 | 36 | float maxFabTranslation = Math.max(Math.abs(fabTranslationX), Math.abs(fabTranslationY)) * 1.5f; 37 | float maxTransformView = Math.max(Math.abs(transformView.getWidth()), Math.abs(transformView.getHeight())); 38 | 39 | this.fabAnimationDuration = (long) (duration * (maxFabTranslation / (maxFabTranslation + maxTransformView))); 40 | this.revealAnimationDuration = (long) (duration * (maxTransformView / (maxFabTranslation + maxTransformView))); 41 | } 42 | 43 | long getFabAnimationDuration() { 44 | return fabAnimationDuration; 45 | } 46 | 47 | long getRevealAnimationDuration() { 48 | return revealAnimationDuration; 49 | } 50 | 51 | public void transformTo(final View fab, final View transformView, long duration, final View overlay, 52 | final FabTransformation.OnTransformListener listener) { 53 | calculateDuration(fab, transformView, duration); 54 | 55 | fabMoveIn(fab, transformView, new FabAnimationCallback() { 56 | @Override 57 | public void onAnimationStart() { 58 | if (overlay != null) showOverlay(overlay); 59 | if (listener != null) listener.onStartTransform(); 60 | } 61 | 62 | @Override 63 | public void onAnimationEnd() { 64 | revealOn(fab, transformView, new RevealCallback() { 65 | @Override 66 | public void onRevealStart() { 67 | fab.setVisibility(View.INVISIBLE); 68 | } 69 | 70 | @Override 71 | public void onRevealEnd() { 72 | if (listener != null) listener.onEndTransform(); 73 | } 74 | }); 75 | } 76 | 77 | @Override 78 | public void onAnimationCancel() { 79 | // 80 | } 81 | 82 | @Override 83 | public void onAnimationRepeat() { 84 | // 85 | } 86 | }); 87 | } 88 | 89 | public void transformOut(final View fab, final View transformView, long duration, final View overlay, 90 | final FabTransformation.OnTransformListener listener) { 91 | calculateDuration(fab, transformView, duration); 92 | 93 | if (overlay != null) hideOverlay(overlay); 94 | 95 | revealOff(fab, transformView, new RevealCallback() { 96 | @Override 97 | public void onRevealStart() { 98 | if (listener != null) listener.onStartTransform(); 99 | } 100 | 101 | @Override 102 | public void onRevealEnd() { 103 | fabMoveOut(fab, transformView, new FabAnimationCallback() { 104 | @Override 105 | public void onAnimationStart() { 106 | fab.setVisibility(View.VISIBLE); 107 | } 108 | 109 | @Override 110 | public void onAnimationEnd() { 111 | if (listener != null) listener.onEndTransform(); 112 | } 113 | 114 | @Override 115 | public void onAnimationCancel() { 116 | // 117 | } 118 | 119 | @Override 120 | public void onAnimationRepeat() { 121 | // 122 | } 123 | }); 124 | } 125 | }); 126 | } 127 | 128 | int getCenterX(View view) { 129 | return view.getWidth() / 2 + view.getLeft(); 130 | } 131 | 132 | int getCenterY(View view) { 133 | return view.getHeight() / 2 + view.getTop(); 134 | } 135 | 136 | int getTranslationX(View fab, View transformView) { 137 | int fabX = ViewUtil.getRelativeLeft(fab) + fab.getWidth() / 2; 138 | int transformViewX = ViewUtil.getRelativeLeft(transformView) + transformView.getWidth() / 2; 139 | return transformViewX - fabX; 140 | } 141 | 142 | int getTranslationY(View fab, View transformView) { 143 | int fabY = ViewUtil.getRelativeTop(fab) + fab.getHeight() / 2; 144 | int transformViewY = ViewUtil.getRelativeTop(transformView) + transformView.getHeight() / 2; 145 | return transformViewY - fabY; 146 | } 147 | 148 | interface RevealCallback { 149 | void onRevealStart(); 150 | 151 | void onRevealEnd(); 152 | } 153 | 154 | interface FabAnimationCallback { 155 | void onAnimationStart(); 156 | 157 | void onAnimationEnd(); 158 | 159 | void onAnimationCancel(); 160 | 161 | void onAnimationRepeat(); 162 | } 163 | 164 | } 165 | -------------------------------------------------------------------------------- /fab-transformation/src/main/java/com/konifar/fab_transformation/animation/FabAnimatorLollipop.java: -------------------------------------------------------------------------------- 1 | package com.konifar.fab_transformation.animation; 2 | 3 | import android.animation.Animator; 4 | import android.animation.AnimatorListenerAdapter; 5 | import android.annotation.TargetApi; 6 | import android.os.Build; 7 | import android.view.View; 8 | import android.view.ViewAnimationUtils; 9 | 10 | public class FabAnimatorLollipop extends FabAnimator { 11 | 12 | @TargetApi(Build.VERSION_CODES.LOLLIPOP) 13 | @Override 14 | final void revealOff(final View fab, final View transformView, final RevealCallback callback) { 15 | Animator animator = ViewAnimationUtils.createCircularReveal( 16 | transformView, 17 | getCenterX(transformView), 18 | getCenterY(transformView), 19 | (float) Math.hypot(transformView.getWidth(), transformView.getHeight()) / 2, 20 | fab.getWidth() / 2); 21 | animator.setInterpolator(REVEAL_INTERPOLATOR); 22 | animator.addListener(new Animator.AnimatorListener() { 23 | @Override 24 | public void onAnimationStart(Animator animation) { 25 | callback.onRevealStart(); 26 | } 27 | 28 | @Override 29 | public void onAnimationEnd(Animator animation) { 30 | transformView.setVisibility(View.INVISIBLE); 31 | callback.onRevealEnd(); 32 | } 33 | 34 | @Override 35 | public void onAnimationCancel(Animator animation) { 36 | // 37 | } 38 | 39 | @Override 40 | public void onAnimationRepeat(Animator animation) { 41 | // 42 | } 43 | }); 44 | if (transformView.getVisibility() == View.VISIBLE) { 45 | animator.setDuration(getRevealAnimationDuration()); 46 | animator.start(); 47 | transformView.setEnabled(true); 48 | } 49 | } 50 | 51 | @TargetApi(Build.VERSION_CODES.LOLLIPOP) 52 | final void revealOn(final View fab, View transformView, final RevealCallback callback) { 53 | Animator animator = ViewAnimationUtils.createCircularReveal( 54 | transformView, 55 | getCenterX(transformView), 56 | getCenterY(transformView), 57 | fab.getWidth() / 2, 58 | (float) Math.hypot(transformView.getWidth(), transformView.getHeight()) / 2); 59 | transformView.setVisibility(View.VISIBLE); 60 | animator.setInterpolator(REVEAL_INTERPOLATOR); 61 | animator.addListener(new Animator.AnimatorListener() { 62 | @Override 63 | public void onAnimationStart(Animator animation) { 64 | callback.onRevealStart(); 65 | } 66 | 67 | @Override 68 | public void onAnimationEnd(Animator animation) { 69 | callback.onRevealEnd(); 70 | } 71 | 72 | @Override 73 | public void onAnimationCancel(Animator animation) { 74 | // 75 | } 76 | 77 | @Override 78 | public void onAnimationRepeat(Animator animation) { 79 | // 80 | } 81 | }); 82 | if (transformView.getVisibility() == View.VISIBLE) { 83 | animator.setDuration(getRevealAnimationDuration()); 84 | animator.start(); 85 | transformView.setEnabled(true); 86 | } 87 | } 88 | 89 | @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) 90 | @Override 91 | final void fabMoveOut(final View fab, final View transformView, final FabAnimationCallback callback) { 92 | fab.animate() 93 | .scaleX(1) 94 | .scaleY(1) 95 | .translationX(0) 96 | .translationY(0) 97 | .setInterpolator(FAB_INTERPOLATOR) 98 | .setDuration(getFabAnimationDuration()) 99 | .setListener(new Animator.AnimatorListener() { 100 | @Override 101 | public void onAnimationStart(Animator animation) { 102 | callback.onAnimationStart(); 103 | } 104 | 105 | @Override 106 | public void onAnimationEnd(Animator animation) { 107 | callback.onAnimationEnd(); 108 | } 109 | 110 | @Override 111 | public void onAnimationCancel(Animator animation) { 112 | callback.onAnimationCancel(); 113 | } 114 | 115 | @Override 116 | public void onAnimationRepeat(Animator animation) { 117 | callback.onAnimationRepeat(); 118 | } 119 | }) 120 | .start(); 121 | } 122 | 123 | @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) 124 | @Override 125 | final void fabMoveIn(final View fab, View transformView, final FabAnimationCallback callback) { 126 | fab.animate() 127 | .scaleX(FAB_SCALE) 128 | .scaleY(FAB_SCALE) 129 | .translationX(getTranslationX(fab, transformView)) 130 | .translationY(getTranslationY(fab, transformView)) 131 | .setInterpolator(FAB_INTERPOLATOR) 132 | .setDuration(getRevealAnimationDuration()) 133 | .setListener(new Animator.AnimatorListener() { 134 | @Override 135 | public void onAnimationStart(Animator animation) { 136 | callback.onAnimationStart(); 137 | } 138 | 139 | @Override 140 | public void onAnimationEnd(Animator animation) { 141 | callback.onAnimationEnd(); 142 | } 143 | 144 | @Override 145 | public void onAnimationCancel(Animator animation) { 146 | callback.onAnimationCancel(); 147 | } 148 | 149 | @Override 150 | public void onAnimationRepeat(Animator animation) { 151 | callback.onAnimationRepeat(); 152 | } 153 | }) 154 | .start(); 155 | } 156 | 157 | @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) 158 | @Override 159 | void showOverlay(final View overlay) { 160 | overlay.animate() 161 | .alpha(1) 162 | .setDuration(getRevealAnimationDuration()) 163 | .setInterpolator(OVERLAY_INTERPOLATOR) 164 | .setListener(new AnimatorListenerAdapter() { 165 | @Override 166 | public void onAnimationStart(Animator animation) { 167 | overlay.setVisibility(View.VISIBLE); 168 | } 169 | 170 | @Override 171 | public void onAnimationEnd(Animator animation) { 172 | // 173 | } 174 | }) 175 | .start(); 176 | } 177 | 178 | @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) 179 | @Override 180 | void hideOverlay(final View overlay) { 181 | overlay.animate() 182 | .alpha(0) 183 | .setDuration(getRevealAnimationDuration()) 184 | .setInterpolator(OVERLAY_INTERPOLATOR) 185 | .setListener(new AnimatorListenerAdapter() { 186 | @Override 187 | public void onAnimationStart(Animator animation) { 188 | // 189 | } 190 | 191 | @Override 192 | public void onAnimationEnd(Animator animation) { 193 | overlay.setVisibility(View.GONE); 194 | } 195 | }) 196 | .start(); 197 | } 198 | 199 | } 200 | -------------------------------------------------------------------------------- /fab-transformation/src/main/java/com/konifar/fab_transformation/animation/FabAnimatorPreL.java: -------------------------------------------------------------------------------- 1 | package com.konifar.fab_transformation.animation; 2 | 3 | import android.view.View; 4 | import android.view.animation.AccelerateDecelerateInterpolator; 5 | 6 | import com.nineoldandroids.animation.Animator; 7 | import com.nineoldandroids.animation.AnimatorListenerAdapter; 8 | import com.nineoldandroids.view.ViewPropertyAnimator; 9 | 10 | import io.codetail.animation.SupportAnimator; 11 | import io.codetail.animation.ViewAnimationUtils; 12 | 13 | public class FabAnimatorPreL extends FabAnimator { 14 | 15 | @Override 16 | final void revealOff(final View fab, final View transformView, final RevealCallback callback) { 17 | SupportAnimator animator = ViewAnimationUtils.createCircularReveal( 18 | transformView, 19 | getCenterX(fab), 20 | getCenterY(fab), 21 | (float) Math.hypot(transformView.getWidth(), transformView.getHeight()) / 2, 22 | fab.getWidth() / 2); 23 | animator.setInterpolator(REVEAL_INTERPOLATOR); 24 | animator.addListener(new SupportAnimator.AnimatorListener() { 25 | @Override 26 | public void onAnimationStart() { 27 | callback.onRevealStart(); 28 | } 29 | 30 | @Override 31 | public void onAnimationEnd() { 32 | transformView.setVisibility(View.INVISIBLE); 33 | callback.onRevealEnd(); 34 | } 35 | 36 | @Override 37 | public void onAnimationCancel() { 38 | // 39 | } 40 | 41 | @Override 42 | public void onAnimationRepeat() { 43 | // 44 | } 45 | }); 46 | if (transformView.getVisibility() == View.VISIBLE) { 47 | animator.setDuration((int) getRevealAnimationDuration()); 48 | animator.start(); 49 | transformView.setEnabled(true); 50 | } 51 | } 52 | 53 | @Override 54 | final void revealOn(final View fab, final View transformView, final RevealCallback callback) { 55 | SupportAnimator animator = ViewAnimationUtils.createCircularReveal( 56 | transformView, 57 | getCenterX(fab), 58 | getCenterY(fab), 59 | fab.getWidth() / 2, 60 | (float) Math.hypot(transformView.getWidth(), transformView.getHeight()) / 2); 61 | transformView.setVisibility(View.VISIBLE); 62 | animator.setInterpolator(FAB_INTERPOLATOR); 63 | animator.addListener(new SupportAnimator.AnimatorListener() { 64 | @Override 65 | public void onAnimationStart() { 66 | callback.onRevealStart(); 67 | } 68 | 69 | @Override 70 | public void onAnimationEnd() { 71 | callback.onRevealEnd(); 72 | } 73 | 74 | @Override 75 | public void onAnimationCancel() { 76 | // 77 | } 78 | 79 | @Override 80 | public void onAnimationRepeat() { 81 | // 82 | } 83 | }); 84 | if (transformView.getVisibility() == View.VISIBLE) { 85 | animator.setDuration((int) getRevealAnimationDuration()); 86 | animator.start(); 87 | transformView.setEnabled(true); 88 | } 89 | } 90 | 91 | @Override 92 | final void fabMoveOut(final View fab, final View transformView, final FabAnimationCallback callback) { 93 | ViewPropertyAnimator.animate(fab) 94 | .scaleX(1) 95 | .scaleY(1) 96 | .translationX(0) 97 | .translationY(0) 98 | .setInterpolator(new AccelerateDecelerateInterpolator()) 99 | .setDuration(getFabAnimationDuration()) 100 | .setListener(new Animator.AnimatorListener() { 101 | @Override 102 | public void onAnimationStart(Animator animation) { 103 | callback.onAnimationStart(); 104 | } 105 | 106 | @Override 107 | public void onAnimationEnd(Animator animation) { 108 | callback.onAnimationEnd(); 109 | } 110 | 111 | @Override 112 | public void onAnimationCancel(Animator animation) { 113 | callback.onAnimationCancel(); 114 | } 115 | 116 | @Override 117 | public void onAnimationRepeat(Animator animation) { 118 | callback.onAnimationRepeat(); 119 | } 120 | }) 121 | .start(); 122 | } 123 | 124 | @Override 125 | final void fabMoveIn(final View fab, final View transformView, final FabAnimationCallback callback) { 126 | ViewPropertyAnimator.animate(fab) 127 | .scaleX(FAB_SCALE) 128 | .scaleY(FAB_SCALE) 129 | .translationX(getTranslationX(fab, transformView)) 130 | .translationY(getTranslationY(fab, transformView)) 131 | .setInterpolator(FAB_INTERPOLATOR) 132 | .setDuration(getFabAnimationDuration()) 133 | .setListener(new Animator.AnimatorListener() { 134 | @Override 135 | public void onAnimationStart(Animator animation) { 136 | callback.onAnimationStart(); 137 | } 138 | 139 | @Override 140 | public void onAnimationEnd(Animator animation) { 141 | callback.onAnimationEnd(); 142 | } 143 | 144 | @Override 145 | public void onAnimationCancel(Animator animation) { 146 | callback.onAnimationCancel(); 147 | } 148 | 149 | @Override 150 | public void onAnimationRepeat(Animator animation) { 151 | callback.onAnimationRepeat(); 152 | } 153 | }) 154 | .start(); 155 | } 156 | 157 | @Override 158 | void showOverlay(final View overlay) { 159 | ViewPropertyAnimator.animate(overlay) 160 | .alpha(1) 161 | .setDuration(getRevealAnimationDuration()) 162 | .setInterpolator(OVERLAY_INTERPOLATOR) 163 | .setListener(new AnimatorListenerAdapter() { 164 | @Override 165 | public void onAnimationStart(Animator animation) { 166 | overlay.setVisibility(View.VISIBLE); 167 | } 168 | 169 | @Override 170 | public void onAnimationEnd(Animator animation) { 171 | // 172 | } 173 | }) 174 | .start(); 175 | } 176 | 177 | @Override 178 | void hideOverlay(final View overlay) { 179 | ViewPropertyAnimator.animate(overlay) 180 | .alpha(0) 181 | .setDuration(getRevealAnimationDuration()) 182 | .setInterpolator(OVERLAY_INTERPOLATOR) 183 | .setListener(new AnimatorListenerAdapter() { 184 | @Override 185 | public void onAnimationStart(Animator animation) { 186 | // 187 | } 188 | 189 | @Override 190 | public void onAnimationEnd(Animator animation) { 191 | overlay.setVisibility(View.GONE); 192 | } 193 | }) 194 | .start(); 195 | } 196 | 197 | } 198 | -------------------------------------------------------------------------------- /fab-transformation/src/main/java/com/konifar/fab_transformation/animation/ViewUtil.java: -------------------------------------------------------------------------------- 1 | package com.konifar.fab_transformation.animation; 2 | 3 | import android.view.View; 4 | 5 | public class ViewUtil { 6 | 7 | public static int getRelativeLeft(View view) { 8 | if (view.getParent() == view.getRootView()) 9 | return view.getLeft(); 10 | else 11 | return view.getLeft() + getRelativeLeft((View) view.getParent()); 12 | } 13 | 14 | public static int getRelativeTop(View view) { 15 | if (view.getParent() == view.getRootView()) 16 | return view.getTop(); 17 | else 18 | return view.getTop() + getRelativeTop((View) view.getParent()); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /fab-transformation/src/main/java/io/codetail/animation/RevealAnimator.java: -------------------------------------------------------------------------------- 1 | package io.codetail.animation; 2 | 3 | import android.annotation.TargetApi; 4 | import android.graphics.Rect; 5 | import android.os.Build; 6 | import android.view.View; 7 | 8 | import com.nineoldandroids.animation.Animator; 9 | import com.nineoldandroids.util.FloatProperty; 10 | 11 | import java.lang.ref.WeakReference; 12 | 13 | import static io.codetail.animation.ViewAnimationUtils.SimpleAnimationListener; 14 | 15 | /** 16 | * @hide 17 | */ 18 | public interface RevealAnimator { 19 | 20 | RevealRadius CLIP_RADIUS = new RevealRadius(); 21 | 22 | /** 23 | * Listen when animation start/end/cancel 24 | * and setup view for it 25 | */ 26 | void onRevealAnimationStart(); 27 | 28 | void onRevealAnimationEnd(); 29 | 30 | void onRevealAnimationCancel(); 31 | 32 | /** 33 | * Used with animator to animate view clipping 34 | * 35 | * @return current radius 36 | */ 37 | float getRevealRadius(); 38 | 39 | /** 40 | * Used with animator to animate view clipping 41 | * 42 | * @param value clip radius 43 | */ 44 | void setRevealRadius(float value); 45 | 46 | /** 47 | * Invalidate certain rectangle 48 | * 49 | * @param bounds bounds to redraw 50 | * @see View#invalidate(Rect) 51 | */ 52 | void invalidate(Rect bounds); 53 | 54 | /** 55 | * {@link ViewAnimationUtils#createCircularReveal(View, int, int, float, float)} is 56 | * called it creates new {@link io.codetail.animation.RevealAnimator.RevealInfo} 57 | * and attaches to parent, here is necessary data about animation 58 | * 59 | * @param info reveal information 60 | * @see RevealAnimator.RevealInfo 61 | */ 62 | void attachRevealInfo(RevealInfo info); 63 | 64 | /** 65 | * Returns new {@link SupportAnimator} that plays 66 | * reversed animation of current one 67 | *

68 | * This method might be temporary, you should call 69 | * {@link SupportAnimator#reverse()} instead 70 | * 71 | * @return reverse {@link SupportAnimator} 72 | * @hide 73 | * @see SupportAnimator#reverse() 74 | */ 75 | SupportAnimator startReverseAnimation(); 76 | 77 | class RevealInfo { 78 | public final int centerX; 79 | public final int centerY; 80 | public final float startRadius; 81 | public final float endRadius; 82 | public final WeakReference target; 83 | 84 | public RevealInfo(int centerX, int centerY, float startRadius, float endRadius, 85 | WeakReference target) { 86 | this.centerX = centerX; 87 | this.centerY = centerY; 88 | this.startRadius = startRadius; 89 | this.endRadius = endRadius; 90 | this.target = target; 91 | } 92 | 93 | public View getTarget() { 94 | return target.get(); 95 | } 96 | 97 | public boolean hasTarget() { 98 | return getTarget() != null; 99 | } 100 | } 101 | 102 | class RevealFinishedGingerbread extends SimpleAnimationListener { 103 | WeakReference mReference; 104 | 105 | RevealFinishedGingerbread(RevealAnimator target) { 106 | mReference = new WeakReference<>(target); 107 | } 108 | 109 | @Override 110 | public void onAnimationStart(Animator animation) { 111 | RevealAnimator target = mReference.get(); 112 | target.onRevealAnimationStart(); 113 | } 114 | 115 | @Override 116 | public void onAnimationCancel(Animator animation) { 117 | RevealAnimator target = mReference.get(); 118 | target.onRevealAnimationCancel(); 119 | } 120 | 121 | @Override 122 | public void onAnimationEnd(Animator animation) { 123 | RevealAnimator target = mReference.get(); 124 | target.onRevealAnimationEnd(); 125 | } 126 | } 127 | 128 | @TargetApi(Build.VERSION_CODES.HONEYCOMB) 129 | class RevealFinishedIceCreamSandwich extends RevealFinishedGingerbread { 130 | int mFeaturedLayerType; 131 | int mLayerType; 132 | 133 | RevealFinishedIceCreamSandwich(RevealAnimator target) { 134 | super(target); 135 | 136 | mLayerType = ((View) target).getLayerType(); 137 | mFeaturedLayerType = View.LAYER_TYPE_SOFTWARE; 138 | } 139 | 140 | @Override 141 | public void onAnimationCancel(Animator animation) { 142 | ((View) mReference.get()).setLayerType(mLayerType, null); 143 | super.onAnimationEnd(animation); 144 | } 145 | 146 | @Override 147 | public void onAnimationStart(Animator animation) { 148 | ((View) mReference.get()).setLayerType(mFeaturedLayerType, null); 149 | super.onAnimationStart(animation); 150 | } 151 | 152 | @Override 153 | public void onAnimationEnd(Animator animation) { 154 | ((View) mReference.get()).setLayerType(mLayerType, null); 155 | super.onAnimationEnd(animation); 156 | } 157 | } 158 | 159 | class RevealFinishedJellyBeanMr2 extends RevealFinishedIceCreamSandwich { 160 | 161 | @TargetApi(Build.VERSION_CODES.HONEYCOMB) 162 | RevealFinishedJellyBeanMr2(RevealAnimator target) { 163 | super(target); 164 | 165 | mFeaturedLayerType = View.LAYER_TYPE_HARDWARE; 166 | } 167 | } 168 | 169 | class RevealRadius extends FloatProperty { 170 | 171 | public RevealRadius() { 172 | super("revealRadius"); 173 | } 174 | 175 | @Override 176 | public void setValue(RevealAnimator object, float value) { 177 | object.setRevealRadius(value); 178 | } 179 | 180 | @Override 181 | public Float get(RevealAnimator object) { 182 | return object.getRevealRadius(); 183 | } 184 | } 185 | } -------------------------------------------------------------------------------- /fab-transformation/src/main/java/io/codetail/animation/SupportAnimator.java: -------------------------------------------------------------------------------- 1 | package io.codetail.animation; 2 | 3 | import android.view.animation.Interpolator; 4 | 5 | import java.lang.ref.WeakReference; 6 | 7 | public abstract class SupportAnimator { 8 | 9 | WeakReference mTarget; 10 | 11 | public SupportAnimator(RevealAnimator target) { 12 | mTarget = new WeakReference<>(target); 13 | } 14 | 15 | /** 16 | * @return true if using native android animation framework, otherwise is 17 | * nineoldandroids 18 | */ 19 | public abstract boolean isNativeAnimator(); 20 | 21 | /** 22 | * @return depends from {@link android.os.Build.VERSION} if sdk version 23 | * {@link android.os.Build.VERSION_CODES#LOLLIPOP} and greater will return 24 | * {@link android.animation.Animator} otherwise {@link com.nineoldandroids.animation.Animator} 25 | */ 26 | public abstract Object get(); 27 | 28 | /** 29 | * Starts this animation. If the animation has a nonzero startDelay, the animation will start 30 | * running after that delay elapses. A non-delayed animation will have its initial 31 | * value(s) set immediately, followed by calls to 32 | * {@link android.animation.Animator.AnimatorListener#onAnimationStart(android.animation.Animator)} 33 | * for any listeners of this animator. 34 | *

35 | *

The animation started by calling this method will be run on the thread that called 36 | * this method. This thread should have a Looper on it (a runtime exception will be thrown if 37 | * this is not the case). Also, if the animation will animate 38 | * properties of objects in the view hierarchy, then the calling thread should be the UI 39 | * thread for that view hierarchy.

40 | */ 41 | public abstract void start(); 42 | 43 | /** 44 | * Sets the duration of the animation. 45 | * 46 | * @param duration The length of the animation, in milliseconds. 47 | */ 48 | public abstract void setDuration(int duration); 49 | 50 | /** 51 | * The time interpolator used in calculating the elapsed fraction of the 52 | * animation. The interpolator determines whether the animation runs with 53 | * linear or non-linear motion, such as acceleration and deceleration. The 54 | * default value is {@link android.view.animation.AccelerateDecelerateInterpolator}. 55 | * 56 | * @param value the interpolator to be used by this animation 57 | */ 58 | public abstract void setInterpolator(Interpolator value); 59 | 60 | 61 | /** 62 | * Adds a listener to the set of listeners that are sent events through the life of an 63 | * animation, such as start, repeat, and end. 64 | * 65 | * @param listener the listener to be added to the current set of listeners for this animation. 66 | */ 67 | public abstract void addListener(AnimatorListener listener); 68 | 69 | 70 | /** 71 | * Returns whether this Animator is currently running (having been started and gone past any 72 | * initial startDelay period and not yet ended). 73 | * 74 | * @return Whether the Animator is running. 75 | */ 76 | public abstract boolean isRunning(); 77 | 78 | 79 | /** 80 | * Cancels the animation. Unlike {@link #end()}, cancel() causes the animation to 81 | * stop in its tracks, sending an 82 | * {@link AnimatorListener#onAnimationCancel()} to 83 | * its listeners, followed by an 84 | * {@link AnimatorListener#onAnimationEnd()} message. 85 | *

86 | *

This method must be called on the thread that is running the animation.

87 | */ 88 | public abstract void cancel(); 89 | 90 | /** 91 | * Ends the animation. This causes the animation to assign the end value of the property being 92 | * animated, then calling the 93 | * {@link AnimatorListener#onAnimationEnd()} method on 94 | * its listeners. 95 | *

96 | *

This method must be called on the thread that is running the animation.

97 | */ 98 | public void end() { 99 | } 100 | 101 | /** 102 | * This method tells the object to use appropriate information to extract 103 | * starting values for the animation. For example, a AnimatorSet object will pass 104 | * this call to its child objects to tell them to set up the values. A 105 | * ObjectAnimator object will use the information it has about its target object 106 | * and PropertyValuesHolder objects to get the start values for its properties. 107 | * A ValueAnimator object will ignore the request since it does not have enough 108 | * information (such as a target object) to gather these values. 109 | */ 110 | public void setupStartValues() { 111 | } 112 | 113 | /** 114 | * This method tells the object to use appropriate information to extract 115 | * ending values for the animation. For example, a AnimatorSet object will pass 116 | * this call to its child objects to tell them to set up the values. A 117 | * ObjectAnimator object will use the information it has about its target object 118 | * and PropertyValuesHolder objects to get the start values for its properties. 119 | * A ValueAnimator object will ignore the request since it does not have enough 120 | * information (such as a target object) to gather these values. 121 | */ 122 | public void setupEndValues() { 123 | } 124 | 125 | /** 126 | * Experimental feature 127 | */ 128 | public SupportAnimator reverse() { 129 | if (isRunning()) { 130 | return null; 131 | } 132 | 133 | RevealAnimator target = mTarget.get(); 134 | if (target != null) { 135 | return target.startReverseAnimation(); 136 | } 137 | 138 | return null; 139 | } 140 | 141 | /** 142 | *

An animation listener receives notifications from an animation. 143 | * Notifications indicate animation related events, such as the end or the 144 | * repetition of the animation.

145 | */ 146 | public interface AnimatorListener { 147 | /** 148 | *

Notifies the start of the animation.

149 | */ 150 | void onAnimationStart(); 151 | 152 | /** 153 | *

Notifies the end of the animation. This callback is not invoked 154 | * for animations with repeat count set to INFINITE.

155 | */ 156 | void onAnimationEnd(); 157 | 158 | /** 159 | *

Notifies the cancellation of the animation. This callback is not invoked 160 | * for animations with repeat count set to INFINITE.

161 | */ 162 | void onAnimationCancel(); 163 | 164 | /** 165 | *

Notifies the repetition of the animation.

166 | */ 167 | void onAnimationRepeat(); 168 | } 169 | 170 | /** 171 | *

Provides default implementation for AnimatorListener.

172 | */ 173 | public static abstract class SimpleAnimatorListener implements AnimatorListener { 174 | 175 | @Override 176 | public void onAnimationStart() { 177 | 178 | } 179 | 180 | @Override 181 | public void onAnimationEnd() { 182 | 183 | } 184 | 185 | @Override 186 | public void onAnimationCancel() { 187 | 188 | } 189 | 190 | @Override 191 | public void onAnimationRepeat() { 192 | 193 | } 194 | } 195 | 196 | } 197 | -------------------------------------------------------------------------------- /fab-transformation/src/main/java/io/codetail/animation/SupportAnimatorLollipop.java: -------------------------------------------------------------------------------- 1 | package io.codetail.animation; 2 | 3 | import android.animation.Animator; 4 | import android.annotation.TargetApi; 5 | import android.os.Build; 6 | import android.view.animation.Interpolator; 7 | 8 | import java.lang.ref.WeakReference; 9 | 10 | @TargetApi(Build.VERSION_CODES.HONEYCOMB) 11 | final class SupportAnimatorLollipop extends SupportAnimator { 12 | 13 | WeakReference mAnimator; 14 | 15 | SupportAnimatorLollipop(Animator animator, RevealAnimator target) { 16 | super(target); 17 | mAnimator = new WeakReference<>(animator); 18 | } 19 | 20 | @Override 21 | public boolean isNativeAnimator() { 22 | return true; 23 | } 24 | 25 | @Override 26 | public Object get() { 27 | return mAnimator.get(); 28 | } 29 | 30 | 31 | @Override 32 | public void start() { 33 | Animator a = mAnimator.get(); 34 | if (a != null) { 35 | a.start(); 36 | } 37 | } 38 | 39 | @Override 40 | public void setDuration(int duration) { 41 | Animator a = mAnimator.get(); 42 | if (a != null) { 43 | a.setDuration(duration); 44 | } 45 | } 46 | 47 | @Override 48 | public void setInterpolator(Interpolator value) { 49 | Animator a = mAnimator.get(); 50 | if (a != null) { 51 | a.setInterpolator(value); 52 | } 53 | } 54 | 55 | @Override 56 | public void addListener(final AnimatorListener listener) { 57 | Animator a = mAnimator.get(); 58 | if (a == null) { 59 | return; 60 | } 61 | 62 | if (listener == null) { 63 | a.addListener(null); 64 | return; 65 | } 66 | 67 | a.addListener(new Animator.AnimatorListener() { 68 | @Override 69 | public void onAnimationStart(Animator animation) { 70 | listener.onAnimationStart(); 71 | } 72 | 73 | @Override 74 | public void onAnimationEnd(Animator animation) { 75 | listener.onAnimationEnd(); 76 | } 77 | 78 | @Override 79 | public void onAnimationCancel(Animator animation) { 80 | listener.onAnimationCancel(); 81 | } 82 | 83 | @Override 84 | public void onAnimationRepeat(Animator animation) { 85 | listener.onAnimationRepeat(); 86 | } 87 | }); 88 | } 89 | 90 | @Override 91 | public boolean isRunning() { 92 | Animator a = mAnimator.get(); 93 | return a != null && a.isRunning(); 94 | } 95 | 96 | @Override 97 | public void cancel() { 98 | Animator a = mAnimator.get(); 99 | if (a != null) { 100 | a.cancel(); 101 | } 102 | } 103 | 104 | @Override 105 | public void end() { 106 | Animator a = mAnimator.get(); 107 | if (a != null) { 108 | a.end(); 109 | } 110 | } 111 | 112 | @Override 113 | public void setupStartValues() { 114 | Animator a = mAnimator.get(); 115 | if (a != null) { 116 | a.setupStartValues(); 117 | } 118 | } 119 | 120 | @Override 121 | public void setupEndValues() { 122 | Animator a = mAnimator.get(); 123 | if (a != null) { 124 | a.setupEndValues(); 125 | } 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /fab-transformation/src/main/java/io/codetail/animation/SupportAnimatorPreL.java: -------------------------------------------------------------------------------- 1 | package io.codetail.animation; 2 | 3 | import android.view.animation.Interpolator; 4 | 5 | import com.nineoldandroids.animation.Animator; 6 | 7 | import java.lang.ref.WeakReference; 8 | 9 | final class SupportAnimatorPreL extends SupportAnimator { 10 | 11 | WeakReference mAnimator; 12 | 13 | SupportAnimatorPreL(Animator animator, RevealAnimator target) { 14 | super(target); 15 | mAnimator = new WeakReference<>(animator); 16 | } 17 | 18 | @Override 19 | public boolean isNativeAnimator() { 20 | return false; 21 | } 22 | 23 | @Override 24 | public Object get() { 25 | return mAnimator.get(); 26 | } 27 | 28 | @Override 29 | public void start() { 30 | Animator a = mAnimator.get(); 31 | if (a != null) { 32 | a.start(); 33 | } 34 | } 35 | 36 | @Override 37 | public void setDuration(int duration) { 38 | Animator a = mAnimator.get(); 39 | if (a != null) { 40 | a.setDuration(duration); 41 | } 42 | } 43 | 44 | @Override 45 | public void setInterpolator(Interpolator value) { 46 | Animator a = mAnimator.get(); 47 | if (a != null) { 48 | a.setInterpolator(value); 49 | } 50 | } 51 | 52 | @Override 53 | public void addListener(final AnimatorListener listener) { 54 | Animator a = mAnimator.get(); 55 | if (a == null) { 56 | return; 57 | } 58 | 59 | if (listener == null) { 60 | a.addListener(null); 61 | return; 62 | } 63 | 64 | a.addListener(new Animator.AnimatorListener() { 65 | @Override 66 | public void onAnimationStart(Animator animation) { 67 | listener.onAnimationStart(); 68 | } 69 | 70 | @Override 71 | public void onAnimationEnd(Animator animation) { 72 | listener.onAnimationEnd(); 73 | } 74 | 75 | @Override 76 | public void onAnimationCancel(Animator animation) { 77 | listener.onAnimationCancel(); 78 | } 79 | 80 | @Override 81 | public void onAnimationRepeat(Animator animation) { 82 | listener.onAnimationRepeat(); 83 | } 84 | }); 85 | } 86 | 87 | @Override 88 | public boolean isRunning() { 89 | Animator a = mAnimator.get(); 90 | return a != null && a.isRunning(); 91 | } 92 | 93 | @Override 94 | public void cancel() { 95 | Animator a = mAnimator.get(); 96 | if (a != null) { 97 | a.cancel(); 98 | } 99 | } 100 | 101 | @Override 102 | public void end() { 103 | Animator a = mAnimator.get(); 104 | if (a != null) { 105 | a.end(); 106 | } 107 | } 108 | 109 | @Override 110 | public void setupStartValues() { 111 | Animator a = mAnimator.get(); 112 | if (a != null) { 113 | a.setupStartValues(); 114 | } 115 | } 116 | 117 | @Override 118 | public void setupEndValues() { 119 | Animator a = mAnimator.get(); 120 | if (a != null) { 121 | a.setupEndValues(); 122 | } 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /fab-transformation/src/main/java/io/codetail/animation/ViewAnimationUtils.java: -------------------------------------------------------------------------------- 1 | package io.codetail.animation; 2 | 3 | import android.annotation.TargetApi; 4 | import android.os.Build; 5 | import android.view.View; 6 | import android.view.animation.AccelerateDecelerateInterpolator; 7 | 8 | import com.nineoldandroids.animation.Animator; 9 | import com.nineoldandroids.animation.ObjectAnimator; 10 | import com.nineoldandroids.view.ViewHelper; 11 | import com.nineoldandroids.view.ViewPropertyAnimator; 12 | 13 | import java.lang.ref.WeakReference; 14 | 15 | import io.codetail.animation.RevealAnimator.RevealInfo; 16 | 17 | import static android.os.Build.VERSION.SDK_INT; 18 | import static android.os.Build.VERSION_CODES.LOLLIPOP; 19 | import static io.codetail.animation.RevealAnimator.CLIP_RADIUS; 20 | 21 | public class ViewAnimationUtils { 22 | 23 | public static final int SCALE_UP_DURATION = 500; 24 | private final static boolean LOLLIPOP_PLUS = SDK_INT >= LOLLIPOP; 25 | 26 | /** 27 | * Returns an Animator which can animate a clipping circle. 28 | *

29 | * Any shadow cast by the View will respect the circular clip from this animator. 30 | *

31 | * Only a single non-rectangular clip can be applied on a View at any time. 32 | * Views clipped by a circular reveal animation take priority over 33 | * {@link View#setClipToOutline(boolean) View Outline clipping}. 34 | *

35 | * Note that the animation returned here is a one-shot animation. It cannot 36 | * be re-used, and once started it cannot be paused or resumed. 37 | * 38 | * @param view The View will be clipped to the animating circle. 39 | * @param centerX The x coordinate of the center of the animating circle. 40 | * @param centerY The y coordinate of the center of the animating circle. 41 | * @param startRadius The starting radius of the animating circle. 42 | * @param endRadius The ending radius of the animating circle. 43 | */ 44 | @TargetApi(Build.VERSION_CODES.LOLLIPOP) 45 | public static SupportAnimator createCircularReveal(View view, 46 | int centerX, int centerY, 47 | float startRadius, float endRadius) { 48 | 49 | if (!(view.getParent() instanceof RevealAnimator)) { 50 | throw new IllegalArgumentException("View must be inside RevealFrameLayout or RevealLinearLayout."); 51 | } 52 | 53 | RevealAnimator revealLayout = (RevealAnimator) view.getParent(); 54 | revealLayout.attachRevealInfo(new RevealInfo(centerX, centerY, startRadius, endRadius, 55 | new WeakReference<>(view))); 56 | 57 | if (LOLLIPOP_PLUS) { 58 | return new SupportAnimatorLollipop(android.view.ViewAnimationUtils 59 | .createCircularReveal(view, centerX, centerY, startRadius, endRadius), revealLayout); 60 | } 61 | 62 | ObjectAnimator reveal = ObjectAnimator.ofFloat(revealLayout, CLIP_RADIUS, 63 | startRadius, endRadius); 64 | reveal.addListener(getRevealFinishListener(revealLayout)); 65 | 66 | return new SupportAnimatorPreL(reveal, revealLayout); 67 | } 68 | 69 | private static Animator.AnimatorListener getRevealFinishListener(RevealAnimator target) { 70 | if (SDK_INT >= 18) { 71 | return new RevealAnimator.RevealFinishedJellyBeanMr2(target); 72 | } else if (SDK_INT >= 14) { 73 | return new RevealAnimator.RevealFinishedIceCreamSandwich(target); 74 | } else { 75 | return new RevealAnimator.RevealFinishedGingerbread(target); 76 | } 77 | } 78 | 79 | /** 80 | * Lifting view 81 | * 82 | * @param view The animation target 83 | * @param baseRotation initial Rotation X in 3D space 84 | * @param fromY initial Y position of view 85 | * @param duration aniamtion duration 86 | * @param startDelay start delay before animation begin 87 | */ 88 | @Deprecated 89 | public static void liftingFromBottom(View view, float baseRotation, float fromY, int duration, int startDelay) { 90 | ViewHelper.setRotationX(view, baseRotation); 91 | ViewHelper.setTranslationY(view, fromY); 92 | 93 | ViewPropertyAnimator 94 | .animate(view) 95 | .setInterpolator(new AccelerateDecelerateInterpolator()) 96 | .setDuration(duration) 97 | .setStartDelay(startDelay) 98 | .rotationX(0) 99 | .translationY(0) 100 | .start(); 101 | 102 | } 103 | 104 | /** 105 | * Lifting view 106 | * 107 | * @param view The animation target 108 | * @param baseRotation initial Rotation X in 3D space 109 | * @param duration aniamtion duration 110 | * @param startDelay start delay before animation begin 111 | */ 112 | @Deprecated 113 | public static void liftingFromBottom(View view, float baseRotation, int duration, int startDelay) { 114 | ViewHelper.setRotationX(view, baseRotation); 115 | ViewHelper.setTranslationY(view, view.getHeight() / 3); 116 | 117 | ViewPropertyAnimator 118 | .animate(view) 119 | .setInterpolator(new AccelerateDecelerateInterpolator()) 120 | .setDuration(duration) 121 | .setStartDelay(startDelay) 122 | .rotationX(0) 123 | .translationY(0) 124 | .start(); 125 | 126 | } 127 | 128 | /** 129 | * Lifting view 130 | * 131 | * @param view The animation target 132 | * @param baseRotation initial Rotation X in 3D space 133 | * @param duration aniamtion duration 134 | */ 135 | @Deprecated 136 | public static void liftingFromBottom(View view, float baseRotation, int duration) { 137 | ViewHelper.setRotationX(view, baseRotation); 138 | ViewHelper.setTranslationY(view, view.getHeight() / 3); 139 | 140 | ViewPropertyAnimator 141 | .animate(view) 142 | .setInterpolator(new AccelerateDecelerateInterpolator()) 143 | .setDuration(duration) 144 | .rotationX(0) 145 | .translationY(0) 146 | .start(); 147 | 148 | } 149 | 150 | static class SimpleAnimationListener implements Animator.AnimatorListener { 151 | 152 | @Override 153 | public void onAnimationStart(Animator animation) { 154 | 155 | } 156 | 157 | @Override 158 | public void onAnimationEnd(Animator animation) { 159 | 160 | } 161 | 162 | @Override 163 | public void onAnimationCancel(Animator animation) { 164 | 165 | } 166 | 167 | @Override 168 | public void onAnimationRepeat(Animator animation) { 169 | 170 | } 171 | } 172 | 173 | } 174 | -------------------------------------------------------------------------------- /fab-transformation/src/main/java/io/codetail/widget/RevealFrameLayout.java: -------------------------------------------------------------------------------- 1 | package io.codetail.widget; 2 | 3 | import android.content.Context; 4 | import android.graphics.Canvas; 5 | import android.graphics.Path; 6 | import android.graphics.Rect; 7 | import android.util.AttributeSet; 8 | import android.view.View; 9 | import android.widget.FrameLayout; 10 | 11 | import io.codetail.animation.RevealAnimator; 12 | import io.codetail.animation.SupportAnimator; 13 | import io.codetail.animation.ViewAnimationUtils; 14 | 15 | public class RevealFrameLayout extends FrameLayout implements RevealAnimator { 16 | 17 | private final Rect mTargetBounds = new Rect(); 18 | private Path mRevealPath; 19 | private RevealInfo mRevealInfo; 20 | private boolean mRunning; 21 | private float mRadius; 22 | 23 | public RevealFrameLayout(Context context) { 24 | this(context, null); 25 | } 26 | 27 | public RevealFrameLayout(Context context, AttributeSet attrs) { 28 | this(context, attrs, 0); 29 | } 30 | 31 | public RevealFrameLayout(Context context, AttributeSet attrs, int defStyle) { 32 | super(context, attrs, defStyle); 33 | mRevealPath = new Path(); 34 | } 35 | 36 | @Override 37 | public void onRevealAnimationStart() { 38 | mRunning = true; 39 | } 40 | 41 | @Override 42 | public void onRevealAnimationEnd() { 43 | mRunning = false; 44 | invalidate(mTargetBounds); 45 | } 46 | 47 | @Override 48 | public void onRevealAnimationCancel() { 49 | onRevealAnimationEnd(); 50 | } 51 | 52 | /** 53 | * Circle radius size 54 | * 55 | * @hide 56 | */ 57 | @Override 58 | public float getRevealRadius() { 59 | return mRadius; 60 | } 61 | 62 | /** 63 | * Circle radius size 64 | * 65 | * @hide 66 | */ 67 | @Override 68 | public void setRevealRadius(float radius) { 69 | mRadius = radius; 70 | invalidate(mTargetBounds); 71 | } 72 | 73 | /** 74 | * @hide 75 | */ 76 | @Override 77 | public void attachRevealInfo(RevealInfo info) { 78 | info.getTarget().getHitRect(mTargetBounds); 79 | mRevealInfo = info; 80 | } 81 | 82 | /** 83 | * @hide 84 | */ 85 | @Override 86 | public SupportAnimator startReverseAnimation() { 87 | if (mRevealInfo != null && mRevealInfo.hasTarget() && !mRunning) { 88 | return ViewAnimationUtils.createCircularReveal(mRevealInfo.getTarget(), 89 | mRevealInfo.centerX, mRevealInfo.centerY, 90 | mRevealInfo.endRadius, mRevealInfo.startRadius); 91 | } 92 | return null; 93 | } 94 | 95 | @Override 96 | protected boolean drawChild(Canvas canvas, View child, long drawingTime) { 97 | if (mRunning && child == mRevealInfo.getTarget()) { 98 | final int state = canvas.save(); 99 | 100 | mRevealPath.reset(); 101 | mRevealPath.addCircle(mRevealInfo.centerX, mRevealInfo.centerY, mRadius, Path.Direction.CW); 102 | 103 | canvas.clipPath(mRevealPath); 104 | 105 | boolean isInvalided = super.drawChild(canvas, child, drawingTime); 106 | 107 | canvas.restoreToCount(state); 108 | 109 | return isInvalided; 110 | } 111 | 112 | return super.drawChild(canvas, child, drawingTime); 113 | } 114 | 115 | } 116 | -------------------------------------------------------------------------------- /fab-transformation/src/main/java/io/codetail/widget/RevealLinearLayout.java: -------------------------------------------------------------------------------- 1 | package io.codetail.widget; 2 | 3 | import android.content.Context; 4 | import android.graphics.Canvas; 5 | import android.graphics.Path; 6 | import android.graphics.Rect; 7 | import android.util.AttributeSet; 8 | import android.view.View; 9 | import android.widget.LinearLayout; 10 | 11 | import io.codetail.animation.RevealAnimator; 12 | import io.codetail.animation.SupportAnimator; 13 | import io.codetail.animation.ViewAnimationUtils; 14 | 15 | public class RevealLinearLayout extends LinearLayout implements RevealAnimator { 16 | 17 | private final Rect mTargetBounds = new Rect(); 18 | private Path mRevealPath; 19 | private RevealInfo mRevealInfo; 20 | private boolean mRunning; 21 | private float mRadius; 22 | 23 | public RevealLinearLayout(Context context) { 24 | this(context, null); 25 | } 26 | 27 | public RevealLinearLayout(Context context, AttributeSet attrs) { 28 | this(context, attrs, 0); 29 | } 30 | 31 | public RevealLinearLayout(Context context, AttributeSet attrs, int defStyle) { 32 | super(context, attrs); 33 | mRevealPath = new Path(); 34 | } 35 | 36 | @Override 37 | public void onRevealAnimationStart() { 38 | mRunning = true; 39 | } 40 | 41 | @Override 42 | public void onRevealAnimationEnd() { 43 | mRunning = false; 44 | invalidate(mTargetBounds); 45 | } 46 | 47 | @Override 48 | public void onRevealAnimationCancel() { 49 | onRevealAnimationEnd(); 50 | } 51 | 52 | /** 53 | * Circle radius size 54 | * 55 | * @hide 56 | */ 57 | @Override 58 | public float getRevealRadius() { 59 | return mRadius; 60 | } 61 | 62 | /** 63 | * Circle radius size 64 | * 65 | * @hide 66 | */ 67 | @Override 68 | public void setRevealRadius(float radius) { 69 | mRadius = radius; 70 | invalidate(mTargetBounds); 71 | } 72 | 73 | /** 74 | * @hide 75 | */ 76 | @Override 77 | public void attachRevealInfo(RevealInfo info) { 78 | info.getTarget().getHitRect(mTargetBounds); 79 | mRevealInfo = info; 80 | } 81 | 82 | /** 83 | * @hide 84 | */ 85 | @Override 86 | public SupportAnimator startReverseAnimation() { 87 | if (mRevealInfo != null && mRevealInfo.hasTarget() && !mRunning) { 88 | return ViewAnimationUtils.createCircularReveal(mRevealInfo.getTarget(), 89 | mRevealInfo.centerX, mRevealInfo.centerY, 90 | mRevealInfo.endRadius, mRevealInfo.startRadius); 91 | } 92 | return null; 93 | } 94 | 95 | @Override 96 | protected boolean drawChild(Canvas canvas, View child, long drawingTime) { 97 | if (mRunning && child == mRevealInfo.getTarget()) { 98 | final int state = canvas.save(); 99 | 100 | mRevealPath.reset(); 101 | mRevealPath.addCircle(mRevealInfo.centerX, mRevealInfo.centerY, mRadius, Path.Direction.CW); 102 | 103 | canvas.clipPath(mRevealPath); 104 | 105 | boolean isInvalided = super.drawChild(canvas, child, drawingTime); 106 | 107 | canvas.restoreToCount(state); 108 | 109 | return isInvalided; 110 | } 111 | 112 | return super.drawChild(canvas, child, drawingTime); 113 | } 114 | 115 | } 116 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | VERSION_NAME=1.0.0 2 | VERSION_CODE=4 3 | GROUP=com.konifar 4 | ARTIFACT_ID=fab-transformation 5 | 6 | COMPILE_SDK_VERSION=22 7 | BUILD_TOOLS_VERSION=22.0.1 8 | TARGET_SDK_VERSION=22 9 | RENDERSCRIPT_TARGET_API=22 10 | MIN_SDK_VERSION=9 11 | 12 | POM_DESCRIPTION=Support Floating Action Button transformation for Android 13 | POM_URL=https://github.com/konifar/fab-transformation 14 | POM_SCM_URL=git@github.com:konifar/fab-transformation.git 15 | POM_SCM_CONNECTION=git@github.com:konifar/fab-transformation.git 16 | POM_SCM_DEV_CONNECTION=scm:git@github.com:konifar/fab-transformation.git 17 | POM_LICENCE_NAME=The MIT License 18 | POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt 19 | POM_LICENCE_DIST=repo 20 | POM_DEVELOPER_ID=konifar 21 | POM_DEVELOPER_NAME=konifar 22 | POM_DEVELOPER_EMAIL=yahpeycoy0403@gmail.com 23 | POM_DEVELOPER_URL=konifar.com 24 | ISSUE_URL=https://github.com/konifar/fab-transformation/issues 25 | 26 | SUPPORT_PACKAGE_VERSION=22.2.1 27 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/konifar/fab-transformation/fd176bfff9c5ad4fc6bad28ffec77cbdaf4089d5/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Nov 29 21:12:05 CST 2016 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':fab-transformation', ':example' 2 | --------------------------------------------------------------------------------