diff --git a/app/src/main/java/moe/matsuri/nb4a/ui/SimpleMenuPreference.kt b/app/src/main/java/moe/matsuri/nb4a/ui/SimpleMenuPreference.kt index afb42d598..4e4141ac7 100644 --- a/app/src/main/java/moe/matsuri/nb4a/ui/SimpleMenuPreference.kt +++ b/app/src/main/java/moe/matsuri/nb4a/ui/SimpleMenuPreference.kt @@ -23,6 +23,7 @@ import android.view.View import android.view.ViewGroup import android.widget.ArrayAdapter import android.widget.Spinner +import androidx.core.graphics.ColorUtils import androidx.preference.DropDownPreference import androidx.preference.PreferenceViewHolder import io.nekohasekai.sagernet.R @@ -70,7 +71,14 @@ open class SimpleMenuPreference var currentPosition = -1 private val radius = 12f * context.resources.displayMetrics.density - private val selectedColor = context.getColorAttr(R.attr.colorMaterial100) + + // Highlight the selected item with a translucent primary tint rather than + // an opaque colorMaterial100 fill: the light fill made the (light) item + // text low-contrast on dark themes. ~20% alpha reads on any background + // while keeping the text legible. + private val selectedColor = ColorUtils.setAlphaComponent( + context.getColorAttr(R.attr.colorPrimary), 41 // 0.16 alpha, matches nav_item_fill.xml + ) private val topDrawable = GradientDrawable().apply { setColor(selectedColor)