Simplify card view theme
This commit is contained in:
parent
29d99fca17
commit
864bb2d4bc
@ -7,7 +7,6 @@ import android.view.LayoutInflater
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.ImageView.ScaleType
|
import android.widget.ImageView.ScaleType
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import apps.amine.bou.readerforselfoss.R
|
import apps.amine.bou.readerforselfoss.R
|
||||||
import apps.amine.bou.readerforselfoss.api.selfoss.Item
|
import apps.amine.bou.readerforselfoss.api.selfoss.Item
|
||||||
import apps.amine.bou.readerforselfoss.api.selfoss.SelfossApi
|
import apps.amine.bou.readerforselfoss.api.selfoss.SelfossApi
|
||||||
@ -61,10 +60,6 @@ class ItemCardAdapter(
|
|||||||
|
|
||||||
binding.favButton.isSelected = itm.starred
|
binding.favButton.isSelected = itm.starred
|
||||||
binding.title.text = itm.getTitleDecoded()
|
binding.title.text = itm.getTitleDecoded()
|
||||||
binding.title.setTextColor(ContextCompat.getColor(
|
|
||||||
c,
|
|
||||||
appColors.textColor
|
|
||||||
))
|
|
||||||
|
|
||||||
binding.title.setOnTouchListener(LinkOnTouchListener())
|
binding.title.setOnTouchListener(LinkOnTouchListener())
|
||||||
|
|
||||||
@ -72,11 +67,6 @@ class ItemCardAdapter(
|
|||||||
|
|
||||||
binding.sourceTitleAndDate.text = itm.sourceAndDateText()
|
binding.sourceTitleAndDate.text = itm.sourceAndDateText()
|
||||||
|
|
||||||
binding.sourceTitleAndDate.setTextColor(ContextCompat.getColor(
|
|
||||||
c,
|
|
||||||
appColors.textColor
|
|
||||||
))
|
|
||||||
|
|
||||||
if (!fullHeightCards) {
|
if (!fullHeightCards) {
|
||||||
binding.itemImage.maxHeight = imageMaxHeight
|
binding.itemImage.maxHeight = imageMaxHeight
|
||||||
binding.itemImage.scaleType = ScaleType.CENTER_CROP
|
binding.itemImage.scaleType = ScaleType.CENTER_CROP
|
||||||
@ -112,7 +102,6 @@ class ItemCardAdapter(
|
|||||||
|
|
||||||
inner class ViewHolder(val binding: CardItemBinding) : RecyclerView.ViewHolder(binding.root) {
|
inner class ViewHolder(val binding: CardItemBinding) : RecyclerView.ViewHolder(binding.root) {
|
||||||
init {
|
init {
|
||||||
binding.root.setCardBackgroundColor(appColors.cardBackgroundColor)
|
|
||||||
handleClickListeners()
|
handleClickListeners()
|
||||||
handleCustomTabActions()
|
handleCustomTabActions()
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,9 @@
|
|||||||
package apps.amine.bou.readerforselfoss.themes
|
package apps.amine.bou.readerforselfoss.themes
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Context
|
|
||||||
import androidx.preference.PreferenceManager
|
|
||||||
import androidx.annotation.ColorInt
|
import androidx.annotation.ColorInt
|
||||||
import androidx.appcompat.view.ContextThemeWrapper
|
import androidx.preference.PreferenceManager
|
||||||
import android.util.TypedValue
|
|
||||||
import apps.amine.bou.readerforselfoss.R
|
import apps.amine.bou.readerforselfoss.R
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.ViewGroup
|
|
||||||
|
|
||||||
class AppColors(a: Activity) {
|
class AppColors(a: Activity) {
|
||||||
|
|
||||||
@ -16,7 +11,6 @@ class AppColors(a: Activity) {
|
|||||||
@ColorInt val colorPrimaryDark: Int
|
@ColorInt val colorPrimaryDark: Int
|
||||||
@ColorInt val colorAccent: Int
|
@ColorInt val colorAccent: Int
|
||||||
@ColorInt val colorAccentDark: Int
|
@ColorInt val colorAccentDark: Int
|
||||||
@ColorInt val cardBackgroundColor: Int
|
|
||||||
@ColorInt val colorBackground: Int
|
@ColorInt val colorBackground: Int
|
||||||
@ColorInt val textColor: Int
|
@ColorInt val textColor: Int
|
||||||
val isDarkTheme: Boolean
|
val isDarkTheme: Boolean
|
||||||
@ -63,14 +57,5 @@ class AppColors(a: Activity) {
|
|||||||
} else {
|
} else {
|
||||||
R.color.grey_900
|
R.color.grey_900
|
||||||
}
|
}
|
||||||
|
|
||||||
val wrapper = Context::class.java
|
|
||||||
val method = wrapper!!.getMethod("getThemeResId")
|
|
||||||
method.isAccessible = true
|
|
||||||
|
|
||||||
val typedCardBackground = TypedValue()
|
|
||||||
a.theme.resolveAttribute(R.attr.cardBackgroundColor, typedCardBackground, true)
|
|
||||||
|
|
||||||
cardBackgroundColor = typedCardBackground.data
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,8 @@
|
|||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
card_view:cardElevation="2dp"
|
card_view:cardElevation="2dp"
|
||||||
card_view:cardUseCompatPadding="true"
|
card_view:cardUseCompatPadding="true"
|
||||||
card_view:layout_constraintBottom_toBottomOf="parent">
|
card_view:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:cardBackgroundColor="?cardBackgroundColor">
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -65,6 +66,7 @@
|
|||||||
android:gravity="start"
|
android:gravity="start"
|
||||||
android:textAlignment="viewStart"
|
android:textAlignment="viewStart"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
|
android:textColor="?android:textColorPrimary"
|
||||||
app:layout_constraintHorizontal_bias="0.0"
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
app:layout_constraintLeft_toRightOf="@+id/sourceImage"
|
app:layout_constraintLeft_toRightOf="@+id/sourceImage"
|
||||||
app:layout_constraintRight_toRightOf="parent"
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
@ -79,6 +81,7 @@
|
|||||||
android:gravity="start"
|
android:gravity="start"
|
||||||
android:textAlignment="viewStart"
|
android:textAlignment="viewStart"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
|
android:textColor="?android:textColorPrimary"
|
||||||
app:layout_constraintLeft_toLeftOf="@+id/title"
|
app:layout_constraintLeft_toLeftOf="@+id/title"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/title"
|
app:layout_constraintTop_toBottomOf="@+id/title"
|
||||||
tools:text="Google Actualité Il y a 5h" />
|
tools:text="Google Actualité Il y a 5h" />
|
||||||
|
Loading…
Reference in New Issue
Block a user