Skip to content

Commit

Permalink
[Motion] Update container transform to use new motion system.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 444848054
  • Loading branch information
hunterstich authored and dsn5ft committed Apr 27, 2022
1 parent 0e4e44e commit f2f454b
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 9 deletions.
Expand Up @@ -99,7 +99,9 @@ void configure(MaterialContainerTransform transform, boolean entering) {
if (duration != NO_DURATION) {
transform.setDuration(duration);
}
transform.setInterpolator(getInterpolator());
if (getInterpolator() != null) {
transform.setInterpolator(getInterpolator());
}
if (isArcMotionEnabled()) {
transform.setPathMotion(new MaterialArcMotion());
}
Expand All @@ -116,7 +118,9 @@ void configure(
if (duration != NO_DURATION) {
transform.setDuration(duration);
}
transform.setInterpolator(getInterpolator());
if (getInterpolator() != null) {
transform.setInterpolator(getInterpolator());
}
if (isArcMotionEnabled()) {
transform.setPathMotion(
new com.google.android.material.transition.platform.MaterialArcMotion());
Expand Down Expand Up @@ -302,6 +306,8 @@ private void setUpBottomSheetInterpolation(View view) {
setTextFloat(view.findViewById(R.id.y1_edit_text), currentInterp.controlY1);
setTextFloat(view.findViewById(R.id.x2_edit_text), currentInterp.controlX2);
setTextFloat(view.findViewById(R.id.y2_edit_text), currentInterp.controlY2);
} else {
interpolationGroup.check(R.id.radio_default);
}

// Show/hide custom text input fields depending on initial checked radio button.
Expand Down Expand Up @@ -452,9 +458,12 @@ private void setUpBottomSheetConfirmationButtons(View view, BottomSheetDialog di
} else if (checkedRadioButtonId == R.id.radio_bounce) {
interpolator = new BounceInterpolator();
dialog.dismiss();
} else {
} else if (checkedRadioButtonId == R.id.radio_fast_out_slow_in) {
interpolator = new FastOutSlowInInterpolator();
dialog.dismiss();
} else {
interpolator = null;
dialog.dismiss();
}
});

Expand Down
Expand Up @@ -164,12 +164,18 @@
android:animateLayoutChanges="true"
android:orientation="vertical">

<RadioButton
android:id="@+id/radio_default"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/cat_transition_config_default"
android:checked="true"/>

<RadioButton
android:id="@+id/radio_fast_out_slow_in"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/cat_transition_config_fast_out_slow_in_title"
android:checked="true"/>
android:text="@string/cat_transition_config_fast_out_slow_in_title"/>

<RadioButton
android:id="@+id/radio_overshoot"
Expand Down
Expand Up @@ -51,6 +51,7 @@ Phasellus in aliquet mi. Pellentesque habitant morbi tristique senectus et netus
<string name="cat_transition_config_enter_duration_title">Enter Duration</string>
<string name="cat_transition_config_return_duration_title">Return Duration</string>
<string name="cat_transition_config_interpolation_title">Interpolation</string>
<string name="cat_transition_config_default">Default</string>
<string name="cat_transition_config_fast_out_slow_in_title">FastOutSlowIn</string>
<string name="cat_transition_config_overshoot">Overshoot</string>
<string name="cat_transition_config_anticipate_overshoot">AnticipateOvershoot</string>
Expand Down
Expand Up @@ -1005,9 +1005,12 @@ public void onTransitionEnd(@NonNull Transition transition) {

private void maybeApplyThemeValues(Context context, boolean entering) {
TransitionUtils.maybeApplyThemeInterpolator(
this, context, R.attr.motionEasingStandard, AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR);
this,
context,
R.attr.motionEasingEmphasizedInterpolator,
AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR);
TransitionUtils.maybeApplyThemeDuration(
this, context, entering ? R.attr.motionDurationLong1 : R.attr.motionDurationMedium2);
this, context, entering ? R.attr.motionDurationExtraLong2 : R.attr.motionDurationMedium4);
if (!pathMotionCustom) {
TransitionUtils.maybeApplyThemePath(this, context, R.attr.motionPath);
}
Expand Down
Expand Up @@ -1010,9 +1010,12 @@ public void onTransitionEnd(@NonNull Transition transition) {

private void maybeApplyThemeValues(Context context, boolean entering) {
TransitionUtils.maybeApplyThemeInterpolator(
this, context, R.attr.motionEasingStandard, AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR);
this,
context,
R.attr.motionEasingEmphasizedInterpolator,
AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR);
TransitionUtils.maybeApplyThemeDuration(
this, context, entering ? R.attr.motionDurationLong1 : R.attr.motionDurationMedium2);
this, context, entering ? R.attr.motionDurationExtraLong2 : R.attr.motionDurationMedium4);
if (!pathMotionCustom) {
TransitionUtils.maybeApplyThemePath(this, context, R.attr.motionPath);
}
Expand Down

0 comments on commit f2f454b

Please sign in to comment.