diff --git a/uikit/src/main/java/adapter/MessageAdapter.java b/uikit/src/main/java/adapter/MessageAdapter.java index c75ff6a8..682c37b4 100644 --- a/uikit/src/main/java/adapter/MessageAdapter.java +++ b/uikit/src/main/java/adapter/MessageAdapter.java @@ -2046,6 +2046,17 @@ public boolean onLongClick(View view) { if (CometChat.isExtensionEnabled("data-masking")) message = Extensions.checkDataMasking(baseMessage); + if (baseMessage.getMetadata()!=null && baseMessage.getMetadata().has("values")) { + try { + if (Extensions.isMessageTranslated(baseMessage.getMetadata().getJSONObject("values"), ((TextMessage) baseMessage).getText())) { + String translatedMessage = Extensions.getTranslatedMessage(baseMessage); + message = message + "\n(" + translatedMessage + ")"; + } + } catch (JSONException e) { + Toast.makeText(context, context.getString(R.string.no_translation_available), Toast.LENGTH_SHORT).show(); + } + } + viewHolder.txtMessage.setText(message); viewHolder.txtMessage.setTypeface(fontUtils.getTypeFace(FontUtils.robotoRegular)); diff --git a/uikit/src/main/java/adapter/ThreadAdapter.java b/uikit/src/main/java/adapter/ThreadAdapter.java index b036b80d..14d6c303 100644 --- a/uikit/src/main/java/adapter/ThreadAdapter.java +++ b/uikit/src/main/java/adapter/ThreadAdapter.java @@ -24,6 +24,7 @@ import android.widget.ProgressBar; import android.widget.RelativeLayout; import android.widget.TextView; +import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -859,6 +860,17 @@ public void onClick(DialogInterface dialog, int which) { else if (CometChat.isExtensionEnabled("data-masking")) message = Extensions.checkDataMasking(baseMessage); + if (baseMessage.getMetadata()!=null && baseMessage.getMetadata().has("values")) { + try { + if (Extensions.isMessageTranslated(baseMessage.getMetadata().getJSONObject("values"), ((TextMessage) baseMessage).getText())) { + String translatedMessage = Extensions.getTranslatedMessage(baseMessage); + message = message + "\n(" + translatedMessage + ")"; + } + } catch (JSONException e) { + Toast.makeText(context, context.getString(R.string.no_translation_available), Toast.LENGTH_SHORT).show(); + } + } + viewHolder.txtMessage.setText(message); viewHolder.txtMessage.setTypeface(fontUtils.getTypeFace(FontUtils.robotoRegular)); diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/Settings/UIKitSettings.java b/uikit/src/main/java/com/cometchat/pro/uikit/Settings/UIKitSettings.java index 9e3214d0..e699e215 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/Settings/UIKitSettings.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/Settings/UIKitSettings.java @@ -339,4 +339,8 @@ public static void enableCollaborativeWhiteBoard(boolean enableWhiteBoardSharing public static void enableCollaborativeWriteBoard(boolean enableWriteBoardSharing) { UISettings.sendWriteBoard = enableWriteBoardSharing; } + + public static void enableMessageTranslation(boolean enableMessageTranslation) { + UISettings.allowMessageTranslation = enableMessageTranslation; + } } diff --git a/uikit/src/main/java/com/cometchat/pro/uikit/Settings/UISettings.java b/uikit/src/main/java/com/cometchat/pro/uikit/Settings/UISettings.java index 8bcdc386..c52ac967 100644 --- a/uikit/src/main/java/com/cometchat/pro/uikit/Settings/UISettings.java +++ b/uikit/src/main/java/com/cometchat/pro/uikit/Settings/UISettings.java @@ -57,6 +57,7 @@ public UISettings() {} protected static boolean hideCallNotification = false; protected static boolean liveReaction = true; protected static boolean allowReactionOnMessage = true; + protected static boolean allowMessageTranslation = true; protected static int emailColor = R.color.primaryTextColor; protected static int phoneColor = R.color.purple; protected static int urlColor = R.color.dark_blue; @@ -256,4 +257,6 @@ public static boolean isWhiteBoardVisible() { public static boolean isWriteBoardVisible() { return sendWriteBoard; } + + public static boolean isTranslationAllowed() { return allowMessageTranslation; } } diff --git a/uikit/src/main/java/screen/messagelist/CometChatMessageScreen.java b/uikit/src/main/java/screen/messagelist/CometChatMessageScreen.java index 92353ad2..cf8ee859 100644 --- a/uikit/src/main/java/screen/messagelist/CometChatMessageScreen.java +++ b/uikit/src/main/java/screen/messagelist/CometChatMessageScreen.java @@ -99,6 +99,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Timer; import java.util.TimerTask; @@ -2303,6 +2304,7 @@ public void setLongMessageClick(List baseMessagesList) { boolean deleteVisible = UISettings.isEnableDeleteMessage(); boolean forwardVisible = UISettings.isEnableShareCopyForward(); boolean reactionVisible = UISettings.isReactionVisible(); + boolean translateVisible = UISettings.isTranslationAllowed(); List textMessageList = new ArrayList<>(); List mediaMessageList = new ArrayList<>(); List locationMessageList = new ArrayList<>(); @@ -2332,6 +2334,7 @@ public void setLongMessageClick(List baseMessagesList) { } } if (textMessageList.size() == 1) { + translateVisible = UISettings.isTranslationAllowed(); BaseMessage basemessage = textMessageList.get(0); if (basemessage != null && basemessage.getSender() != null) { if (!(basemessage instanceof Action) && basemessage.getDeletedAt() == 0) { @@ -2356,6 +2359,7 @@ public void setLongMessageClick(List baseMessagesList) { } if (mediaMessageList.size() == 1) { + translateVisible = false; BaseMessage basemessage = mediaMessageList.get(0); if (basemessage != null && basemessage.getSender() != null) { if (!(basemessage instanceof Action) && basemessage.getDeletedAt() == 0) { @@ -2380,6 +2384,7 @@ public void setLongMessageClick(List baseMessagesList) { } } if (locationMessageList.size() == 1){ + translateVisible = false; BaseMessage basemessage = locationMessageList.get(0); if (basemessage != null && basemessage.getSender() != null) { if (!(basemessage instanceof Action) && basemessage.getDeletedAt() == 0) { @@ -2408,6 +2413,7 @@ public void setLongMessageClick(List baseMessagesList) { } if (pollsMessageList.size() == 1){ forwardVisible = false; + translateVisible = false; copyVisible = false; editVisible = false; shareVisible = false; @@ -2436,8 +2442,9 @@ public void setLongMessageClick(List baseMessagesList) { forwardVisible = false; copyVisible = false; editVisible = false; + translateVisible = false; shareVisible = false; - replyVisible = UISettings.isStickerVisible(); + replyVisible = UISettings.isEnableReplyToMessage(); BaseMessage basemessage = stickerMessageList.get(0); if (basemessage!=null && basemessage.getSender()!=null) { if (basemessage.getDeletedAt() == 0) { @@ -2461,9 +2468,10 @@ public void setLongMessageClick(List baseMessagesList) { if (whiteBoardMessageList.size()==1) { forwardVisible = false; copyVisible = false; + translateVisible = false; editVisible = false; shareVisible = false; - replyVisible = UISettings.isStickerVisible(); + replyVisible = UISettings.isEnableReplyToMessage(); BaseMessage basemessage = whiteBoardMessageList.get(0); if (basemessage!=null && basemessage.getSender()!=null) { if (basemessage.getDeletedAt() == 0) { @@ -2489,8 +2497,9 @@ public void setLongMessageClick(List baseMessagesList) { forwardVisible = false; copyVisible = false; editVisible = false; + translateVisible = false; shareVisible = false; - replyVisible = UISettings.isStickerVisible(); + replyVisible = UISettings.isEnableReplyToMessage(); BaseMessage basemessage = writeBoardMessageList.get(0); if (basemessage!=null && basemessage.getSender()!=null) { if (basemessage.getDeletedAt() == 0) { @@ -2522,6 +2531,7 @@ public void setLongMessageClick(List baseMessagesList) { bundle.putBoolean("deleteVisible",deleteVisible); bundle.putBoolean("replyVisible",replyVisible); bundle.putBoolean("forwardVisible",forwardVisible); + bundle.putBoolean("translateVisible",translateVisible); if (CometChat.isExtensionEnabled("reactions")) bundle.putBoolean("isReactionVisible",reactionVisible); if (baseMessage.getReceiverType().equals(CometChatConstants.RECEIVER_TYPE_GROUP) && @@ -2658,6 +2668,50 @@ public void onEmojiClicked(Reaction emojicon) { sendReaction(reaction); } } + + @Override + public void onTranslateMessageClick() { + try { + String localeLanguage = Locale.getDefault().getLanguage(); + JSONObject body = new JSONObject(); + JSONArray languages = new JSONArray(); + languages.put(localeLanguage); + body.put("msgId", baseMessage.getId()); + body.put("languages", languages); + body.put("text", ((TextMessage)baseMessage).getText()); + + CometChat.callExtension("message-translation", "POST", "/v2/translate", body, + new CometChat.CallbackListener() { + @Override + public void onSuccess(JSONObject jsonObject) { + if (Extensions.isMessageTranslated(jsonObject,((TextMessage)baseMessage).getText())) { + if (baseMessage.getMetadata()!=null) { + JSONObject meta = baseMessage.getMetadata(); + try { + meta.accumulate("values",jsonObject); + baseMessage.setMetadata(meta); + updateMessage(baseMessage); + } catch (JSONException e) { + e.printStackTrace(); + } + } else { + baseMessage.setMetadata(jsonObject); + updateMessage(baseMessage); + } + } else { + Snackbar.make(rvChatListView,context.getString(R.string.no_translation_available),Snackbar.LENGTH_LONG).show(); + } + } + + @Override + public void onError(CometChatException e) { + Toast.makeText(context,e.getCode(),Toast.LENGTH_LONG).show(); + } + }); + } catch (Exception e) { + Toast.makeText(context,e.getMessage(),Toast.LENGTH_LONG).show(); + } + } }); } diff --git a/uikit/src/main/java/screen/messagelist/MessageActionFragment.java b/uikit/src/main/java/screen/messagelist/MessageActionFragment.java index 4dcc78b3..032c1728 100644 --- a/uikit/src/main/java/screen/messagelist/MessageActionFragment.java +++ b/uikit/src/main/java/screen/messagelist/MessageActionFragment.java @@ -36,6 +36,7 @@ public class MessageActionFragment extends BottomSheetDialogFragment { private TextView copyMessage; private TextView messageInfo; private TextView shareMessage; + private TextView translateMessage; private LinearLayout reactionsList; @@ -50,6 +51,7 @@ public class MessageActionFragment extends BottomSheetDialogFragment { private boolean isReplyVisible; private boolean isMessageInfoVisible; private boolean isReactionsVisible; + private boolean isTranslateVisible; private MessageActionListener messageActionListener; @@ -74,6 +76,7 @@ private void fetchArguments() { isShareVisible = getArguments().getBoolean("shareVisible"); isMessageInfoVisible = getArguments().getBoolean("messageInfoVisible"); isReactionsVisible = getArguments().getBoolean("isReactionVisible"); + isTranslateVisible = getArguments().getBoolean("translateVisible"); type = getArguments().getString("type"); } } @@ -135,25 +138,7 @@ public void onClick(View view) { } }); -// reactionsList.addOnItemTouchListener(new RecyclerTouchListener(getContext(), reactionsList, new ClickListener() { -// @Override -// public void onClick(View var1, int var2) { -// Reaction reaction = (Reaction)var1.getTag(R.string.reaction); -// if (messageActionListener != null) -// messageActionListener.onReactionClick(reaction); -// dismiss(); -// } -// })); -// showReactionDialog = view.findViewById(R.id.show_reaction_dialog); -// showReactionDialog.setVisibility(View.GONE); -// showReactionDialog.setOnClickListener(new View.OnClickListener() { -// @Override -// public void onClick(View view) { -// if (messageActionListener!=null) -// messageActionListener.onReactionClick(new Reaction("add_emoji",0)); -// dismiss(); -// } -// }); + translateMessage = view.findViewById(R.id.translate_message); threadMessage = view.findViewById(R.id.start_thread); editMessage = view.findViewById(R.id.edit_message); replyMessage = view.findViewById(R.id.reply_message); @@ -163,6 +148,11 @@ public void onClick(View view) { shareMessage = view.findViewById(R.id.share_message); messageInfo = view.findViewById(R.id.message_info); + if (isTranslateVisible) + translateMessage.setVisibility(View.VISIBLE); + else + translateMessage.setVisibility(View.GONE); + if (isReactionsVisible) reactionsList.setVisibility(View.VISIBLE); else @@ -204,6 +194,14 @@ public void onClick(View view) { threadMessage.setVisibility(View.GONE); } + translateMessage.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (messageActionListener!=null) + messageActionListener.onTranslateMessageClick(); + dismiss(); + } + }); threadMessage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -289,6 +287,8 @@ public interface MessageActionListener { void onMessageInfoClick(); void onReactionClick(Reaction reaction); + + void onTranslateMessageClick(); } @Override diff --git a/uikit/src/main/java/screen/threadconversation/CometChatThreadMessageScreen.java b/uikit/src/main/java/screen/threadconversation/CometChatThreadMessageScreen.java index 2da68b56..4be1ad12 100644 --- a/uikit/src/main/java/screen/threadconversation/CometChatThreadMessageScreen.java +++ b/uikit/src/main/java/screen/threadconversation/CometChatThreadMessageScreen.java @@ -91,6 +91,7 @@ import com.google.android.material.chip.ChipGroup; import com.google.android.material.snackbar.Snackbar; +import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -98,6 +99,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Objects; import java.util.Timer; import java.util.TimerTask; @@ -1938,8 +1940,10 @@ public void onClick(View view) { else if (id == R.id.ic_more_option) { MessageActionFragment messageActionFragment = new MessageActionFragment(); Bundle bundle = new Bundle(); - if (messageType.equals(CometChatConstants.MESSAGE_TYPE_TEXT)) - bundle.putBoolean("copyVisible",true); + if (messageType.equals(CometChatConstants.MESSAGE_TYPE_TEXT)) { + bundle.putBoolean("translateVisible",true); + bundle.putBoolean("copyVisible", true); + } else bundle.putBoolean("copyVisible",false); @@ -1953,6 +1957,7 @@ else if (id == R.id.ic_more_option) { bundle.putString("type", CometChatThreadMessageActivity.class.getName()); messageActionFragment.setArguments(bundle); showBottomSheet(messageActionFragment); + isParent = true; } else if (id == R.id.ic_forward_option) { isParent = true; @@ -2017,7 +2022,8 @@ public void setLongMessageClick(List baseMessagesList) { boolean editVisible = UISettings.isEnableEditingMessage(); boolean deleteVisible = UISettings.isEnableDeleteMessage(); boolean forwardVisible = UISettings.isEnableShareCopyForward(); - boolean reactionVisible = true; + boolean reactionVisible = UISettings.isReactionVisible(); + boolean translateVisible = UISettings.isTranslationAllowed(); List textMessageList = new ArrayList<>(); List mediaMessageList = new ArrayList<>(); List locationMessageList = new ArrayList<>(); @@ -2036,6 +2042,7 @@ else if (baseMessage.getType().equals(CometChatConstants.MESSAGE_TYPE_IMAGE) || } } if (textMessageList.size() == 1) { + translateVisible = UISettings.isTranslationAllowed(); BaseMessage basemessage = textMessageList.get(0); if (basemessage != null && basemessage.getSender() != null) { if (!(basemessage instanceof Action) && basemessage.getDeletedAt() == 0) { @@ -2059,6 +2066,7 @@ else if (baseMessage.getType().equals(CometChatConstants.MESSAGE_TYPE_IMAGE) || } if (mediaMessageList.size() == 1) { + translateVisible = false; BaseMessage basemessage = mediaMessageList.get(0); if (basemessage != null && basemessage.getSender() != null) { if (!(basemessage instanceof Action) && basemessage.getDeletedAt() == 0) { @@ -2082,6 +2090,7 @@ else if (baseMessage.getType().equals(CometChatConstants.MESSAGE_TYPE_IMAGE) || } } if (locationMessageList.size() == 1){ + translateVisible = false; BaseMessage basemessage = locationMessageList.get(0); if (basemessage != null && basemessage.getSender() != null) { if (!(basemessage instanceof Action) && basemessage.getDeletedAt() == 0) { @@ -2112,6 +2121,7 @@ else if (baseMessage.getType().equals(CometChatConstants.MESSAGE_TYPE_IMAGE) || bundle.putBoolean("deleteVisible",deleteVisible); bundle.putBoolean("replyVisible",replyVisible); bundle.putBoolean("forwardVisible",forwardVisible); + bundle.putBoolean("translateVisible",translateVisible); if (CometChat.isExtensionEnabled("reactions")) bundle.putBoolean("isReactionVisible",reactionVisible); if (baseMessage.getReceiverType().equals(CometChatConstants.RECEIVER_TYPE_GROUP) && @@ -2165,18 +2175,20 @@ public void onCopyMessageClick() { String copyMessage = ""; if (isParent) { copyMessage = message; - } - for (BaseMessage bMessage : baseMessages) { - if (bMessage.getDeletedAt() == 0 && bMessage instanceof TextMessage) { - copyMessage = copyMessage + "[" + Utils.getLastMessageDate(bMessage.getSentAt()) + "] " + bMessage.getSender().getName() + ": " + ((TextMessage) bMessage).getText(); + isParent = true; + } else { + for (BaseMessage bMessage : baseMessages) { + if (bMessage.getDeletedAt() == 0 && bMessage instanceof TextMessage) { + copyMessage = copyMessage + "[" + Utils.getLastMessageDate(bMessage.getSentAt()) + "] " + bMessage.getSender().getName() + ": " + ((TextMessage) bMessage).getText(); + } } + isParent = false; } Log.e(TAG, "onCopy: " + message); ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); ClipData clipData = ClipData.newPlainText("ThreadMessageAdapter", copyMessage); clipboardManager.setPrimaryClip(clipData); Toast.makeText(context, getResources().getString(R.string.text_copied), Toast.LENGTH_LONG).show(); - isParent = true; if (messageAdapter != null) { messageAdapter.clearLongClickSelectedItem(); messageAdapter.notifyDataSetChanged(); @@ -2240,6 +2252,66 @@ public void onEmojiClicked(Reaction emojicon) { sendReaction(reaction); } } + + @Override + public void onTranslateMessageClick() { + try { + String localeLanguage = Locale.getDefault().getLanguage(); + JSONObject body = new JSONObject(); + JSONArray languages = new JSONArray(); + languages.put(localeLanguage); + if (isParent) { + body.put("msgId", parentId); + body.put("text", textMessage.getText().toString()); + } + else { + body.put("msgId", baseMessage.getId()); + body.put("text", ((TextMessage) baseMessage).getText()); + } + body.put("languages", languages); + CometChat.callExtension("message-translation", "POST", "/v2/translate", body, + new CometChat.CallbackListener() { + @Override + public void onSuccess(JSONObject jsonObject) { + if (isParent) { + if (Extensions.isMessageTranslated(jsonObject,textMessage.getText().toString())) { + String translatedMessage = Extensions + .getTextTranslatedMessage(jsonObject, + textMessage.getText().toString()); + textMessage.setText(translatedMessage); + } else { + Snackbar.make(rvChatListView,getString(R.string.no_translation_available),Snackbar.LENGTH_LONG).show(); + } + } else { + if (Extensions.isMessageTranslated(jsonObject,((TextMessage)baseMessage).getText())) { + if (baseMessage.getMetadata()!=null) { + JSONObject meta = baseMessage.getMetadata(); + try { + meta.accumulate("values",jsonObject); + baseMessage.setMetadata(meta); + updateMessage(baseMessage); + } catch (JSONException e) { + e.printStackTrace(); + } + } else { + baseMessage.setMetadata(jsonObject); + updateMessage(baseMessage); + } + } else { + Snackbar.make(rvChatListView,getString(R.string.no_translation_available),Snackbar.LENGTH_LONG).show(); + } + } + } + + @Override + public void onError(CometChatException e) { + Toast.makeText(context,e.getCode(),Toast.LENGTH_LONG).show(); + } + }); + } catch (Exception e) { + Toast.makeText(context,e.getMessage(),Toast.LENGTH_LONG).show(); + } + } }); } @@ -2309,6 +2381,7 @@ private void editThreadMessage() { if (baseMessage!=null&&baseMessage.getType().equals(CometChatConstants.MESSAGE_TYPE_TEXT)) { isEdit = true; isReply = false; + isParent = false; tvMessageTitle.setText(getResources().getString(R.string.edit_message)); tvMessageSubTitle.setText(((TextMessage) baseMessage).getText()); composeBox.ivSend.setVisibility(View.VISIBLE); diff --git a/uikit/src/main/java/utils/Extensions.java b/uikit/src/main/java/utils/Extensions.java index e8a352b3..f6e67f52 100644 --- a/uikit/src/main/java/utils/Extensions.java +++ b/uikit/src/main/java/utils/Extensions.java @@ -18,6 +18,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.Locale; import constant.StringContract; import listeners.ExtensionResponseListener; @@ -539,4 +540,86 @@ public static void openWriteBoard(BaseMessage baseMessage, Context context) { Toast.makeText(context, e.getMessage(), Toast.LENGTH_SHORT).show(); } } + + + public static String getTranslatedMessage(BaseMessage baseMessage) { + String translatedMessage = ((TextMessage)baseMessage).getText(); + try { + if (baseMessage.getMetadata() != null) { + JSONObject metadataObject = baseMessage.getMetadata(); + if (metadataObject.has("values")) { + JSONObject valueObject = metadataObject.getJSONObject("values"); + if (valueObject.has("data")) { + JSONObject dataObject = valueObject.getJSONObject("data"); + if (dataObject.has("translations")) { + JSONArray translations = dataObject.getJSONArray("translations"); + if (translations.length() > 0) { + JSONObject jsonObject = translations.getJSONObject(0); + translatedMessage = jsonObject.getString("message_translated"); + } + } + } + } + } + } catch (Exception e) { + Log.e(TAG, "getTranslatedMessageError: "+e.getMessage()); + } + return translatedMessage; + } + + public static boolean isMessageTranslated(JSONObject jsonObject,String txtMessage) { + boolean result = false; + try { + JSONObject metadataObject = jsonObject; + if (metadataObject.has("data")) { + JSONObject dataObject = metadataObject.getJSONObject("data"); + if (dataObject.has("translations")) { + JSONArray translations = dataObject.getJSONArray("translations"); + if (translations.length() > 0) { + JSONObject translationsJSONObject = translations.getJSONObject(0); + String language = translationsJSONObject.getString("language_translated"); + String localLanguage = Locale.getDefault().getLanguage(); + String translatedMessage = translationsJSONObject.getString("message_translated"); + if (language.equalsIgnoreCase(localLanguage) && + !txtMessage.equalsIgnoreCase(translatedMessage)) { + result = true; + } else { + result = false; + } + } + } + } + } catch (Exception e) { + Log.e(TAG, "isMessageTranslatedError: "+e.getMessage()); + } + return result; + } + + public static String getTextTranslatedMessage(JSONObject jsonObject,String originalString) { + String result=""; + try { + JSONObject metadataObject = jsonObject; + if (metadataObject.has("data")) { + JSONObject dataObject = metadataObject.getJSONObject("data"); + if (dataObject.has("translations")) { + JSONArray translations = dataObject.getJSONArray("translations"); + if (translations.length() > 0) { + JSONObject translationsJSONObject = translations.getJSONObject(0); + String language = translationsJSONObject.getString("language_translated"); + String localLanguage = Locale.getDefault().getLanguage(); + String translatedMessage = translationsJSONObject.getString("message_translated"); + if (language.equalsIgnoreCase(localLanguage) && + !originalString.equalsIgnoreCase(translatedMessage)) { + result = originalString+"\n("+translatedMessage+")"; + } else { + result = originalString; + } + } + } + } + } catch (Exception e) { + Log.e(TAG, "isMessageTranslatedError: "+e.getMessage()); + } + return result; + } } diff --git a/uikit/src/main/res/drawable/ic_translate.xml b/uikit/src/main/res/drawable/ic_translate.xml new file mode 100644 index 00000000..20ddcb01 --- /dev/null +++ b/uikit/src/main/res/drawable/ic_translate.xml @@ -0,0 +1,7 @@ + + + diff --git a/uikit/src/main/res/layout/fragment_message_actions.xml b/uikit/src/main/res/layout/fragment_message_actions.xml index 71f0cc1a..d1263cec 100644 --- a/uikit/src/main/res/layout/fragment_message_actions.xml +++ b/uikit/src/main/res/layout/fragment_message_actions.xml @@ -21,6 +21,18 @@ android:layout_height="wrap_content"/> + مضاف بدأت مصنوع + ترجمة الرسالة + لا يوجد ترجمة متوفرة \ No newline at end of file diff --git a/uikit/src/main/res/values-de/strings.xml b/uikit/src/main/res/values-de/strings.xml index 38b2b7e1..72a87674 100644 --- a/uikit/src/main/res/values-de/strings.xml +++ b/uikit/src/main/res/values-de/strings.xml @@ -340,4 +340,6 @@ initiiert getreten gemacht + Nachricht übersetzen + Keine Übersetzung verfügbar \ No newline at end of file diff --git a/uikit/src/main/res/values-es/strings.xml b/uikit/src/main/res/values-es/strings.xml index 62d195be..703941d0 100644 --- a/uikit/src/main/res/values-es/strings.xml +++ b/uikit/src/main/res/values-es/strings.xml @@ -348,4 +348,6 @@ iniciado golpeado hecho + Traducir mensaje + No hay traducción disponible \ No newline at end of file diff --git a/uikit/src/main/res/values-fr/strings.xml b/uikit/src/main/res/values-fr/strings.xml index cfdaf46e..7545efda 100644 --- a/uikit/src/main/res/values-fr/strings.xml +++ b/uikit/src/main/res/values-fr/strings.xml @@ -345,4 +345,6 @@ ajouté initié fabriqué + Traduire le message + Pas de traduction disponible \ No newline at end of file diff --git a/uikit/src/main/res/values-hi/strings.xml b/uikit/src/main/res/values-hi/strings.xml index 70d2750e..fc2e1bff 100644 --- a/uikit/src/main/res/values-hi/strings.xml +++ b/uikit/src/main/res/values-hi/strings.xml @@ -341,4 +341,6 @@ लात मारी समूह छोड़ दिया " बनाया" + अनुवाद संदेश + कोई अनुवाद उपलब्ध नहीं \ No newline at end of file diff --git a/uikit/src/main/res/values-ms/strings.xml b/uikit/src/main/res/values-ms/strings.xml index 1ae3d02c..9a657cd2 100644 --- a/uikit/src/main/res/values-ms/strings.xml +++ b/uikit/src/main/res/values-ms/strings.xml @@ -340,4 +340,6 @@ dimulakan ditendang dibuat + Terjemahkan Mesej + Terjemahan Tidak Ada \ No newline at end of file diff --git a/uikit/src/main/res/values-pt/strings.xml b/uikit/src/main/res/values-pt/strings.xml index 2735cab8..1da20a1b 100644 --- a/uikit/src/main/res/values-pt/strings.xml +++ b/uikit/src/main/res/values-pt/strings.xml @@ -341,4 +341,6 @@ iniciado chutado feito + Traduzir mensagem + Nenhuma tradução disponível \ No newline at end of file diff --git a/uikit/src/main/res/values-ru/strings.xml b/uikit/src/main/res/values-ru/strings.xml index 157c2a34..07e47ce4 100644 --- a/uikit/src/main/res/values-ru/strings.xml +++ b/uikit/src/main/res/values-ru/strings.xml @@ -343,4 +343,6 @@ инициированный пнул сделанный + Перевести сообщение + Перевод недоступен \ No newline at end of file diff --git a/uikit/src/main/res/values-zh-rTW/strings.xml b/uikit/src/main/res/values-zh-rTW/strings.xml index 408174bd..306c4a75 100644 --- a/uikit/src/main/res/values-zh-rTW/strings.xml +++ b/uikit/src/main/res/values-zh-rTW/strings.xml @@ -343,4 +343,6 @@ 添加 已发起 制作 + 翻譯訊息 + 沒有可用的翻譯 \ No newline at end of file diff --git a/uikit/src/main/res/values-zh/strings.xml b/uikit/src/main/res/values-zh/strings.xml index 340dc939..c2bc31a7 100644 --- a/uikit/src/main/res/values-zh/strings.xml +++ b/uikit/src/main/res/values-zh/strings.xml @@ -339,4 +339,6 @@ 添加 已发起 制作 + 翻译讯息 + 没有可用的翻译 \ No newline at end of file diff --git a/uikit/src/main/res/values/strings.xml b/uikit/src/main/res/values/strings.xml index cdfcb0c8..335e6b14 100644 --- a/uikit/src/main/res/values/strings.xml +++ b/uikit/src/main/res/values/strings.xml @@ -330,5 +330,7 @@ Unban made participant + Translate Message + No translation available