├── .gitignore ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── github │ │ └── takahirom │ │ └── materialelement │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ ├── fonts │ │ │ ├── Roboto-LightItalic.ttf │ │ │ └── Roboto-Regular.ttf │ │ └── product_icon.json │ ├── java │ │ └── com │ │ │ └── github │ │ │ └── takahirom │ │ │ └── materialelement │ │ │ ├── ElementApplication.java │ │ │ ├── MaterialElementActivity.java │ │ │ ├── ProductIconActivity.java │ │ │ ├── animation │ │ │ ├── ObservableColorMatrix.java │ │ │ ├── OnetimeViewTreeObserver.java │ │ │ ├── motion │ │ │ │ └── GravityArcMotion.java │ │ │ └── transition │ │ │ │ ├── AnimatorUtils.java │ │ │ │ ├── AsymmetricTransform.java │ │ │ │ ├── BlinkDebugTransition.java │ │ │ │ ├── BlinkVisibilityDebugTransition.java │ │ │ │ ├── FabTransform.java │ │ │ │ ├── FadeInTransition.java │ │ │ │ ├── FadeOutTransition.java │ │ │ │ ├── LiftOff.java │ │ │ │ ├── StaggeredDistanceSlide.java │ │ │ │ └── TransitionUtils.java │ │ │ ├── main │ │ │ ├── AnimateRecyclerAdapter.java │ │ │ ├── HeaderItem.java │ │ │ ├── ImplementationAdapter.java │ │ │ ├── ImplementationItem.java │ │ │ ├── ListItem.java │ │ │ └── MainActivity.java │ │ │ ├── motion │ │ │ ├── choreography │ │ │ │ ├── ChoreographyActivity.java │ │ │ │ ├── ShareAllElementActivity.java │ │ │ │ └── ShareFewElementActivity.java │ │ │ ├── creative │ │ │ │ └── CreativeCustomizationActivity.java │ │ │ ├── durationeasing │ │ │ │ └── DurationAndEasingActivity.java │ │ │ ├── movement │ │ │ │ └── MovementActivity.java │ │ │ └── transforming │ │ │ │ ├── LoginActivity.java │ │ │ │ └── TransformingActivity.java │ │ │ ├── pattern │ │ │ ├── loadingimages │ │ │ │ └── LoadingImagesActivity.java │ │ │ └── transition │ │ │ │ ├── ChildActivity.java │ │ │ │ ├── NavigationalTransitionActivity.java │ │ │ │ └── RecyclerViewAdapter.java │ │ │ ├── util │ │ │ ├── AndroidVersionUtil.java │ │ │ ├── ScreenUtil.java │ │ │ └── ThemeUtil.java │ │ │ └── view │ │ │ ├── ForegroundConstraintLayout.java │ │ │ ├── ForegroundImageView.java │ │ │ ├── ForegroundRelativeLayout.java │ │ │ ├── FourThreeImageView.java │ │ │ ├── QuoteLayout.java │ │ │ └── ResourceUtil.java │ └── res │ │ ├── animator │ │ └── raise.xml │ │ ├── drawable │ │ ├── avd_menu_back_menu_to_back.xml │ │ ├── dialog_background.xml │ │ ├── ic_add_white_24dp.xml │ │ ├── ic_apps_black_24dp.xml │ │ ├── ic_choreography.xml │ │ ├── ic_creative_customize.xml │ │ ├── ic_duration_easing.xml │ │ ├── ic_format_quote_black_24dp.xml │ │ ├── ic_loading_image.xml │ │ ├── ic_logo.xml │ │ ├── ic_movement.xml │ │ ├── ic_navigational_transition.xml │ │ ├── ic_navigational_transition_circle.xml │ │ └── ic_transforming_material.xml │ │ ├── layout │ │ ├── activity_child.xml │ │ ├── activity_choreography.xml │ │ ├── activity_creative_customization.xml │ │ ├── activity_dynamic_durations.xml │ │ ├── activity_loading_images.xml │ │ ├── activity_login.xml │ │ ├── activity_main.xml │ │ ├── activity_movement.xml │ │ ├── activity_navigational_transition.xml │ │ ├── activity_product_icon.xml │ │ ├── activity_share_all_element.xml │ │ ├── activity_share_few_element.xml │ │ ├── activity_transforming.xml │ │ ├── all_element_share_scene1.xml │ │ ├── all_element_share_scene2.xml │ │ ├── card_arc_scene1.xml │ │ ├── card_arc_scene2.xml │ │ ├── card_not_arc_scene1.xml │ │ ├── card_not_arc_scene2.xml │ │ ├── content_child.xml │ │ ├── content_choreography.xml │ │ ├── content_creative_customization.xml │ │ ├── content_duration_easing.xml │ │ ├── content_loading_images.xml │ │ ├── content_main.xml │ │ ├── content_movement.xml │ │ ├── content_navigational_transition.xml │ │ ├── content_transforming.xml │ │ ├── few_element_share_scene1.xml │ │ ├── few_element_share_scene2.xml │ │ ├── implementation_appbar_layout.xml │ │ ├── item_main_header.xml │ │ ├── item_main_implementation.xml │ │ ├── item_navigational_transition.xml │ │ ├── list_row_card.xml │ │ └── quote_layout.xml │ │ ├── menu │ │ └── menu_main.xml │ │ ├── mipmap-hdpi │ │ └── element_icon.png │ │ ├── mipmap-mdpi │ │ └── element_icon.png │ │ ├── mipmap-xhdpi │ │ └── element_icon.png │ │ ├── mipmap-xxhdpi │ │ └── element_icon.png │ │ ├── mipmap-xxxhdpi │ │ └── element_icon.png │ │ ├── transition │ │ ├── choreography_all_element_share_enter.xml │ │ ├── choreography_all_element_share_return.xml │ │ ├── choreography_few_element_share_enter.xml │ │ ├── choreography_few_element_share_return.xml │ │ ├── default_share.xml │ │ ├── default_window_enter.xml │ │ ├── default_window_return.xml │ │ ├── movement_change_bounds_arc.xml │ │ ├── navigational_transition_share_enter.xml │ │ └── navigational_transition_share_return.xml │ │ └── values │ │ ├── attrs_foreground_view.xml │ │ ├── attrs_lift_off.xml │ │ ├── attrs_quote_layout.xml │ │ ├── attrs_staggered_distance_slide.xml │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── github │ └── takahirom │ └── materialelement │ └── ExampleUnitTest.java ├── build.gradle ├── debug.keystore ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # material-element 2 | ![logo](https://cloud.githubusercontent.com/assets/1386930/23596654/fa752a92-026f-11e7-8548-fe1256b6edc1.png) 3 | 4 | An Android app which provides example of implementing material design animation. 5 | 6 | [Try it on your device via DeployGate](https://dply.me/qke65z#install) 7 | 8 | ![screenrecord](https://cloud.githubusercontent.com/assets/1386930/23823658/7c5f09c2-06aa-11e7-8898-ab58859e251d.gif) 9 | 10 | 11 | ## Designer 12 | [sorashin](http://github.com/sorashin) 13 | 14 | ## Examples 15 | 16 | Choreography 17 | 18 | ![choreography](https://cloud.githubusercontent.com/assets/1386930/23785409/f064504e-05aa-11e7-95a5-848da6a854aa.gif) 19 | 20 | | | Animation Start | Animation End | 21 | |---|---|---| 22 | | Card Width | 0ms | 275ms | 23 | | Card Height | 30ms | 375ms | 24 | | SharedElement x position | 0ms | 275ms | 25 | | SharedElement y position | 30ms | 375ms | 26 | | Entering View Alpha | 75ms | 225ms |  27 | 28 | 29 | | Duration & Easing | Movement | Transforming material | 30 | |---|---|---| 31 | | ![element_duration_easing](https://cloud.githubusercontent.com/assets/1386930/23667688/0ec91534-03a2-11e7-921a-b753e4ccac6f.gif) | ![element_movement](https://cloud.githubusercontent.com/assets/1386930/23667764/4f5a381c-03a2-11e7-85af-f894aef98eb3.gif) | ![element_transforming](https://cloud.githubusercontent.com/assets/1386930/23667832/831fb87a-03a2-11e7-86bb-a29a258da009.gif) | 32 | 33 | 34 | And more.. 35 | 36 | 37 | ## Credit 38 | This app use codes in these project. 39 | 40 | [Plaid](https://github.com/nickbutcher/plaid) 41 | [Android Open Source Project](https://source.android.com/source/licenses.html) 42 | 43 | ## License 44 | 45 | Copyright 2017 takahirom, sorashin 46 | 47 | Licensed under the Apache License, Version 2.0 (the "License"); 48 | you may not use this file except in compliance with the License. 49 | You may obtain a copy of the License at 50 | 51 | http://www.apache.org/licenses/LICENSE-2.0 52 | 53 | Unless required by applicable law or agreed to in writing, software 54 | distributed under the License is distributed on an "AS IS" BASIS, 55 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 56 | See the License for the specific language governing permissions and 57 | limitations under the License. 58 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'net.ltgt.errorprone' 3 | 4 | android { 5 | compileSdkVersion 25 6 | buildToolsVersion "25.0.2" 7 | defaultConfig { 8 | applicationId "com.github.takahirom.materialelement" 9 | minSdkVersion 16 10 | targetSdkVersion 25 11 | versionCode 1 12 | versionName "1.0" 13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 14 | vectorDrawables.useSupportLibrary true 15 | } 16 | 17 | signingConfigs { 18 | debug { 19 | storeFile rootProject.file("debug.keystore") 20 | storePassword "android" 21 | keyAlias "androiddebugkey" 22 | keyPassword "android" 23 | } 24 | } 25 | 26 | buildTypes { 27 | release { 28 | minifyEnabled false 29 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 30 | } 31 | } 32 | lintOptions { 33 | disable 'InvalidPackage' 34 | abortOnError false 35 | textReport true 36 | textOutput 'stdout' 37 | lintConfig file("lint.xml") 38 | } 39 | } 40 | 41 | project.afterEvaluate { 42 | tasks.withType(JavaCompile) { 43 | options.compilerArgs << '-Werror' 44 | } 45 | } 46 | 47 | dependencies { 48 | compile fileTree(dir: 'libs', include: ['*.jar']) 49 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 50 | exclude group: 'com.android.support', module: 'support-annotations' 51 | }) 52 | 53 | 54 | compile 'com.android.support:appcompat-v7:25.2.0' 55 | compile 'com.android.support:cardview-v7:25.2.0' 56 | compile 'com.android.support:design:25.2.0' 57 | compile 'com.android.support.constraint:constraint-layout:1.0.0' 58 | compile 'uk.co.chrisjenx:calligraphy:2.2.0' 59 | compile 'com.airbnb.android:lottie:1.5.2' 60 | compile 'com.github.bumptech.glide:glide:3.7.0' 61 | testCompile 'junit:junit:4.12' 62 | 63 | } 64 | -------------------------------------------------------------------------------- /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 /Users/takahirom/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/github/takahirom/materialelement/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.github.takahirom.materialelement; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.github.takahirom.material_design_animation_playground", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 14 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 26 | 29 | 32 | 35 | 38 | 41 | 44 | 47 | 50 | 53 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /app/src/main/assets/fonts/Roboto-LightItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/takahirom/material-element/e3263f80935edf2aa09f7e8240273b2a99745bb8/app/src/main/assets/fonts/Roboto-LightItalic.ttf -------------------------------------------------------------------------------- /app/src/main/assets/fonts/Roboto-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/takahirom/material-element/e3263f80935edf2aa09f7e8240273b2a99745bb8/app/src/main/assets/fonts/Roboto-Regular.ttf -------------------------------------------------------------------------------- /app/src/main/assets/product_icon.json: -------------------------------------------------------------------------------- 1 | {"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"シェイプレイヤー 2","ks":{"o":{"k":100},"r":{"k":0},"p":{"k":[{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":0,"s":[196.735,338.012,0],"e":[254.536,350,0],"to":[0,6.62100219726562,0],"ti":[-31.9228057861328,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":10,"s":[254.536,350,0],"e":[312.337,338.012,0],"to":[31.9227905273438,0,0],"ti":[0,6.62100219726562,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":19,"s":[312.337,338.012,0],"e":[156.742,256.006,0],"to":[0,0,0],"ti":[131.206497192383,-11.9941101074219,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":26,"s":[156.742,256.006,0],"e":[254.536,276.289,0],"to":[-11.1555023193359,1.01968383789062,0],"ti":[-54.0099029541016,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":31,"s":[254.536,276.289,0],"e":[352.33,233.006,0],"to":[54.0098876953125,0,0],"ti":[-0.71630859375,11.1790771484375,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":37,"s":[352.33,233.006,0],"e":[253.808,162,0],"to":[1.94119262695312,-30.2985076904297,0],"ti":[105.435485839844,17.2673950195312,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":42,"s":[253.808,162,0],"e":[119.536,166,0],"to":[-73.2723999023438,-12,0],"ti":[8.74580383300781,-12.0731964111328,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":49,"s":[119.536,166,0],"e":[254.536,194,0],"to":[-9.0718994140625,12.5234069824219,0],"ti":[-74.5583953857422,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":54,"s":[254.536,194,0],"e":[389.536,166,0],"to":[74.5584106445312,0,0],"ti":[0,15.4640045166016,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":59.94,"s":[389.536,166,0],"e":[196.735,338.012,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":72,"s":[196.735,338.012,0],"e":[254.536,350,0],"to":[0,6.62100219726562,0],"ti":[-31.9228057861328,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":75.349,"s":[254.536,350,0],"e":[312.337,338.012,0],"to":[31.9227905273438,0,0],"ti":[0,6.62100219726562,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":78.699,"s":[312.337,338.012,0],"e":[156.742,256.006,0],"to":[0,0,0],"ti":[131.206497192383,-11.9941101074219,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":89.191,"s":[156.742,256.006,0],"e":[254.536,276.289,0],"to":[-11.1555023193359,1.01968383789062,0],"ti":[-54.0099029541016,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":94.908,"s":[254.536,276.289,0],"e":[352.33,233.006,0],"to":[54.0098876953125,0,0],"ti":[-0.71630859375,11.1790771484375,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":101.038,"s":[352.33,233.006,0],"e":[253.808,162,0],"to":[1.94119262695312,-30.2985076904297,0],"ti":[105.435485839844,17.2673950195312,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":108.671,"s":[253.808,162,0],"e":[119.536,166,0],"to":[-73.2723999023438,-12,0],"ti":[8.74580383300781,-12.0731964111328,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":116.209,"s":[119.536,166,0],"e":[254.536,194,0],"to":[-9.0718994140625,12.5234069824219,0],"ti":[-74.5583953857422,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":124.115,"s":[254.536,194,0],"e":[389.536,166,0],"to":[74.5584106445312,0,0],"ti":[0,15.4640045166016,0]},{"t":131.940005374026}]},"a":{"k":[25,6,0]},"s":{"k":[90.973,90.973,100]}},"ao":0,"ef":[{"ty":5,"nm":"ドロップシャドウ","mn":"ADBE Drop Shadow","ix":1,"ef":[{"ty":2,"nm":"シャドウのカラー","mn":"ADBE Drop Shadow-0001","ix":1,"v":{"k":[0,0,0,1]}},{"ty":0,"nm":"不透明度","mn":"ADBE Drop Shadow-0002","ix":2,"v":{"k":127.5}},{"ty":0,"nm":"方向","mn":"ADBE Drop Shadow-0003","ix":3,"v":{"k":138}},{"ty":0,"nm":"距離","mn":"ADBE Drop Shadow-0004","ix":4,"v":{"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":0,"s":[11],"e":[49]},{"t":31.0000012626559}]}},{"ty":0,"nm":"柔らかさ","mn":"ADBE Drop Shadow-0005","ix":5,"v":{"k":0}},{"ty":7,"nm":"シャドウのみ","mn":"ADBE Drop Shadow-0006","ix":6,"v":{"k":0}}]}],"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"k":[209.02,209.02]},"p":{"k":[0,0]},"nm":"楕円形パス 1","mn":"ADBE Vector Shape - Ellipse"},{"ty":"st","fillEnabled":true,"c":{"k":[1,1,1,1]},"o":{"k":100},"w":{"k":2},"lc":1,"lj":1,"ml":4,"nm":"線 1","mn":"ADBE Vector Graphic - Stroke"},{"ty":"fl","fillEnabled":true,"c":{"k":[1,1,1,1]},"o":{"k":100},"nm":"塗り 1","mn":"ADBE Vector Graphic - Fill"},{"ty":"tr","p":{"k":[27.196,5.751],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"トランスフォーム"}],"nm":"楕円形 1","np":3,"mn":"ADBE Vector Group"}],"ip":0,"op":150.000006109625,"st":0,"bm":0,"sr":1}],"v":"4.5.0","ddd":1,"ip":0,"op":150.000006109625,"fr":29.9700012207031,"w":500,"h":500} -------------------------------------------------------------------------------- /app/src/main/java/com/github/takahirom/materialelement/ElementApplication.java: -------------------------------------------------------------------------------- 1 | package com.github.takahirom.materialelement; 2 | 3 | import android.app.Application; 4 | 5 | import uk.co.chrisjenx.calligraphy.CalligraphyConfig; 6 | 7 | public class ElementApplication extends Application { 8 | @Override 9 | public void onCreate() { 10 | super.onCreate(); 11 | // Install font 12 | CalligraphyConfig.initDefault(new CalligraphyConfig.Builder() 13 | .setDefaultFontPath("fonts/Roboto-Regular.ttf") 14 | .setFontAttrId(uk.co.chrisjenx.calligraphy.R.attr.fontPath) 15 | .build()); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/takahirom/materialelement/MaterialElementActivity.java: -------------------------------------------------------------------------------- 1 | package com.github.takahirom.materialelement; 2 | 3 | import android.content.Context; 4 | import android.support.v7.app.AppCompatActivity; 5 | 6 | import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper; 7 | 8 | public class MaterialElementActivity extends AppCompatActivity { 9 | // For Calligraphy 10 | @Override 11 | protected void attachBaseContext(Context newBase) { 12 | super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase)); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/takahirom/materialelement/ProductIconActivity.java: -------------------------------------------------------------------------------- 1 | package com.github.takahirom.materialelement; 2 | 3 | import android.content.Intent; 4 | import android.os.Handler; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.os.Bundle; 7 | import android.view.ViewTreeObserver; 8 | 9 | import com.airbnb.lottie.LottieAnimationView; 10 | import com.github.takahirom.materialelement.animation.OnetimeViewTreeObserver; 11 | import com.github.takahirom.materialelement.main.MainActivity; 12 | 13 | public class ProductIconActivity extends MaterialElementActivity { 14 | 15 | @Override 16 | protected void onCreate(Bundle savedInstanceState) { 17 | super.onCreate(savedInstanceState); 18 | setContentView(R.layout.activity_product_icon); 19 | final LottieAnimationView animationView = (LottieAnimationView) findViewById(R.id.animation_view); 20 | OnetimeViewTreeObserver.addOnPreDrawListener(animationView, new OnetimeViewTreeObserver.OnPreDrawListener() { 21 | @Override 22 | public void onPreDraw() { 23 | // wait for start animation 24 | new Handler().postDelayed(new Runnable() { 25 | @Override 26 | public void run() { 27 | startActivity(new Intent(ProductIconActivity.this, MainActivity.class)); 28 | finish(); 29 | overridePendingTransition(0, 0); 30 | } 31 | }, animationView.getDuration()); 32 | } 33 | }); 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/takahirom/materialelement/animation/ObservableColorMatrix.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.github.takahirom.materialelement.animation; 18 | 19 | import android.graphics.ColorMatrix; 20 | import android.util.Property; 21 | 22 | /** 23 | * An extension to {@link ColorMatrix} which caches the saturation value for animation purposes. 24 | */ 25 | public class ObservableColorMatrix extends ColorMatrix { 26 | 27 | private float saturation = 1f; 28 | 29 | public ObservableColorMatrix() { 30 | super(); 31 | } 32 | 33 | public float getSaturation() { 34 | return saturation; 35 | } 36 | 37 | @Override 38 | public void setSaturation(float saturation) { 39 | this.saturation = saturation; 40 | super.setSaturation(saturation); 41 | } 42 | 43 | public static final Property SATURATION 44 | = new FloatProperty("saturation") { 45 | 46 | @Override 47 | public void setValue(ObservableColorMatrix cm, float value) { 48 | cm.setSaturation(value); 49 | } 50 | 51 | @Override 52 | public Float get(ObservableColorMatrix cm) { 53 | return cm.getSaturation(); 54 | } 55 | }; 56 | 57 | 58 | /** 59 | * An implementation of {@link android.util.Property} to be used specifically with fields of 60 | * type 61 | * float. This type-specific subclass enables performance benefit by allowing 62 | * calls to a {@link #set(Object, Float) set()} function that takes the primitive 63 | * float type and avoids autoboxing and other overhead associated with the 64 | * Float class. 65 | * 66 | * @param The class on which the Property is declared. 67 | **/ 68 | public static abstract class FloatProperty extends Property { 69 | public FloatProperty(String name) { 70 | super(Float.class, name); 71 | } 72 | 73 | /** 74 | * A type-specific override of the {@link #set(Object, Float)} that is faster when dealing 75 | * with fields of type float. 76 | */ 77 | public abstract void setValue(T object, float value); 78 | 79 | @Override 80 | final public void set(T object, Float value) { 81 | setValue(object, value); 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/takahirom/materialelement/animation/OnetimeViewTreeObserver.java: -------------------------------------------------------------------------------- 1 | package com.github.takahirom.materialelement.animation; 2 | 3 | import android.view.View; 4 | import android.view.ViewTreeObserver; 5 | 6 | public class OnetimeViewTreeObserver { 7 | public static void addOnPreDrawListener(final View view, final OnetimeViewTreeObserver.OnPreDrawListener listener) { 8 | view.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { 9 | @Override 10 | public boolean onPreDraw() { 11 | view.getViewTreeObserver().removeOnPreDrawListener(this); 12 | listener.onPreDraw(); 13 | return false; 14 | } 15 | }); 16 | } 17 | 18 | public interface OnPreDrawListener { 19 | void onPreDraw(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/takahirom/materialelement/animation/transition/BlinkDebugTransition.java: -------------------------------------------------------------------------------- 1 | package com.github.takahirom.materialelement.animation.transition; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ObjectAnimator; 5 | import android.animation.ValueAnimator; 6 | import android.annotation.TargetApi; 7 | import android.content.Context; 8 | import android.graphics.Rect; 9 | import android.os.Build; 10 | import android.transition.Transition; 11 | import android.transition.TransitionValues; 12 | import android.transition.Visibility; 13 | import android.util.AttributeSet; 14 | import android.view.View; 15 | import android.view.ViewGroup; 16 | 17 | @TargetApi(Build.VERSION_CODES.KITKAT) 18 | public class BlinkDebugTransition extends Transition { 19 | private static final String PROP_BOUNDS = "mdap:fabTransform:bounds"; 20 | 21 | private static final String[] transitionProperties = { 22 | PROP_BOUNDS 23 | }; 24 | 25 | public BlinkDebugTransition() { 26 | super(); 27 | } 28 | 29 | public BlinkDebugTransition(Context context, AttributeSet attrs) { 30 | super(context, attrs); 31 | setDuration(5000); 32 | } 33 | 34 | @Override 35 | public String[] getTransitionProperties() { 36 | return transitionProperties; 37 | } 38 | 39 | @Override 40 | public void captureStartValues(TransitionValues transitionValues) { 41 | captureValues(transitionValues); 42 | } 43 | 44 | @Override 45 | public void captureEndValues(TransitionValues transitionValues) { 46 | captureValues(transitionValues); 47 | } 48 | 49 | 50 | private void captureValues(TransitionValues transitionValues) { 51 | final View view = transitionValues.view; 52 | if (view == null || view.getWidth() <= 0 || view.getHeight() <= 0) return; 53 | 54 | transitionValues.values.put(PROP_BOUNDS, new Rect(view.getLeft(), view.getTop(), 55 | view.getRight(), view.getBottom())); 56 | } 57 | 58 | 59 | @Override 60 | public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, 61 | TransitionValues endValues) { 62 | if (startValues == null || endValues == null) return null; 63 | 64 | final Rect startBounds = (Rect) startValues.values.get(PROP_BOUNDS); 65 | final Rect endBounds = (Rect) endValues.values.get(PROP_BOUNDS); 66 | 67 | final View view = endValues.view; 68 | ValueAnimator alphaAnim = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f); 69 | alphaAnim.setDuration(5); 70 | alphaAnim.setRepeatCount(ValueAnimator.INFINITE); 71 | alphaAnim.setRepeatMode(ValueAnimator.REVERSE); 72 | return alphaAnim; 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/takahirom/materialelement/animation/transition/BlinkVisibilityDebugTransition.java: -------------------------------------------------------------------------------- 1 | package com.github.takahirom.materialelement.animation.transition; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ObjectAnimator; 5 | import android.animation.ValueAnimator; 6 | import android.content.Context; 7 | import android.graphics.Rect; 8 | import android.transition.TransitionValues; 9 | import android.transition.Visibility; 10 | import android.util.AttributeSet; 11 | import android.view.View; 12 | import android.view.ViewGroup; 13 | 14 | @SuppressWarnings("unused") 15 | public class BlinkVisibilityDebugTransition extends Visibility { 16 | private static final String PROP_BOUNDS = "mdap:fabTransform:bounds"; 17 | 18 | private static final String[] transitionProperties = { 19 | PROP_BOUNDS 20 | }; 21 | 22 | public BlinkVisibilityDebugTransition() { 23 | super(); 24 | } 25 | 26 | public BlinkVisibilityDebugTransition(Context context, AttributeSet attrs) { 27 | super(context, attrs); 28 | } 29 | 30 | @Override 31 | public String[] getTransitionProperties() { 32 | return transitionProperties; 33 | } 34 | 35 | @Override 36 | public void captureStartValues(TransitionValues transitionValues) { 37 | captureValues(transitionValues); 38 | } 39 | 40 | @Override 41 | public void captureEndValues(TransitionValues transitionValues) { 42 | captureValues(transitionValues); 43 | } 44 | 45 | 46 | private void captureValues(TransitionValues transitionValues) { 47 | final View view = transitionValues.view; 48 | if (view == null || view.getWidth() <= 0 || view.getHeight() <= 0) return; 49 | 50 | transitionValues.values.put(PROP_BOUNDS, new Rect(view.getLeft(), view.getTop(), 51 | view.getRight(), view.getBottom())); 52 | } 53 | 54 | 55 | @Override 56 | public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, 57 | TransitionValues endValues) { 58 | if (startValues == null || endValues == null) return null; 59 | 60 | final Rect startBounds = (Rect) startValues.values.get(PROP_BOUNDS); 61 | final Rect endBounds = (Rect) endValues.values.get(PROP_BOUNDS); 62 | 63 | final View view = endValues.view; 64 | ValueAnimator alphaAnim = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f); 65 | alphaAnim.setDuration(5); 66 | alphaAnim.setRepeatCount(ValueAnimator.INFINITE); 67 | alphaAnim.setRepeatMode(ValueAnimator.REVERSE); 68 | return alphaAnim; 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/takahirom/materialelement/animation/transition/FadeInTransition.java: -------------------------------------------------------------------------------- 1 | package com.github.takahirom.materialelement.animation.transition; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ObjectAnimator; 5 | import android.animation.ValueAnimator; 6 | import android.annotation.TargetApi; 7 | import android.content.Context; 8 | import android.graphics.Rect; 9 | import android.os.Build; 10 | import android.support.v4.view.animation.LinearOutSlowInInterpolator; 11 | import android.transition.Transition; 12 | import android.transition.TransitionValues; 13 | import android.util.AttributeSet; 14 | import android.view.View; 15 | import android.view.ViewGroup; 16 | 17 | /** 18 | * SharedElementTransition cannot Visibility transition like fade 19 | * So I create this transtiion. 20 | */ 21 | @TargetApi(Build.VERSION_CODES.KITKAT) 22 | public class FadeInTransition extends Transition { 23 | private static final String PROP_BOUNDS = "mdap:fabTransform:bounds"; 24 | 25 | private static final String[] transitionProperties = { 26 | PROP_BOUNDS 27 | }; 28 | 29 | public FadeInTransition() { 30 | super(); 31 | } 32 | 33 | public FadeInTransition(Context context, AttributeSet attrs) { 34 | super(context, attrs); 35 | } 36 | 37 | @Override 38 | public String[] getTransitionProperties() { 39 | return transitionProperties; 40 | } 41 | 42 | @Override 43 | public void captureStartValues(TransitionValues transitionValues) { 44 | captureValues(transitionValues); 45 | } 46 | 47 | @Override 48 | public void captureEndValues(TransitionValues transitionValues) { 49 | captureValues(transitionValues); 50 | } 51 | 52 | 53 | private void captureValues(TransitionValues transitionValues) { 54 | final View view = transitionValues.view; 55 | if (view == null || view.getWidth() <= 0 || view.getHeight() <= 0) return; 56 | 57 | transitionValues.values.put(PROP_BOUNDS, new Rect(view.getLeft(), view.getTop(), 58 | view.getRight(), view.getBottom())); 59 | } 60 | 61 | 62 | @Override 63 | public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, 64 | TransitionValues endValues) { 65 | if (startValues == null || endValues == null) return null; 66 | 67 | final View view = endValues.view; 68 | view.setAlpha(0f); 69 | ValueAnimator alphaAnim = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f); 70 | alphaAnim.setDuration(getDuration()); 71 | alphaAnim.setInterpolator(getInterpolator()); 72 | return alphaAnim; 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/takahirom/materialelement/animation/transition/FadeOutTransition.java: -------------------------------------------------------------------------------- 1 | package com.github.takahirom.materialelement.animation.transition; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ObjectAnimator; 5 | import android.animation.ValueAnimator; 6 | import android.annotation.TargetApi; 7 | import android.content.Context; 8 | import android.graphics.Rect; 9 | import android.os.Build; 10 | import android.support.v4.view.animation.LinearOutSlowInInterpolator; 11 | import android.transition.Transition; 12 | import android.transition.TransitionValues; 13 | import android.util.AttributeSet; 14 | import android.view.View; 15 | import android.view.ViewGroup; 16 | 17 | /** 18 | * SharedElementTransition cannot Visibility transition like fade 19 | * So I create this transtiion. 20 | */ 21 | @TargetApi(Build.VERSION_CODES.KITKAT) 22 | public class FadeOutTransition extends Transition { 23 | private static final String PROP_BOUNDS = "mdap:fabTransform:bounds"; 24 | 25 | private static final String[] transitionProperties = { 26 | PROP_BOUNDS 27 | }; 28 | 29 | public FadeOutTransition() { 30 | super(); 31 | } 32 | 33 | public FadeOutTransition(Context context, AttributeSet attrs) { 34 | super(context, attrs); 35 | } 36 | 37 | @Override 38 | public String[] getTransitionProperties() { 39 | return transitionProperties; 40 | } 41 | 42 | @Override 43 | public void captureStartValues(TransitionValues transitionValues) { 44 | captureValues(transitionValues); 45 | } 46 | 47 | @Override 48 | public void captureEndValues(TransitionValues transitionValues) { 49 | captureValues(transitionValues); 50 | } 51 | 52 | 53 | private void captureValues(TransitionValues transitionValues) { 54 | final View view = transitionValues.view; 55 | if (view == null || view.getWidth() <= 0 || view.getHeight() <= 0) return; 56 | 57 | transitionValues.values.put(PROP_BOUNDS, new Rect(view.getLeft(), view.getTop(), 58 | view.getRight(), view.getBottom())); 59 | } 60 | 61 | 62 | @Override 63 | public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, 64 | TransitionValues endValues) { 65 | if (startValues == null || endValues == null) return null; 66 | 67 | final View view = endValues.view; 68 | view.setAlpha(1f); 69 | ValueAnimator alphaAnim = ObjectAnimator.ofFloat(view, "alpha", 1f, 0f); 70 | alphaAnim.setDuration(getDuration()); 71 | alphaAnim.setInterpolator(getInterpolator()); 72 | return alphaAnim; 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/takahirom/materialelement/animation/transition/LiftOff.java: -------------------------------------------------------------------------------- 1 | package com.github.takahirom.materialelement.animation.transition; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ObjectAnimator; 5 | import android.content.Context; 6 | import android.content.res.TypedArray; 7 | import android.transition.Transition; 8 | import android.transition.TransitionValues; 9 | import android.util.AttributeSet; 10 | import android.view.View; 11 | import android.view.ViewGroup; 12 | 13 | import com.github.takahirom.materialelement.R; 14 | 15 | 16 | /** 17 | * A transition that animates the elevation of a View from a given value down to zero. 18 | *

19 | * Useful for creating parent↔child navigation transitions 20 | * (https://www.google.com/design/spec/patterns/navigational-transitions.html#navigational-transitions-parent-to-child) 21 | * when combined with a {@link android.transition.ChangeBounds} on a shared element. 22 | */ 23 | public class LiftOff extends Transition { 24 | 25 | private static final String PROPNAME_ELEVATION = "plaid:liftoff:elevation"; 26 | 27 | private static final String[] transitionProperties = { 28 | PROPNAME_ELEVATION 29 | }; 30 | 31 | private final float initialElevation; 32 | private final float finalElevation; 33 | 34 | public LiftOff(Context context, AttributeSet attrs) { 35 | super(context, attrs); 36 | final TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.LiftOff); 37 | initialElevation = ta.getDimension(R.styleable.LiftOff_initialElevation, 0f); 38 | finalElevation = ta.getDimension(R.styleable.LiftOff_finalElevation, 0f); 39 | ta.recycle(); 40 | } 41 | 42 | @Override 43 | public String[] getTransitionProperties() { 44 | return transitionProperties; 45 | } 46 | 47 | @Override 48 | public void captureStartValues(TransitionValues transitionValues) { 49 | transitionValues.values.put(PROPNAME_ELEVATION, initialElevation); 50 | } 51 | 52 | @Override 53 | public void captureEndValues(TransitionValues transitionValues) { 54 | transitionValues.values.put(PROPNAME_ELEVATION, finalElevation); 55 | } 56 | 57 | @Override 58 | public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, 59 | TransitionValues endValues) { 60 | return ObjectAnimator.ofFloat(endValues.view, View.TRANSLATION_Z, 61 | initialElevation, finalElevation); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/takahirom/materialelement/animation/transition/StaggeredDistanceSlide.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.github.takahirom.materialelement.animation.transition; 18 | 19 | import android.animation.Animator; 20 | import android.animation.AnimatorListenerAdapter; 21 | import android.animation.ObjectAnimator; 22 | import android.annotation.TargetApi; 23 | import android.content.Context; 24 | import android.content.res.TypedArray; 25 | import android.os.Build; 26 | import android.support.annotation.Keep; 27 | import android.transition.TransitionValues; 28 | import android.transition.Visibility; 29 | import android.util.AttributeSet; 30 | import android.view.View; 31 | import android.view.ViewGroup; 32 | 33 | import com.github.takahirom.materialelement.R; 34 | 35 | import java.util.List; 36 | 37 | 38 | /** 39 | * An alternative to {@link android.transition.Slide} which staggers elements by distance 40 | * rather than using start delays. That is elements start from/end at a progressively increasing 41 | * displacement such that they come together/move apart over the same duration as they default_window_enter/exit. 42 | * This can produce more cohesive choreography. The displacement factor can be controlled by the 43 | * {@code spread} attribute. 44 | *

45 | * Currently only supports entering/exiting from the bottom edge. 46 | */ 47 | @TargetApi(Build.VERSION_CODES.LOLLIPOP) 48 | public class StaggeredDistanceSlide extends Visibility { 49 | 50 | private static final String PROPNAME_SCREEN_LOCATION = "android:visibility:screenLocation"; 51 | 52 | private int spread = 1; 53 | 54 | public StaggeredDistanceSlide() { 55 | super(); 56 | } 57 | 58 | @Keep 59 | public StaggeredDistanceSlide(Context context, AttributeSet attrs) { 60 | super(context, attrs); 61 | final TypedArray a = 62 | context.obtainStyledAttributes(attrs, R.styleable.StaggeredDistanceSlide); 63 | spread = a.getInteger(R.styleable.StaggeredDistanceSlide_spread, spread); 64 | a.recycle(); 65 | } 66 | 67 | public int getSpread() { 68 | return spread; 69 | } 70 | 71 | public void setSpread(int spread) { 72 | this.spread = spread; 73 | } 74 | 75 | @Override 76 | public Animator onAppear(ViewGroup sceneRoot, View view, 77 | TransitionValues startValues, TransitionValues endValues) { 78 | int[] position = (int[]) endValues.values.get(PROPNAME_SCREEN_LOCATION); 79 | return createAnimator(view, sceneRoot.getHeight() + (position[1] * spread), 0f); 80 | } 81 | 82 | @Override 83 | public Animator onDisappear(ViewGroup sceneRoot, View view, 84 | TransitionValues startValues, TransitionValues endValues) { 85 | int[] position = (int[]) endValues.values.get(PROPNAME_SCREEN_LOCATION); 86 | return createAnimator(view, 0f, sceneRoot.getHeight() + (position[1] * spread)); 87 | } 88 | 89 | private Animator createAnimator( 90 | final View view, float startTranslationY, float endTranslationY) { 91 | view.setTranslationY(startTranslationY); 92 | final List ancestralClipping = TransitionUtils.setAncestralClipping(view, false); 93 | Animator transition = ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, endTranslationY); 94 | transition.addListener(new AnimatorListenerAdapter() { 95 | @Override 96 | public void onAnimationEnd(Animator animation) { 97 | TransitionUtils.restoreAncestralClipping(view, ancestralClipping); 98 | } 99 | }); 100 | return transition; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/takahirom/materialelement/animation/transition/TransitionUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.github.takahirom.materialelement.animation.transition; 18 | 19 | import android.app.Notification; 20 | import android.support.annotation.IdRes; 21 | import android.support.annotation.NonNull; 22 | import android.support.annotation.Nullable; 23 | import android.support.v4.app.NotificationCompat; 24 | import android.support.v4.app.NotificationManagerCompat; 25 | import android.support.v7.app.AlertDialog; 26 | import android.transition.Transition; 27 | import android.transition.TransitionSet; 28 | import android.view.View; 29 | import android.view.ViewGroup; 30 | import android.view.ViewParent; 31 | import android.view.Window; 32 | import android.widget.Toast; 33 | 34 | import com.github.takahirom.materialelement.R; 35 | import com.github.takahirom.materialelement.util.AndroidVersionUtil; 36 | 37 | import java.util.ArrayList; 38 | import java.util.List; 39 | import java.util.Objects; 40 | 41 | /** 42 | * Utility methods for working with transitions 43 | */ 44 | public class TransitionUtils { 45 | 46 | private TransitionUtils() { 47 | } 48 | 49 | public static 50 | @Nullable 51 | Transition findTransition( 52 | @NonNull TransitionSet set, @NonNull Class clazz) { 53 | for (int i = 0; i < set.getTransitionCount(); i++) { 54 | Transition transition = set.getTransitionAt(i); 55 | if (transition.getClass() == clazz) { 56 | return transition; 57 | } 58 | if (transition instanceof TransitionSet) { 59 | Transition child = findTransition((TransitionSet) transition, clazz); 60 | if (child != null) return child; 61 | } 62 | } 63 | return null; 64 | } 65 | 66 | public static 67 | @Nullable 68 | Transition findTransition( 69 | @NonNull TransitionSet set, 70 | @NonNull Class clazz, 71 | @IdRes int targetId) { 72 | for (int i = 0; i < set.getTransitionCount(); i++) { 73 | Transition transition = set.getTransitionAt(i); 74 | if (transition.getClass() == clazz) { 75 | if (transition.getTargetIds().contains(targetId)) { 76 | return transition; 77 | } 78 | } 79 | if (transition instanceof TransitionSet) { 80 | Transition child = findTransition((TransitionSet) transition, clazz, targetId); 81 | if (child != null) return child; 82 | } 83 | } 84 | return null; 85 | } 86 | 87 | public static List setAncestralClipping(@NonNull View view, boolean clipChildren) { 88 | return setAncestralClipping(view, clipChildren, new ArrayList()); 89 | } 90 | 91 | private static List setAncestralClipping( 92 | @NonNull View view, boolean clipChildren, List was) { 93 | if (view instanceof ViewGroup) { 94 | ViewGroup group = (ViewGroup) view; 95 | was.add(group.getClipChildren()); 96 | group.setClipChildren(clipChildren); 97 | } 98 | ViewParent parent = view.getParent(); 99 | if (parent != null && parent instanceof ViewGroup) { 100 | setAncestralClipping((ViewGroup) parent, clipChildren, was); 101 | } 102 | return was; 103 | } 104 | 105 | public static void restoreAncestralClipping(@NonNull View view, List was) { 106 | if (view instanceof ViewGroup) { 107 | ViewGroup group = (ViewGroup) view; 108 | group.setClipChildren(was.remove(0)); 109 | } 110 | ViewParent parent = view.getParent(); 111 | if (parent != null && parent instanceof ViewGroup) { 112 | restoreAncestralClipping((ViewGroup) parent, was); 113 | } 114 | } 115 | 116 | 117 | public static void setSharedElementEnterTransitionEndListenerCompat(Window window, final OnSharedElementEnterTransitionEndListener listener) { 118 | if (!AndroidVersionUtil.isGreaterThanL()) { 119 | return; 120 | } 121 | window.getSharedElementEnterTransition().addListener(new TransitionListenerAdapter() { 122 | @Override 123 | public void onTransitionEnd(Transition transition) { 124 | listener.onEnd(transition); 125 | } 126 | }); 127 | } 128 | 129 | public static void showForDebug(Window window) { 130 | if (!AndroidVersionUtil.isGreaterThanL()) { 131 | return; 132 | } 133 | String message = "If you want to disable this dialog, Please restart app." + 134 | "windowAnimations:" + 135 | window.getContext().getResources().getResourceName(window.getAttributes().windowAnimations) + 136 | "\n-----\n" + 137 | "SharedElementEnterTransition:" + 138 | window.getSharedElementEnterTransition() + 139 | "\n-----\n" + 140 | "ReturnTransition:" + 141 | window.getReturnTransition() + 142 | "\n-----\n" + 143 | "SharedElementReturnTransition:" + 144 | window.getSharedElementReturnTransition() + 145 | "\n-----\n" + 146 | "ReenterTransition:" + 147 | window.getReenterTransition() + 148 | "\n-----\n" + 149 | "SharedElementReenterTransition:" + 150 | window.getSharedElementReenterTransition() + 151 | "\n-----\n" + 152 | "ExitTransition:" + 153 | window.getExitTransition() + 154 | "\n-----\n" + 155 | "SharedElementExitTransition:" + 156 | window.getSharedElementExitTransition(); 157 | new AlertDialog.Builder(window.getContext()) 158 | .setMessage(message).show(); 159 | } 160 | private static String toStringForLog(Object object){ 161 | if (object == null) { 162 | return "None"; 163 | } 164 | return object.toString(); 165 | } 166 | 167 | public interface OnSharedElementEnterTransitionEndListener { 168 | void onEnd(Transition transition); 169 | } 170 | 171 | public static class TransitionListenerAdapter implements Transition.TransitionListener { 172 | 173 | @Override 174 | public void onTransitionStart(Transition transition) { 175 | } 176 | 177 | @Override 178 | public void onTransitionEnd(Transition transition) { 179 | } 180 | 181 | @Override 182 | public void onTransitionCancel(Transition transition) { 183 | } 184 | 185 | @Override 186 | public void onTransitionPause(Transition transition) { 187 | } 188 | 189 | @Override 190 | public void onTransitionResume(Transition transition) { 191 | } 192 | } 193 | } 194 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/takahirom/materialelement/main/AnimateRecyclerAdapter.java: -------------------------------------------------------------------------------- 1 | package com.github.takahirom.materialelement.main; 2 | 3 | import android.support.v4.view.animation.LinearOutSlowInInterpolator; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | 9 | import com.github.takahirom.materialelement.R; 10 | import com.github.takahirom.materialelement.util.ScreenUtil; 11 | 12 | public class AnimateRecyclerAdapter extends RecyclerView.Adapter { 13 | int animatedRow = -1; 14 | 15 | @Override 16 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 17 | View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_row_card, parent, false); 18 | return new RecyclerView.ViewHolder(view) { 19 | }; 20 | } 21 | 22 | @Override 23 | public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { 24 | if (position > animatedRow) { 25 | // https://www.youtube.com/watch?feature=player_detailpage&v=6p3i6H2oGa0#t=602 26 | animatedRow = position; 27 | long animationDelay = 1000 + holder.getAdapterPosition() * 25; 28 | 29 | holder.itemView.setAlpha(0); 30 | holder.itemView.setTranslationY(ScreenUtil.dp2px(16, holder.itemView.getContext())); 31 | 32 | 33 | holder.itemView.animate() 34 | .alpha(1) 35 | .translationY(0) 36 | .setDuration(200) 37 | .setInterpolator(new LinearOutSlowInInterpolator()) 38 | .setStartDelay(animationDelay) 39 | .start(); 40 | } 41 | } 42 | 43 | @Override 44 | public int getItemCount() { 45 | return 4; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/takahirom/materialelement/main/HeaderItem.java: -------------------------------------------------------------------------------- 1 | package com.github.takahirom.materialelement.main; 2 | 3 | class HeaderItem extends ListItem { 4 | 5 | public final String title; 6 | 7 | HeaderItem(int viewType, int itemId, String title) { 8 | super(viewType, itemId); 9 | this.title = title; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/takahirom/materialelement/main/ImplementationItem.java: -------------------------------------------------------------------------------- 1 | package com.github.takahirom.materialelement.main; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | 6 | public class ImplementationItem extends ListItem implements Parcelable { 7 | public final String title; 8 | public final int imageRes; 9 | private final String activityClassName; 10 | 11 | ImplementationItem(int itemId, String title, int imageRes, Class clazz) { 12 | super(ImplementationAdapter.VIEW_TYPE_IMPLEMENTATION, itemId); 13 | 14 | this.title = title; 15 | this.imageRes = imageRes; 16 | this.activityClassName = clazz.getName(); 17 | } 18 | 19 | protected ImplementationItem(Parcel in) { 20 | super(in); 21 | title = in.readString(); 22 | imageRes = in.readInt(); 23 | activityClassName = in.readString(); 24 | } 25 | 26 | @Override 27 | public void writeToParcel(Parcel dest, int flags) { 28 | super.writeToParcel(dest, flags); 29 | dest.writeString(title); 30 | dest.writeInt(imageRes); 31 | dest.writeString(activityClassName); 32 | } 33 | 34 | @Override 35 | public int describeContents() { 36 | return 0; 37 | } 38 | 39 | public static final Creator CREATOR = new Creator() { 40 | @Override 41 | public ImplementationItem createFromParcel(Parcel in) { 42 | return new ImplementationItem(in); 43 | } 44 | 45 | @Override 46 | public ImplementationItem[] newArray(int size) { 47 | return new ImplementationItem[size]; 48 | } 49 | }; 50 | 51 | Class getActivityClass() { 52 | try { 53 | return Class.forName(activityClassName); 54 | } catch (ClassNotFoundException e) { 55 | e.printStackTrace(); 56 | } 57 | 58 | return null; 59 | } 60 | 61 | 62 | } -------------------------------------------------------------------------------- /app/src/main/java/com/github/takahirom/materialelement/main/ListItem.java: -------------------------------------------------------------------------------- 1 | package com.github.takahirom.materialelement.main; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | 6 | class ListItem implements Parcelable { 7 | public int viewType; 8 | public int itemId; 9 | 10 | ListItem(int viewType, int itemId) { 11 | this.viewType = viewType; 12 | this.itemId = itemId; 13 | } 14 | 15 | public ListItem() { 16 | } 17 | 18 | protected ListItem(Parcel in) { 19 | viewType = in.readInt(); 20 | itemId = in.readInt(); 21 | } 22 | 23 | @Override 24 | public void writeToParcel(Parcel dest, int flags) { 25 | dest.writeInt(viewType); 26 | dest.writeInt(itemId); 27 | } 28 | 29 | @Override 30 | public int describeContents() { 31 | return 0; 32 | } 33 | 34 | public static final Creator CREATOR = new Creator() { 35 | @Override 36 | public ListItem createFromParcel(Parcel in) { 37 | return new ListItem(in); 38 | } 39 | 40 | @Override 41 | public ListItem[] newArray(int size) { 42 | return new ListItem[size]; 43 | } 44 | }; 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/takahirom/materialelement/motion/choreography/ShareAllElementActivity.java: -------------------------------------------------------------------------------- 1 | package com.github.takahirom.materialelement.motion.choreography; 2 | 3 | import android.graphics.Bitmap; 4 | import android.support.v4.graphics.drawable.RoundedBitmapDrawable; 5 | import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.os.Bundle; 8 | import android.widget.ImageView; 9 | 10 | import com.github.takahirom.materialelement.MaterialElementActivity; 11 | import com.github.takahirom.materialelement.R; 12 | import com.github.takahirom.materialelement.view.ResourceUtil; 13 | 14 | public class ShareAllElementActivity extends MaterialElementActivity { 15 | 16 | @Override 17 | protected void onCreate(Bundle savedInstanceState) { 18 | super.onCreate(savedInstanceState); 19 | setContentView(R.layout.all_element_share_scene2); 20 | 21 | Bitmap bitmap = ResourceUtil.getBitmap(this, R.drawable.ic_choreography); 22 | RoundedBitmapDrawable circularBitmapDrawable = 23 | RoundedBitmapDrawableFactory.create(getResources(), bitmap); 24 | circularBitmapDrawable.setCircular(true); 25 | final ImageView rowImage = (ImageView) findViewById(R.id.all_element_share_image); 26 | rowImage.setImageDrawable(circularBitmapDrawable); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/takahirom/materialelement/motion/choreography/ShareFewElementActivity.java: -------------------------------------------------------------------------------- 1 | package com.github.takahirom.materialelement.motion.choreography; 2 | 3 | import android.content.Intent; 4 | import android.graphics.Bitmap; 5 | import android.os.Bundle; 6 | import android.support.v4.app.ActivityCompat; 7 | import android.support.v4.graphics.drawable.RoundedBitmapDrawable; 8 | import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory; 9 | import android.support.v7.app.AppCompatActivity; 10 | import android.widget.ImageView; 11 | 12 | import com.github.takahirom.materialelement.MaterialElementActivity; 13 | import com.github.takahirom.materialelement.R; 14 | import com.github.takahirom.materialelement.view.ResourceUtil; 15 | 16 | public class ShareFewElementActivity extends MaterialElementActivity { 17 | 18 | @Override 19 | protected void onCreate(Bundle savedInstanceState) { 20 | super.onCreate(savedInstanceState); 21 | setContentView(R.layout.activity_share_few_element); 22 | 23 | 24 | Bitmap bitmap = ResourceUtil.getBitmap(this, R.drawable.ic_choreography); 25 | RoundedBitmapDrawable circularBitmapDrawable = 26 | RoundedBitmapDrawableFactory.create(getResources(), bitmap); 27 | circularBitmapDrawable.setCircular(true); 28 | final ImageView rowImage = (ImageView) findViewById(R.id.few_element_share_image); 29 | rowImage.setImageDrawable(circularBitmapDrawable); 30 | } 31 | 32 | @Override 33 | public void onBackPressed() { 34 | setResultAndFinish(); 35 | } 36 | 37 | 38 | void setResultAndFinish() { 39 | final Intent resultData = new Intent(); 40 | setResult(RESULT_OK, resultData); 41 | ActivityCompat.finishAfterTransition(this); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/takahirom/materialelement/motion/creative/CreativeCustomizationActivity.java: -------------------------------------------------------------------------------- 1 | package com.github.takahirom.materialelement.motion.creative; 2 | 3 | import android.content.Intent; 4 | import android.graphics.drawable.Animatable; 5 | import android.os.Bundle; 6 | import android.support.design.widget.CollapsingToolbarLayout; 7 | import android.support.v4.app.ActivityCompat; 8 | import android.support.v7.app.AppCompatActivity; 9 | import android.support.v7.widget.Toolbar; 10 | import android.transition.Transition; 11 | import android.view.View; 12 | import android.widget.ImageView; 13 | 14 | import com.github.takahirom.materialelement.MaterialElementActivity; 15 | import com.github.takahirom.materialelement.R; 16 | import com.github.takahirom.materialelement.animation.transition.TransitionUtils; 17 | import com.github.takahirom.materialelement.main.ImplementationItem; 18 | 19 | public class CreativeCustomizationActivity extends MaterialElementActivity { 20 | 21 | public final static String RESULT_EXTRA_ITEM_ID = "RESULT_EXTRA_ITEM_ID"; 22 | public static final String INTENT_EXTRA_ITEM = "item"; 23 | private ImplementationItem item; 24 | 25 | @Override 26 | protected void onCreate(Bundle savedInstanceState) { 27 | super.onCreate(savedInstanceState); 28 | setContentView(R.layout.activity_creative_customization); 29 | item = getIntent().getParcelableExtra(INTENT_EXTRA_ITEM); 30 | 31 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 32 | setSupportActionBar(toolbar); 33 | 34 | setupViews(); 35 | } 36 | 37 | public void setupViews() { 38 | final CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); 39 | 40 | final ImageView imageView = (ImageView) findViewById(R.id.detail_image); 41 | // collapsingToolbarLayout.setExpandedTitleColor(ContextCompat.getColor(DurationAndEasingActivity.this, android.R.color.white)); 42 | 43 | imageView.setImageResource(item.imageRes); 44 | TransitionUtils.setSharedElementEnterTransitionEndListenerCompat(getWindow(), new TransitionUtils.OnSharedElementEnterTransitionEndListener() { 45 | @Override 46 | public void onEnd(Transition transition) { 47 | collapsingToolbarLayout.setTitleEnabled(true); 48 | collapsingToolbarLayout.setTitle(item.title); 49 | } 50 | }); 51 | final ImageView systemIconImageView = (ImageView) findViewById(R.id.system_icon); 52 | systemIconImageView.setOnClickListener(new View.OnClickListener() { 53 | @Override 54 | public void onClick(View v) { 55 | ((Animatable) systemIconImageView.getDrawable()).start(); 56 | } 57 | }); 58 | 59 | } 60 | 61 | @Override 62 | public void onBackPressed() { 63 | setResultAndFinish(); 64 | } 65 | 66 | 67 | void setResultAndFinish() { 68 | final Intent resultData = new Intent(); 69 | resultData.putExtra(RESULT_EXTRA_ITEM_ID, item.itemId); 70 | setResult(RESULT_OK, resultData); 71 | ActivityCompat.finishAfterTransition(this); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/takahirom/materialelement/motion/movement/MovementActivity.java: -------------------------------------------------------------------------------- 1 | package com.github.takahirom.materialelement.motion.movement; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.design.widget.CollapsingToolbarLayout; 6 | import android.support.v4.app.ActivityCompat; 7 | import android.support.v4.view.animation.FastOutSlowInInterpolator; 8 | import android.support.v7.app.AppCompatActivity; 9 | import android.support.v7.widget.CardView; 10 | import android.support.v7.widget.Toolbar; 11 | import android.transition.Scene; 12 | import android.transition.Transition; 13 | import android.transition.TransitionInflater; 14 | import android.transition.TransitionManager; 15 | import android.view.View; 16 | import android.widget.ImageView; 17 | import android.widget.RelativeLayout; 18 | import android.widget.Toast; 19 | 20 | import com.github.takahirom.materialelement.MaterialElementActivity; 21 | import com.github.takahirom.materialelement.animation.OnetimeViewTreeObserver; 22 | import com.github.takahirom.materialelement.animation.transition.TransitionUtils; 23 | import com.github.takahirom.materialelement.main.ImplementationItem; 24 | import com.github.takahirom.materialelement.R; 25 | import com.github.takahirom.materialelement.util.AndroidVersionUtil; 26 | import com.github.takahirom.materialelement.util.ScreenUtil; 27 | 28 | public class MovementActivity extends MaterialElementActivity { 29 | 30 | 31 | public final static String RESULT_EXTRA_ITEM_ID = "RESULT_EXTRA_ITEM_ID"; 32 | public static final String INTENT_EXTRA_ITEM = "item"; 33 | private ImplementationItem item; 34 | private Scene arcScene1; 35 | private Scene arcScene2; 36 | private Scene notArcScene1; 37 | private Scene notArcScene2; 38 | 39 | @Override 40 | protected void onCreate(Bundle savedInstanceState) { 41 | super.onCreate(savedInstanceState); 42 | setContentView(R.layout.activity_movement); 43 | item = getIntent().getParcelableExtra(INTENT_EXTRA_ITEM); 44 | 45 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 46 | setSupportActionBar(toolbar); 47 | 48 | setupViews(); 49 | } 50 | 51 | public void setupViews() { 52 | final CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); 53 | 54 | final ImageView imageView = (ImageView) findViewById(R.id.detail_image); 55 | 56 | // collapsingToolbarLayout.setExpandedTitleColor(ContextCompat.getColor(MovementActivity.this, android.R.color.white)); 57 | imageView.setImageResource(item.imageRes); 58 | 59 | TransitionUtils.setSharedElementEnterTransitionEndListenerCompat(getWindow(), new TransitionUtils.OnSharedElementEnterTransitionEndListener() { 60 | @Override 61 | public void onEnd(Transition transition) { 62 | collapsingToolbarLayout.setTitleEnabled(true); 63 | collapsingToolbarLayout.setTitle(item.title); 64 | 65 | TransitionManager.go(arcScene1); 66 | TransitionManager.go(notArcScene1); 67 | } 68 | }); 69 | 70 | setupArcMotion(); 71 | setupNotArcMotion(); 72 | 73 | final CardView cardView = (CardView) findViewById(R.id.inset_card); 74 | final View fab = findViewById(R.id.fab); 75 | fab.setOnClickListener(new View.OnClickListener() { 76 | @Override 77 | public void onClick(View v) { 78 | if (cardView.getTranslationY() > 0) { 79 | cardView 80 | .animate() 81 | .translationY(0) 82 | .setInterpolator(new FastOutSlowInInterpolator()) 83 | .start(); 84 | } else { 85 | cardView 86 | .animate() 87 | .translationY(cardView.getHeight()) 88 | .setInterpolator(new FastOutSlowInInterpolator()) 89 | .start(); 90 | } 91 | 92 | } 93 | }); 94 | } 95 | 96 | private void setupArcMotion() { 97 | final RelativeLayout sceneRoot = (RelativeLayout) findViewById(R.id.arc_scene_root); 98 | if (AndroidVersionUtil.isGreaterThanL()) { 99 | arcScene1 = Scene.getSceneForLayout(sceneRoot, R.layout.card_arc_scene1, this); 100 | arcScene2 = Scene.getSceneForLayout(sceneRoot, R.layout.card_arc_scene2, this); 101 | sceneRoot.setOnClickListener(new View.OnClickListener() { 102 | boolean isScene2 = false; 103 | 104 | @Override 105 | public void onClick(View v) { 106 | final Transition transition = TransitionInflater.from(MovementActivity.this).inflateTransition(R.transition.movement_change_bounds_arc); 107 | if (isScene2) { 108 | TransitionManager.go(arcScene1, transition); 109 | } else { 110 | TransitionManager.go(arcScene2, transition); 111 | } 112 | isScene2 = !isScene2; 113 | } 114 | }); 115 | } else { 116 | sceneRoot.setOnClickListener(new View.OnClickListener() { 117 | @Override 118 | public void onClick(View v) { 119 | Toast.makeText(MovementActivity.this, R.string.all_not_support_os_version, Toast.LENGTH_LONG).show(); 120 | } 121 | }); 122 | } 123 | } 124 | 125 | 126 | private void setupNotArcMotion() { 127 | final RelativeLayout sceneRoot = (RelativeLayout) findViewById(R.id.not_arc_scene_root); 128 | if (AndroidVersionUtil.isGreaterThanL()) { 129 | notArcScene1 = Scene.getSceneForLayout(sceneRoot, R.layout.card_not_arc_scene1, this); 130 | notArcScene2 = Scene.getSceneForLayout(sceneRoot, R.layout.card_not_arc_scene2, this); 131 | sceneRoot.setOnClickListener(new View.OnClickListener() { 132 | boolean isScene2 = false; 133 | 134 | @Override 135 | public void onClick(View v) { 136 | if (isScene2) { 137 | TransitionManager.go(notArcScene1, TransitionInflater.from(MovementActivity.this).inflateTransition(R.transition.movement_change_bounds_arc)); 138 | } else { 139 | TransitionManager.go(notArcScene2, TransitionInflater.from(MovementActivity.this).inflateTransition(R.transition.movement_change_bounds_arc)); 140 | } 141 | isScene2 = !isScene2; 142 | } 143 | }); 144 | } else { 145 | sceneRoot.setOnClickListener(new View.OnClickListener() { 146 | @Override 147 | public void onClick(View v) { 148 | Toast.makeText(MovementActivity.this, R.string.all_not_support_os_version, Toast.LENGTH_LONG).show(); 149 | } 150 | }); 151 | } 152 | } 153 | 154 | 155 | @Override 156 | public void onBackPressed() { 157 | setResultAndFinish(); 158 | } 159 | 160 | 161 | void setResultAndFinish() { 162 | final Intent resultData = new Intent(); 163 | resultData.putExtra(RESULT_EXTRA_ITEM_ID, item.itemId); 164 | setResult(RESULT_OK, resultData); 165 | ActivityCompat.finishAfterTransition(this); 166 | } 167 | 168 | } 169 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/takahirom/materialelement/motion/transforming/LoginActivity.java: -------------------------------------------------------------------------------- 1 | package com.github.takahirom.materialelement.motion.transforming; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | import android.support.annotation.Nullable; 6 | import android.support.v4.app.ActivityCompat; 7 | import android.view.View; 8 | 9 | import com.github.takahirom.materialelement.R; 10 | import com.github.takahirom.materialelement.animation.transition.FabTransform; 11 | import com.github.takahirom.materialelement.util.AndroidVersionUtil; 12 | 13 | 14 | public class LoginActivity extends Activity { 15 | @Override 16 | protected void onCreate(@Nullable Bundle savedInstanceState) { 17 | super.onCreate(savedInstanceState); 18 | setContentView(R.layout.activity_login); 19 | if (AndroidVersionUtil.isGreaterThanL()) { 20 | FabTransform.setup(this, findViewById(R.id.container)); 21 | } 22 | } 23 | 24 | 25 | public void dismiss(View view) { 26 | ActivityCompat.finishAfterTransition(this); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/takahirom/materialelement/motion/transforming/TransformingActivity.java: -------------------------------------------------------------------------------- 1 | package com.github.takahirom.materialelement.motion.transforming; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.design.widget.CollapsingToolbarLayout; 6 | import android.support.v4.app.ActivityCompat; 7 | import android.support.v4.app.ActivityOptionsCompat; 8 | import android.support.v4.content.ContextCompat; 9 | import android.support.v4.view.ViewCompat; 10 | import android.support.v4.view.animation.FastOutSlowInInterpolator; 11 | import android.support.v7.app.AppCompatActivity; 12 | import android.support.v7.widget.CardView; 13 | import android.support.v7.widget.Toolbar; 14 | import android.transition.Transition; 15 | import android.view.View; 16 | import android.widget.ImageView; 17 | 18 | import com.github.takahirom.materialelement.MaterialElementActivity; 19 | import com.github.takahirom.materialelement.animation.transition.TransitionUtils; 20 | import com.github.takahirom.materialelement.main.ImplementationItem; 21 | import com.github.takahirom.materialelement.R; 22 | import com.github.takahirom.materialelement.animation.transition.FabTransform; 23 | import com.github.takahirom.materialelement.util.AndroidVersionUtil; 24 | 25 | public class TransformingActivity extends MaterialElementActivity { 26 | 27 | public final static String RESULT_EXTRA_ITEM_ID = "RESULT_EXTRA_ITEM_ID"; 28 | public static final String INTENT_EXTRA_ITEM = "item"; 29 | private ImplementationItem item; 30 | 31 | @Override 32 | protected void onCreate(Bundle savedInstanceState) { 33 | super.onCreate(savedInstanceState); 34 | setContentView(R.layout.activity_transforming); 35 | item = getIntent().getParcelableExtra(INTENT_EXTRA_ITEM); 36 | 37 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 38 | setSupportActionBar(toolbar); 39 | 40 | setupViews(); 41 | } 42 | 43 | public void setupViews() { 44 | final CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); 45 | 46 | final ImageView imageView = (ImageView) findViewById(R.id.detail_image); 47 | // collapsingToolbarLayout.setExpandedTitleColor(ContextCompat.getColor(TransformingActivity.this, android.R.color.white)); 48 | imageView.setImageResource(item.imageRes); 49 | 50 | TransitionUtils.setSharedElementEnterTransitionEndListenerCompat(getWindow(), new TransitionUtils.OnSharedElementEnterTransitionEndListener() { 51 | @Override 52 | public void onEnd(Transition transition) { 53 | collapsingToolbarLayout.setTitleEnabled(true); 54 | collapsingToolbarLayout.setTitle(item.title); 55 | } 56 | }); 57 | 58 | findViewById(R.id.aync_card).setOnClickListener(new View.OnClickListener() { 59 | @Override 60 | public void onClick(View v) { 61 | final CardView cardView = (CardView) findViewById(R.id.aync_card); 62 | cardView.setOnClickListener(new View.OnClickListener() { 63 | boolean isSmall = true; 64 | 65 | @Override 66 | public void onClick(View view) { 67 | if (isSmall) { 68 | ViewCompat 69 | .animate(view) 70 | .scaleX(3.0f) 71 | .setDuration(275) 72 | .setStartDelay(0) 73 | .setInterpolator(new FastOutSlowInInterpolator()) 74 | .start(); 75 | ViewCompat 76 | .animate(view) 77 | .scaleY(3.0f) 78 | .setDuration(350) 79 | .setStartDelay(25) // 開始をずらす 80 | .setInterpolator(new FastOutSlowInInterpolator()) 81 | .start(); 82 | } else { 83 | ViewCompat 84 | .animate(view) 85 | .scaleX(1.0f) 86 | .setDuration(325) 87 | .setStartDelay(50) 88 | .setInterpolator(new FastOutSlowInInterpolator()) 89 | .start(); 90 | ViewCompat 91 | .animate(view) 92 | .scaleY(1.0f) 93 | .setStartDelay(0) 94 | .setDuration(325) 95 | .setInterpolator(new FastOutSlowInInterpolator()) 96 | .start(); 97 | } 98 | isSmall = !isSmall; 99 | } 100 | }); 101 | } 102 | }); 103 | 104 | findViewById(R.id.sync_card).setOnClickListener(new View.OnClickListener() { 105 | boolean isSmall = true; 106 | 107 | @Override 108 | public void onClick(View v) { 109 | ViewCompat 110 | .animate(v) 111 | .scaleX(isSmall ? 3.0f : 1.0f) 112 | .scaleY(isSmall ? 3.0f : 1.0f) 113 | .setDuration(300) 114 | .setInterpolator(new FastOutSlowInInterpolator()) 115 | .start(); 116 | isSmall = !isSmall; 117 | } 118 | }); 119 | 120 | findViewById(R.id.fab).setOnClickListener(new View.OnClickListener() { 121 | @Override 122 | public void onClick(View v) { 123 | Intent intent = new Intent(TransformingActivity.this, LoginActivity.class); 124 | int color = ContextCompat.getColor(TransformingActivity.this, R.color.colorAccent); 125 | if (AndroidVersionUtil.isGreaterThanL()) { 126 | FabTransform.addExtras(intent, color, R.drawable.ic_add_white_24dp); 127 | } 128 | ActivityOptionsCompat optionsCompat = ActivityOptionsCompat 129 | .makeSceneTransitionAnimation(TransformingActivity.this, 130 | v, 131 | getString(R.string.transition_name_login)); 132 | ActivityCompat.startActivity(TransformingActivity.this, 133 | intent, 134 | optionsCompat.toBundle()); 135 | } 136 | }); 137 | 138 | 139 | } 140 | 141 | @Override 142 | public void onBackPressed() { 143 | setResultAndFinish(); 144 | } 145 | 146 | 147 | void setResultAndFinish() { 148 | final Intent resultData = new Intent(); 149 | resultData.putExtra(RESULT_EXTRA_ITEM_ID, item.itemId); 150 | setResult(RESULT_OK, resultData); 151 | ActivityCompat.finishAfterTransition(this); 152 | } 153 | 154 | 155 | } 156 | 157 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/takahirom/materialelement/pattern/loadingimages/LoadingImagesActivity.java: -------------------------------------------------------------------------------- 1 | package com.github.takahirom.materialelement.pattern.loadingimages; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.design.widget.CollapsingToolbarLayout; 6 | import android.support.v4.app.ActivityCompat; 7 | import android.support.v7.app.AppCompatActivity; 8 | import android.support.v7.widget.Toolbar; 9 | import android.transition.Transition; 10 | import android.view.View; 11 | import android.widget.ImageView; 12 | 13 | import com.github.takahirom.materialelement.MaterialElementActivity; 14 | import com.github.takahirom.materialelement.R; 15 | import com.github.takahirom.materialelement.animation.transition.AnimatorUtils; 16 | import com.github.takahirom.materialelement.animation.transition.TransitionUtils; 17 | import com.github.takahirom.materialelement.main.ImplementationItem; 18 | 19 | public class LoadingImagesActivity extends MaterialElementActivity { 20 | 21 | public final static String RESULT_EXTRA_ITEM_ID = "RESULT_EXTRA_ITEM_ID"; 22 | public static final String INTENT_EXTRA_ITEM = "item"; 23 | private ImplementationItem item; 24 | 25 | @Override 26 | protected void onCreate(Bundle savedInstanceState) { 27 | super.onCreate(savedInstanceState); 28 | setContentView(R.layout.activity_loading_images); 29 | item = getIntent().getParcelableExtra(INTENT_EXTRA_ITEM); 30 | 31 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 32 | setSupportActionBar(toolbar); 33 | 34 | setupViews(); 35 | } 36 | 37 | public void setupViews() { 38 | final CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); 39 | 40 | final ImageView imageView = (ImageView) findViewById(R.id.detail_image); 41 | // collapsingToolbarLayout.setExpandedTitleColor(ContextCompat.getColor(DurationAndEasingActivity.this, android.R.color.white)); 42 | 43 | imageView.setImageResource(item.imageRes); 44 | TransitionUtils.setSharedElementEnterTransitionEndListenerCompat(getWindow(), new TransitionUtils.OnSharedElementEnterTransitionEndListener() { 45 | @Override 46 | public void onEnd(Transition transition) { 47 | collapsingToolbarLayout.setTitleEnabled(true); 48 | collapsingToolbarLayout.setTitle(item.title); 49 | } 50 | }); 51 | 52 | final ImageView loadingImageImageView = (ImageView) findViewById(R.id.loading_image); 53 | loadingImageImageView.setImageResource(item.imageRes); 54 | loadingImageImageView.setOnClickListener(new View.OnClickListener() { 55 | @Override 56 | public void onClick(View v) { 57 | AnimatorUtils.startLoadingAnimation(loadingImageImageView); 58 | } 59 | }); 60 | } 61 | 62 | 63 | @Override 64 | public void onBackPressed() { 65 | setResultAndFinish(); 66 | } 67 | 68 | 69 | void setResultAndFinish() { 70 | final Intent resultData = new Intent(); 71 | resultData.putExtra(RESULT_EXTRA_ITEM_ID, item.itemId); 72 | setResult(RESULT_OK, resultData); 73 | ActivityCompat.finishAfterTransition(this); 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/takahirom/materialelement/pattern/transition/ChildActivity.java: -------------------------------------------------------------------------------- 1 | package com.github.takahirom.materialelement.pattern.transition; 2 | 3 | import android.os.Bundle; 4 | import android.support.design.widget.FloatingActionButton; 5 | import android.support.design.widget.Snackbar; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.support.v7.widget.Toolbar; 8 | import android.view.View; 9 | 10 | import com.github.takahirom.materialelement.MaterialElementActivity; 11 | import com.github.takahirom.materialelement.R; 12 | 13 | public class ChildActivity extends MaterialElementActivity { 14 | 15 | @Override 16 | protected void onCreate(Bundle savedInstanceState) { 17 | super.onCreate(savedInstanceState); 18 | setContentView(R.layout.activity_child); 19 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 20 | setSupportActionBar(toolbar); 21 | 22 | 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/takahirom/materialelement/pattern/transition/NavigationalTransitionActivity.java: -------------------------------------------------------------------------------- 1 | package com.github.takahirom.materialelement.pattern.transition; 2 | 3 | import android.animation.Animator; 4 | import android.animation.AnimatorListenerAdapter; 5 | import android.animation.ObjectAnimator; 6 | import android.animation.ValueAnimator; 7 | import android.content.Intent; 8 | import android.graphics.ColorMatrixColorFilter; 9 | import android.os.Bundle; 10 | import android.support.design.widget.CollapsingToolbarLayout; 11 | import android.support.v4.app.ActivityCompat; 12 | import android.support.v4.app.ActivityOptionsCompat; 13 | import android.support.v4.view.ViewCompat; 14 | import android.support.v4.view.animation.FastOutSlowInInterpolator; 15 | import android.support.v7.app.AppCompatActivity; 16 | import android.support.v7.widget.DividerItemDecoration; 17 | import android.support.v7.widget.LinearLayoutManager; 18 | import android.support.v7.widget.RecyclerView; 19 | import android.support.v7.widget.Toolbar; 20 | import android.transition.Transition; 21 | import android.view.View; 22 | import android.widget.ImageView; 23 | 24 | import com.github.takahirom.materialelement.MaterialElementActivity; 25 | import com.github.takahirom.materialelement.R; 26 | import com.github.takahirom.materialelement.animation.ObservableColorMatrix; 27 | import com.github.takahirom.materialelement.animation.OnetimeViewTreeObserver; 28 | import com.github.takahirom.materialelement.animation.transition.TransitionUtils; 29 | import com.github.takahirom.materialelement.main.ImplementationItem; 30 | import com.github.takahirom.materialelement.util.ThemeUtil; 31 | 32 | public class NavigationalTransitionActivity extends MaterialElementActivity { 33 | 34 | public final static String RESULT_EXTRA_ITEM_ID = "RESULT_EXTRA_ITEM_ID"; 35 | public static final String INTENT_EXTRA_ITEM = "item"; 36 | private ImplementationItem item; 37 | 38 | @Override 39 | protected void onCreate(Bundle savedInstanceState) { 40 | super.onCreate(savedInstanceState); 41 | setContentView(R.layout.activity_navigational_transition); 42 | item = getIntent().getParcelableExtra(INTENT_EXTRA_ITEM); 43 | 44 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 45 | setSupportActionBar(toolbar); 46 | 47 | setupViews(); 48 | } 49 | 50 | public void setupViews() { 51 | final CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); 52 | TransitionUtils.setSharedElementEnterTransitionEndListenerCompat(getWindow(), new TransitionUtils.OnSharedElementEnterTransitionEndListener() { 53 | @Override 54 | public void onEnd(Transition transition) { 55 | collapsingToolbarLayout.setTitleEnabled(true); 56 | collapsingToolbarLayout.setTitle(item.title); 57 | 58 | // FIXME: recycler view breaks AppbarLayout 59 | setupRecyclerView(); 60 | } 61 | }); 62 | 63 | final ImageView imageView = (ImageView) findViewById(R.id.detail_image); 64 | // collapsingToolbarLayout.setExpandedTitleColor(ContextCompat.getColor(DurationAndEasingActivity.this, android.R.color.white)); 65 | 66 | imageView.setImageResource(item.imageRes); 67 | 68 | } 69 | 70 | private void setupRecyclerView() { 71 | RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view); 72 | recyclerView.setVisibility(View.VISIBLE); 73 | recyclerView.setLayoutManager(new LinearLayoutManager(this)); 74 | recyclerView.setAdapter(new RecyclerViewAdapter(new RecyclerViewAdapter.OnItemClickListener() { 75 | @Override 76 | public void onClick(int position, View view) { 77 | Intent intent = new Intent(NavigationalTransitionActivity.this, ChildActivity.class); 78 | String elementName = getString(R.string.transition_name_navigational_transition); 79 | ActivityOptionsCompat activityOptionsCompat = ActivityOptionsCompat.makeSceneTransitionAnimation(NavigationalTransitionActivity.this, view, elementName); 80 | startActivity(intent, activityOptionsCompat.toBundle()); 81 | } 82 | })); 83 | recyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL)); 84 | } 85 | 86 | 87 | @Override 88 | public void onBackPressed() { 89 | setResultAndFinish(); 90 | } 91 | 92 | 93 | void setResultAndFinish() { 94 | final Intent resultData = new Intent(); 95 | resultData.putExtra(RESULT_EXTRA_ITEM_ID, item.itemId); 96 | setResult(RESULT_OK, resultData); 97 | ActivityCompat.finishAfterTransition(this); 98 | } 99 | 100 | } 101 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/takahirom/materialelement/pattern/transition/RecyclerViewAdapter.java: -------------------------------------------------------------------------------- 1 | package com.github.takahirom.materialelement.pattern.transition; 2 | 3 | import android.support.v7.widget.CardView; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | 9 | import com.github.takahirom.materialelement.R; 10 | 11 | 12 | public class RecyclerViewAdapter extends RecyclerView.Adapter { 13 | OnItemClickListener onItemClickListener; 14 | 15 | public RecyclerViewAdapter(OnItemClickListener onItemClickListener) { 16 | this.onItemClickListener = onItemClickListener; 17 | } 18 | 19 | @Override 20 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 21 | View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_navigational_transition, parent, false); 22 | return new RecyclerView.ViewHolder(view) { 23 | }; 24 | } 25 | 26 | @Override 27 | public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) { 28 | holder.itemView.setOnClickListener(new View.OnClickListener() { 29 | @Override 30 | public void onClick(View v) { 31 | onItemClickListener.onClick(position, v); 32 | } 33 | }); 34 | } 35 | 36 | @Override 37 | public int getItemCount() { 38 | return 5; 39 | } 40 | 41 | interface OnItemClickListener { 42 | void onClick(int position, View view); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/takahirom/materialelement/util/AndroidVersionUtil.java: -------------------------------------------------------------------------------- 1 | package com.github.takahirom.materialelement.util; 2 | 3 | import android.os.Build; 4 | 5 | public class AndroidVersionUtil { 6 | public static boolean isGreaterThanKitKat() { 7 | return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT; 8 | } 9 | 10 | public static boolean isGreaterThanL() { 11 | return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP; 12 | } 13 | 14 | public static boolean isGreaterThanM() { 15 | return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/takahirom/materialelement/util/ScreenUtil.java: -------------------------------------------------------------------------------- 1 | package com.github.takahirom.materialelement.util; 2 | 3 | import android.content.Context; 4 | 5 | public class ScreenUtil { 6 | public static float dp2px(int dip, Context context) { 7 | float scale = context.getResources().getDisplayMetrics().density; 8 | return dip * scale + 0.5f; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/takahirom/materialelement/util/ThemeUtil.java: -------------------------------------------------------------------------------- 1 | package com.github.takahirom.materialelement.util; 2 | 3 | import android.app.Activity; 4 | import android.app.ActivityManager; 5 | import android.graphics.Bitmap; 6 | import android.graphics.BitmapFactory; 7 | import android.support.v4.content.ContextCompat; 8 | import android.transition.Transition; 9 | import android.view.Window; 10 | 11 | import com.github.takahirom.materialelement.R; 12 | 13 | public class ThemeUtil { 14 | public static void setTaskDescriptionColor(Activity activity) { 15 | if (AndroidVersionUtil.isGreaterThanL()) { 16 | Bitmap bm = BitmapFactory.decodeResource(activity.getResources(), R.mipmap.element_icon); 17 | String name = activity.getString(R.string.app_name); 18 | int color = ContextCompat.getColor(activity, R.color.colorPrimaryDark); 19 | ActivityManager.TaskDescription taskDesc = new ActivityManager.TaskDescription(name, bm, color); 20 | activity.setTaskDescription(taskDesc); 21 | } 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/takahirom/materialelement/view/ForegroundConstraintLayout.java: -------------------------------------------------------------------------------- 1 | package com.github.takahirom.materialelement.view; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.Canvas; 6 | import android.graphics.drawable.Drawable; 7 | import android.support.constraint.ConstraintLayout; 8 | import android.util.AttributeSet; 9 | import android.view.ViewOutlineProvider; 10 | 11 | import com.github.takahirom.materialelement.R; 12 | import com.github.takahirom.materialelement.util.AndroidVersionUtil; 13 | 14 | public class ForegroundConstraintLayout extends ConstraintLayout { 15 | private Drawable foreground; 16 | 17 | public ForegroundConstraintLayout(Context context) { 18 | super(context); 19 | } 20 | 21 | public ForegroundConstraintLayout(Context context, AttributeSet attrs) { 22 | super(context, attrs); 23 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ForegroundView); 24 | 25 | final Drawable d = a.getDrawable(R.styleable.ForegroundView_android_foreground); 26 | if (d != null) { 27 | setForeground(d); 28 | } 29 | a.recycle(); 30 | if (AndroidVersionUtil.isGreaterThanL()) { 31 | setOutlineProvider(ViewOutlineProvider.BOUNDS); 32 | } 33 | } 34 | 35 | @Override 36 | protected void onSizeChanged(int w, int h, int oldw, int oldh) { 37 | super.onSizeChanged(w, h, oldw, oldh); 38 | if (foreground != null) { 39 | foreground.setBounds(0, 0, w, h); 40 | } 41 | } 42 | 43 | @Override 44 | public boolean hasOverlappingRendering() { 45 | return false; 46 | } 47 | 48 | @Override 49 | protected boolean verifyDrawable(Drawable who) { 50 | return super.verifyDrawable(who) || (who == foreground); 51 | } 52 | 53 | @Override 54 | public void jumpDrawablesToCurrentState() { 55 | super.jumpDrawablesToCurrentState(); 56 | if (foreground != null) foreground.jumpToCurrentState(); 57 | } 58 | 59 | @Override 60 | protected void drawableStateChanged() { 61 | super.drawableStateChanged(); 62 | if (foreground != null && foreground.isStateful()) { 63 | foreground.setState(getDrawableState()); 64 | } 65 | } 66 | 67 | /** 68 | * Returns the drawable used as the foreground of this view. The 69 | * foreground drawable, if non-null, is always drawn on top of the children. 70 | * 71 | * @return A Drawable or null if no foreground was set. 72 | */ 73 | @Override 74 | public Drawable getForeground() { 75 | return foreground; 76 | } 77 | 78 | /** 79 | * Supply a Drawable that is to be rendered on top of all of the child 80 | * views within this layout. Any padding in the Drawable will be taken 81 | * into account by ensuring that the children are inset to be placed 82 | * inside of the padding area. 83 | * 84 | * @param drawable The Drawable to be drawn on top of the children. 85 | */ 86 | @Override 87 | public void setForeground(Drawable drawable) { 88 | if (foreground != drawable) { 89 | if (foreground != null) { 90 | foreground.setCallback(null); 91 | unscheduleDrawable(foreground); 92 | } 93 | 94 | foreground = drawable; 95 | 96 | if (foreground != null) { 97 | foreground.setBounds(getLeft(), getTop(), getRight(), getBottom()); 98 | setWillNotDraw(false); 99 | foreground.setCallback(this); 100 | if (foreground.isStateful()) { 101 | foreground.setState(getDrawableState()); 102 | } 103 | } else { 104 | setWillNotDraw(true); 105 | } 106 | invalidate(); 107 | } 108 | } 109 | 110 | @Override 111 | public void draw(Canvas canvas) { 112 | super.draw(canvas); 113 | if (foreground != null) { 114 | foreground.draw(canvas); 115 | } 116 | } 117 | 118 | @Override 119 | public void drawableHotspotChanged(float x, float y) { 120 | super.drawableHotspotChanged(x, y); 121 | if (foreground != null) { 122 | foreground.setHotspot(x, y); 123 | } 124 | } 125 | 126 | } 127 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/takahirom/materialelement/view/ForegroundImageView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.github.takahirom.materialelement.view; 18 | 19 | import android.content.Context; 20 | import android.content.res.TypedArray; 21 | import android.graphics.Canvas; 22 | import android.graphics.drawable.Drawable; 23 | import android.util.AttributeSet; 24 | import android.view.ViewOutlineProvider; 25 | import android.widget.ImageView; 26 | 27 | import com.github.takahirom.materialelement.R; 28 | 29 | 30 | /** 31 | * An extension to {@link ImageView} which has a foreground drawable. 32 | */ 33 | public class ForegroundImageView extends ImageView { 34 | 35 | private Drawable foreground; 36 | 37 | public ForegroundImageView(Context context, AttributeSet attrs) { 38 | super(context, attrs); 39 | 40 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ForegroundView); 41 | 42 | final Drawable d = a.getDrawable(R.styleable.ForegroundView_android_foreground); 43 | if (d != null) { 44 | setForeground(d); 45 | } 46 | a.recycle(); 47 | setOutlineProvider(ViewOutlineProvider.BOUNDS); 48 | } 49 | 50 | @Override 51 | protected void onSizeChanged(int w, int h, int oldw, int oldh) { 52 | super.onSizeChanged(w, h, oldw, oldh); 53 | if (foreground != null) { 54 | foreground.setBounds(0, 0, w, h); 55 | } 56 | } 57 | 58 | @Override 59 | public boolean hasOverlappingRendering() { 60 | return false; 61 | } 62 | 63 | @Override 64 | protected boolean verifyDrawable(Drawable who) { 65 | return super.verifyDrawable(who) || (who == foreground); 66 | } 67 | 68 | @Override 69 | public void jumpDrawablesToCurrentState() { 70 | super.jumpDrawablesToCurrentState(); 71 | if (foreground != null) foreground.jumpToCurrentState(); 72 | } 73 | 74 | @Override 75 | protected void drawableStateChanged() { 76 | super.drawableStateChanged(); 77 | if (foreground != null && foreground.isStateful()) { 78 | foreground.setState(getDrawableState()); 79 | } 80 | } 81 | 82 | /** 83 | * Returns the drawable used as the foreground of this view. The 84 | * foreground drawable, if non-null, is always drawn on top of the children. 85 | * 86 | * @return A Drawable or null if no foreground was set. 87 | */ 88 | @Override 89 | public Drawable getForeground() { 90 | return foreground; 91 | } 92 | 93 | /** 94 | * Supply a Drawable that is to be rendered on top of the contents of this ImageView 95 | * 96 | * @param drawable The Drawable to be drawn on top of the ImageView 97 | */ 98 | @Override 99 | public void setForeground(Drawable drawable) { 100 | if (foreground != drawable) { 101 | if (foreground != null) { 102 | foreground.setCallback(null); 103 | unscheduleDrawable(foreground); 104 | } 105 | 106 | foreground = drawable; 107 | 108 | if (foreground != null) { 109 | foreground.setBounds(0, 0, getWidth(), getHeight()); 110 | setWillNotDraw(false); 111 | foreground.setCallback(this); 112 | if (foreground.isStateful()) { 113 | foreground.setState(getDrawableState()); 114 | } 115 | } else { 116 | setWillNotDraw(true); 117 | } 118 | invalidate(); 119 | } 120 | } 121 | 122 | @Override 123 | public void draw(Canvas canvas) { 124 | super.draw(canvas); 125 | if (foreground != null) { 126 | foreground.draw(canvas); 127 | } 128 | } 129 | 130 | @Override 131 | public void drawableHotspotChanged(float x, float y) { 132 | super.drawableHotspotChanged(x, y); 133 | if (foreground != null) { 134 | foreground.setHotspot(x, y); 135 | } 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/takahirom/materialelement/view/ForegroundRelativeLayout.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.github.takahirom.materialelement.view; 18 | 19 | import android.content.Context; 20 | import android.content.res.TypedArray; 21 | import android.graphics.Canvas; 22 | import android.graphics.drawable.Drawable; 23 | import android.os.Build; 24 | import android.util.AttributeSet; 25 | import android.view.ViewOutlineProvider; 26 | import android.widget.RelativeLayout; 27 | 28 | import com.github.takahirom.materialelement.R; 29 | import com.github.takahirom.materialelement.util.AndroidVersionUtil; 30 | 31 | 32 | /** 33 | * An extension to {@link RelativeLayout} which has a foreground drawable. 34 | */ 35 | public class ForegroundRelativeLayout extends RelativeLayout { 36 | 37 | private Drawable foreground; 38 | 39 | public ForegroundRelativeLayout(Context context, AttributeSet attrs) { 40 | super(context, attrs); 41 | 42 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ForegroundView); 43 | 44 | final Drawable d = a.getDrawable(R.styleable.ForegroundView_android_foreground); 45 | if (d != null) { 46 | setForeground(d); 47 | } 48 | a.recycle(); 49 | if (AndroidVersionUtil.isGreaterThanL()) { 50 | setOutlineProvider(ViewOutlineProvider.BOUNDS); 51 | } 52 | } 53 | 54 | @Override 55 | protected void onSizeChanged(int w, int h, int oldw, int oldh) { 56 | super.onSizeChanged(w, h, oldw, oldh); 57 | if (foreground != null) { 58 | foreground.setBounds(0, 0, w, h); 59 | } 60 | } 61 | 62 | @Override 63 | public boolean hasOverlappingRendering() { 64 | return false; 65 | } 66 | 67 | @Override 68 | protected boolean verifyDrawable(Drawable who) { 69 | return super.verifyDrawable(who) || (who == foreground); 70 | } 71 | 72 | @Override 73 | public void jumpDrawablesToCurrentState() { 74 | super.jumpDrawablesToCurrentState(); 75 | if (foreground != null) foreground.jumpToCurrentState(); 76 | } 77 | 78 | @Override 79 | protected void drawableStateChanged() { 80 | super.drawableStateChanged(); 81 | if (foreground != null && foreground.isStateful()) { 82 | foreground.setState(getDrawableState()); 83 | } 84 | } 85 | 86 | /** 87 | * Returns the drawable used as the foreground of this view. The 88 | * foreground drawable, if non-null, is always drawn on top of the children. 89 | * 90 | * @return A Drawable or null if no foreground was set. 91 | */ 92 | @Override 93 | public Drawable getForeground() { 94 | return foreground; 95 | } 96 | 97 | /** 98 | * Supply a Drawable that is to be rendered on top of all of the child 99 | * views within this layout. Any padding in the Drawable will be taken 100 | * into account by ensuring that the children are inset to be placed 101 | * inside of the padding area. 102 | * 103 | * @param drawable The Drawable to be drawn on top of the children. 104 | */ 105 | @Override 106 | public void setForeground(Drawable drawable) { 107 | if (foreground != drawable) { 108 | if (foreground != null) { 109 | foreground.setCallback(null); 110 | unscheduleDrawable(foreground); 111 | } 112 | 113 | foreground = drawable; 114 | 115 | if (foreground != null) { 116 | foreground.setBounds(getLeft(), getTop(), getRight(), getBottom()); 117 | setWillNotDraw(false); 118 | foreground.setCallback(this); 119 | if (foreground.isStateful()) { 120 | foreground.setState(getDrawableState()); 121 | } 122 | } else { 123 | setWillNotDraw(true); 124 | } 125 | invalidate(); 126 | } 127 | } 128 | 129 | @Override 130 | public void draw(Canvas canvas) { 131 | super.draw(canvas); 132 | if (foreground != null) { 133 | foreground.draw(canvas); 134 | } 135 | } 136 | 137 | @Override 138 | public void drawableHotspotChanged(float x, float y) { 139 | super.drawableHotspotChanged(x, y); 140 | if (foreground != null) { 141 | foreground.setHotspot(x, y); 142 | } 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/takahirom/materialelement/view/FourThreeImageView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.github.takahirom.materialelement.view; 18 | 19 | import android.content.Context; 20 | import android.util.AttributeSet; 21 | import android.view.View; 22 | 23 | /** 24 | * A extension of ForegroundImageView that is always 4:3 aspect ratio. 25 | */ 26 | public class FourThreeImageView extends ForegroundImageView { 27 | 28 | public FourThreeImageView(Context context, AttributeSet attrs) { 29 | super(context, attrs); 30 | } 31 | 32 | @Override 33 | protected void onMeasure(int widthSpec, int heightSpec) { 34 | int fourThreeHeight = View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.getSize(widthSpec) * 3 / 4, 35 | View.MeasureSpec.EXACTLY); 36 | super.onMeasure(widthSpec, fourThreeHeight); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/takahirom/materialelement/view/QuoteLayout.java: -------------------------------------------------------------------------------- 1 | package com.github.takahirom.materialelement.view; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.support.annotation.AttrRes; 6 | import android.support.annotation.NonNull; 7 | import android.support.annotation.Nullable; 8 | import android.util.AttributeSet; 9 | import android.view.LayoutInflater; 10 | import android.view.View; 11 | import android.widget.FrameLayout; 12 | import android.widget.TextView; 13 | 14 | import com.github.takahirom.materialelement.R; 15 | 16 | public class QuoteLayout extends FrameLayout { 17 | 18 | public QuoteLayout(@NonNull Context context) { 19 | this(context, null); 20 | } 21 | 22 | public QuoteLayout(@NonNull Context context, @Nullable AttributeSet attrs) { 23 | this(context, attrs, 0); 24 | } 25 | 26 | public QuoteLayout(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) { 27 | super(context, attrs, defStyleAttr); 28 | final TypedArray a = context.obtainStyledAttributes( 29 | attrs, R.styleable.QuoteLayout); 30 | CharSequence text = a.getText(R.styleable.QuoteLayout_android_text); 31 | 32 | View view = LayoutInflater.from(context).inflate(R.layout.quote_layout, this, true); 33 | TextView textView = (TextView) view.findViewById(R.id.quote_text); 34 | textView.setText(text); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/takahirom/materialelement/view/ResourceUtil.java: -------------------------------------------------------------------------------- 1 | package com.github.takahirom.materialelement.view; 2 | 3 | import android.annotation.TargetApi; 4 | import android.content.Context; 5 | import android.graphics.Bitmap; 6 | import android.graphics.Canvas; 7 | import android.graphics.drawable.BitmapDrawable; 8 | import android.graphics.drawable.Drawable; 9 | import android.graphics.drawable.VectorDrawable; 10 | import android.os.Build; 11 | import android.support.annotation.DrawableRes; 12 | import android.support.graphics.drawable.VectorDrawableCompat; 13 | import android.support.v4.content.ContextCompat; 14 | 15 | /** 16 | * From https://github.com/konifar/droidkaigi2016/blob/e5d52ed29619fa7cc53b5eeaf59ef36b1ca12635/app/src/main/java/io/github/droidkaigi/confsched/util/ResourceUtil.java 17 | */ 18 | public class ResourceUtil { 19 | 20 | @TargetApi(Build.VERSION_CODES.LOLLIPOP) 21 | private static Bitmap getBitmap(VectorDrawable vectorDrawable) { 22 | Bitmap bitmap = Bitmap.createBitmap(vectorDrawable.getIntrinsicWidth(), 23 | vectorDrawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); 24 | Canvas canvas = new Canvas(bitmap); 25 | vectorDrawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); 26 | vectorDrawable.draw(canvas); 27 | return bitmap; 28 | } 29 | 30 | private static Bitmap getBitmap(VectorDrawableCompat vectorDrawable) { 31 | Bitmap bitmap = Bitmap.createBitmap(vectorDrawable.getIntrinsicWidth(), 32 | vectorDrawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); 33 | Canvas canvas = new Canvas(bitmap); 34 | vectorDrawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); 35 | vectorDrawable.draw(canvas); 36 | return bitmap; 37 | } 38 | 39 | public static Bitmap getBitmap(Context context, @DrawableRes int drawableResId) { 40 | Drawable drawable = VectorDrawableCompat.create(context.getResources(), drawableResId, context.getTheme()); 41 | if (drawable instanceof BitmapDrawable) { 42 | return ((BitmapDrawable) drawable).getBitmap(); 43 | } else if (drawable instanceof VectorDrawableCompat) { 44 | return getBitmap((VectorDrawableCompat) drawable); 45 | } else if (drawable instanceof VectorDrawable) { 46 | return getBitmap((VectorDrawable) drawable); 47 | } else { 48 | throw new IllegalArgumentException("Unsupported drawable type"); 49 | } 50 | } 51 | 52 | } -------------------------------------------------------------------------------- /app/src/main/res/animator/raise.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 10 | 11 | 12 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/dialog_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 15 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_add_white_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_apps_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_choreography.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 9 | 12 | 15 | 18 | 21 | 24 | 27 | 30 | 31 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_creative_customize.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 8 | 9 | 12 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_duration_easing.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 9 | 12 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_format_quote_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_loading_image.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 12 | 16 | 20 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_logo.xml: -------------------------------------------------------------------------------- 1 | 6 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_movement.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 9 | 12 | 15 | 18 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_navigational_transition.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 16 | 20 | 24 | 30 | 36 | 42 | 48 | 54 | 60 | 64 | 68 | 72 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_navigational_transition_circle.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 16 | 20 | 24 | 30 | 36 | 42 | 48 | 54 | 60 | 64 | 68 | 72 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_child.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 22 | 23 | 31 | 32 | 38 | 39 | 48 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_choreography.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_creative_customization.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_dynamic_durations.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_loading_images.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_login.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 23 | 24 | 37 | 38 | 46 | 47 | 52 | 53 | 59 | 60 | 61 | 62 | 67 | 68 | 75 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 20 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_movement.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 19 | 20 | 29 | 33 | 38 | 39 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_navigational_transition.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_product_icon.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_share_all_element.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_share_few_element.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 22 | 23 | 24 | 34 | 35 | 41 | 42 | 50 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_transforming.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/layout/all_element_share_scene1.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 19 | 20 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/layout/all_element_share_scene2.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 21 | 22 | 30 | 31 | 37 | 38 | 47 | -------------------------------------------------------------------------------- /app/src/main/res/layout/card_arc_scene1.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/layout/card_arc_scene2.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/layout/card_not_arc_scene1.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/layout/card_not_arc_scene2.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_child.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_creative_customization.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 15 | 19 | 20 | 24 | 25 | 35 | 36 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_loading_images.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 15 | 16 | 20 | 21 | 25 | 26 | 36 | 37 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_movement.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 15 | 16 | 17 | 21 | 22 | 26 | 27 | 36 | 37 | 38 | 45 | 46 | 47 | 51 | 52 | 53 | 54 | 55 | 56 | 63 | 64 | 65 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_navigational_transition.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 15 | 19 | 20 | 24 | 25 | 35 | 36 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_transforming.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 15 | 16 | 17 | 21 | 22 | 26 | 27 | 36 | 37 | 45 | 46 | 47 | 54 | 55 | 56 | 59 | 60 | 66 | 67 | 68 | 69 | 70 | 77 | 78 | 79 | 82 | 83 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /app/src/main/res/layout/few_element_share_scene1.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 17 | 18 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/layout/few_element_share_scene2.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 21 | 22 | 32 | 33 | 39 | 40 | 48 | -------------------------------------------------------------------------------- /app/src/main/res/layout/implementation_appbar_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 19 | 20 | 21 | 31 | 32 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_main_header.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_main_implementation.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 24 | 25 | 32 | 33 | 45 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_navigational_transition.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 21 | 22 | 30 | 31 | -------------------------------------------------------------------------------- /app/src/main/res/layout/list_row_card.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/layout/quote_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 14 | 15 | 25 | 26 | 31 | 32 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 |

5 | 10 | 15 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/element_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/takahirom/material-element/e3263f80935edf2aa09f7e8240273b2a99745bb8/app/src/main/res/mipmap-hdpi/element_icon.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/element_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/takahirom/material-element/e3263f80935edf2aa09f7e8240273b2a99745bb8/app/src/main/res/mipmap-mdpi/element_icon.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/element_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/takahirom/material-element/e3263f80935edf2aa09f7e8240273b2a99745bb8/app/src/main/res/mipmap-xhdpi/element_icon.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/element_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/takahirom/material-element/e3263f80935edf2aa09f7e8240273b2a99745bb8/app/src/main/res/mipmap-xxhdpi/element_icon.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/element_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/takahirom/material-element/e3263f80935edf2aa09f7e8240273b2a99745bb8/app/src/main/res/mipmap-xxxhdpi/element_icon.png -------------------------------------------------------------------------------- /app/src/main/res/transition/choreography_all_element_share_enter.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 14 | 15 | 16 | 17 | 18 | 19 | 24 | 25 | 26 | 27 | 28 | 29 | 34 | -------------------------------------------------------------------------------- /app/src/main/res/transition/choreography_all_element_share_return.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/res/transition/choreography_few_element_share_enter.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | 15 | 16 | 17 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /app/src/main/res/transition/choreography_few_element_share_return.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /app/src/main/res/transition/default_share.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/transition/default_window_enter.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 24 | 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 | -------------------------------------------------------------------------------- /app/src/main/res/transition/default_window_return.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 37 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /app/src/main/res/transition/movement_change_bounds_arc.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/transition/navigational_transition_share_enter.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/transition/navigational_transition_share_return.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/values/attrs_foreground_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/values/attrs_lift_off.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/values/attrs_quote_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/values/attrs_staggered_distance_slide.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #00BCD4 4 | #0097A7 5 | #FFC107 6 | 7 | #99323232 8 | #fafafa 9 | 10 | #ff292929 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 16dp 3 | 6dp 4 | 2dp 5 | 6 | 8dp 7 | 4dp 8 | 32dp 9 | 48dp 10 | 64dp 11 | 16dp 12 | 24dp 13 | 14 | 15 | 24dp 16 | 20dp 17 | 18 | 2dp 19 | 56dp 20 | 21 | 22 | 6dp 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ELEMENT 4 | 5 | login 6 | shared_element 7 | all_element_share 8 | few_element_share 9 | few_element_share_image 10 | content_root 11 | 12 | Your Android OS version does not support this feature. 13 | 14 | Motion 15 | Patterns 16 | Please enable developer mode in settings 17 | Developer Settings 18 | Transition Debug 19 | Open GitHub 20 | 21 | implementation image 22 | 23 | Material in motion is responsive and natural. 24 | Dynamic durations 25 | 300dp 290ms 26 | 120dp 225ms 27 | Natural easing curves 28 | Standard curve 29 | Deceleration curve 30 | Acceleration curve 31 | Sharp curve 32 | 33 | Material can make surfaces feel alive by multiplying and dividing them, and changing their shape and size. 34 | Radial transformation sample 35 | 36 | Material in motion abides by forces similar to those of the real world, like gravity. 37 | 38 | Material in motion guides the user’s focus through interactions by sharing elements across transitions. 39 | 40 | Animation may be used in a wide range of scales and contexts to unite beauty and function. 41 | 42 | Illustrations and photographs may load and transition in three phases by staggering opacity, exposure, and saturation levels. 43 | 44 | Navigational transitions are movements between states in an app, such as from a high-level view to a detailed view. 45 | http://git.io/element 46 | 47 | 48 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | 18 | 19 | 23 | 24 | 29 | 30 | 31 | 36 | 37 | 41 | 42 | 57 | 58 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /app/src/test/java/com/github/takahirom/materialelement/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.github.takahirom.materialelement; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /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 | maven { url "https://plugins.gradle.org/m2/" } 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:2.3.0' 10 | classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.9' 11 | 12 | // NOTE: Do not place your application dependencies here; they belong 13 | // in the individual module build.gradle files 14 | } 15 | } 16 | 17 | allprojects { 18 | repositories { 19 | jcenter() 20 | } 21 | } 22 | 23 | task clean(type: Delete) { 24 | delete rootProject.buildDir 25 | } 26 | -------------------------------------------------------------------------------- /debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/takahirom/material-element/e3263f80935edf2aa09f7e8240273b2a99745bb8/debug.keystore -------------------------------------------------------------------------------- /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 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/takahirom/material-element/e3263f80935edf2aa09f7e8240273b2a99745bb8/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Mar 25 18:25:56 JST 2017 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-3.4.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------