Skip to content

Commit a38e46c

Browse files
author
DrKLO
committed
Bug fixes
1 parent dd61bba commit a38e46c

19 files changed

+178
-114
lines changed

TMessagesProj/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ android {
8080
defaultConfig {
8181
minSdkVersion 8
8282
targetSdkVersion 21
83-
versionCode 391
84-
versionName "2.0.2"
83+
versionCode 392
84+
versionName "2.0.3"
8585
}
8686
}

TMessagesProj/src/main/java/org/telegram/android/ContactsController.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,6 +1636,9 @@ public void run() {
16361636
TLRPC.User toDbUser = new TLRPC.User();
16371637
TLRPC.TL_contactStatus status = (TLRPC.TL_contactStatus) object;
16381638

1639+
if (status == null) {
1640+
continue;
1641+
}
16391642
if (status.status instanceof TLRPC.TL_userStatusRecently) {
16401643
status.status.expires = -100;
16411644
} else if (status.status instanceof TLRPC.TL_userStatusLastWeek) {

TMessagesProj/src/main/java/org/telegram/android/MessagesController.java

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,77 +1062,76 @@ public void deleteDialog(final long did, int offset, final boolean onlyHistory)
10621062
if (offset == 0) {
10631063
MessagesStorage.getInstance().deleteDialog(did, onlyHistory);
10641064
}
1065-
TLRPC.TL_dialog dialog = dialogs_dict.get(did);
1066-
if (dialog != null) {
1067-
int lower_part = (int)did;
1068-
int high_id = (int)(did >> 32);
10691065

1070-
if (offset == 0) {
1071-
if (!onlyHistory) {
1072-
dialogs.remove(dialog);
1073-
dialogsServerOnly.remove(dialog);
1074-
dialogs_dict.remove(did);
1075-
totalDialogsCount--;
1076-
} else {
1077-
dialog.unread_count = 0;
1078-
}
1079-
dialogMessage.remove(dialog.top_message);
1080-
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
1081-
@Override
1082-
public void run() {
1083-
AndroidUtilities.runOnUIThread(new Runnable() {
1084-
@Override
1085-
public void run() {
1086-
NotificationsController.getInstance().processReadMessages(null, did, 0, Integer.MAX_VALUE, false);
1087-
HashMap<Long, Integer> dialogsToUpdate = new HashMap<Long, Integer>();
1088-
dialogsToUpdate.put(did, 0);
1089-
NotificationsController.getInstance().processDialogsUpdateRead(dialogsToUpdate);
1090-
}
1091-
});
1092-
}
1093-
});
1094-
NotificationCenter.getInstance().postNotificationName(NotificationCenter.removeAllMessagesFromDialog, did);
1095-
NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload);
1096-
}
1066+
int lower_part = (int)did;
1067+
int high_id = (int)(did >> 32);
10971068

1098-
if (high_id == 1) {
1099-
return;
1069+
if (offset == 0) {
1070+
TLRPC.TL_dialog dialog = dialogs_dict.get(did);
1071+
if (!onlyHistory) {
1072+
dialogs.remove(dialog);
1073+
dialogsServerOnly.remove(dialog);
1074+
dialogs_dict.remove(did);
1075+
totalDialogsCount--;
1076+
} else {
1077+
dialog.unread_count = 0;
11001078
}
1079+
dialogMessage.remove(dialog.top_message);
1080+
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
1081+
@Override
1082+
public void run() {
1083+
AndroidUtilities.runOnUIThread(new Runnable() {
1084+
@Override
1085+
public void run() {
1086+
NotificationsController.getInstance().processReadMessages(null, did, 0, Integer.MAX_VALUE, false);
1087+
HashMap<Long, Integer> dialogsToUpdate = new HashMap<Long, Integer>();
1088+
dialogsToUpdate.put(did, 0);
1089+
NotificationsController.getInstance().processDialogsUpdateRead(dialogsToUpdate);
1090+
}
1091+
});
1092+
}
1093+
});
1094+
NotificationCenter.getInstance().postNotificationName(NotificationCenter.removeAllMessagesFromDialog, did);
1095+
NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload);
1096+
}
11011097

1102-
if (lower_part != 0) {
1103-
TLRPC.TL_messages_deleteHistory req = new TLRPC.TL_messages_deleteHistory();
1104-
req.offset = offset;
1105-
if (did < 0) {
1106-
req.peer = new TLRPC.TL_inputPeerChat();
1107-
req.peer.chat_id = -lower_part;
1098+
if (high_id == 1) {
1099+
return;
1100+
}
1101+
1102+
if (lower_part != 0) {
1103+
TLRPC.TL_messages_deleteHistory req = new TLRPC.TL_messages_deleteHistory();
1104+
req.offset = offset;
1105+
if (did < 0) {
1106+
req.peer = new TLRPC.TL_inputPeerChat();
1107+
req.peer.chat_id = -lower_part;
1108+
} else {
1109+
TLRPC.User user = getUser(lower_part);
1110+
if (user instanceof TLRPC.TL_userForeign || user instanceof TLRPC.TL_userRequest) {
1111+
req.peer = new TLRPC.TL_inputPeerForeign();
1112+
req.peer.access_hash = user.access_hash;
11081113
} else {
1109-
TLRPC.User user = getUser(lower_part);
1110-
if (user instanceof TLRPC.TL_userForeign || user instanceof TLRPC.TL_userRequest) {
1111-
req.peer = new TLRPC.TL_inputPeerForeign();
1112-
req.peer.access_hash = user.access_hash;
1113-
} else {
1114-
req.peer = new TLRPC.TL_inputPeerContact();
1115-
}
1116-
req.peer.user_id = lower_part;
1114+
req.peer = new TLRPC.TL_inputPeerContact();
11171115
}
1118-
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
1119-
@Override
1120-
public void run(TLObject response, TLRPC.TL_error error) {
1121-
if (error == null) {
1122-
TLRPC.TL_messages_affectedHistory res = (TLRPC.TL_messages_affectedHistory) response;
1123-
if (res.offset > 0) {
1124-
deleteDialog(did, res.offset, onlyHistory);
1125-
}
1126-
processNewDifferenceParams(res.seq, res.pts, -1);
1116+
req.peer.user_id = lower_part;
1117+
}
1118+
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
1119+
@Override
1120+
public void run(TLObject response, TLRPC.TL_error error) {
1121+
if (error == null) {
1122+
TLRPC.TL_messages_affectedHistory res = (TLRPC.TL_messages_affectedHistory) response;
1123+
if (res.offset > 0) {
1124+
deleteDialog(did, res.offset, onlyHistory);
11271125
}
1126+
processNewDifferenceParams(res.seq, res.pts, -1);
11281127
}
1129-
});
1130-
} else {
1131-
if (onlyHistory) {
1132-
SendMessagesHelper.getInstance().sendClearHistoryMessage(getEncryptedChat(high_id), null);
1133-
} else {
1134-
declineSecretChat(high_id);
11351128
}
1129+
});
1130+
} else {
1131+
if (onlyHistory) {
1132+
SendMessagesHelper.getInstance().sendClearHistoryMessage(getEncryptedChat(high_id), null);
1133+
} else {
1134+
declineSecretChat(high_id);
11361135
}
11371136
}
11381137
}
@@ -1455,6 +1454,7 @@ public void loadDialogs(final int offset, final int serverOffset, final int coun
14551454
return;
14561455
}
14571456
loadingDialogs = true;
1457+
NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload);
14581458

14591459
if (fromCache) {
14601460
MessagesStorage.getInstance().getDialogs(offset, serverOffset, count);

TMessagesProj/src/main/java/org/telegram/android/NotificationsController.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,10 @@ private void showOrUpdateNotification(boolean notifyAboutLast) {
397397
.setGroup("messages")
398398
.setGroupSummary(true);
399399

400+
//if (ApplicationLoader.mainInterfacePaused) {
401+
// mBuilder.setPriority(NotificationCompat.PRIORITY_HIGH);
402+
//}
403+
400404
String lastMessage = null;
401405
String lastMessageFull = null;
402406
if (pushMessages.size() == 1) {

TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2236,6 +2236,17 @@ public void run() {
22362236

22372237
lastOutgoingMessageId = Math.max(messageId, lastOutgoingMessageId);
22382238
}
2239+
long resultMid = ((TLRPC.TL_bad_server_salt) message).bad_msg_id;
2240+
if (resultMid != 0) {
2241+
for (RPCRequest request : runningRequests) {
2242+
if ((request.flags & RPCRequest.RPCRequestClassDownloadMedia) == 0) {
2243+
continue;
2244+
}
2245+
if (request.respondsToMessageId(resultMid)) {
2246+
request.retryCount = 0;
2247+
}
2248+
}
2249+
}
22392250

22402251
datacenter.clearServerSalts();
22412252

TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -628,8 +628,7 @@ public void run() {
628628
currentAnimation = new AnimatorSetProxy();
629629
currentAnimation.playTogether(
630630
ObjectAnimatorProxy.ofFloat(containerView, "alpha", 0.0f, 1.0f),
631-
ObjectAnimatorProxy.ofFloat(containerView, "scaleX", 0.8f, 1.0f),
632-
ObjectAnimatorProxy.ofFloat(containerView, "scaleY", 0.8f, 1.0f));
631+
ObjectAnimatorProxy.ofFloat(containerView, "translationY", AndroidUtilities.dp(48), 0));
633632
currentAnimation.setInterpolator(new DecelerateInterpolator(1.5f));
634633
currentAnimation.setDuration(200);
635634
currentAnimation.addListener(new AnimatorListenerAdapterProxy() {
@@ -731,14 +730,14 @@ public void closeLastFragment(boolean animated) {
731730
@Override
732731
public void run() {
733732
closeLastFragmentInternalRemoveOld(currentFragment);
733+
ViewProxy.setTranslationY(containerViewBack, 0);
734734
}
735735
};
736736

737737
currentAnimation = new AnimatorSetProxy();
738738
currentAnimation.playTogether(
739739
ObjectAnimatorProxy.ofFloat(containerViewBack, "alpha", 1.0f, 0.0f),
740-
ObjectAnimatorProxy.ofFloat(containerViewBack, "scaleX", 1.0f, 0.8f),
741-
ObjectAnimatorProxy.ofFloat(containerViewBack, "scaleY", 1.0f, 0.8f));
740+
ObjectAnimatorProxy.ofFloat(containerViewBack, "translationY", 0, AndroidUtilities.dp(48)));
742741
currentAnimation.setInterpolator(new DecelerateInterpolator(1.5f));
743742
currentAnimation.setDuration(200);
744743
currentAnimation.addListener(new AnimatorListenerAdapterProxy() {

TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenu.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,9 @@ public void onMenuButtonPressed() {
134134
View view = getChildAt(a);
135135
if (view instanceof ActionBarMenuItem) {
136136
ActionBarMenuItem item = (ActionBarMenuItem)view;
137-
if (item.hasSubMenu()) {
137+
if (item.hasSubMenu() && item.getVisibility() == VISIBLE) {
138138
item.toggleSubMenu();
139+
break;
139140
}
140141
}
141142
}

TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -214,15 +214,19 @@ protected void showAlertDialog(AlertDialog.Builder builder) {
214214
} catch (Exception e) {
215215
FileLog.e("tmessages", e);
216216
}
217-
visibleDialog = builder.show();
218-
visibleDialog.setCanceledOnTouchOutside(true);
219-
visibleDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
220-
@Override
221-
public void onDismiss(DialogInterface dialog) {
222-
visibleDialog = null;
223-
onDialogDismiss();
224-
}
225-
});
217+
try {
218+
visibleDialog = builder.show();
219+
visibleDialog.setCanceledOnTouchOutside(true);
220+
visibleDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
221+
@Override
222+
public void onDismiss(DialogInterface dialog) {
223+
visibleDialog = null;
224+
onDialogDismiss();
225+
}
226+
});
227+
} catch (Exception e) {
228+
FileLog.e("tmessages", e);
229+
}
226230
}
227231

228232
protected void onDialogDismiss() {

TMessagesProj/src/main/java/org/telegram/ui/Adapters/ContactsAdapter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ public Object getItem(int section, int position) {
5252
if (onlyUsers) {
5353
if (section < ContactsController.getInstance().sortedUsersSectionsArray.size()) {
5454
ArrayList<TLRPC.TL_contact> arr = ContactsController.getInstance().usersSectionsDict.get(ContactsController.getInstance().sortedUsersSectionsArray.get(section));
55-
return MessagesController.getInstance().getUser(arr.get(position).user_id);
55+
if (position < arr.size()) {
56+
return MessagesController.getInstance().getUser(arr.get(position).user_id);
57+
}
5658
}
5759
return null;
5860
} else {

TMessagesProj/src/main/java/org/telegram/ui/ChangeUsernameActivity.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,11 @@ private boolean checkUserName(final String name, boolean alert) {
236236
}
237237
lastNameAvailable = false;
238238
if (name != null) {
239+
if (name.startsWith("_") || name.endsWith("_")) {
240+
checkTextView.setText(LocaleController.getString("UsernameInvalid", R.string.UsernameInvalid));
241+
checkTextView.setTextColor(0xffcf3030);
242+
return false;
243+
}
239244
for (int a = 0; a < name.length(); a++) {
240245
char ch = name.charAt(a);
241246
if (a == 0 && ch >= '0' && ch <= '9') {

0 commit comments

Comments
 (0)