This commit is contained in:
世界 2020-11-17 13:25:54 +00:00
parent e857f69846
commit 6dce0743db
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
9 changed files with 68 additions and 115 deletions

View File

@ -2,8 +2,8 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
def verName = "7.2.1-rc07"
def verCode = 114
def verName = "7.2.1-rc08"
def verCode = 115
def serviceAccountCredentialsFile = rootProject.file("service_account_credentials.json")
@ -82,8 +82,8 @@ dependencies {
implementation 'dnsjava:dnsjava:3.3.1'
implementation 'org.dizitart:nitrite:3.4.2'
implementation 'cn.hutool:hutool-core:5.4.7'
implementation 'cn.hutool:hutool-crypto:5.4.7'
implementation 'cn.hutool:hutool-core:5.5.1'
implementation 'cn.hutool:hutool-crypto:5.5.1'
implementation project(":openpgp-api")

View File

@ -1723,8 +1723,7 @@ public class MessageObject {
}
public void applyNewText() {
if (StrUtil.isBlank(messageOwner.message) || (messageOwner.translated && StrUtil.isBlank(messageOwner.translatedMessage))) {
if (TextUtils.isEmpty(messageOwner.message)) {
return;
}
@ -1733,11 +1732,7 @@ public class MessageObject {
fromUser = MessagesController.getInstance(currentAccount).getUser(messageOwner.from_id.user_id);
}
if (messageOwner.translated) {
messageText = messageOwner.translatedMessage;
} else {
messageText = messageOwner.message;
}
TextPaint paint;
if (messageOwner.media instanceof TLRPC.TL_messageMediaGame) {
@ -2707,6 +2702,8 @@ public class MessageObject {
}
}
}
} else if (messageOwner.translated) {
messageText = messageOwner.translatedMessage;
} else {
messageText = messageOwner.message;
}

View File

@ -17489,7 +17489,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
options.add(12);
icons.add(R.drawable.baseline_edit_24);
}
if (selectedObject.contentType == 0 && !selectedObject.isMediaEmptyWebpage() && selectedObject.getId() > 0 && !selectedObject.isOut() && (currentChat != null || currentUser != null && currentUser.bot)) {
if (NekoConfig.showReport && selectedObject.contentType == 0 && !selectedObject.isMediaEmptyWebpage() && selectedObject.getId() > 0 && !selectedObject.isOut() && (currentChat != null || currentUser != null && currentUser.bot)) {
items.add(LocaleController.getString("ReportChat", R.string.ReportChat));
options.add(23);
icons.add(R.drawable.baseline_report_24);
@ -17611,15 +17611,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
options.add(6);
icons.add(R.drawable.baseline_share_24);
} else if (selectedObject.getDocument() != null) {
items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads));
options.add(10);
icons.add(R.drawable.baseline_file_download_24);
if (MessageObject.isNewGifDocument(selectedObject.getDocument())) {
items.add(LocaleController.getString("SaveToGIFs", R.string.SaveToGIFs));
options.add(11);
icons.add(R.drawable.deproko_baseline_gif_24);
}
items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads));
options.add(10);
icons.add(R.drawable.baseline_file_download_24);
if (NekoConfig.showDeleteDownloadedFile) {
} else if (NekoConfig.showDeleteDownloadedFile) {
items.add(LocaleController.getString("DeleteDownloadedFile", R.string.DeleteDownloadedFile));
options.add(91);
icons.add(R.drawable.baseline_delete_sweep_24);
@ -17796,22 +17795,22 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
options.add(90);
icons.add(R.drawable.baseline_schedule_24);
}
if (NekoConfig.showTranslate) {
MessageObject messageObject = null;
if (selectedObjectGroup != null) {
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;
MessageObject messageObject = null;
if (selectedObjectGroup != null) {
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 (NekoConfig.showTranslate) {
if (messageObject != null) {
items.add(selectedObject.messageOwner.translated ? LocaleController.getString("UndoTranslate", R.string.UndoTranslate) : LocaleController.getString("Translate", R.string.Translate));
items.add(messageObject.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 (messageObject != null && StrUtil.isNotBlank(messageObject.messageOwner.message) && StrUtil.isNotBlank(NekoConfig.openPGPApp)) {
if (PgpHelper.PGP_CLEARTEXT_SIGNATURE.matcher(selectedObject.messageOwner.message).matches()) {
items.add(LocaleController.getString("PGPVerify", R.string.PGPVerify));
options.add(200);
@ -17863,11 +17862,15 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (chatMode != MODE_SCHEDULED && selectedObject.contentType == 0 && selectedObject.getId() > 0 && !selectedObject.isOut() && (currentChat != null || currentUser != null && currentUser.bot)) {
if (UserObject.isReplyUser(currentUser)) {
items.add(LocaleController.getString("BlockContact", R.string.BlockContact));
} else {
options.add(23);
icons.add(R.drawable.baseline_report_24);
} else if (NekoConfig.showReport) {
items.add(LocaleController.getString("ReportChat", R.string.ReportChat));
options.add(23);
icons.add(R.drawable.baseline_report_24);
}
options.add(23);
icons.add(R.drawable.baseline_report_24);
}
if (message.canDeleteMessage(chatMode == MODE_SCHEDULED, currentChat) && (threadMessageObjects == null || !threadMessageObjects.contains(message))) {
items.add(LocaleController.getString("Delete", R.string.Delete));
@ -19065,7 +19068,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return;
}
MessageTransKt.translateMessages(this, new MessageObject[]{selectedObject});
MessageTransKt.translateMessages(this, new MessageObject[]{messageObject});
break;
@ -19219,9 +19222,21 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
case 200:
case 201: {
MessageObject messageObject = null;
if (selectedObjectGroup != null) {
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;
}
Intent open = new Intent(Intent.ACTION_SEND);
open.setType("application/pgp-message");
open.putExtra(Intent.EXTRA_TEXT, selectedObject.messageOwner.message);
open.putExtra(Intent.EXTRA_TEXT, messageObject.messageOwner.message);
open.setClassName(NekoConfig.openPGPApp, NekoConfig.openPGPApp + ".ui.DecryptActivity");
try {

View File

@ -44,6 +44,8 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.RequiresApi;
import org.telegram.messenger.AccountInstance;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader;
@ -101,10 +103,9 @@ import java.util.concurrent.CountDownLatch;
import kotlin.Unit;
import tw.nekomimi.nekogram.BottomBuilder;
import tw.nekomimi.nekogram.JalaliCalendar;
import tw.nekomimi.nekogram.NekoConfig;
import tw.nekomimi.nekogram.utils.VibrateUtil;
import androidx.annotation.RequiresApi;
public class AlertsCreator {
public static Dialog processError(int currentAccount, TLRPC.TL_error error, BaseFragment fragment, TLObject request, Object... args) {
@ -898,7 +899,7 @@ public class AlertsCreator {
return;
}
long inlineReturn = (fragment instanceof ChatActivity) ? ((ChatActivity) fragment).getInlineReturn() : 0;
if (Browser.isInternalUrl(url, null) || !ask) {
if (Browser.isInternalUrl(url, null) || !ask || NekoConfig.skipOpenLinkConfirm) {
Browser.openUrl(fragment.getParentActivity(), url, inlineReturn == 0, tryTelegraph);
} else {
String urlFinal;

View File

@ -4297,7 +4297,9 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
isInInput = use;
if (duration == 0) botButton.setVisibility(use ? View.GONE : View.VISIBLE);
if (duration == 0 && (hasBotCommands || botReplyMarkup != null)) {
botButton.setVisibility(use ? View.GONE : View.VISIBLE);
}
if (use) {
@ -6181,12 +6183,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
setSlowModeButtonVisible(false);
cancelBotButton.setVisibility(GONE);
audioVideoButtonContainer.setVisibility(GONE);
if (!NekoConfig.useChatAttachMediaMenu) {
attachLayout.setVisibility(GONE);
} else {
checkAttachButton(true, 150);
updateFieldRight(1);
}
sendButtonContainer.setVisibility(GONE);
if (scheduledButton != null) {
scheduledButton.setVisibility(GONE);
@ -6227,7 +6224,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
}
attachLayout.setScaleX(0.01f);
attachLayout.setAlpha(0.0f);
if (!NekoConfig.useChatAttachMediaMenu) attachLayout.setVisibility(GONE);
attachLayout.setVisibility(GONE);
audioVideoButtonContainer.setScaleX(0.1f);
audioVideoButtonContainer.setScaleY(0.1f);
audioVideoButtonContainer.setAlpha(0.0f);

View File

@ -12,8 +12,6 @@ public class JalaliCalendar extends Calendar {
public static Calendar mInstance() {
if (NekoConfig.usePersianCalender) return new JalaliCalendar();
return Calendar.getInstance();
}

View File

@ -1,20 +1,22 @@
package tw.nekomimi.nekogram;
import android.util.SparseArray;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.BaseController;
import org.telegram.messenger.MessageObject;
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.Cells.ChatMessageCell;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import tw.nekomimi.nekogram.utils.AlertUtil;
import java.util.HashMap;
public class MessageHelper extends BaseController {
@ -25,20 +27,16 @@ public class MessageHelper extends BaseController {
super(num);
}
public static void resetMessageContent(MessageObject messageObject) {
if (messageObject.caption != null) {
messageObject.caption = null;
messageObject.generateCaption();
messageObject.forceUpdate = true;
}
messageObject.applyNewText();
messageObject.resetLayout();
}
public void resetMessageContent(long dialog_id, MessageObject messageObject) {
TLRPC.Message message = messageObject.messageOwner;
final SparseArray<TLRPC.User> usersDict = new SparseArray<>();
final SparseArray<TLRPC.Chat> chatsDict = new SparseArray<>();
public static void resetMessageContent(ChatMessageCell chatMessageCell) {
chatMessageCell.onAttachedToWindow();
chatMessageCell.requestLayout();
chatMessageCell.invalidate();
MessageObject obj = new MessageObject(currentAccount, message, usersDict, chatsDict, true, true);
ArrayList<MessageObject> arrayList = new ArrayList<>();
arrayList.add(obj);
getNotificationCenter().postNotificationName(NotificationCenter.replaceMessagesObjects, dialog_id, arrayList, false);
}
public static MessageHelper getInstance(int num) {

View File

@ -1,6 +1,5 @@
package tw.nekomimi.nekogram.parts
import android.text.TextUtils
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
@ -8,9 +7,7 @@ import kotlinx.coroutines.withContext
import org.telegram.messenger.LocaleController
import org.telegram.messenger.MessageObject
import org.telegram.tgnet.TLRPC
import org.telegram.ui.Cells.ChatMessageCell
import org.telegram.ui.ChatActivity
import tw.nekomimi.nekogram.MessageHelper
import tw.nekomimi.nekogram.NekoConfig
import tw.nekomimi.nekogram.transtale.TranslateDb
import tw.nekomimi.nekogram.transtale.Translator
@ -89,24 +86,7 @@ fun ChatActivity.translateMessages(messages: Array<MessageObject>, target: Local
messageObject.messageOwner.translated = false
MessageHelper.resetMessageContent(messageObject);
for (index in 0 until chatListView.childCount) {
val cell = chatListView.getChildAt(index)
.takeIf { it is ChatMessageCell && it.messageObject === messageObject } as ChatMessageCell?
if (cell != null) {
MessageHelper.resetMessageContent(cell);
break
}
}
chatAdapter.updateRowWithMessageObject(messageObject, true)
messageHelper.resetMessageContent(dialogId, messageObject)
}
@ -132,38 +112,13 @@ fun ChatActivity.translateMessages(messages: Array<MessageObject>, target: Local
val isEnd = i == messages.size - 1
var messageCell: ChatMessageCell? = null
for (index in 0 until chatListView.childCount) {
val cell = chatListView.getChildAt(index)
.takeIf { it is ChatMessageCell && it.messageObject === selectedObject } as ChatMessageCell?
if (cell != null) {
messageCell = cell
break
}
}
if (selectedObject.translateFinished(target)) {
withContext(Dispatchers.Main) {
selectedObject.messageOwner.translated = true
MessageHelper.resetMessageContent(selectedObject)
messageCell?.also {
MessageHelper.resetMessageContent(it)
}
chatAdapter.updateRowWithMessageObject(selectedObject, true)
messageHelper.resetMessageContent(dialogId, selectedObject)
if (isEnd) status.dismiss()
@ -299,15 +254,7 @@ fun ChatActivity.translateMessages(messages: Array<MessageObject>, target: Local
withContext(Dispatchers.Main) {
MessageHelper.resetMessageContent(selectedObject)
messageCell?.also {
MessageHelper.resetMessageContent(it)
}
chatAdapter.updateRowWithMessageObject(selectedObject, true)
messageHelper.resetMessageContent(dialogId, selectedObject)
if (isEnd) status.dismiss()

View File

@ -764,7 +764,7 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
disableNumberRoundingRow = rowCount++;
openArchiveOnPullRow = rowCount++;
nameOrderRow = rowCount++;
usePersianCalenderRow = rowCount++;
usePersianCalenderRow = -1;
general2Row = rowCount++;
if (listAdapter != null) {