1
0
mirror of https://github.com/NekoX-Dev/NekoX.git synced 2025-01-05 19:16:13 +01:00

Merge remote-tracking branch 'telegram/master'

This commit is contained in:
NekoInverter 2020-03-31 08:53:50 +08:00
commit 33d49afbcf
No known key found for this signature in database
GPG Key ID: 280D6CCCF95715F9
18 changed files with 505 additions and 270 deletions

View File

@ -1,6 +1,6 @@
name: Nekogram name: Nekogram
on: on:
push: push:
branches: branches:
- master - master

View File

@ -301,7 +301,7 @@ android {
} }
} }
defaultConfig.versionCode = 10 * 1908 defaultConfig.versionCode = 10 * 1911
def tgVoipDexFileName = "libtgvoip.dex" def tgVoipDexFileName = "libtgvoip.dex"
def tgVoipDexClasses = ["AudioRecordJNI", "AudioTrackJNI", "NativeTgVoipDelegate", "NativeTgVoipInstance", "TgVoipNativeLoader", "Resampler", "VLog"] def tgVoipDexClasses = ["AudioRecordJNI", "AudioTrackJNI", "NativeTgVoipDelegate", "NativeTgVoipInstance", "TgVoipNativeLoader", "Resampler", "VLog"]
@ -399,7 +399,7 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 28 targetSdkVersion 28
versionName "6.0.0" versionName "6.0.1"
vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi'] vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi']

View File

@ -1,4 +1,4 @@
APP_PLATFORM := android-16 APP_PLATFORM := android-16
NDK_TOOLCHAIN_VERSION := clang NDK_TOOLCHAIN_VERSION := clang
APP_STL := c++_shared
APP_SHORT_COMMANDS := true APP_SHORT_COMMANDS := true
APP_STL := c++_static

View File

@ -19,7 +19,7 @@ public class BuildVars {
public static boolean USE_CLOUD_STRINGS = true; public static boolean USE_CLOUD_STRINGS = true;
public static boolean CHECK_UPDATES = true; public static boolean CHECK_UPDATES = true;
public static boolean TON_WALLET_STANDALONE = false; public static boolean TON_WALLET_STANDALONE = false;
public static int BUILD_VERSION = 1908; public static int BUILD_VERSION = 1911;
public static String BUILD_VERSION_STRING = "6.0.0"; public static String BUILD_VERSION_STRING = "6.0.0";
public static int APP_ID = 336779; public static int APP_ID = 336779;
public static String APP_HASH = "b91eefacc86747c068c8d8a16b41500d"; public static String APP_HASH = "b91eefacc86747c068c8d8a16b41500d";

View File

@ -261,6 +261,7 @@ public class MessagesController extends BaseController implements NotificationCe
public boolean backgroundConnection; public boolean backgroundConnection;
public float animatedEmojisZoom; public float animatedEmojisZoom;
public boolean filtersEnabled; public boolean filtersEnabled;
public boolean showFiltersTooltip;
public String venueSearchBot; public String venueSearchBot;
public String gifSearchBot; public String gifSearchBot;
public String imageSearchBot; public String imageSearchBot;
@ -528,6 +529,7 @@ public class MessagesController extends BaseController implements NotificationCe
animatedEmojisZoom = mainPreferences.getFloat("animatedEmojisZoom", 0.625f); animatedEmojisZoom = mainPreferences.getFloat("animatedEmojisZoom", 0.625f);
qrLoginCamera = mainPreferences.getBoolean("qrLoginCamera", false); qrLoginCamera = mainPreferences.getBoolean("qrLoginCamera", false);
filtersEnabled = mainPreferences.getBoolean("filtersEnabled", false); filtersEnabled = mainPreferences.getBoolean("filtersEnabled", false);
showFiltersTooltip = mainPreferences.getBoolean("showFiltersTooltip", false);
} }
private void sendLoadPeersRequest(TLObject req, ArrayList<TLObject> requests, TLRPC.messages_Dialogs pinnedDialogs, TLRPC.messages_Dialogs pinnedRemoteDialogs, ArrayList<TLRPC.User> users, ArrayList<TLRPC.Chat> chats, ArrayList<MessagesController.DialogFilter> filtersToSave, SparseArray<MessagesController.DialogFilter> filtersToDelete, ArrayList<Integer> filtersOrder, HashMap<Integer, HashSet<Integer>> filterDialogRemovals, HashMap<Integer, HashSet<Integer>> filterUserRemovals, HashSet<Integer> filtersUnreadCounterReset) { private void sendLoadPeersRequest(TLObject req, ArrayList<TLObject> requests, TLRPC.messages_Dialogs pinnedDialogs, TLRPC.messages_Dialogs pinnedRemoteDialogs, ArrayList<TLRPC.User> users, ArrayList<TLRPC.Chat> chats, ArrayList<MessagesController.DialogFilter> filtersToSave, SparseArray<MessagesController.DialogFilter> filtersToDelete, ArrayList<Integer> filtersOrder, HashMap<Integer, HashSet<Integer>> filterDialogRemovals, HashMap<Integer, HashSet<Integer>> filterUserRemovals, HashSet<Integer> filtersUnreadCounterReset) {
@ -997,6 +999,15 @@ public class MessagesController extends BaseController implements NotificationCe
filtersEnabled = bool.value; filtersEnabled = bool.value;
editor.putBoolean("filtersEnabled", filtersEnabled); editor.putBoolean("filtersEnabled", filtersEnabled);
changed = true; changed = true;
}
}
} else if ("dialog_filters_tooltip".equals(value.key)) {
if (value.value instanceof TLRPC.TL_jsonBool) {
TLRPC.TL_jsonBool bool = (TLRPC.TL_jsonBool) value.value;
if (bool.value != showFiltersTooltip) {
showFiltersTooltip = bool.value;
editor.putBoolean("showFiltersTooltip", showFiltersTooltip);
changed = true;
getNotificationCenter().postNotificationName(NotificationCenter.filterSettingsUpdated); getNotificationCenter().postNotificationName(NotificationCenter.filterSettingsUpdated);
} }
} }
@ -11642,9 +11653,13 @@ public class MessagesController extends BaseController implements NotificationCe
} }
public boolean isDialogMuted(long dialog_id) { public boolean isDialogMuted(long dialog_id) {
return isDialogMuted(dialog_id, null);
}
public boolean isDialogMuted(long dialog_id, TLRPC.Chat chat) {
int mute_type = notificationsPreferences.getInt("notify2_" + dialog_id, -1); int mute_type = notificationsPreferences.getInt("notify2_" + dialog_id, -1);
if (mute_type == -1) { if (mute_type == -1) {
return !getNotificationsController().isGlobalNotificationsEnabled(dialog_id); return !getNotificationsController().isGlobalNotificationsEnabled(dialog_id, chat);
} }
if (mute_type == 2) { if (mute_type == 2) {
return true; return true;

View File

@ -1696,6 +1696,8 @@ public class MessagesStorage extends BaseController {
private int[][] bots = new int[][]{new int[2], new int[2]}; private int[][] bots = new int[][]{new int[2], new int[2]};
private int[][] channels = new int[][]{new int[2], new int[2]}; private int[][] channels = new int[][]{new int[2], new int[2]};
private int[][] groups = new int[][]{new int[2], new int[2]}; private int[][] groups = new int[][]{new int[2], new int[2]};
private int[] mentionChannels = new int[2];
private int[] mentionGroups = new int[2];
private LongSparseArray<Integer> dialogsWithMentions = new LongSparseArray<>(); private LongSparseArray<Integer> dialogsWithMentions = new LongSparseArray<>();
private LongSparseArray<Integer> dialogsWithUnread = new LongSparseArray<>(); private LongSparseArray<Integer> dialogsWithUnread = new LongSparseArray<>();
private void calcUnreadCounters(boolean apply) { private void calcUnreadCounters(boolean apply) {
@ -1728,6 +1730,9 @@ public class MessagesStorage extends BaseController {
if (mentions > 0) { if (mentions > 0) {
dialogsWithMentions.put(did, mentions); dialogsWithMentions.put(did, mentions);
} }
/*if (BuildVars.DEBUG_VERSION) {
FileLog.d("unread chat " + did + " counters = " + unread + " and " + mentions);
}*/
dialogsByFolders.put(did, folderId); dialogsByFolders.put(did, folderId);
int lower_id = (int) did; int lower_id = (int) did;
int high_id = (int) (did >> 32); int high_id = (int) (did >> 32);
@ -1752,12 +1757,17 @@ public class MessagesStorage extends BaseController {
SparseArray<TLRPC.Chat> chatsDict = new SparseArray<>(); SparseArray<TLRPC.Chat> chatsDict = new SparseArray<>();
SparseArray<TLRPC.User> encUsersDict = new SparseArray<>(); SparseArray<TLRPC.User> encUsersDict = new SparseArray<>();
SparseArray<Integer> encryptedChatsByUsersCount = new SparseArray<>(); SparseArray<Integer> encryptedChatsByUsersCount = new SparseArray<>();
SparseArray<Boolean> mutedDialogs = new SparseArray<>();
if (!usersToLoad.isEmpty()) { if (!usersToLoad.isEmpty()) {
getUsersInternal(TextUtils.join(",", usersToLoad), users); getUsersInternal(TextUtils.join(",", usersToLoad), users);
for (int a = 0, N = users.size(); a < N; a++) { for (int a = 0, N = users.size(); a < N; a++) {
TLRPC.User user = users.get(a); TLRPC.User user = users.get(a);
boolean muted = getMessagesController().isDialogMuted(user.id);
int idx1 = dialogsByFolders.get(user.id); int idx1 = dialogsByFolders.get(user.id);
int idx2 = getMessagesController().isDialogMuted(user.id) && dialogsWithMentions.indexOfKey(user.id) < 0 ? 1 : 0; int idx2 = muted ? 1 : 0;
if (muted) {
mutedDialogs.put(user.id, true);
}
if (user.bot) { if (user.bot) {
bots[idx1][idx2]++; bots[idx1][idx2]++;
} else if (user.self || user.contact) { } else if (user.self || user.contact) {
@ -1785,8 +1795,12 @@ public class MessagesStorage extends BaseController {
continue; continue;
} }
long did = ((long) encryptedChat.id) << 32; long did = ((long) encryptedChat.id) << 32;
boolean muted = getMessagesController().isDialogMuted(did);
int idx1 = dialogsByFolders.get(did); int idx1 = dialogsByFolders.get(did);
int idx2 = getMessagesController().isDialogMuted(did) && dialogsWithMentions.indexOfKey(did) < 0 ? 1 : 0; int idx2 = muted ? 1 : 0;
if (muted) {
mutedDialogs.put(user.id, true);
}
if (user.self || user.contact) { if (user.self || user.contact) {
contacts[idx1][idx2]++; contacts[idx1][idx2]++;
} else { } else {
@ -1806,8 +1820,12 @@ public class MessagesStorage extends BaseController {
dialogsWithMentions.remove(-chat.id); dialogsWithMentions.remove(-chat.id);
continue; continue;
} }
boolean muted = getMessagesController().isDialogMuted(-chat.id, chat);
int idx1 = dialogsByFolders.get(-chat.id); int idx1 = dialogsByFolders.get(-chat.id);
int idx2 = getMessagesController().isDialogMuted(-chat.id) && dialogsWithMentions.indexOfKey(-chat.id) < 0 ? 1 : 0; int idx2 = muted && dialogsWithMentions.indexOfKey(-chat.id) < 0 ? 1 : 0;
if (muted) {
mutedDialogs.put(-chat.id, true);
}
if (ChatObject.isChannel(chat) && !chat.megagroup) { if (ChatObject.isChannel(chat) && !chat.megagroup) {
channels[idx1][idx2]++; channels[idx1][idx2]++;
} else { } else {
@ -1816,6 +1834,15 @@ public class MessagesStorage extends BaseController {
chatsDict.put(chat.id, chat); chatsDict.put(chat.id, chat);
} }
} }
/*if (BuildVars.DEBUG_VERSION) {
for (int b = 0; b < 2; b++) {
FileLog.d("contacts = " + contacts[b][0] + ", " + contacts[b][1]);
FileLog.d("nonContacts = " + nonContacts[b][0] + ", " + nonContacts[b][1]);
FileLog.d("groups = " + groups[b][0] + ", " + groups[b][1]);
FileLog.d("channels = " + channels[b][0] + ", " + channels[b][1]);
FileLog.d("bots = " + bots[b][0] + ", " + bots[b][1]);
}
}*/
for (int a = 0, N = dialogFilters.size(); a < N + 2; a++) { for (int a = 0, N = dialogFilters.size(); a < N + 2; a++) {
MessagesController.DialogFilter filter; MessagesController.DialogFilter filter;
int flags; int flags;
@ -1914,47 +1941,59 @@ public class MessagesStorage extends BaseController {
if (did > 0) { if (did > 0) {
TLRPC.User user = usersDict.get(did); TLRPC.User user = usersDict.get(did);
if (user != null) { if (user != null) {
if (user.bot) { if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) != 0 && mutedDialogs.indexOfKey(user.id) >= 0) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_BOTS) == 0) { unreadCount++;
unreadCount++;
}
} else if (user.self || user.contact) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_CONTACTS) == 0) {
unreadCount++;
}
} else { } else {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS) == 0) { if (user.bot) {
unreadCount++; if ((flags & MessagesController.DIALOG_FILTER_FLAG_BOTS) == 0) {
unreadCount++;
}
} else if (user.self || user.contact) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_CONTACTS) == 0) {
unreadCount++;
}
} else {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS) == 0) {
unreadCount++;
}
} }
} }
} }
user = encUsersDict.get(did); user = encUsersDict.get(did);
if (user != null) { if (user != null) {
int count = encryptedChatsByUsersCount.get(did, 0); int count = encryptedChatsByUsersCount.get(did, 0);
if (user.bot) { if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) != 0 && mutedDialogs.indexOfKey(user.id) >= 0) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_BOTS) == 0) { unreadCount += count;
unreadCount += count;
}
} else if (user.self || user.contact) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_CONTACTS) == 0) {
unreadCount += count;
}
} else { } else {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS) == 0) { if (user.bot) {
unreadCount += count; if ((flags & MessagesController.DIALOG_FILTER_FLAG_BOTS) == 0) {
unreadCount += count;
}
} else if (user.self || user.contact) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_CONTACTS) == 0) {
unreadCount += count;
}
} else {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS) == 0) {
unreadCount += count;
}
} }
} }
} }
} else { } else {
TLRPC.Chat chat = chatsDict.get(-did); TLRPC.Chat chat = chatsDict.get(-did);
if (chat != null) { if (chat != null) {
if (ChatObject.isChannel(chat) && !chat.megagroup) { if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) != 0 && mutedDialogs.indexOfKey(-chat.id) >= 0 && dialogsWithMentions.indexOfKey(-chat.id) < 0) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_CHANNELS) == 0) { unreadCount++;
unreadCount++;
}
} else { } else {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_GROUPS) == 0) { if (ChatObject.isChannel(chat) && !chat.megagroup) {
unreadCount++; if ((flags & MessagesController.DIALOG_FILTER_FLAG_CHANNELS) == 0) {
unreadCount++;
}
} else {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_GROUPS) == 0) {
unreadCount++;
}
} }
} }
} }
@ -1979,6 +2018,9 @@ public class MessagesStorage extends BaseController {
} }
} }
filter.pendingUnreadCount = unreadCount; filter.pendingUnreadCount = unreadCount;
/*if (BuildVars.DEBUG_VERSION) {
FileLog.d("filter " + filter.name + " flags = " + filter.flags + " unread count = " + filter.pendingUnreadCount);
}*/
if (apply) { if (apply) {
filter.unreadCount = unreadCount; filter.unreadCount = unreadCount;
} }
@ -3586,6 +3628,7 @@ public class MessagesStorage extends BaseController {
for (int b = 0; b < 2; b++) { for (int b = 0; b < 2; b++) {
contacts[a][b] = nonContacts[a][b] = bots[a][b] = channels[a][b] = groups[a][b] = 0; contacts[a][b] = nonContacts[a][b] = bots[a][b] = channels[a][b] = groups[a][b] = 0;
} }
mentionChannels[a] = mentionGroups[a] = 0;
} }
final ArrayList<TLRPC.User> users = new ArrayList<>(); final ArrayList<TLRPC.User> users = new ArrayList<>();
@ -3595,6 +3638,7 @@ public class MessagesStorage extends BaseController {
ArrayList<Integer> chatsToLoad = new ArrayList<>(); ArrayList<Integer> chatsToLoad = new ArrayList<>();
ArrayList<Integer> encryptedToLoad = new ArrayList<>(); ArrayList<Integer> encryptedToLoad = new ArrayList<>();
LongSparseArray<Integer> dialogsByFolders = new LongSparseArray<>(); LongSparseArray<Integer> dialogsByFolders = new LongSparseArray<>();
LongSparseArray<Integer> newUnreadDialogs = new LongSparseArray<>();
for (int b = 0; b < 2; b++) { for (int b = 0; b < 2; b++) {
LongSparseArray<Integer> array = b == 0 ? dialogsToUpdate : dialogsToUpdateMentions; LongSparseArray<Integer> array = b == 0 ? dialogsToUpdate : dialogsToUpdateMentions;
@ -3610,27 +3654,41 @@ public class MessagesStorage extends BaseController {
if (read) { if (read) {
if (b == 0) { if (b == 0) {
dialogsWithUnread.remove(did); dialogsWithUnread.remove(did);
/*if (BuildVars.DEBUG_VERSION) {
FileLog.d("read remove = " + did);
}*/
} else { } else {
dialogsWithMentions.remove(did); dialogsWithMentions.remove(did);
/*if (BuildVars.DEBUG_VERSION) {
FileLog.d("mention remove = " + did);
}*/
} }
} else { } else {
if (dialogsWithMentions.indexOfKey(did) < 0 && dialogsWithUnread.indexOfKey(did) < 0) {
newUnreadDialogs.put(did, count);
}
if (b == 0) { if (b == 0) {
dialogsWithUnread.put(did, count); dialogsWithUnread.put(did, count);
/*if (BuildVars.DEBUG_VERSION) {
FileLog.d("read add = " + did);
}*/
} else { } else {
dialogsWithMentions.put(did, count); dialogsWithMentions.put(did, count);
/*if (BuildVars.DEBUG_VERSION) {
FileLog.d("mention add = " + did);
}*/
} }
} }
if (b == 0 && dialogsWithMentions.indexOfKey(did) >= 0 || b == 1 && dialogsWithUnread.indexOfKey(did) >= 0) {
continue;
}
SQLiteCursor cursor = database.queryFinalized("SELECT folder_id FROM dialogs WHERE did = " + did);
int folderId = 0;
if (cursor.next()) {
folderId = cursor.intValue(0);
}
cursor.dispose();
dialogsByFolders.put(did, folderId); if (dialogsByFolders.indexOfKey(did) < 0) {
SQLiteCursor cursor = database.queryFinalized("SELECT folder_id FROM dialogs WHERE did = " + did);
int folderId = 0;
if (cursor.next()) {
folderId = cursor.intValue(0);
}
cursor.dispose();
dialogsByFolders.put(did, folderId);
}
int lowerId = (int) did; int lowerId = (int) did;
int highId = (int) (did >> 32); int highId = (int) (did >> 32);
@ -3655,12 +3713,17 @@ public class MessagesStorage extends BaseController {
SparseArray<TLRPC.Chat> chatsDict = new SparseArray<>(); SparseArray<TLRPC.Chat> chatsDict = new SparseArray<>();
SparseArray<TLRPC.User> encUsersDict = new SparseArray<>(); SparseArray<TLRPC.User> encUsersDict = new SparseArray<>();
SparseArray<Integer> encryptedChatsByUsersCount = new SparseArray<>(); SparseArray<Integer> encryptedChatsByUsersCount = new SparseArray<>();
SparseArray<Boolean> mutedDialogs = new SparseArray<>();
if (!usersToLoad.isEmpty()) { if (!usersToLoad.isEmpty()) {
getUsersInternal(TextUtils.join(",", usersToLoad), users); getUsersInternal(TextUtils.join(",", usersToLoad), users);
for (int a = 0, N = users.size(); a < N; a++) { for (int a = 0, N = users.size(); a < N; a++) {
TLRPC.User user = users.get(a); TLRPC.User user = users.get(a);
boolean muted = getMessagesController().isDialogMuted(user.id);
int idx1 = dialogsByFolders.get(user.id); int idx1 = dialogsByFolders.get(user.id);
int idx2 = getMessagesController().isDialogMuted(user.id) && (dialogsToUpdateMentions == null || dialogsToUpdateMentions.indexOfKey(user.id) < 0) ? 1 : 0; int idx2 = muted ? 1 : 0;
if (muted) {
mutedDialogs.put(user.id, true);
}
if (user.bot) { if (user.bot) {
bots[idx1][idx2]++; bots[idx1][idx2]++;
} else if (user.self || user.contact) { } else if (user.self || user.contact) {
@ -3688,8 +3751,12 @@ public class MessagesStorage extends BaseController {
continue; continue;
} }
long did = ((long) encryptedChat.id) << 32; long did = ((long) encryptedChat.id) << 32;
boolean muted = getMessagesController().isDialogMuted(did);
int idx1 = dialogsByFolders.get(did); int idx1 = dialogsByFolders.get(did);
int idx2 = getMessagesController().isDialogMuted(did) && (dialogsToUpdateMentions == null || dialogsToUpdateMentions.indexOfKey(did) < 0) ? 1 : 0; int idx2 = muted ? 1 : 0;
if (muted) {
mutedDialogs.put(user.id, true);
}
if (user.self || user.contact) { if (user.self || user.contact) {
contacts[idx1][idx2]++; contacts[idx1][idx2]++;
} else { } else {
@ -3707,16 +3774,40 @@ public class MessagesStorage extends BaseController {
if (chat.migrated_to instanceof TLRPC.TL_inputChannel || ChatObject.isNotInChat(chat)) { if (chat.migrated_to instanceof TLRPC.TL_inputChannel || ChatObject.isNotInChat(chat)) {
continue; continue;
} }
boolean muted = getMessagesController().isDialogMuted(-chat.id, chat);
boolean hasUnread = dialogsWithUnread.indexOfKey(-chat.id) >= 0;
boolean hasMention = dialogsWithMentions.indexOfKey(-chat.id) >= 0;
int idx1 = dialogsByFolders.get(-chat.id); int idx1 = dialogsByFolders.get(-chat.id);
int idx2 = getMessagesController().isDialogMuted(-chat.id) && (dialogsToUpdateMentions == null || dialogsToUpdateMentions.indexOfKey(-chat.id) < 0) ? 1 : 0; int idx2 = muted ? 1 : 0;
if (ChatObject.isChannel(chat) && !chat.megagroup) { if (muted) {
channels[idx1][idx2]++; mutedDialogs.put(-chat.id, true);
} else { }
groups[idx1][idx2]++; if (muted && dialogsToUpdateMentions != null && dialogsToUpdateMentions.indexOfKey(-chat.id) >= 0) {
if (ChatObject.isChannel(chat) && !chat.megagroup) {
mentionChannels[idx1]++;
} else {
mentionGroups[idx1]++;
}
}
if (read && !hasUnread && !hasMention || !read && newUnreadDialogs.indexOfKey(-chat.id) >= 0) {
if (ChatObject.isChannel(chat) && !chat.megagroup) {
channels[idx1][idx2]++;
} else {
groups[idx1][idx2]++;
}
} }
chatsDict.put(chat.id, chat); chatsDict.put(chat.id, chat);
} }
} }
/*if (BuildVars.DEBUG_VERSION) {
for (int b = 0; b < 2; b++) {
FileLog.d("read = " + read + " contacts = " + contacts[b][0] + ", " + contacts[b][1]);
FileLog.d("read = " + read + " nonContacts = " + nonContacts[b][0] + ", " + nonContacts[b][1]);
FileLog.d("read = " + read + " groups = " + groups[b][0] + ", " + groups[b][1]);
FileLog.d("read = " + read + " channels = " + channels[b][0] + ", " + channels[b][1]);
FileLog.d("read = " + read + " bots = " + bots[b][0] + ", " + bots[b][1]);
}
}*/
for (int a = 0, N = dialogFilters.size(); a < N + 2; a++) { for (int a = 0, N = dialogFilters.size(); a < N + 2; a++) {
int unreadCount; int unreadCount;
@ -3777,12 +3868,16 @@ public class MessagesStorage extends BaseController {
unreadCount -= groups[0][0]; unreadCount -= groups[0][0];
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) { if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
unreadCount -= groups[0][1]; unreadCount -= groups[0][1];
} else {
unreadCount -= mentionGroups[0];
} }
} }
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED) == 0) { if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED) == 0) {
unreadCount -= groups[1][0]; unreadCount -= groups[1][0];
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) { if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
unreadCount -= groups[1][1]; unreadCount -= groups[1][1];
} else {
unreadCount -= mentionGroups[1];
} }
} }
} }
@ -3791,12 +3886,16 @@ public class MessagesStorage extends BaseController {
unreadCount -= channels[0][0]; unreadCount -= channels[0][0];
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) { if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
unreadCount -= channels[0][1]; unreadCount -= channels[0][1];
} else {
unreadCount -= mentionChannels[0];
} }
} }
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED) == 0) { if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED) == 0) {
unreadCount -= channels[1][0]; unreadCount -= channels[1][0];
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) { if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
unreadCount -= channels[1][1]; unreadCount -= channels[1][1];
} else {
unreadCount -= mentionChannels[1];
} }
} }
} }
@ -3820,47 +3919,59 @@ public class MessagesStorage extends BaseController {
if (did > 0) { if (did > 0) {
TLRPC.User user = usersDict.get(did); TLRPC.User user = usersDict.get(did);
if (user != null) { if (user != null) {
if (user.bot) { if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) != 0 && mutedDialogs.indexOfKey(user.id) >= 0) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_BOTS) == 0) { unreadCount--;
unreadCount--;
}
} else if (user.self || user.contact) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_CONTACTS) == 0) {
unreadCount--;
}
} else { } else {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS) == 0) { if (user.bot) {
unreadCount--; if ((flags & MessagesController.DIALOG_FILTER_FLAG_BOTS) == 0) {
unreadCount--;
}
} else if (user.self || user.contact) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_CONTACTS) == 0) {
unreadCount--;
}
} else {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS) == 0) {
unreadCount--;
}
} }
} }
} }
user = encUsersDict.get(did); user = encUsersDict.get(did);
if (user != null) { if (user != null) {
int count = encryptedChatsByUsersCount.get(did, 0); int count = encryptedChatsByUsersCount.get(did, 0);
if (user.bot) { if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) != 0 && mutedDialogs.indexOfKey(user.id) >= 0) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_BOTS) == 0) { unreadCount -= count;
unreadCount -= count;
}
} else if (user.self || user.contact) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_CONTACTS) == 0) {
unreadCount -= count;
}
} else { } else {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS) == 0) { if (user.bot) {
unreadCount -= count; if ((flags & MessagesController.DIALOG_FILTER_FLAG_BOTS) == 0) {
unreadCount -= count;
}
} else if (user.self || user.contact) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_CONTACTS) == 0) {
unreadCount -= count;
}
} else {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS) == 0) {
unreadCount -= count;
}
} }
} }
} }
} else { } else {
TLRPC.Chat chat = chatsDict.get(-did); TLRPC.Chat chat = chatsDict.get(-did);
if (chat != null) { if (chat != null) {
if (ChatObject.isChannel(chat) && !chat.megagroup) { if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) != 0 && mutedDialogs.indexOfKey(-chat.id) >= 0 && dialogsWithMentions.indexOfKey(-chat.id) < 0 && dialogsWithUnread.indexOfKey(-chat.id) < 0) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_CHANNELS) == 0) { unreadCount--;
unreadCount--;
}
} else { } else {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_GROUPS) == 0) { if (ChatObject.isChannel(chat) && !chat.megagroup) {
unreadCount--; if ((flags & MessagesController.DIALOG_FILTER_FLAG_CHANNELS) == 0) {
unreadCount--;
}
} else {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_GROUPS) == 0) {
unreadCount--;
}
} }
} }
} }
@ -3868,6 +3979,9 @@ public class MessagesStorage extends BaseController {
} }
for (int b = 0, N2 = filter.neverShow.size(); b < N2; b++) { for (int b = 0, N2 = filter.neverShow.size(); b < N2; b++) {
int did = filter.neverShow.get(b); int did = filter.neverShow.get(b);
if (dialogsToUpdateMentions != null && dialogsToUpdateMentions.indexOfKey(did) >= 0 && mutedDialogs.indexOfKey(did) < 0) {
continue;
}
if (did > 0) { if (did > 0) {
TLRPC.User user = usersDict.get(did); TLRPC.User user = usersDict.get(did);
if (user != null) { if (user != null) {
@ -3922,12 +4036,16 @@ public class MessagesStorage extends BaseController {
unreadCount += groups[0][0]; unreadCount += groups[0][0];
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) { if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
unreadCount += groups[0][1]; unreadCount += groups[0][1];
} else {
unreadCount += mentionGroups[0];
} }
} }
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED) == 0) { if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED) == 0) {
unreadCount += groups[1][0]; unreadCount += groups[1][0];
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) { if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
unreadCount += groups[1][1]; unreadCount += groups[1][1];
} else {
unreadCount += mentionGroups[1];
} }
} }
} }
@ -3936,12 +4054,16 @@ public class MessagesStorage extends BaseController {
unreadCount += channels[0][0]; unreadCount += channels[0][0];
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) { if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
unreadCount += channels[0][1]; unreadCount += channels[0][1];
} else {
unreadCount += mentionChannels[0];
} }
} }
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED) == 0) { if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED) == 0) {
unreadCount += channels[1][0]; unreadCount += channels[1][0];
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) { if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
unreadCount += channels[1][1]; unreadCount += channels[1][1];
} else {
unreadCount += mentionChannels[1];
} }
} }
} }
@ -3960,52 +4082,87 @@ public class MessagesStorage extends BaseController {
} }
} }
if (filter != null) { if (filter != null) {
for (int b = 0, N2 = filter.alwaysShow.size(); b < N2; b++) { if (!filter.alwaysShow.isEmpty()) {
int did = filter.alwaysShow.get(b); if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) != 0) {
if (did > 0) { for (int b = 0, N2 = dialogsToUpdateMentions.size(); b < N2; b++) {
TLRPC.User user = usersDict.get(did); int did = (int) dialogsToUpdateMentions.keyAt(b);
if (user != null) { TLRPC.Chat chat = chatsDict.get(-did);
if (user.bot) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_BOTS) == 0) {
unreadCount++;
}
} else if (user.self || user.contact) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_CONTACTS) == 0) {
unreadCount++;
}
} else {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS) == 0) {
unreadCount++;
}
}
}
user = encUsersDict.get(did);
if (user != null) {
int count = encryptedChatsByUsersCount.get(did, 0);
if (user.bot) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_BOTS) == 0) {
unreadCount += count;
}
} else if (user.self || user.contact) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_CONTACTS) == 0) {
unreadCount += count;
}
} else {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS) == 0) {
unreadCount += count;
}
}
}
} else {
TLRPC.Chat chat = chatsDict.get(-did);
if (chat != null) {
if (ChatObject.isChannel(chat) && !chat.megagroup) { if (ChatObject.isChannel(chat) && !chat.megagroup) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_CHANNELS) == 0) { if ((flags & MessagesController.DIALOG_FILTER_FLAG_CHANNELS) == 0) {
unreadCount++; continue;
} }
} else { } else {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_GROUPS) == 0) { if ((flags & MessagesController.DIALOG_FILTER_FLAG_GROUPS) == 0) {
continue;
}
}
if (mutedDialogs.indexOfKey(did) >= 0 && filter.alwaysShow.indexOf(did) >= 0) {
unreadCount--;
}
}
}
for (int b = 0, N2 = filter.alwaysShow.size(); b < N2; b++) {
int did = filter.alwaysShow.get(b);
if (newUnreadDialogs.indexOfKey(did) < 0) {
continue;
}
if (did > 0) {
TLRPC.User user = usersDict.get(did);
if (user != null) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) != 0 && mutedDialogs.indexOfKey(user.id) >= 0) {
unreadCount++; unreadCount++;
} else {
if (user.bot) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_BOTS) == 0) {
unreadCount++;
}
} else if (user.self || user.contact) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_CONTACTS) == 0) {
unreadCount++;
}
} else {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS) == 0) {
unreadCount++;
}
}
}
}
user = encUsersDict.get(did);
if (user != null) {
int count = encryptedChatsByUsersCount.get(did, 0);
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) != 0 && mutedDialogs.indexOfKey(user.id) >= 0) {
unreadCount += count;
} else {
if (user.bot) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_BOTS) == 0) {
unreadCount += count;
}
} else if (user.self || user.contact) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_CONTACTS) == 0) {
unreadCount += count;
}
} else {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS) == 0) {
unreadCount += count;
}
}
}
}
} else {
TLRPC.Chat chat = chatsDict.get(-did);
if (chat != null) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) != 0 && mutedDialogs.indexOfKey(-chat.id) >= 0) {
unreadCount++;
} else {
if (ChatObject.isChannel(chat) && !chat.megagroup) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_CHANNELS) == 0) {
unreadCount++;
}
} else {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_GROUPS) == 0) {
unreadCount++;
}
}
} }
} }
} }
@ -4033,6 +4190,9 @@ public class MessagesStorage extends BaseController {
} }
if (filter != null) { if (filter != null) {
filter.pendingUnreadCount = unreadCount; filter.pendingUnreadCount = unreadCount;
/*if (BuildVars.DEBUG_VERSION) {
FileLog.d("filter " + filter.name + " flags = " + flags + " read = " + read + " unread count = " + filter.pendingUnreadCount);
}*/
} else if (a == N) { } else if (a == N) {
pendingMainUnreadCount = unreadCount; pendingMainUnreadCount = unreadCount;
} else if (a == N + 1) { } else if (a == N + 1) {

View File

@ -10,13 +10,13 @@ package org.telegram.messenger;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.os.Build; import android.os.Build;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.Locale;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
@ -24,36 +24,105 @@ public class NativeLoader {
private final static int LIB_VERSION = 30; private final static int LIB_VERSION = 30;
private final static String LIB_NAME = "tmessages." + LIB_VERSION; private final static String LIB_NAME = "tmessages." + LIB_VERSION;
private final static String SHARED_LIB_NAME = "c++_shared"; private final static String LIB_SO_NAME = "lib" + LIB_NAME + ".so";
private final static String LOCALE_LIB_SO_NAME = "lib" + LIB_NAME + "loc.so";
private String crashPath = "";
private static volatile boolean nativeLoaded = false; private static volatile boolean nativeLoaded = false;
private NativeLoader() { private static File getNativeLibraryDir(Context context) {
File f = null;
if (context != null) {
try {
f = new File((String)ApplicationInfo.class.getField("nativeLibraryDir").get(context.getApplicationInfo()));
} catch (Throwable th) {
th.printStackTrace();
}
}
if (f == null) {
f = new File(context.getApplicationInfo().dataDir, "lib");
}
if (f.isDirectory()) {
return f;
}
return null;
} }
public static synchronized void initNativeLibs(Context context) { @SuppressLint({"UnsafeDynamicallyLoadedCode", "SetWorldReadable"})
if (!nativeLoaded) { private static boolean loadFromZip(Context context, File destDir, File destLocalFile, String folder) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) { try {
if (!loadNativeLib(context, SHARED_LIB_NAME)) { for (File file : destDir.listFiles()) {
throw new IllegalStateException("unable to load shared c++ library: " + SHARED_LIB_NAME); file.delete();
}
} catch (Exception e) {
FileLog.e(e);
}
ZipFile zipFile = null;
InputStream stream = null;
try {
zipFile = new ZipFile(context.getApplicationInfo().sourceDir);
ZipEntry entry = zipFile.getEntry("lib/" + folder + "/" + LIB_SO_NAME);
if (entry == null) {
throw new Exception("Unable to find file in apk:" + "lib/" + folder + "/" + LIB_NAME);
}
stream = zipFile.getInputStream(entry);
OutputStream out = new FileOutputStream(destLocalFile);
byte[] buf = new byte[4096];
int len;
while ((len = stream.read(buf)) > 0) {
Thread.yield();
out.write(buf, 0, len);
}
out.close();
destLocalFile.setReadable(true, false);
destLocalFile.setExecutable(true, false);
destLocalFile.setWritable(true);
try {
System.load(destLocalFile.getAbsolutePath());
nativeLoaded = true;
} catch (Error e) {
FileLog.e(e);
}
return true;
} catch (Exception e) {
FileLog.e(e);
} finally {
if (stream != null) {
try {
stream.close();
} catch (Exception e) {
FileLog.e(e);
} }
} }
if (!loadNativeLib(context, LIB_NAME)) { if (zipFile != null) {
throw new IllegalStateException("unable to load native library: " + LIB_NAME); try {
zipFile.close();
} catch (Exception e) {
FileLog.e(e);
}
} }
nativeLoaded = true;
} }
return false;
} }
@SuppressLint("UnsafeDynamicallyLoadedCode") @SuppressLint("UnsafeDynamicallyLoadedCode")
private static boolean loadNativeLib(Context context, String libName) { public static synchronized void initNativeLibs(Context context) {
if (nativeLoaded) {
return;
}
try { try {
try { try {
System.loadLibrary(libName); System.loadLibrary(LIB_NAME);
nativeLoaded = true;
if (BuildVars.LOGS_ENABLED) { if (BuildVars.LOGS_ENABLED) {
FileLog.d("loaded normal lib: " + libName); FileLog.d("loaded normal lib");
} }
return true; return;
} catch (Error e) { } catch (Error e) {
FileLog.e(e); FileLog.e(e);
} }
@ -89,17 +158,32 @@ public class NativeLoader {
folder = "x86"; folder = "x86";
} }
/*File destFile = getNativeLibraryDir(context);
if (destFile != null) {
destFile = new File(destFile, LIB_SO_NAME);
if (destFile.exists()) {
try {
System.loadLibrary(LIB_NAME);
nativeLoaded = true;
return;
} catch (Error e) {
FileLog.e(e);
}
}
}*/
File destDir = new File(context.getFilesDir(), "lib"); File destDir = new File(context.getFilesDir(), "lib");
destDir.mkdirs(); destDir.mkdirs();
File destLocalFile = new File(destDir, "lib" + libName + "loc.so"); File destLocalFile = new File(destDir, LOCALE_LIB_SO_NAME);
if (destLocalFile.exists()) { if (destLocalFile.exists()) {
try { try {
System.load(destLocalFile.getAbsolutePath());
if (BuildVars.LOGS_ENABLED) { if (BuildVars.LOGS_ENABLED) {
FileLog.d("loaded local lib: " + libName); FileLog.d("Load local lib");
} }
return true; System.load(destLocalFile.getAbsolutePath());
nativeLoaded = true;
return;
} catch (Error e) { } catch (Error e) {
FileLog.e(e); FileLog.e(e);
} }
@ -107,89 +191,24 @@ public class NativeLoader {
} }
if (BuildVars.LOGS_ENABLED) { if (BuildVars.LOGS_ENABLED) {
FileLog.e(String.format(Locale.US, "library %s not found, arch = %s", libName, folder)); FileLog.e("Library not found, arch = " + folder);
} }
if (loadFromZip(context, destDir, destLocalFile, folder, libName)) { if (loadFromZip(context, destDir, destLocalFile, folder)) {
return true; return;
} }
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
} }
try { try {
System.loadLibrary(libName); System.loadLibrary(LIB_NAME);
if (BuildVars.LOGS_ENABLED) { nativeLoaded = true;
FileLog.d("loaded lib: " + libName);
}
return true;
} catch (Error e) { } catch (Error e) {
FileLog.e(e); FileLog.e(e);
} }
return false;
} }
@SuppressLint({"UnsafeDynamicallyLoadedCode", "SetWorldReadable"}) private static native void init(String path, boolean enable);
private static boolean loadFromZip(Context context, File destDir, File destLocalFile, String folder, String libName) { //public static native void crash();
try {
for (File file : destDir.listFiles()) {
file.delete();
}
} catch (Exception e) {
FileLog.e(e);
}
ZipFile zipFile = null;
InputStream stream = null;
try {
zipFile = new ZipFile(context.getApplicationInfo().sourceDir);
ZipEntry entry = zipFile.getEntry("lib/" + folder + "/lib" + libName + ".so");
if (entry == null) {
throw new Exception("Unable to find file in apk:" + "lib/" + folder + "/" + libName);
}
stream = zipFile.getInputStream(entry);
OutputStream out = new FileOutputStream(destLocalFile);
byte[] buf = new byte[4096];
int len;
while ((len = stream.read(buf)) > 0) {
Thread.yield();
out.write(buf, 0, len);
}
out.close();
destLocalFile.setReadable(true, false);
destLocalFile.setExecutable(true, false);
destLocalFile.setWritable(true);
try {
System.load(destLocalFile.getAbsolutePath());
if (BuildVars.LOGS_ENABLED) {
FileLog.d("loaded lib from zip: " + libName);
}
return true;
} catch (Error e) {
FileLog.e(e);
}
} catch (Exception e) {
FileLog.e(e);
} finally {
if (stream != null) {
try {
stream.close();
} catch (Exception e) {
FileLog.e(e);
}
}
if (zipFile != null) {
try {
zipFile.close();
} catch (Exception e) {
FileLog.e(e);
}
}
}
return false;
}
} }

View File

@ -3805,10 +3805,16 @@ public class NotificationsController extends BaseController {
} }
public boolean isGlobalNotificationsEnabled(long did) { public boolean isGlobalNotificationsEnabled(long did) {
return isGlobalNotificationsEnabled(did, null);
}
public boolean isGlobalNotificationsEnabled(long did, TLRPC.Chat chat) {
int type; int type;
int lower_id = (int) did; int lower_id = (int) did;
if (lower_id < 0) { if (lower_id < 0) {
TLRPC.Chat chat = getMessagesController().getChat(-lower_id); if (chat == null) {
chat = getMessagesController().getChat(-lower_id);
}
if (ChatObject.isChannel(chat) && !chat.megagroup) { if (ChatObject.isChannel(chat) && !chat.megagroup) {
type = TYPE_CHANNEL; type = TYPE_CHANNEL;
} else { } else {

View File

@ -250,7 +250,7 @@ public class SharedLinkCell extends FrameLayout {
} }
} }
if (link != null) { if (link != null) {
if (link.toLowerCase().indexOf("http") != 0 && link.toLowerCase().indexOf("mailto") != 0) { if (!link.contains("://") && link.toLowerCase().indexOf("http") != 0 && link.toLowerCase().indexOf("mailto") != 0) {
links.add("http://" + link); links.add("http://" + link);
} else { } else {
links.add(link); links.add(link);

View File

@ -16626,15 +16626,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return; return;
} }
if (message.isDice()) { if (message.isDice()) {
try { undoView.showWithAction(0, chatActivityEnterView.getVisibility() == View.VISIBLE ? UndoView.ACTION_DICE_INFO : UndoView.ACTION_DICE_NO_SEND_INFO, null, null, () -> getSendMessagesHelper().sendMessage("\uD83C\uDFB2", dialog_id, null, null, false, null, null, null, true, 0));
if (currentToast != null) {
currentToast.cancel();
}
} catch (Exception e) {
FileLog.e(e);
}
currentToast = Toast.makeText(getParentActivity(), LocaleController.getString("DiceInfo", R.string.DiceInfo), Toast.LENGTH_SHORT);
currentToast.show();
} else if (message.isAnimatedEmoji()) { } else if (message.isAnimatedEmoji()) {
restartSticker(cell); restartSticker(cell);
} else if (message.needDrawBluredPreview()) { } else if (message.needDrawBluredPreview()) {

View File

@ -946,7 +946,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
@Override @Override
protected void onDraw(Canvas canvas) { protected void onDraw(Canvas canvas) {
float multilinTooltipOffset = 0; float multilinTooltipOffset = 0;
if (tooltipLayout.getLineCount() > 1) { if (tooltipLayout != null && tooltipLayout.getLineCount() > 1) {
multilinTooltipOffset = tooltipLayout.getHeight() - tooltipLayout.getLineBottom(0); multilinTooltipOffset = tooltipLayout.getHeight() - tooltipLayout.getLineBottom(0);
} }
int cx = getMeasuredWidth() - AndroidUtilities.dp2(26); int cx = getMeasuredWidth() - AndroidUtilities.dp2(26);
@ -1194,47 +1194,50 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
} }
} }
int alphaInt = (int) (tooltipAlpha * 255); int alphaInt = (int) (tooltipAlpha * 255);
tooltipBackground.setAlpha(alphaInt); tooltipBackground.setAlpha(alphaInt);
tooltipBackgroundArrow.setAlpha(alphaInt); tooltipBackgroundArrow.setAlpha(alphaInt);
tooltipPaint.setAlpha(alphaInt); tooltipPaint.setAlpha(alphaInt);
canvas.save(); if (tooltipLayout != null) {
rectF.set(0, 0, getMeasuredWidth(), getMeasuredHeight()); canvas.save();
canvas.translate(getMeasuredWidth() - tooltipWidth - AndroidUtilities.dp(44), AndroidUtilities.dpf2(16)); rectF.set(0, 0, getMeasuredWidth(), getMeasuredHeight());
tooltipBackground.setBounds( canvas.translate(getMeasuredWidth() - tooltipWidth - AndroidUtilities.dp(44), AndroidUtilities.dpf2(16));
-AndroidUtilities.dp(8), -AndroidUtilities.dp(2), tooltipBackground.setBounds(
(int) (tooltipWidth + AndroidUtilities.dp(36)), (int) (tooltipLayout.getHeight() + AndroidUtilities.dpf2(4)) -AndroidUtilities.dp(8), -AndroidUtilities.dp(2),
); (int) (tooltipWidth + AndroidUtilities.dp(36)), (int) (tooltipLayout.getHeight() + AndroidUtilities.dpf2(4))
tooltipBackground.draw(canvas); );
tooltipLayout.draw(canvas); tooltipBackground.draw(canvas);
canvas.restore(); tooltipLayout.draw(canvas);
canvas.restore();
canvas.save(); canvas.save();
canvas.translate(cx, AndroidUtilities.dpf2(17) + tooltipLayout.getHeight() / 2f - idleProgress * AndroidUtilities.dpf2(3f)); canvas.translate(cx, AndroidUtilities.dpf2(17) + tooltipLayout.getHeight() / 2f - idleProgress * AndroidUtilities.dpf2(3f));
path.reset(); path.reset();
path.setLastPoint(-AndroidUtilities.dpf2(5), AndroidUtilities.dpf2(4)); path.setLastPoint(-AndroidUtilities.dpf2(5), AndroidUtilities.dpf2(4));
path.lineTo(0, 0); path.lineTo(0, 0);
path.lineTo(AndroidUtilities.dpf2(5), AndroidUtilities.dpf2(4)); path.lineTo(AndroidUtilities.dpf2(5), AndroidUtilities.dpf2(4));
Paint p = new Paint(Paint.ANTI_ALIAS_FLAG); Paint p = new Paint(Paint.ANTI_ALIAS_FLAG);
p.setColor(Color.WHITE); p.setColor(Color.WHITE);
p.setAlpha(alphaInt); p.setAlpha(alphaInt);
p.setStyle(Paint.Style.STROKE); p.setStyle(Paint.Style.STROKE);
p.setStrokeCap(Paint.Cap.ROUND); p.setStrokeCap(Paint.Cap.ROUND);
p.setStrokeJoin(Paint.Join.ROUND); p.setStrokeJoin(Paint.Join.ROUND);
p.setStrokeWidth(AndroidUtilities.dpf2(1.5f)); p.setStrokeWidth(AndroidUtilities.dpf2(1.5f));
canvas.drawPath(path, p); canvas.drawPath(path, p);
canvas.restore(); canvas.restore();
canvas.save(); canvas.save();
tooltipBackgroundArrow.setBounds( tooltipBackgroundArrow.setBounds(
cx - tooltipBackgroundArrow.getIntrinsicWidth() / 2, (int) (tooltipLayout.getHeight() + AndroidUtilities.dpf2(20)), cx - tooltipBackgroundArrow.getIntrinsicWidth() / 2, (int) (tooltipLayout.getHeight() + AndroidUtilities.dpf2(20)),
cx + tooltipBackgroundArrow.getIntrinsicWidth() / 2, (int) (tooltipLayout.getHeight() + AndroidUtilities.dpf2(20)) + tooltipBackgroundArrow.getIntrinsicHeight() cx + tooltipBackgroundArrow.getIntrinsicWidth() / 2, (int) (tooltipLayout.getHeight() + AndroidUtilities.dpf2(20)) + tooltipBackgroundArrow.getIntrinsicHeight()
); );
tooltipBackgroundArrow.draw(canvas); tooltipBackgroundArrow.draw(canvas);
canvas.restore(); canvas.restore();
}
} }
canvas.save(); canvas.save();
@ -4437,9 +4440,12 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
sendButton.setVisibility(GONE); sendButton.setVisibility(GONE);
cancelBotButton.setVisibility(GONE); cancelBotButton.setVisibility(GONE);
setSlowModeButtonVisible(false); setSlowModeButtonVisible(false);
audioVideoButtonContainer.setVisibility(VISIBLE);
runningAnimation = null; runningAnimation = null;
runningAnimationType = 0; runningAnimationType = 0;
if (audioVideoButtonContainer != null) {
audioVideoButtonContainer.setVisibility(VISIBLE);
}
} }
} }
@ -5112,7 +5118,9 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
messageEditText.requestFocus(); messageEditText.requestFocus();
} }
recordedAudioBackground.setAlpha(1f); recordedAudioBackground.setAlpha(1f);
attachLayout.setTranslationX(0); if (attachLayout != null) {
attachLayout.setTranslationX(0);
}
slideText.setCancelToProgress(0f); slideText.setCancelToProgress(0f);
delegate.onAudioVideoInterfaceUpdated(); delegate.onAudioVideoInterfaceUpdated();

View File

@ -87,6 +87,8 @@ public class UndoView extends FrameLayout {
public final static int ACTION_QUIZ_CORRECT = 13; public final static int ACTION_QUIZ_CORRECT = 13;
public final static int ACTION_QUIZ_INCORRECT = 14; public final static int ACTION_QUIZ_INCORRECT = 14;
public final static int ACTION_FILTERS_AVAILABLE = 15; public final static int ACTION_FILTERS_AVAILABLE = 15;
public final static int ACTION_DICE_INFO = 16;
public final static int ACTION_DICE_NO_SEND_INFO = 17;
public UndoView(Context context) { public UndoView(Context context) {
super(context); super(context);
@ -267,6 +269,12 @@ public class UndoView extends FrameLayout {
lastUpdateTime = SystemClock.elapsedRealtime(); lastUpdateTime = SystemClock.elapsedRealtime();
undoTextView.setText(LocaleController.getString("Undo", R.string.Undo).toUpperCase()); undoTextView.setText(LocaleController.getString("Undo", R.string.Undo).toUpperCase());
undoImageView.setVisibility(VISIBLE); undoImageView.setVisibility(VISIBLE);
infoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
infoTextView.setGravity(Gravity.LEFT | Gravity.TOP);
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) infoTextView.getLayoutParams();
layoutParams.height = LayoutHelper.WRAP_CONTENT;
layoutParams.bottomMargin = 0;
if (isTooltipAction()) { if (isTooltipAction()) {
CharSequence infoText; CharSequence infoText;
@ -328,7 +336,6 @@ public class UndoView extends FrameLayout {
leftImageView.setAnimation(icon, size, size); leftImageView.setAnimation(icon, size, size);
if (subInfoText != null) { if (subInfoText != null) {
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) infoTextView.getLayoutParams();
layoutParams.leftMargin = AndroidUtilities.dp(58); layoutParams.leftMargin = AndroidUtilities.dp(58);
layoutParams.topMargin = AndroidUtilities.dp(6); layoutParams.topMargin = AndroidUtilities.dp(6);
layoutParams.rightMargin = 0; layoutParams.rightMargin = 0;
@ -339,7 +346,6 @@ public class UndoView extends FrameLayout {
infoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); infoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
infoTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); infoTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
} else { } else {
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) infoTextView.getLayoutParams();
layoutParams.leftMargin = AndroidUtilities.dp(58); layoutParams.leftMargin = AndroidUtilities.dp(58);
layoutParams.topMargin = AndroidUtilities.dp(13); layoutParams.topMargin = AndroidUtilities.dp(13);
layoutParams.rightMargin = 0; layoutParams.rightMargin = 0;
@ -359,7 +365,6 @@ public class UndoView extends FrameLayout {
infoTextView.setText(LocaleController.getString("AuthAnotherClientOk", R.string.AuthAnotherClientOk)); infoTextView.setText(LocaleController.getString("AuthAnotherClientOk", R.string.AuthAnotherClientOk));
leftImageView.setAnimation(R.raw.contact_check, 36, 36); leftImageView.setAnimation(R.raw.contact_check, 36, 36);
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) infoTextView.getLayoutParams();
layoutParams.leftMargin = AndroidUtilities.dp(58); layoutParams.leftMargin = AndroidUtilities.dp(58);
layoutParams.topMargin = AndroidUtilities.dp(6); layoutParams.topMargin = AndroidUtilities.dp(6);
subinfoTextView.setText(authorization.app_name); subinfoTextView.setText(authorization.app_name);
@ -381,7 +386,6 @@ public class UndoView extends FrameLayout {
leftImageView.setAnimation(R.raw.filter_new, 36, 36); leftImageView.setAnimation(R.raw.filter_new, 36, 36);
int margin = (int) Math.ceil(undoTextView.getPaint().measureText(undoTextView.getText().toString())) + AndroidUtilities.dp(26); int margin = (int) Math.ceil(undoTextView.getPaint().measureText(undoTextView.getText().toString())) + AndroidUtilities.dp(26);
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) infoTextView.getLayoutParams();
layoutParams.leftMargin = AndroidUtilities.dp(58); layoutParams.leftMargin = AndroidUtilities.dp(58);
layoutParams.rightMargin = margin; layoutParams.rightMargin = margin;
layoutParams.topMargin = AndroidUtilities.dp(6); layoutParams.topMargin = AndroidUtilities.dp(6);
@ -408,13 +412,38 @@ public class UndoView extends FrameLayout {
leftImageView.setProgress(0); leftImageView.setProgress(0);
leftImageView.playAnimation(); leftImageView.playAnimation();
} else if (currentAction == ACTION_THEME_CHANGED) { } else if (currentAction == ACTION_DICE_INFO || currentAction == ACTION_DICE_NO_SEND_INFO) {
TLRPC.TL_authorization authorization = (TLRPC.TL_authorization) infoObject; timeLeft = 4000;
infoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
infoTextView.setGravity(Gravity.CENTER_VERTICAL);
infoTextView.setText(AndroidUtilities.replaceTags(LocaleController.getString("DiceInfo2", R.string.DiceInfo2)));
undoTextView.setText(LocaleController.getString("SendDice", R.string.SendDice));
leftImageView.setImageResource(R.drawable.dice);
int margin;
if (currentAction == ACTION_DICE_INFO) {
margin = (int) Math.ceil(undoTextView.getPaint().measureText(undoTextView.getText().toString())) + AndroidUtilities.dp(26);
undoTextView.setVisibility(VISIBLE);
undoTextView.setTextColor(Theme.getColor(Theme.key_undo_cancelColor));
undoImageView.setVisibility(GONE);
undoButton.setVisibility(VISIBLE);
} else {
margin = 0;
undoTextView.setVisibility(GONE);
undoButton.setVisibility(GONE);
}
layoutParams.leftMargin = AndroidUtilities.dp(58);
layoutParams.rightMargin = margin;
layoutParams.topMargin = AndroidUtilities.dp(6);
layoutParams.bottomMargin = AndroidUtilities.dp(7);
layoutParams.height = TableLayout.LayoutParams.MATCH_PARENT;
subinfoTextView.setVisibility(GONE);
leftImageView.setVisibility(VISIBLE);
} else if (currentAction == ACTION_THEME_CHANGED) {
infoTextView.setText(LocaleController.getString("ColorThemeChanged", R.string.ColorThemeChanged)); infoTextView.setText(LocaleController.getString("ColorThemeChanged", R.string.ColorThemeChanged));
leftImageView.setImageResource(R.drawable.toast_pallete); leftImageView.setImageResource(R.drawable.toast_pallete);
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) infoTextView.getLayoutParams();
layoutParams.leftMargin = AndroidUtilities.dp(58); layoutParams.leftMargin = AndroidUtilities.dp(58);
layoutParams.rightMargin = AndroidUtilities.dp(48); layoutParams.rightMargin = AndroidUtilities.dp(48);
layoutParams.topMargin = AndroidUtilities.dp(6); layoutParams.topMargin = AndroidUtilities.dp(6);
@ -445,7 +474,6 @@ public class UndoView extends FrameLayout {
infoTextView.setText(LocaleController.getString("ChatsArchived", R.string.ChatsArchived)); infoTextView.setText(LocaleController.getString("ChatsArchived", R.string.ChatsArchived));
} }
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) infoTextView.getLayoutParams();
layoutParams.leftMargin = AndroidUtilities.dp(58); layoutParams.leftMargin = AndroidUtilities.dp(58);
layoutParams.topMargin = AndroidUtilities.dp(13); layoutParams.topMargin = AndroidUtilities.dp(13);
layoutParams.rightMargin = 0; layoutParams.rightMargin = 0;
@ -460,7 +488,6 @@ public class UndoView extends FrameLayout {
leftImageView.setProgress(0); leftImageView.setProgress(0);
leftImageView.playAnimation(); leftImageView.playAnimation();
} else { } else {
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) infoTextView.getLayoutParams();
layoutParams.leftMargin = AndroidUtilities.dp(45); layoutParams.leftMargin = AndroidUtilities.dp(45);
layoutParams.topMargin = AndroidUtilities.dp(13); layoutParams.topMargin = AndroidUtilities.dp(13);
layoutParams.rightMargin = 0; layoutParams.rightMargin = 0;
@ -509,7 +536,7 @@ public class UndoView extends FrameLayout {
width = AndroidUtilities.displaySize.x; width = AndroidUtilities.displaySize.x;
} }
measureChildWithMargins(infoTextView, MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), 0, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), 0); measureChildWithMargins(infoTextView, MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), 0, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), 0);
undoViewHeight = infoTextView.getMeasuredHeight() + AndroidUtilities.dp(28); undoViewHeight = infoTextView.getMeasuredHeight() + AndroidUtilities.dp(currentAction == ACTION_DICE_INFO ? 14 : 28);
} }
if (getVisibility() != VISIBLE) { if (getVisibility() != VISIBLE) {

View File

@ -1749,6 +1749,10 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
if (viewPages[0].selectedType == id) { if (viewPages[0].selectedType == id) {
return; return;
} }
ArrayList<MessagesController.DialogFilter> dialogFilters = getMessagesController().dialogFilters;
if (id != Integer.MAX_VALUE && (id < 0 || id >= dialogFilters.size())) {
return;
}
if (parentLayout != null) { if (parentLayout != null) {
parentLayout.getDrawerLayoutContainer().setAllowOpenDrawerBySwipe(id == filterTabsView.getFirstTabId()); parentLayout.getDrawerLayoutContainer().setAllowOpenDrawerBySwipe(id == filterTabsView.getFirstTabId());
} }
@ -1792,9 +1796,12 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
public int getTabCounter(int tabId) { public int getTabCounter(int tabId) {
if (tabId == Integer.MAX_VALUE) { if (tabId == Integer.MAX_VALUE) {
return getMessagesStorage().getMainUnreadCount(); return getMessagesStorage().getMainUnreadCount();
} else {
return getMessagesController().dialogFilters.get(tabId).unreadCount;
} }
ArrayList<MessagesController.DialogFilter> dialogFilters = getMessagesController().dialogFilters;
if (tabId < 0 || tabId >= dialogFilters.size()) {
return 0;
}
return getMessagesController().dialogFilters.get(tabId).unreadCount;
} }
@Override @Override
@ -3156,7 +3163,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
} else if (actionBar != null && actionBar.isActionModeShowed()) { } else if (actionBar != null && actionBar.isActionModeShowed()) {
hideActionMode(true); hideActionMode(true);
return false; return false;
} else if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE && !filterTabsView.isAnimatingIndicator() && filterTabsView.getCurrentTabId() != Integer.MAX_VALUE && !startedTracking) { } else if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE && !tabsAnimationInProgress && !filterTabsView.isAnimatingIndicator() && filterTabsView.getCurrentTabId() != Integer.MAX_VALUE && !startedTracking) {
filterTabsView.selectFirstTab(); filterTabsView.selectFirstTab();
return false; return false;
} else if (commentView != null && commentView.isPopupShowing()) { } else if (commentView != null && commentView.isPopupShowing()) {
@ -4868,7 +4875,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
} }
private void showFiltersHint() { private void showFiltersHint() {
if (askingForPermissions || !getMessagesController().filtersEnabled || filterTabsView == null || filterTabsView.getVisibility() == View.VISIBLE || isPaused || !getUserConfig().filtersLoaded) { if (askingForPermissions || !getMessagesController().showFiltersTooltip || filterTabsView == null || filterTabsView.getVisibility() == View.VISIBLE || isPaused || !getUserConfig().filtersLoaded) {
return; return;
} }
SharedPreferences preferences = MessagesController.getGlobalMainSettings(); SharedPreferences preferences = MessagesController.getGlobalMainSettings();

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -969,7 +969,8 @@
<string name="TextSelectionHit">Hold the **word**, then move the cursor to select more text to copy.</string> <string name="TextSelectionHit">Hold the **word**, then move the cursor to select more text to copy.</string>
<string name="CardNumberCopied">Card number copied to clipboard</string> <string name="CardNumberCopied">Card number copied to clipboard</string>
<string name="CopyCardNumber">Copy</string> <string name="CopyCardNumber">Copy</string>
<string name="DiceInfo">The result of this throw was randomly generated by Telegram.\nSend a 🎲 emoji to any chat to get a random number from Telegram.</string> <string name="DiceInfo2">Send a **:dice:** emoji to any chat to roll a die.</string>
<string name="SendDice">SEND</string>
<!--notification--> <!--notification-->
<string name="MessageLifetimeChanged">%1$s set the self-destruct timer to %2$s</string> <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> <string name="MessageLifetimeChangedOutgoing">You set the self-destruct timer to %1$s</string>