From 28eb8959b274407a02602e3151727455b0e3d641 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Mon, 26 Jun 2023 13:23:55 +0200 Subject: [PATCH] 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 --- .../java/com/nextcloud/talk/translate/ui/TranslateActivity.kt | 4 ++-- .../java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/translate/ui/TranslateActivity.kt b/app/src/main/java/com/nextcloud/talk/translate/ui/TranslateActivity.kt index 48ee313deeb..a65dd45db7a 100644 --- a/app/src/main/java/com/nextcloud/talk/translate/ui/TranslateActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/translate/ui/TranslateActivity.kt @@ -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) diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt index 0ea98c59a33..2ac437814e1 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt @@ -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(