Fix to parse OpenAI translations.

The parsed result was without quotes which resulted in error:

Unterminated object at character 21 of [{fromLabel=English (US),

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2023-06-26 13:23:55 +02:00
parent 817ea1ab64
commit 64d0f0e2cd
2 changed files with 3 additions and 3 deletions

View File

@ -156,7 +156,7 @@ class TranslateActivity : BaseActivity() {
private fun getLanguageOptions() {
val currentUser = userManager.currentUser.blockingGet()
val json = JSONArray(CapabilitiesUtilNew.getLanguages(currentUser).toString())
val json = JSONArray((CapabilitiesUtilNew.getLanguages(currentUser) as ArrayList<*>).toArray())
val fromLanguagesSet = mutableSetOf(resources.getString(R.string.translation_detect_language))
val toLanguagesSet = mutableSetOf(resources.getString(R.string.translation_device_settings))
@ -212,7 +212,7 @@ class TranslateActivity : BaseActivity() {
private fun getISOFromServer(language: String): String {
val currentUser = userManager.currentUser.blockingGet()
val json = JSONArray(CapabilitiesUtilNew.getLanguages(currentUser).toString())
val json = JSONArray((CapabilitiesUtilNew.getLanguages(currentUser) as ArrayList<*>).toArray())
for (i in 0 until json.length()) {
val current = json.getJSONObject(i)

View File

@ -95,7 +95,7 @@ class MessageActionsDialog(
!message.isDeleted &&
ChatMessage.MessageType.REGULAR_TEXT_MESSAGE == message.getCalculateMessageType() &&
CapabilitiesUtilNew.isTranslationsSupported(user) &&
JSONArray(CapabilitiesUtilNew.getLanguages(user).toString()).length() > 0
JSONArray((CapabilitiesUtilNew.getLanguages(user) as ArrayList<*>).toArray()).length() > 0
)
initMenuReplyToMessage(message.replyable && hasChatPermission)
initMenuReplyPrivately(