From 11e10f6eff6b5d5b67f67c6d96741cfda617f3a7 Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 19 Apr 2020 11:13:04 -0400 Subject: [PATCH] Replace some old color attribute usages --- .../ui/manga/chapter/ChaptersAdapter.kt | 6 +++--- .../ui/recent/updates/UpdatesHolder.kt | 12 +++-------- .../ui/source/browse/SourceListHolder.kt | 6 ++++-- .../ui/source/filter/TriStateItem.kt | 7 ++++--- .../tachiyomi/widget/StateImageViewTarget.kt | 12 +++++------ app/src/main/res/layout/download_item.xml | 1 - .../main/res/layout/reader_color_filter.xml | 2 +- .../main/res/layout/recent_section_item.xml | 5 +++-- app/src/main/res/layout/source_grid_item.xml | 12 +++++++---- app/src/main/res/layout/source_list_item.xml | 9 +++++--- app/src/main/res/values/styles.xml | 21 +++---------------- 11 files changed, 40 insertions(+), 53 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersAdapter.kt index 6866be6754..ad32a11c3e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersAdapter.kt @@ -1,6 +1,7 @@ package eu.kanade.tachiyomi.ui.manga.chapter import android.content.Context +import androidx.core.content.ContextCompat import eu.davidea.flexibleadapter.FlexibleAdapter import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.preference.PreferencesHelper @@ -20,9 +21,8 @@ class ChaptersAdapter( var items: List = emptyList() - val readColor = context.getResourceColor(android.R.attr.textColorHint) - - val unreadColor = context.getResourceColor(android.R.attr.textColorPrimary) + val readColor = ContextCompat.getColor(context, R.color.material_on_surface_disabled) + val unreadColor = context.getResourceColor(R.attr.colorOnSurface) val bookmarkedColor = context.getResourceColor(R.attr.colorAccent) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesHolder.kt index 9108eba178..140478e5e2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesHolder.kt @@ -1,6 +1,7 @@ package eu.kanade.tachiyomi.ui.recent.updates import android.view.View +import androidx.core.content.ContextCompat import com.bumptech.glide.load.engine.DiskCacheStrategy import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.download.model.Download @@ -25,15 +26,8 @@ import kotlinx.android.synthetic.main.updates_item.manga_title class UpdatesHolder(private val view: View, private val adapter: UpdatesAdapter) : BaseFlexibleViewHolder(view, adapter) { - /** - * Color of read chapter - */ - private var readColor = view.context.getResourceColor(android.R.attr.textColorHint) - - /** - * Color of unread chapter - */ - private var unreadColor = view.context.getResourceColor(android.R.attr.textColorPrimary) + private var readColor = ContextCompat.getColor(view.context, R.color.material_on_surface_disabled) + private var unreadColor = view.context.getResourceColor(R.attr.colorOnSurface) /** * Currently bound item. diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/SourceListHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/SourceListHolder.kt index 71605f70b3..dc87a898c4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/SourceListHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/SourceListHolder.kt @@ -1,8 +1,10 @@ package eu.kanade.tachiyomi.ui.source.browse import android.view.View +import androidx.core.content.ContextCompat import com.bumptech.glide.load.engine.DiskCacheStrategy import eu.davidea.flexibleadapter.FlexibleAdapter +import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.glide.GlideApp import eu.kanade.tachiyomi.util.system.getResourceColor @@ -20,8 +22,8 @@ import kotlinx.android.synthetic.main.source_list_item.title class SourceListHolder(private val view: View, adapter: FlexibleAdapter<*>) : SourceHolder(view, adapter) { - private val favoriteColor = view.context.getResourceColor(android.R.attr.textColorHint) - private val unfavoriteColor = view.context.getResourceColor(android.R.attr.textColorPrimary) + private val favoriteColor = ContextCompat.getColor(view.context, R.color.material_on_surface_disabled) + private val unfavoriteColor = view.context.getResourceColor(R.attr.colorOnSurface) /** * Method called from [CatalogueAdapter.onBindViewHolder]. It updates the data for this diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/source/filter/TriStateItem.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/source/filter/TriStateItem.kt index 53d5bf68c7..ee60e504e0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/source/filter/TriStateItem.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/source/filter/TriStateItem.kt @@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.source.filter import android.view.View import android.widget.CheckedTextView +import androidx.core.content.ContextCompat import androidx.recyclerview.widget.RecyclerView import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat import com.google.android.material.R @@ -39,11 +40,11 @@ open class TriStateItem(val filter: Filter.TriState) : AbstractFlexibleItem throw Exception("Unknown state") }, null)?.apply { val color = if (filter.state == Filter.TriState.STATE_INCLUDE) - R.attr.colorAccent + view.context.getResourceColor(R.attr.colorAccent) else - android.R.attr.textColorSecondary + ContextCompat.getColor(view.context, R.color.material_on_background_disabled) - setTint(view.context.getResourceColor(color)) + setTint(color) } view.setCompoundDrawablesWithIntrinsicBounds(getIcon(), null, null, null) diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/StateImageViewTarget.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/StateImageViewTarget.kt index 0613e330b6..4366a94ad3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/StateImageViewTarget.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/StateImageViewTarget.kt @@ -4,11 +4,11 @@ import android.graphics.drawable.Drawable import android.view.View import android.widget.ImageView import android.widget.ImageView.ScaleType +import androidx.core.content.ContextCompat import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat import com.bumptech.glide.request.target.ImageViewTarget import com.bumptech.glide.request.transition.Transition import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.util.system.getResourceColor import eu.kanade.tachiyomi.util.view.gone import eu.kanade.tachiyomi.util.view.visible @@ -24,11 +24,9 @@ import eu.kanade.tachiyomi.util.view.visible class StateImageViewTarget( view: ImageView, val progress: View? = null, - val errorDrawableRes: Int = R.drawable.ic_broken_image_grey_24dp, - val errorScaleType: ScaleType = ScaleType.CENTER -) : - - ImageViewTarget(view) { + private val errorDrawableRes: Int = R.drawable.ic_broken_image_grey_24dp, + private val errorScaleType: ScaleType = ScaleType.CENTER +) : ImageViewTarget(view) { private var resource: Drawable? = null @@ -48,7 +46,7 @@ class StateImageViewTarget( view.scaleType = errorScaleType val vector = VectorDrawableCompat.create(view.context.resources, errorDrawableRes, null) - vector?.setTint(view.context.getResourceColor(android.R.attr.textColorSecondary)) + vector?.setTint(ContextCompat.getColor(view.context, com.google.android.material.R.color.material_on_background_disabled)) view.setImageDrawable(vector) } diff --git a/app/src/main/res/layout/download_item.xml b/app/src/main/res/layout/download_item.xml index 5e14a45b21..0cc41742e4 100644 --- a/app/src/main/res/layout/download_item.xml +++ b/app/src/main/res/layout/download_item.xml @@ -4,7 +4,6 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" - android:paddingStart="0dp" android:paddingTop="@dimen/material_component_lists_padding_above_list"> + android:textColor="?attr/colorOnPrimary" + android:textStyle="bold" /> diff --git a/app/src/main/res/layout/source_grid_item.xml b/app/src/main/res/layout/source_grid_item.xml index 3e53c2756d..7620e861c2 100644 --- a/app/src/main/res/layout/source_grid_item.xml +++ b/app/src/main/res/layout/source_grid_item.xml @@ -37,7 +37,7 @@ bold - - @@ -71,12 +67,8 @@ 12sp - - - - - - @@ -190,7 +174,8 @@