Browse Source

Tweak button styles

arkon 5 years ago
parent
commit
3f4140900d

+ 3 - 10
app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionHolder.kt

@@ -1,8 +1,6 @@
 package eu.kanade.tachiyomi.ui.extension
 
 import android.view.View
-import androidx.core.content.ContextCompat
-import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat
 import eu.kanade.tachiyomi.R
 import eu.kanade.tachiyomi.data.glide.GlideApp
 import eu.kanade.tachiyomi.extension.model.Extension
@@ -10,6 +8,7 @@ import eu.kanade.tachiyomi.extension.model.InstallStep
 import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
 import eu.kanade.tachiyomi.ui.base.holder.SlicedHolder
 import eu.kanade.tachiyomi.util.system.LocaleHelper
+import eu.kanade.tachiyomi.util.system.getResourceColor
 import io.github.mthli.slice.Slice
 import kotlinx.android.synthetic.main.extension_card_item.card
 import kotlinx.android.synthetic.main.extension_card_item.ext_button
@@ -63,10 +62,8 @@ class ExtensionHolder(view: View, override val adapter: ExtensionAdapter) :
     fun bindButton(item: ExtensionItem) = with(ext_button) {
         isEnabled = true
         isClickable = true
-        isActivated = false
 
-        background = VectorDrawableCompat.create(resources!!, R.drawable.button_bg_transparent, null)
-        setTextColor(ContextCompat.getColorStateList(context, R.drawable.button_bg_transparent))
+        setTextColor(context.getResourceColor(R.attr.colorAccent))
 
         val extension = item.extension
 
@@ -86,14 +83,10 @@ class ExtensionHolder(view: View, override val adapter: ExtensionAdapter) :
         } else if (extension is Extension.Installed) {
             when {
                 extension.hasUpdate -> {
-                    isActivated = true
                     setText(R.string.ext_update)
                 }
                 extension.isObsolete -> {
-                    // Red outline
-                    background = VectorDrawableCompat.create(resources, R.drawable.button_bg_error, null)
-                    setTextColor(ContextCompat.getColorStateList(context, R.drawable.button_bg_error))
-
+                    setTextColor(context.getResourceColor(R.attr.colorError))
                     setText(R.string.ext_obsolete)
                 }
                 else -> {

+ 0 - 26
app/src/main/res/drawable/button_bg_error.xml

@@ -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="@color/md_white_1000">
-        <shape android:shape="rectangle">
-            <corners android:radius="2dp" />
-            <solid android:color="@color/red_error" />
-            <padding android:left="8dp" android:right="8dp" />
-        </shape>
-    </item>
-    <item android:state_enabled="false" android:color="@color/textColorHintLight">
-        <shape android:shape="rectangle">
-            <corners android:radius="2dp" />
-            <solid android:color="@android:color/transparent" />
-            <stroke android:width="1dp" android:color="@color/textColorHintLight" />
-            <padding android:left="8dp" android:right="8dp" />
-        </shape>
-    </item>
-    <item android:color="@color/red_error">
-        <shape android:color="@color/red_error" android:shape="rectangle">
-            <corners android:radius="2dp" />
-            <solid android:color="@android:color/transparent" />
-            <stroke android:width="1dp" android:color="@color/red_error" />
-            <padding android:left="8dp" android:right="8dp" />
-        </shape>
-    </item>
-</selector>

+ 0 - 26
app/src/main/res/drawable/button_bg_transparent.xml

@@ -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="@color/md_white_1000">
-        <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/textColorHintLight">
-        <shape android:shape="rectangle">
-            <corners android:radius="2dp" />
-            <solid android:color="@android:color/transparent" />
-            <stroke android:color="@color/textColorHintLight" android:width="1dp"/>
-            <padding android:left="8dp" android:right="8dp" />
-        </shape>
-    </item>
-    <item android:color="?attr/colorAccent">
-        <shape android:shape="rectangle" android:color="?attr/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>

+ 2 - 2
app/src/main/res/layout/catalogue_drawer_content.xml

@@ -50,7 +50,7 @@
 
         <Button
             android:id="@+id/reset_btn"
-            style="@style/Theme.Widget.Button.Borderless"
+            style="@style/Theme.Widget.Button"
             android:layout_width="0dp"
             android:layout_height="wrap_content"
             android:layout_weight="1"
@@ -58,7 +58,7 @@
 
         <Button
             android:id="@+id/search_btn"
-            style="@style/Theme.Widget.Button.Colored"
+            style="@style/Theme.Widget.Button.FilledAccent"
             android:layout_width="0dp"
             android:layout_height="wrap_content"
             android:layout_weight="1"

+ 6 - 2
app/src/main/res/layout/catalogue_main_controller_card_item.xml

@@ -39,9 +39,11 @@
 
         <Button
             android:id="@+id/source_latest"
-            style="@style/Theme.Widget.Button.Borderless.Small"
+            style="@style/Theme.Widget.Button"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
+            android:maxHeight="48dp"
+            android:minHeight="48dp"
             android:text="@string/latest"
             app:layout_constraintBottom_toBottomOf="parent"
             app:layout_constraintEnd_toStartOf="@+id/source_browse"
@@ -49,9 +51,11 @@
 
         <Button
             android:id="@+id/source_browse"
-            style="@style/Theme.Widget.Button.Borderless.Small"
+            style="@style/Theme.Widget.Button"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
+            android:maxHeight="48dp"
+            android:minHeight="48dp"
             android:text="@string/browse"
             app:layout_constraintBottom_toBottomOf="parent"
             app:layout_constraintEnd_toEndOf="parent"

+ 3 - 7
app/src/main/res/layout/extension_card_item.xml

@@ -60,20 +60,16 @@
             android:layout_marginStart="4dp"
             android:maxLines="1"
             android:textSize="12sp"
-            app:layout_constraintBaseline_toBaselineOf="@id/lang"
             app:layout_constraintStart_toEndOf="@id/lang"
+            app:layout_constraintTop_toBottomOf="@+id/ext_title"
             tools:text="Version" />
 
         <Button
             android:id="@+id/ext_button"
+            style="@style/Theme.Widget.Button.Outlined.Accent"
             android:layout_width="wrap_content"
-            android:layout_height="32dp"
-            android:layout_marginTop="16dp"
+            android:layout_height="wrap_content"
             android:layout_marginEnd="16dp"
-            android:layout_marginBottom="16dp"
-            android:background="@drawable/button_bg_transparent"
-            android:foreground="?attr/selectableItemBackground"
-            android:textColor="@drawable/button_bg_transparent"
             app:layout_constraintBottom_toBottomOf="parent"
             app:layout_constraintEnd_toEndOf="parent"
             app:layout_constraintTop_toTopOf="parent"

+ 1 - 1
app/src/main/res/layout/extension_detail_controller.xml

@@ -78,7 +78,7 @@
 
     <Button
         android:id="@+id/extension_uninstall_button"
-        style="@style/Theme.Widget.Button.Colored"
+        style="@style/Theme.Widget.Button.FilledAccent"
         android:layout_width="0dp"
         android:layout_height="wrap_content"
         android:layout_marginStart="16dp"

+ 2 - 2
app/src/main/res/layout/history_item.xml

@@ -51,7 +51,7 @@
 
             <Button
                 android:id="@+id/remove"
-                style="@style/Theme.Widget.Button.Borderless.Negative"
+                style="@style/Theme.Widget.Button.Error"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_alignParentBottom="true"
@@ -59,7 +59,7 @@
 
             <Button
                 android:id="@+id/resume"
-                style="@style/Theme.Widget.Button.Borderless"
+                style="@style/Theme.Widget.Button"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_alignParentBottom="true"

+ 14 - 14
app/src/main/res/values/styles.xml

@@ -27,8 +27,8 @@
         <item name="android:textColor">?attr/colorOnSurface</item>
 
         <item name="buttonBarPositiveButtonStyle">@style/Theme.Widget.Button</item>
-        <item name="buttonBarNegativeButtonStyle">@style/Theme.Widget.Button.Borderless</item>
-        <item name="buttonBarNeutralButtonStyle">@style/Theme.Widget.Button.Borderless</item>
+        <item name="buttonBarNegativeButtonStyle">@style/Theme.Widget.Button</item>
+        <item name="buttonBarNeutralButtonStyle">@style/Theme.Widget.Button</item>
     </style>
 
     <style name="Theme.AlertDialog.Light" parent="Theme.AlertDialog">
@@ -224,24 +224,24 @@
     <!--Widgets.Button-->
     <!--==============-->
     <style name="Theme.Widget.Button" parent="Widget.MaterialComponents.Button.TextButton">
-        <item name="android:textColor">?attr/colorOnSurface</item>
-    </style>
-
-    <style name="Theme.Widget.Button.Colored" parent="Widget.MaterialComponents.Button">
-        <item name="backgroundTint">?attr/colorAccent</item>
+        <item name="android:textColor">?attr/colorAccent</item>
+        <item name="rippleColor">?attr/colorAccent</item>
     </style>
 
-    <style name="Theme.Widget.Button.Borderless" parent="Theme.Widget.Button">
-        <item name="android:textColor">?attr/colorAccent</item>
+    <style name="Theme.Widget.Button.Error" parent="Theme.Widget.Button">
+        <item name="android:textColor">?attr/colorError</item>
+        <item name="rippleColor">?attr/colorError</item>
     </style>
 
-    <style name="Theme.Widget.Button.Borderless.Negative" parent="Theme.Widget.Button.Borderless">
-        <item name="android:textColor">@color/md_red_500</item>
+    <style name="Theme.Widget.Button.FilledAccent" parent="Widget.MaterialComponents.Button">
+        <item name="android:textColor">?attr/colorOnSecondary</item>
+        <item name="backgroundTint">?attr/colorAccent</item>
+        <item name="rippleColor">?attr/colorAccent</item>
     </style>
 
-    <style name="Theme.Widget.Button.Borderless.Small" parent="Theme.Widget.Button.Borderless">
-        <item name="android:minHeight">48dip</item>
-        <item name="android:minWidth">48dip</item>
+    <style name="Theme.Widget.Button.Outlined.Accent" parent="Widget.MaterialComponents.Button.OutlinedButton">
+        <item name="android:textColor">?attr/colorAccent</item>
+        <item name="rippleColor">?attr/colorAccent</item>
     </style>
 
 

+ 2 - 2
app/src/main/res/values/themes.xml

@@ -49,7 +49,7 @@
         <item name="preferenceTheme">@style/PreferenceThemeOverlay</item>
         <item name="dialogTheme">@style/Theme.AlertDialog.Light</item>
         <item name="alertDialogTheme">@style/Theme.AlertDialog.Dark</item>
-        <item name="snackbarButtonStyle">@style/Theme.Widget.Button.Borderless</item>
+        <item name="snackbarButtonStyle">@style/Theme.Widget.Button</item>
         <item name="textAppearanceButton">@style/TextAppearance.Widget.Button</item>
         <item name="android:itemTextAppearance">@style/TextAppearance.Widget.Menu</item>
 
@@ -125,7 +125,7 @@
         <item name="preferenceTheme">@style/PreferenceThemeOverlay</item>
         <item name="dialogTheme">@style/Theme.AlertDialog.Dark</item>
         <item name="alertDialogTheme">@style/Theme.AlertDialog.Dark</item>
-        <item name="snackbarButtonStyle">@style/Theme.Widget.Button.Borderless</item>
+        <item name="snackbarButtonStyle">@style/Theme.Widget.Button</item>
         <item name="textAppearanceButton">@style/TextAppearance.Widget.Button</item>
         <item name="android:itemTextAppearance">@style/TextAppearance.Widget.Menu</item>