commit 58a13fe5be925e7d92526bc68683f0ded58c4126
parent 3656024c986c76b7ab26c19e4f515ff1c70ea167
Author: rhunk <101876869+rhunk@users.noreply.github.com>
Date: Sat, 2 Sep 2023 13:43:47 +0200
fix(ui/amoled_dark_mode): opera context menu download button
Diffstat:
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/ui/ViewAppearanceHelper.kt b/core/src/main/kotlin/me/rhunk/snapenhance/ui/ViewAppearanceHelper.kt
@@ -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)
}
}
diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/ui/menu/impl/OperaContextActionMenu.kt b/core/src/main/kotlin/me/rhunk/snapenhance/ui/menu/impl/OperaContextActionMenu.kt
@@ -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) {