~repos /only-bible-app
git clone https://pyrossh.dev/repos/only-bible-app.git
The only bible app you will ever need. No ads. No in-app purchases. No distractions.
595e6663
—
pyrossh 1 year ago
remove nightMode
- app/src/main/AndroidManifest.xml +0 -1
- app/src/main/java/dev/pyrossh/onlyBible/AppTheme.kt +5 -6
- app/src/main/java/dev/pyrossh/onlyBible/AppViewModel.kt +5 -11
- app/src/main/java/dev/pyrossh/onlyBible/MainActivity.kt +1 -3
- app/src/main/java/dev/pyrossh/onlyBible/composables/TextSettingsBottomSheet.kt +13 -11
- app/src/main/java/dev/pyrossh/onlyBible/composables/VerseText.kt +1 -2
app/src/main/AndroidManifest.xml
CHANGED
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
android:supportsRtl="true">
|
|
18
18
|
<activity
|
|
19
19
|
android:name=".MainActivity"
|
|
20
|
-
android:configChanges="uiMode"
|
|
21
20
|
android:exported="true"
|
|
22
21
|
android:theme="@style/Theme.MaterialComponents.DayNight.NoActionBar">
|
|
23
22
|
<intent-filter>
|
app/src/main/java/dev/pyrossh/onlyBible/AppTheme.kt
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
package dev.pyrossh.onlyBible
|
|
2
2
|
|
|
3
|
-
import android.app.UiModeManager
|
|
4
3
|
import androidx.compose.foundation.isSystemInDarkTheme
|
|
5
4
|
import androidx.compose.material3.MaterialTheme
|
|
6
5
|
import androidx.compose.material3.dynamicDarkColorScheme
|
|
@@ -45,18 +44,18 @@ val darkHighlights = listOf(
|
|
|
45
44
|
Color(0xFFFF66B3),
|
|
46
45
|
)
|
|
47
46
|
|
|
48
|
-
fun isLightTheme(
|
|
47
|
+
fun isLightTheme(themeType: ThemeType, isSystemDark: Boolean): Boolean {
|
|
49
|
-
return
|
|
48
|
+
return themeType == ThemeType.Light || (themeType == ThemeType.Auto && !isSystemDark)
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
@Composable
|
|
53
52
|
fun AppTheme(
|
|
54
|
-
|
|
53
|
+
themeType: ThemeType,
|
|
55
54
|
content: @Composable() () -> Unit
|
|
56
55
|
) {
|
|
57
56
|
val context = LocalContext.current
|
|
58
57
|
val systemUiController = rememberSystemUiController()
|
|
59
|
-
val colorScheme = if (isLightTheme(
|
|
58
|
+
val colorScheme = if (isLightTheme(themeType, isSystemInDarkTheme()))
|
|
60
59
|
dynamicLightColorScheme(context).copy(
|
|
61
60
|
onSurface = Color.Black,
|
|
62
61
|
outline = Color.LightGray,
|
|
@@ -67,7 +66,7 @@ fun AppTheme(
|
|
|
67
66
|
surface = Color(0xFF090F12),
|
|
68
67
|
outline = Color(0xAA5D4979),
|
|
69
68
|
)
|
|
70
|
-
LaunchedEffect(key1 =
|
|
69
|
+
LaunchedEffect(key1 = themeType) {
|
|
71
70
|
systemUiController.setSystemBarsColor(
|
|
72
71
|
color = colorScheme.background
|
|
73
72
|
)
|
app/src/main/java/dev/pyrossh/onlyBible/AppViewModel.kt
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
package dev.pyrossh.onlyBible
|
|
2
2
|
|
|
3
|
-
import android.app.UiModeManager
|
|
4
3
|
import android.content.Context
|
|
5
4
|
import android.content.Context.MODE_PRIVATE
|
|
6
|
-
import android.content.Context.UI_MODE_SERVICE
|
|
7
5
|
import android.content.Intent
|
|
8
6
|
import android.text.Html
|
|
9
7
|
import androidx.compose.runtime.getValue
|
|
@@ -71,7 +69,7 @@ class AppViewModel : ViewModel() {
|
|
|
71
69
|
var fontSizeDelta by mutableIntStateOf(0)
|
|
72
70
|
var fontBoldEnabled by mutableStateOf(false)
|
|
73
71
|
var lineSpacingDelta by mutableIntStateOf(0)
|
|
74
|
-
var
|
|
72
|
+
var themeType by mutableStateOf(ThemeType.Auto)
|
|
75
73
|
val selectedVerses = MutableStateFlow(listOf<Verse>())
|
|
76
74
|
val searchText = MutableStateFlow("")
|
|
77
75
|
|
|
@@ -97,12 +95,6 @@ class AppViewModel : ViewModel() {
|
|
|
97
95
|
searchText.value = text
|
|
98
96
|
}
|
|
99
97
|
|
|
100
|
-
fun setApplicationNightMode(context: Context, v: Int) {
|
|
101
|
-
val uiModeManager = context.getSystemService(UI_MODE_SERVICE) as UiModeManager
|
|
102
|
-
uiModeManager.setApplicationNightMode(v)
|
|
103
|
-
nightMode = v
|
|
104
|
-
}
|
|
105
|
-
|
|
106
98
|
fun setSelectedVerses(verses: List<Verse>) {
|
|
107
99
|
selectedVerses.value = verses
|
|
108
100
|
}
|
|
@@ -127,7 +119,9 @@ class AppViewModel : ViewModel() {
|
|
|
127
119
|
fontSizeDelta = prefs.getInt("fontSizeDelta", 0)
|
|
128
120
|
fontBoldEnabled = prefs.getBoolean("fontBoldEnabled", false)
|
|
129
121
|
lineSpacingDelta = prefs.getInt("lineSpacingDelta", 0)
|
|
122
|
+
themeType = ThemeType.valueOf(
|
|
130
|
-
|
|
123
|
+
prefs.getString("themeType", ThemeType.Auto.name) ?: ThemeType.Auto.name
|
|
124
|
+
)
|
|
131
125
|
highlightedVerses.value = JSONObject(prefs.getString("highlightedVerses", "{}") ?: "{}")
|
|
132
126
|
val localBible = bibles.find { it.filename() == bibleFileName } ?: bibles.first()
|
|
133
127
|
loadBible(localBible, context)
|
|
@@ -181,7 +175,7 @@ class AppViewModel : ViewModel() {
|
|
|
181
175
|
putInt("fontSizeDelta", fontSizeDelta)
|
|
182
176
|
putBoolean("fontBoldEnabled", fontBoldEnabled)
|
|
183
177
|
putInt("lineSpacingDelta", lineSpacingDelta)
|
|
184
|
-
|
|
178
|
+
putString("themeType", themeType.name)
|
|
185
179
|
putString("highlightedVerses", highlightedVerses.value.toString())
|
|
186
180
|
apply()
|
|
187
181
|
commit()
|
app/src/main/java/dev/pyrossh/onlyBible/MainActivity.kt
CHANGED
|
@@ -21,9 +21,7 @@ class MainActivity : ComponentActivity() {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
setContent {
|
|
24
|
-
AppTheme(
|
|
25
|
-
|
|
24
|
+
AppTheme(themeType = model.themeType) {
|
|
26
|
-
) {
|
|
27
25
|
AppHost(model = model)
|
|
28
26
|
}
|
|
29
27
|
}
|
app/src/main/java/dev/pyrossh/onlyBible/composables/TextSettingsBottomSheet.kt
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
package dev.pyrossh.onlyBible.composables
|
|
2
2
|
|
|
3
|
-
import android.app.UiModeManager.MODE_NIGHT_AUTO
|
|
4
|
-
import android.app.UiModeManager.MODE_NIGHT_NO
|
|
5
|
-
import android.app.UiModeManager.MODE_NIGHT_YES
|
|
6
3
|
import android.view.SoundEffectConstants
|
|
7
4
|
import androidx.compose.foundation.BorderStroke
|
|
8
5
|
import androidx.compose.foundation.background
|
|
@@ -42,6 +39,7 @@ import androidx.compose.ui.unit.dp
|
|
|
42
39
|
import androidx.compose.ui.unit.sp
|
|
43
40
|
import dev.pyrossh.onlyBible.AppViewModel
|
|
44
41
|
import dev.pyrossh.onlyBible.FontType
|
|
42
|
+
import dev.pyrossh.onlyBible.ThemeType
|
|
45
43
|
import kotlinx.coroutines.launch
|
|
46
44
|
|
|
47
45
|
@Composable
|
|
@@ -237,17 +235,17 @@ fun TextSettingsBottomSheet(
|
|
|
237
235
|
horizontalArrangement = Arrangement.SpaceBetween,
|
|
238
236
|
verticalAlignment = Alignment.CenterVertically,
|
|
239
237
|
) {
|
|
240
|
-
|
|
238
|
+
ThemeType.entries.map {
|
|
241
239
|
Surface(
|
|
242
240
|
shape = RoundedCornerShape(8.dp),
|
|
243
|
-
border = if (model.
|
|
241
|
+
border = if (model.themeType == it) BorderStroke(
|
|
244
242
|
2.dp, MaterialTheme.colorScheme.primary
|
|
245
243
|
) else null,
|
|
246
|
-
color = if (model.
|
|
244
|
+
color = if (model.themeType == it)
|
|
247
245
|
MaterialTheme.colorScheme.primary
|
|
248
246
|
else
|
|
249
247
|
MaterialTheme.colorScheme.onSurface,
|
|
250
|
-
contentColor = if (model.
|
|
248
|
+
contentColor = if (model.themeType == it)
|
|
251
249
|
MaterialTheme.colorScheme.primary
|
|
252
250
|
else
|
|
253
251
|
MaterialTheme.colorScheme.onSurface,
|
|
@@ -260,12 +258,16 @@ fun TextSettingsBottomSheet(
|
|
|
260
258
|
view.playSoundEffect(SoundEffectConstants.CLICK)
|
|
261
259
|
scope.launch {
|
|
262
260
|
onDismiss()
|
|
263
|
-
model.
|
|
261
|
+
model.themeType = it
|
|
262
|
+
// android:configChanges="uiMode"
|
|
263
|
+
// min API 31
|
|
264
|
+
// val uiModeManager = context.getSystemService(UI_MODE_SERVICE) as UiModeManager
|
|
265
|
+
// uiModeManager.setApplicationNightMode(UiModeManager.MODE_NIGHT_AUTO)
|
|
264
266
|
}
|
|
265
267
|
}
|
|
266
268
|
) {
|
|
267
269
|
when (it) {
|
|
268
|
-
|
|
270
|
+
ThemeType.Light -> Icon(
|
|
269
271
|
imageVector = Icons.Filled.LightMode,
|
|
270
272
|
contentDescription = "Light",
|
|
271
273
|
modifier = Modifier
|
|
@@ -273,7 +275,7 @@ fun TextSettingsBottomSheet(
|
|
|
273
275
|
.padding(12.dp)
|
|
274
276
|
)
|
|
275
277
|
|
|
276
|
-
|
|
278
|
+
ThemeType.Dark -> Icon(
|
|
277
279
|
imageVector = Icons.Filled.DarkMode,
|
|
278
280
|
contentDescription = "Dark",
|
|
279
281
|
modifier = Modifier
|
|
@@ -281,7 +283,7 @@ fun TextSettingsBottomSheet(
|
|
|
281
283
|
.padding(12.dp)
|
|
282
284
|
)
|
|
283
285
|
|
|
284
|
-
|
|
286
|
+
ThemeType.Auto -> Column(
|
|
285
287
|
modifier = Modifier.background(
|
|
286
288
|
color = MaterialTheme.colorScheme.background,
|
|
287
289
|
),
|
app/src/main/java/dev/pyrossh/onlyBible/composables/VerseText.kt
CHANGED
|
@@ -54,7 +54,6 @@ import androidx.compose.ui.unit.IntOffset
|
|
|
54
54
|
import androidx.compose.ui.unit.dp
|
|
55
55
|
import androidx.compose.ui.unit.sp
|
|
56
56
|
import androidx.compose.ui.window.Popup
|
|
57
|
-
import androidx.navigation.fragment.NavHostFragment
|
|
58
57
|
import dev.pyrossh.onlyBible.AppViewModel
|
|
59
58
|
import dev.pyrossh.onlyBible.ChapterScreenProps
|
|
60
59
|
import dev.pyrossh.onlyBible.FontType
|
|
@@ -80,7 +79,7 @@ fun VerseText(
|
|
|
80
79
|
mutableIntStateOf(0)
|
|
81
80
|
}
|
|
82
81
|
val selectedVerses by model.selectedVerses.collectAsState()
|
|
83
|
-
val isLight = isLightTheme(model.
|
|
82
|
+
val isLight = isLightTheme(model.themeType, isSystemInDarkTheme())
|
|
84
83
|
val buttonInteractionSource = remember { MutableInteractionSource() }
|
|
85
84
|
val isSelected = selectedVerses.contains(verse)
|
|
86
85
|
val highlightedColorIndex = model.getHighlightForVerse(verse)
|