Skip to content

Commit

Permalink
Merge pull request #38 from greenart7c3/main
Browse files Browse the repository at this point in the history
Fix relay list text color when in light theme
  • Loading branch information
KoalaSat authored Nov 6, 2024
2 parents 9c31087 + 437abbe commit 3314eb3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/java/com/koalasat/pokey/utils/ThemeUtils.kt
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 3314eb3

Please sign in to comment.