~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.
715bdfa9
—
pyrossh 1 year ago
remove context in AppViewModel
- app/build.gradle.kts +0 -9
- app/src/main/AndroidManifest.xml +2 -11
- app/src/main/assets/bibles/en_kjv.txt +1 -1
- app/src/main/java/dev/pyrossh/onlyBible/AppViewModel.kt +3 -6
- app/src/main/java/dev/pyrossh/onlyBible/composables/TextSettingsBottomSheet.kt +3 -1
- app/src/main/java/dev/pyrossh/onlyBible/composables/VerseHeading.kt +1 -1
app/build.gradle.kts
CHANGED
|
@@ -60,12 +60,6 @@ android {
|
|
|
60
60
|
buildFeatures {
|
|
61
61
|
compose = true
|
|
62
62
|
buildConfig = true
|
|
63
|
-
|
|
64
|
-
testOptions {
|
|
65
|
-
emulatorControl {
|
|
66
|
-
enable = true
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
63
|
}
|
|
70
64
|
packaging {
|
|
71
65
|
resources {
|
|
@@ -75,9 +69,6 @@ android {
|
|
|
75
69
|
kotlinOptions {
|
|
76
70
|
jvmTarget = JavaLanguageVersion.of(17).toString()
|
|
77
71
|
}
|
|
78
|
-
androidResources {
|
|
79
|
-
generateLocaleConfig = true
|
|
80
|
-
}
|
|
81
72
|
}
|
|
82
73
|
|
|
83
74
|
composeCompiler {
|
app/src/main/AndroidManifest.xml
CHANGED
|
@@ -14,25 +14,16 @@
|
|
|
14
14
|
android:label="@string/app_name"
|
|
15
15
|
android:icon="@mipmap/ic_launcher"
|
|
16
16
|
android:roundIcon="@mipmap/ic_launcher_round"
|
|
17
|
-
android:supportsRtl="true"
|
|
17
|
+
android:supportsRtl="true">
|
|
18
|
-
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar">
|
|
19
18
|
<activity
|
|
20
19
|
android:name=".MainActivity"
|
|
21
20
|
android:configChanges="uiMode"
|
|
22
21
|
android:exported="true"
|
|
23
|
-
android:theme="@style/Theme.
|
|
22
|
+
android:theme="@style/Theme.MaterialComponents.DayNight.NoActionBar">
|
|
24
23
|
<intent-filter>
|
|
25
24
|
<action android:name="android.intent.action.MAIN" />
|
|
26
25
|
<category android:name="android.intent.category.LAUNCHER" />
|
|
27
26
|
</intent-filter>
|
|
28
27
|
</activity>
|
|
29
|
-
<service
|
|
30
|
-
android:name="androidx.appcompat.app.AppLocalesMetadataHolderService"
|
|
31
|
-
android:enabled="false"
|
|
32
|
-
android:exported="false">
|
|
33
|
-
<meta-data
|
|
34
|
-
android:name="autoStoreLocales"
|
|
35
|
-
android:value="true" />
|
|
36
|
-
</service>
|
|
37
28
|
</application>
|
|
38
29
|
</manifest>
|
app/src/main/assets/bibles/en_kjv.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Genesis|0|0|0|The History of Creation <br> (<a href="42:0:0">John 1:1–5</a>;<a href="57:10:1">Hebrews 11:1–3</a>)|In the beginning God created the heaven and the earth.
|
|
1
|
+
Genesis|0|0|0|The History of Creation <br> (<a href="42:0:0">John 1:1–5</a> ; <a href="57:10:1">Hebrews 11:1–3</a>)|In the beginning God created the heaven and the earth.
|
|
2
2
|
Genesis|0|0|1||And the earth was without form, and void; and darkness <em>was</em> upon the face of the deep. And the Spirit of God moved upon the face of the waters.
|
|
3
3
|
Genesis|0|0|2||And God said, Let there be light: and there was light.
|
|
4
4
|
Genesis|0|0|3||And God saw the light, that <em>it was</em> good: and God divided the light from the darkness.
|
app/src/main/java/dev/pyrossh/onlyBible/AppViewModel.kt
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
package dev.pyrossh.onlyBible
|
|
2
2
|
|
|
3
|
-
import android.app.Application
|
|
4
3
|
import android.app.UiModeManager
|
|
5
4
|
import android.content.Context
|
|
6
5
|
import android.content.Context.MODE_PRIVATE
|
|
@@ -12,7 +11,7 @@ import androidx.compose.runtime.getValue
|
|
|
12
11
|
import androidx.compose.runtime.mutableIntStateOf
|
|
13
12
|
import androidx.compose.runtime.mutableStateOf
|
|
14
13
|
import androidx.compose.runtime.setValue
|
|
15
|
-
import androidx.lifecycle.
|
|
14
|
+
import androidx.lifecycle.ViewModel
|
|
16
15
|
import androidx.lifecycle.viewModelScope
|
|
17
16
|
import com.microsoft.cognitiveservices.speech.SpeechConfig
|
|
18
17
|
import com.microsoft.cognitiveservices.speech.SpeechSynthesisEventArgs
|
|
@@ -34,9 +33,7 @@ import kotlinx.coroutines.launch
|
|
|
34
33
|
import org.json.JSONObject
|
|
35
34
|
import java.io.IOException
|
|
36
35
|
|
|
37
|
-
class AppViewModel
|
|
36
|
+
class AppViewModel : ViewModel() {
|
|
38
|
-
private val context
|
|
39
|
-
get() = getApplication<Application>()
|
|
40
37
|
val speechService = SpeechSynthesizer(
|
|
41
38
|
SpeechConfig.fromSubscription(
|
|
42
39
|
BuildConfig.subscriptionKey,
|
|
@@ -128,7 +125,7 @@ class AppViewModel(application: Application) : AndroidViewModel(application) {
|
|
|
128
125
|
showBottomSheet = false
|
|
129
126
|
}
|
|
130
127
|
|
|
131
|
-
fun setApplicationNightMode(v: Int) {
|
|
128
|
+
fun setApplicationNightMode(context: Context, v: Int) {
|
|
132
129
|
val uiModeManager = context.getSystemService(UI_MODE_SERVICE) as UiModeManager
|
|
133
130
|
uiModeManager.setApplicationNightMode(v)
|
|
134
131
|
nightMode = v
|
app/src/main/java/dev/pyrossh/onlyBible/composables/TextSettingsBottomSheet.kt
CHANGED
|
@@ -35,6 +35,7 @@ import androidx.compose.runtime.Composable
|
|
|
35
35
|
import androidx.compose.runtime.rememberCoroutineScope
|
|
36
36
|
import androidx.compose.ui.Alignment
|
|
37
37
|
import androidx.compose.ui.Modifier
|
|
38
|
+
import androidx.compose.ui.platform.LocalContext
|
|
38
39
|
import androidx.compose.ui.platform.LocalView
|
|
39
40
|
import androidx.compose.ui.text.TextStyle
|
|
40
41
|
import androidx.compose.ui.text.font.FontWeight
|
|
@@ -49,6 +50,7 @@ import kotlinx.coroutines.launch
|
|
|
49
50
|
@OptIn(ExperimentalMaterial3Api::class)
|
|
50
51
|
fun TextSettingsBottomSheet(model: AppViewModel = viewModel()) {
|
|
51
52
|
val view = LocalView.current
|
|
53
|
+
val context = LocalContext.current
|
|
52
54
|
val scope = rememberCoroutineScope()
|
|
53
55
|
val sheetState = rememberModalBottomSheetState()
|
|
54
56
|
return ModalBottomSheet(
|
|
@@ -268,7 +270,7 @@ fun TextSettingsBottomSheet(model: AppViewModel = viewModel()) {
|
|
|
268
270
|
scope.launch {
|
|
269
271
|
sheetState.hide()
|
|
270
272
|
model.closeSheet()
|
|
271
|
-
model.setApplicationNightMode(it)
|
|
273
|
+
model.setApplicationNightMode(context, it)
|
|
272
274
|
}
|
|
273
275
|
}
|
|
274
276
|
) {
|
app/src/main/java/dev/pyrossh/onlyBible/composables/VerseHeading.kt
CHANGED
|
@@ -30,7 +30,7 @@ fun VerseHeading(
|
|
|
30
30
|
) {
|
|
31
31
|
val view = LocalView.current
|
|
32
32
|
Text(
|
|
33
|
-
modifier = Modifier.padding(bottom =
|
|
33
|
+
modifier = Modifier.padding(bottom = 12.dp),
|
|
34
34
|
style = TextStyle(
|
|
35
35
|
fontFamily = fontType.family(),
|
|
36
36
|
fontSize = (16 + fontSizeDelta).sp,
|