diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
index 44ca2d9b..103e00cb 100644
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -3,39 +3,30 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/java/dev/pyrossh/onlyBible/AppTheme.kt b/app/src/main/java/dev/pyrossh/onlyBible/AppTheme.kt
index 7322f789..211fbb96 100644
--- a/app/src/main/java/dev/pyrossh/onlyBible/AppTheme.kt
+++ b/app/src/main/java/dev/pyrossh/onlyBible/AppTheme.kt
@@ -1,8 +1,6 @@
package dev.pyrossh.onlyBible
-import android.content.res.Configuration.UI_MODE_NIGHT_MASK
-import android.content.res.Configuration.UI_MODE_NIGHT_NO
-import android.content.res.Configuration.UI_MODE_NIGHT_UNDEFINED
+import android.app.UiModeManager
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.dynamicDarkColorScheme
@@ -44,8 +42,7 @@ val darkHighlights = listOf(
fun isLightTheme(uiMode: Int, isSystemDark: Boolean): Boolean {
- val maskedMode = uiMode and UI_MODE_NIGHT_MASK
- return maskedMode == UI_MODE_NIGHT_NO || (maskedMode == UI_MODE_NIGHT_UNDEFINED && !isSystemDark)
+ return uiMode == UiModeManager.MODE_NIGHT_NO || (uiMode == UiModeManager.MODE_NIGHT_AUTO && !isSystemDark)
}
@Composable
@@ -55,7 +52,7 @@ fun AppTheme(
) {
val context = LocalContext.current
val systemUiController = rememberSystemUiController()
- val colorScheme = if (isLightTheme(model.uiMode, isSystemInDarkTheme()))
+ val colorScheme = if (isLightTheme(model.nightMode, isSystemInDarkTheme()))
dynamicLightColorScheme(context).copy(
onSurface = Color.Black,
outline = Color.LightGray,
@@ -66,8 +63,7 @@ fun AppTheme(
surface = Color(0xFF090F12),
outline = Color(0xAA5D4979),
)
- println("AppTheme ${model.uiMode}")
- LaunchedEffect(key1 = model.uiMode) {
+ LaunchedEffect(key1 = model.nightMode) {
systemUiController.setSystemBarsColor(
color = colorScheme.background
)
diff --git a/app/src/main/java/dev/pyrossh/onlyBible/AppViewModel.kt b/app/src/main/java/dev/pyrossh/onlyBible/AppViewModel.kt
index 75220705..a33d556d 100644
--- a/app/src/main/java/dev/pyrossh/onlyBible/AppViewModel.kt
+++ b/app/src/main/java/dev/pyrossh/onlyBible/AppViewModel.kt
@@ -3,8 +3,10 @@ package dev.pyrossh.onlyBible
import android.app.Application
import android.app.LocaleConfig
import android.app.LocaleManager
+import android.app.UiModeManager
import android.content.Context
import android.content.Context.MODE_PRIVATE
+import android.content.Context.UI_MODE_SERVICE
import android.content.Intent
import android.os.Build
import android.os.LocaleList
@@ -72,7 +74,8 @@ class AppViewModel(application: Application) : AndroidViewModel(application) {
var fontType by mutableStateOf(FontType.Sans)
var fontSizeDelta by mutableIntStateOf(0)
var fontBoldEnabled by mutableStateOf(false)
- var uiMode by mutableIntStateOf(0)
+ var lineSpacingDelta by mutableStateOf(0)
+ var nightMode by mutableStateOf(UiModeManager.MODE_NIGHT_AUTO)
var scrollState = LazyListState(
0,
0
@@ -129,9 +132,14 @@ class AppViewModel(application: Application) : AndroidViewModel(application) {
showBottomSheet = false
}
+ fun setApplicationNightMode(v: Int) {
+ val uiModeManager = context.getSystemService(UI_MODE_SERVICE) as UiModeManager
+ uiModeManager.setApplicationNightMode(v)
+ nightMode = v
+ }
+
fun loadData() {
viewModelScope.launch(Dispatchers.IO) {
- uiMode = context.applicationContext.resources.configuration.uiMode
loadedOnce = prefs.getBoolean("loadedOnce", false)
if (!loadedOnce) {
initLocales()
@@ -144,6 +152,8 @@ class AppViewModel(application: Application) : AndroidViewModel(application) {
)
fontSizeDelta = prefs.getInt("fontSizeDelta", 0)
fontBoldEnabled = prefs.getBoolean("fontBoldEnabled", false)
+ lineSpacingDelta = prefs.getInt("lineSpacingDelta", 0)
+ nightMode = prefs.getInt("nightMode", UiModeManager.MODE_NIGHT_AUTO)
highlightedVerses.value = JSONObject(prefs.getString("highlightedVerses", "{}") ?: "{}")
scrollState = LazyListState(
prefs.getInt("scrollIndex", 0),
@@ -197,6 +207,8 @@ class AppViewModel(application: Application) : AndroidViewModel(application) {
putString("fontType", fontType.name)
putInt("fontSizeDelta", fontSizeDelta)
putBoolean("fontBoldEnabled", fontBoldEnabled)
+ putInt("lineSpacingDelta", lineSpacingDelta)
+ putInt("nightMode", nightMode)
putString("highlightedVerses", highlightedVerses.value.toString())
putInt("scrollIndex", scrollState.firstVisibleItemIndex)
putInt("scrollOffset", scrollState.firstVisibleItemScrollOffset)
diff --git a/app/src/main/java/dev/pyrossh/onlyBible/ChapterScreen.kt b/app/src/main/java/dev/pyrossh/onlyBible/ChapterScreen.kt
index 3cdc2ca6..9a7b2d1e 100644
--- a/app/src/main/java/dev/pyrossh/onlyBible/ChapterScreen.kt
+++ b/app/src/main/java/dev/pyrossh/onlyBible/ChapterScreen.kt
@@ -123,7 +123,6 @@ fun ChapterScreen(
) {
val view = LocalView.current
val context = LocalContext.current
- println("Locales ${LocaleList.current.localeList.joinToString { "${it}" }}")
val verses by model.verses.collectAsState()
val bookNames by model.bookNames.collectAsState()
var selectedVerses by rememberSaveable {
@@ -260,7 +259,7 @@ fun ChapterScreen(
state = rememberSaveable(saver = LazyListState.Saver) {
model.scrollState
},
- verticalArrangement = Arrangement.spacedBy(12.dp),
+ verticalArrangement = Arrangement.spacedBy(16.dp + (model.lineSpacingDelta * 2).dp),
modifier = Modifier
.fillMaxSize()
.padding(innerPadding)
diff --git a/app/src/main/java/dev/pyrossh/onlyBible/MainActivity.kt b/app/src/main/java/dev/pyrossh/onlyBible/MainActivity.kt
index 18768537..549a1832 100644
--- a/app/src/main/java/dev/pyrossh/onlyBible/MainActivity.kt
+++ b/app/src/main/java/dev/pyrossh/onlyBible/MainActivity.kt
@@ -1,12 +1,11 @@
package dev.pyrossh.onlyBible
+import android.content.res.Configuration.UI_MODE_NIGHT_MASK
import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
-import androidx.appcompat.app.AppCompatDelegate
-import androidx.core.os.LocaleListCompat
import androidx.lifecycle.lifecycleScope
import kotlinx.coroutines.launch
@@ -21,7 +20,6 @@ class MainActivity : AppCompatActivity() {
model.loadData()
}
addOnConfigurationChangedListener {
- model.uiMode = it.uiMode
}
setContent {
AppTheme {
diff --git a/app/src/main/java/dev/pyrossh/onlyBible/TextSettingsBottomSheet.kt b/app/src/main/java/dev/pyrossh/onlyBible/TextSettingsBottomSheet.kt
index 531525fd..b0b5a832 100644
--- a/app/src/main/java/dev/pyrossh/onlyBible/TextSettingsBottomSheet.kt
+++ b/app/src/main/java/dev/pyrossh/onlyBible/TextSettingsBottomSheet.kt
@@ -1,11 +1,8 @@
package dev.pyrossh.onlyBible
-import android.app.UiModeManager
-import android.content.Context.UI_MODE_SERVICE
-import android.content.res.Configuration
-import android.content.res.Configuration.UI_MODE_NIGHT_NO
-import android.content.res.Configuration.UI_MODE_NIGHT_UNDEFINED
-import android.content.res.Configuration.UI_MODE_NIGHT_YES
+import android.app.UiModeManager.MODE_NIGHT_AUTO
+import android.app.UiModeManager.MODE_NIGHT_NO
+import android.app.UiModeManager.MODE_NIGHT_YES
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
@@ -37,7 +34,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
-import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
@@ -47,8 +43,6 @@ import kotlinx.coroutines.launch
@Composable
@OptIn(ExperimentalMaterial3Api::class)
fun TextSettingsBottomSheet(model: AppViewModel) {
- val uiModeManager = LocalContext.current.getSystemService(UI_MODE_SERVICE) as UiModeManager
- val uiMode = model.uiMode and Configuration.UI_MODE_NIGHT_MASK
val scope = rememberCoroutineScope()
val sheetState = rememberModalBottomSheetState()
return ModalBottomSheet(
@@ -168,7 +162,13 @@ fun TextSettingsBottomSheet(model: AppViewModel) {
.height(60.dp)
.padding(end = 16.dp)
.weight(1f),
- onClick = {}) {
+ onClick = {
+ if (model.lineSpacingDelta > 5) {
+ model.lineSpacingDelta = 0
+ } else {
+ model.lineSpacingDelta += 1
+ }
+ }) {
Column(
modifier = Modifier.background(MaterialTheme.colorScheme.background),
verticalArrangement = Arrangement.Center,
@@ -232,17 +232,17 @@ fun TextSettingsBottomSheet(model: AppViewModel) {
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically,
) {
- listOf(UI_MODE_NIGHT_NO, UI_MODE_NIGHT_YES, UI_MODE_NIGHT_UNDEFINED).map {
+ listOf(MODE_NIGHT_NO, MODE_NIGHT_YES, MODE_NIGHT_AUTO).map {
Surface(
shape = RoundedCornerShape(8.dp),
- border = if (uiMode == it) BorderStroke(
+ border = if (model.nightMode == it) BorderStroke(
2.dp, MaterialTheme.colorScheme.primary
) else null,
- color = if (uiMode == it)
+ color = if (model.nightMode == it)
MaterialTheme.colorScheme.primary
else
MaterialTheme.colorScheme.onSurface,
- contentColor = if (uiMode == it)
+ contentColor = if (model.nightMode == it)
MaterialTheme.colorScheme.primary
else
MaterialTheme.colorScheme.onSurface,
@@ -255,24 +255,12 @@ fun TextSettingsBottomSheet(model: AppViewModel) {
scope.launch {
sheetState.hide()
model.closeSheet()
- when (it) {
- UI_MODE_NIGHT_NO -> uiModeManager.setApplicationNightMode(
- UiModeManager.MODE_NIGHT_NO
- )
-
- UI_MODE_NIGHT_YES -> uiModeManager.setApplicationNightMode(
- UiModeManager.MODE_NIGHT_YES
- )
-
- UI_MODE_NIGHT_UNDEFINED -> uiModeManager.setApplicationNightMode(
- UiModeManager.MODE_NIGHT_AUTO
- )
- }
+ model.setApplicationNightMode(it)
}
}
) {
when (it) {
- UI_MODE_NIGHT_NO -> Icon(
+ MODE_NIGHT_NO -> Icon(
imageVector = Icons.Filled.LightMode,
contentDescription = "Light",
modifier = Modifier
@@ -280,7 +268,7 @@ fun TextSettingsBottomSheet(model: AppViewModel) {
.padding(12.dp)
)
- UI_MODE_NIGHT_YES -> Icon(
+ MODE_NIGHT_YES -> Icon(
imageVector = Icons.Filled.DarkMode,
contentDescription = "Dark",
modifier = Modifier
@@ -288,7 +276,7 @@ fun TextSettingsBottomSheet(model: AppViewModel) {
.padding(12.dp)
)
- UI_MODE_NIGHT_UNDEFINED -> Column(
+ MODE_NIGHT_AUTO -> Column(
modifier = Modifier.background(
color = MaterialTheme.colorScheme.background,
),
diff --git a/app/src/main/java/dev/pyrossh/onlyBible/composables/VerseView.kt b/app/src/main/java/dev/pyrossh/onlyBible/composables/VerseView.kt
index f3cf468b..882d3d99 100644
--- a/app/src/main/java/dev/pyrossh/onlyBible/composables/VerseView.kt
+++ b/app/src/main/java/dev/pyrossh/onlyBible/composables/VerseView.kt
@@ -71,7 +71,7 @@ fun VerseView(
var barYPosition by remember {
mutableIntStateOf(0)
}
- val isLight = isLightTheme(model.uiMode, isSystemInDarkTheme())
+ val isLight = isLightTheme(model.nightMode, isSystemInDarkTheme())
val fontSizeDelta = model.fontSizeDelta
val boldWeight = if (model.fontBoldEnabled) FontWeight.W700 else FontWeight.W400
val buttonInteractionSource = remember { MutableInteractionSource() }
diff --git a/readme.md b/readme.md
index 1a6a1a85..2c4fe361 100644
--- a/readme.md
+++ b/readme.md
@@ -5,8 +5,8 @@ The only bible app you will ever need.
No ads, No in-app purchases, No distractions.
Optimized for reading and highlighting.
-Only Bibles which are in the public domain are available.
-Verse by verse audio is also supported for some of the languages using Azure TTS.
+Bibles which are in the public domain are supported.
+Verse by verse audio playback is supported for most of the languages using Azure TTS.
Many languages supported Indian, European and Asian.
## Setup
@@ -37,7 +37,3 @@ fastlane supply --aab ../build/app/outputs/bundle/release/app-release.aab
flutter build ipa --release --dart-define-from-file=.env
fastlane deliver --ipa "../build/ios/ipa/only-bible-app.ipa" --automatic_release --submit_for_review
```
-
-## TODO
-
-* Improve Paging in dark mode
\ No newline at end of file