diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/preference/ThemesPreferenceAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/preference/ThemesPreferenceAdapter.kt index 5f985325a3..c8b65edff2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/preference/ThemesPreferenceAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/preference/ThemesPreferenceAdapter.kt @@ -5,10 +5,12 @@ import android.view.View import android.view.ViewGroup import androidx.appcompat.view.ContextThemeWrapper import androidx.recyclerview.widget.RecyclerView +import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.preference.PreferenceValues import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.databinding.PrefThemeItemBinding import eu.kanade.tachiyomi.ui.base.activity.BaseThemedActivity +import eu.kanade.tachiyomi.util.system.getResourceColor import uy.kohesive.injekt.injectLazy class ThemesPreferenceAdapter(private val clickListener: OnItemClickListener) : @@ -45,14 +47,19 @@ class ThemesPreferenceAdapter(private val clickListener: OnItemClickListener) : } inner class ThemeViewHolder(private val view: View) : RecyclerView.ViewHolder(view) { + + private val selectedColor = view.context.getResourceColor(R.attr.colorAccent) + private val unselectedColor = view.context.getResourceColor(android.R.attr.textColorHint) + fun bind(appTheme: PreferenceValues.AppTheme) { binding.name.text = view.context.getString(appTheme.titleResId!!) // Rounded corners - binding.coverContainer1.clipToOutline = true - binding.coverContainer2.clipToOutline = true + binding.coverContainer.clipToOutline = true - binding.themeCard.isChecked = preferences.appTheme().get() == appTheme + val isSelected = preferences.appTheme().get() == appTheme + binding.themeCard.isChecked = isSelected + binding.themeCard.strokeColor = if (isSelected) selectedColor else unselectedColor listOf(binding.root, binding.themeCard).forEach { it.setOnClickListener { diff --git a/app/src/main/res/layout/pref_theme_item.xml b/app/src/main/res/layout/pref_theme_item.xml index ba73c2bff8..d8069bf0a5 100644 --- a/app/src/main/res/layout/pref_theme_item.xml +++ b/app/src/main/res/layout/pref_theme_item.xml @@ -2,7 +2,7 @@ @@ -15,7 +15,10 @@ android:clickable="true" android:focusable="true" android:importantForAccessibility="no" - app:cardCornerRadius="@dimen/card_radius" + app:cardCornerRadius="@dimen/card_selector_radius" + app:contentPadding="4dp" + app:strokeColor="?attr/colorAccent" + app:strokeWidth="4dp" app:cardElevation="0dp"> - - + app:layout_constraintTop_toBottomOf="@+id/top_nav"> - - - - - - + android:background="?attr/colorAccent" + app:layout_constraintStart_toStartOf="@+id/cover_container" + app:layout_constraintTop_toTopOf="@+id/cover_container" /> - - - - - - + app:tint="?attr/colorOnSurface" /> + +