diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSearchAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSearchAdapter.kt
index 4ce598e457..c346e7d7e7 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSearchAdapter.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSearchAdapter.kt
@@ -35,7 +35,7 @@ class TrackSearchAdapter(
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TrackSearchHolder {
val binding = TrackSearchItemBinding.inflate(LayoutInflater.from(parent.context), parent, false)
- binding.container.applyElevationOverlay()
+ binding.root.applyElevationOverlay()
return TrackSearchHolder(binding, this)
}
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSearchHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSearchHolder.kt
index 9526f60836..c7d253aa18 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSearchHolder.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSearchHolder.kt
@@ -15,10 +15,10 @@ class TrackSearchHolder(
private val adapter: TrackSearchAdapter
) : RecyclerView.ViewHolder(binding.root) {
fun bind(track: TrackSearch, position: Int) {
- binding.container.isChecked = position == adapter.selectedItemPosition
- binding.container.setOnClickListener {
+ binding.root.isChecked = position == adapter.selectedItemPosition
+ binding.root.setOnClickListener {
adapter.selectedItemPosition = position
- binding.container.isChecked = true
+ binding.root.isChecked = true
}
binding.trackSearchTitle.text = track.title
@@ -62,6 +62,6 @@ class TrackSearchHolder(
}
fun setUnchecked() {
- binding.container.isChecked = false
+ binding.root.isChecked = false
}
}
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsTrackingController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsTrackingController.kt
index 1305dab490..894e8b3cad 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsTrackingController.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsTrackingController.kt
@@ -28,7 +28,7 @@ import eu.kanade.tachiyomi.util.preference.switchPreference
import eu.kanade.tachiyomi.util.preference.titleRes
import eu.kanade.tachiyomi.util.system.openInBrowser
import eu.kanade.tachiyomi.util.system.toast
-import eu.kanade.tachiyomi.widget.preference.LoginPreference
+import eu.kanade.tachiyomi.widget.preference.TrackerPreference
import uy.kohesive.injekt.injectLazy
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
@@ -96,12 +96,13 @@ class SettingsTrackingController :
private inline fun PreferenceGroup.trackPreference(
service: TrackService,
crossinline login: () -> Unit
- ): LoginPreference {
+ ): TrackerPreference {
return add(
- LoginPreference(context).apply {
+ TrackerPreference(context).apply {
key = Keys.trackUsername(service.id)
titleRes = service.nameRes()
iconRes = service.getLogo()
+ iconColor = service.getLogoColor()
onClick {
if (service.isLogged) {
if (service is NoLoginTrackService) {
@@ -142,7 +143,7 @@ class SettingsTrackingController :
}
private fun updatePreference(id: Int) {
- val pref = findPreference(Keys.trackUsername(id)) as? LoginPreference
+ val pref = findPreference(Keys.trackUsername(id)) as? TrackerPreference
pref?.notifyChanged()
}
diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/preference/LoginPreference.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/preference/LoginPreference.kt
deleted file mode 100644
index eea07d9775..0000000000
--- a/app/src/main/java/eu/kanade/tachiyomi/widget/preference/LoginPreference.kt
+++ /dev/null
@@ -1,32 +0,0 @@
-package eu.kanade.tachiyomi.widget.preference
-
-import android.content.Context
-import android.util.AttributeSet
-import android.widget.ImageView
-import androidx.preference.Preference
-import androidx.preference.PreferenceViewHolder
-import eu.kanade.tachiyomi.R
-
-class LoginPreference @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
- Preference(context, attrs) {
-
- init {
- widgetLayoutResource = R.layout.pref_widget_imageview
- }
-
- override fun onBindViewHolder(holder: PreferenceViewHolder) {
- super.onBindViewHolder(holder)
-
- (holder.findViewById(R.id.image_view) as ImageView).setImageResource(
- if (getPersistedString("").isNullOrEmpty()) {
- android.R.color.transparent
- } else {
- R.drawable.ic_done_green_24dp
- }
- )
- }
-
- public override fun notifyChanged() {
- super.notifyChanged()
- }
-}
diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/preference/TrackerPreference.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/preference/TrackerPreference.kt
new file mode 100644
index 0000000000..2077744b99
--- /dev/null
+++ b/app/src/main/java/eu/kanade/tachiyomi/widget/preference/TrackerPreference.kt
@@ -0,0 +1,41 @@
+package eu.kanade.tachiyomi.widget.preference
+
+import android.content.Context
+import android.graphics.Color
+import android.util.AttributeSet
+import android.widget.ImageView
+import androidx.annotation.ColorInt
+import androidx.core.view.isVisible
+import androidx.preference.Preference
+import androidx.preference.PreferenceViewHolder
+import com.google.android.material.card.MaterialCardView
+import eu.kanade.tachiyomi.R
+
+class TrackerPreference @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
+ Preference(context, attrs) {
+
+ init {
+ layoutResource = R.layout.pref_tracker_item
+ }
+
+ override fun onBindViewHolder(holder: PreferenceViewHolder) {
+ super.onBindViewHolder(holder)
+
+ val logoContainer = holder.findViewById(R.id.logo_container) as MaterialCardView
+ val checkedIcon = holder.findViewById(R.id.checked_icon) as ImageView
+
+ logoContainer.setCardBackgroundColor(iconColor)
+ checkedIcon.isVisible = !getPersistedString("").isNullOrEmpty()
+ }
+
+ @ColorInt
+ var iconColor: Int = Color.TRANSPARENT
+ set(value) {
+ field = value
+ notifyChanged()
+ }
+
+ public override fun notifyChanged() {
+ super.notifyChanged()
+ }
+}
diff --git a/app/src/main/res/layout/pref_tracker_item.xml b/app/src/main/res/layout/pref_tracker_item.xml
new file mode 100644
index 0000000000..c740adb6c1
--- /dev/null
+++ b/app/src/main/res/layout/pref_tracker_item.xml
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/pref_widget_imageview.xml b/app/src/main/res/layout/pref_widget_imageview.xml
deleted file mode 100644
index f6d664ebce..0000000000
--- a/app/src/main/res/layout/pref_widget_imageview.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
diff --git a/app/src/main/res/layout/track_search_item.xml b/app/src/main/res/layout/track_search_item.xml
index 86127b5e41..1c611394a7 100644
--- a/app/src/main/res/layout/track_search_item.xml
+++ b/app/src/main/res/layout/track_search_item.xml
@@ -2,7 +2,6 @@