Updating style and logic for extension update/install button

Not similar to upstream but almost similar to upstream
This commit is contained in:
Jays2Kings 2021-06-23 17:52:06 -04:00
parent 3f1869cab6
commit d9ef6f8e3f
6 changed files with 24 additions and 40 deletions

View File

@ -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)
}
}

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_activated="true" android:color="?colorAccent" />
<item android:state_activated="false" android:color="@android:color/transparent" />
</selector>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_activated="true" android:color="?colorOnAccent"/>
<item android:state_enabled="false" android:color="@color/text_color_hint"/>
<item android:color="?colorAccent"/>
</selector>

View File

@ -1,26 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_activated="true" android:color="?colorOnAccent">
<shape android:shape="rectangle">
<corners android:radius="2dp" />
<solid android:color="?attr/colorAccent" />
<padding android:left="8dp" android:right="8dp" />
</shape>
</item>
<item android:state_enabled="false" android:color="@color/text_color_hint">
<shape android:shape="rectangle">
<corners android:radius="2dp" />
<solid android:color="@android:color/transparent" />
<stroke android:color="@color/text_color_hint" android:width="1dp"/>
<padding android:left="8dp" android:right="8dp" />
</shape>
</item>
<item android:color="?colorAccent">
<shape android:shape="rectangle" android:color="?colorAccent">
<corners android:radius="2dp" />
<solid android:color="@android:color/transparent" />
<stroke android:color="?attr/colorAccent" android:width="1dp"/>
<padding android:left="8dp" android:right="8dp" />
</shape>
</item>
</selector>

View File

@ -80,18 +80,16 @@
<com.google.android.material.button.MaterialButton
android:id="@+id/ext_button"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
style="@style/Theme.Widget.Button.OutlinedButtonAccent"
android:textAllCaps="false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:textColor="@drawable/button_text_state"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:rippleColor="@color/fullRippleColor"
tools:text="Details" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -247,6 +247,14 @@
<item name="rippleColor">@color/fullRippleColor</item>
</style>
<style name="Theme.Widget.Button.OutlinedButtonAccent" parent="Widget.MaterialComponents.Button.OutlinedButton">
<item name="strokeColor">@android:color/transparent</item>
<item name="backgroundTint">@color/ext_bg_selector</item>
<item name="android:textColor">@color/ext_button_text_selector</item>
<item name="rippleColor">@color/fullRippleColor</item>
</style>
<style name="Theme.Widget.Button.Borderless.Small">
<item name="android:minHeight">48dip</item>
<item name="android:minWidth">48dip</item>