|
20 | 20 | */ |
21 | 21 | package com.google.android.material.transition.platform; |
22 | 22 |
|
| 23 | +import com.google.android.material.R; |
| 24 | + |
23 | 25 | import static androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP; |
24 | 26 |
|
25 | 27 | import android.view.Gravity; |
| 28 | +import androidx.annotation.AttrRes; |
26 | 29 | import androidx.annotation.IntDef; |
27 | 30 | import androidx.annotation.RestrictTo; |
28 | 31 | import java.lang.annotation.Retention; |
|
44 | 47 | * true, the target will slide to the left on the X axis, up on the Y axis and out in on the Z axis. |
45 | 48 | * When false, the target will slide to the right on the X axis, down on the Y axis and in on the Z |
46 | 49 | * axis. Note that this is independent of whether or not the target is appearing or disappearing. |
| 50 | + * |
| 51 | + * <p>MaterialSharedAxis supports theme-based easing and duration. The transition will load theme |
| 52 | + * values from the {@code SceneRoot}'s context before it runs, and only use them if the |
| 53 | + * corresponding properties weren't already set on the transition instance. |
47 | 54 | */ |
48 | 55 | @androidx.annotation.RequiresApi(android.os.Build.VERSION_CODES.LOLLIPOP) |
49 | 56 | public final class MaterialSharedAxis extends MaterialVisibility<VisibilityAnimatorProvider> { |
@@ -81,6 +88,9 @@ public final class MaterialSharedAxis extends MaterialVisibility<VisibilityAnima |
81 | 88 | @Axis private final int axis; |
82 | 89 | private final boolean forward; |
83 | 90 |
|
| 91 | + @AttrRes private static final int DEFAULT_THEMED_DURATION_ATTR = R.attr.motionDurationLong1; |
| 92 | + @AttrRes private static final int DEFAULT_THEMED_EASING_ATTR = R.attr.motionEasingStandard; |
| 93 | + |
84 | 94 | public MaterialSharedAxis(@Axis int axis, boolean forward) { |
85 | 95 | super(createPrimaryAnimatorProvider(axis, forward), createSecondaryAnimatorProvider()); |
86 | 96 | this.axis = axis; |
@@ -113,4 +123,16 @@ private static VisibilityAnimatorProvider createPrimaryAnimatorProvider( |
113 | 123 | private static VisibilityAnimatorProvider createSecondaryAnimatorProvider() { |
114 | 124 | return new FadeThroughProvider(); |
115 | 125 | } |
| 126 | + |
| 127 | + @AttrRes |
| 128 | + @Override |
| 129 | + int getDurationThemeAttrResId(boolean appearing) { |
| 130 | + return DEFAULT_THEMED_DURATION_ATTR; |
| 131 | + } |
| 132 | + |
| 133 | + @AttrRes |
| 134 | + @Override |
| 135 | + int getEasingThemeAttrResId(boolean appearing) { |
| 136 | + return DEFAULT_THEMED_EASING_ATTR; |
| 137 | + } |
116 | 138 | } |
0 commit comments