Using colorAccent attr instead of color in some places

This commit is contained in:
Jays2Kings 2021-04-09 15:49:08 -04:00
parent f7dd1211da
commit b9bf495ed6
18 changed files with 37 additions and 38 deletions

View File

@ -4,7 +4,6 @@ import android.app.PendingIntent
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat
import androidx.core.content.ContextCompat
import androidx.work.Constraints import androidx.work.Constraints
import androidx.work.CoroutineWorker import androidx.work.CoroutineWorker
import androidx.work.ExistingPeriodicWorkPolicy import androidx.work.ExistingPeriodicWorkPolicy
@ -14,6 +13,7 @@ import androidx.work.WorkManager
import androidx.work.WorkerParameters import androidx.work.WorkerParameters
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.notification.Notifications import eu.kanade.tachiyomi.data.notification.Notifications
import eu.kanade.tachiyomi.util.system.getResourceColor
import eu.kanade.tachiyomi.util.system.notificationManager import eu.kanade.tachiyomi.util.system.notificationManager
import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.coroutineScope
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
@ -38,7 +38,7 @@ class UpdaterJob(private val context: Context, workerParams: WorkerParameters) :
setContentTitle(context.getString(R.string.app_name)) setContentTitle(context.getString(R.string.app_name))
setContentText(context.getString(R.string.update_available)) setContentText(context.getString(R.string.update_available))
setSmallIcon(android.R.drawable.stat_sys_download_done) setSmallIcon(android.R.drawable.stat_sys_download_done)
color = ContextCompat.getColor(context, R.color.colorAccent) color = context.getResourceColor(R.attr.colorAccent)
// Download action // Download action
addAction( addAction(
android.R.drawable.stat_sys_download_done, android.R.drawable.stat_sys_download_done,

View File

@ -26,7 +26,6 @@ import eu.kanade.tachiyomi.util.view.invisible
import eu.kanade.tachiyomi.util.view.isVisible import eu.kanade.tachiyomi.util.view.isVisible
import eu.kanade.tachiyomi.util.view.setBottomEdge import eu.kanade.tachiyomi.util.view.setBottomEdge
import eu.kanade.tachiyomi.util.view.setEdgeToEdge 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.updateLayoutParams
import eu.kanade.tachiyomi.util.view.visible import eu.kanade.tachiyomi.util.view.visible
import eu.kanade.tachiyomi.util.view.visibleIf import eu.kanade.tachiyomi.util.view.visibleIf
@ -88,9 +87,9 @@ open class MaterialMenuSheet(
} }
if (item.id == selectedId) { if (item.id == selectedId) {
currentIndex = index currentIndex = index
setTextColorRes(R.color.colorAccent) setTextColor(context.getResourceColor(R.attr.colorAccent))
compoundDrawableTintList = compoundDrawableTintList =
ColorStateList.valueOf(context.getColor(R.color.colorAccent)) ColorStateList.valueOf(context.getResourceColor(R.attr.colorAccent))
} }
updateLayoutParams<ViewGroup.MarginLayoutParams> { updateLayoutParams<ViewGroup.MarginLayoutParams> {
height = 48.dpToPx height = 48.dpToPx
@ -156,9 +155,9 @@ open class MaterialMenuSheet(
val layout = binding.menuLayout.findViewById<ViewGroup>(id) ?: return val layout = binding.menuLayout.findViewById<ViewGroup>(id) ?: return
val textView = layout.getChildAt(0) as? TextView val textView = layout.getChildAt(0) as? TextView
val imageView = layout.getChildAt(1) as? ImageView val imageView = layout.getChildAt(1) as? ImageView
textView?.setTextColorRes(R.color.colorAccent) textView?.setTextColor(context.getResourceColor(R.attr.colorAccent))
textView?.compoundDrawableTintList = textView?.compoundDrawableTintList =
ColorStateList.valueOf(context.getColor(R.color.colorAccent)) ColorStateList.valueOf(context.getResourceColor(R.attr.colorAccent))
imageView?.visible() imageView?.visible()
imageView?.setImageResource(drawableRes) imageView?.setImageResource(drawableRes)
} }

View File

@ -263,11 +263,8 @@ class LibraryHeaderHolder(val view: View, private val adapter: LibraryCategoryAd
) )
val tintedDrawable = drawable?.mutate() val tintedDrawable = drawable?.mutate()
tintedDrawable?.setTint( tintedDrawable?.setTint(
ContextCompat.getColor( if (allSelected) contentView.context.getResourceColor(R.attr.colorAccent)
contentView.context, else ContextCompat.getColor(contentView.context, R.color.gray_button)
if (allSelected) R.color.colorAccent
else R.color.gray_button
)
) )
binding.checkbox.setImageDrawable(tintedDrawable) binding.checkbox.setImageDrawable(tintedDrawable)
} }

View File

@ -401,7 +401,7 @@ open class MainActivity : BaseActivity<MainActivityBinding>(), DownloadServiceLi
recentsItem, recentsItem,
getString(R.string.manage_whats_downloading), getString(R.string.manage_whats_downloading),
getString(R.string.visit_recents_for_download_queue) 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) .titleTextColor(android.R.color.white).descriptionTextSize(16)
.descriptionTextColor(R.color.md_white_1000_76) .descriptionTextColor(R.color.md_white_1000_76)
.icon(contextCompatDrawable(R.drawable.ic_recent_read_32dp)) .icon(contextCompatDrawable(R.drawable.ic_recent_read_32dp))

View File

@ -1,12 +1,12 @@
package eu.kanade.tachiyomi.ui.setting.search package eu.kanade.tachiyomi.ui.setting.search
import android.view.View import android.view.View
import androidx.core.content.ContextCompat
import androidx.core.graphics.ColorUtils import androidx.core.graphics.ColorUtils
import eu.davidea.viewholders.FlexibleViewHolder import eu.davidea.viewholders.FlexibleViewHolder
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.databinding.SettingsSearchControllerCardBinding import eu.kanade.tachiyomi.databinding.SettingsSearchControllerCardBinding
import eu.kanade.tachiyomi.util.lang.highlightText import eu.kanade.tachiyomi.util.lang.highlightText
import eu.kanade.tachiyomi.util.system.getResourceColor
import kotlin.reflect.full.createInstance import kotlin.reflect.full.createInstance
/** /**
@ -37,7 +37,7 @@ class SettingsSearchHolder(view: View, val adapter: SettingsSearchAdapter) :
* @param item item of card. * @param item item of card.
*/ */
fun bind(item: SettingsSearchItem) { 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.searchResultPrefTitle.text = item.settingsSearchResult.title.highlightText(item.searchResult, color)
binding.searchResultPrefSummary.text = item.settingsSearchResult.summary.highlightText(item.searchResult, color) binding.searchResultPrefSummary.text = item.settingsSearchResult.summary.highlightText(item.searchResult, color)
binding.searchResultPrefBreadcrumb.text = item.settingsSearchResult.breadcrumb.highlightText(item.searchResult, color) binding.searchResultPrefBreadcrumb.text = item.settingsSearchResult.breadcrumb.highlightText(item.searchResult, color)

View File

@ -5,7 +5,7 @@
Ensures visibility on top of the background color. Ensures visibility on top of the background color.
--> -->
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/colorAccentText" android:state_selected="true"/> <item android:color="?colorAccentText" android:state_selected="true"/>
<item android:color="@color/colorAccent" android:state_pressed="true"/> <item android:color="?colorAccent" android:state_pressed="true"/>
<item android:alpha="0.60" android:color="?attr/actionBarTintColor"/> <item android:alpha="0.60" android:color="?attr/actionBarTintColor"/>
</selector> </selector>

View File

@ -15,8 +15,8 @@
<padding android:left="8dp" android:right="8dp" /> <padding android:left="8dp" android:right="8dp" />
</shape> </shape>
</item> </item>
<item android:color="@color/colorAccent"> <item android:color="?colorAccent">
<shape android:shape="rectangle" android:color="@color/colorAccent"> <shape android:shape="rectangle" android:color="?colorAccent">
<corners android:radius="2dp" /> <corners android:radius="2dp" />
<solid android:color="@android:color/transparent" /> <solid android:color="@android:color/transparent" />
<stroke android:color="?attr/colorAccent" android:width="1dp"/> <stroke android:color="?attr/colorAccent" android:width="1dp"/>

View File

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android" <ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/colorAccent"> android:color="?colorAccent">
<item android:id="@android:id/mask"> <item android:id="@android:id/mask">
<shape android:shape="rectangle"> <shape android:shape="rectangle">
<solid android:color="@color/colorAccent" /> <solid android:color="?colorAccent" />
<corners android:radius="30dp" /> <corners android:radius="30dp" />
</shape> </shape>
</item> </item>
@ -24,7 +24,7 @@
<size <size
android:width="32dp" android:width="32dp"
android:height="32dp" /> android:height="32dp" />
<solid android:color="@color/colorAccent" /> <solid android:color="?colorAccent" />
</shape> </shape>
</item> </item>
</selector> </selector>

View File

@ -13,10 +13,10 @@
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:layout_marginEnd="16dp" android:layout_marginEnd="16dp"
android:hint="@string/title" android:hint="@string/title"
app:boxStrokeColor="@color/colorAccent" app:boxStrokeColor="?colorAccent"
app:endIconMode="clear_text" app:endIconMode="clear_text"
app:hintEnabled="false" app:hintEnabled="false"
app:hintTextColor="@color/colorAccent"> app:hintTextColor="?colorAccent">
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
android:id="@+id/title" android:id="@+id/title"

View File

@ -305,9 +305,9 @@
android:layout_marginEnd="16dp" android:layout_marginEnd="16dp"
android:visibility="gone" android:visibility="gone"
app:atg_backgroundColor="@android:color/transparent" app:atg_backgroundColor="@android:color/transparent"
app:atg_borderColor="@color/colorAccent" app:atg_borderColor="?colorAccent"
app:atg_borderStrokeWidth="1dp" app:atg_borderStrokeWidth="1dp"
app:atg_textColor="@color/colorAccent" app:atg_textColor="?colorAccent"
app:layout_constrainedHeight="true" app:layout_constrainedHeight="true"
app:layout_constraintBottom_toTopOf="@id/less_button" app:layout_constraintBottom_toTopOf="@id/less_button"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"

View File

@ -3,6 +3,7 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="42dp" android:layout_height="42dp"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
@ -28,7 +29,7 @@
android:layout_height="42dp" android:layout_height="42dp"
android:paddingStart="8dp" android:paddingStart="8dp"
android:paddingEnd="8dp" android:paddingEnd="8dp"
android:tint="@color/colorAccent" app:tint="?colorAccent"
android:visibility="invisible" android:visibility="invisible"
tools:visibility="visible" tools:visibility="visible"
android:src="@drawable/ic_arrow_upward_24dp" /> android:src="@drawable/ic_arrow_upward_24dp" />

View File

@ -38,9 +38,9 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:hint="@string/password" android:hint="@string/password"
app:boxStrokeColor="@color/colorAccent" app:boxStrokeColor="?colorAccent"
app:endIconMode="password_toggle" app:endIconMode="password_toggle"
app:hintTextColor="@color/colorAccent"> app:hintTextColor="?colorAccent">
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
android:id="@+id/password" android:id="@+id/password"

View File

@ -14,7 +14,7 @@
android:id="@+id/category_hopper_layout" android:id="@+id/category_hopper_layout"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/colorAccent" android:background="?colorAccent"
android:clickable="true" android:clickable="true"
android:focusable="true"> android:focusable="true">

View File

@ -58,7 +58,7 @@
android:layout_height="0dp" android:layout_height="0dp"
android:layout_marginEnd="16dp" android:layout_marginEnd="16dp"
app:icon="@drawable/ic_plus_24dp" app:icon="@drawable/ic_plus_24dp"
app:iconTint="@color/colorAccent" app:iconTint="?colorAccent"
style="@style/Theme.Widget.Button.TextButton" style="@style/Theme.Widget.Button.TextButton"
android:text="@string/new_category" android:text="@string/new_category"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
@ -112,7 +112,7 @@
android:layout_marginStart="48dp" android:layout_marginStart="48dp"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:text="@string/new_category" android:text="@string/new_category"
app:iconTint="@color/colorAccent" app:iconTint="?colorAccent"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/cancel_button" app:layout_constraintStart_toEndOf="@id/cancel_button"

View File

@ -13,10 +13,10 @@
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:layout_marginEnd="16dp" android:layout_marginEnd="16dp"
android:hint="@string/title" android:hint="@string/title"
app:boxStrokeColor="@color/colorAccent" app:boxStrokeColor="?colorAccent"
app:endIconMode="clear_text" app:endIconMode="clear_text"
app:hintEnabled="false" app:hintEnabled="false"
app:hintTextColor="@color/colorAccent"> app:hintTextColor="?colorAccent">
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
android:id="@+id/track_search" android:id="@+id/track_search"

View File

@ -48,7 +48,7 @@
style="?android:attr/progressBarStyleHorizontal" style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="2dp" android:layout_height="2dp"
android:progressTint="@color/colorAccent" android:progressTint="?colorAccent"
android:progressBackgroundTint="@color/colorPrimary" android:progressBackgroundTint="@color/colorPrimary"
/> />
</WebView> </WebView>

View File

@ -13,9 +13,10 @@
<attr name="actionBarTintColor" format="color"/> <attr name="actionBarTintColor" format="color"/>
<attr name="readerBackground" format="color"/> <attr name="readerBackground" format="color"/>
<attr name="colorAccentText" format="color"/>
<attr name="tabBarIconColor" format="reference|integer"/> <attr name="tabBarIconColor" format="reference|integer"/>
<attr name="tabBarIconInactive" format="reference|integer"/> <attr name="tabBarIconInactive" format="reference|integer"/>
<attr name="tabHighlightBackground" format="reference|integer"/> <attr name="tabHighlightBackground" format="color"/>
<declare-styleable name="ReaderSpinnerView"> <declare-styleable name="ReaderSpinnerView">
<attr name="title" format="reference|string"/> <attr name="title" format="reference|string"/>

View File

@ -14,8 +14,9 @@
<item name="colorPrimaryVariant">@color/colorPrimary</item> <item name="colorPrimaryVariant">@color/colorPrimary</item>
<item name="colorSecondary">@color/background</item> <item name="colorSecondary">@color/background</item>
<item name="colorPrimaryDark">@color/app_color_primary</item> <item name="colorPrimaryDark">@color/app_color_primary</item>
<item name="colorControlActivated">@color/colorAccent</item>
<item name="colorAccent">@color/colorAccent</item> <item name="colorAccent">@color/colorAccent</item>
<item name="colorAccentText">@color/colorAccentText</item>
<item name="colorControlActivated">?colorAccent</item>
<item name="android:textColorPrimary">@color/textColorPrimary</item> <item name="android:textColorPrimary">@color/textColorPrimary</item>
<item name="android:textColorSecondary">@color/text_color_secondary</item> <item name="android:textColorSecondary">@color/text_color_secondary</item>
<item name="android:textColorHint">@color/text_color_hint</item> <item name="android:textColorHint">@color/text_color_hint</item>
@ -46,7 +47,7 @@
<!-- Material Dialog colors --> <!-- Material Dialog colors -->
<item name="md_color_title">@color/textColorPrimary</item> <item name="md_color_title">@color/textColorPrimary</item>
<item name="md_color_content">@color/text_color_secondary</item> <item name="md_color_content">@color/text_color_secondary</item>
<item name="md_color_button_text">@color/colorAccent</item> <item name="md_color_button_text">?colorAccent</item>
<item name="md_background_color">@color/dialog</item> <item name="md_background_color">@color/dialog</item>
<item name="md_button_casing">literal</item> <item name="md_button_casing">literal</item>
<item name="md_corner_radius">16dp</item> <item name="md_corner_radius">16dp</item>