Skip to content

Commit

Permalink
1.4.3
Browse files Browse the repository at this point in the history
- Bugfix Listen: Mozilla changed API response
- Updated Arabic translation
  • Loading branch information
Sav22999 committed May 18, 2020
1 parent 3642080 commit 2e340b7
Show file tree
Hide file tree
Showing 8 changed files with 223 additions and 197 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Legend:

| Status | Percentage | Language (code) | Language (name) | Translators | Link |
| :----: | :--------: | :-------------: | :-------------- | :----------------------------------------------------------- | :----------------------------------------------------------: |
| 🔶 | 25% | `ar` | Arabic | [**ABDELGHANI HOURANI**](https://crowdin.com/profile/abdelghani.me) | **[Translate](https://crowdin.com/project/common-voice-android/ar)** |
| | 98% | `ar` | Arabic | [**ABDELGHANI HOURANI**](https://crowdin.com/profile/abdelghani.me) | **[Translate](https://crowdin.com/project/common-voice-android/ar)** |
| 🔶 | 12% | `ca` | Catalan | [**Carles Paredes Lanau**](https://crowdin.com/profile/carlesparedes) | **[Translate](https://crowdin.com/project/common-voice-android/ca)** |
| 🔶 | 24% | `cs` | Czech | [**acrylicpaintboy**](https://crowdin.com/profile/acrylicpaintboy) | **[Translate](https://crowdin.com/project/common-voice-android/cs)** |
| 🔶 | 43% | `de` | German | [**acrylicpaintboy**](https://crowdin.com/profile/acrylicpaintboy), [**Moini**](https://github.com/Moini), [**akoyaxd**](https://crowdin.com/profile/akoyaxd) | **[Translate](https://crowdin.com/project/common-voice-android/de)** |
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId 'org.commonvoice.saverio'
minSdkVersion 23
targetSdkVersion 29
versionCode = 103
versionName '1.4.2'
versionCode = 105
versionName '1.4.3'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
Binary file modified app/release/app-release.aab
Binary file not shown.
197 changes: 111 additions & 86 deletions app/src/main/java/org/commonvoice/saverio/ListenActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -403,105 +403,126 @@ class ListenActivity : VariableLanguageActivity(R.layout.activity_listen) {
val que = Volley.newRequestQueue(this)
val req = object : JsonArrayRequest(Request.Method.GET, url + path, params,
Response.Listener {
val jsonResult = it.toString()
var jsonResultArray = arrayOf(jsonResult, "")
//println(jsonResult)
if (!this.opened) {
//println("substring: "+jsonResult.substring(1,jsonResult.length-1))
if (jsonResult.substring(
1,
jsonResult.length - 1
).split("},{").size == 2
) {
jsonResultArray[0] = "[" + jsonResult.substring(
1,
jsonResult.length - 1
).split("},{")[0] + "}]"
jsonResultArray[1] =
"[{" + jsonResult.substring(1, jsonResult.length - 1)
.split(
"},{"
)[1] + "]"
}
}
if (jsonResult.length > 2) {
try {
val jsonResult = it.toString()
var jsonResultArray = arrayOf(jsonResult, "")
//println(jsonResult)
if (!this.opened) {
val jsonObj = JSONObject(
jsonResultArray[0].substring(
jsonResultArray[0].indexOf("{"),
jsonResultArray[0].lastIndexOf("}") + 1
//println("substring: "+jsonResult.substring(1,jsonResult.length-1))
if (jsonResult.substring(
1,
jsonResult.length - 1
).split("},{").size == 2
) {
jsonResultArray[0] = "[" + jsonResult.substring(
1,
jsonResult.length - 1
).split("},{")[0] + "}]"
jsonResultArray[1] =
"[{" + jsonResult.substring(1, jsonResult.length - 1)
.split(
"},{"
)[1] + "]"
}
}
if (jsonResult.length > 2) {
if (!this.opened) {
val jsonObj = JSONObject(
jsonResultArray[0].substring(
jsonResultArray[0].indexOf("{"),
jsonResultArray[0].lastIndexOf("}") + 1
)
)
)
//println(jsonObj.toString())
this.idSentence[0] = jsonObj.getString("id").toInt()
this.textSentence[0] = jsonObj.getString("text")
this.soundSentence[0] = jsonObj.getString("sound")
this.globSentence[0] = jsonObj.getString("glob")


val jsonObj2 = JSONObject(
jsonResultArray[1].substring(
jsonResultArray[1].indexOf("{"),
jsonResultArray[1].lastIndexOf("}") + 1
val sentence = JSONObject(
jsonObj.getString("sentence").substring(
jsonObj.getString("sentence").indexOf("{"),
jsonObj.getString("sentence").lastIndexOf("}") + 1
)
)
)
//println(jsonObj2.toString())
this.idSentence[1] = jsonObj2.getString("id").toInt()
this.textSentence[1] = jsonObj2.getString("text")
this.soundSentence[1] = jsonObj2.getString("sound")
this.globSentence[1] = jsonObj2.getString("glob")
} else {
val jsonObj = JSONObject(
jsonResultArray[0].substring(
jsonResultArray[0].indexOf("{"),
jsonResultArray[0].lastIndexOf("}") + 1
//println(jsonObj.toString())
//println(sentence.toString())
this.idSentence[0] = jsonObj.getString("id").toInt()
this.textSentence[0] = sentence.getString("text").toString()
this.soundSentence[0] =
jsonObj.getString("audioSrc").toString()
this.globSentence[0] = jsonObj.getString("glob").toString()


val jsonObj2 = JSONObject(
jsonResultArray[1].substring(
jsonResultArray[1].indexOf("{"),
jsonResultArray[1].lastIndexOf("}") + 1
)
)
)
//println(jsonObj.toString())
this.idSentence[1] = jsonObj.getString("id").toInt()
this.textSentence[1] = jsonObj.getString("text")
this.soundSentence[1] = jsonObj.getString("sound")
this.globSentence[1] = jsonObj.getString("glob")
}
val sentence2 = JSONObject(
jsonObj2.getString("sentence").substring(
jsonObj2.getString("sentence").indexOf("{"),
jsonObj2.getString("sentence").lastIndexOf("}") + 1
)
)
//println(jsonObj2.toString())
this.idSentence[1] = jsonObj2.getString("id").toInt()
this.textSentence[1] = sentence2.getString("text")
this.soundSentence[1] = jsonObj2.getString("audioSrc")
this.globSentence[1] = jsonObj2.getString("glob")
} else {
val jsonObj = JSONObject(
jsonResultArray[0].substring(
jsonResultArray[0].indexOf("{"),
jsonResultArray[0].lastIndexOf("}") + 1
)
)
val sentence = JSONObject(
jsonObj.getString("sentence").substring(
jsonObj.getString("sentence").indexOf("{"),
jsonObj.getString("sentence").lastIndexOf("}") + 1
)
)
//println(jsonObj.toString())
this.idSentence[1] = jsonObj.getString("id").toInt()
this.textSentence[1] = sentence.getString("text")
this.soundSentence[1] = jsonObj.getString("audioSrc")
this.globSentence[1] = jsonObj.getString("glob")
}

if (!this.opened) {
this.opened = true
//API_request() //the second request at the first load //it's not necessary anymore, because the app request 2 clips the first-time (?count=2)
if (!this.opened) {
this.opened = true
//API_request() //the second request at the first load //it's not necessary anymore, because the app request 2 clips the first-time (?count=2)

}
}

if (this.idSentence[0] != 0 && sentence.text == "...") {
sentence.text = this.textSentence[0]
msg.text = getString(R.string.txt_press_icon_below_listen_1)
if (this.idSentence[0] != 0 && sentence.text == "...") {
sentence.text = this.textSentence[0]
msg.text = getString(R.string.txt_press_icon_below_listen_1)

this.mediaPlayer = MediaPlayer().apply {
//setAudioStreamType(AudioManager.STREAM_MUSIC) //to send the object to the initialized state
setDataSource(soundSentence[0]) //to set media source and send the object to the initialized state
prepare() //to send the object to the prepared state, this may take time for fetching and decoding
this.mediaPlayer = MediaPlayer().apply {
//setAudioStreamType(AudioManager.STREAM_MUSIC) //to send the object to the initialized state
setDataSource(soundSentence[0]) //to set media source and send the object to the initialized state
prepare() //to send the object to the prepared state, this may take time for fetching and decoding
}
this.mediaPlayer?.setAuxEffectSendLevel(Float.MAX_VALUE)

btnYes.isVisible = false
btnNo.isVisible = false
btnListen.isEnabled = true

if (this.autoPlayClips && !this.isFinishing) {
StartListening()
}
}
this.mediaPlayer?.setAuxEffectSendLevel(Float.MAX_VALUE)
btnSkip.isEnabled = true
btnReport.isGone = false
} else {
//println(" -->> Something wrong 1: "+it.toString()+" <<-- ")
error4()
btnSkip.isEnabled = true

btnYes.isVisible = false
btnNo.isVisible = false
btnListen.isEnabled = true

if (this.autoPlayClips && !this.isFinishing) {
StartListening()
}
btnReport.isGone = true
}
btnSkip.isEnabled = true
btnReport.isGone = false
} else {
//println(" -->> Something wrong 1: "+it.toString()+" <<-- ")
error4()
btnSkip.isEnabled = true

btnYes.isVisible = false
btnNo.isVisible = false
btnReport.isGone = true
}

/*
/*
println("------")
println("idSentence: " + this.idSentence[0] + " " + this.idSentence[1])
println("textSentence: '" + this.textSentence[0] + "' '" + this.textSentence[1] + "'")
Expand All @@ -510,7 +531,11 @@ class ListenActivity : VariableLanguageActivity(R.layout.activity_listen) {
println("------")
*/

this.loading = false
this.loading = false
} catch (ex: Exception) {
println("Exception: " + ex.printStackTrace())
onBackPressed()
}
}, Response.ErrorListener {
//println(" -->> Something wrong: "+it.toString()+" <<-- ")
error1()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class TranslationsLanguages {
)
this.not_completed_translated =
arrayOf(
"ar",
"ca",
"cs",
"de",
Expand Down
Loading

0 comments on commit 2e340b7

Please sign in to comment.