├── .gitignore ├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── gradle.xml ├── misc.xml ├── modules.xml └── vcs.xml ├── .travis.yml ├── PreLollipopTransition ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── albinmathew │ │ └── pre_lollipop_activity_transition │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ └── java │ └── com │ └── albinmathew │ └── transitions │ ├── ActivityTransition.java │ ├── ActivityTransitionLauncher.java │ ├── BuildConfigUtils.java │ ├── ExitActivityTransition.java │ ├── core │ ├── MoveData.java │ ├── TransitionAnimation.java │ ├── TransitionBundleFactory.java │ └── TransitionData.java │ └── fragment │ ├── ExitFragmentTransition.java │ ├── FragmentTransition.java │ └── FragmentTransitionLauncher.java ├── README.md ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── sample-app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── albinmathew │ │ └── prelollipoptransition │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── albinmathew │ │ └── prelollipoptransition │ │ ├── MainActivity.java │ │ ├── SubActivity.java │ │ ├── SubActivity2.java │ │ ├── fragment │ │ ├── EndFragment.java │ │ └── StartFragment.java │ │ └── support_fragment │ │ ├── SupportEndFragment.java │ │ └── SupportStartFragment.java │ └── res │ ├── drawable │ └── photo.jpg │ ├── layout │ ├── activity_main.xml │ ├── activity_sub.xml │ ├── activity_sub2.xml │ ├── fragment_end.xml │ ├── support_fragment_end.xml │ └── support_fragment_start.xml │ ├── menu │ ├── menu_main.xml │ └── menu_sub.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea/workspace.xml 4 | /.idea/libraries 5 | .DS_Store 6 | /build 7 | *.apk 8 | *.iml 9 | manifest-merger-release-report.txt 10 | keys.gradle 11 | pre-lollipop-activity-transition/key 12 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | PreLollipopTransitions -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | android: 3 | components: 4 | - platform-tools 5 | - android-22 6 | - build-tools-21.1.2 7 | - extra 8 | 9 | jdk: oraclejdk7 10 | 11 | script: 12 | - ./gradlew clean build -------------------------------------------------------------------------------- /PreLollipopTransition/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | key 3 | -------------------------------------------------------------------------------- /PreLollipopTransition/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | } 5 | dependencies { 6 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0' 7 | classpath 'com.github.dcendents:android-maven-plugin:1.2' 8 | } 9 | } 10 | apply plugin: 'com.android.library' 11 | apply plugin: 'com.github.dcendents.android-maven' 12 | apply plugin: 'com.jfrog.bintray' 13 | 14 | android { 15 | compileSdkVersion 22 16 | buildToolsVersion "21.1.2" 17 | 18 | defaultConfig { 19 | minSdkVersion 14 20 | targetSdkVersion 22 21 | versionCode 1 22 | versionName "1.0" 23 | } 24 | lintOptions { 25 | abortOnError false 26 | } 27 | buildTypes { 28 | release { 29 | minifyEnabled false 30 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 31 | } 32 | } 33 | } 34 | 35 | dependencies { 36 | compile fileTree(dir: 'libs', include: ['*.jar']) 37 | compile 'com.android.support:appcompat-v7:22.0.+' 38 | compile 'com.android.support:support-v4:+' 39 | } 40 | 41 | group = 'com.albinmathew' 42 | version = '1.1.2' 43 | 44 | 45 | apply plugin: 'maven' 46 | apply plugin: 'maven-publish' 47 | 48 | 49 | def siteUrl = 'https://github.com/albinmathew/PreLollipopTransition' 50 | def gitUrl = 'https://github.com/albinmathew/PreLollipopTransition.git' 51 | bintray { 52 | user = "albinmathew" 53 | if (file("key").exists()) { 54 | key = file("key").text 55 | } 56 | 57 | configurations = ['archives'] 58 | publish = true 59 | pkg { 60 | repo = 'maven' 61 | name = 'PreLollipopTransition' 62 | desc = 'A library which help you to implement activity transition for pre-Lollipop devices' 63 | websiteUrl = siteUrl 64 | issueTrackerUrl = 'https://github.com/albinmathew/PreLollipopTransition/issues' 65 | vcsUrl = gitUrl 66 | licenses = ['Apache-2.0'] 67 | labels = ['aar', 'android', 'animation'] 68 | publicDownloadNumbers = true 69 | } 70 | } 71 | 72 | 73 | task sourcesJar(type: Jar) { 74 | from android.sourceSets.main.java.srcDirs 75 | classifier = 'sources' 76 | } 77 | 78 | task javadoc(type: Javadoc) { 79 | source = android.sourceSets.main.java.srcDirs 80 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) 81 | } 82 | 83 | task javadocJar(type: Jar, dependsOn: javadoc) { 84 | classifier = 'javadoc' 85 | from javadoc.destinationDir 86 | } 87 | artifacts { 88 | archives javadocJar 89 | archives sourcesJar 90 | } 91 | -------------------------------------------------------------------------------- /PreLollipopTransition/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 /Applications/android-sdk-macosx-l/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 | -------------------------------------------------------------------------------- /PreLollipopTransition/src/androidTest/java/com/albinmathew/pre_lollipop_activity_transition/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.albinmathew.pre_lollipop_activity_transition; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /PreLollipopTransition/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /PreLollipopTransition/src/main/java/com/albinmathew/transitions/ActivityTransition.java: -------------------------------------------------------------------------------- 1 | package com.albinmathew.transitions; 2 | 3 | import android.animation.TimeInterpolator; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.os.Bundle; 7 | import android.view.View; 8 | import android.view.animation.DecelerateInterpolator; 9 | 10 | import com.albinmathew.transitions.core.MoveData; 11 | import com.albinmathew.transitions.core.TransitionAnimation; 12 | 13 | 14 | public class ActivityTransition { 15 | private static final TimeInterpolator sDecelerator = new DecelerateInterpolator(); 16 | private Intent fromIntent; 17 | int duration = 1000; 18 | View toView; 19 | 20 | private ActivityTransition(Intent intent) { 21 | this.fromIntent = intent; 22 | } 23 | 24 | public static ActivityTransition with(Intent intent) { 25 | return new ActivityTransition(intent); 26 | } 27 | 28 | public ActivityTransition to(View toView) { 29 | this.toView = toView; 30 | return this; 31 | } 32 | 33 | public ActivityTransition duration(int duration) { 34 | this.duration = duration; 35 | return this; 36 | } 37 | 38 | 39 | public ExitActivityTransition start(Bundle savedInstanceState) { 40 | final Context context = toView.getContext(); 41 | final Bundle bundle = fromIntent.getExtras(); 42 | final MoveData moveData = TransitionAnimation.startAnimation(context, toView, bundle, savedInstanceState, duration, sDecelerator); 43 | return new ExitActivityTransition(moveData); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /PreLollipopTransition/src/main/java/com/albinmathew/transitions/ActivityTransitionLauncher.java: -------------------------------------------------------------------------------- 1 | package com.albinmathew.transitions; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.graphics.Bitmap; 6 | import android.os.Bundle; 7 | import android.view.View; 8 | 9 | import com.albinmathew.transitions.core.TransitionBundleFactory; 10 | 11 | 12 | public class ActivityTransitionLauncher { 13 | private static final String TAG = "TransitionLauncher"; 14 | 15 | private final Activity activity; 16 | private View fromView; 17 | private Bitmap bitmap; 18 | 19 | 20 | private ActivityTransitionLauncher(Activity activity) { 21 | this.activity = activity; 22 | } 23 | 24 | public static ActivityTransitionLauncher with(Activity activity) { 25 | return new ActivityTransitionLauncher(activity); 26 | } 27 | 28 | public ActivityTransitionLauncher from(View fromView) { 29 | this.fromView = fromView; 30 | return this; 31 | } 32 | 33 | public ActivityTransitionLauncher image(final Bitmap bitmap) { 34 | this.bitmap = bitmap; 35 | return this; 36 | } 37 | 38 | public void launch(Intent intent) { 39 | final Bundle transitionBundle = TransitionBundleFactory.createTransitionBundle(activity, fromView, bitmap); 40 | intent.putExtras(transitionBundle); 41 | activity.startActivity(intent); 42 | activity.overridePendingTransition(0, 0); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /PreLollipopTransition/src/main/java/com/albinmathew/transitions/BuildConfigUtils.java: -------------------------------------------------------------------------------- 1 | package com.albinmathew.transitions; 2 | 3 | import android.content.Context; 4 | 5 | import java.lang.reflect.Field; 6 | 7 | 8 | public class BuildConfigUtils { 9 | public static Object getBuildConfigValue(Context context, String fieldName) { 10 | try { 11 | Class clazz = Class.forName(context.getPackageName() + ".BuildConfig"); 12 | Field field = clazz.getField(fieldName); 13 | return field.get(null); 14 | } catch (ClassNotFoundException e) { 15 | e.printStackTrace(); 16 | } catch (NoSuchFieldException e) { 17 | e.printStackTrace(); 18 | } catch (IllegalAccessException e) { 19 | e.printStackTrace(); 20 | } 21 | return null; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /PreLollipopTransition/src/main/java/com/albinmathew/transitions/ExitActivityTransition.java: -------------------------------------------------------------------------------- 1 | package com.albinmathew.transitions; 2 | 3 | import android.app.Activity; 4 | 5 | import com.albinmathew.transitions.core.MoveData; 6 | import com.albinmathew.transitions.core.TransitionAnimation; 7 | 8 | public class ExitActivityTransition { 9 | private final MoveData moveData; 10 | 11 | 12 | public ExitActivityTransition(MoveData moveData) { 13 | this.moveData = moveData; 14 | } 15 | 16 | public void exit(final Activity activity) { 17 | TransitionAnimation.startExitAnimation(moveData, new Runnable() { 18 | @Override 19 | public void run() { 20 | activity.finish(); 21 | activity.overridePendingTransition(0, 0); 22 | } 23 | }); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /PreLollipopTransition/src/main/java/com/albinmathew/transitions/core/MoveData.java: -------------------------------------------------------------------------------- 1 | package com.albinmathew.transitions.core; 2 | 3 | import android.view.View; 4 | 5 | public class MoveData { 6 | 7 | public int leftDelta; 8 | public int topDelta; 9 | public float widthScale; 10 | public float heightScale; 11 | public int duration = 1000; 12 | public View toView; 13 | } 14 | -------------------------------------------------------------------------------- /PreLollipopTransition/src/main/java/com/albinmathew/transitions/core/TransitionAnimation.java: -------------------------------------------------------------------------------- 1 | package com.albinmathew.transitions.core; 2 | 3 | import android.animation.TimeInterpolator; 4 | import android.content.Context; 5 | import android.graphics.Bitmap; 6 | import android.graphics.BitmapFactory; 7 | import android.graphics.drawable.BitmapDrawable; 8 | import android.os.Build; 9 | import android.os.Bundle; 10 | import android.view.View; 11 | import android.view.ViewTreeObserver; 12 | import android.widget.ImageView; 13 | 14 | import java.lang.ref.WeakReference; 15 | 16 | 17 | public class TransitionAnimation { 18 | private static final String TAG = "Transition"; 19 | public static WeakReference bitmapCache; 20 | 21 | public static MoveData startAnimation(Context context, final View toView, Bundle transitionBundle, Bundle savedInstanceState, final int duration, final TimeInterpolator interpolator) { 22 | final TransitionData transitionData = new TransitionData(context, transitionBundle); 23 | if (transitionData.imageFilePath != null) { 24 | setImageToView(toView, transitionData.imageFilePath); 25 | } 26 | final MoveData moveData = new MoveData(); 27 | moveData.toView = toView; 28 | moveData.duration = duration; 29 | if (savedInstanceState == null) { 30 | 31 | ViewTreeObserver observer = toView.getViewTreeObserver(); 32 | observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { 33 | 34 | @Override 35 | public boolean onPreDraw() { 36 | toView.getViewTreeObserver().removeOnPreDrawListener(this); 37 | 38 | int[] screenLocation = new int[2]; 39 | toView.getLocationOnScreen(screenLocation); 40 | moveData.leftDelta = transitionData.thumbnailLeft - screenLocation[0]; 41 | moveData.topDelta = transitionData.thumbnailTop - screenLocation[1]; 42 | 43 | moveData.widthScale = (float) transitionData.thumbnailWidth / toView.getWidth(); 44 | moveData.heightScale = (float) transitionData.thumbnailHeight / toView.getHeight(); 45 | 46 | runEnterAnimation(moveData, interpolator); 47 | 48 | return true; 49 | } 50 | }); 51 | } 52 | return moveData; 53 | } 54 | 55 | 56 | private static void runEnterAnimation(MoveData moveData, TimeInterpolator interpolator) { 57 | final View toView = moveData.toView; 58 | toView.setPivotX(0); 59 | toView.setPivotY(0); 60 | toView.setScaleX(moveData.widthScale); 61 | toView.setScaleY(moveData.heightScale); 62 | toView.setTranslationX(moveData.leftDelta); 63 | toView.setTranslationY(moveData.topDelta); 64 | 65 | toView.animate().setDuration(moveData.duration). 66 | scaleX(1).scaleY(1). 67 | translationX(0).translationY(0). 68 | setInterpolator(interpolator); 69 | } 70 | 71 | private static void setImageToView(View toView, String imageFilePath) { 72 | Bitmap bitmap; 73 | if (bitmapCache == null || (bitmap = bitmapCache.get()) == null) { 74 | // Cant get bitmap by static field 75 | bitmap = BitmapFactory.decodeFile(imageFilePath); 76 | } else { 77 | bitmapCache.clear(); 78 | } 79 | if (toView instanceof ImageView) { 80 | final ImageView toImageView = (ImageView) toView; 81 | toImageView.setImageBitmap(bitmap); 82 | } else { 83 | if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) { 84 | toView.setBackground(new BitmapDrawable(toView.getResources(), bitmap)); 85 | } else { 86 | toView.setBackgroundDrawable(new BitmapDrawable(toView.getResources(), bitmap)); 87 | } 88 | } 89 | } 90 | 91 | public static void startExitAnimation(MoveData moveData, final Runnable endAction) { 92 | View view = moveData.toView; 93 | int duration = moveData.duration; 94 | int leftDelta = moveData.leftDelta; 95 | int topDelta = moveData.topDelta; 96 | float widthScale = moveData.widthScale; 97 | float heightScale = moveData.heightScale; 98 | view.animate().setDuration(duration). 99 | scaleX(widthScale).scaleY(heightScale). 100 | translationX(leftDelta).translationY(topDelta); 101 | view.postDelayed(endAction, duration); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /PreLollipopTransition/src/main/java/com/albinmathew/transitions/core/TransitionBundleFactory.java: -------------------------------------------------------------------------------- 1 | package com.albinmathew.transitions.core; 2 | 3 | import android.content.Context; 4 | import android.graphics.Bitmap; 5 | import android.os.Bundle; 6 | import android.util.Log; 7 | import android.view.View; 8 | 9 | import com.albinmathew.transitions.BuildConfigUtils; 10 | 11 | import java.io.BufferedOutputStream; 12 | import java.io.File; 13 | import java.io.FileNotFoundException; 14 | import java.io.FileOutputStream; 15 | import java.io.IOException; 16 | import java.lang.ref.WeakReference; 17 | 18 | 19 | public class TransitionBundleFactory { 20 | public static final String TEMP_IMAGE_FILE_NAME = "activity_transition_image.png"; 21 | private static final String TAG = "Transition"; 22 | 23 | public static Bundle createTransitionBundle(Context context, View fromView, Bitmap bitmap) { 24 | // Bitmap is Optional 25 | String imageFilePath = null; 26 | if (bitmap != null) { 27 | imageFilePath = saveImage(context, bitmap); 28 | } 29 | int[] screenLocation = new int[2]; 30 | fromView.getLocationOnScreen(screenLocation); 31 | final TransitionData transitionData = new TransitionData(context, screenLocation[0], screenLocation[1], fromView.getMeasuredWidth(), fromView.getMeasuredHeight(), imageFilePath); 32 | return transitionData.getBundle(); 33 | } 34 | 35 | private static String saveImage(Context context, Bitmap bitmap) { 36 | final String imageSavePath = context.getFilesDir().getAbsolutePath() + "/activity_transition/"; 37 | new File(imageSavePath).mkdirs(); 38 | final File imageFile = new File(imageSavePath, TEMP_IMAGE_FILE_NAME); 39 | final String imageFilePath = imageFile.getAbsolutePath(); 40 | final Boolean isDebug = (Boolean) BuildConfigUtils.getBuildConfigValue(context, "DEBUG"); 41 | 42 | BufferedOutputStream bos = null; 43 | try { 44 | if (imageFile.exists()) { 45 | imageFile.delete(); 46 | } 47 | imageFile.createNewFile(); 48 | bos = new BufferedOutputStream(new FileOutputStream(imageFile)); 49 | bitmap.compress(Bitmap.CompressFormat.JPEG, 50, bos); 50 | } catch (FileNotFoundException e) { 51 | if (isDebug) { 52 | Log.i(TAG, "file not found", e); 53 | } 54 | } catch (IOException e) { 55 | if (isDebug) { 56 | Log.i(TAG, "can't create file", e); 57 | } 58 | } finally { 59 | try { 60 | bos.close(); 61 | } catch (Exception e) { 62 | if (isDebug) { 63 | //IOException, NullPointerException 64 | Log.i(TAG, "fail save image", e); 65 | } 66 | } 67 | } 68 | TransitionAnimation.bitmapCache = new WeakReference(bitmap); 69 | return imageFilePath; 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /PreLollipopTransition/src/main/java/com/albinmathew/transitions/core/TransitionData.java: -------------------------------------------------------------------------------- 1 | package com.albinmathew.transitions.core; 2 | 3 | import android.content.Context; 4 | import android.os.Bundle; 5 | 6 | import com.albinmathew.transitions.BuildConfigUtils; 7 | 8 | 9 | public class TransitionData { 10 | public static final String EXTRA_IMAGE_LEFT = ".left"; 11 | public static final String EXTRA_IMAGE_TOP = ".top"; 12 | public static final String EXTRA_IMAGE_WIDTH = ".width"; 13 | public static final String EXTRA_IMAGE_HEIGHT = ".height"; 14 | public static final String EXTRA_IMAGE_PATH = ".imageFilePath"; 15 | 16 | public final int thumbnailTop; 17 | public final int thumbnailLeft; 18 | public final int thumbnailWidth; 19 | public final int thumbnailHeight; 20 | public final String imageFilePath; 21 | private String appId; 22 | 23 | public TransitionData(Context context, int thumbnailLeft, int thumbnailTop, int thumbnailWidth, int thumbnailHeight, String imageFilePath) { 24 | setAppId(context); 25 | this.thumbnailLeft = thumbnailLeft; 26 | this.thumbnailTop = thumbnailTop; 27 | this.thumbnailWidth = thumbnailWidth; 28 | this.thumbnailHeight = thumbnailHeight; 29 | this.imageFilePath = imageFilePath; 30 | } 31 | 32 | public TransitionData(Context context, Bundle bundle) { 33 | setAppId(context); 34 | thumbnailTop = bundle.getInt(appId + EXTRA_IMAGE_TOP); 35 | thumbnailLeft = bundle.getInt(appId + EXTRA_IMAGE_LEFT); 36 | thumbnailWidth = bundle.getInt(appId + EXTRA_IMAGE_WIDTH); 37 | thumbnailHeight = bundle.getInt(appId + EXTRA_IMAGE_HEIGHT); 38 | imageFilePath = bundle.getString(appId + EXTRA_IMAGE_PATH); 39 | } 40 | 41 | private void setAppId(Context context) { 42 | appId = (String) BuildConfigUtils.getBuildConfigValue(context, "APPLICATION_ID"); 43 | } 44 | 45 | 46 | public Bundle getBundle() { 47 | final Bundle bundle = new Bundle(); 48 | if (imageFilePath != null) { 49 | bundle.putString(appId + EXTRA_IMAGE_PATH, imageFilePath); 50 | } 51 | bundle.putInt(appId + EXTRA_IMAGE_LEFT, thumbnailLeft); 52 | bundle.putInt(appId + EXTRA_IMAGE_TOP, thumbnailTop); 53 | bundle.putInt(appId + EXTRA_IMAGE_WIDTH, thumbnailWidth); 54 | bundle.putInt(appId + EXTRA_IMAGE_HEIGHT, thumbnailHeight); 55 | return bundle; 56 | 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /PreLollipopTransition/src/main/java/com/albinmathew/transitions/fragment/ExitFragmentTransition.java: -------------------------------------------------------------------------------- 1 | package com.albinmathew.transitions.fragment; 2 | 3 | import android.app.Fragment; 4 | import android.support.v4.app.FragmentManager; 5 | import android.view.KeyEvent; 6 | import android.view.View; 7 | 8 | import com.albinmathew.transitions.core.MoveData; 9 | import com.albinmathew.transitions.core.TransitionAnimation; 10 | 11 | 12 | public class ExitFragmentTransition { 13 | private final MoveData moveData; 14 | private Fragment fragment; 15 | private android.support.v4.app.Fragment supportFragment; 16 | 17 | 18 | public ExitFragmentTransition(Fragment fragment, MoveData moveData) { 19 | this.fragment = fragment; 20 | this.moveData = moveData; 21 | } 22 | 23 | public ExitFragmentTransition(final android.support.v4.app.Fragment fragment, MoveData moveData) { 24 | this.supportFragment = fragment; 25 | this.moveData = moveData; 26 | } 27 | 28 | public void startExitListening() { 29 | startExitListening(null); 30 | } 31 | 32 | public void startExitListening(final Runnable popBackStackRunnable) { 33 | final View toView = moveData.toView; 34 | toView.setFocusableInTouchMode(true); 35 | toView.requestFocus(); 36 | toView.setOnKeyListener(new View.OnKeyListener() { 37 | @Override 38 | public boolean onKey(View v, int keyCode, KeyEvent event) { 39 | if (keyCode == KeyEvent.KEYCODE_BACK) { 40 | if (event.getAction() != KeyEvent.ACTION_UP) { 41 | return true; 42 | } 43 | TransitionAnimation.startExitAnimation(moveData, new Runnable() { 44 | @Override 45 | public void run() { 46 | if (popBackStackRunnable != null) { 47 | popBackStackRunnable.run(); 48 | return; 49 | } 50 | if (fragment == null) { 51 | if (!supportFragment.isResumed()) { 52 | return; 53 | } 54 | final FragmentManager fragmentManager = supportFragment.getFragmentManager(); 55 | if (fragmentManager != null) { 56 | fragmentManager.popBackStack(); 57 | } 58 | } else { 59 | if (!fragment.isResumed()) { 60 | return; 61 | } 62 | final android.app.FragmentManager fragmentManager = ((Fragment) fragment).getFragmentManager(); 63 | if (fragmentManager != null) { 64 | fragmentManager.popBackStack(); 65 | } 66 | } 67 | } 68 | }); 69 | return true; 70 | } 71 | return false; 72 | } 73 | }); 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /PreLollipopTransition/src/main/java/com/albinmathew/transitions/fragment/FragmentTransition.java: -------------------------------------------------------------------------------- 1 | package com.albinmathew.transitions.fragment; 2 | 3 | import android.animation.TimeInterpolator; 4 | import android.app.Fragment; 5 | import android.content.Context; 6 | import android.os.Bundle; 7 | import android.view.View; 8 | import android.view.animation.DecelerateInterpolator; 9 | 10 | import com.albinmathew.transitions.core.MoveData; 11 | import com.albinmathew.transitions.core.TransitionAnimation; 12 | 13 | 14 | public class FragmentTransition { 15 | private static final TimeInterpolator sDecelerator = new DecelerateInterpolator(); 16 | private android.support.v4.app.Fragment supportFragment; 17 | private Fragment fragment; 18 | int duration = 1000; 19 | View toView; 20 | 21 | private FragmentTransition(Fragment fragment) { 22 | this.fragment = fragment; 23 | } 24 | 25 | private FragmentTransition(android.support.v4.app.Fragment fragment) { 26 | this.supportFragment = fragment; 27 | } 28 | 29 | public static FragmentTransition with(Fragment fragment) { 30 | return new FragmentTransition(fragment); 31 | } 32 | 33 | public static FragmentTransition with(android.support.v4.app.Fragment fragment) { 34 | return new FragmentTransition(fragment); 35 | } 36 | 37 | public FragmentTransition to(View toView) { 38 | this.toView = toView; 39 | return this; 40 | } 41 | 42 | public FragmentTransition duration(int duration) { 43 | this.duration = duration; 44 | return this; 45 | } 46 | 47 | 48 | public ExitFragmentTransition start(Bundle savedInstanceState) { 49 | final Context context = toView.getContext(); 50 | final Bundle bundle; 51 | if (fragment == null) { 52 | bundle = supportFragment.getArguments(); 53 | } else { 54 | bundle = fragment.getArguments(); 55 | } 56 | final MoveData moveData = TransitionAnimation.startAnimation(context, toView, bundle, savedInstanceState, duration, sDecelerator); 57 | if (fragment == null) { 58 | return new ExitFragmentTransition(supportFragment, moveData); 59 | } 60 | return new ExitFragmentTransition(fragment, moveData); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /PreLollipopTransition/src/main/java/com/albinmathew/transitions/fragment/FragmentTransitionLauncher.java: -------------------------------------------------------------------------------- 1 | package com.albinmathew.transitions.fragment; 2 | 3 | import android.app.Fragment; 4 | import android.content.Context; 5 | import android.graphics.Bitmap; 6 | import android.os.Bundle; 7 | import android.view.View; 8 | 9 | import com.albinmathew.transitions.core.TransitionBundleFactory; 10 | 11 | 12 | public class FragmentTransitionLauncher { 13 | private static final String TAG = "TransitionLauncher"; 14 | 15 | private final Context context; 16 | private View fromView; 17 | private Bitmap bitmap; 18 | 19 | 20 | private FragmentTransitionLauncher(Context context) { 21 | this.context = context; 22 | } 23 | 24 | public static FragmentTransitionLauncher with(Context context) { 25 | return new FragmentTransitionLauncher(context); 26 | } 27 | 28 | public FragmentTransitionLauncher from(View fromView) { 29 | this.fromView = fromView; 30 | return this; 31 | } 32 | 33 | public FragmentTransitionLauncher image(final Bitmap bitmap) { 34 | this.bitmap = bitmap; 35 | return this; 36 | } 37 | 38 | public void prepare(Fragment toFragment) { 39 | final Bundle transitionBundle = TransitionBundleFactory.createTransitionBundle(context, fromView, bitmap); 40 | toFragment.setArguments(transitionBundle); 41 | } 42 | 43 | public void prepare(android.support.v4.app.Fragment toFragment) { 44 | final Bundle transitionBundle = TransitionBundleFactory.createTransitionBundle(context, fromView, bitmap); 45 | toFragment.setArguments(transitionBundle); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PreLollipopTransition 2 | Simple tool which help you to implement activity and fragment transition for pre-Lollipop devices. 3 | 4 | [![Build Status](https://travis-ci.org/albinmathew/PreLollipopTransition.svg?branch=master)](https://travis-ci.org/albinmathew/PreLollipopTransition) [ ![Download](https://api.bintray.com/packages/albinmathew/maven/PreLollipopTransition/images/download.svg) ](https://bintray.com/albinmathew/maven/PreLollipopTransition/_latestVersion) [ ![Download](https://img.shields.io/github/release/albinmathew/PreLollipopTransition.svg?label=JitPack) ](https://jitpack.io/#albinmathew/PreLollipopTransition/1.1.2) 5 | 6 | ![prelollipopanimation](https://cloud.githubusercontent.com/assets/1386930/7614211/53ca12d8-f9d0-11e4-8b98-b6d98272f67d.gif) 7 | 8 | ## Download 9 | In your app build.gradle add 10 | 11 | ``` 12 | repositories { 13 | maven { 14 | url "https://jitpack.io" 15 | } 16 | } 17 | ``` 18 | ``` 19 | dependencies { 20 | compile 'com.github.albinmathew:PreLollipopTransition:1.1.2' 21 | } 22 | ``` 23 | or using bintray and jcenter 24 | 25 | ``` 26 | repositories { 27 | maven { 28 | url "http://dl.bintray.com/albinmathew/maven" 29 | } 30 | } 31 | ``` 32 | ``` 33 | dependencies { 34 | compile 'com.albinmathew:PreLollipopTransition:1.1.2' 35 | } 36 | ``` 37 | 38 | ## Code 39 | ### Actvity 40 | Start Activity in first activity. 41 | 42 | ``` 43 | findViewById(R.id.imageView).setOnClickListener(new View.OnClickListener() { 44 | @Override 45 | public void onClick(View v) { 46 | final Intent intent = new Intent(MainActivity.this, SubActivity.class); 47 | ActivityTransitionLauncher.with(MainActivity.this).from(v).launch(intent); 48 | } 49 | }); 50 | ``` 51 | 52 | Receive intent in second activity. 53 | 54 | ``` 55 | @Override 56 | protected void onCreate(Bundle savedInstanceState) { 57 | super.onCreate(savedInstanceState); 58 | setContentView(R.layout.activity_sub); 59 | ActivityTransition.with(getIntent()).to(findViewById(R.id.sub_imageView)).start(savedInstanceState); 60 | } 61 | ``` 62 | 63 | If you want the exit animation, you can do like this. 64 | ``` 65 | private ExitActivityTransition exitTransition; 66 | @Override 67 | protected void onCreate(Bundle savedInstanceState) { 68 | super.onCreate(savedInstanceState); 69 | setContentView(R.layout.activity_sub2); 70 | exitTransition = ActivityTransition.with(getIntent()).to(findViewById(R.id.sub_imageView)).start(savedInstanceState); 71 | } 72 | @Override 73 | public void onBackPressed() { 74 | exitTransition.exit(this); 75 | } 76 | ``` 77 | 78 | ### Fragment 79 | Start fragment transition in first activity. 80 | ``` 81 | @Override 82 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 83 | View v = inflater.inflate(R.layout.support_fragment_start, container, false); 84 | v.setOnClickListener(new View.OnClickListener() { 85 | @Override 86 | public void onClick(View view) { 87 | final EndFragment toFragment = new EndFragment(); 88 | FragmentTransitionLauncher 89 | .with(view.getContext()) 90 | .image(BitmapFactory.decodeResource(getResources(), R.drawable.photo)) 91 | .from(view.findViewById(R.id.imageView)).prepare(toFragment); 92 | getFragmentManager().beginTransaction().replace(R.id.content, toFragment).addToBackStack(null).commit(); 93 | } 94 | }); 95 | return v; 96 | } 97 | ``` 98 | 99 | Start animation in second fragment. 100 | ``` 101 | @Override 102 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 103 | View v = inflater.inflate(R.layout.support_fragment_end, container, false); 104 | final ExitFragmentTransition exitFragmentTransition = FragmentTransition.with(this).to(v.findViewById(R.id.fragment_imageView)).start(savedInstanceState); 105 | exitFragmentTransition.startExitListening(); 106 | return v; 107 | } 108 | ``` 109 | 110 | ## Thanks 111 | Sample Photo 112 | Luke Ma 113 | https://www.flickr.com/photos/lukema/12499338274/in/photostream/ 114 | 115 | DevBytes: Custom Activity Animations 116 | https://www.youtube.com/watch?v=CPxkoe2MraA 117 | 118 | ## License 119 | 120 | This project is released under the Apache License, Version 2.0. 121 | 122 | * [The Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:1.2.3' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albinmathew/PreLollipopTransition/bd4498603cb870111bce8eeacdea30a3de14931a/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Apr 10 15:27:10 PDT 2013 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /sample-app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /sample-app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 22 5 | buildToolsVersion "21.1.2" 6 | 7 | defaultConfig { 8 | applicationId "com.albinmathew.prelollipoptransition" 9 | minSdkVersion 14 10 | targetSdkVersion 22 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | lintOptions { 15 | abortOnError false 16 | } 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | } 24 | 25 | dependencies { 26 | compile project(":PreLollipopTransition") 27 | compile fileTree(dir: 'libs', include: ['*.jar']) 28 | compile 'com.android.support:appcompat-v7:22.0.+' 29 | compile 'com.android.support:support-v4:+' 30 | } 31 | -------------------------------------------------------------------------------- /sample-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 /Applications/android-sdk-macosx-l/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 | -------------------------------------------------------------------------------- /sample-app/src/androidTest/java/com/albinmathew/prelollipoptransition/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.albinmathew.prelollipoptransition; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /sample-app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 22 | 23 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /sample-app/src/main/java/com/albinmathew/prelollipoptransition/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.albinmathew.prelollipoptransition; 2 | 3 | import android.content.Intent; 4 | import android.graphics.BitmapFactory; 5 | import android.os.Bundle; 6 | import android.support.v7.app.ActionBarActivity; 7 | import android.view.Menu; 8 | import android.view.MenuItem; 9 | import android.view.View; 10 | 11 | import com.albinmathew.transitions.ActivityTransitionLauncher; 12 | import com.albinmathew.prelollipoptransition.support_fragment.SupportStartFragment; 13 | 14 | 15 | public class MainActivity extends ActionBarActivity { 16 | 17 | @Override 18 | protected void onCreate(Bundle savedInstanceState) { 19 | super.onCreate(savedInstanceState); 20 | setContentView(R.layout.activity_main); 21 | findViewById(R.id.imageView).setOnClickListener(new View.OnClickListener() { 22 | @Override 23 | public void onClick(View v) { 24 | final Intent intent = new Intent(MainActivity.this, SubActivity.class); 25 | ActivityTransitionLauncher.with(MainActivity.this).from(v).launch(intent); 26 | } 27 | }); 28 | 29 | findViewById(R.id.imageView2).setOnClickListener(new View.OnClickListener() { 30 | @Override 31 | public void onClick(View v) { 32 | final Intent intent = new Intent(MainActivity.this, SubActivity2.class); 33 | // set bitmap for animation 34 | ActivityTransitionLauncher.with(MainActivity.this).image(BitmapFactory.decodeResource(getResources(), R.drawable.photo)).from(v).launch(intent); 35 | } 36 | }); 37 | 38 | if (savedInstanceState == null) { 39 | getSupportFragmentManager() 40 | .beginTransaction() 41 | .add(R.id.support_content, new SupportStartFragment()) 42 | .commit(); 43 | getFragmentManager() 44 | .beginTransaction() 45 | .add(R.id.content, new com.albinmathew.prelollipoptransition.fragment.StartFragment()) 46 | .commit(); 47 | 48 | } 49 | } 50 | 51 | 52 | @Override 53 | public boolean onCreateOptionsMenu(Menu menu) { 54 | // Inflate the menu; this adds items to the action bar if it is present. 55 | getMenuInflater().inflate(R.menu.menu_main, menu); 56 | return true; 57 | } 58 | 59 | @Override 60 | public boolean onOptionsItemSelected(MenuItem item) { 61 | // Handle action bar item clicks here. The action bar will 62 | // automatically handle clicks on the Home/Up button, so long 63 | // as you specify a parent activity in AndroidManifest.xml. 64 | int id = item.getItemId(); 65 | 66 | //noinspection SimplifiableIfStatement 67 | if (id == R.id.action_settings) { 68 | return true; 69 | } 70 | 71 | return super.onOptionsItemSelected(item); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /sample-app/src/main/java/com/albinmathew/prelollipoptransition/SubActivity.java: -------------------------------------------------------------------------------- 1 | package com.albinmathew.prelollipoptransition; 2 | 3 | import android.support.v7.app.ActionBarActivity; 4 | import android.os.Bundle; 5 | import android.view.Menu; 6 | import android.view.MenuItem; 7 | 8 | import com.albinmathew.transitions.ActivityTransition; 9 | import com.albinmathew.transitions.ExitActivityTransition; 10 | 11 | 12 | public class SubActivity extends ActionBarActivity { 13 | 14 | private ExitActivityTransition exitTransition; 15 | 16 | @Override 17 | protected void onCreate(Bundle savedInstanceState) { 18 | super.onCreate(savedInstanceState); 19 | setContentView(R.layout.activity_sub); 20 | exitTransition = ActivityTransition.with(getIntent()).to(findViewById(R.id.sub_imageView)).start(savedInstanceState); 21 | } 22 | 23 | 24 | @Override 25 | public boolean onCreateOptionsMenu(Menu menu) { 26 | // Inflate the menu; this adds items to the action bar if it is present. 27 | getMenuInflater().inflate(R.menu.menu_sub, menu); 28 | return true; 29 | } 30 | 31 | @Override 32 | public boolean onOptionsItemSelected(MenuItem item) { 33 | // Handle action bar item clicks here. The action bar will 34 | // automatically handle clicks on the Home/Up button, so long 35 | // as you specify a parent activity in AndroidManifest.xml. 36 | int id = item.getItemId(); 37 | 38 | //noinspection SimplifiableIfStatement 39 | if (id == R.id.action_settings) { 40 | return true; 41 | } 42 | 43 | return super.onOptionsItemSelected(item); 44 | } 45 | 46 | @Override 47 | public void onBackPressed() { 48 | exitTransition.exit(this); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /sample-app/src/main/java/com/albinmathew/prelollipoptransition/SubActivity2.java: -------------------------------------------------------------------------------- 1 | package com.albinmathew.prelollipoptransition; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.ActionBarActivity; 5 | import android.view.Menu; 6 | import android.view.MenuItem; 7 | 8 | import com.albinmathew.transitions.ActivityTransition; 9 | import com.albinmathew.transitions.ExitActivityTransition; 10 | 11 | 12 | public class SubActivity2 extends ActionBarActivity { 13 | 14 | private ExitActivityTransition exitTransition; 15 | 16 | @Override 17 | protected void onCreate(Bundle savedInstanceState) { 18 | super.onCreate(savedInstanceState); 19 | setContentView(R.layout.activity_sub2); 20 | exitTransition = ActivityTransition.with(getIntent()).to(findViewById(R.id.sub_imageView)).start(savedInstanceState); 21 | } 22 | 23 | 24 | @Override 25 | public boolean onCreateOptionsMenu(Menu menu) { 26 | // Inflate the menu; this adds items to the action bar if it is present. 27 | getMenuInflater().inflate(R.menu.menu_sub, menu); 28 | return true; 29 | } 30 | 31 | @Override 32 | public boolean onOptionsItemSelected(MenuItem item) { 33 | // Handle action bar item clicks here. The action bar will 34 | // automatically handle clicks on the Home/Up button, so long 35 | // as you specify a parent activity in AndroidManifest.xml. 36 | int id = item.getItemId(); 37 | 38 | //noinspection SimplifiableIfStatement 39 | if (id == R.id.action_settings) { 40 | return true; 41 | } 42 | 43 | return super.onOptionsItemSelected(item); 44 | } 45 | 46 | @Override 47 | public void onBackPressed() { 48 | exitTransition.exit(this); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /sample-app/src/main/java/com/albinmathew/prelollipoptransition/fragment/EndFragment.java: -------------------------------------------------------------------------------- 1 | package com.albinmathew.prelollipoptransition.fragment; 2 | 3 | import android.app.Fragment; 4 | import android.os.Bundle; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | 9 | import com.albinmathew.transitions.fragment.ExitFragmentTransition; 10 | import com.albinmathew.transitions.fragment.FragmentTransition; 11 | import com.albinmathew.prelollipoptransition.R; 12 | 13 | 14 | public class EndFragment extends Fragment { 15 | @Override 16 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 17 | View v = inflater.inflate(R.layout.fragment_end, container, false); 18 | final ExitFragmentTransition exitFragmentTransition = FragmentTransition.with(this).to(v.findViewById(R.id.fragment_imageView)).start(savedInstanceState); 19 | exitFragmentTransition.startExitListening(); 20 | return v; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /sample-app/src/main/java/com/albinmathew/prelollipoptransition/fragment/StartFragment.java: -------------------------------------------------------------------------------- 1 | package com.albinmathew.prelollipoptransition.fragment; 2 | 3 | import android.app.Fragment; 4 | import android.graphics.BitmapFactory; 5 | import android.os.Bundle; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | 10 | import com.albinmathew.transitions.fragment.FragmentTransitionLauncher; 11 | import com.albinmathew.prelollipoptransition.R; 12 | 13 | public class StartFragment extends Fragment { 14 | @Override 15 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 16 | View v = inflater.inflate(R.layout.support_fragment_start, container, false); 17 | v.setOnClickListener(new View.OnClickListener() { 18 | @Override 19 | public void onClick(View view) { 20 | final EndFragment toFragment = new EndFragment(); 21 | FragmentTransitionLauncher 22 | .with(view.getContext()) 23 | .image(BitmapFactory.decodeResource(getResources(), R.drawable.photo)) 24 | .from(view.findViewById(R.id.imageView)).prepare(toFragment); 25 | getFragmentManager().beginTransaction().replace(R.id.content, toFragment).addToBackStack(null).commit(); 26 | } 27 | }); 28 | return v; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /sample-app/src/main/java/com/albinmathew/prelollipoptransition/support_fragment/SupportEndFragment.java: -------------------------------------------------------------------------------- 1 | package com.albinmathew.prelollipoptransition.support_fragment; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.app.Fragment; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | 9 | import com.albinmathew.transitions.fragment.ExitFragmentTransition; 10 | import com.albinmathew.transitions.fragment.FragmentTransition; 11 | import com.albinmathew.prelollipoptransition.R; 12 | 13 | public class SupportEndFragment extends Fragment { 14 | @Override 15 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 16 | View v = inflater.inflate(R.layout.support_fragment_end, container, false); 17 | final ExitFragmentTransition exitFragmentTransition = FragmentTransition.with(this).to(v.findViewById(R.id.fragment_imageView)).start(savedInstanceState); 18 | exitFragmentTransition.startExitListening(); 19 | return v; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /sample-app/src/main/java/com/albinmathew/prelollipoptransition/support_fragment/SupportStartFragment.java: -------------------------------------------------------------------------------- 1 | package com.albinmathew.prelollipoptransition.support_fragment; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.app.Fragment; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | 9 | import com.albinmathew.transitions.fragment.FragmentTransitionLauncher; 10 | import com.albinmathew.prelollipoptransition.R; 11 | 12 | 13 | public class SupportStartFragment extends Fragment { 14 | @Override 15 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 16 | View v = inflater.inflate(R.layout.support_fragment_start, container, false); 17 | v.setOnClickListener(new View.OnClickListener() { 18 | @Override 19 | public void onClick(View view) { 20 | final SupportEndFragment toFragment = new SupportEndFragment(); 21 | FragmentTransitionLauncher.with(view.getContext()).from(view.findViewById(R.id.imageView)).prepare(toFragment); 22 | getFragmentManager().beginTransaction().replace(R.id.support_content, toFragment).addToBackStack(null).commit(); 23 | } 24 | }); 25 | return v; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /sample-app/src/main/res/drawable/photo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albinmathew/PreLollipopTransition/bd4498603cb870111bce8eeacdea30a3de14931a/sample-app/src/main/res/drawable/photo.jpg -------------------------------------------------------------------------------- /sample-app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 15 | 16 | 20 | 21 | 25 | 26 | 31 | 32 | 37 | 38 | 43 | 44 | 51 | 52 | 53 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /sample-app/src/main/res/layout/activity_sub.xml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /sample-app/src/main/res/layout/activity_sub2.xml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /sample-app/src/main/res/layout/fragment_end.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 14 | 15 | -------------------------------------------------------------------------------- /sample-app/src/main/res/layout/support_fragment_end.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 15 | 16 | -------------------------------------------------------------------------------- /sample-app/src/main/res/layout/support_fragment_start.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 15 | 16 | -------------------------------------------------------------------------------- /sample-app/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 4 | 6 | 7 | -------------------------------------------------------------------------------- /sample-app/src/main/res/menu/menu_sub.xml: -------------------------------------------------------------------------------- 1 | 5 | 10 | 11 | -------------------------------------------------------------------------------- /sample-app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albinmathew/PreLollipopTransition/bd4498603cb870111bce8eeacdea30a3de14931a/sample-app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample-app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albinmathew/PreLollipopTransition/bd4498603cb870111bce8eeacdea30a3de14931a/sample-app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample-app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albinmathew/PreLollipopTransition/bd4498603cb870111bce8eeacdea30a3de14931a/sample-app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample-app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albinmathew/PreLollipopTransition/bd4498603cb870111bce8eeacdea30a3de14931a/sample-app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample-app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /sample-app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /sample-app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | PreLollipopTransition 3 | 4 | Hello world! 5 | Settings 6 | SubActivity 7 | SubActivity2 8 | 9 | -------------------------------------------------------------------------------- /sample-app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include 'sample-app:','PreLollipopTransition:' 2 | --------------------------------------------------------------------------------