~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.
af18112d
—
Peter John 1 year ago
fix locale
- app/build.gradle.kts +19 -10
- app/src/main/AndroidManifest.xml +9 -2
- app/src/main/assets/bibles/{Bengali.txt → Bangla.txt} +0 -0
- app/src/main/assets/bibles/{Oriya.txt → Odia.txt} +0 -0
- app/src/main/java/dev/pyrossh/onlyBible/AppDrawer.kt +51 -18
- app/src/main/java/dev/pyrossh/onlyBible/AppViewModel.kt +21 -21
- app/src/main/java/dev/pyrossh/onlyBible/ChapterScreen.kt +7 -4
- app/src/main/java/dev/pyrossh/onlyBible/MainActivity.kt +10 -2
- app/src/main/java/dev/pyrossh/onlyBible/domain/Bible.kt +0 -34
- app/src/main/java/dev/pyrossh/onlyBible/domain/Verse.kt +2 -3
- app/src/main/res/resources.properties +1 -0
- app/src/main/res/values-bn/strings.xml +8 -0
- app/src/main/res/values-gu/strings.xml +8 -0
- app/src/main/res/values-hi/strings.xml +7 -0
- app/src/main/res/values-kn/strings.xml +8 -0
- app/src/main/res/values-ml/strings.xml +8 -0
- app/src/main/res/values-ne/strings.xml +7 -0
- app/src/main/res/values-or/strings.xml +8 -0
- app/src/main/res/values-pa/strings.xml +8 -0
- app/src/main/res/values-ta/strings.xml +8 -0
- app/src/main/res/values-te/strings.xml +8 -0
- app/src/main/res/values/strings.xml +4 -0
- gradle/libs.versions.toml +9 -4
app/build.gradle.kts
CHANGED
|
@@ -15,7 +15,7 @@ android {
|
|
|
15
15
|
|
|
16
16
|
defaultConfig {
|
|
17
17
|
applicationId = "dev.pyrossh.onlyBible"
|
|
18
|
-
minSdk =
|
|
18
|
+
minSdk = 33
|
|
19
19
|
targetSdk = 34
|
|
20
20
|
versionCode = 1
|
|
21
21
|
versionName = "1.0"
|
|
@@ -24,6 +24,7 @@ android {
|
|
|
24
24
|
vectorDrawables {
|
|
25
25
|
useSupportLibrary = true
|
|
26
26
|
}
|
|
27
|
+
resourceConfigurations.plus(listOf("ta","en", "hi","ml","fr"))
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
buildTypes {
|
|
@@ -51,6 +52,9 @@ android {
|
|
|
51
52
|
kotlinOptions {
|
|
52
53
|
jvmTarget = JavaLanguageVersion.of(11).toString()
|
|
53
54
|
}
|
|
55
|
+
androidResources {
|
|
56
|
+
generateLocaleConfig = true
|
|
57
|
+
}
|
|
54
58
|
}
|
|
55
59
|
|
|
56
60
|
composeCompiler {
|
|
@@ -72,20 +76,25 @@ dependencies {
|
|
|
72
76
|
implementation(libs.androidx.navigation.fragment.ktx)
|
|
73
77
|
implementation(libs.androidx.navigation.ui.ktx)
|
|
74
78
|
implementation(libs.androidx.navigation.compose)
|
|
75
|
-
testImplementation(libs.junit)
|
|
76
|
-
androidTestImplementation(libs.androidx.junit)
|
|
77
|
-
androidTestImplementation(libs.androidx.espresso.core)
|
|
78
|
-
androidTestImplementation(platform(libs.androidx.compose.bom))
|
|
79
|
-
androidTestImplementation(libs.androidx.ui.test.junit4)
|
|
80
|
-
debugImplementation(libs.androidx.ui.tooling)
|
|
81
|
-
debugImplementation(libs.androidx.ui.test.manifest)
|
|
82
79
|
implementation(libs.androidx.foundation)
|
|
83
80
|
implementation(libs.accompanist.systemuicontroller)
|
|
84
81
|
implementation(libs.androidx.ui.text.google.fonts)
|
|
85
|
-
implementation(libs.client.sdk)
|
|
82
|
+
implementation(libs.speech.client.sdk)
|
|
86
83
|
implementation(libs.kotlinx.coroutines.core)
|
|
87
84
|
implementation(libs.androidx.datastore.preferences)
|
|
88
85
|
implementation(libs.androidx.core.splashscreen)
|
|
89
|
-
implementation(libs.compose.remember.preference)
|
|
90
86
|
implementation(libs.androidx.lifecycle.viewmodel.compose)
|
|
87
|
+
implementation(libs.androidx.appcompat)
|
|
88
|
+
implementation(libs.androidx.appcompat.resources)
|
|
89
|
+
implementation(libs.androidx.appsearch)
|
|
90
|
+
implementation(libs.androidx.appsearch.local.storage)
|
|
91
|
+
implementation(libs.androidx.appsearch.platform.storage)
|
|
92
|
+
|
|
93
|
+
testImplementation(libs.junit)
|
|
94
|
+
androidTestImplementation(libs.androidx.junit)
|
|
95
|
+
androidTestImplementation(libs.androidx.espresso.core)
|
|
96
|
+
androidTestImplementation(platform(libs.androidx.compose.bom))
|
|
97
|
+
androidTestImplementation(libs.androidx.ui.test.junit4)
|
|
98
|
+
debugImplementation(libs.androidx.ui.tooling)
|
|
99
|
+
debugImplementation(libs.androidx.ui.test.manifest)
|
|
91
100
|
}
|
app/src/main/AndroidManifest.xml
CHANGED
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
android:icon="@mipmap/ic_launcher"
|
|
9
9
|
android:roundIcon="@mipmap/ic_launcher_round"
|
|
10
10
|
android:supportsRtl="true"
|
|
11
|
-
android:theme="@style/Theme.BibleAppSplash"
|
|
11
|
+
android:theme="@style/Theme.BibleAppSplash">
|
|
12
|
-
>
|
|
13
12
|
<activity
|
|
14
13
|
android:name=".MainActivity"
|
|
15
14
|
android:exported="true"
|
|
@@ -21,5 +20,13 @@
|
|
|
21
20
|
<category android:name="android.intent.category.LAUNCHER" />
|
|
22
21
|
</intent-filter>
|
|
23
22
|
</activity>
|
|
23
|
+
<service
|
|
24
|
+
android:name="androidx.appcompat.app.AppLocalesMetadataHolderService"
|
|
25
|
+
android:enabled="false"
|
|
26
|
+
android:exported="false">
|
|
27
|
+
<meta-data
|
|
28
|
+
android:name="autoStoreLocales"
|
|
29
|
+
android:value="true" />
|
|
30
|
+
</service>
|
|
24
31
|
</application>
|
|
25
32
|
</manifest>
|
app/src/main/assets/bibles/{Bengali.txt → Bangla.txt}
RENAMED
|
File without changes
|
app/src/main/assets/bibles/{Oriya.txt → Odia.txt}
RENAMED
|
File without changes
|
app/src/main/java/dev/pyrossh/onlyBible/AppDrawer.kt
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package dev.pyrossh.onlyBible
|
|
2
2
|
|
|
3
|
+
import android.app.LocaleConfig
|
|
3
4
|
import androidx.compose.foundation.layout.Arrangement
|
|
4
5
|
import androidx.compose.foundation.layout.Column
|
|
5
6
|
import androidx.compose.foundation.layout.PaddingValues
|
|
@@ -12,7 +13,6 @@ import androidx.compose.foundation.lazy.grid.GridItemSpan
|
|
|
12
13
|
import androidx.compose.foundation.lazy.grid.LazyGridItemScope
|
|
13
14
|
import androidx.compose.foundation.lazy.grid.LazyGridScope
|
|
14
15
|
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
|
15
|
-
import androidx.compose.foundation.lazy.grid.items
|
|
16
16
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
17
17
|
import androidx.compose.material.icons.Icons
|
|
18
18
|
import androidx.compose.material.icons.filled.Close
|
|
@@ -38,10 +38,10 @@ import androidx.compose.ui.text.TextStyle
|
|
|
38
38
|
import androidx.compose.ui.text.font.FontWeight
|
|
39
39
|
import androidx.compose.ui.unit.dp
|
|
40
40
|
import androidx.compose.ui.unit.sp
|
|
41
|
-
import dev.pyrossh.onlyBible.domain.Bible
|
|
42
41
|
import dev.pyrossh.onlyBible.domain.Verse
|
|
43
42
|
import kotlinx.coroutines.Job
|
|
44
43
|
import kotlinx.coroutines.launch
|
|
44
|
+
import java.util.Locale
|
|
45
45
|
|
|
46
46
|
enum class MenuType {
|
|
47
47
|
Bible,
|
|
@@ -100,6 +100,7 @@ fun AppDrawer(
|
|
|
100
100
|
.padding(bottom = 16.dp),
|
|
101
101
|
) {
|
|
102
102
|
if (menuType == MenuType.Bible) {
|
|
103
|
+
val locales = LocaleConfig(context).supportedLocales!!
|
|
103
104
|
LazyVerticalGrid(
|
|
104
105
|
modifier = Modifier.fillMaxSize(),
|
|
105
106
|
verticalArrangement = Arrangement.spacedBy(10.dp),
|
|
@@ -126,11 +127,19 @@ fun AppDrawer(
|
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
129
|
}
|
|
129
|
-
items(
|
|
130
|
+
items(locales.size()) {
|
|
131
|
+
val loc = locales[it]
|
|
132
|
+
QuickButton(
|
|
133
|
+
title = locales[it].getDisplayName(Locale.ENGLISH),
|
|
134
|
+
subtitle = if (loc.language == "en")
|
|
135
|
+
"KJV"
|
|
136
|
+
else
|
|
130
|
-
|
|
137
|
+
locales[it].getDisplayName(loc),
|
|
131
|
-
|
|
138
|
+
) {
|
|
132
139
|
scope.launch {
|
|
133
140
|
drawerState.close()
|
|
141
|
+
}.invokeOnCompletion {
|
|
142
|
+
setLocale(context, loc)
|
|
134
143
|
}
|
|
135
144
|
}
|
|
136
145
|
}
|
|
@@ -150,7 +159,7 @@ fun AppDrawer(
|
|
|
150
159
|
verticalAlignment = Alignment.CenterVertically,
|
|
151
160
|
) {
|
|
152
161
|
Text(
|
|
153
|
-
text =
|
|
162
|
+
text = context.getString(R.string.old_testament),
|
|
154
163
|
fontSize = 18.sp,
|
|
155
164
|
fontWeight = FontWeight.W500,
|
|
156
165
|
)
|
|
@@ -164,7 +173,10 @@ fun AppDrawer(
|
|
|
164
173
|
}
|
|
165
174
|
}
|
|
166
175
|
items(39) { b ->
|
|
176
|
+
QuickButton(
|
|
167
|
-
|
|
177
|
+
title = shortName(model.bookNames[b]),
|
|
178
|
+
subtitle = null,
|
|
179
|
+
) {
|
|
168
180
|
bookIndex = b
|
|
169
181
|
menuType = MenuType.Chapter
|
|
170
182
|
}
|
|
@@ -176,7 +188,7 @@ fun AppDrawer(
|
|
|
176
188
|
verticalAlignment = Alignment.CenterVertically,
|
|
177
189
|
) {
|
|
178
190
|
Text(
|
|
179
|
-
text =
|
|
191
|
+
text = context.getString(R.string.new_testament),
|
|
180
192
|
fontSize = 18.sp,
|
|
181
193
|
fontWeight = FontWeight.W500
|
|
182
194
|
)
|
|
@@ -184,7 +196,10 @@ fun AppDrawer(
|
|
|
184
196
|
}
|
|
185
197
|
items(27) { i ->
|
|
186
198
|
val b = 39 + i
|
|
199
|
+
QuickButton(
|
|
187
|
-
|
|
200
|
+
title = shortName(model.bookNames[b]),
|
|
201
|
+
subtitle = null,
|
|
202
|
+
) {
|
|
188
203
|
bookIndex = b
|
|
189
204
|
menuType = MenuType.Chapter
|
|
190
205
|
}
|
|
@@ -221,7 +236,10 @@ fun AppDrawer(
|
|
|
221
236
|
}
|
|
222
237
|
|
|
223
238
|
items(Verse.chapterSizes[bookIndex]) { c ->
|
|
239
|
+
QuickButton(
|
|
224
|
-
|
|
240
|
+
title = "${c + 1}",
|
|
241
|
+
subtitle = null,
|
|
242
|
+
) {
|
|
225
243
|
scope.launch {
|
|
226
244
|
navigateToChapter(
|
|
227
245
|
ChapterScreenProps(
|
|
@@ -244,18 +262,33 @@ fun AppDrawer(
|
|
|
244
262
|
}
|
|
245
263
|
|
|
246
264
|
@Composable
|
|
247
|
-
fun QuickButton(
|
|
265
|
+
fun QuickButton(title: String, subtitle: String?, onClick: () -> Unit) {
|
|
248
266
|
Button(
|
|
249
267
|
shape = RoundedCornerShape(2.dp),
|
|
250
268
|
contentPadding = PaddingValues(4.dp),
|
|
251
269
|
onClick = onClick
|
|
252
270
|
) {
|
|
271
|
+
Column(
|
|
272
|
+
horizontalAlignment = Alignment.CenterHorizontally,
|
|
273
|
+
modifier = Modifier.padding(vertical = 8.dp)
|
|
274
|
+
) {
|
|
253
|
-
|
|
275
|
+
Text(
|
|
254
|
-
|
|
276
|
+
style = TextStyle(
|
|
255
|
-
|
|
277
|
+
fontSize = 18.sp,
|
|
256
|
-
|
|
278
|
+
fontWeight = FontWeight.W500,
|
|
257
|
-
|
|
279
|
+
),
|
|
258
|
-
|
|
280
|
+
text = title,
|
|
259
|
-
|
|
281
|
+
)
|
|
282
|
+
if (!subtitle.isNullOrEmpty()) {
|
|
283
|
+
Text(
|
|
284
|
+
modifier = Modifier.padding(top = 8.dp),
|
|
285
|
+
style = TextStyle(
|
|
286
|
+
fontSize = 18.sp,
|
|
287
|
+
fontWeight = FontWeight.W500,
|
|
288
|
+
),
|
|
289
|
+
text = "($subtitle)",
|
|
290
|
+
)
|
|
291
|
+
}
|
|
292
|
+
}
|
|
260
293
|
}
|
|
261
294
|
}
|
app/src/main/java/dev/pyrossh/onlyBible/AppViewModel.kt
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
package dev.pyrossh.onlyBible
|
|
2
2
|
|
|
3
3
|
import android.app.Application
|
|
4
|
+
import android.app.LocaleManager
|
|
4
5
|
import android.content.Context
|
|
5
6
|
import android.content.Intent
|
|
7
|
+
import android.os.Build
|
|
8
|
+
import android.os.LocaleList
|
|
9
|
+
import androidx.appcompat.app.AppCompatDelegate
|
|
6
10
|
import androidx.compose.foundation.lazy.LazyListState
|
|
7
11
|
import androidx.compose.runtime.MutableState
|
|
8
12
|
import androidx.compose.runtime.getValue
|
|
9
13
|
import androidx.compose.runtime.mutableIntStateOf
|
|
10
14
|
import androidx.compose.runtime.mutableStateOf
|
|
11
15
|
import androidx.compose.runtime.setValue
|
|
16
|
+
import androidx.core.os.LocaleListCompat
|
|
12
17
|
import androidx.datastore.preferences.core.Preferences
|
|
13
18
|
import androidx.datastore.preferences.core.booleanPreferencesKey
|
|
14
19
|
import androidx.datastore.preferences.core.edit
|
|
@@ -19,7 +24,6 @@ import androidx.lifecycle.AndroidViewModel
|
|
|
19
24
|
import androidx.lifecycle.viewModelScope
|
|
20
25
|
import com.microsoft.cognitiveservices.speech.SpeechConfig
|
|
21
26
|
import com.microsoft.cognitiveservices.speech.SpeechSynthesizer
|
|
22
|
-
import dev.pyrossh.onlyBible.domain.Bible
|
|
23
27
|
import dev.pyrossh.onlyBible.domain.Verse
|
|
24
28
|
import kotlinx.coroutines.CoroutineScope
|
|
25
29
|
import kotlinx.coroutines.Dispatchers
|
|
@@ -29,6 +33,7 @@ import kotlinx.coroutines.flow.map
|
|
|
29
33
|
import kotlinx.coroutines.launch
|
|
30
34
|
import kotlinx.coroutines.withContext
|
|
31
35
|
import java.io.IOException
|
|
36
|
+
import java.util.Locale
|
|
32
37
|
|
|
33
38
|
internal val Context.dataStore by preferencesDataStore(name = "onlyBible")
|
|
34
39
|
|
|
@@ -46,14 +51,6 @@ class AppViewModel(application: Application) : AndroidViewModel(application) {
|
|
|
46
51
|
var verses by mutableStateOf(listOf<Verse>())
|
|
47
52
|
var bookNames by mutableStateOf(listOf<String>())
|
|
48
53
|
var showBottomSheet by mutableStateOf(false)
|
|
49
|
-
var bibleName by preferenceMutableState(
|
|
50
|
-
coroutineScope = viewModelScope,
|
|
51
|
-
context = context,
|
|
52
|
-
keyName = "bibleName",
|
|
53
|
-
initialValue = "English",
|
|
54
|
-
defaultValue = "English",
|
|
55
|
-
getPreferencesKey = ::stringPreferencesKey,
|
|
56
|
-
)
|
|
57
54
|
var bookIndex by preferenceMutableState(
|
|
58
55
|
coroutineScope = viewModelScope,
|
|
59
56
|
context = context,
|
|
@@ -109,14 +106,8 @@ class AppViewModel(application: Application) : AndroidViewModel(application) {
|
|
|
109
106
|
showBottomSheet = false
|
|
110
107
|
}
|
|
111
108
|
|
|
112
|
-
fun setBibleName(context: Context, b: Bible) {
|
|
113
|
-
bibleName = b.name
|
|
114
|
-
loadBible(context)
|
|
115
|
-
}
|
|
116
|
-
|
|
117
109
|
fun initData(p: Preferences) {
|
|
118
|
-
uiMode
|
|
110
|
+
uiMode = context.applicationContext.resources.configuration.uiMode
|
|
119
|
-
bibleName = p[stringPreferencesKey("bibleName")] ?: "English"
|
|
120
111
|
scrollState = LazyListState(
|
|
121
112
|
p[intPreferencesKey("scrollIndex")] ?: 0,
|
|
122
113
|
p[intPreferencesKey("scrollOffset")] ?: 0
|
|
@@ -127,17 +118,15 @@ class AppViewModel(application: Application) : AndroidViewModel(application) {
|
|
|
127
118
|
scrollState = LazyListState(0, 0)
|
|
128
119
|
}
|
|
129
120
|
|
|
130
|
-
fun loadBible(context: Context) {
|
|
121
|
+
fun loadBible(loc: Locale, context: Context) {
|
|
131
|
-
println("LoadBible")
|
|
132
122
|
viewModelScope.launch(Dispatchers.IO) {
|
|
133
123
|
launch(Dispatchers.Main) {
|
|
134
124
|
isLoading = true
|
|
135
125
|
isOnError = false
|
|
136
126
|
}
|
|
137
127
|
try {
|
|
138
|
-
val b = Bible.valueOf(bibleName)
|
|
139
128
|
val buffer =
|
|
140
|
-
context.assets.open("bibles/${
|
|
129
|
+
context.assets.open("bibles/${loc.getDisplayLanguage(Locale.ENGLISH)}.txt").bufferedReader()
|
|
141
130
|
val localVerses = buffer.readLines().filter { it.isNotEmpty() }.map {
|
|
142
131
|
val arr = it.split("|")
|
|
143
132
|
val bookName = arr[0]
|
|
@@ -147,7 +136,6 @@ class AppViewModel(application: Application) : AndroidViewModel(application) {
|
|
|
147
136
|
val heading = arr[4]
|
|
148
137
|
val verseText = arr.subList(5, arr.size).joinToString("|")
|
|
149
138
|
Verse(
|
|
150
|
-
bible = b,
|
|
151
139
|
bookIndex = book,
|
|
152
140
|
bookName = bookName,
|
|
153
141
|
chapterIndex = chapter,
|
|
@@ -193,6 +181,18 @@ fun shareVerses(context: Context, verses: List<Verse>) {
|
|
|
193
181
|
context.startActivity(shareIntent)
|
|
194
182
|
}
|
|
195
183
|
|
|
184
|
+
fun setLocale(context: Context, loc: Locale) {
|
|
185
|
+
if (Build.VERSION.SDK_INT >= 33) {
|
|
186
|
+
val localeManager = context.getSystemService(LocaleManager::class.java)
|
|
187
|
+
localeManager.applicationLocales = LocaleList(loc)
|
|
188
|
+
} else {
|
|
189
|
+
// For this to work you need to extend MainActivity with AppCompatActivity
|
|
190
|
+
AppCompatDelegate.setApplicationLocales(
|
|
191
|
+
LocaleListCompat.forLanguageTags(loc.language)
|
|
192
|
+
)
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
196
|
private inline fun <reified T, reified NNT : T> preferenceMutableState(
|
|
197
197
|
coroutineScope: CoroutineScope,
|
|
198
198
|
context: Context,
|
app/src/main/java/dev/pyrossh/onlyBible/ChapterScreen.kt
CHANGED
|
@@ -72,7 +72,6 @@ import androidx.compose.ui.text.withStyle
|
|
|
72
72
|
import androidx.compose.ui.unit.dp
|
|
73
73
|
import androidx.compose.ui.unit.sp
|
|
74
74
|
import com.microsoft.cognitiveservices.speech.SpeechSynthesisEventArgs
|
|
75
|
-
import dev.pyrossh.onlyBible.domain.Bible
|
|
76
75
|
import dev.pyrossh.onlyBible.domain.Verse
|
|
77
76
|
import kotlinx.coroutines.Dispatchers
|
|
78
77
|
import kotlinx.coroutines.Job
|
|
@@ -162,6 +161,7 @@ fun ChapterScreen(
|
|
|
162
161
|
var isPlaying by rememberSaveable {
|
|
163
162
|
mutableStateOf(false)
|
|
164
163
|
}
|
|
164
|
+
var expanded by remember { mutableStateOf(false) }
|
|
165
165
|
DisposableEffect(Unit) {
|
|
166
166
|
val started = { _: Any, _: SpeechSynthesisEventArgs ->
|
|
167
167
|
isPlaying = true
|
|
@@ -226,7 +226,7 @@ fun ChapterScreen(
|
|
|
226
226
|
actions = {
|
|
227
227
|
TextButton(onClick = { openDrawer(MenuType.Bible, bookIndex) }) {
|
|
228
228
|
Text(
|
|
229
|
-
text =
|
|
229
|
+
text = context.getCurrentLocale().language.uppercase(),
|
|
230
230
|
style = TextStyle(
|
|
231
231
|
fontSize = 18.sp,
|
|
232
232
|
fontWeight = FontWeight.W500,
|
|
@@ -292,7 +292,9 @@ fun ChapterScreen(
|
|
|
292
292
|
} else {
|
|
293
293
|
scope.launch(Dispatchers.IO) {
|
|
294
294
|
for (v in selectedVerses.sortedBy { it.verseIndex }) {
|
|
295
|
-
model.speechService.StartSpeakingSsml(
|
|
295
|
+
model.speechService.StartSpeakingSsml(
|
|
296
|
+
v.toSSML(context.getString(R.string.voice)),
|
|
297
|
+
)
|
|
296
298
|
}
|
|
297
299
|
}
|
|
298
300
|
}
|
|
@@ -344,7 +346,8 @@ fun ChapterScreen(
|
|
|
344
346
|
onSwipeLeft = onSwipeLeft,
|
|
345
347
|
onSwipeRight = { onSwipeRight() },
|
|
346
348
|
)
|
|
349
|
+
}
|
|
347
|
-
|
|
350
|
+
) {
|
|
348
351
|
items(chapterVerses) { v ->
|
|
349
352
|
if (v.heading.isNotEmpty()) {
|
|
350
353
|
Text(
|
app/src/main/java/dev/pyrossh/onlyBible/MainActivity.kt
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
package dev.pyrossh.onlyBible
|
|
2
2
|
|
|
3
3
|
import android.animation.ObjectAnimator
|
|
4
|
+
import android.content.Context
|
|
4
5
|
import android.os.Bundle
|
|
5
6
|
import android.view.View
|
|
6
7
|
import android.view.animation.AccelerateInterpolator
|
|
@@ -15,6 +16,11 @@ import androidx.datastore.preferences.core.intPreferencesKey
|
|
|
15
16
|
import androidx.lifecycle.lifecycleScope
|
|
16
17
|
import kotlinx.coroutines.flow.first
|
|
17
18
|
import kotlinx.coroutines.launch
|
|
19
|
+
import java.util.Locale
|
|
20
|
+
|
|
21
|
+
fun Context.getCurrentLocale(): Locale {
|
|
22
|
+
return resources.configuration.locales.get(0)
|
|
23
|
+
}
|
|
18
24
|
|
|
19
25
|
class MainActivity : ComponentActivity() {
|
|
20
26
|
|
|
@@ -27,7 +33,7 @@ class MainActivity : ComponentActivity() {
|
|
|
27
33
|
lifecycleScope.launch {
|
|
28
34
|
val data = applicationContext.dataStore.data.first()
|
|
29
35
|
model.initData(data)
|
|
30
|
-
model.loadBible(applicationContext)
|
|
36
|
+
model.loadBible(applicationContext.getCurrentLocale(), applicationContext)
|
|
31
37
|
}
|
|
32
38
|
splashScreen.setKeepOnScreenCondition { model.isLoading }
|
|
33
39
|
splashScreen.setOnExitAnimationListener { viewProvider ->
|
|
@@ -47,6 +53,7 @@ class MainActivity : ComponentActivity() {
|
|
|
47
53
|
start()
|
|
48
54
|
}
|
|
49
55
|
}
|
|
56
|
+
|
|
50
57
|
addOnConfigurationChangedListener {
|
|
51
58
|
model.uiMode = it.uiMode
|
|
52
59
|
}
|
|
@@ -66,7 +73,8 @@ class MainActivity : ComponentActivity() {
|
|
|
66
73
|
applicationContext.dataStore.edit {
|
|
67
74
|
println("saveData ${model.scrollState.firstVisibleItemIndex}")
|
|
68
75
|
it[intPreferencesKey("scrollIndex")] = model.scrollState.firstVisibleItemIndex
|
|
69
|
-
it[intPreferencesKey("scrollOffset")] =
|
|
76
|
+
it[intPreferencesKey("scrollOffset")] =
|
|
77
|
+
model.scrollState.firstVisibleItemScrollOffset
|
|
70
78
|
}
|
|
71
79
|
}
|
|
72
80
|
}
|
app/src/main/java/dev/pyrossh/onlyBible/domain/Bible.kt
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
package dev.pyrossh.onlyBible.domain
|
|
2
|
-
|
|
3
|
-
import android.os.Parcelable
|
|
4
|
-
import kotlinx.parcelize.Parcelize
|
|
5
|
-
import kotlinx.serialization.Serializable
|
|
6
|
-
|
|
7
|
-
enum class BibleFamily {
|
|
8
|
-
English,
|
|
9
|
-
Indian,
|
|
10
|
-
European,
|
|
11
|
-
African;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
@Serializable
|
|
15
|
-
@Parcelize
|
|
16
|
-
enum class Bible(
|
|
17
|
-
val displayName: String,
|
|
18
|
-
val fileName: String,
|
|
19
|
-
val voiceName: String?,
|
|
20
|
-
val code: String,
|
|
21
|
-
val family: BibleFamily
|
|
22
|
-
) : Parcelable {
|
|
23
|
-
English("English", "English", "en-GB-RyanNeural", "en", BibleFamily.English),
|
|
24
|
-
Bengali("Bengali", "Bengali", "bn-IN-TanishaaNeural", "bn", BibleFamily.Indian),
|
|
25
|
-
Gujarati("Gujarati", "Gujarati", "gu-IN-DhwaniNeural", "gu", BibleFamily.Indian),
|
|
26
|
-
Hindi("Hindi", "Hindi", "hi-IN-SwaraNeural", "hi", BibleFamily.Indian),
|
|
27
|
-
Kannada("Kannada", "Kannada", "kn-IN-GaganNeural", "kn", BibleFamily.Indian),
|
|
28
|
-
Malayalam("Malayalam", "Malayalam", "ml-IN-SobhanaNeural", "ml", BibleFamily.Indian),
|
|
29
|
-
Nepali("Nepali", "Nepali", "ne-NP-HemkalaNeural", "ne", BibleFamily.Indian),
|
|
30
|
-
Oriya("Oriya", "Oriya", "or-IN-SubhasiniNeural", "or", BibleFamily.Indian),
|
|
31
|
-
Punjabi("Punjabi", "Punjabi", "pa-IN-OjasNeural", "pa", BibleFamily.Indian),
|
|
32
|
-
Tamil("Tamil", "Tamil", "ta-IN-PallaviNeural", "ta", BibleFamily.Indian),
|
|
33
|
-
Telugu("Telugu", "Telugu", "te-IN-ShrutiNeural", "te", BibleFamily.Indian),
|
|
34
|
-
}
|
app/src/main/java/dev/pyrossh/onlyBible/domain/Verse.kt
CHANGED
|
@@ -78,7 +78,6 @@ val engTitles = listOf(
|
|
|
78
78
|
@Serializable
|
|
79
79
|
@Parcelize
|
|
80
80
|
data class Verse(
|
|
81
|
-
val bible: Bible,
|
|
82
81
|
val bookIndex: Int,
|
|
83
82
|
val bookName: String,
|
|
84
83
|
val chapterIndex: Int,
|
|
@@ -87,10 +86,10 @@ data class Verse(
|
|
|
87
86
|
val text: String,
|
|
88
87
|
) : Parcelable {
|
|
89
88
|
|
|
90
|
-
fun toSSML(): String {
|
|
89
|
+
fun toSSML(voice: String): String {
|
|
91
90
|
return """
|
|
92
91
|
<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="en-US">
|
|
93
|
-
<voice name="$
|
|
92
|
+
<voice name="$voice">
|
|
94
93
|
$text
|
|
95
94
|
</voice>
|
|
96
95
|
</speak>
|
app/src/main/res/resources.properties
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
unqualifiedResLocale=en
|
app/src/main/res/values-bn/strings.xml
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<resources>
|
|
3
|
+
<string name="app_name">Only Bible</string>
|
|
4
|
+
<string name="old_testament">পুরানো ইচ্ছাপত্র</string>
|
|
5
|
+
<string name="new_testament">নববিধান</string>
|
|
6
|
+
<string name="settings">সেটিংস</string>
|
|
7
|
+
<string name="voice">bn-IN-TanishaaNeural</string>
|
|
8
|
+
</resources>
|
app/src/main/res/values-gu/strings.xml
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<resources>
|
|
3
|
+
<string name="app_name">Only Bible</string>
|
|
4
|
+
<string name="old_testament">ઓલ્ડ ટેસ્ટામેન્ટ</string>
|
|
5
|
+
<string name="new_testament">ન્યૂ વસિયતનામું</string>
|
|
6
|
+
<string name="settings">સેટિંગ્સ</string>
|
|
7
|
+
<string name="voice">gu-IN-DhwaniNeural</string>
|
|
8
|
+
</resources>
|
app/src/main/res/values-hi/strings.xml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<resources>
|
|
2
|
+
<string name="app_name">Only Bible</string>
|
|
3
|
+
<string name="old_testament">पुराना नियम</string>
|
|
4
|
+
<string name="new_testament">नया नियम</string>
|
|
5
|
+
<string name="settings">समायोजन</string>
|
|
6
|
+
<string name="voice">hi-IN-SwaraNeural</string>
|
|
7
|
+
</resources>
|
app/src/main/res/values-kn/strings.xml
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<resources>
|
|
3
|
+
<string name="app_name">Only Bible</string>
|
|
4
|
+
<string name="old_testament">ಹಳೆಯ ಒಡಂಬಡಿಕೆ</string>
|
|
5
|
+
<string name="new_testament">ಹೊಸ ಒಡಂಬಡಿಕೆಯು</string>
|
|
6
|
+
<string name="settings">ಸಂಯೋಜನೆಗಳು</string>
|
|
7
|
+
<string name="voice">kn-IN-GaganNeural</string>
|
|
8
|
+
</resources>
|
app/src/main/res/values-ml/strings.xml
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<resources>
|
|
3
|
+
<string name="app_name">Only Bible</string>
|
|
4
|
+
<string name="old_testament">പഴയ നിയമം</string>
|
|
5
|
+
<string name="new_testament">പുതിയ നിയമം</string>
|
|
6
|
+
<string name="settings">ക്രമീകരണങ്ങൾ</string>
|
|
7
|
+
<string name="voice">ml-IN-SobhanaNeural</string>
|
|
8
|
+
</resources>
|
app/src/main/res/values-ne/strings.xml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<resources>
|
|
2
|
+
<string name="app_name">Only Bible</string>
|
|
3
|
+
<string name="old_testament">पुरानो नियम</string>
|
|
4
|
+
<string name="new_testament">नयाँ नियम</string>
|
|
5
|
+
<string name="settings">सेटिङहरू</string>
|
|
6
|
+
<string name="voice">ne-NP-HemkalaNeural</string>
|
|
7
|
+
</resources>
|
app/src/main/res/values-or/strings.xml
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<resources>
|
|
3
|
+
<string name="app_name">Only Bible</string>
|
|
4
|
+
<string name="old_testament">ଓଲ୍ଡ ଷ୍ଟେଟାମେଣ୍ଟ</string>
|
|
5
|
+
<string name="new_testament">ନ୍ୟୁ ଷ୍ଟେଟାମେଣ୍ଟ</string>
|
|
6
|
+
<string name="settings">ସେଟିଂସମୂହ</string>
|
|
7
|
+
<string name="voice">or-IN-SubhasiniNeural</string>
|
|
8
|
+
</resources>
|
app/src/main/res/values-pa/strings.xml
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<resources>
|
|
3
|
+
<string name="app_name">Only Bible</string>
|
|
4
|
+
<string name="old_testament">ਪੁਰਾਣੇ ਨੇਮ</string>
|
|
5
|
+
<string name="new_testament">ਨਵਾਂ ਨੇਮ</string>
|
|
6
|
+
<string name="settings">ਸੈਟਿੰਗਾਂ</string>
|
|
7
|
+
<string name="voice">pa-IN-OjasNeural</string>
|
|
8
|
+
</resources>
|
app/src/main/res/values-ta/strings.xml
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<resources>
|
|
3
|
+
<string name="app_name">Only Bible</string>
|
|
4
|
+
<string name="old_testament">பழைய ஏற்பாடு</string>
|
|
5
|
+
<string name="new_testament">புதிய ஏற்பாடு</string>
|
|
6
|
+
<string name="settings">அமைப்புகள்</string>
|
|
7
|
+
<string name="voice">ta-IN-PallaviNeural</string>
|
|
8
|
+
</resources>
|
app/src/main/res/values-te/strings.xml
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<resources>
|
|
3
|
+
<string name="app_name">Only Bible</string>
|
|
4
|
+
<string name="old_testament">పాత నిబంధన</string>
|
|
5
|
+
<string name="new_testament">కొత్త నిబంధన</string>
|
|
6
|
+
<string name="settings">సెట్టింగ్\\u200Cలు</string>
|
|
7
|
+
<string name="voice">te-IN-ShrutiNeural</string>
|
|
8
|
+
</resources>
|
app/src/main/res/values/strings.xml
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
<resources>
|
|
2
2
|
<string name="app_name">Only Bible</string>
|
|
3
|
+
<string name="old_testament">Old Testament</string>
|
|
4
|
+
<string name="new_testament">New Testament</string>
|
|
5
|
+
<string name="settings">Text Settings</string>
|
|
6
|
+
<string name="voice">en-GB-RyanNeural</string>
|
|
3
7
|
</resources>
|
gradle/libs.versions.toml
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
[versions]
|
|
2
2
|
accompanistSystemuicontroller = "0.27.0"
|
|
3
3
|
agp = "8.4.2"
|
|
4
|
+
appcompat = "1.7.0"
|
|
5
|
+
appsearch = "1.1.0-alpha03"
|
|
4
|
-
|
|
6
|
+
speechClientSdk = "1.34.0"
|
|
5
|
-
composeRememberPreference = "1.1.0"
|
|
6
7
|
coreSplashscreen = "1.0.1"
|
|
7
8
|
datastorePreferences = "1.1.1"
|
|
8
9
|
foundation = "1.6.8"
|
|
@@ -25,6 +26,11 @@ uiUtilAndroid = "1.6.8"
|
|
|
25
26
|
|
|
26
27
|
[libraries]
|
|
27
28
|
accompanist-systemuicontroller = { module = "com.google.accompanist:accompanist-systemuicontroller", version.ref = "accompanistSystemuicontroller" }
|
|
29
|
+
androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" }
|
|
30
|
+
androidx-appcompat-resources = { module = "androidx.appcompat:appcompat-resources", version.ref = "appcompat" }
|
|
31
|
+
androidx-appsearch = { module = "androidx.appsearch:appsearch", version.ref = "appsearch" }
|
|
32
|
+
androidx-appsearch-local-storage = { module = "androidx.appsearch:appsearch-local-storage", version.ref = "appsearch" }
|
|
33
|
+
androidx-appsearch-platform-storage = { module = "androidx.appsearch:appsearch-platform-storage", version.ref = "appsearch" }
|
|
28
34
|
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
|
29
35
|
androidx-core-splashscreen = { module = "androidx.core:core-splashscreen", version.ref = "coreSplashscreen" }
|
|
30
36
|
androidx-datastore-preferences = { module = "androidx.datastore:datastore-preferences", version.ref = "datastorePreferences" }
|
|
@@ -35,8 +41,7 @@ androidx-navigation-compose = { module = "androidx.navigation:navigation-compose
|
|
|
35
41
|
androidx-navigation-fragment-ktx = { module = "androidx.navigation:navigation-fragment-ktx", version.ref = "navigationFragmentKtx" }
|
|
36
42
|
androidx-navigation-ui-ktx = { module = "androidx.navigation:navigation-ui-ktx", version.ref = "navigationFragmentKtx" }
|
|
37
43
|
androidx-ui-text-google-fonts = { module = "androidx.compose.ui:ui-text-google-fonts", version.ref = "uiTextGoogleFonts" }
|
|
38
|
-
client-sdk = { module = "com.microsoft.cognitiveservices.speech:client-sdk", version.ref = "
|
|
44
|
+
speech-client-sdk = { module = "com.microsoft.cognitiveservices.speech:client-sdk", version.ref = "speechClientSdk" }
|
|
39
|
-
compose-remember-preference = { module = "dev.burnoo:compose-remember-preference", version.ref = "composeRememberPreference" }
|
|
40
45
|
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
|
41
46
|
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
|
|
42
47
|
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
|