merge official 8.1.2

This commit is contained in:
luvletter2333 2021-09-28 01:10:49 +08:00
commit 97d13b90a4
No known key found for this signature in database
GPG Key ID: BFD68B892BECC1D8
14 changed files with 93 additions and 48 deletions

View File

@ -10,8 +10,8 @@ if (System.getenv("DEBUG_BUILD") == "true") {
verName += "-" + RuntimeUtil.execForStr("git log --pretty=format:'%h' -n 1")
}
def officialVer = "8.1.1"
def officialCode = 2431
def officialVer = "8.1.2"
def officialCode = 2432
def serviceAccountCredentialsFile = rootProject.file("service_account_credentials.json")

View File

@ -4054,10 +4054,27 @@ public class MediaDataController extends BaseController {
if (messageObject == null) {
continue;
}
if (messageObject.getId() > 0 && messageObject.isReply() && messageObject.replyMessageObject == null) {
if (messageObject.getId() > 0 && messageObject.isReply()) {
int messageId = messageObject.messageOwner.reply_to.reply_to_msg_id;
long did = MessageObject.getReplyToDialogId(messageObject.messageOwner);
long channelId = messageObject.messageOwner.peer_id != null ? messageObject.messageOwner.peer_id.channel_id : 0;
long channelId = 0;
if (messageObject.messageOwner.reply_to.reply_to_peer_id != null) {
if (messageObject.messageOwner.reply_to.reply_to_peer_id.channel_id != 0) {
channelId = messageObject.messageOwner.reply_to.reply_to_peer_id.channel_id;
}
} else
if (messageObject.messageOwner.peer_id.channel_id != 0) {
channelId = messageObject.messageOwner.peer_id.channel_id;
}
if (messageObject.replyMessageObject != null) {
if (messageObject.replyMessageObject.messageOwner == null || messageObject.replyMessageObject.messageOwner.peer_id == null || messageObject.messageOwner instanceof TLRPC.TL_messageEmpty) {
continue;
}
if (messageObject.replyMessageObject.messageOwner.peer_id.channel_id == channelId) {
continue;
}
}
SparseArray<ArrayList<MessageObject>> sparseArray = replyMessageOwners.get(dialogId);
ArrayList<Integer> ids = dialogReplyMessagesIds.get(channelId);
if (sparseArray == null) {
@ -4068,12 +4085,12 @@ public class MediaDataController extends BaseController {
ids = new ArrayList<>();
dialogReplyMessagesIds.put(channelId, ids);
}
ArrayList<MessageObject> arrayList = sparseArray.get(messageObject.messageOwner.reply_to.reply_to_msg_id);
ArrayList<MessageObject> arrayList = sparseArray.get(messageId);
if (arrayList == null) {
arrayList = new ArrayList<>();
sparseArray.put(messageObject.messageOwner.reply_to.reply_to_msg_id, arrayList);
if (!ids.contains(messageObject.messageOwner.reply_to.reply_to_msg_id)) {
ids.add(messageObject.messageOwner.reply_to.reply_to_msg_id);
sparseArray.put(messageId, arrayList);
if (!ids.contains(messageId)) {
ids.add(messageId);
}
}
arrayList.add(messageObject);
@ -4145,6 +4162,12 @@ public class MediaDataController extends BaseController {
getConnectionsManager().sendRequest(req, (response, error) -> {
if (error == null) {
TLRPC.messages_Messages messagesRes = (TLRPC.messages_Messages) response;
for (int i = 0; i < messagesRes.messages.size(); i++) {
TLRPC.Message message = messagesRes.messages.get(i);
if (message.dialog_id == 0) {
message.dialog_id = dialogId;
}
}
MessageObject.fixMessagePeer(messagesRes.messages, channelId);
ImageLoader.saveMessagesThumbs(messagesRes.messages);
broadcastReplyMessages(messagesRes.messages, replyMessageOwners, messagesRes.users, messagesRes.chats, dialogId, false);

View File

@ -2965,8 +2965,8 @@ public class MessageObject {
: LocaleController.formatString("ChatThemeDisabled", R.string.ChatThemeDisabled, userName, emoticon);
} else {
messageText = isUserSelf
? LocaleController.formatString("ChangedChatThemeYou", R.string.ChatThemeChangedYou, emoticon)
: LocaleController.formatString("ChangedChatThemeTo", R.string.ChatThemeChangedTo, userName, emoticon);
? LocaleController.formatString("ChatThemeChangedYou", R.string.ChatThemeChangedYou, emoticon)
: LocaleController.formatString("ChatThemeChangedTo", R.string.ChatThemeChangedTo, userName, emoticon);
}
}
}

View File

@ -52,6 +52,8 @@ import cn.hutool.core.util.StrUtil;
import tw.nekomimi.nekogram.NekoConfig;
import androidx.collection.LongSparseArray;
import com.google.android.exoplayer2.util.Log;
public class MessagesStorage extends BaseController {
public interface IntCallback {
@ -449,7 +451,12 @@ public class MessagesStorage extends BaseController {
FileLog.e(e);
}
if (version < LAST_DB_VERSION) {
updateDbToLastVersion(version);
try {
updateDbToLastVersion(version);
} catch (Exception e) {
FileLog.e(e);
throw new RuntimeException("malformed");
}
}
}
} catch (Exception e) {
@ -469,6 +476,13 @@ public class MessagesStorage extends BaseController {
openDatabase(openTries == 1 ? 2 : 3);
}
}
AndroidUtilities.runOnUIThread(() -> {
if (databaseMigrationInProgress) {
databaseMigrationInProgress = false;
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.onDatabaseMigration, false);
}
});
loadDialogFilters();
loadUnreadMessages();
loadPendingTasks();
@ -1273,8 +1287,12 @@ public class MessagesStorage extends BaseController {
SQLiteCursor cursor;
cursor = database.queryFinalized("SELECT mid, uid, read_state, send_state, date, data, out, ttl, media, replydata, imp, mention, forwards, replies_data, thread_reply_id FROM messages WHERE 1");
try {
cursor = database.queryFinalized("SELECT mid, uid, read_state, send_state, date, data, out, ttl, media, replydata, imp, mention, forwards, replies_data, thread_reply_id FROM messages WHERE 1");
} catch (Exception e) {
cursor = null;
FileLog.e(e);
}
if (cursor != null) {
SQLitePreparedStatement statement = database.executeFast("REPLACE INTO messages_v2 VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
int num = 0;

View File

@ -139,8 +139,6 @@ public class NotificationsController extends BaseController {
private int notificationId;
private String notificationGroup;
private int lastInternalNotificationId;
static {
if (Build.VERSION.SDK_INT >= 26 && ApplicationLoader.applicationContext != null) {
notificationManager = NotificationManagerCompat.from(ApplicationLoader.applicationContext);
@ -167,7 +165,7 @@ public class NotificationsController extends BaseController {
public NotificationsController(int instance) {
super(instance);
lastInternalNotificationId = instance * 1000000 + 5000;
notificationId = currentAccount + 1;
notificationGroup = "messages" + (currentAccount == 0 ? "" : currentAccount);
SharedPreferences preferences = getAccountInstance().getNotificationsSettings();
@ -3923,7 +3921,10 @@ lastInternalNotificationId = instance * 1000000 + 5000;
arrayList.add(messageObject);
}
LongSparseArray<Integer> oldIdsWear = wearNotificationsIds.clone();
LongSparseArray<Integer> oldIdsWear = new LongSparseArray<>();
for (int i = 0; i < wearNotificationsIds.size(); i++) {
oldIdsWear.put(wearNotificationsIds.keyAt(i), wearNotificationsIds.valueAt(i));
}
wearNotificationsIds.clear();
class NotificationHolder {
@ -3945,7 +3946,7 @@ lastInternalNotificationId = instance * 1000000 + 5000;
void call() {
if (BuildVars.LOGS_ENABLED) {
FileLog.w("show dialog notification with id " + id);
FileLog.w("show dialog notification with id " + id + " " + dialogId + " user=" + user + " chat=" + chat);
}
try {
notificationManager.notify(id, notification.build());
@ -3978,7 +3979,7 @@ lastInternalNotificationId = instance * 1000000 + 5000;
Integer internalId = oldIdsWear.get(dialogId);
if (internalId == null) {
internalId = lastInternalNotificationId++;
internalId = (int) dialogId + (int) (dialogId >> 32);
} else {
oldIdsWear.remove(dialogId);
}

View File

@ -232,9 +232,6 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter {
}
currentCount = count;
if (BuildVars.LOGS_ENABLED) {
FileLog.d("DialogsAdapter dialogsCount=" + dialogsCount + " dialogsType=" + dialogsType);
}
return count;
}

View File

@ -574,7 +574,9 @@ public class GroupCallUserCell extends FrameLayout {
}
private void applyParticipantChanges(boolean animated, boolean internal) {
TLRPC.Chat chat = accountInstance.getMessagesController().getChat(currentCall.chatId);
if (currentCall == null) {
return;
}
muteButton.setEnabled(!isSelfUser() || participant.raise_hand_rating != 0);
boolean hasVoice;

View File

@ -16494,13 +16494,16 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private void clearHistory(boolean overwrite, TLRPC.TL_updates_channelDifferenceTooLong differenceTooLong) {
if (overwrite) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("clear history by overwrite firstLoading=" + firstLoading + " minMessage=" + minMessageId[0] + " topMessage=" + differenceTooLong.dialog.top_message);
}
if (firstLoading) {
waitingForLoad.clear();
chatWasReset = true;
last_message_id = differenceTooLong.dialog.top_message;
createUnreadMessageAfterId = 0;
} else {
if (differenceTooLong.dialog.top_message > minMessageId[0]) {
last_message_id = Math.max(last_message_id, differenceTooLong.dialog.top_message);
createUnreadMessageAfterId = Math.max(minMessageId[0] + 1, differenceTooLong.dialog.read_inbox_max_id);
}
}
@ -25260,7 +25263,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (BuildVars.LOGS_ENABLED) {
FileLog.d("notify data set changed");
}
if (animated && fragmentOpened && BuildVars.DEBUG_VERSION) {
if (animated && fragmentOpened) {
if (chatListView.getItemAnimator() != chatListItemAnimator) {
chatListView.setItemAnimator(chatListItemAnimator);
}

View File

@ -565,7 +565,7 @@ public class ChatThemeBottomSheet extends BottomSheet implements NotificationCen
}
private void onAnimationStart() {
if (adapter != null) {
if (adapter != null && adapter.items != null) {
for (ChatThemeItem item : adapter.items) {
item.isDark = forceDark;
}

View File

@ -2157,14 +2157,14 @@ public class ShareAlert extends BottomSheet implements NotificationCenter.Notifi
itemsCount += recentSearchObjects.size();
}
lastFilledItem = itemsCount++;
return itemsCount;
return lastItemCont = itemsCount;
} else {
firstEmptyViewCell = itemsCount++;
searchResultsStartRow = itemsCount;
itemsCount += (searchResult.size() + searchAdapterHelper.getLocalServerSearch().size());
if (itemsCount == 1) {
firstEmptyViewCell = -1;
return 0;
return lastItemCont = itemsCount = 0;
}
lastFilledItem = itemsCount++;
}

View File

@ -385,7 +385,6 @@ public class EmojiAnimationsOverlay implements NotificationCenter.NotificationCe
lastTappedTime = System.currentTimeMillis();
timeIntervals.clear();
animationIndexes.clear();
;
timeIntervals.add(0L);
animationIndexes.add(animation);
} else {

View File

@ -308,7 +308,7 @@ public class ExternalActionActivity extends Activity implements ActionBarLayout.
}
}
final long bot_id = intent.getLongExtra("bot_id", 0);
final long bot_id = intent.getLongExtra("bot_id", intent.getIntExtra("bot_id", 0));
final String nonce = intent.getStringExtra("nonce");
final String payload = intent.getStringExtra("payload");
final TLRPC.TL_account_getAuthorizationForm req = new TLRPC.TL_account_getAuthorizationForm();

View File

@ -2075,26 +2075,28 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
TLRPC.TL_help_getCountriesList req = new TLRPC.TL_help_getCountriesList();
req.lang_code = "";
getConnectionsManager().sendRequest(req, (response, error) -> {
if (error == null) {
countriesArray.clear();
codesMap.clear();
phoneFormatMap.clear();
TLRPC.TL_help_countriesList help_countriesList = (TLRPC.TL_help_countriesList) response;
for (int i = 0; i < help_countriesList.countries.size(); i++) {
TLRPC.TL_help_country c = help_countriesList.countries.get(i);
for (int k = 0; k < c.country_codes.size(); k++) {
CountrySelectActivity.Country countryWithCode = new CountrySelectActivity.Country();
countryWithCode.name = c.default_name;
countryWithCode.code = c.country_codes.get(k).country_code;
AndroidUtilities.runOnUIThread(() -> {
if (error == null) {
countriesArray.clear();
codesMap.clear();
phoneFormatMap.clear();
TLRPC.TL_help_countriesList help_countriesList = (TLRPC.TL_help_countriesList) response;
for (int i = 0; i < help_countriesList.countries.size(); i++) {
TLRPC.TL_help_country c = help_countriesList.countries.get(i);
for (int k = 0; k < c.country_codes.size(); k++) {
CountrySelectActivity.Country countryWithCode = new CountrySelectActivity.Country();
countryWithCode.name = c.default_name;
countryWithCode.code = c.country_codes.get(k).country_code;
countriesArray.add(countryWithCode);
codesMap.put(c.country_codes.get(k).country_code, countryWithCode);
if (c.country_codes.get(k).patterns.size() > 0) {
phoneFormatMap.put(c.country_codes.get(k).country_code, c.country_codes.get(k).patterns.get(0));
countriesArray.add(countryWithCode);
codesMap.put(c.country_codes.get(k).country_code, countryWithCode);
if (c.country_codes.get(k).patterns.size() > 0) {
phoneFormatMap.put(c.country_codes.get(k).country_code, c.country_codes.get(k).patterns.get(0));
}
}
}
}
}
});
}, ConnectionsManager.RequestFlagWithoutLogin | ConnectionsManager.RequestFlagFailOnServerErrors);
}

View File

@ -2565,7 +2565,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
}
if (position == settingsKeyRow) {
Bundle args = new Bundle();
args.putLong("chat_id", DialogObject.getEncryptedChatId(dialogId));
args.putInt("chat_id", DialogObject.getEncryptedChatId(dialogId));
presentFragment(new IdenticonActivity(args));
} else if (position == settingsTimerRow) {
showDialog(AlertsCreator.createTTLAlert(getParentActivity(), currentEncryptedChat, null).create());