~repos /only-bible-app

#kotlin#android#ios

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.


1287336d Peter John

1 year ago
fix voice
app/src/main/java/dev/pyrossh/onlyBible/AppDrawer.kt CHANGED
@@ -39,6 +39,8 @@ import androidx.compose.ui.text.font.FontWeight
39
39
  import androidx.compose.ui.unit.dp
40
40
  import androidx.compose.ui.unit.sp
41
41
  import androidx.navigation.NavController
42
+ import dev.pyrossh.onlyBible.domain.Bible
43
+ import dev.pyrossh.onlyBible.domain.Verse
42
44
  import kotlinx.coroutines.Job
43
45
  import kotlinx.coroutines.launch
44
46
 
@@ -61,20 +63,6 @@ fun LazyGridScope.header(
61
63
  item(span = { GridItemSpan(this.maxLineSpan) }, content = content)
62
64
  }
63
65
 
64
- val bibles = listOf(
65
- "Bengali",
66
- "English",
67
- "Gujarati",
68
- "Hindi",
69
- "Kannada",
70
- "Malayalam",
71
- "Nepali",
72
- "Oriya",
73
- "Punjabi",
74
- "Tamil",
75
- "Telugu"
76
- )
77
-
78
66
  @Composable
79
67
  fun AppDrawer(
80
68
  model: AppViewModel,
@@ -109,7 +97,8 @@ fun AppDrawer(
109
97
  Column(
110
98
  modifier = Modifier
111
99
  .fillMaxSize()
112
- .padding(horizontal = 16.dp),
100
+ .padding(horizontal = 16.dp)
101
+ .padding(bottom = 16.dp),
113
102
  ) {
114
103
  if (menuType == MenuType.Bible) {
115
104
  LazyVerticalGrid(
@@ -138,8 +127,8 @@ fun AppDrawer(
138
127
  }
139
128
  }
140
129
  }
141
- items(bibles) { b ->
130
+ items(Bible.entries.toTypedArray()) { b ->
142
- QuickButton(b) {
131
+ QuickButton(b.displayName) {
143
132
  model.setBibleName(context, b)
144
133
  scope.launch {
145
134
  drawerState.close()
app/src/main/java/dev/pyrossh/onlyBible/AppViewModel.kt CHANGED
@@ -17,6 +17,8 @@ import androidx.lifecycle.AndroidViewModel
17
17
  import androidx.lifecycle.viewModelScope
18
18
  import com.microsoft.cognitiveservices.speech.SpeechConfig
19
19
  import com.microsoft.cognitiveservices.speech.SpeechSynthesizer
20
+ import dev.pyrossh.onlyBible.domain.Bible
21
+ import dev.pyrossh.onlyBible.domain.Verse
20
22
  import kotlinx.coroutines.CoroutineScope
21
23
  import kotlinx.coroutines.Dispatchers
22
24
  import kotlinx.coroutines.flow.collectLatest
@@ -112,10 +114,8 @@ class AppViewModel(application: Application) : AndroidViewModel(application) {
112
114
  showBottomSheet = false
113
115
  }
114
116
 
115
- fun setBibleName(context: Context, b: String) {
117
+ fun setBibleName(context: Context, b: Bible) {
116
- bibleName = b
118
+ bibleName = b.name
117
- context.getSharedPreferences("settings", Context.MODE_PRIVATE).edit()
118
- .putString("bibleName", b).apply()
119
119
  loadBible(context)
120
120
  }
121
121
 
@@ -131,8 +131,9 @@ class AppViewModel(application: Application) : AndroidViewModel(application) {
131
131
  isOnError = false
132
132
  }
133
133
  try {
134
+ val b = Bible.valueOf(bibleName)
134
135
  val buffer =
135
- context.assets.open("bibles/${bibleName}.txt").bufferedReader()
136
+ context.assets.open("bibles/${b.fileName}.txt").bufferedReader()
136
137
  val localVerses = buffer.readLines().filter { it.isNotEmpty() }.map {
137
138
  val arr = it.split("|")
138
139
  val bookName = arr[0]
@@ -142,6 +143,7 @@ class AppViewModel(application: Application) : AndroidViewModel(application) {
142
143
  val heading = arr[4]
143
144
  val verseText = arr.subList(5, arr.size).joinToString("|")
144
145
  Verse(
146
+ bible = b,
145
147
  bookIndex = book,
146
148
  bookName = bookName,
147
149
  chapterIndex = chapter,
app/src/main/java/dev/pyrossh/onlyBible/ChapterScreen.kt CHANGED
@@ -62,6 +62,8 @@ import androidx.compose.ui.unit.dp
62
62
  import androidx.compose.ui.unit.sp
63
63
  import androidx.navigation.NavController
64
64
  import com.microsoft.cognitiveservices.speech.SpeechSynthesisEventArgs
65
+ import dev.pyrossh.onlyBible.domain.Bible
66
+ import dev.pyrossh.onlyBible.domain.Verse
65
67
  import kotlinx.coroutines.Dispatchers
66
68
  import kotlinx.coroutines.Job
67
69
  import kotlinx.coroutines.launch
@@ -175,7 +177,7 @@ fun ChapterScreen(
175
177
  actions = {
176
178
  TextButton(onClick = { openDrawer(MenuType.Bible, bookIndex) }) {
177
179
  Text(
178
- text = model.bibleName.substring(0, 2).uppercase(),
180
+ text = Bible.valueOf(model.bibleName).code.uppercase(),
179
181
  style = TextStyle(
180
182
  fontSize = 18.sp,
181
183
  fontWeight = FontWeight.W500,
@@ -206,7 +208,7 @@ fun ChapterScreen(
206
208
  actions = {
207
209
  Surface(
208
210
  color = Color.Transparent,
209
- contentColor = MaterialTheme.colorScheme.primary,
211
+ // contentColor = MaterialTheme.colorScheme.primary,
210
212
  ) {
211
213
  HorizontalDivider(
212
214
  color = MaterialTheme.colorScheme.outline,
@@ -250,15 +252,6 @@ fun ChapterScreen(
250
252
  contentDescription = "Audio",
251
253
  )
252
254
  }
253
- // IconButton(onClick = {
254
- // shareVerses(context, selectedVerses)
255
- // }) {
256
- // Icon(
257
- // modifier = Modifier.size(48.dp),
258
- // imageVector = Icons.Outlined.Edit,
259
- // contentDescription = "Highlight",
260
- // )
261
- // }
262
255
  IconButton(onClick = {
263
256
  shareVerses(
264
257
  context,
@@ -271,37 +264,13 @@ fun ChapterScreen(
271
264
  )
272
265
  }
273
266
  }
274
- // IconButton(onClick = { /* do something */ }) {
267
+ // IconButton(onClick = {}) {
275
268
  // Icon(
276
269
  // Icons.Filled.Circle,
277
270
  // contentDescription = "",
278
271
  // modifier = Modifier.size(64.dp),
279
272
  // tint = Color.Yellow
280
273
  // )
281
- // }
282
- // IconButton(onClick = { /* do something */ }) {
283
- // Icon(
284
- // Icons.Filled.Circle,
285
- // contentDescription = "",
286
- // modifier = Modifier.size(64.dp),
287
- // tint = Color.Blue,
288
- // )
289
- // }
290
- // IconButton(onClick = { /* do something */ }) {
291
- // Icon(
292
- // Icons.Filled.Circle,
293
- // contentDescription = "",
294
- // modifier = Modifier.size(64.dp),
295
- // tint = Color.Cyan,
296
- // )
297
- // }
298
- // IconButton(onClick = { /* do something */ }) {
299
- // Icon(
300
- // Icons.Filled.Circle,
301
- // contentDescription = "",
302
- // modifier = Modifier.size(64.dp),
303
- // tint = Color.Magenta,
304
- // )
305
274
  // }
306
275
  }
307
276
  },
app/src/main/java/dev/pyrossh/onlyBible/domain/Bible.kt ADDED
@@ -0,0 +1,34 @@
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/{Verse.kt → domain/Verse.kt} RENAMED
@@ -1,4 +1,4 @@
1
- package dev.pyrossh.onlyBible
1
+ package dev.pyrossh.onlyBible.domain
2
2
 
3
3
  import android.os.Parcelable
4
4
  import kotlinx.parcelize.Parcelize
@@ -78,6 +78,7 @@ val engTitles = listOf(
78
78
  @Serializable
79
79
  @Parcelize
80
80
  data class Verse(
81
+ val bible: Bible,
81
82
  val bookIndex: Int,
82
83
  val bookName: String,
83
84
  val chapterIndex: Int,
@@ -89,8 +90,8 @@ data class Verse(
89
90
  fun toSSML(): String {
90
91
  return """
91
92
  <speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="en-US">
92
- <voice name="en-US-AvaMultilingualNeural">
93
+ <voice name="${bible.voiceName}">
93
- ${text}
94
+ $text
94
95
  </voice>
95
96
  </speak>
96
97
  """.trimIndent()