From fa1734518d8df5746d4bbbffe87dc9cd8dc40899 Mon Sep 17 00:00:00 2001 From: DrKLO Date: Sat, 12 Jul 2014 01:47:50 +0400 Subject: [PATCH] Bug fixes --- TMessagesProj/build.gradle | 2 +- .../android/NotificationsController.java | 3 ++- .../messenger/ConnectionsManager.java | 1 + .../org/telegram/objects/MessageObject.java | 11 +++++++--- .../java/org/telegram/ui/ChatActivity.java | 21 ++++++++++++------- .../org/telegram/ui/UserProfileActivity.java | 2 +- 6 files changed, 27 insertions(+), 13 deletions(-) diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle index 80e5c11c..720603a3 100644 --- a/TMessagesProj/build.gradle +++ b/TMessagesProj/build.gradle @@ -83,7 +83,7 @@ android { defaultConfig { minSdkVersion 8 targetSdkVersion 19 - versionCode 273 + versionCode 274 versionName "1.6.0" } } diff --git a/TMessagesProj/src/main/java/org/telegram/android/NotificationsController.java b/TMessagesProj/src/main/java/org/telegram/android/NotificationsController.java index bda2d26a..8339743a 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/NotificationsController.java +++ b/TMessagesProj/src/main/java/org/telegram/android/NotificationsController.java @@ -547,9 +547,9 @@ public class NotificationsController { } if (old_unread_count != total_unread_count) { showOrUpdateNotification(notifyCheck); - setBadge(ApplicationLoader.applicationContext, total_unread_count); notifyCheck = false; } + setBadge(ApplicationLoader.applicationContext, total_unread_count); } public void processLoadedUnreadMessages(HashMap dialogs) { @@ -569,6 +569,7 @@ public class NotificationsController { dialogsToLoad += "" + dialog_id; } } + setBadge(ApplicationLoader.applicationContext, total_unread_count); } private void setBadge(Context context, int count) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java b/TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java index c8944094..5e93263a 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java @@ -788,6 +788,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. if (object.layer() > 0) { Datacenter datacenter = datacenterWithId(datacenterId); if (datacenter == null || datacenter.lastInitVersion != currentAppVersion) { + registerForPush(); request.initRequest = true; TLRPC.initConnection invoke = new TLRPC.initConnection(); invoke.query = object; diff --git a/TMessagesProj/src/main/java/org/telegram/objects/MessageObject.java b/TMessagesProj/src/main/java/org/telegram/objects/MessageObject.java index 2b92df8a..15589035 100644 --- a/TMessagesProj/src/main/java/org/telegram/objects/MessageObject.java +++ b/TMessagesProj/src/main/java/org/telegram/objects/MessageObject.java @@ -468,13 +468,11 @@ public class MessageObject { FileLog.e("tmessages", e); } - int linesMaxWidth; + int linesMaxWidth = (int)Math.ceil(lastLine); int lastLineWidthWithLeft; int linesMaxWidthWithLeft; boolean hasNonRTL = false; - linesMaxWidth = (int)Math.ceil(lastLine); - if (a == blocksCount - 1) { lastLineWidth = linesMaxWidth; } @@ -494,6 +492,13 @@ public class MessageObject { lineWidth = 0; } + if (lineWidth > maxWidth + 100) { + int start = block.textLayout.getLineStart(n); + int end = block.textLayout.getLineEnd(n); + CharSequence text = block.textLayout.getText().subSequence(start, end); + continue; + } + try { lineLeft = block.textLayout.getLineLeft(n); } catch (Exception e) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index 0fe0aa50..d6737a91 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -1439,7 +1439,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not public void run() { MessagesController.getInstance().sendMessage(photoFinal, originalPathFinal, dialog_id); if (chatListView != null) { - chatListView.setSelection(messages.size() + 1); + chatListView.setSelectionFromTop(messages.size() - 1, -100000 - chatListView.getPaddingTop()); } if (paused) { scrollToTopOnResume = true; @@ -1528,7 +1528,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not public void run() { MessagesController.getInstance().sendMessage(documentFinal, originalPathFinal, dialog_id); if (chatListView != null) { - chatListView.setSelection(messages.size() + 1); + chatListView.setSelectionFromTop(messages.size() - 1, -100000 - chatListView.getPaddingTop()); } if (paused) { scrollToTopOnResume = true; @@ -1609,7 +1609,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not public void run() { MessagesController.getInstance().sendMessage(videoFinal, originalPathFinal, dialog_id); if (chatListView != null) { - chatListView.setSelection(messages.size() + 1); + chatListView.setSelectionFromTop(messages.size() - 1, -100000 - chatListView.getPaddingTop()); } if (paused) { scrollToTopOnResume = true; @@ -2113,7 +2113,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } else if (id == 997) { MessagesController.getInstance().sendMessage((Double) args[0], (Double) args[1], dialog_id); if (chatListView != null) { - chatListView.setSelection(messages.size() + 1); + chatListView.setSelectionFromTop(messages.size() - 1, -100000 - chatListView.getPaddingTop()); scrollToTopOnResume = true; } } else if (id == MessagesController.chatInfoDidLoaded) { @@ -2347,7 +2347,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } else { if (chatListView != null) { - chatListView.setSelection(messages.size() + 1); + chatListView.setSelectionFromTop(messages.size() - 1, -100000 - chatListView.getPaddingTop()); } } scrollToTopUnReadOnResume = false; @@ -2768,7 +2768,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not random_ids.add(selectedObject.messageOwner.random_id); } MessagesController.getInstance().deleteMessages(arr, random_ids, currentEncryptedChat); - chatListView.setSelection(messages.size() + 1); + chatListView.setSelectionFromTop(messages.size() - 1, -100000 - chatListView.getPaddingTop()); } } else if (option == 1) { if (selectedObject != null) { @@ -2843,6 +2843,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not MessagesController.getInstance().sendMessage((TLRPC.TL_document)messageObject.messageOwner.media.document, null, did); } else if (messageObject.messageOwner.media.geo instanceof TLRPC.TL_geoPoint) { MessagesController.getInstance().sendMessage(messageObject.messageOwner.media.geo.lat, messageObject.messageOwner.media.geo._long, did); + } else if (messageObject.messageOwner.media.phone_number != null) { + TLRPC.User user = new TLRPC.TL_userContact(); + user.phone = messageObject.messageOwner.media.phone_number; + user.first_name = messageObject.messageOwner.media.first_name; + user.last_name = messageObject.messageOwner.media.last_name; + user.id = messageObject.messageOwner.media.user_id; + MessagesController.getInstance().sendMessage(user, did); } else { MessagesController.getInstance().sendMessage(messageObject, did); } @@ -2900,7 +2907,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } else { activity.finishFragment(); - chatListView.setSelection(messages.size() + 1); + chatListView.setSelectionFromTop(messages.size() - 1, -100000 - chatListView.getPaddingTop()); scrollToTopOnResume = true; } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/UserProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/UserProfileActivity.java index f2925fa2..86659edf 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/UserProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/UserProfileActivity.java @@ -218,7 +218,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen return; } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); - builder.setMessage(LocaleController.getString("AreYouSure", R.string.AreYouSure)); + builder.setMessage(LocaleController.getString("AreYouSureSecretChat", R.string.AreYouSureSecretChat)); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { @Override