mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-20 06:09:19 +01:00
Updating style and logic for extension update/install button
Not similar to upstream but almost similar to upstream
This commit is contained in:
parent
3f1869cab6
commit
d9ef6f8e3f
@ -3,7 +3,6 @@ package eu.kanade.tachiyomi.ui.extension
|
|||||||
import android.content.res.ColorStateList
|
import android.content.res.ColorStateList
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import coil.clear
|
import coil.clear
|
||||||
import coil.load
|
import coil.load
|
||||||
import eu.kanade.tachiyomi.R
|
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.extension.model.InstallStep
|
||||||
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||||
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
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.image.coil.CoverViewTarget
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.databinding.ExtensionCardItemBinding
|
import eu.kanade.tachiyomi.databinding.ExtensionCardItemBinding
|
||||||
|
import eu.kanade.tachiyomi.util.view.resetStrokeColor
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
@ -67,12 +65,9 @@ class ExtensionHolder(view: View, val adapter: ExtensionAdapter) :
|
|||||||
isClickable = true
|
isClickable = true
|
||||||
isActivated = false
|
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 extension = item.extension
|
||||||
val installStep = item.installStep
|
val installStep = item.installStep
|
||||||
|
strokeColor = ColorStateList.valueOf(Color.TRANSPARENT)
|
||||||
if (installStep != null) {
|
if (installStep != null) {
|
||||||
setText(
|
setText(
|
||||||
when (installStep) {
|
when (installStep) {
|
||||||
@ -91,10 +86,6 @@ class ExtensionHolder(view: View, val adapter: ExtensionAdapter) :
|
|||||||
when {
|
when {
|
||||||
extension.hasUpdate -> {
|
extension.hasUpdate -> {
|
||||||
isActivated = true
|
isActivated = true
|
||||||
backgroundTintList = ColorStateList.valueOf(
|
|
||||||
context.getResourceColor(R.attr.colorAccent)
|
|
||||||
)
|
|
||||||
strokeColor = ColorStateList.valueOf(Color.TRANSPARENT)
|
|
||||||
setText(R.string.update)
|
setText(R.string.update)
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
@ -102,8 +93,10 @@ class ExtensionHolder(view: View, val adapter: ExtensionAdapter) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (extension is Extension.Untrusted) {
|
} else if (extension is Extension.Untrusted) {
|
||||||
|
resetStrokeColor()
|
||||||
setText(R.string.trust)
|
setText(R.string.trust)
|
||||||
} else {
|
} else {
|
||||||
|
resetStrokeColor()
|
||||||
setText(R.string.install)
|
setText(R.string.install)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
5
app/src/main/res/color/ext_bg_selector.xml
Normal file
5
app/src/main/res/color/ext_bg_selector.xml
Normal 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>
|
6
app/src/main/res/color/ext_button_text_selector.xml
Normal file
6
app/src/main/res/color/ext_button_text_selector.xml
Normal 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>
|
@ -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>
|
|
@ -80,18 +80,16 @@
|
|||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/ext_button"
|
android:id="@+id/ext_button"
|
||||||
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
|
style="@style/Theme.Widget.Button.OutlinedButtonAccent"
|
||||||
android:textAllCaps="false"
|
android:textAllCaps="false"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="16dp"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
android:layout_marginBottom="16dp"
|
android:layout_marginBottom="16dp"
|
||||||
android:textColor="@drawable/button_text_state"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:rippleColor="@color/fullRippleColor"
|
|
||||||
tools:text="Details" />
|
tools:text="Details" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
@ -247,6 +247,14 @@
|
|||||||
<item name="rippleColor">@color/fullRippleColor</item>
|
<item name="rippleColor">@color/fullRippleColor</item>
|
||||||
</style>
|
</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">
|
<style name="Theme.Widget.Button.Borderless.Small">
|
||||||
<item name="android:minHeight">48dip</item>
|
<item name="android:minHeight">48dip</item>
|
||||||
<item name="android:minWidth">48dip</item>
|
<item name="android:minWidth">48dip</item>
|
||||||
|
Loading…
Reference in New Issue
Block a user