Bug fixes

This commit is contained in:
DrKLO 2014-11-20 17:45:33 +03:00
parent dd61bbaa7a
commit a38e46cd8b
19 changed files with 183 additions and 119 deletions

View File

@ -80,7 +80,7 @@ android {
defaultConfig {
minSdkVersion 8
targetSdkVersion 21
versionCode 391
versionName "2.0.2"
versionCode 392
versionName "2.0.3"
}
}

View File

@ -1636,6 +1636,9 @@ public class ContactsController {
TLRPC.User toDbUser = new TLRPC.User();
TLRPC.TL_contactStatus status = (TLRPC.TL_contactStatus) object;
if (status == null) {
continue;
}
if (status.status instanceof TLRPC.TL_userStatusRecently) {
status.status.expires = -100;
} else if (status.status instanceof TLRPC.TL_userStatusLastWeek) {

View File

@ -1062,77 +1062,76 @@ public class MessagesController implements NotificationCenter.NotificationCenter
if (offset == 0) {
MessagesStorage.getInstance().deleteDialog(did, onlyHistory);
}
TLRPC.TL_dialog dialog = dialogs_dict.get(did);
if (dialog != null) {
int lower_part = (int)did;
int high_id = (int)(did >> 32);
if (offset == 0) {
if (!onlyHistory) {
dialogs.remove(dialog);
dialogsServerOnly.remove(dialog);
dialogs_dict.remove(did);
totalDialogsCount--;
} else {
dialog.unread_count = 0;
}
dialogMessage.remove(dialog.top_message);
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
@Override
public void run() {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
NotificationsController.getInstance().processReadMessages(null, did, 0, Integer.MAX_VALUE, false);
HashMap<Long, Integer> dialogsToUpdate = new HashMap<Long, Integer>();
dialogsToUpdate.put(did, 0);
NotificationsController.getInstance().processDialogsUpdateRead(dialogsToUpdate);
}
});
}
});
NotificationCenter.getInstance().postNotificationName(NotificationCenter.removeAllMessagesFromDialog, did);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload);
}
int lower_part = (int)did;
int high_id = (int)(did >> 32);
if (high_id == 1) {
return;
}
if (lower_part != 0) {
TLRPC.TL_messages_deleteHistory req = new TLRPC.TL_messages_deleteHistory();
req.offset = offset;
if (did < 0) {
req.peer = new TLRPC.TL_inputPeerChat();
req.peer.chat_id = -lower_part;
} else {
TLRPC.User user = getUser(lower_part);
if (user instanceof TLRPC.TL_userForeign || user instanceof TLRPC.TL_userRequest) {
req.peer = new TLRPC.TL_inputPeerForeign();
req.peer.access_hash = user.access_hash;
} else {
req.peer = new TLRPC.TL_inputPeerContact();
}
req.peer.user_id = lower_part;
}
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override
public void run(TLObject response, TLRPC.TL_error error) {
if (error == null) {
TLRPC.TL_messages_affectedHistory res = (TLRPC.TL_messages_affectedHistory) response;
if (res.offset > 0) {
deleteDialog(did, res.offset, onlyHistory);
}
processNewDifferenceParams(res.seq, res.pts, -1);
}
}
});
if (offset == 0) {
TLRPC.TL_dialog dialog = dialogs_dict.get(did);
if (!onlyHistory) {
dialogs.remove(dialog);
dialogsServerOnly.remove(dialog);
dialogs_dict.remove(did);
totalDialogsCount--;
} else {
if (onlyHistory) {
SendMessagesHelper.getInstance().sendClearHistoryMessage(getEncryptedChat(high_id), null);
} else {
declineSecretChat(high_id);
dialog.unread_count = 0;
}
dialogMessage.remove(dialog.top_message);
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
@Override
public void run() {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
NotificationsController.getInstance().processReadMessages(null, did, 0, Integer.MAX_VALUE, false);
HashMap<Long, Integer> dialogsToUpdate = new HashMap<Long, Integer>();
dialogsToUpdate.put(did, 0);
NotificationsController.getInstance().processDialogsUpdateRead(dialogsToUpdate);
}
});
}
});
NotificationCenter.getInstance().postNotificationName(NotificationCenter.removeAllMessagesFromDialog, did);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload);
}
if (high_id == 1) {
return;
}
if (lower_part != 0) {
TLRPC.TL_messages_deleteHistory req = new TLRPC.TL_messages_deleteHistory();
req.offset = offset;
if (did < 0) {
req.peer = new TLRPC.TL_inputPeerChat();
req.peer.chat_id = -lower_part;
} else {
TLRPC.User user = getUser(lower_part);
if (user instanceof TLRPC.TL_userForeign || user instanceof TLRPC.TL_userRequest) {
req.peer = new TLRPC.TL_inputPeerForeign();
req.peer.access_hash = user.access_hash;
} else {
req.peer = new TLRPC.TL_inputPeerContact();
}
req.peer.user_id = lower_part;
}
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override
public void run(TLObject response, TLRPC.TL_error error) {
if (error == null) {
TLRPC.TL_messages_affectedHistory res = (TLRPC.TL_messages_affectedHistory) response;
if (res.offset > 0) {
deleteDialog(did, res.offset, onlyHistory);
}
processNewDifferenceParams(res.seq, res.pts, -1);
}
}
});
} else {
if (onlyHistory) {
SendMessagesHelper.getInstance().sendClearHistoryMessage(getEncryptedChat(high_id), null);
} else {
declineSecretChat(high_id);
}
}
}
@ -1455,6 +1454,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
return;
}
loadingDialogs = true;
NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload);
if (fromCache) {
MessagesStorage.getInstance().getDialogs(offset, serverOffset, count);

View File

@ -397,6 +397,10 @@ public class NotificationsController {
.setGroup("messages")
.setGroupSummary(true);
//if (ApplicationLoader.mainInterfacePaused) {
// mBuilder.setPriority(NotificationCompat.PRIORITY_HIGH);
//}
String lastMessage = null;
String lastMessageFull = null;
if (pushMessages.size() == 1) {

View File

@ -2236,6 +2236,17 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
lastOutgoingMessageId = Math.max(messageId, lastOutgoingMessageId);
}
long resultMid = ((TLRPC.TL_bad_server_salt) message).bad_msg_id;
if (resultMid != 0) {
for (RPCRequest request : runningRequests) {
if ((request.flags & RPCRequest.RPCRequestClassDownloadMedia) == 0) {
continue;
}
if (request.respondsToMessageId(resultMid)) {
request.retryCount = 0;
}
}
}
datacenter.clearServerSalts();

View File

@ -628,8 +628,7 @@ public class ActionBarLayout extends FrameLayout {
currentAnimation = new AnimatorSetProxy();
currentAnimation.playTogether(
ObjectAnimatorProxy.ofFloat(containerView, "alpha", 0.0f, 1.0f),
ObjectAnimatorProxy.ofFloat(containerView, "scaleX", 0.8f, 1.0f),
ObjectAnimatorProxy.ofFloat(containerView, "scaleY", 0.8f, 1.0f));
ObjectAnimatorProxy.ofFloat(containerView, "translationY", AndroidUtilities.dp(48), 0));
currentAnimation.setInterpolator(new DecelerateInterpolator(1.5f));
currentAnimation.setDuration(200);
currentAnimation.addListener(new AnimatorListenerAdapterProxy() {
@ -731,14 +730,14 @@ public class ActionBarLayout extends FrameLayout {
@Override
public void run() {
closeLastFragmentInternalRemoveOld(currentFragment);
ViewProxy.setTranslationY(containerViewBack, 0);
}
};
currentAnimation = new AnimatorSetProxy();
currentAnimation.playTogether(
ObjectAnimatorProxy.ofFloat(containerViewBack, "alpha", 1.0f, 0.0f),
ObjectAnimatorProxy.ofFloat(containerViewBack, "scaleX", 1.0f, 0.8f),
ObjectAnimatorProxy.ofFloat(containerViewBack, "scaleY", 1.0f, 0.8f));
ObjectAnimatorProxy.ofFloat(containerViewBack, "translationY", 0, AndroidUtilities.dp(48)));
currentAnimation.setInterpolator(new DecelerateInterpolator(1.5f));
currentAnimation.setDuration(200);
currentAnimation.addListener(new AnimatorListenerAdapterProxy() {

View File

@ -134,8 +134,9 @@ public class ActionBarMenu extends LinearLayout {
View view = getChildAt(a);
if (view instanceof ActionBarMenuItem) {
ActionBarMenuItem item = (ActionBarMenuItem)view;
if (item.hasSubMenu()) {
if (item.hasSubMenu() && item.getVisibility() == VISIBLE) {
item.toggleSubMenu();
break;
}
}
}

View File

@ -214,15 +214,19 @@ public class BaseFragment {
} catch (Exception e) {
FileLog.e("tmessages", e);
}
visibleDialog = builder.show();
visibleDialog.setCanceledOnTouchOutside(true);
visibleDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
visibleDialog = null;
onDialogDismiss();
}
});
try {
visibleDialog = builder.show();
visibleDialog.setCanceledOnTouchOutside(true);
visibleDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
visibleDialog = null;
onDialogDismiss();
}
});
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
protected void onDialogDismiss() {

View File

@ -52,7 +52,9 @@ public class ContactsAdapter extends BaseSectionsAdapter {
if (onlyUsers) {
if (section < ContactsController.getInstance().sortedUsersSectionsArray.size()) {
ArrayList<TLRPC.TL_contact> arr = ContactsController.getInstance().usersSectionsDict.get(ContactsController.getInstance().sortedUsersSectionsArray.get(section));
return MessagesController.getInstance().getUser(arr.get(position).user_id);
if (position < arr.size()) {
return MessagesController.getInstance().getUser(arr.get(position).user_id);
}
}
return null;
} else {

View File

@ -236,6 +236,11 @@ public class ChangeUsernameActivity extends BaseFragment {
}
lastNameAvailable = false;
if (name != null) {
if (name.startsWith("_") || name.endsWith("_")) {
checkTextView.setText(LocaleController.getString("UsernameInvalid", R.string.UsernameInvalid));
checkTextView.setTextColor(0xffcf3030);
return false;
}
for (int a = 0; a < name.length(); a++) {
char ch = name.charAt(a);
if (a == 0 && ch >= '0' && ch <= '9') {

View File

@ -473,7 +473,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (currentUser != null) {
MessagesController.getInstance().cancelLoadFullUser(currentUser.id);
}
if (!AndroidUtilities.isTablet()) {
if (!AndroidUtilities.isTablet() && getParentActivity() != null) {
getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
}
AndroidUtilities.unlockOrientation(getParentActivity());
@ -1270,7 +1270,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
private void scrollToLastMessage() {
if ((forward_end_reached || first_unread_id == 0) && startLoadFromMessageId == 0) {
if (forward_end_reached && first_unread_id == 0 && startLoadFromMessageId == 0) {
chatListView.setSelectionFromTop(messages.size() - 1, -100000 - chatListView.getPaddingTop());
} else {
messages.clear();
@ -3087,7 +3087,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
presentFragment(chatActivity, true);
if (!AndroidUtilities.isTablet()) {
removeSelfFromStack();
chatActivity.getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
Activity parentActivity = getParentActivity();
if (parentActivity == null) {
parentActivity = chatActivity.getParentActivity();
}
if (parentActivity != null) {
parentActivity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
}
}
} else {
activity.finishFragment();

View File

@ -1131,7 +1131,16 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
}
}
if (fragment instanceof ChatActivity) {
if (!tabletFullSize && layout != rightActionBarLayout) {
if (!tabletFullSize && layout == rightActionBarLayout || tabletFullSize && layout == actionBarLayout) {
if (!layersActionBarLayout.fragmentsStack.isEmpty()) {
for (int a = 0; a < layersActionBarLayout.fragmentsStack.size() - 1; a++) {
layersActionBarLayout.removeFragmentFromStack(layersActionBarLayout.fragmentsStack.get(0));
a--;
}
layersActionBarLayout.closeLastFragment(!forceWithoutAnimation);
}
return true;
} else if (!tabletFullSize && layout != rightActionBarLayout) {
rightActionBarLayout.setVisibility(View.VISIBLE);
backgroundTablet.setVisibility(View.GONE);
rightActionBarLayout.removeAllFragments();

View File

@ -530,6 +530,12 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
@SuppressWarnings("unchecked")
public void didReceivedNotification(int id, Object... args) {
if (id == NotificationCenter.dialogsNeedReload) {
if (dialogsAdapter != null) {
dialogsAdapter.notifyDataSetChanged();
}
if (dialogsSearchAdapter != null) {
dialogsSearchAdapter.notifyDataSetChanged();
}
if (messagesListView != null) {
if (MessagesController.getInstance().loadingDialogs && MessagesController.getInstance().dialogs.isEmpty()) {
searchEmptyView.setVisibility(View.GONE);
@ -537,33 +543,14 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
messagesListView.setEmptyView(progressView);
} else {
if (searching && searchWas) {
if (dialogsAdapter != null) {
dialogsAdapter.notifyDataSetChanged();
}
if (dialogsSearchAdapter != null) {
dialogsSearchAdapter.notifyDataSetChanged();
}
messagesListView.setEmptyView(searchEmptyView);
emptyView.setVisibility(View.GONE);
} else {
if (dialogsAdapter != null) {
dialogsAdapter.notifyDataSetChanged();
}
if (dialogsSearchAdapter != null) {
dialogsSearchAdapter.notifyDataSetChanged();
}
messagesListView.setEmptyView(emptyView);
searchEmptyView.setVisibility(View.GONE);
}
progressView.setVisibility(View.GONE);
}
} else {
if (dialogsAdapter != null) {
dialogsAdapter.notifyDataSetChanged();
}
if (dialogsSearchAdapter != null) {
dialogsSearchAdapter.notifyDataSetChanged();
}
}
} else if (id == NotificationCenter.emojiDidLoaded) {
if (messagesListView != null) {

View File

@ -183,7 +183,7 @@ public class PrivacySettingsActivity extends BaseFragment implements Notificatio
if (which == 0) {
value = 30;
} else if (which == 1) {
value = 60;
value = 90;
} else if (which == 2) {
value = 182;
} else if (which == 3) {

View File

@ -937,8 +937,8 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
public int compare(Integer lhs, Integer rhs) {
TLRPC.User user1 = MessagesController.getInstance().getUser(info.participants.get(rhs).user_id);
TLRPC.User user2 = MessagesController.getInstance().getUser(info.participants.get(lhs).user_id);
Integer status1 = 0;
Integer status2 = 0;
int status1 = 0;
int status2 = 0;
if (user1 != null && user1.status != null) {
if (user1.id == UserConfig.getClientUserId()) {
status1 = ConnectionsManager.getInstance().getCurrentTime() + 50000;
@ -953,7 +953,26 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
status2 = user2.status.expires;
}
}
return status1.compareTo(status2);
if (status1 > 0 && status2 > 0) {
if (status1 > status2) {
return 1;
} else if (status1 < status2) {
return -1;
}
return 0;
} else if (status1 < 0 && status2 < 0) {
if (status1 > status2) {
return 1;
} else if (status1 < status2) {
return -1;
}
return 0;
} else if (status1 < 0 && status2 > 0 || status1 == 0 && status2 != 0) {
return -1;
} else if (status2 < 0 && status1 > 0 || status2 == 0 && status1 != 0) {
return 1;
}
return 0;
}
});

View File

@ -184,7 +184,9 @@ public class VideoEditorActivity extends BaseFragment implements TextureView.Sur
@Override
public void onPrepared(MediaPlayer mp) {
playerPrepared = true;
videoPlayer.seekTo((int) (videoTimelineView.getLeftProgress() * videoDuration));
if (videoTimelineView != null && videoPlayer != null) {
videoPlayer.seekTo((int) (videoTimelineView.getLeftProgress() * videoDuration));
}
}
});
try {

View File

@ -391,9 +391,11 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
});
runningAnimation2.start();
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) messsageEditText.getLayoutParams();
layoutParams.rightMargin = AndroidUtilities.dp(0);
messsageEditText.setLayoutParams(layoutParams);
if (messsageEditText != null) {
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) messsageEditText.getLayoutParams();
layoutParams.rightMargin = AndroidUtilities.dp(0);
messsageEditText.setLayoutParams(layoutParams);
}
delegate.onAttachButtonHidden();
}
@ -470,9 +472,11 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
runningAnimation2.setDuration(100);
runningAnimation2.start();
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) messsageEditText.getLayoutParams();
layoutParams.rightMargin = AndroidUtilities.dp(50);
messsageEditText.setLayoutParams(layoutParams);
if (messsageEditText != null) {
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) messsageEditText.getLayoutParams();
layoutParams.rightMargin = AndroidUtilities.dp(50);
messsageEditText.setLayoutParams(layoutParams);
}
delegate.onAttachButtonShow();
}

View File

@ -132,6 +132,8 @@ public class SectionsListView extends ListView implements AbsListView.OnScrollLi
View child = getChildAt(itemNum - firstVisibleItem);
if (child != null) {
header.setTag(child.getTop());
} else {
header.setTag(-AndroidUtilities.dp(100));
}
itemNum += count;
}

View File

@ -106,6 +106,7 @@
<string name="SaveToDownloads">Save to downloads</string>
<string name="ApplyLocalizationFile">Apply localization file</string>
<string name="UnsupportedAttachment">Unsupported attachment</string>
<string name="SetTimer">Set timer</string>
<!--notification-->
<string name="MessageLifetimeChanged">%1$s set the self-destruct timer to %2$s</string>
<string name="MessageLifetimeChangedOutgoing">You set the self-destruct timer to %1$s</string>
@ -146,7 +147,7 @@
<string name="SelectContact">Select Contact</string>
<string name="NoContacts">No contacts yet</string>
<string name="InviteText">Hey, let\'s switch to Telegram: http://telegram.org/dl2</string>
<string name="TodayAt">today at</string>
<string name="TodayAt">at</string>
<string name="YesterdayAt">yesterday at</string>
<string name="Online">online</string>
<string name="LastSeen">last seen</string>
@ -271,6 +272,11 @@
<string name="NoMediaAutoDownload">No media</string>
<string name="SaveToGallerySettings">Save to gallery</string>
<string name="EditName">Edit name</string>
<string name="NotificationsPriority">Priority</string>
<string name="NotificationsPriorityDefault">Default</string>
<string name="NotificationsPriorityLow">Low</string>
<string name="NotificationsPriorityHigh">High</string>
<string name="NotificationsPriorityMax">Max</string>
<!--media view-->
<string name="NoMedia">No shared media yet</string>
<!--map view-->