From d9ef6f8e3f8d224449bbba04e5225ec50fbf14d6 Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Wed, 23 Jun 2021 17:52:06 -0400 Subject: [PATCH] Updating style and logic for extension update/install button Not similar to upstream but almost similar to upstream --- .../tachiyomi/ui/extension/ExtensionHolder.kt | 15 +++-------- app/src/main/res/color/ext_bg_selector.xml | 5 ++++ .../res/color/ext_button_text_selector.xml | 6 +++++ .../main/res/drawable/button_text_state.xml | 26 ------------------- .../main/res/layout/extension_card_item.xml | 4 +-- app/src/main/res/values/styles.xml | 8 ++++++ 6 files changed, 24 insertions(+), 40 deletions(-) create mode 100644 app/src/main/res/color/ext_bg_selector.xml create mode 100644 app/src/main/res/color/ext_button_text_selector.xml delete mode 100644 app/src/main/res/drawable/button_text_state.xml diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionHolder.kt index a81a1fe74e..7721b26e8b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionHolder.kt @@ -3,7 +3,6 @@ package eu.kanade.tachiyomi.ui.extension import android.content.res.ColorStateList import android.graphics.Color import android.view.View -import androidx.core.content.ContextCompat import coil.clear import coil.load import eu.kanade.tachiyomi.R @@ -11,11 +10,10 @@ import eu.kanade.tachiyomi.extension.model.Extension import eu.kanade.tachiyomi.extension.model.InstallStep import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder import eu.kanade.tachiyomi.util.system.LocaleHelper -import eu.kanade.tachiyomi.util.system.getResourceColor -import eu.kanade.tachiyomi.util.view.resetStrokeColor import eu.kanade.tachiyomi.data.image.coil.CoverViewTarget import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.databinding.ExtensionCardItemBinding +import eu.kanade.tachiyomi.util.view.resetStrokeColor import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import java.util.Locale @@ -67,12 +65,9 @@ class ExtensionHolder(view: View, val adapter: ExtensionAdapter) : isClickable = true isActivated = false - setTextColor(ContextCompat.getColorStateList(context, R.drawable.button_text_state)) - backgroundTintList = ContextCompat.getColorStateList(context, android.R.color.transparent) - - resetStrokeColor() val extension = item.extension val installStep = item.installStep + strokeColor = ColorStateList.valueOf(Color.TRANSPARENT) if (installStep != null) { setText( when (installStep) { @@ -91,10 +86,6 @@ class ExtensionHolder(view: View, val adapter: ExtensionAdapter) : when { extension.hasUpdate -> { isActivated = true - backgroundTintList = ColorStateList.valueOf( - context.getResourceColor(R.attr.colorAccent) - ) - strokeColor = ColorStateList.valueOf(Color.TRANSPARENT) setText(R.string.update) } else -> { @@ -102,8 +93,10 @@ class ExtensionHolder(view: View, val adapter: ExtensionAdapter) : } } } else if (extension is Extension.Untrusted) { + resetStrokeColor() setText(R.string.trust) } else { + resetStrokeColor() setText(R.string.install) } } diff --git a/app/src/main/res/color/ext_bg_selector.xml b/app/src/main/res/color/ext_bg_selector.xml new file mode 100644 index 0000000000..1028d53c6c --- /dev/null +++ b/app/src/main/res/color/ext_bg_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/color/ext_button_text_selector.xml b/app/src/main/res/color/ext_button_text_selector.xml new file mode 100644 index 0000000000..c88aee4dec --- /dev/null +++ b/app/src/main/res/color/ext_button_text_selector.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/button_text_state.xml b/app/src/main/res/drawable/button_text_state.xml deleted file mode 100644 index 2ec49b4099..0000000000 --- a/app/src/main/res/drawable/button_text_state.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/extension_card_item.xml b/app/src/main/res/layout/extension_card_item.xml index 06c35db5bd..f041b165ce 100644 --- a/app/src/main/res/layout/extension_card_item.xml +++ b/app/src/main/res/layout/extension_card_item.xml @@ -80,18 +80,16 @@ diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index a43e5c1d33..842da20110 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -247,6 +247,14 @@ @color/fullRippleColor + + +