Merge "Make Activity#overrideActivityTransition handle invalid resId." into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
dd887408f2
@@ -143,8 +143,12 @@ public class TransitionAnimationHelper {
|
|||||||
Animation a = null;
|
Animation a = null;
|
||||||
if (animAttr != 0) {
|
if (animAttr != 0) {
|
||||||
if (overrideType == ANIM_FROM_STYLE && !isTask) {
|
if (overrideType == ANIM_FROM_STYLE && !isTask) {
|
||||||
a = loadCustomActivityTransition(animAttr, options, enter, transitionAnimation);
|
final TransitionInfo.AnimationOptions.CustomActivityTransition customTransition =
|
||||||
if (a == null) {
|
getCustomActivityTransition(animAttr, options);
|
||||||
|
if (customTransition != null) {
|
||||||
|
a = loadCustomActivityTransition(
|
||||||
|
customTransition, options, enter, transitionAnimation);
|
||||||
|
} else {
|
||||||
a = transitionAnimation
|
a = transitionAnimation
|
||||||
.loadAnimationAttr(options.getPackageName(), options.getAnimations(),
|
.loadAnimationAttr(options.getPackageName(), options.getAnimations(),
|
||||||
animAttr, translucent);
|
animAttr, translucent);
|
||||||
@@ -161,10 +165,8 @@ public class TransitionAnimationHelper {
|
|||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Animation loadCustomActivityTransition(int animAttr,
|
static TransitionInfo.AnimationOptions.CustomActivityTransition getCustomActivityTransition(
|
||||||
TransitionInfo.AnimationOptions options, boolean enter,
|
int animAttr, TransitionInfo.AnimationOptions options) {
|
||||||
TransitionAnimation transitionAnimation) {
|
|
||||||
Animation a = null;
|
|
||||||
boolean isOpen = false;
|
boolean isOpen = false;
|
||||||
switch (animAttr) {
|
switch (animAttr) {
|
||||||
case R.styleable.WindowAnimation_activityOpenEnterAnimation:
|
case R.styleable.WindowAnimation_activityOpenEnterAnimation:
|
||||||
@@ -178,17 +180,19 @@ public class TransitionAnimationHelper {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final TransitionInfo.AnimationOptions.CustomActivityTransition transitionAnim =
|
return options.getCustomActivityTransition(isOpen);
|
||||||
options.getCustomActivityTransition(isOpen);
|
}
|
||||||
if (transitionAnim != null) {
|
|
||||||
a = transitionAnimation.loadAppTransitionAnimation(options.getPackageName(),
|
|
||||||
enter ? transitionAnim.getCustomEnterResId()
|
|
||||||
: transitionAnim.getCustomExitResId());
|
|
||||||
if (a != null && transitionAnim.getCustomBackgroundColor() != 0) {
|
|
||||||
a.setBackdropColor(transitionAnim.getCustomBackgroundColor());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
static Animation loadCustomActivityTransition(
|
||||||
|
@NonNull TransitionInfo.AnimationOptions.CustomActivityTransition transitionAnim,
|
||||||
|
TransitionInfo.AnimationOptions options, boolean enter,
|
||||||
|
TransitionAnimation transitionAnimation) {
|
||||||
|
final Animation a = transitionAnimation.loadAppTransitionAnimation(options.getPackageName(),
|
||||||
|
enter ? transitionAnim.getCustomEnterResId()
|
||||||
|
: transitionAnim.getCustomExitResId());
|
||||||
|
if (a != null && transitionAnim.getCustomBackgroundColor() != 0) {
|
||||||
|
a.setBackdropColor(transitionAnim.getCustomBackgroundColor());
|
||||||
|
}
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -888,8 +888,11 @@ public class AppTransition implements Dump {
|
|||||||
} else {
|
} else {
|
||||||
int animAttr = mapOpenCloseTransitTypes(transit, enter);
|
int animAttr = mapOpenCloseTransitTypes(transit, enter);
|
||||||
if (animAttr != 0) {
|
if (animAttr != 0) {
|
||||||
a = loadCustomActivityAnimation(animAttr, enter, container);
|
final CustomAppTransition customAppTransition =
|
||||||
if (a == null) {
|
getCustomAppTransition(animAttr, container);
|
||||||
|
if (customAppTransition != null) {
|
||||||
|
a = loadCustomActivityAnimation(customAppTransition, enter, container);
|
||||||
|
} else {
|
||||||
if (canCustomizeAppTransition) {
|
if (canCustomizeAppTransition) {
|
||||||
a = loadAnimationAttr(lp, animAttr, transit);
|
a = loadAnimationAttr(lp, animAttr, transit);
|
||||||
} else {
|
} else {
|
||||||
@@ -911,7 +914,7 @@ public class AppTransition implements Dump {
|
|||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
Animation loadCustomActivityAnimation(int animAttr, boolean enter, WindowContainer container) {
|
CustomAppTransition getCustomAppTransition(int animAttr, WindowContainer container) {
|
||||||
ActivityRecord customAnimationSource = container.asActivityRecord();
|
ActivityRecord customAnimationSource = container.asActivityRecord();
|
||||||
if (customAnimationSource == null) {
|
if (customAnimationSource == null) {
|
||||||
return null;
|
return null;
|
||||||
@@ -927,31 +930,28 @@ public class AppTransition implements Dump {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final CustomAppTransition custom;
|
|
||||||
switch (animAttr) {
|
switch (animAttr) {
|
||||||
case WindowAnimation_activityOpenEnterAnimation:
|
case WindowAnimation_activityOpenEnterAnimation:
|
||||||
case WindowAnimation_activityOpenExitAnimation:
|
case WindowAnimation_activityOpenExitAnimation:
|
||||||
custom = customAnimationSource.getCustomAnimation(true /* open */);
|
return customAnimationSource.getCustomAnimation(true /* open */);
|
||||||
break;
|
|
||||||
case WindowAnimation_activityCloseEnterAnimation:
|
case WindowAnimation_activityCloseEnterAnimation:
|
||||||
case WindowAnimation_activityCloseExitAnimation:
|
case WindowAnimation_activityCloseExitAnimation:
|
||||||
custom = customAnimationSource.getCustomAnimation(false /* open */);
|
return customAnimationSource.getCustomAnimation(false /* open */);
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (custom != null) {
|
|
||||||
final Animation a = mTransitionAnimation.loadAppTransitionAnimation(
|
|
||||||
customAnimationSource.packageName, enter
|
|
||||||
? custom.mEnterAnim : custom.mExitAnim);
|
|
||||||
if (a != null && custom.mBackgroundColor != 0) {
|
|
||||||
a.setBackdropColor(custom.mBackgroundColor);
|
|
||||||
a.setShowBackdrop(true);
|
|
||||||
}
|
|
||||||
return a;
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
private Animation loadCustomActivityAnimation(@NonNull CustomAppTransition custom,
|
||||||
|
boolean enter, WindowContainer container) {
|
||||||
|
final ActivityRecord customAnimationSource = container.asActivityRecord();
|
||||||
|
final Animation a = mTransitionAnimation.loadAppTransitionAnimation(
|
||||||
|
customAnimationSource.packageName, enter
|
||||||
|
? custom.mEnterAnim : custom.mExitAnim);
|
||||||
|
if (a != null && custom.mBackgroundColor != 0) {
|
||||||
|
a.setBackdropColor(custom.mBackgroundColor);
|
||||||
|
a.setShowBackdrop(true);
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
int getAppRootTaskClipMode() {
|
int getAppRootTaskClipMode() {
|
||||||
return mNextAppTransitionRequests.contains(TRANSIT_RELAUNCH)
|
return mNextAppTransitionRequests.contains(TRANSIT_RELAUNCH)
|
||||||
|
|||||||
Reference in New Issue
Block a user