Skip to content

Commit

Permalink
fix(android): amend hasActivityTransitions() for transitions (#10832)
Browse files Browse the repository at this point in the history
* allow listening of initial resume event
* remove unsupported transitions from TabGroupProxy
* prevent script loading on future resumes
* do not apply transitions to launch activity

Fixes TIMOB-25678
  • Loading branch information
garymathews authored and sgtcoolguy committed Apr 15, 2019
1 parent 4b599eb commit 14ad127
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,7 @@ protected void handleOpen(KrollDict options)
int exitAnimation = TiConvert.toInt(options.get(TiC.PROPERTY_ACTIVITY_EXIT_ANIMATION), 0);
topActivity.overridePendingTransition(enterAnimation, exitAnimation);
} else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
topActivity.startActivity(intent, createActivityOptionsBundle(topActivity));
} else {
topActivity.startActivity(intent);
}
topActivity.startActivity(intent);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public abstract class TiLaunchActivity extends TiBaseActivity
*/
public abstract String getUrl();

private boolean hasLoadedScript = false;

/**
* The JavaScript URL that should be ran for the given TiJSActivity derived class name.
* Will only return a result if given activity class was launched at least once.
Expand Down Expand Up @@ -167,16 +169,20 @@ protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
}

@Override
protected void windowCreated(Bundle savedInstanceState)
public boolean isJSActivity()
{
super.windowCreated(savedInstanceState);
loadScript();
return false;
}

public boolean isJSActivity()
@Override
protected void onResume()
{
return false;
// Prevent script from loading on future resumes
if (!hasLoadedScript) {
hasLoadedScript = true;
loadScript();
}
super.onResume();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.appcelerator.titanium.TiBlob;
import org.appcelerator.titanium.TiC;
import org.appcelerator.titanium.TiDimension;
import org.appcelerator.titanium.TiLaunchActivity;
import org.appcelerator.titanium.util.TiConvert;
import org.appcelerator.titanium.util.TiDeviceOrientation;
import org.appcelerator.titanium.util.TiRHelper;
Expand All @@ -38,9 +39,10 @@
import android.os.Build;
import android.os.Bundle;
import android.os.Message;
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v4.util.Pair;
import android.support.annotation.Nullable;
import android.util.DisplayMetrics;
import android.util.Pair;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
Expand Down Expand Up @@ -640,15 +642,20 @@ public void setNavigationWindow(TiWindowProxy navigationWindow)
@Nullable
protected Bundle createActivityOptionsBundle(Activity activity)
{
if (hasActivityTransitions()) {
Bundle b = ActivityOptions
.makeSceneTransitionAnimation(
activity, sharedElementPairs.toArray(new Pair[sharedElementPairs.size()]))
.toBundle();
return b;
ActivityOptionsCompat options = null;

// Do NOT apply transitions to launch activity.
if (hasActivityTransitions() && !(activity instanceof TiLaunchActivity)) {
if (!sharedElementPairs.isEmpty()) {
options = ActivityOptionsCompat.makeSceneTransitionAnimation(
activity, sharedElementPairs.toArray(new Pair[sharedElementPairs.size()]));
} else {
options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity);
}
} else {
return null;
options = ActivityOptionsCompat.makeBasic();
}
return options.toBundle();
}

/**
Expand All @@ -657,6 +664,6 @@ protected Bundle createActivityOptionsBundle(Activity activity)
protected boolean hasActivityTransitions()
{
final boolean animated = TiConvert.toBoolean(getProperties(), TiC.PROPERTY_ANIMATED, true);
return (LOLLIPOP_OR_GREATER && animated && sharedElementPairs != null && !sharedElementPairs.isEmpty());
return LOLLIPOP_OR_GREATER && animated;
}
}

0 comments on commit 14ad127

Please sign in to comment.