This repository was archived by the owner on Nov 21, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 8 files changed +28
-48
lines changed
java/com/materialstudies/reply Expand file tree Collapse file tree 8 files changed +28
-48
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ import com.materialstudies.reply.data.Email
33
33
import com.materialstudies.reply.data.EmailStore
34
34
import com.materialstudies.reply.databinding.ComposeRecipientChipBinding
35
35
import com.materialstudies.reply.databinding.FragmentComposeBinding
36
- import com.materialstudies.reply.util.FastOutUltraSlowIn
36
+ import com.materialstudies.reply.util.themeInterpolator
37
37
import com.materialstudies.reply.util.transition.MaterialContainerTransition
38
38
import kotlin.LazyThreadSafetyMode.NONE
39
39
@@ -119,7 +119,7 @@ class ComposeFragment : Fragment() {
119
119
binding.emailCardView
120
120
)
121
121
duration = resources.getInteger(R .integer.reply_motion_default_duration).toLong()
122
- interpolator = FastOutUltraSlowIn ( )
122
+ interpolator = requireContext().themeInterpolator( R .attr.materialMotionInterpolator )
123
123
}
124
124
returnTransition = Slide ().apply {
125
125
duration = resources.getInteger(R .integer.reply_motion_micro_duration).toLong()
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ import androidx.recyclerview.widget.GridLayoutManager
27
27
import com.materialstudies.reply.R
28
28
import com.materialstudies.reply.data.EmailStore
29
29
import com.materialstudies.reply.databinding.FragmentEmailBinding
30
- import com.materialstudies.reply.util.FastOutUltraSlowIn
30
+ import com.materialstudies.reply.util.themeInterpolator
31
31
import com.materialstudies.reply.util.transition.MaterialContainerTransition
32
32
import kotlin.LazyThreadSafetyMode.NONE
33
33
@@ -96,14 +96,14 @@ class EmailFragment : Fragment() {
96
96
correctForZOrdering = true
97
97
).apply {
98
98
duration = resources.getInteger(R .integer.reply_motion_default_duration).toLong()
99
- interpolator = FastOutUltraSlowIn ( )
99
+ interpolator = requireContext().themeInterpolator( R .attr.materialMotionInterpolator )
100
100
}
101
101
sharedElementReturnTransition = MaterialContainerTransition (
102
102
R .id.recycler_view,
103
103
correctForZOrdering = true
104
104
).apply {
105
105
duration = resources.getInteger(R .integer.reply_motion_default_duration).toLong()
106
- interpolator = FastOutUltraSlowIn ( )
106
+ interpolator = requireContext().themeInterpolator( R .attr.materialMotionInterpolator )
107
107
}
108
108
}
109
109
Original file line number Diff line number Diff line change @@ -37,9 +37,9 @@ import com.materialstudies.reply.R
37
37
import com.materialstudies.reply.data.Account
38
38
import com.materialstudies.reply.data.AccountStore
39
39
import com.materialstudies.reply.databinding.FragmentBottomNavDrawerBinding
40
- import com.materialstudies.reply.util.FastOutUltraSlowIn
41
40
import com.materialstudies.reply.util.lerp
42
41
import com.materialstudies.reply.util.themeColor
42
+ import com.materialstudies.reply.util.themeInterpolator
43
43
import kotlin.LazyThreadSafetyMode.NONE
44
44
import kotlin.math.abs
45
45
@@ -128,7 +128,9 @@ class BottomNavDrawerFragment :
128
128
129
129
private var sandwichState: SandwichState = SandwichState .CLOSED
130
130
private var sandwichAnim: ValueAnimator ? = null
131
- private val sandwichInterp = FastOutUltraSlowIn ()
131
+ private val sandwichInterp by lazy(NONE ) {
132
+ requireContext().themeInterpolator(R .attr.materialMotionInterpolator)
133
+ }
132
134
// Progress value which drives the animation of the sandwiching account picker. Responsible
133
135
// for both calling progress updates and state updates.
134
136
private var sandwichProgress: Float = 0F
Original file line number Diff line number Diff line change @@ -21,6 +21,8 @@ import android.content.Context
21
21
import android.graphics.Color
22
22
import android.graphics.drawable.Drawable
23
23
import android.util.TypedValue
24
+ import android.view.animation.AnimationUtils
25
+ import android.view.animation.Interpolator
24
26
import androidx.annotation.AttrRes
25
27
import androidx.annotation.ColorInt
26
28
import androidx.annotation.DrawableRes
@@ -47,12 +49,22 @@ fun Context.themeColor(
47
49
* Retrieve a style from the current [android.content.res.Resources.Theme].
48
50
*/
49
51
@StyleRes
50
- fun Context.themeStyle (attr : Int ): Int {
52
+ fun Context.themeStyle (@AttrRes attr : Int ): Int {
51
53
val tv = TypedValue ()
52
54
theme.resolveAttribute(attr, tv, true )
53
55
return tv.data
54
56
}
55
57
58
+ @SuppressLint(" Recycle" )
59
+ fun Context.themeInterpolator (@AttrRes attr : Int ): Interpolator {
60
+ return AnimationUtils .loadInterpolator(
61
+ this ,
62
+ obtainStyledAttributes(intArrayOf(attr)).use {
63
+ it.getResourceId(0 , android.R .interpolator.fast_out_slow_in)
64
+ }
65
+ )
66
+ }
67
+
56
68
fun Context.getDrawableOrNull (@DrawableRes id : Int? ): Drawable ? {
57
69
return if (id == null || id == 0 ) null else AppCompatResources .getDrawable(this , id)
58
70
}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 24
24
<attr name =" emphasisMediumAlpha" format =" float" />
25
25
<attr name =" emphasisDisabledAlpha" format =" float" />
26
26
27
+ <attr name =" materialMotionInterpolator" format =" reference" />
28
+
27
29
<!-- Custom view themes/styles-->
28
30
<attr name =" bottomNavigationDrawerStyle" format =" reference" />
29
31
<attr name =" bottomNavigationDrawerNavigationViewTheme" format =" reference" />
Original file line number Diff line number Diff line change 16
16
17
17
<!-- Motion-->
18
18
19
- <integer name =" reply_motion_default_duration" >350 </integer >
20
- <integer name =" reply_motion_short_duration" >250 </integer >
19
+ <integer name =" reply_motion_default_duration" >300 </integer >
20
+ <integer name =" reply_motion_short_duration" >225 </integer >
21
21
<integer name =" reply_motion_micro_duration" >175</integer >
22
22
23
23
</resources >
Original file line number Diff line number Diff line change 62
62
<item name =" emphasisMediumAlpha" >0.60</item >
63
63
<item name =" emphasisDisabledAlpha" >0.38</item >
64
64
65
+ <item name =" materialMotionInterpolator" >@android:interpolator/fast_out_slow_in</item >
66
+
65
67
<!-- Styles-->
66
68
<item name =" bottomAppBarStyle" >@style/Widget.MaterialComponents.BottomAppBar.PrimarySurface</item >
67
69
<item name =" bottomSheetStyle" >@style/Widget.MaterialComponents.BottomSheet.Modal</item >
You can’t perform that action at this time.
0 commit comments