├── .gitignore ├── .idea └── libraries │ └── gridlayout_v7_23_1_1.xml ├── LICENSE ├── README.md ├── UI-Motion.iml ├── app ├── .gitignore ├── app.iml ├── build.gradle ├── proguard-rules.pro ├── settings.gradle └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── example │ │ └── andremion │ │ └── uimotion │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── ic_launcher-web.png │ ├── java │ └── com │ │ └── example │ │ └── andremion │ │ └── uimotion │ │ ├── DetailActivity.java │ │ ├── MainActivity.java │ │ ├── PictureView.java │ │ ├── SharingActivity.java │ │ └── TransitionAdapter.java │ └── res │ ├── drawable-xxhdpi │ ├── chrysanthemum.jpg │ ├── desert.jpg │ ├── hydrangeas.jpg │ ├── ic_facebook.png │ ├── ic_instagram.png │ ├── ic_share_white_24dp.png │ ├── ic_twitter.png │ ├── jellyfish.jpg │ ├── penguins.jpg │ └── tulips.jpg │ ├── drawable │ └── sharing_bg.xml │ ├── layout │ ├── activity_detail.xml │ ├── activity_main.xml │ └── activity_sharing.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 │ ├── transition │ ├── detail_enter.xml │ ├── main_exit.xml │ ├── main_reenter.xml │ ├── sharing_item_chosen.xml │ └── sharing_shared_element_enter.xml │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── integers.xml │ ├── strings.xml │ └── styles.xml ├── assets ├── detail.png ├── detail_to_sharing.gif ├── item_share_click.gif ├── main.png ├── main_to_detail.gif ├── post_head.jpg ├── preview.gif └── sharing.png ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | 15 | # Gradle files 16 | .gradle/ 17 | build/ 18 | /*/build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | -------------------------------------------------------------------------------- /.idea/libraries/gridlayout_v7_23_1_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![#AndroidDev Digest #110](https://img.shields.io/badge/AndroidDev%20Digest-%23110-blue.svg)](https://www.androiddevdigest.com/digest-110/) 2 | 3 | # Applying meaningful motion on Android 4 | 5 | ![Preview](https://github.com/andremion/UI-Motion/raw/master/assets/preview.gif) 6 | 7 | ### How to apply meaningful and delightful motion in a sample Android app 8 | 9 | Read the complete post at https://medium.com/@andremion/applying-meaningful-motion-on-android-a271a873bd78#.734xmwqk9 10 | -------------------------------------------------------------------------------- /UI-Motion.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/app.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.2" 6 | 7 | defaultConfig { 8 | applicationId "com.example.andremion.uimotion" 9 | minSdkVersion 21 10 | targetSdkVersion 23 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(include: ['*.jar'], dir: 'libs') 24 | compile 'com.android.support:design:23.1.1' 25 | compile 'com.android.support:gridlayout-v7:23.1.1' 26 | compile 'com.android.support:cardview-v7:23.1.1' 27 | } 28 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:\Users\alor\Documents\development\android\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/example/andremion/uimotion/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.example.andremion.uimotion; 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 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 23 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andremion/UI-Motion/878703c83eb8803afb3876e01d7f1e1b97cb535c/app/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /app/src/main/java/com/example/andremion/uimotion/DetailActivity.java: -------------------------------------------------------------------------------- 1 | package com.example.andremion.uimotion; 2 | 3 | import android.animation.Animator; 4 | import android.animation.AnimatorListenerAdapter; 5 | import android.app.ActivityOptions; 6 | import android.content.Context; 7 | import android.content.Intent; 8 | import android.os.Bundle; 9 | import android.support.design.widget.CollapsingToolbarLayout; 10 | import android.support.design.widget.CoordinatorLayout; 11 | import android.support.design.widget.FloatingActionButton; 12 | import android.support.v7.app.AppCompatActivity; 13 | import android.support.v7.widget.Toolbar; 14 | import android.transition.Transition; 15 | import android.util.AttributeSet; 16 | import android.view.View; 17 | import android.widget.ImageView; 18 | 19 | public class DetailActivity extends AppCompatActivity { 20 | 21 | static final String EXTRA_PICTURE = DetailActivity.class.getPackage() + ".extra.PICTURE"; 22 | static final String EXTRA_TITLE = DetailActivity.class.getPackage() + ".extra.TITLE"; 23 | 24 | private View mShareButton; 25 | 26 | @Override 27 | protected void onCreate(Bundle savedInstanceState) { 28 | super.onCreate(savedInstanceState); 29 | setContentView(R.layout.activity_detail); 30 | setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); 31 | 32 | int picture = getIntent().getExtras().getInt(EXTRA_PICTURE); 33 | CharSequence title = getIntent().getExtras().getCharSequence(EXTRA_TITLE); 34 | 35 | CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); 36 | collapsingToolbarLayout.setTitle(title); 37 | 38 | ImageView pictureView = (ImageView) findViewById(R.id.picture); 39 | pictureView.setImageResource(picture); 40 | pictureView.setContentDescription(title); 41 | 42 | mShareButton = findViewById(R.id.share_button); 43 | 44 | if (savedInstanceState == null) { 45 | mShareButton.setScaleX(0); 46 | mShareButton.setScaleY(0); 47 | getWindow().getEnterTransition().addListener(new TransitionAdapter() { 48 | @Override 49 | public void onTransitionEnd(Transition transition) { 50 | getWindow().getEnterTransition().removeListener(this); 51 | mShareButton.animate().scaleX(1).scaleY(1); 52 | } 53 | }); 54 | } 55 | } 56 | 57 | @Override 58 | public void onBackPressed() { 59 | mShareButton.animate().scaleX(0).scaleY(0).setListener(new AnimatorListenerAdapter() { 60 | @Override 61 | public void onAnimationEnd(Animator animation) { 62 | supportFinishAfterTransition(); 63 | } 64 | }); 65 | } 66 | 67 | public void shareClick(View view) { 68 | ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(this, 69 | mShareButton, getString(R.string.share_transition_name)); 70 | Intent intent = new Intent(this, SharingActivity.class); 71 | startActivity(intent, options.toBundle()); 72 | } 73 | 74 | public static class CustomFloatingActionButtonBehavior extends FloatingActionButton.Behavior { 75 | 76 | public CustomFloatingActionButtonBehavior(Context context, AttributeSet attrs) { 77 | super(); 78 | } 79 | 80 | @Override 81 | public boolean onLayoutChild(CoordinatorLayout parent, FloatingActionButton child, int layoutDirection) { 82 | // Prevent the FAB disappears when return from called Activity 83 | return false; 84 | } 85 | 86 | } 87 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/andremion/uimotion/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.example.andremion.uimotion; 2 | 3 | import android.app.ActivityOptions; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.view.View; 8 | 9 | public class MainActivity extends AppCompatActivity { 10 | 11 | @Override 12 | protected void onCreate(Bundle savedInstanceState) { 13 | super.onCreate(savedInstanceState); 14 | setContentView(R.layout.activity_main); 15 | } 16 | 17 | public void pictureClick(View view) { 18 | // Create an object containing information about our scene transition animation 19 | ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(this, 20 | view, getString(R.string.picture_transition_name)); 21 | PictureView pictureView = (PictureView) view; 22 | int picture = pictureView.getImageResource(); 23 | CharSequence title = view.getContentDescription(); 24 | // Pass information to Detail Activity in order to show the chosen image and its details 25 | Intent intent = new Intent(this, DetailActivity.class); 26 | intent.putExtra(DetailActivity.EXTRA_PICTURE, picture); 27 | intent.putExtra(DetailActivity.EXTRA_TITLE, title); 28 | startActivity(intent, options.toBundle()); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/andremion/uimotion/PictureView.java: -------------------------------------------------------------------------------- 1 | package com.example.andremion.uimotion; 2 | 3 | import android.content.Context; 4 | import android.support.annotation.Nullable; 5 | import android.util.AttributeSet; 6 | import android.widget.ImageView; 7 | 8 | public class PictureView extends ImageView { 9 | 10 | private int mResId; 11 | 12 | public PictureView(Context context) { 13 | this(context, null, 0); 14 | } 15 | 16 | public PictureView(Context context, @Nullable AttributeSet attrs) { 17 | this(context, attrs, 0); 18 | } 19 | 20 | public PictureView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { 21 | super(context, attrs, defStyleAttr); 22 | if (attrs != null) { 23 | final String namespace = "http://schemas.android.com/apk/res/android"; 24 | final String attribute = "src"; 25 | mResId = attrs.getAttributeResourceValue(namespace, attribute, 0); 26 | } 27 | } 28 | 29 | public int getImageResource() { 30 | return mResId; 31 | } 32 | 33 | @Override 34 | public void setImageResource(int resId) { 35 | super.setImageResource(resId); 36 | mResId = resId; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/andremion/uimotion/SharingActivity.java: -------------------------------------------------------------------------------- 1 | package com.example.andremion.uimotion; 2 | 3 | import android.animation.Animator; 4 | import android.animation.AnimatorListenerAdapter; 5 | import android.graphics.Matrix; 6 | import android.os.Bundle; 7 | import android.support.v7.app.AppCompatActivity; 8 | import android.transition.Transition; 9 | import android.transition.TransitionInflater; 10 | import android.transition.TransitionManager; 11 | import android.view.View; 12 | import android.view.ViewAnimationUtils; 13 | import android.view.ViewGroup; 14 | import android.view.animation.AccelerateInterpolator; 15 | import android.view.animation.DecelerateInterpolator; 16 | import android.widget.ImageView; 17 | import android.widget.RelativeLayout; 18 | 19 | public class SharingActivity extends AppCompatActivity { 20 | 21 | private int mDefaultAnimDuration; 22 | 23 | private ViewGroup mRootView; 24 | private ImageView mBackgroundView; 25 | private View[] mItemViews; 26 | 27 | @Override 28 | protected void onCreate(Bundle savedInstanceState) { 29 | super.onCreate(savedInstanceState); 30 | setContentView(R.layout.activity_sharing); 31 | 32 | mDefaultAnimDuration = getResources().getInteger(R.integer.default_anim_duration); 33 | 34 | // Find view references 35 | mRootView = (ViewGroup) findViewById(R.id.content_root); 36 | mBackgroundView = (ImageView) findViewById(R.id.background); 37 | mItemViews = new View[]{findViewById(R.id.facebook), findViewById(R.id.google_plus), 38 | findViewById(R.id.instagram), findViewById(R.id.twitter)}; 39 | 40 | if (savedInstanceState == null) { 41 | // Setup initial states 42 | mBackgroundView.setVisibility(View.INVISIBLE); 43 | for (View itemView : mItemViews) { 44 | itemView.setAlpha(0); 45 | } 46 | } 47 | 48 | getWindow().getSharedElementEnterTransition().addListener(new TransitionAdapter() { 49 | @Override 50 | public void onTransitionEnd(Transition transition) { 51 | getWindow().getSharedElementEnterTransition().removeListener(this); 52 | revealTheBackground(); 53 | showTheItems(); 54 | } 55 | }); 56 | } 57 | 58 | @Override 59 | public void onBackPressed() { 60 | hideTheItems(); 61 | hideTheBackground(); 62 | } 63 | 64 | /** 65 | * Reveal the background 66 | */ 67 | private void revealTheBackground() { 68 | mBackgroundView.setVisibility(View.VISIBLE); 69 | Animator reveal = createRevealAnimator(true); 70 | reveal.start(); 71 | } 72 | 73 | /** 74 | * Hide the background 75 | */ 76 | private void hideTheBackground() { 77 | Animator hide = createRevealAnimator(false); 78 | hide.setStartDelay(mDefaultAnimDuration); 79 | hide.addListener(new AnimatorListenerAdapter() { 80 | @Override 81 | public void onAnimationEnd(Animator animation) { 82 | mBackgroundView.setVisibility(View.INVISIBLE); 83 | supportFinishAfterTransition(); 84 | } 85 | }); 86 | hide.start(); 87 | } 88 | 89 | /** 90 | * Show the items 91 | */ 92 | private void showTheItems() { 93 | for (int i = 0; i < mItemViews.length; i++) { 94 | View itemView = mItemViews[i]; 95 | long startDelay = (mDefaultAnimDuration / mItemViews.length) * (i + 1); 96 | itemView.animate().alpha(1).setStartDelay(startDelay); 97 | } 98 | } 99 | 100 | /** 101 | * Hide the items 102 | */ 103 | private void hideTheItems() { 104 | for (int i = 0; i < mItemViews.length; i++) { 105 | View itemView = mItemViews[i]; 106 | long startDelay = (mDefaultAnimDuration / mItemViews.length) * (mItemViews.length - i); 107 | itemView.animate().alpha(0).setStartDelay(startDelay); 108 | } 109 | } 110 | 111 | private Animator createRevealAnimator(boolean show) { 112 | final int cx = mBackgroundView.getWidth() / 2; 113 | final int cy = mBackgroundView.getHeight() / 2; 114 | // A lit bit more than half the width and half the height because this view is a square 115 | // and it's not going to perfectly align with a circle. 116 | final int radius = (int) Math.hypot(cx, cy); 117 | final Animator animator; 118 | if (show) { 119 | animator = ViewAnimationUtils.createCircularReveal(mBackgroundView, cx, cy, 0, radius); 120 | animator.setInterpolator(new DecelerateInterpolator()); 121 | } else { 122 | animator = ViewAnimationUtils.createCircularReveal(mBackgroundView, cx, cy, radius, 0); 123 | animator.setInterpolator(new AccelerateInterpolator()); 124 | } 125 | animator.setDuration(mDefaultAnimDuration); 126 | return animator; 127 | } 128 | 129 | public void shareClick(View view) { 130 | 131 | // Load the transition 132 | Transition transition = TransitionInflater.from(this).inflateTransition(R.transition.sharing_item_chosen); 133 | // Finish this Activity when the transition is ended 134 | transition.addListener(new TransitionAdapter() { 135 | @Override 136 | public void onTransitionEnd(Transition transition) { 137 | // Finish the activity 138 | finish(); 139 | // Override default transition to fade out 140 | overridePendingTransition(0, android.R.anim.fade_out); 141 | } 142 | }); 143 | // Capture current values in the scene root and then post a request to run a transition on the next frame 144 | TransitionManager.beginDelayedTransition(mRootView, transition); 145 | 146 | // Change view property values 147 | 148 | // 1. Item chosen 149 | RelativeLayout.LayoutParams layoutParams = 150 | new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); 151 | layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); 152 | view.setLayoutParams(layoutParams); 153 | 154 | // 2. Rest of items 155 | for (View itemView : mItemViews) { 156 | if (itemView != view) { 157 | itemView.setVisibility(View.INVISIBLE); 158 | } 159 | } 160 | 161 | // 3. Background 162 | double diagonal = Math.sqrt(mRootView.getHeight() * mRootView.getHeight() + mRootView.getWidth() * mRootView.getWidth()); 163 | float radius = (float) (diagonal / 2f); 164 | int h = mBackgroundView.getDrawable().getIntrinsicHeight(); 165 | float scale = radius / (h / 2f); 166 | Matrix matrix = new Matrix(mBackgroundView.getImageMatrix()); 167 | matrix.postScale(scale, scale, mBackgroundView.getWidth() / 2f, mBackgroundView.getHeight() / 2f); 168 | mBackgroundView.setScaleType(ImageView.ScaleType.MATRIX); 169 | mBackgroundView.setImageMatrix(matrix); 170 | } 171 | 172 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/andremion/uimotion/TransitionAdapter.java: -------------------------------------------------------------------------------- 1 | package com.example.andremion.uimotion; 2 | 3 | import android.transition.Transition; 4 | 5 | public class TransitionAdapter implements Transition.TransitionListener { 6 | 7 | @Override 8 | public void onTransitionStart(Transition transition) { 9 | 10 | } 11 | 12 | @Override 13 | public void onTransitionEnd(Transition transition) { 14 | 15 | } 16 | 17 | @Override 18 | public void onTransitionCancel(Transition transition) { 19 | 20 | } 21 | 22 | @Override 23 | public void onTransitionPause(Transition transition) { 24 | 25 | } 26 | 27 | @Override 28 | public void onTransitionResume(Transition transition) { 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/chrysanthemum.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andremion/UI-Motion/878703c83eb8803afb3876e01d7f1e1b97cb535c/app/src/main/res/drawable-xxhdpi/chrysanthemum.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/desert.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andremion/UI-Motion/878703c83eb8803afb3876e01d7f1e1b97cb535c/app/src/main/res/drawable-xxhdpi/desert.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/hydrangeas.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andremion/UI-Motion/878703c83eb8803afb3876e01d7f1e1b97cb535c/app/src/main/res/drawable-xxhdpi/hydrangeas.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_facebook.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andremion/UI-Motion/878703c83eb8803afb3876e01d7f1e1b97cb535c/app/src/main/res/drawable-xxhdpi/ic_facebook.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_instagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andremion/UI-Motion/878703c83eb8803afb3876e01d7f1e1b97cb535c/app/src/main/res/drawable-xxhdpi/ic_instagram.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_share_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andremion/UI-Motion/878703c83eb8803afb3876e01d7f1e1b97cb535c/app/src/main/res/drawable-xxhdpi/ic_share_white_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_twitter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andremion/UI-Motion/878703c83eb8803afb3876e01d7f1e1b97cb535c/app/src/main/res/drawable-xxhdpi/ic_twitter.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/jellyfish.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andremion/UI-Motion/878703c83eb8803afb3876e01d7f1e1b97cb535c/app/src/main/res/drawable-xxhdpi/jellyfish.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/penguins.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andremion/UI-Motion/878703c83eb8803afb3876e01d7f1e1b97cb535c/app/src/main/res/drawable-xxhdpi/penguins.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/tulips.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andremion/UI-Motion/878703c83eb8803afb3876e01d7f1e1b97cb535c/app/src/main/res/drawable-xxhdpi/tulips.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/sharing_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 20 | 21 | 22 | 23 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_detail.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 23 | 24 | 28 | 29 | 37 | 38 | 47 | 48 | 49 | 50 | 51 | 52 | 58 | 59 | 65 | 66 | 74 | 75 | 80 | 81 | 82 | 83 | 84 | 85 | 96 | 97 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 27 | 28 | 32 | 33 | 37 | 38 | 42 | 43 | 48 | 49 | 53 | 54 | 59 | 60 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_sharing.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 24 | 25 | 34 | 35 | 42 | 43 | 51 | 52 | 60 | 61 | 69 | 70 | 78 | 79 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andremion/UI-Motion/878703c83eb8803afb3876e01d7f1e1b97cb535c/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andremion/UI-Motion/878703c83eb8803afb3876e01d7f1e1b97cb535c/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andremion/UI-Motion/878703c83eb8803afb3876e01d7f1e1b97cb535c/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andremion/UI-Motion/878703c83eb8803afb3876e01d7f1e1b97cb535c/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andremion/UI-Motion/878703c83eb8803afb3876e01d7f1e1b97cb535c/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/transition/detail_enter.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 20 | 21 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/transition/main_exit.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/transition/main_reenter.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/res/transition/sharing_item_chosen.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/transition/sharing_shared_element_enter.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 20 | 21 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #99000000 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | 4dp 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/values/integers.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | @android:integer/config_mediumAnimTime 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | UI-Motion 3 | 4 | Chrysanthemum 5 | Desert 6 | Hydrangeas 7 | Jellyfish 8 | Penguins 9 | Tulips 10 | 11 | picture_transition 12 | share_transition 13 | 14 | 15 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin tristique tellus nulla, vel tincidunt quam tincidunt fermentum. Integer semper efficitur dignissim. Pellentesque in leo sit amet urna vehicula tempor. Vivamus convallis finibus neque id egestas. Donec ultricies at tortor sed egestas. Donec justo arcu, convallis sed rutrum a, suscipit ut nisi. Morbi gravida odio at semper porta. Sed pretium, lacus at eleifend tempus, libero nibh gravida nibh, eu tempus augue nunc sit amet diam. Phasellus turpis justo, vehicula et tempus quis, rhoncus a dui. Nunc tincidunt diam arcu, a placerat dui efficitur id. Sed ullamcorper nisl sit amet nisl iaculis efficitur. Fusce ultrices dui magna, eu scelerisque mi aliquet a. Suspendisse potenti. Cras rutrum sagittis lectus ac gravida.\n\nInteger fringilla purus quis tortor tincidunt viverra. Ut in ultricies tortor, nec fringilla dolor. Morbi et consectetur augue, vel iaculis lorem. Cras porttitor libero nec ligula suscipit cursus. Etiam convallis viverra iaculis. Duis a nisi eget ligula ornare feugiat quis vitae mauris. Nunc nec mauris id turpis luctus posuere. In hac habitasse platea dictumst. Nulla tempus luctus tellus vitae iaculis. Sed felis est, varius eget egestas a, dignissim pharetra arcu. Quisque hendrerit faucibus purus vitae finibus. Fusce facilisis blandit nisi, vitae facilisis massa eleifend vel. Donec vitae venenatis lorem. Nullam eu pharetra est. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Suspendisse at risus et quam bibendum pellentesque. 16 | 17 | 18 | Facebook 19 | Twitter 20 | Google+ 21 | Instagram 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 14 | 15 | 20 | 21 | 29 | 30 | 40 | 41 | 48 | 49 | -------------------------------------------------------------------------------- /assets/detail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andremion/UI-Motion/878703c83eb8803afb3876e01d7f1e1b97cb535c/assets/detail.png -------------------------------------------------------------------------------- /assets/detail_to_sharing.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andremion/UI-Motion/878703c83eb8803afb3876e01d7f1e1b97cb535c/assets/detail_to_sharing.gif -------------------------------------------------------------------------------- /assets/item_share_click.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andremion/UI-Motion/878703c83eb8803afb3876e01d7f1e1b97cb535c/assets/item_share_click.gif -------------------------------------------------------------------------------- /assets/main.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andremion/UI-Motion/878703c83eb8803afb3876e01d7f1e1b97cb535c/assets/main.png -------------------------------------------------------------------------------- /assets/main_to_detail.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andremion/UI-Motion/878703c83eb8803afb3876e01d7f1e1b97cb535c/assets/main_to_detail.gif -------------------------------------------------------------------------------- /assets/post_head.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andremion/UI-Motion/878703c83eb8803afb3876e01d7f1e1b97cb535c/assets/post_head.jpg -------------------------------------------------------------------------------- /assets/preview.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andremion/UI-Motion/878703c83eb8803afb3876e01d7f1e1b97cb535c/assets/preview.gif -------------------------------------------------------------------------------- /assets/sharing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andremion/UI-Motion/878703c83eb8803afb3876e01d7f1e1b97cb535c/assets/sharing.png -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:1.5.0' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andremion/UI-Motion/878703c83eb8803afb3876e01d7f1e1b97cb535c/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Apr 10 15:27:10 PDT 2013 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.2.1-all.zip 7 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------