fix(ui/amoled_dark_mode): opera context menu download button

This commit is contained in:
rhunk
2023-09-02 13:43:47 +02:00
parent 3656024c98
commit 58a13fe5be
2 changed files with 9 additions and 5 deletions

View File

@@ -36,7 +36,7 @@ object ViewAppearanceHelper {
}
@SuppressLint("DiscouragedApi")
fun applyTheme(component: View, componentWidth: Int? = null, hasRadius: Boolean = false) {
fun applyTheme(component: View, componentWidth: Int? = null, hasRadius: Boolean = false, isAmoled: Boolean = true) {
val resources = component.context.resources
if (sigColorBackgroundSurface == 0 || sigColorTextPrimary == 0) {
with(component.context.theme) {
@@ -66,9 +66,13 @@ object ViewAppearanceHelper {
outlineProvider = null
setPadding((40 * scalingFactor).toInt(), 0, (40 * scalingFactor).toInt(), 0)
}
background = StateListDrawable().apply {
addState(intArrayOf(), createRoundedBackground(color = sigColorBackgroundSurface, hasRadius))
addState(intArrayOf(android.R.attr.state_pressed), createRoundedBackground(color = 0x5395026, hasRadius))
if (isAmoled) {
background = StateListDrawable().apply {
addState(intArrayOf(), createRoundedBackground(color = sigColorBackgroundSurface, hasRadius))
addState(intArrayOf(android.R.attr.state_pressed), createRoundedBackground(color = 0x5395026, hasRadius))
}
} else {
setBackgroundColor(0x0)
}
}

View File

@@ -71,7 +71,7 @@ class OperaContextActionMenu : AbstractMenu() {
val button = Button(childView.getContext())
button.text = context.translation["opera_context_menu.download"]
button.setOnClickListener { context.feature(MediaDownloader::class).downloadLastOperaMediaAsync() }
applyTheme(button)
applyTheme(button, isAmoled = false)
linearLayout.addView(button)
(childView as ViewGroup).addView(linearLayout, 0)
} catch (e: Throwable) {