mirror of
https://github.com/NekoX-Dev/NekoX.git
synced 2024-11-30 05:11:22 +01:00
Bug fixes
This commit is contained in:
parent
e2a6511fbf
commit
f92df091ef
@ -83,7 +83,7 @@ android {
|
||||
defaultConfig {
|
||||
minSdkVersion 8
|
||||
targetSdkVersion 19
|
||||
versionCode 288
|
||||
versionName "1.6.1"
|
||||
versionCode 289
|
||||
versionName "1.6.2"
|
||||
}
|
||||
}
|
||||
|
@ -927,7 +927,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
|
||||
if (updatesStartWaitTime != 0 && updatesStartWaitTime + 1500 < currentTime) {
|
||||
FileLog.e("tmessages", "UPDATES WAIT TIMEOUT - CHECK QUEUE");
|
||||
processUpdatesQueue(false);
|
||||
processUpdatesQueue(0);
|
||||
}
|
||||
}
|
||||
if (!printingUsers.isEmpty() || lastPrintingStringCount != printingUsers.size()) {
|
||||
@ -3197,6 +3197,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
MessagesStorage.lastPtsValue = res.pts;
|
||||
MessagesStorage.lastSeqValue = res.seq;
|
||||
MessagesStorage.lastQtsValue = res.qts;
|
||||
processUpdatesQueue(2);
|
||||
MessagesStorage.getInstance().saveDiffParams(MessagesStorage.lastSeqValue, MessagesStorage.lastPtsValue, MessagesStorage.lastDateValue, MessagesStorage.lastQtsValue);
|
||||
} else {
|
||||
if (error.code != 401) {
|
||||
@ -3215,7 +3216,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
}
|
||||
}
|
||||
|
||||
private void processUpdatesQueue(boolean getDifference) {
|
||||
private void processUpdatesQueue(int state) {
|
||||
if (!updatesQueue.isEmpty()) {
|
||||
Collections.sort(updatesQueue, new Comparator<TLRPC.Updates>() {
|
||||
@Override
|
||||
@ -3231,6 +3232,10 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
}
|
||||
});
|
||||
boolean anyProceed = false;
|
||||
if (state == 2) {
|
||||
TLRPC.Updates updates = updatesQueue.get(0);
|
||||
MessagesStorage.lastSeqValue = getUpdateSeq(updates);
|
||||
}
|
||||
for (int a = 0; a < updatesQueue.size(); a++) {
|
||||
TLRPC.Updates updates = updatesQueue.get(a);
|
||||
int seq = getUpdateSeq(updates);
|
||||
@ -3261,7 +3266,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
updatesQueue.clear();
|
||||
FileLog.e("tmessages", "UPDATES QUEUE PROCEED - OK");
|
||||
updatesStartWaitTime = 0;
|
||||
if (getDifference) {
|
||||
if (state == 1) {
|
||||
final int stateCopy = ConnectionsManager.getInstance().getConnectionState();
|
||||
Utilities.RunOnUIThread(new Runnable() {
|
||||
@Override
|
||||
@ -3271,7 +3276,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (getDifference) {
|
||||
if (state == 1) {
|
||||
final int stateCopy = ConnectionsManager.getInstance().getConnectionState();
|
||||
Utilities.RunOnUIThread(new Runnable() {
|
||||
@Override
|
||||
@ -3469,7 +3474,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
MessagesStorage.lastPtsValue = res.state.pts;
|
||||
MessagesStorage.lastQtsValue = res.state.qts;
|
||||
ConnectionsManager.getInstance().setConnectionState(0);
|
||||
processUpdatesQueue(true);
|
||||
processUpdatesQueue(1);
|
||||
} else if (res instanceof TLRPC.TL_updates_differenceSlice) {
|
||||
MessagesStorage.lastDateValue = res.intermediate_state.date;
|
||||
MessagesStorage.lastPtsValue = res.intermediate_state.pts;
|
||||
@ -3480,7 +3485,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
MessagesStorage.lastSeqValue = res.seq;
|
||||
MessagesStorage.lastDateValue = res.date;
|
||||
ConnectionsManager.getInstance().setConnectionState(0);
|
||||
processUpdatesQueue(true);
|
||||
processUpdatesQueue(1);
|
||||
}
|
||||
MessagesStorage.getInstance().saveDiffParams(MessagesStorage.lastSeqValue, MessagesStorage.lastPtsValue, MessagesStorage.lastDateValue, MessagesStorage.lastQtsValue);
|
||||
FileLog.e("tmessages", "received difference with date = " + MessagesStorage.lastDateValue + " pts = " + MessagesStorage.lastPtsValue + " seq = " + MessagesStorage.lastSeqValue);
|
||||
@ -3692,7 +3697,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
if (needGetDiff && !fromQueue) {
|
||||
getDifference();
|
||||
} else if (!fromQueue && !updatesQueue.isEmpty()) {
|
||||
processUpdatesQueue(false);
|
||||
processUpdatesQueue(0);
|
||||
}
|
||||
if (needReceivedQueue) {
|
||||
TLRPC.TL_messages_receivedQueue req = new TLRPC.TL_messages_receivedQueue();
|
||||
|
@ -191,7 +191,7 @@ public class MessagesStorage {
|
||||
}
|
||||
}
|
||||
|
||||
public void cleanUp() {
|
||||
public void cleanUp(final boolean isLogin) {
|
||||
storageQueue.cleanupQueue();
|
||||
storageQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
@ -219,6 +219,14 @@ public class MessagesStorage {
|
||||
}
|
||||
storageQueue.cleanupQueue();
|
||||
openDatabase();
|
||||
if (isLogin) {
|
||||
Utilities.stageQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MessagesController.getInstance().getDifference();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -305,10 +305,12 @@ public class NotificationsController {
|
||||
intent.setAction("com.tmessages.openchat" + Math.random() + Integer.MAX_VALUE);
|
||||
intent.setFlags(32768);
|
||||
if ((int)dialog_id != 0) {
|
||||
if (chat_id != 0) {
|
||||
intent.putExtra("chatId", chat_id);
|
||||
} else if (user_id != 0) {
|
||||
intent.putExtra("userId", user_id);
|
||||
if (pushDialogs.size() == 1) {
|
||||
if (chat_id != 0) {
|
||||
intent.putExtra("chatId", chat_id);
|
||||
} else if (user_id != 0) {
|
||||
intent.putExtra("userId", user_id);
|
||||
}
|
||||
}
|
||||
if (pushDialogs.size() == 1) {
|
||||
if (chat != null) {
|
||||
@ -322,7 +324,9 @@ public class NotificationsController {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
intent.putExtra("encId", (int)(dialog_id >> 32));
|
||||
if (pushDialogs.size() == 1) {
|
||||
intent.putExtra("encId", (int) (dialog_id >> 32));
|
||||
}
|
||||
}
|
||||
PendingIntent contentIntent = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent, PendingIntent.FLAG_ONE_SHOT);
|
||||
|
||||
@ -350,7 +354,6 @@ public class NotificationsController {
|
||||
.setContentTitle(name)
|
||||
.setSmallIcon(R.drawable.notification)
|
||||
.setAutoCancel(true)
|
||||
.setContentText(detailText)
|
||||
.setContentIntent(contentIntent);
|
||||
|
||||
String lastMessage = null;
|
||||
@ -366,8 +369,10 @@ public class NotificationsController {
|
||||
message = message.replace(name + ": ", "").replace(name + " ", "");
|
||||
}
|
||||
}
|
||||
mBuilder.setContentText(message);
|
||||
mBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(message));
|
||||
} else {
|
||||
mBuilder.setContentText(detailText);
|
||||
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
|
||||
inboxStyle.setBigContentTitle(name);
|
||||
int count = Math.min(10, pushMessages.size());
|
||||
@ -417,6 +422,8 @@ public class NotificationsController {
|
||||
}
|
||||
if (needVibrate) {
|
||||
mBuilder.setVibrate(new long[]{0, 100, 0, 100});
|
||||
} else {
|
||||
mBuilder.setVibrate(new long[]{0, 0});
|
||||
}
|
||||
} else {
|
||||
mBuilder.setVibrate(new long[]{0, 0});
|
||||
@ -485,7 +492,7 @@ public class NotificationsController {
|
||||
remove = true;
|
||||
}
|
||||
} else {
|
||||
if (messageObject.messageOwner.id <= max_id) {
|
||||
if (messageObject.messageOwner.id <= max_id || max_id < 0) {
|
||||
remove = true;
|
||||
}
|
||||
}
|
||||
@ -569,32 +576,32 @@ public class NotificationsController {
|
||||
int notify_override = preferences.getInt("notify2_" + dialog_id, 0);
|
||||
boolean isChat = (int)dialog_id < 0;
|
||||
Integer currentCount = pushDialogs.get(dialog_id);
|
||||
if (!(notify_override == 2 || (!preferences.getBoolean("EnableAll", true) || isChat && !preferences.getBoolean("EnableGroup", true)) && notify_override == 0)) {
|
||||
Integer newCount = entry.getValue();
|
||||
if (replace) {
|
||||
if (currentCount != null) {
|
||||
total_unread_count -= currentCount;
|
||||
}
|
||||
if (newCount == 0) {
|
||||
pushDialogs.remove(dialog_id);
|
||||
} else {
|
||||
total_unread_count += newCount;
|
||||
pushDialogs.put(dialog_id, newCount);
|
||||
}
|
||||
} else {
|
||||
if (currentCount == null) {
|
||||
currentCount = 0;
|
||||
}
|
||||
currentCount += newCount;
|
||||
total_unread_count += newCount;
|
||||
pushDialogs.put(dialog_id, currentCount);
|
||||
boolean canAddValue = !(notify_override == 2 || (!preferences.getBoolean("EnableAll", true) || isChat && !preferences.getBoolean("EnableGroup", true)) && notify_override == 0);
|
||||
|
||||
Integer newCount = entry.getValue();
|
||||
if (replace) {
|
||||
if (currentCount != null) {
|
||||
total_unread_count -= currentCount;
|
||||
}
|
||||
if (newCount == 0) {
|
||||
pushDialogs.remove(dialog_id);
|
||||
} else if (canAddValue) {
|
||||
total_unread_count += newCount;
|
||||
pushDialogs.put(dialog_id, newCount);
|
||||
}
|
||||
} else if (canAddValue) {
|
||||
if (currentCount == null) {
|
||||
currentCount = 0;
|
||||
}
|
||||
currentCount += newCount;
|
||||
total_unread_count += newCount;
|
||||
pushDialogs.put(dialog_id, currentCount);
|
||||
}
|
||||
}
|
||||
if (old_unread_count != total_unread_count) {
|
||||
showOrUpdateNotification(notifyCheck);
|
||||
notifyCheck = false;
|
||||
}
|
||||
notifyCheck = false;
|
||||
if (preferences.getBoolean("badgeNumber", true)) {
|
||||
setBadge(ApplicationLoader.applicationContext, total_unread_count);
|
||||
}
|
||||
|
@ -1105,8 +1105,13 @@ public class FileLoader {
|
||||
return null;
|
||||
}
|
||||
float scaleFactor = Math.max(photoW / maxWidth, photoH / maxHeight);
|
||||
int w = (int)(photoW / scaleFactor);
|
||||
int h = (int)(photoH / scaleFactor);
|
||||
if (h == 0 || w == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, (int)(photoW / scaleFactor), (int)(photoH / scaleFactor), true);
|
||||
Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, h, w, true);
|
||||
|
||||
TLRPC.TL_fileLocation location = new TLRPC.TL_fileLocation();
|
||||
location.volume_id = Integer.MIN_VALUE;
|
||||
|
@ -85,7 +85,6 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
||||
currentConnectionState = ConnectionsManager.getInstance().getConnectionState();
|
||||
|
||||
NotificationCenter.getInstance().addObserver(this, 1234);
|
||||
NotificationCenter.getInstance().addObserver(this, 658);
|
||||
NotificationCenter.getInstance().addObserver(this, 701);
|
||||
NotificationCenter.getInstance().addObserver(this, 702);
|
||||
NotificationCenter.getInstance().addObserver(this, 703);
|
||||
@ -149,6 +148,7 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
||||
Integer push_chat_id = 0;
|
||||
Integer push_enc_id = 0;
|
||||
Integer open_settings = 0;
|
||||
boolean showDialogsList = false;
|
||||
|
||||
photoPathsArray = null;
|
||||
videoPath = null;
|
||||
@ -379,6 +379,8 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
||||
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
|
||||
push_enc_id = encId;
|
||||
}
|
||||
} else {
|
||||
showDialogsList = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -408,6 +410,11 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
||||
if (presentFragment(fragment, false, true)) {
|
||||
pushOpened = true;
|
||||
}
|
||||
} else if (showDialogsList) {
|
||||
for (int a = 1; a < fragmentsStack.size(); a++) {
|
||||
removeFragmentFromStack(fragmentsStack.get(a));
|
||||
a--;
|
||||
}
|
||||
}
|
||||
if (videoPath != null || photoPathsArray != null || sendingText != null || documentsPathsArray != null || contactsToSend != null) {
|
||||
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
|
||||
@ -522,7 +529,6 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
||||
}
|
||||
finished = true;
|
||||
NotificationCenter.getInstance().removeObserver(this, 1234);
|
||||
NotificationCenter.getInstance().removeObserver(this, 658);
|
||||
NotificationCenter.getInstance().removeObserver(this, 701);
|
||||
NotificationCenter.getInstance().removeObserver(this, 702);
|
||||
NotificationCenter.getInstance().removeObserver(this, 703);
|
||||
@ -546,30 +552,6 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
||||
startActivity(intent2);
|
||||
onFinish();
|
||||
finish();
|
||||
} else if (id == 658) {
|
||||
if (PhotoViewer.getInstance().isVisible()) {
|
||||
PhotoViewer.getInstance().closePhoto(false);
|
||||
}
|
||||
Integer push_chat_id = (Integer)args[0];
|
||||
Integer push_user_id = (Integer)args[1];
|
||||
Integer push_enc_id = (Integer)args[2];
|
||||
|
||||
if (push_user_id != 0) {
|
||||
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
|
||||
Bundle args2 = new Bundle();
|
||||
args2.putInt("user_id", push_user_id);
|
||||
presentFragment(new ChatActivity(args2), false, true);
|
||||
} else if (push_chat_id != 0) {
|
||||
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
|
||||
Bundle args2 = new Bundle();
|
||||
args2.putInt("chat_id", push_chat_id);
|
||||
presentFragment(new ChatActivity(args2), false, true);
|
||||
} else if (push_enc_id != 0) {
|
||||
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
|
||||
Bundle args2 = new Bundle();
|
||||
args2.putInt("enc_id", push_enc_id);
|
||||
presentFragment(new ChatActivity(args2), false, true);
|
||||
}
|
||||
} else if (id == 702) {
|
||||
if (args[0] != this) {
|
||||
onFinish();
|
||||
|
@ -150,10 +150,10 @@ public class LoginActivityRegisterView extends SlideView {
|
||||
final TLRPC.TL_auth_authorization res = (TLRPC.TL_auth_authorization)response;
|
||||
TLRPC.TL_userSelf user = (TLRPC.TL_userSelf)res.user;
|
||||
UserConfig.clearConfig();
|
||||
MessagesStorage.getInstance().cleanUp();
|
||||
MessagesController.getInstance().cleanUp();
|
||||
UserConfig.setCurrentUser(user);
|
||||
UserConfig.saveConfig(true);
|
||||
MessagesStorage.getInstance().cleanUp(true);
|
||||
ArrayList<TLRPC.User> users = new ArrayList<TLRPC.User>();
|
||||
users.add(user);
|
||||
MessagesStorage.getInstance().putUsersAndChats(users, null, true, true);
|
||||
|
@ -260,10 +260,10 @@ public class LoginActivitySmsView extends SlideView implements NotificationCente
|
||||
TLRPC.TL_auth_authorization res = (TLRPC.TL_auth_authorization)response;
|
||||
destroyTimer();
|
||||
UserConfig.clearConfig();
|
||||
MessagesStorage.getInstance().cleanUp();
|
||||
MessagesController.getInstance().cleanUp();
|
||||
UserConfig.setCurrentUser(res.user);
|
||||
UserConfig.saveConfig(true);
|
||||
MessagesStorage.getInstance().cleanUp(true);
|
||||
ArrayList<TLRPC.User> users = new ArrayList<TLRPC.User>();
|
||||
users.add(res.user);
|
||||
MessagesStorage.getInstance().putUsersAndChats(users, null, true, true);
|
||||
|
@ -413,6 +413,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
imagesByIdsTemp.clear();
|
||||
needSearchImageInArr = false;
|
||||
currentIndex = -1;
|
||||
if (foundIndex >= imagesArr.size()) {
|
||||
foundIndex = imagesArr.size() - 1;
|
||||
}
|
||||
setImageIndex(foundIndex, true);
|
||||
} else {
|
||||
if (!cacheEndReached || !arr.isEmpty() && added != 0) {
|
||||
@ -1384,6 +1387,15 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
NotificationCenter.getInstance().addObserver(this, MessagesController.mediaDidLoaded);
|
||||
NotificationCenter.getInstance().addObserver(this, MessagesController.userPhotosLoaded);
|
||||
|
||||
try {
|
||||
if (windowView.getParent() != null) {
|
||||
WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE);
|
||||
wm.removeView(windowView);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
|
||||
placeProvider = provider;
|
||||
WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE);
|
||||
wm.addView(windowView, windowLayoutParams);
|
||||
@ -1702,8 +1714,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
return;
|
||||
}
|
||||
try {
|
||||
WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE);
|
||||
if (windowView.getParent() != null) {
|
||||
WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE);
|
||||
wm.removeViewImmediate(windowView);
|
||||
}
|
||||
windowView = null;
|
||||
@ -1730,8 +1742,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
public void run() {
|
||||
animatingImageView.setImageBitmap(null);
|
||||
try {
|
||||
WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE);
|
||||
if (windowView.getParent() != null) {
|
||||
WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE);
|
||||
wm.removeView(windowView);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -962,7 +962,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
MessagesController.getInstance().unregistedPush();
|
||||
MessagesController.getInstance().logOut();
|
||||
UserConfig.clearConfig();
|
||||
MessagesStorage.getInstance().cleanUp();
|
||||
MessagesStorage.getInstance().cleanUp(false);
|
||||
MessagesController.getInstance().cleanUp();
|
||||
ContactsController.getInstance().deleteAllAppAccounts();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user