improve snackbar colors

This commit is contained in:
Bnyro 2022-07-04 08:48:47 +02:00
parent 486ee090d1
commit 3dfdd45aaf

View File

@ -5,6 +5,7 @@ import android.net.Uri
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.text.Html import android.text.Html
import android.util.TypedValue
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -49,7 +50,8 @@ class AboutFragment : Fragment() {
binding.piped.setOnClickListener { binding.piped.setOnClickListener {
openLinkFromHref(PIPED_GITHUB_URL) openLinkFromHref(PIPED_GITHUB_URL)
} }
binding.piped.setOnLongClickListener { val text = context?.getString(R.string.piped_summary)!! binding.piped.setOnLongClickListener {
val text = context?.getString(R.string.piped_summary)!!
showSnackBar(text) showSnackBar(text)
true true
} }
@ -57,7 +59,8 @@ class AboutFragment : Fragment() {
binding.donate.setOnClickListener { binding.donate.setOnClickListener {
openLinkFromHref(DONATE_URL) openLinkFromHref(DONATE_URL)
} }
binding.donate.setOnLongClickListener { val text = context?.getString(R.string.donate_summary)!! binding.donate.setOnLongClickListener {
val text = context?.getString(R.string.donate_summary)!!
showSnackBar(text) showSnackBar(text)
true true
} }
@ -74,7 +77,6 @@ class AboutFragment : Fragment() {
binding.license.setOnClickListener { binding.license.setOnClickListener {
showLicense() showLicense()
} }
binding.license.setOnLongClickListener { binding.license.setOnLongClickListener {
val text = context?.getString(R.string.license_summary)!! val text = context?.getString(R.string.license_summary)!!
showSnackBar(text) showSnackBar(text)
@ -91,6 +93,8 @@ class AboutFragment : Fragment() {
private fun showSnackBar(text: String) { private fun showSnackBar(text: String) {
val snackBar = Snackbar val snackBar = Snackbar
.make(binding.root, text, Snackbar.LENGTH_LONG) .make(binding.root, text, Snackbar.LENGTH_LONG)
snackBar.setBackgroundTint(getThemeColor(R.attr.colorSurface))
snackBar.setTextColor(getThemeColor(R.attr.colorPrimary))
snackBar.show() snackBar.show()
} }
@ -115,4 +119,10 @@ class AboutFragment : Fragment() {
.create() .create()
.show() .show()
} }
private fun getThemeColor(colorCode: Int): Int {
val value = TypedValue()
context!!.theme.resolveAttribute(colorCode, value, true)
return value.data
}
} }