From 0a509cb382611fe86cd99f11f024c3487eeaebe9 Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 26 Apr 2020 17:24:31 -0400 Subject: [PATCH] Remove usage of alpha color selectors (fixes #2957) Doesn't work properly in API < 23 --- .../ui/manga/chapter/ChaptersAdapter.kt | 3 +-- .../ui/recent/updates/UpdatesHolder.kt | 3 +-- .../ui/source/browse/SourceListHolder.kt | 3 +-- .../ui/source/filter/TriStateItem.kt | 3 +-- .../util/system/ContextExtensions.kt | 19 ++++++++++++++++--- .../tachiyomi/widget/StateImageViewTarget.kt | 4 ++-- 6 files changed, 22 insertions(+), 13 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 dd0fa66d84..9e696fc4f5 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,7 +1,6 @@ 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 @@ -21,7 +20,7 @@ class ChaptersAdapter( var items: List = emptyList() - val readColor = ContextCompat.getColor(context, R.color.material_on_surface_disabled) + val readColor = context.getResourceColor(R.attr.colorOnSurface, 0.38f) 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 6452278c72..08a4015f12 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,7 +1,6 @@ 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 @@ -27,7 +26,7 @@ import kotlinx.android.synthetic.main.updates_item.manga_title class UpdatesHolder(private val view: View, private val adapter: UpdatesAdapter) : BaseFlexibleViewHolder(view, adapter) { - private var readColor = ContextCompat.getColor(view.context, R.color.material_on_surface_disabled) + private var readColor = view.context.getResourceColor(R.attr.colorOnSurface, 0.38f) private var unreadColor = view.context.getResourceColor(R.attr.colorOnSurface) /** 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 7d803316c7..23ff9c6642 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,7 +1,6 @@ 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 @@ -23,7 +22,7 @@ import kotlinx.android.synthetic.main.source_list_item.title class SourceListHolder(private val view: View, adapter: FlexibleAdapter<*>) : SourceHolder(view, adapter) { - private val favoriteColor = ContextCompat.getColor(view.context, R.color.material_on_surface_disabled) + private val favoriteColor = view.context.getResourceColor(R.attr.colorOnSurface, 0.38f) private val unfavoriteColor = view.context.getResourceColor(R.attr.colorOnSurface) /** 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 1237b0329e..529fa935e2 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,7 +2,6 @@ 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 @@ -46,7 +45,7 @@ open class TriStateItem(val filter: Filter.TriState) : AbstractFlexibleItem