Filter Tag Group now matches color accent of theme

Plus tool tip for clearing filters
This commit is contained in:
Jays2Kings 2021-04-16 03:25:01 -04:00
parent 681ceccf2e
commit 388595c290
4 changed files with 28 additions and 8 deletions

View File

@ -21,6 +21,7 @@ import eu.kanade.tachiyomi.util.system.dpToPx
import eu.kanade.tachiyomi.util.system.launchUI import eu.kanade.tachiyomi.util.system.launchUI
import eu.kanade.tachiyomi.util.view.activityBinding import eu.kanade.tachiyomi.util.view.activityBinding
import eu.kanade.tachiyomi.util.view.collapse import eu.kanade.tachiyomi.util.view.collapse
import eu.kanade.tachiyomi.util.view.compatToolTipText
import eu.kanade.tachiyomi.util.view.hide import eu.kanade.tachiyomi.util.view.hide
import eu.kanade.tachiyomi.util.view.inflate import eu.kanade.tachiyomi.util.view.inflate
import eu.kanade.tachiyomi.util.view.isExpanded import eu.kanade.tachiyomi.util.view.isExpanded
@ -156,6 +157,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
createTags() createTags()
clearButton.setOnClickListener { clearFilters() } clearButton.setOnClickListener { clearFilters() }
clearButton.compatToolTipText = context.getString(R.string.clear_filters)
preferences.filterOrder().asFlow() preferences.filterOrder().asFlow()
.drop(1) .drop(1)
.onEach { .onEach {

View File

@ -1,12 +1,12 @@
package eu.kanade.tachiyomi.ui.library.filter package eu.kanade.tachiyomi.ui.library.filter
import android.content.Context import android.content.Context
import android.graphics.Color
import android.util.AttributeSet import android.util.AttributeSet
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.LinearLayout import android.widget.LinearLayout
import com.f2prateek.rx.preferences.Preference import com.f2prateek.rx.preferences.Preference
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.preference.getOrDefault import eu.kanade.tachiyomi.data.preference.getOrDefault
import eu.kanade.tachiyomi.databinding.FilterTagGroupBinding import eu.kanade.tachiyomi.databinding.FilterTagGroupBinding
import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.util.system.dpToPx
@ -119,10 +119,16 @@ class FilterTagGroup@JvmOverloads constructor(context: Context, attrs: Attribute
if (itemCount == 1) { if (itemCount == 1) {
binding.firstButton.isActivated = !binding.firstButton.isActivated binding.firstButton.isActivated = !binding.firstButton.isActivated
binding.firstButton.setTextColor( binding.firstButton.setTextColor(
if (binding.firstButton.isActivated) Color.WHITE else context context.getResourceColor(
.getResourceColor(android.R.attr.textColorPrimary) if (binding.firstButton.isActivated) R.attr.colorOnAccent
else android.R.attr.textColorPrimary
)
)
listener?.onFilterClicked(
this,
if (binding.firstButton.isActivated) index else -1,
callBack
) )
listener?.onFilterClicked(this, if (binding.firstButton.isActivated) index else -1, callBack)
return return
} }
val mainButton = buttons[index] val mainButton = buttons[index]
@ -145,8 +151,10 @@ class FilterTagGroup@JvmOverloads constructor(context: Context, attrs: Attribute
separators.forEach { it.gone() } separators.forEach { it.gone() }
} }
mainButton.setTextColor( mainButton.setTextColor(
if (mainButton.isActivated) Color.WHITE else context context.getResourceColor(
.getResourceColor(android.R.attr.textColorPrimary) if (mainButton.isActivated) R.attr.colorOnAccent
else android.R.attr.textColorPrimary
)
) )
} }
} }

View File

@ -15,8 +15,17 @@
<size <size
android:height="32dp" android:height="32dp"
android:width="32dp" /> android:width="32dp" />
<solid android:color="@android:color/transparent"/> <stroke android:width="1dp" android:color="?attr/colorAccent" />
<stroke android:width="1dp" android:color="@color/app_color_primary" /> </shape>
</item>
<item android:id="@+id/bg_dim" android:alpha="0.1">
<shape
android:shape="rectangle">
<corners android:radius="16dp"/>
<size
android:height="32dp"
android:width="32dp" />
<stroke android:width="1dp" android:color="?android:attr/textColorSecondaryInverse" />
</shape> </shape>
</item> </item>
</ripple> </ripple>

View File

@ -821,6 +821,7 @@
<string name="change">Change</string> <string name="change">Change</string>
<string name="charging">Charging</string> <string name="charging">Charging</string>
<string name="clear">Clear</string> <string name="clear">Clear</string>
<string name="clear_filters">Clear filters</string>
<string name="close">Close</string> <string name="close">Close</string>
<string name="common">Common</string> <string name="common">Common</string>
<string name="cover_of_image">Cover of manga</string> <string name="cover_of_image">Cover of manga</string>