From b9bf495ed6953518a7c0506abcc0fee902ac3253 Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Fri, 9 Apr 2021 15:49:08 -0400 Subject: [PATCH] Using colorAccent attr instead of color in some places --- .../java/eu/kanade/tachiyomi/data/updater/UpdaterJob.kt | 4 ++-- .../eu/kanade/tachiyomi/ui/base/MaterialMenuSheet.kt | 9 ++++----- .../kanade/tachiyomi/ui/library/LibraryHeaderHolder.kt | 7 ++----- .../java/eu/kanade/tachiyomi/ui/main/MainActivity.kt | 2 +- .../tachiyomi/ui/setting/search/SettingsSearchHolder.kt | 4 ++-- app/src/main/res/color/tabs_selector_alt.xml | 4 ++-- app/src/main/res/drawable/button_text_state.xml | 4 ++-- app/src/main/res/drawable/oval_ripple.xml | 6 +++--- app/src/main/res/layout/manga_category_dialog.xml | 4 ++-- app/src/main/res/layout/manga_header_item.xml | 4 ++-- app/src/main/res/layout/menu_sheet_item.xml | 3 ++- app/src/main/res/layout/pref_account_login.xml | 4 ++-- app/src/main/res/layout/rounded_category_hopper.xml | 2 +- app/src/main/res/layout/set_categories_sheet.xml | 4 ++-- app/src/main/res/layout/track_search_dialog.xml | 4 ++-- app/src/main/res/layout/webview_activity.xml | 2 +- app/src/main/res/values/attrs.xml | 3 ++- app/src/main/res/values/themes.xml | 5 +++-- 18 files changed, 37 insertions(+), 38 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/updater/UpdaterJob.kt b/app/src/main/java/eu/kanade/tachiyomi/data/updater/UpdaterJob.kt index f6a16fbe5f..868c1fb752 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/updater/UpdaterJob.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/updater/UpdaterJob.kt @@ -4,7 +4,6 @@ import android.app.PendingIntent import android.content.Context import android.content.Intent import androidx.core.app.NotificationCompat -import androidx.core.content.ContextCompat import androidx.work.Constraints import androidx.work.CoroutineWorker import androidx.work.ExistingPeriodicWorkPolicy @@ -14,6 +13,7 @@ import androidx.work.WorkManager import androidx.work.WorkerParameters import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.notification.Notifications +import eu.kanade.tachiyomi.util.system.getResourceColor import eu.kanade.tachiyomi.util.system.notificationManager import kotlinx.coroutines.coroutineScope import java.util.concurrent.TimeUnit @@ -38,7 +38,7 @@ class UpdaterJob(private val context: Context, workerParams: WorkerParameters) : setContentTitle(context.getString(R.string.app_name)) setContentText(context.getString(R.string.update_available)) setSmallIcon(android.R.drawable.stat_sys_download_done) - color = ContextCompat.getColor(context, R.color.colorAccent) + color = context.getResourceColor(R.attr.colorAccent) // Download action addAction( android.R.drawable.stat_sys_download_done, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/MaterialMenuSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/MaterialMenuSheet.kt index 46b24eb6a3..109ac4cbd5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/MaterialMenuSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/MaterialMenuSheet.kt @@ -26,7 +26,6 @@ import eu.kanade.tachiyomi.util.view.invisible import eu.kanade.tachiyomi.util.view.isVisible import eu.kanade.tachiyomi.util.view.setBottomEdge import eu.kanade.tachiyomi.util.view.setEdgeToEdge -import eu.kanade.tachiyomi.util.view.setTextColorRes import eu.kanade.tachiyomi.util.view.updateLayoutParams import eu.kanade.tachiyomi.util.view.visible import eu.kanade.tachiyomi.util.view.visibleIf @@ -88,9 +87,9 @@ open class MaterialMenuSheet( } if (item.id == selectedId) { currentIndex = index - setTextColorRes(R.color.colorAccent) + setTextColor(context.getResourceColor(R.attr.colorAccent)) compoundDrawableTintList = - ColorStateList.valueOf(context.getColor(R.color.colorAccent)) + ColorStateList.valueOf(context.getResourceColor(R.attr.colorAccent)) } updateLayoutParams { height = 48.dpToPx @@ -156,9 +155,9 @@ open class MaterialMenuSheet( val layout = binding.menuLayout.findViewById(id) ?: return val textView = layout.getChildAt(0) as? TextView val imageView = layout.getChildAt(1) as? ImageView - textView?.setTextColorRes(R.color.colorAccent) + textView?.setTextColor(context.getResourceColor(R.attr.colorAccent)) textView?.compoundDrawableTintList = - ColorStateList.valueOf(context.getColor(R.color.colorAccent)) + ColorStateList.valueOf(context.getResourceColor(R.attr.colorAccent)) imageView?.visible() imageView?.setImageResource(drawableRes) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryHeaderHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryHeaderHolder.kt index a42b4becb2..711aa6fdba 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryHeaderHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryHeaderHolder.kt @@ -263,11 +263,8 @@ class LibraryHeaderHolder(val view: View, private val adapter: LibraryCategoryAd ) val tintedDrawable = drawable?.mutate() tintedDrawable?.setTint( - ContextCompat.getColor( - contentView.context, - if (allSelected) R.color.colorAccent - else R.color.gray_button - ) + if (allSelected) contentView.context.getResourceColor(R.attr.colorAccent) + else ContextCompat.getColor(contentView.context, R.color.gray_button) ) binding.checkbox.setImageDrawable(tintedDrawable) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index dd1b6d385b..82531cd8be 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -401,7 +401,7 @@ open class MainActivity : BaseActivity(), DownloadServiceLi recentsItem, getString(R.string.manage_whats_downloading), getString(R.string.visit_recents_for_download_queue) - ).outerCircleColor(R.color.colorAccent).outerCircleAlpha(0.95f).titleTextSize(20) + ).outerCircleColor(getResourceColor(R.attr.colorAccent)).outerCircleAlpha(0.95f).titleTextSize(20) .titleTextColor(android.R.color.white).descriptionTextSize(16) .descriptionTextColor(R.color.md_white_1000_76) .icon(contextCompatDrawable(R.drawable.ic_recent_read_32dp)) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/search/SettingsSearchHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/search/SettingsSearchHolder.kt index 5d64608a7a..b5449ecd04 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/search/SettingsSearchHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/search/SettingsSearchHolder.kt @@ -1,12 +1,12 @@ package eu.kanade.tachiyomi.ui.setting.search import android.view.View -import androidx.core.content.ContextCompat import androidx.core.graphics.ColorUtils import eu.davidea.viewholders.FlexibleViewHolder import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.databinding.SettingsSearchControllerCardBinding import eu.kanade.tachiyomi.util.lang.highlightText +import eu.kanade.tachiyomi.util.system.getResourceColor import kotlin.reflect.full.createInstance /** @@ -37,7 +37,7 @@ class SettingsSearchHolder(view: View, val adapter: SettingsSearchAdapter) : * @param item item of card. */ fun bind(item: SettingsSearchItem) { - val color = ColorUtils.setAlphaComponent(ContextCompat.getColor(itemView.context, R.color.colorAccent), 75) + val color = ColorUtils.setAlphaComponent(itemView.context.getResourceColor(R.attr.colorAccent), 75) binding.searchResultPrefTitle.text = item.settingsSearchResult.title.highlightText(item.searchResult, color) binding.searchResultPrefSummary.text = item.settingsSearchResult.summary.highlightText(item.searchResult, color) binding.searchResultPrefBreadcrumb.text = item.settingsSearchResult.breadcrumb.highlightText(item.searchResult, color) diff --git a/app/src/main/res/color/tabs_selector_alt.xml b/app/src/main/res/color/tabs_selector_alt.xml index 2c58c7ee23..0346c464e3 100644 --- a/app/src/main/res/color/tabs_selector_alt.xml +++ b/app/src/main/res/color/tabs_selector_alt.xml @@ -5,7 +5,7 @@ Ensures visibility on top of the background color. --> - - + + diff --git a/app/src/main/res/drawable/button_text_state.xml b/app/src/main/res/drawable/button_text_state.xml index 481da7dfde..d476414a3a 100644 --- a/app/src/main/res/drawable/button_text_state.xml +++ b/app/src/main/res/drawable/button_text_state.xml @@ -15,8 +15,8 @@ - - + + diff --git a/app/src/main/res/drawable/oval_ripple.xml b/app/src/main/res/drawable/oval_ripple.xml index 4f48db0d13..83003bbb21 100644 --- a/app/src/main/res/drawable/oval_ripple.xml +++ b/app/src/main/res/drawable/oval_ripple.xml @@ -1,9 +1,9 @@ + android:color="?colorAccent"> - + @@ -24,7 +24,7 @@ - + diff --git a/app/src/main/res/layout/manga_category_dialog.xml b/app/src/main/res/layout/manga_category_dialog.xml index d71b03bbdc..47d6947a30 100644 --- a/app/src/main/res/layout/manga_category_dialog.xml +++ b/app/src/main/res/layout/manga_category_dialog.xml @@ -13,10 +13,10 @@ android:layout_marginStart="16dp" android:layout_marginEnd="16dp" android:hint="@string/title" - app:boxStrokeColor="@color/colorAccent" + app:boxStrokeColor="?colorAccent" app:endIconMode="clear_text" app:hintEnabled="false" - app:hintTextColor="@color/colorAccent"> + app:hintTextColor="?colorAccent"> diff --git a/app/src/main/res/layout/pref_account_login.xml b/app/src/main/res/layout/pref_account_login.xml index 9157f75fa7..ef77400bae 100644 --- a/app/src/main/res/layout/pref_account_login.xml +++ b/app/src/main/res/layout/pref_account_login.xml @@ -38,9 +38,9 @@ android:layout_height="wrap_content" android:layout_marginTop="12dp" android:hint="@string/password" - app:boxStrokeColor="@color/colorAccent" + app:boxStrokeColor="?colorAccent" app:endIconMode="password_toggle" - app:hintTextColor="@color/colorAccent"> + app:hintTextColor="?colorAccent"> diff --git a/app/src/main/res/layout/set_categories_sheet.xml b/app/src/main/res/layout/set_categories_sheet.xml index 4e18ba52e1..30c551f75b 100644 --- a/app/src/main/res/layout/set_categories_sheet.xml +++ b/app/src/main/res/layout/set_categories_sheet.xml @@ -58,7 +58,7 @@ android:layout_height="0dp" android:layout_marginEnd="16dp" app:icon="@drawable/ic_plus_24dp" - app:iconTint="@color/colorAccent" + app:iconTint="?colorAccent" style="@style/Theme.Widget.Button.TextButton" android:text="@string/new_category" app:layout_constraintBottom_toBottomOf="parent" @@ -112,7 +112,7 @@ android:layout_marginStart="48dp" android:layout_marginEnd="8dp" android:text="@string/new_category" - app:iconTint="@color/colorAccent" + app:iconTint="?colorAccent" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toEndOf="@id/cancel_button" diff --git a/app/src/main/res/layout/track_search_dialog.xml b/app/src/main/res/layout/track_search_dialog.xml index f7a4e433a0..edfa03b631 100644 --- a/app/src/main/res/layout/track_search_dialog.xml +++ b/app/src/main/res/layout/track_search_dialog.xml @@ -13,10 +13,10 @@ android:layout_marginStart="16dp" android:layout_marginEnd="16dp" android:hint="@string/title" - app:boxStrokeColor="@color/colorAccent" + app:boxStrokeColor="?colorAccent" app:endIconMode="clear_text" app:hintEnabled="false" - app:hintTextColor="@color/colorAccent"> + app:hintTextColor="?colorAccent"> diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index 41c31a5a73..a26aafca53 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -13,9 +13,10 @@ + - + diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 87825feec3..0b5a48f87d 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -14,8 +14,9 @@ @color/colorPrimary @color/background @color/app_color_primary - @color/colorAccent @color/colorAccent + @color/colorAccentText + ?colorAccent @color/textColorPrimary @color/text_color_secondary @color/text_color_hint @@ -46,7 +47,7 @@ @color/textColorPrimary @color/text_color_secondary - @color/colorAccent + ?colorAccent @color/dialog literal 16dp