Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/src/main/java/com/darkempire78/opencalculator/Themes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.core.content.ContextCompat
import androidx.core.content.ContextCompat.startActivity
import com.google.android.material.color.DynamicColors
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import android.content.res.Configuration

class Themes(private val context: Context) {

Expand Down Expand Up @@ -115,7 +116,10 @@ class Themes(private val context: Context) {
var theme = "THEME"
when (themeID) {
DEFAULT_THEME_INDEX -> {
theme = if (MyPreferences(this.context).forceDayNight == AppCompatDelegate.MODE_NIGHT_YES) {
val currentUiMode = context.resources.configuration.uiMode
val isNightMode = currentUiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES

theme = if (MyPreferences(this.context).forceDayNight == AppCompatDelegate.MODE_NIGHT_YES || isNightMode) {
context.getString(R.string.theme_dark)
} else {
context.getString(R.string.theme_light)
Expand Down