mirror of
https://github.com/DrKLO/Telegram.git
synced 2024-12-22 22:45:18 +01:00
Crash fixes
This commit is contained in:
parent
87cb843ea0
commit
15ac6cdb38
5 changed files with 39 additions and 28 deletions
|
@ -373,7 +373,11 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||||
sendMessage(null, null, null, null, null, null, null, null, audio, null, peer, false, path);
|
sendMessage(null, null, null, null, null, null, null, null, audio, null, peer, false, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
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) {
|
||||||
|
if (peer == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
TLRPC.Message newMsg = null;
|
TLRPC.Message newMsg = null;
|
||||||
int type = -1;
|
int type = -1;
|
||||||
int lower_id = (int) peer;
|
int lower_id = (int) peer;
|
||||||
|
@ -548,7 +552,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||||
if (high_id == 1) {
|
if (high_id == 1) {
|
||||||
if (currentChatInfo == null) {
|
if (currentChatInfo == null) {
|
||||||
processSentMessage(newMsg.id);
|
processSentMessage(newMsg.id);
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
sendToPeers = new ArrayList<TLRPC.InputUser>();
|
sendToPeers = new ArrayList<TLRPC.InputUser>();
|
||||||
for (TLRPC.TL_chatParticipant participant : currentChatInfo.participants) {
|
for (TLRPC.TL_chatParticipant participant : currentChatInfo.participants) {
|
||||||
|
@ -573,7 +577,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||||
TLRPC.User sendToUser = MessagesController.getInstance().getUser(lower_id);
|
TLRPC.User sendToUser = MessagesController.getInstance().getUser(lower_id);
|
||||||
if (sendToUser == null) {
|
if (sendToUser == null) {
|
||||||
processSentMessage(newMsg.id);
|
processSentMessage(newMsg.id);
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
if (sendToUser instanceof TLRPC.TL_userForeign || sendToUser instanceof TLRPC.TL_userRequest) {
|
if (sendToUser instanceof TLRPC.TL_userForeign || sendToUser instanceof TLRPC.TL_userRequest) {
|
||||||
sendToPeer = new TLRPC.TL_inputPeerForeign();
|
sendToPeer = new TLRPC.TL_inputPeerForeign();
|
||||||
|
@ -929,9 +933,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||||
newMsgObj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR;
|
newMsgObj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR;
|
||||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, newMsgObj.messageOwner.id);
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, newMsgObj.messageOwner.id);
|
||||||
processSentMessage(newMsgObj.messageOwner.id);
|
processSentMessage(newMsgObj.messageOwner.id);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
return newMsg != null ? newMsg.id : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void performSendDelayedMessage(final DelayedMessage message) {
|
private void performSendDelayedMessage(final DelayedMessage message) {
|
||||||
|
|
|
@ -2438,6 +2438,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if ((connection.transportRequestClass & RPCRequest.RPCRequestClassPush) != 0) {
|
} else if ((connection.transportRequestClass & RPCRequest.RPCRequestClassPush) != 0) {
|
||||||
|
FileLog.e("tmessages", "call connection closed");
|
||||||
sendingPushPing = false;
|
sendingPushPing = false;
|
||||||
lastPushPingTime = System.currentTimeMillis() - 60000 * 3 + 4000;
|
lastPushPingTime = System.currentTimeMillis() - 60000 * 3 + 4000;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,6 @@ import org.telegram.ui.Cells.ChatContactCell;
|
||||||
import org.telegram.ui.Cells.ChatMediaCell;
|
import org.telegram.ui.Cells.ChatMediaCell;
|
||||||
import org.telegram.ui.Cells.ChatMessageCell;
|
import org.telegram.ui.Cells.ChatMessageCell;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarLayout;
|
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
||||||
import org.telegram.ui.Views.BackupImageView;
|
import org.telegram.ui.Views.BackupImageView;
|
||||||
|
@ -131,7 +130,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
private View pagedownButton;
|
private View pagedownButton;
|
||||||
private TextView topPanelText;
|
private TextView topPanelText;
|
||||||
private long dialog_id;
|
private long dialog_id;
|
||||||
private boolean isBraodcast = false;
|
private boolean isBroadcast = false;
|
||||||
private HashMap<Integer, MessageObject> selectedMessagesIds = new HashMap<Integer, MessageObject>();
|
private HashMap<Integer, MessageObject> selectedMessagesIds = new HashMap<Integer, MessageObject>();
|
||||||
private HashMap<Integer, MessageObject> selectedMessagesCanCopyIds = new HashMap<Integer, MessageObject>();
|
private HashMap<Integer, MessageObject> selectedMessagesCanCopyIds = new HashMap<Integer, MessageObject>();
|
||||||
|
|
||||||
|
@ -241,15 +240,15 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
if (chatId > 0) {
|
if (chatId > 0) {
|
||||||
dialog_id = -chatId;
|
dialog_id = -chatId;
|
||||||
} else {
|
} else {
|
||||||
isBraodcast = true;
|
isBroadcast = true;
|
||||||
dialog_id = AndroidUtilities.makeBroadcastId(chatId);
|
dialog_id = AndroidUtilities.makeBroadcastId(chatId);
|
||||||
}
|
}
|
||||||
Semaphore semaphore = null;
|
Semaphore semaphore = null;
|
||||||
if (isBraodcast) {
|
if (isBroadcast) {
|
||||||
semaphore = new Semaphore(0);
|
semaphore = new Semaphore(0);
|
||||||
}
|
}
|
||||||
MessagesController.getInstance().loadChatInfo(currentChat.id, semaphore);
|
MessagesController.getInstance().loadChatInfo(currentChat.id, semaphore);
|
||||||
if (isBraodcast) {
|
if (isBroadcast) {
|
||||||
try {
|
try {
|
||||||
semaphore.acquire();
|
semaphore.acquire();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -1176,7 +1175,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
if (currentChat.photo != null) {
|
if (currentChat.photo != null) {
|
||||||
photo = currentChat.photo.photo_small;
|
photo = currentChat.photo.photo_small;
|
||||||
}
|
}
|
||||||
if (isBraodcast) {
|
if (isBroadcast) {
|
||||||
placeHolderId = AndroidUtilities.getBroadcastAvatarForId(currentChat.id);
|
placeHolderId = AndroidUtilities.getBroadcastAvatarForId(currentChat.id);
|
||||||
} else {
|
} else {
|
||||||
placeHolderId = AndroidUtilities.getGroupAvatarForId(currentChat.id);
|
placeHolderId = AndroidUtilities.getGroupAvatarForId(currentChat.id);
|
||||||
|
@ -1203,9 +1202,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getMessageType(MessageObject messageObject) {
|
private int getMessageType(MessageObject messageObject) {
|
||||||
|
if (messageObject == null) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if (currentEncryptedChat == null) {
|
if (currentEncryptedChat == null) {
|
||||||
boolean isBroadcastError = isBraodcast && messageObject.messageOwner.id <= 0 && messageObject.isSendError();
|
boolean isBroadcastError = isBroadcast && messageObject.messageOwner.id <= 0 && messageObject.isSendError();
|
||||||
if (!isBraodcast && messageObject.messageOwner.id <= 0 && messageObject.isOut() || isBroadcastError) {
|
if (!isBroadcast && messageObject.messageOwner.id <= 0 && messageObject.isOut() || isBroadcastError) {
|
||||||
if (messageObject.isSendError()) {
|
if (messageObject.isSendError()) {
|
||||||
if (!(messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty)) {
|
if (!(messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty)) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1447,7 +1449,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
if (currentChat.photo != null) {
|
if (currentChat.photo != null) {
|
||||||
newPhoto = currentChat.photo.photo_small;
|
newPhoto = currentChat.photo.photo_small;
|
||||||
}
|
}
|
||||||
if (isBraodcast) {
|
if (isBroadcast) {
|
||||||
placeHolderId = AndroidUtilities.getBroadcastAvatarForId(currentChat.id);
|
placeHolderId = AndroidUtilities.getBroadcastAvatarForId(currentChat.id);
|
||||||
} else {
|
} else {
|
||||||
placeHolderId = AndroidUtilities.getGroupAvatarForId(currentChat.id);
|
placeHolderId = AndroidUtilities.getGroupAvatarForId(currentChat.id);
|
||||||
|
@ -1458,7 +1460,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean openVideoEditor(String videoPath, boolean removeLast, ActionBarLayout parentLayout) {
|
public boolean openVideoEditor(String videoPath, boolean removeLast) {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putString("videoPath", videoPath);
|
args.putString("videoPath", videoPath);
|
||||||
VideoEditorActivity fragment = new VideoEditorActivity(args);
|
VideoEditorActivity fragment = new VideoEditorActivity(args);
|
||||||
|
@ -1543,7 +1545,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
if (paused) {
|
if (paused) {
|
||||||
startVideoEdit = videoPath;
|
startVideoEdit = videoPath;
|
||||||
} else {
|
} else {
|
||||||
openVideoEditor(videoPath, false, parentLayout);
|
openVideoEditor(videoPath, false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SendMessagesHelper.prepareSendingVideo(videoPath, 0, 0, 0, 0, null, dialog_id);
|
SendMessagesHelper.prepareSendingVideo(videoPath, 0, 0, 0, 0, null, dialog_id);
|
||||||
|
@ -1735,7 +1737,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
if (messArr.size() != count) {
|
if (messArr.size() != count) {
|
||||||
if (isCache) {
|
if (isCache) {
|
||||||
cacheEndReaced = true;
|
cacheEndReaced = true;
|
||||||
if (currentEncryptedChat != null || isBraodcast) {
|
if (currentEncryptedChat != null || isBroadcast) {
|
||||||
endReached = true;
|
endReached = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -2102,7 +2104,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
if (currentChat != null && chatId == currentChat.id) {
|
if (currentChat != null && chatId == currentChat.id) {
|
||||||
info = (TLRPC.ChatParticipants)args[1];
|
info = (TLRPC.ChatParticipants)args[1];
|
||||||
updateOnlineCount();
|
updateOnlineCount();
|
||||||
if (isBraodcast) {
|
if (isBroadcast) {
|
||||||
SendMessagesHelper.getInstance().setCurrentChatInfo(info);
|
SendMessagesHelper.getInstance().setCurrentChatInfo(info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2386,7 +2388,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
openVideoEditor(startVideoEdit, false, parentLayout);
|
openVideoEditor(startVideoEdit, false);
|
||||||
startVideoEdit = null;
|
startVideoEdit = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -2501,6 +2503,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
} else if (v instanceof ChatActionCell) {
|
} else if (v instanceof ChatActionCell) {
|
||||||
message = ((ChatActionCell)v).getMessageObject();
|
message = ((ChatActionCell)v).getMessageObject();
|
||||||
}
|
}
|
||||||
|
if (message == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
final int type = getMessageType(message);
|
final int type = getMessageType(message);
|
||||||
|
|
||||||
selectedObject = null;
|
selectedObject = null;
|
||||||
|
@ -2774,7 +2779,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
@Override
|
@Override
|
||||||
public void didSelectDialog(MessagesActivity activity, long did, boolean param) {
|
public void didSelectDialog(MessagesActivity activity, long did, boolean param) {
|
||||||
if (dialog_id != 0 && (forwaringMessage != null || !selectedMessagesIds.isEmpty())) {
|
if (dialog_id != 0 && (forwaringMessage != null || !selectedMessagesIds.isEmpty())) {
|
||||||
if (isBraodcast) {
|
if (isBroadcast) {
|
||||||
param = true;
|
param = true;
|
||||||
}
|
}
|
||||||
if (did != dialog_id) {
|
if (did != dialog_id) {
|
||||||
|
@ -3178,9 +3183,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
processRowSelect(cell);
|
processRowSelect(cell);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
MessageObject messageObject = cell.getMessageObject();
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putInt("user_id", message.messageOwner.media.user_id);
|
args.putInt("user_id", messageObject.messageOwner.media.user_id);
|
||||||
args.putString("phone", message.messageOwner.media.phone_number);
|
args.putString("phone", messageObject.messageOwner.media.phone_number);
|
||||||
presentFragment(new ContactAddActivity(args));
|
presentFragment(new ContactAddActivity(args));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -661,13 +661,15 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||||
actionBarLayout.presentFragment(fragment, false, true, true);
|
actionBarLayout.presentFragment(fragment, false, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fragment.openVideoEditor(videoPath, true, actionBarLayout)) {
|
if (!AndroidUtilities.isTablet()) {
|
||||||
if (!AndroidUtilities.isTablet()) {
|
|
||||||
actionBarLayout.presentFragment(fragment, true);
|
|
||||||
}
|
|
||||||
} else if (!AndroidUtilities.isTablet()) {
|
|
||||||
actionBarLayout.addFragmentToStack(fragment, actionBarLayout.fragmentsStack.size() - 1);
|
actionBarLayout.addFragmentToStack(fragment, actionBarLayout.fragmentsStack.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!fragment.openVideoEditor(videoPath, true)) {
|
||||||
|
if (!AndroidUtilities.isTablet()) {
|
||||||
|
messageFragment.finishFragment(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
actionBarLayout.presentFragment(fragment, true);
|
actionBarLayout.presentFragment(fragment, true);
|
||||||
SendMessagesHelper.prepareSendingVideo(videoPath, 0, 0, 0, 0, null, dialog_id);
|
SendMessagesHelper.prepareSendingVideo(videoPath, 0, 0, 0, 0, null, dialog_id);
|
||||||
|
|
|
@ -166,7 +166,7 @@ public class NumberPicker extends LinearLayout {
|
||||||
mInputText.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
mInputText.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||||
mInputText.setGravity(Gravity.CENTER);
|
mInputText.setGravity(Gravity.CENTER);
|
||||||
mInputText.setSingleLine(true);
|
mInputText.setSingleLine(true);
|
||||||
mInputText.setBackground(null);
|
mInputText.setBackgroundResource(0);
|
||||||
mInputText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
|
mInputText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
|
||||||
|
|
||||||
ViewConfiguration configuration = ViewConfiguration.get(context);
|
ViewConfiguration configuration = ViewConfiguration.get(context);
|
||||||
|
|
Loading…
Reference in a new issue