Fix translating albums

This commit is contained in:
NekoInverter 2020-10-02 10:25:02 +00:00 committed by 世界
parent a20c1f0d1b
commit 2aa6de188b
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
2 changed files with 27 additions and 4 deletions

View File

@ -16448,10 +16448,20 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
options.add(90);
icons.add(R.drawable.baseline_schedule_24);
}
if ((StrUtil.isNotBlank(selectedObject.messageOwner.message) || selectedObject.isPoll()) && NekoConfig.showTranslate) {
items.add(selectedObject.messageOwner.translated ? LocaleController.getString("UndoTranslate", R.string.UndoTranslate) : LocaleController.getString("Translate", R.string.Translate));
options.add(88);
icons.add(R.drawable.ic_translate);
if (NekoConfig.showTranslate) {
MessageObject messageObject = null;
if (selectedObjectGroup != null && selectedObjectGroup.messages.size() != 0) {
if (!TextUtils.isEmpty(selectedObjectGroup.messages.get(0).messageOwner.message)) {
messageObject = selectedObjectGroup.messages.get(0);
}
} else if (!TextUtils.isEmpty(selectedObject.messageOwner.message) || selectedObject.type == MessageObject.TYPE_POLL) {
messageObject = selectedObject;
}
if (messageObject != null) {
items.add(selectedObject.messageOwner.translated ? LocaleController.getString("UndoTranslate", R.string.UndoTranslate) : LocaleController.getString("Translate", R.string.Translate));
options.add(88);
icons.add(R.drawable.ic_translate);
}
}
if (StrUtil.isNotBlank(selectedObject.messageOwner.message) && StrUtil.isNotBlank(NekoConfig.openPGPApp)) {
if (PgpHelper.PGP_CLEARTEXT_SIGNATURE.matcher(selectedObject.messageOwner.message).matches()) {
@ -17552,6 +17562,18 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
case 88: {
MessageObject messageObject = null;
if (selectedObjectGroup != null && selectedObjectGroup.messages.size() != 0) {
if (!TextUtils.isEmpty(selectedObjectGroup.messages.get(0).messageOwner.message)) {
messageObject = selectedObjectGroup.messages.get(0);
}
} else if (!TextUtils.isEmpty(selectedObject.messageOwner.message) || selectedObject.type == MessageObject.TYPE_POLL) {
messageObject = selectedObject;
}
if (messageObject == null) {
return;
}
MessageTransKt.translateMessages(this, new MessageObject[]{selectedObject});
break;

View File

@ -1,5 +1,6 @@
package tw.nekomimi.nekogram.parts
import android.text.TextUtils
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch