Skip to content

Commit 15ac6cd

Browse files
author
DrKLO
committed
Crash fixes
1 parent 87cb843 commit 15ac6cd

File tree

5 files changed

+38
-27
lines changed

5 files changed

+38
-27
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,11 @@ public void sendMessage(TLRPC.TL_audio audio, String path, long peer) {
373373
sendMessage(null, null, null, null, null, null, null, null, audio, null, peer, false, path);
374374
}
375375

376-
private int sendMessage(String message, Double lat, Double lon, TLRPC.TL_photo photo, TLRPC.TL_video video, MessageObject msgObj, TLRPC.User user, TLRPC.TL_document document, TLRPC.TL_audio audio, String originalPath, long peer, boolean retry, String path) {
376+
private void sendMessage(String message, Double lat, Double lon, TLRPC.TL_photo photo, TLRPC.TL_video video, MessageObject msgObj, TLRPC.User user, TLRPC.TL_document document, TLRPC.TL_audio audio, String originalPath, long peer, boolean retry, String path) {
377+
if (peer == 0) {
378+
return;
379+
}
380+
377381
TLRPC.Message newMsg = null;
378382
int type = -1;
379383
int lower_id = (int) peer;
@@ -548,7 +552,7 @@ private int sendMessage(String message, Double lat, Double lon, TLRPC.TL_photo p
548552
if (high_id == 1) {
549553
if (currentChatInfo == null) {
550554
processSentMessage(newMsg.id);
551-
return 0;
555+
return;
552556
}
553557
sendToPeers = new ArrayList<TLRPC.InputUser>();
554558
for (TLRPC.TL_chatParticipant participant : currentChatInfo.participants) {
@@ -573,7 +577,7 @@ private int sendMessage(String message, Double lat, Double lon, TLRPC.TL_photo p
573577
TLRPC.User sendToUser = MessagesController.getInstance().getUser(lower_id);
574578
if (sendToUser == null) {
575579
processSentMessage(newMsg.id);
576-
return 0;
580+
return;
577581
}
578582
if (sendToUser instanceof TLRPC.TL_userForeign || sendToUser instanceof TLRPC.TL_userRequest) {
579583
sendToPeer = new TLRPC.TL_inputPeerForeign();
@@ -929,9 +933,7 @@ private int sendMessage(String message, Double lat, Double lon, TLRPC.TL_photo p
929933
newMsgObj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR;
930934
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, newMsgObj.messageOwner.id);
931935
processSentMessage(newMsgObj.messageOwner.id);
932-
return 0;
933936
}
934-
return newMsg != null ? newMsg.id : 0;
935937
}
936938

937939
private void performSendDelayedMessage(final DelayedMessage message) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2438,6 +2438,7 @@ public void run() {
24382438
}
24392439
});
24402440
} else if ((connection.transportRequestClass & RPCRequest.RPCRequestClassPush) != 0) {
2441+
FileLog.e("tmessages", "call connection closed");
24412442
sendingPushPing = false;
24422443
lastPushPingTime = System.currentTimeMillis() - 60000 * 3 + 4000;
24432444
}

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

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@
7171
import org.telegram.ui.Cells.ChatMediaCell;
7272
import org.telegram.ui.Cells.ChatMessageCell;
7373
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
74-
import org.telegram.ui.Views.ActionBar.ActionBarLayout;
7574
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
7675
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
7776
import org.telegram.ui.Views.BackupImageView;
@@ -131,7 +130,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
131130
private View pagedownButton;
132131
private TextView topPanelText;
133132
private long dialog_id;
134-
private boolean isBraodcast = false;
133+
private boolean isBroadcast = false;
135134
private HashMap<Integer, MessageObject> selectedMessagesIds = new HashMap<Integer, MessageObject>();
136135
private HashMap<Integer, MessageObject> selectedMessagesCanCopyIds = new HashMap<Integer, MessageObject>();
137136

@@ -241,15 +240,15 @@ public void run() {
241240
if (chatId > 0) {
242241
dialog_id = -chatId;
243242
} else {
244-
isBraodcast = true;
243+
isBroadcast = true;
245244
dialog_id = AndroidUtilities.makeBroadcastId(chatId);
246245
}
247246
Semaphore semaphore = null;
248-
if (isBraodcast) {
247+
if (isBroadcast) {
249248
semaphore = new Semaphore(0);
250249
}
251250
MessagesController.getInstance().loadChatInfo(currentChat.id, semaphore);
252-
if (isBraodcast) {
251+
if (isBroadcast) {
253252
try {
254253
semaphore.acquire();
255254
} catch (Exception e) {
@@ -1176,7 +1175,7 @@ public void onClick(View view) {
11761175
if (currentChat.photo != null) {
11771176
photo = currentChat.photo.photo_small;
11781177
}
1179-
if (isBraodcast) {
1178+
if (isBroadcast) {
11801179
placeHolderId = AndroidUtilities.getBroadcastAvatarForId(currentChat.id);
11811180
} else {
11821181
placeHolderId = AndroidUtilities.getGroupAvatarForId(currentChat.id);
@@ -1203,9 +1202,12 @@ private void updateOnlineCount() {
12031202
}
12041203

12051204
private int getMessageType(MessageObject messageObject) {
1205+
if (messageObject == null) {
1206+
return -1;
1207+
}
12061208
if (currentEncryptedChat == null) {
1207-
boolean isBroadcastError = isBraodcast && messageObject.messageOwner.id <= 0 && messageObject.isSendError();
1208-
if (!isBraodcast && messageObject.messageOwner.id <= 0 && messageObject.isOut() || isBroadcastError) {
1209+
boolean isBroadcastError = isBroadcast && messageObject.messageOwner.id <= 0 && messageObject.isSendError();
1210+
if (!isBroadcast && messageObject.messageOwner.id <= 0 && messageObject.isOut() || isBroadcastError) {
12091211
if (messageObject.isSendError()) {
12101212
if (!(messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty)) {
12111213
return 0;
@@ -1447,7 +1449,7 @@ private void checkAndUpdateAvatar() {
14471449
if (currentChat.photo != null) {
14481450
newPhoto = currentChat.photo.photo_small;
14491451
}
1450-
if (isBraodcast) {
1452+
if (isBroadcast) {
14511453
placeHolderId = AndroidUtilities.getBroadcastAvatarForId(currentChat.id);
14521454
} else {
14531455
placeHolderId = AndroidUtilities.getGroupAvatarForId(currentChat.id);
@@ -1458,7 +1460,7 @@ private void checkAndUpdateAvatar() {
14581460
}
14591461
}
14601462

1461-
public boolean openVideoEditor(String videoPath, boolean removeLast, ActionBarLayout parentLayout) {
1463+
public boolean openVideoEditor(String videoPath, boolean removeLast) {
14621464
Bundle args = new Bundle();
14631465
args.putString("videoPath", videoPath);
14641466
VideoEditorActivity fragment = new VideoEditorActivity(args);
@@ -1543,7 +1545,7 @@ public void onActivityResultFragment(int requestCode, int resultCode, Intent dat
15431545
if (paused) {
15441546
startVideoEdit = videoPath;
15451547
} else {
1546-
openVideoEditor(videoPath, false, parentLayout);
1548+
openVideoEditor(videoPath, false);
15471549
}
15481550
} else {
15491551
SendMessagesHelper.prepareSendingVideo(videoPath, 0, 0, 0, 0, null, dialog_id);
@@ -1735,7 +1737,7 @@ public void didReceivedNotification(int id, final Object... args) {
17351737
if (messArr.size() != count) {
17361738
if (isCache) {
17371739
cacheEndReaced = true;
1738-
if (currentEncryptedChat != null || isBraodcast) {
1740+
if (currentEncryptedChat != null || isBroadcast) {
17391741
endReached = true;
17401742
}
17411743
} else {
@@ -2102,7 +2104,7 @@ public void run() {
21022104
if (currentChat != null && chatId == currentChat.id) {
21032105
info = (TLRPC.ChatParticipants)args[1];
21042106
updateOnlineCount();
2105-
if (isBraodcast) {
2107+
if (isBroadcast) {
21062108
SendMessagesHelper.getInstance().setCurrentChatInfo(info);
21072109
}
21082110
}
@@ -2386,7 +2388,7 @@ public void onResume() {
23862388
AndroidUtilities.RunOnUIThread(new Runnable() {
23872389
@Override
23882390
public void run() {
2389-
openVideoEditor(startVideoEdit, false, parentLayout);
2391+
openVideoEditor(startVideoEdit, false);
23902392
startVideoEdit = null;
23912393
}
23922394
});
@@ -2501,6 +2503,9 @@ public void createMenu(View v, boolean single) {
25012503
} else if (v instanceof ChatActionCell) {
25022504
message = ((ChatActionCell)v).getMessageObject();
25032505
}
2506+
if (message == null) {
2507+
return;
2508+
}
25042509
final int type = getMessageType(message);
25052510

25062511
selectedObject = null;
@@ -2774,7 +2779,7 @@ private void forwardSelectedMessages(long did, boolean fromMyName) {
27742779
@Override
27752780
public void didSelectDialog(MessagesActivity activity, long did, boolean param) {
27762781
if (dialog_id != 0 && (forwaringMessage != null || !selectedMessagesIds.isEmpty())) {
2777-
if (isBraodcast) {
2782+
if (isBroadcast) {
27782783
param = true;
27792784
}
27802785
if (did != dialog_id) {
@@ -3178,9 +3183,10 @@ public void didClickAddButton(ChatContactCell cell, TLRPC.User user) {
31783183
processRowSelect(cell);
31793184
return;
31803185
}
3186+
MessageObject messageObject = cell.getMessageObject();
31813187
Bundle args = new Bundle();
3182-
args.putInt("user_id", message.messageOwner.media.user_id);
3183-
args.putString("phone", message.messageOwner.media.phone_number);
3188+
args.putInt("user_id", messageObject.messageOwner.media.user_id);
3189+
args.putString("phone", messageObject.messageOwner.media.phone_number);
31843190
presentFragment(new ContactAddActivity(args));
31853191
}
31863192

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -661,12 +661,14 @@ public void didSelectDialog(MessagesActivity messageFragment, long dialog_id, bo
661661
actionBarLayout.presentFragment(fragment, false, true, true);
662662
}
663663

664-
if (!fragment.openVideoEditor(videoPath, true, actionBarLayout)) {
664+
if (!AndroidUtilities.isTablet()) {
665+
actionBarLayout.addFragmentToStack(fragment, actionBarLayout.fragmentsStack.size() - 1);
666+
}
667+
668+
if (!fragment.openVideoEditor(videoPath, true)) {
665669
if (!AndroidUtilities.isTablet()) {
666-
actionBarLayout.presentFragment(fragment, true);
670+
messageFragment.finishFragment(true);
667671
}
668-
} else if (!AndroidUtilities.isTablet()) {
669-
actionBarLayout.addFragmentToStack(fragment, actionBarLayout.fragmentsStack.size() - 1);
670672
}
671673
} else {
672674
actionBarLayout.presentFragment(fragment, true);

TMessagesProj/src/main/java/org/telegram/ui/Views/NumberPicker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public NumberPicker(Context context, AttributeSet attrs, int defStyle) {
166166
mInputText.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
167167
mInputText.setGravity(Gravity.CENTER);
168168
mInputText.setSingleLine(true);
169-
mInputText.setBackground(null);
169+
mInputText.setBackgroundResource(0);
170170
mInputText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
171171

172172
ViewConfiguration configuration = ViewConfiguration.get(context);

0 commit comments

Comments
 (0)