Skip to content
This repository was archived by the owner on Nov 21, 2024. It is now read-only.

Commit cc9f061

Browse files
hunterstichGerrit Code Review
authored andcommitted
Merge "Removed obsolete MaterialCardView extension properties"
2 parents db68f0d + e4187aa commit cc9f061

File tree

3 files changed

+2
-40
lines changed

3 files changed

+2
-40
lines changed

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

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,10 @@ package com.materialstudies.reply.ui.home
1818

1919
import android.view.View
2020
import androidx.recyclerview.widget.RecyclerView
21-
import com.google.android.material.shape.MaterialShapeDrawable
2221
import com.materialstudies.reply.R
2322
import com.materialstudies.reply.data.Email
2423
import com.materialstudies.reply.databinding.EmailItemLayoutBinding
2524
import com.materialstudies.reply.ui.common.EmailAttachmentAdapter
26-
import com.materialstudies.reply.util.backgroundShapeDrawable
27-
import com.materialstudies.reply.util.foregroundShapeDrawable
2825
import com.materialstudies.reply.util.getStyleIdFromAttr
2926
import com.materialstudies.reply.util.setTextAppearanceCompat
3027

@@ -38,9 +35,6 @@ class EmailViewHolder(
3835
= R.layout.email_attachment_preview_item_layout
3936
}
4037

41-
private val cardBackground: MaterialShapeDrawable = binding.cardView.backgroundShapeDrawable
42-
private val cardForeground: MaterialShapeDrawable = binding.cardView.foregroundShapeDrawable
43-
4438
override val reboundableView: View = binding.cardView
4539

4640
init {
@@ -74,17 +68,11 @@ class EmailViewHolder(
7468
// rounded or squared. Since all other corners are set to 0dp rounded, they are
7569
// not affected.
7670
val interpolation = if (email.isStarred) 1F else 0F
77-
setCardShapeInterpolation(interpolation)
71+
binding.cardView.progress = interpolation
7872

7973
binding.executePendingBindings()
8074
}
8175

82-
private fun setCardShapeInterpolation(interpolation: Float) {
83-
cardBackground.interpolation = interpolation
84-
cardForeground.interpolation = interpolation
85-
}
86-
87-
8876
override fun onReboundOffsetChanged(
8977
currentSwipePercentage: Float,
9078
swipeThreshold: Float,
@@ -100,7 +88,7 @@ class EmailViewHolder(
10088
// Animate the top left corner radius of the email card as swipe happens.
10189
val interpolation = (currentSwipePercentage / swipeThreshold).coerceIn(0F, 1F)
10290
val adjustedInterpolation = Math.abs((if (isStarred) 1F else 0F) - interpolation)
103-
setCardShapeInterpolation(adjustedInterpolation)
91+
binding.cardView.progress = adjustedInterpolation
10492

10593
// Start the background animation once the threshold is met.
10694
val thresholdMet = currentSwipePercentage >= swipeThreshold

app/src/main/java/com/materialstudies/reply/util/ViewExtensions.kt

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,8 @@
1717
package com.materialstudies.reply.util
1818

1919
import android.content.Context
20-
import android.graphics.drawable.InsetDrawable
21-
import android.graphics.drawable.LayerDrawable
22-
import android.graphics.drawable.RippleDrawable
2320
import android.os.Build
2421
import android.widget.TextView
25-
import com.google.android.material.card.MaterialCardView
26-
import com.google.android.material.shape.MaterialShapeDrawable
2722

2823
@Suppress("DEPRECATION")
2924
fun TextView.setTextAppearanceCompat(context: Context, resId: Int) {
@@ -33,23 +28,3 @@ fun TextView.setTextAppearanceCompat(context: Context, resId: Int) {
3328
setTextAppearance(context, resId)
3429
}
3530
}
36-
37-
/**
38-
* Helper method to get the MaterialShapeDrawable background of MaterialCardView. This should be
39-
* fixed in a future update to Material Components.
40-
*
41-
* TODO(https://issuetracker.google.com/issues/135604742) Remove once fix lands.
42-
*/
43-
val MaterialCardView.backgroundShapeDrawable: MaterialShapeDrawable
44-
get() = (this.background as InsetDrawable).drawable as MaterialShapeDrawable
45-
46-
/**
47-
* Helper method to get the MaterialShapeDrawable foreground of MaterialCardView. This should be
48-
* fixed in a future update to Material Components.
49-
*
50-
* TODO(https://issuetracker.google.com/issues/135604742) Remove once fix lands.
51-
*/
52-
val MaterialCardView.foregroundShapeDrawable: MaterialShapeDrawable
53-
get() = (((this.foreground as InsetDrawable).drawable as LayerDrawable)
54-
.getDrawable(0) as RippleDrawable)
55-
.getDrawable(0) as MaterialShapeDrawable

app/src/main/res/values-night/themes.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
<style name="Theme.Reply.DayNight" parent="Theme.Reply.Dark"/>
1919

2020
<style name="Theme.Reply.Dark" parent="Theme.Reply">
21-
2221
<!--Color-->
2322
<item name="colorPrimary">@color/colorBlue200</item>
2423
<item name="colorPrimaryVariant">@color/colorBlue300</item>

0 commit comments

Comments
 (0)