-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TIMOB-19580] Customize Activity Transitions #7371
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,10 +81,19 @@ public class AndroidModule extends KrollModule | |
@Kroll.constant public static final int WEBVIEW_LOAD_CACHE_ONLY = WebSettings.LOAD_CACHE_ONLY; | ||
@Kroll.constant public static final int WEBVIEW_LOAD_CACHE_ELSE_NETWORK = WebSettings.LOAD_CACHE_ELSE_NETWORK; | ||
|
||
|
||
|
||
|
||
|
||
@Kroll.constant public static final int TRANSITION_NONE = TiUIView.TRANSITION_NONE; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Variable not formatted correctly |
||
@Kroll.constant public static final int TRANSITION_EXPLODE = TiUIView.TRANSITION_EXPLODE; | ||
@Kroll.constant public static final int TRANSITION_FADE_IN = TiUIView.TRANSITION_FADE_IN; | ||
@Kroll.constant public static final int TRANSITION_FADE_OUT = TiUIView.TRANSITION_FADE_OUT; | ||
@Kroll.constant public static final int TRANSITION_SLIDE_TOP = TiUIView.TRANSITION_SLIDE_TOP; | ||
@Kroll.constant public static final int TRANSITION_SLIDE_RIGHT = TiUIView.TRANSITION_SLIDE_RIGHT; | ||
@Kroll.constant public static final int TRANSITION_SLIDE_BOTTOM = TiUIView.TRANSITION_SLIDE_BOTTOM; | ||
@Kroll.constant public static final int TRANSITION_SLIDE_LEFT = TiUIView.TRANSITION_SLIDE_LEFT; | ||
@Kroll.constant public static final int TRANSITION_CHANGE_BOUNDS = TiUIView.TRANSITION_CHANGE_BOUNDS; | ||
@Kroll.constant public static final int TRANSITION_CHANGE_CLIP_BOUNDS = TiUIView.TRANSITION_CHANGE_CLIP_BOUNDS; | ||
@Kroll.constant public static final int TRANSITION_CHANGE_TRANSFORM = TiUIView.TRANSITION_CHANGE_TRANSFORM; | ||
@Kroll.constant public static final int TRANSITION_CHANGE_IMAGE_TRANSFORM = TiUIView.TRANSITION_CHANGE_IMAGE_TRANSFORM; | ||
|
||
@Kroll.constant public static final int PROGRESS_INDICATOR_STATUS_BAR = TiUIProgressIndicator.STATUS_BAR; | ||
@Kroll.constant public static final int PROGRESS_INDICATOR_DIALOG = TiUIProgressIndicator.DIALOG; | ||
@Kroll.constant public static final int PROGRESS_INDICATOR_INDETERMINANT = TiUIProgressIndicator.INDETERMINANT; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -559,6 +559,14 @@ public class TiC | |
public static final String EVENT_UNFOCUSED = "unfocused"; | ||
public static final String INTENT_PROPERTY_ENTER_ANIMATION = "activityEnterAnimation"; | ||
public static final String INTENT_PROPERTY_EXIT_ANIMATION = "activityExitAnimation"; | ||
public static final String PROPERTY_ENTER_TRANSITION = "activityEnterTransition"; | ||
public static final String PROPERTY_EXIT_TRANSITION = "activityExitTransition"; | ||
public static final String PROPERTY_RETURN_TRANSITION = "activityReturnTransition"; | ||
public static final String PROPERTY_REENTER_TRANSITION = "activityReenterTransition"; | ||
public static final String PROPERTY_SHARED_ELEMENT_ENTER_TRANSITION = "activitySharedElementEnterTransition"; | ||
public static final String PROPERTY_SHARED_ELEMENT_EXIT_TRANSITION = "activitySharedElementExitTransition"; | ||
public static final String PROPERTY_SHARED_ELEMENT_REENTER_TRANSITION = "activitySharedElementReenterTransition"; | ||
public static final String PROPERTY_SHARED_ELEMENT_RETURN_TRANSITION = "activitySharedElementReturnTransition"; | ||
public static final String INTENT_PROPERTY_FINISH_ROOT = "finishRoot"; | ||
public static final String INTENT_PROPERTY_IS_TAB = "isTab"; | ||
public static final String INTENT_PROPERTY_LAYOUT = "layout"; | ||
|
@@ -838,6 +846,11 @@ public class TiC | |
*/ | ||
public static final String PROPERTY_BACKGROUND_SELECTED_IMAGE = "backgroundSelectedImage"; | ||
|
||
/** | ||
* @module.api | ||
*/ | ||
public static final String PROPERTY_TRANSITION_NAME = "transitionName"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Variable and comments not formatted correctly |
||
|
||
/** | ||
* @module.api | ||
*/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,9 @@ | |
package org.appcelerator.titanium.proxy; | ||
|
||
import java.lang.ref.WeakReference; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
|
||
import org.appcelerator.kroll.KrollDict; | ||
import org.appcelerator.kroll.KrollProxy; | ||
|
@@ -21,14 +23,18 @@ | |
import org.appcelerator.titanium.TiC; | ||
import org.appcelerator.titanium.util.TiOrientationHelper; | ||
import org.appcelerator.titanium.util.TiUIHelper; | ||
import org.appcelerator.titanium.util.TiWeakList; | ||
import org.appcelerator.titanium.view.TiAnimation; | ||
import org.appcelerator.titanium.view.TiUIView; | ||
import org.appcelerator.titanium.util.TiWeakList; | ||
|
||
import android.app.Activity; | ||
import android.app.ActivityOptions; | ||
import android.content.pm.ActivityInfo; | ||
import android.os.Build; | ||
import android.os.Bundle; | ||
import android.os.Message; | ||
import android.support.annotation.Nullable; | ||
import android.util.Pair; | ||
import android.view.View; | ||
|
||
@Kroll.proxy(propertyAccessors={ | ||
|
@@ -41,6 +47,7 @@ | |
public abstract class TiWindowProxy extends TiViewProxy | ||
{ | ||
private static final String TAG = "TiWindowProxy"; | ||
protected static final boolean LOLLIPOP_OR_GREATER = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP); | ||
|
||
private static final int MSG_FIRST_ID = KrollProxy.MSG_LAST_ID + 1; | ||
private static final int MSG_OPEN = MSG_FIRST_ID + 100; | ||
|
@@ -58,7 +65,7 @@ public abstract class TiWindowProxy extends TiViewProxy | |
protected boolean inTab; | ||
protected PostOpenListener postOpenListener; | ||
protected boolean windowActivityCreated = false; | ||
|
||
protected List< Pair<View, String> > sharedElementPairs; | ||
|
||
public static interface PostOpenListener | ||
{ | ||
|
@@ -74,6 +81,9 @@ public static TiWindowProxy getWaitingForOpen() | |
public TiWindowProxy() | ||
{ | ||
inTab = false; | ||
if (LOLLIPOP_OR_GREATER) { | ||
sharedElementPairs = new ArrayList< Pair<View, String> >(); | ||
} | ||
} | ||
|
||
@Override | ||
|
@@ -481,4 +491,39 @@ public KrollProxy getParentForBubbling() | |
} | ||
return super.getParentForBubbling(); | ||
} | ||
|
||
@Kroll.method | ||
public void addSharedElement(TiViewProxy view, String transitionName) { | ||
if (LOLLIPOP_OR_GREATER) { | ||
TiUIView v = view.peekView(); | ||
if (v != null) { | ||
Pair< View,String > p = new Pair<View, String>(v.getNativeView(), transitionName); | ||
sharedElementPairs.add(p); | ||
} | ||
} | ||
} | ||
|
||
@Kroll.method | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Annotation not formatted correctly. |
||
public void removeAllSharedElements() { | ||
if (LOLLIPOP_OR_GREATER) { | ||
sharedElementPairs.clear(); | ||
} | ||
} | ||
|
||
/** | ||
* Helper method to create an activity options bundle. | ||
* @param activity The activity on which options bundle should be created. | ||
* @return The Bundle or null. | ||
*/ | ||
@SuppressWarnings("unchecked") | ||
@Nullable | ||
protected Bundle createActivityOptionsBundle(Activity activity) { | ||
if (LOLLIPOP_OR_GREATER) { | ||
Bundle b = ActivityOptions.makeSceneTransitionAnimation(activity, | ||
sharedElementPairs.toArray(new Pair[sharedElementPairs.size()])).toBundle(); | ||
return b; | ||
} else { | ||
return null; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,6 +79,8 @@ public abstract class TiUIView | |
{ | ||
|
||
private static final boolean HONEYCOMB_OR_GREATER = (Build.VERSION.SDK_INT >= 11); | ||
private static final boolean LOLLIPOP_OR_GREATER = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP); | ||
|
||
private static final int LAYER_TYPE_SOFTWARE = 1; | ||
private static final String TAG = "TiUIView"; | ||
|
||
|
@@ -91,6 +93,19 @@ public abstract class TiUIView | |
public static final int SOFT_KEYBOARD_DEFAULT_ON_FOCUS = 0; | ||
public static final int SOFT_KEYBOARD_HIDE_ON_FOCUS = 1; | ||
public static final int SOFT_KEYBOARD_SHOW_ON_FOCUS = 2; | ||
|
||
public static final int TRANSITION_NONE = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The variables are not formatted with the variables above. |
||
public static final int TRANSITION_EXPLODE = 1; | ||
public static final int TRANSITION_FADE_IN = 2; | ||
public static final int TRANSITION_FADE_OUT = 3; | ||
public static final int TRANSITION_SLIDE_TOP = 4; | ||
public static final int TRANSITION_SLIDE_RIGHT = 5; | ||
public static final int TRANSITION_SLIDE_BOTTOM = 6; | ||
public static final int TRANSITION_SLIDE_LEFT = 7; | ||
public static final int TRANSITION_CHANGE_BOUNDS = 8; | ||
public static final int TRANSITION_CHANGE_CLIP_BOUNDS = 9; | ||
public static final int TRANSITION_CHANGE_TRANSFORM = 10; | ||
public static final int TRANSITION_CHANGE_IMAGE_TRANSFORM = 11; | ||
|
||
protected View nativeView; // Native View object | ||
|
||
|
@@ -891,7 +906,11 @@ public void propertyChanged(String key, Object oldValue, Object newValue, KrollP | |
if (nativeView != null) { | ||
ViewCompat.setTranslationZ(nativeView, TiConvert.toFloat(newValue)); | ||
} | ||
} else if (Log.isDebugModeEnabled()) { | ||
} else if (key.equals(TiC.PROPERTY_TRANSITION_NAME)) { | ||
if (LOLLIPOP_OR_GREATER && (nativeView != null)) { | ||
ViewCompat.setTransitionName(nativeView, TiConvert.toString(newValue)); | ||
} | ||
} else if (Log.isDebugModeEnabled()) { | ||
Log.d(TAG, "Unhandled property key: " + key, Log.DEBUG_MODE); | ||
} | ||
} | ||
|
@@ -994,6 +1013,11 @@ public void processProperties(KrollDict d) | |
if (d.containsKey(TiC.PROPERTY_TRANSLATION_Z) && !nativeViewNull){ | ||
ViewCompat.setTranslationZ(nativeView, TiConvert.toFloat(d, TiC.PROPERTY_TRANSLATION_Z)); | ||
} | ||
|
||
if (LOLLIPOP_OR_GREATER && !nativeViewNull | ||
&& d.containsKeyAndNotNull(TiC.PROPERTY_TRANSITION_NAME)) { | ||
ViewCompat.setTransitionName(nativeView, d.getString(TiC.PROPERTY_TRANSITION_NAME)); | ||
} | ||
} | ||
|
||
// TODO dead code? @Override | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments not formatted correctly