Add ripple/padding to show all categories button

+ change categories hopper arrow direction when toggling on this setting
This commit is contained in:
Jays2Kings 2022-08-29 00:21:29 -04:00
parent edf2cb95fe
commit 47e16f8445
2 changed files with 12 additions and 1 deletions

View file

@ -96,6 +96,7 @@ import eu.kanade.tachiyomi.util.moveCategories
import eu.kanade.tachiyomi.util.system.contextCompatDrawable
import eu.kanade.tachiyomi.util.system.dpToPx
import eu.kanade.tachiyomi.util.system.getResourceColor
import eu.kanade.tachiyomi.util.system.getResourceDrawable
import eu.kanade.tachiyomi.util.system.ignoredSystemInsets
import eu.kanade.tachiyomi.util.system.isImeVisible
import eu.kanade.tachiyomi.util.system.launchUI
@ -1183,7 +1184,7 @@ class LibraryController(
showMiniBar()
}
updateHopperAlpha()
val isSingleCategory = !presenter.showAllCategories || presenter.forceShowAllCategories
val isSingleCategory = !presenter.showAllCategories && !presenter.forceShowAllCategories
val context = binding.roundedCategoryHopper.root.context
binding.roundedCategoryHopper.upCategory.setImageDrawable(
context.contextCompatDrawable(
@ -1825,7 +1826,10 @@ class LibraryController(
presenter.getLibrary()
isSelected = presenter.forceShowAllCategories
}
val pad = 12.dpToPx
setPadding(pad, 0, pad, 0)
setImageResource(R.drawable.ic_show_all_categories_24dp)
background = context.getResourceDrawable(R.attr.selectableItemBackgroundBorderless)
imageTintList = ColorStateList.valueOf(context.getResourceColor(R.attr.actionBarTintColor))
compatToolTipText = resources?.getText(R.string.show_all_categories)
}

View file

@ -117,6 +117,13 @@ fun Context.getResourceColor(@AttrRes resource: Int): Int {
return attrValue
}
fun Context.getResourceDrawable(@AttrRes resource: Int): Drawable? {
val typedArray = obtainStyledAttributes(intArrayOf(resource))
val attrValue = typedArray.getDrawable(0)
typedArray.recycle()
return attrValue
}
/**
* Returns the color from ContextCompat
*