From 437abbe35dae7732dbab1c0fd8bf46978419a336 Mon Sep 17 00:00:00 2001 From: greenart7c3 Date: Wed, 6 Nov 2024 07:34:57 -0300 Subject: [PATCH] Fix relay list text color when in light theme --- .../java/com/koalasat/pokey/ui/relays/RelayListAdapter.kt | 3 ++- app/src/main/java/com/koalasat/pokey/utils/ThemeUtils.kt | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/com/koalasat/pokey/utils/ThemeUtils.kt diff --git a/app/src/main/java/com/koalasat/pokey/ui/relays/RelayListAdapter.kt b/app/src/main/java/com/koalasat/pokey/ui/relays/RelayListAdapter.kt index fbffa10..8219055 100644 --- a/app/src/main/java/com/koalasat/pokey/ui/relays/RelayListAdapter.kt +++ b/app/src/main/java/com/koalasat/pokey/ui/relays/RelayListAdapter.kt @@ -11,6 +11,7 @@ import com.koalasat.pokey.Pokey import com.koalasat.pokey.R import com.koalasat.pokey.database.AppDatabase import com.koalasat.pokey.database.RelayEntity +import com.koalasat.pokey.utils.isDarkThemeEnabled import com.vitorpamplona.ammolite.relays.RelayPool import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -55,7 +56,7 @@ class RelayListAdapter( val relay = RelayPool.getRelay(relayEntity.url) val color = if (relay == null) { - R.color.white + if (isDarkThemeEnabled(holder.textView.context)) R.color.white else R.color.black } else if (relay.isConnected()) { R.color.green } else { diff --git a/app/src/main/java/com/koalasat/pokey/utils/ThemeUtils.kt b/app/src/main/java/com/koalasat/pokey/utils/ThemeUtils.kt new file mode 100644 index 0000000..8187f8a --- /dev/null +++ b/app/src/main/java/com/koalasat/pokey/utils/ThemeUtils.kt @@ -0,0 +1,8 @@ +package com.koalasat.pokey.utils + +import android.content.Context +import android.content.res.Configuration + +fun isDarkThemeEnabled(context: Context): Boolean { + return (context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES +}