Skip to content

Commit ba127f0

Browse files
committed
Update theme attrs to use limited set of global interpolators (persistent, incoming, outgoing).
- Rename three motion durations to use naming to reflect the size change of the view(s) on which they run
1 parent 600b33b commit ba127f0

File tree

10 files changed

+26
-23
lines changed

10 files changed

+26
-23
lines changed

Reply/app/src/main/java/com/materialstudies/reply/ui/compose/ComposeFragment.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,12 @@ class ComposeFragment : Fragment() {
118118
requireActivity().findViewById(R.id.fab),
119119
binding.emailCardView
120120
)
121-
duration = resources.getInteger(R.integer.reply_motion_default_duration).toLong()
122-
interpolator = requireContext().themeInterpolator(R.attr.materialMotionInterpolator)
121+
duration = resources.getInteger(R.integer.reply_motion_default_large).toLong()
122+
interpolator = requireContext().themeInterpolator(R.attr.motionInterpolatorPersistent)
123123
}
124124
returnTransition = Slide().apply {
125-
duration = resources.getInteger(R.integer.reply_motion_micro_duration).toLong()
126-
interpolator = AccelerateInterpolator()
125+
duration = resources.getInteger(R.integer.reply_motion_duration_medium).toLong()
126+
interpolator = requireContext().themeInterpolator(R.attr.motionInterpolatorOutgoing)
127127
}
128128
startPostponedEnterTransition()
129129
}

Reply/app/src/main/java/com/materialstudies/reply/ui/email/EmailFragment.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,15 @@ class EmailFragment : Fragment() {
9595
R.id.nested_scroll_view,
9696
correctForZOrdering = true
9797
).apply {
98-
duration = resources.getInteger(R.integer.reply_motion_default_duration).toLong()
99-
interpolator = requireContext().themeInterpolator(R.attr.materialMotionInterpolator)
98+
duration = resources.getInteger(R.integer.reply_motion_default_large).toLong()
99+
interpolator = requireContext().themeInterpolator(R.attr.motionInterpolatorPersistent)
100100
}
101101
sharedElementReturnTransition = MaterialContainerTransition(
102102
R.id.recycler_view,
103103
correctForZOrdering = true
104104
).apply {
105-
duration = resources.getInteger(R.integer.reply_motion_default_duration).toLong()
106-
interpolator = requireContext().themeInterpolator(R.attr.materialMotionInterpolator)
105+
duration = resources.getInteger(R.integer.reply_motion_default_large).toLong()
106+
interpolator = requireContext().themeInterpolator(R.attr.motionInterpolatorPersistent)
107107
}
108108
}
109109

Reply/app/src/main/java/com/materialstudies/reply/ui/home/EmailSwipeActionDrawable.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class EmailSwipeActionDrawable(context: Context) : Drawable() {
7878
}
7979
}
8080
private var progressAnim: ValueAnimator? = null
81-
private val dur = context.resources.getInteger(R.integer.reply_motion_short_duration)
81+
private val dur = context.resources.getInteger(R.integer.reply_motion_duration_medium)
8282
private val interp = FastOutSlowInInterpolator()
8383

8484
override fun onBoundsChange(bounds: Rect?) {

Reply/app/src/main/java/com/materialstudies/reply/ui/nav/BottomNavDrawerFragment.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class BottomNavDrawerFragment :
129129
private var sandwichState: SandwichState = SandwichState.CLOSED
130130
private var sandwichAnim: ValueAnimator? = null
131131
private val sandwichInterp by lazy(NONE) {
132-
requireContext().themeInterpolator(R.attr.materialMotionInterpolator)
132+
requireContext().themeInterpolator(R.attr.motionInterpolatorPersistent)
133133
}
134134
// Progress value which drives the animation of the sandwiching account picker. Responsible
135135
// for both calling progress updates and state updates.
@@ -306,7 +306,7 @@ class BottomNavDrawerFragment :
306306
addUpdateListener { sandwichProgress = animatedValue as Float }
307307
interpolator = sandwichInterp
308308
duration = (abs(newProgress - initialProgress) *
309-
resources.getInteger(R.integer.reply_motion_short_duration)).toLong()
309+
resources.getInteger(R.integer.reply_motion_duration_medium)).toLong()
310310
}
311311
sandwichAnim?.start()
312312
}

Reply/app/src/main/java/com/materialstudies/reply/util/transition/MaterialContainerTransition.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,6 @@ private class MaterialContainerTransitionDrawable(
341341
// Fade out the startView while pinning it to the top of currentBounds and scaling it to
342342
// fit the width of currentBounds.
343343
val startAlpha = lerp(1F, 0F, alphaOutStartPoint, alphaOutEndPoint, progress)
344-
println("startAlpha: progress: $progress, $startAlpha")
345344
// Translate to pin to top
346345
if (startAlpha > 0F) {
347346
canvas.withTranslation(currentBounds.left, currentBounds.top) {

Reply/app/src/main/res/animator/fab_hide.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@
1717
android:propertyName="scale"
1818
android:valueFrom="1"
1919
android:valueTo="0"
20-
android:duration="@integer/reply_motion_micro_duration"
20+
android:duration="@integer/reply_motion_duration_small"
2121
android:repeatMode="restart"
2222
android:interpolator="@android:interpolator/fast_out_slow_in"/>
2323
<objectAnimator
2424
android:propertyName="iconScale"
2525
android:valueFrom="1"
2626
android:valueTo="0"
27-
android:duration="@integer/reply_motion_micro_duration"
27+
android:duration="@integer/reply_motion_duration_small"
2828
android:repeatMode="restart"
2929
android:interpolator="@android:interpolator/fast_out_slow_in"/>
3030
<objectAnimator
3131
android:propertyName="opacity"
3232
android:valueFrom="1"
3333
android:valueTo="0"
34-
android:duration="@integer/reply_motion_micro_duration"
34+
android:duration="@integer/reply_motion_duration_small"
3535
android:repeatMode="restart"
3636
android:interpolator="@android:interpolator/fast_out_slow_in"/>
3737
</set>

Reply/app/src/main/res/animator/fab_show.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,21 @@
1818
android:propertyName="scale"
1919
android:valueFrom="0"
2020
android:valueTo="1"
21-
android:duration="@integer/reply_motion_micro_duration"
21+
android:duration="@integer/reply_motion_duration_small"
2222
android:repeatMode="restart"
2323
android:interpolator="@android:interpolator/fast_out_slow_in"/>
2424
<objectAnimator
2525
android:propertyName="iconScale"
2626
android:valueFrom="0"
2727
android:valueTo="1"
28-
android:duration="@integer/reply_motion_micro_duration"
28+
android:duration="@integer/reply_motion_duration_small"
2929
android:repeatMode="restart"
3030
android:interpolator="@android:interpolator/fast_out_slow_in"/>
3131
<objectAnimator
3232
android:propertyName="opacity"
3333
android:valueFrom="0"
3434
android:valueTo="1"
35-
android:duration="@integer/reply_motion_micro_duration"
35+
android:duration="@integer/reply_motion_duration_small"
3636
android:repeatMode="restart"
3737
android:interpolator="@android:interpolator/fast_out_slow_in"/>
3838
</set>

Reply/app/src/main/res/values/attrs.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
<attr name="emphasisMediumAlpha" format="float"/>
2525
<attr name="emphasisDisabledAlpha" format="float"/>
2626

27-
<attr name="materialMotionInterpolator" format="reference"/>
27+
<attr name="motionInterpolatorPersistent" format="reference"/>
28+
<attr name="motionInterpolatorIncoming" format="reference"/>
29+
<attr name="motionInterpolatorOutgoing" format="reference"/>
2830

2931
<!--Custom view themes/styles-->
3032
<attr name="bottomNavigationDrawerStyle" format="reference" />

Reply/app/src/main/res/values/motion.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
<!--Motion-->
1818

19-
<integer name="reply_motion_default_duration">300</integer>
20-
<integer name="reply_motion_short_duration">225</integer>
21-
<integer name="reply_motion_micro_duration">175</integer>
19+
<integer name="reply_motion_default_large">300</integer>
20+
<integer name="reply_motion_duration_medium">225</integer>
21+
<integer name="reply_motion_duration_small">175</integer>
2222

2323
</resources>

Reply/app/src/main/res/values/themes.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@
6262
<item name="emphasisMediumAlpha">0.60</item>
6363
<item name="emphasisDisabledAlpha">0.38</item>
6464

65-
<item name="materialMotionInterpolator">@android:interpolator/fast_out_slow_in</item>
65+
<item name="motionInterpolatorPersistent">@android:interpolator/fast_out_slow_in</item>
66+
<item name="motionInterpolatorIncoming">@android:interpolator/decelerate_cubic</item>
67+
<item name="motionInterpolatorOutgoing">@android:interpolator/accelerate_cubic</item>
6668

6769
<!--Styles-->
6870
<item name="bottomAppBarStyle">@style/Widget.MaterialComponents.BottomAppBar.PrimarySurface</item>

0 commit comments

Comments
 (0)