Skip to content

Commit efe0f32

Browse files
committed
style: fix text readability in SelectableList for Monet mode
- Replace 'colorControlNormal' with 'colorOnSurface' to ensure text contrast against dynamic surface backgrounds. - Update selection style to use Material 3 'colorPrimaryContainer' and 'colorOnPrimaryContainer' color pairs. - Remove hardcoded Alpha/RGB arithmetic in favor of themed semantic colors. - Ensure unselected items remain transparent to inherit the container's dynamic theme.
1 parent 2d191f2 commit efe0f32

1 file changed

Lines changed: 8 additions & 15 deletions

File tree

design/src/main/java/com/github/kr328/clash/design/adapter/PopupListAdapter.kt

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import android.view.View
66
import android.view.ViewGroup
77
import android.widget.BaseAdapter
88
import android.widget.TextView
9-
import com.github.kr328.clash.design.R
109
import com.github.kr328.clash.design.util.layoutInflater
1110
import com.github.kr328.clash.design.util.resolveThemedColor
1211

@@ -15,9 +14,10 @@ class PopupListAdapter(
1514
private val texts: List<CharSequence>,
1615
private val selected: Int,
1716
) : BaseAdapter() {
18-
private val colorPrimary = context.resolveThemedColor(com.google.android.material.R.attr.colorPrimary)
19-
private val colorOnPrimary = context.resolveThemedColor(com.google.android.material.R.attr.colorOnPrimary)
20-
private val colorControlNormal = context.resolveThemedColor(com.google.android.material.R.attr.colorControlNormal)
17+
private val colorPrimaryContainer = context.resolveThemedColor(com.google.android.material.R.attr.colorPrimaryContainer)
18+
private val colorOnPrimaryContainer = context.resolveThemedColor(com.google.android.material.R.attr.colorOnPrimaryContainer)
19+
20+
private val colorOnSurface = context.resolveThemedColor(com.google.android.material.R.attr.colorOnSurface)
2121

2222
override fun getCount(): Int {
2323
return texts.size
@@ -40,20 +40,13 @@ class PopupListAdapter(
4040
text.text = texts[position]
4141

4242
if (position == selected) {
43-
text.setBackgroundColor(
44-
Color.argb(
45-
200,
46-
Color.red(colorPrimary),
47-
Color.green(colorPrimary),
48-
Color.blue(colorPrimary)
49-
)
50-
)
51-
text.setTextColor(colorOnPrimary)
43+
text.setBackgroundColor(colorPrimaryContainer)
44+
text.setTextColor(colorOnPrimaryContainer)
5245
} else {
5346
text.setBackgroundColor(Color.TRANSPARENT)
54-
text.setTextColor(colorControlNormal)
47+
text.setTextColor(colorOnSurface)
5548
}
5649

5750
return view
5851
}
59-
}
52+
}

0 commit comments

Comments
 (0)