mirror of
https://github.com/NekoX-Dev/NekoX.git
synced 2024-12-17 07:39:27 +01:00
Merge remote-tracking branch 'telegram/master'
This commit is contained in:
commit
33d49afbcf
2
.github/workflows/android.yml
vendored
2
.github/workflows/android.yml
vendored
@ -1,6 +1,6 @@
|
||||
name: Nekogram
|
||||
|
||||
on:
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
@ -301,7 +301,7 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
defaultConfig.versionCode = 10 * 1908
|
||||
defaultConfig.versionCode = 10 * 1911
|
||||
|
||||
def tgVoipDexFileName = "libtgvoip.dex"
|
||||
def tgVoipDexClasses = ["AudioRecordJNI", "AudioTrackJNI", "NativeTgVoipDelegate", "NativeTgVoipInstance", "TgVoipNativeLoader", "Resampler", "VLog"]
|
||||
@ -399,7 +399,7 @@ android {
|
||||
defaultConfig {
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 28
|
||||
versionName "6.0.0"
|
||||
versionName "6.0.1"
|
||||
|
||||
vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi']
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
APP_PLATFORM := android-16
|
||||
NDK_TOOLCHAIN_VERSION := clang
|
||||
APP_STL := c++_shared
|
||||
APP_SHORT_COMMANDS := true
|
||||
APP_STL := c++_static
|
||||
|
@ -19,7 +19,7 @@ public class BuildVars {
|
||||
public static boolean USE_CLOUD_STRINGS = true;
|
||||
public static boolean CHECK_UPDATES = true;
|
||||
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 int APP_ID = 336779;
|
||||
public static String APP_HASH = "b91eefacc86747c068c8d8a16b41500d";
|
||||
|
@ -261,6 +261,7 @@ public class MessagesController extends BaseController implements NotificationCe
|
||||
public boolean backgroundConnection;
|
||||
public float animatedEmojisZoom;
|
||||
public boolean filtersEnabled;
|
||||
public boolean showFiltersTooltip;
|
||||
public String venueSearchBot;
|
||||
public String gifSearchBot;
|
||||
public String imageSearchBot;
|
||||
@ -528,6 +529,7 @@ public class MessagesController extends BaseController implements NotificationCe
|
||||
animatedEmojisZoom = mainPreferences.getFloat("animatedEmojisZoom", 0.625f);
|
||||
qrLoginCamera = mainPreferences.getBoolean("qrLoginCamera", 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) {
|
||||
@ -997,6 +999,15 @@ public class MessagesController extends BaseController implements NotificationCe
|
||||
filtersEnabled = bool.value;
|
||||
editor.putBoolean("filtersEnabled", filtersEnabled);
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -11642,9 +11653,13 @@ public class MessagesController extends BaseController implements NotificationCe
|
||||
}
|
||||
|
||||
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);
|
||||
if (mute_type == -1) {
|
||||
return !getNotificationsController().isGlobalNotificationsEnabled(dialog_id);
|
||||
return !getNotificationsController().isGlobalNotificationsEnabled(dialog_id, chat);
|
||||
}
|
||||
if (mute_type == 2) {
|
||||
return true;
|
||||
|
@ -1696,6 +1696,8 @@ public class MessagesStorage extends BaseController {
|
||||
private int[][] bots = 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[] mentionChannels = new int[2];
|
||||
private int[] mentionGroups = new int[2];
|
||||
private LongSparseArray<Integer> dialogsWithMentions = new LongSparseArray<>();
|
||||
private LongSparseArray<Integer> dialogsWithUnread = new LongSparseArray<>();
|
||||
private void calcUnreadCounters(boolean apply) {
|
||||
@ -1728,6 +1730,9 @@ public class MessagesStorage extends BaseController {
|
||||
if (mentions > 0) {
|
||||
dialogsWithMentions.put(did, mentions);
|
||||
}
|
||||
/*if (BuildVars.DEBUG_VERSION) {
|
||||
FileLog.d("unread chat " + did + " counters = " + unread + " and " + mentions);
|
||||
}*/
|
||||
dialogsByFolders.put(did, folderId);
|
||||
int lower_id = (int) did;
|
||||
int high_id = (int) (did >> 32);
|
||||
@ -1752,12 +1757,17 @@ public class MessagesStorage extends BaseController {
|
||||
SparseArray<TLRPC.Chat> chatsDict = new SparseArray<>();
|
||||
SparseArray<TLRPC.User> encUsersDict = new SparseArray<>();
|
||||
SparseArray<Integer> encryptedChatsByUsersCount = new SparseArray<>();
|
||||
SparseArray<Boolean> mutedDialogs = new SparseArray<>();
|
||||
if (!usersToLoad.isEmpty()) {
|
||||
getUsersInternal(TextUtils.join(",", usersToLoad), users);
|
||||
for (int a = 0, N = users.size(); a < N; a++) {
|
||||
TLRPC.User user = users.get(a);
|
||||
boolean muted = getMessagesController().isDialogMuted(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) {
|
||||
bots[idx1][idx2]++;
|
||||
} else if (user.self || user.contact) {
|
||||
@ -1785,8 +1795,12 @@ public class MessagesStorage extends BaseController {
|
||||
continue;
|
||||
}
|
||||
long did = ((long) encryptedChat.id) << 32;
|
||||
boolean muted = getMessagesController().isDialogMuted(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) {
|
||||
contacts[idx1][idx2]++;
|
||||
} else {
|
||||
@ -1806,8 +1820,12 @@ public class MessagesStorage extends BaseController {
|
||||
dialogsWithMentions.remove(-chat.id);
|
||||
continue;
|
||||
}
|
||||
boolean muted = getMessagesController().isDialogMuted(-chat.id, chat);
|
||||
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) {
|
||||
channels[idx1][idx2]++;
|
||||
} else {
|
||||
@ -1816,6 +1834,15 @@ public class MessagesStorage extends BaseController {
|
||||
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++) {
|
||||
MessagesController.DialogFilter filter;
|
||||
int flags;
|
||||
@ -1914,47 +1941,59 @@ public class MessagesStorage extends BaseController {
|
||||
if (did > 0) {
|
||||
TLRPC.User user = usersDict.get(did);
|
||||
if (user != null) {
|
||||
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++;
|
||||
}
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) != 0 && mutedDialogs.indexOfKey(user.id) >= 0) {
|
||||
unreadCount++;
|
||||
} else {
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS) == 0) {
|
||||
unreadCount++;
|
||||
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;
|
||||
}
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) != 0 && mutedDialogs.indexOfKey(user.id) >= 0) {
|
||||
unreadCount += count;
|
||||
} else {
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS) == 0) {
|
||||
unreadCount += count;
|
||||
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 ((flags & MessagesController.DIALOG_FILTER_FLAG_CHANNELS) == 0) {
|
||||
unreadCount++;
|
||||
}
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) != 0 && mutedDialogs.indexOfKey(-chat.id) >= 0 && dialogsWithMentions.indexOfKey(-chat.id) < 0) {
|
||||
unreadCount++;
|
||||
} else {
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_GROUPS) == 0) {
|
||||
unreadCount++;
|
||||
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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1979,6 +2018,9 @@ public class MessagesStorage extends BaseController {
|
||||
}
|
||||
}
|
||||
filter.pendingUnreadCount = unreadCount;
|
||||
/*if (BuildVars.DEBUG_VERSION) {
|
||||
FileLog.d("filter " + filter.name + " flags = " + filter.flags + " unread count = " + filter.pendingUnreadCount);
|
||||
}*/
|
||||
if (apply) {
|
||||
filter.unreadCount = unreadCount;
|
||||
}
|
||||
@ -3586,6 +3628,7 @@ public class MessagesStorage extends BaseController {
|
||||
for (int b = 0; b < 2; b++) {
|
||||
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<>();
|
||||
@ -3595,6 +3638,7 @@ public class MessagesStorage extends BaseController {
|
||||
ArrayList<Integer> chatsToLoad = new ArrayList<>();
|
||||
ArrayList<Integer> encryptedToLoad = new ArrayList<>();
|
||||
LongSparseArray<Integer> dialogsByFolders = new LongSparseArray<>();
|
||||
LongSparseArray<Integer> newUnreadDialogs = new LongSparseArray<>();
|
||||
|
||||
for (int b = 0; b < 2; b++) {
|
||||
LongSparseArray<Integer> array = b == 0 ? dialogsToUpdate : dialogsToUpdateMentions;
|
||||
@ -3610,27 +3654,41 @@ public class MessagesStorage extends BaseController {
|
||||
if (read) {
|
||||
if (b == 0) {
|
||||
dialogsWithUnread.remove(did);
|
||||
/*if (BuildVars.DEBUG_VERSION) {
|
||||
FileLog.d("read remove = " + did);
|
||||
}*/
|
||||
} else {
|
||||
dialogsWithMentions.remove(did);
|
||||
/*if (BuildVars.DEBUG_VERSION) {
|
||||
FileLog.d("mention remove = " + did);
|
||||
}*/
|
||||
}
|
||||
} else {
|
||||
if (dialogsWithMentions.indexOfKey(did) < 0 && dialogsWithUnread.indexOfKey(did) < 0) {
|
||||
newUnreadDialogs.put(did, count);
|
||||
}
|
||||
if (b == 0) {
|
||||
dialogsWithUnread.put(did, count);
|
||||
/*if (BuildVars.DEBUG_VERSION) {
|
||||
FileLog.d("read add = " + did);
|
||||
}*/
|
||||
} else {
|
||||
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 highId = (int) (did >> 32);
|
||||
@ -3655,12 +3713,17 @@ public class MessagesStorage extends BaseController {
|
||||
SparseArray<TLRPC.Chat> chatsDict = new SparseArray<>();
|
||||
SparseArray<TLRPC.User> encUsersDict = new SparseArray<>();
|
||||
SparseArray<Integer> encryptedChatsByUsersCount = new SparseArray<>();
|
||||
SparseArray<Boolean> mutedDialogs = new SparseArray<>();
|
||||
if (!usersToLoad.isEmpty()) {
|
||||
getUsersInternal(TextUtils.join(",", usersToLoad), users);
|
||||
for (int a = 0, N = users.size(); a < N; a++) {
|
||||
TLRPC.User user = users.get(a);
|
||||
boolean muted = getMessagesController().isDialogMuted(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) {
|
||||
bots[idx1][idx2]++;
|
||||
} else if (user.self || user.contact) {
|
||||
@ -3688,8 +3751,12 @@ public class MessagesStorage extends BaseController {
|
||||
continue;
|
||||
}
|
||||
long did = ((long) encryptedChat.id) << 32;
|
||||
boolean muted = getMessagesController().isDialogMuted(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) {
|
||||
contacts[idx1][idx2]++;
|
||||
} else {
|
||||
@ -3707,16 +3774,40 @@ public class MessagesStorage extends BaseController {
|
||||
if (chat.migrated_to instanceof TLRPC.TL_inputChannel || ChatObject.isNotInChat(chat)) {
|
||||
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 idx2 = getMessagesController().isDialogMuted(-chat.id) && (dialogsToUpdateMentions == null || dialogsToUpdateMentions.indexOfKey(-chat.id) < 0) ? 1 : 0;
|
||||
if (ChatObject.isChannel(chat) && !chat.megagroup) {
|
||||
channels[idx1][idx2]++;
|
||||
} else {
|
||||
groups[idx1][idx2]++;
|
||||
int idx2 = muted ? 1 : 0;
|
||||
if (muted) {
|
||||
mutedDialogs.put(-chat.id, true);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
/*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++) {
|
||||
int unreadCount;
|
||||
@ -3777,12 +3868,16 @@ public class MessagesStorage extends BaseController {
|
||||
unreadCount -= groups[0][0];
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
|
||||
unreadCount -= groups[0][1];
|
||||
} else {
|
||||
unreadCount -= mentionGroups[0];
|
||||
}
|
||||
}
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED) == 0) {
|
||||
unreadCount -= groups[1][0];
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
|
||||
unreadCount -= groups[1][1];
|
||||
} else {
|
||||
unreadCount -= mentionGroups[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3791,12 +3886,16 @@ public class MessagesStorage extends BaseController {
|
||||
unreadCount -= channels[0][0];
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
|
||||
unreadCount -= channels[0][1];
|
||||
} else {
|
||||
unreadCount -= mentionChannels[0];
|
||||
}
|
||||
}
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED) == 0) {
|
||||
unreadCount -= channels[1][0];
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
|
||||
unreadCount -= channels[1][1];
|
||||
} else {
|
||||
unreadCount -= mentionChannels[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3820,47 +3919,59 @@ public class MessagesStorage extends BaseController {
|
||||
if (did > 0) {
|
||||
TLRPC.User user = usersDict.get(did);
|
||||
if (user != null) {
|
||||
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--;
|
||||
}
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) != 0 && mutedDialogs.indexOfKey(user.id) >= 0) {
|
||||
unreadCount--;
|
||||
} else {
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS) == 0) {
|
||||
unreadCount--;
|
||||
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;
|
||||
}
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) != 0 && mutedDialogs.indexOfKey(user.id) >= 0) {
|
||||
unreadCount -= count;
|
||||
} else {
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS) == 0) {
|
||||
unreadCount -= count;
|
||||
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 ((flags & MessagesController.DIALOG_FILTER_FLAG_CHANNELS) == 0) {
|
||||
unreadCount--;
|
||||
}
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) != 0 && mutedDialogs.indexOfKey(-chat.id) >= 0 && dialogsWithMentions.indexOfKey(-chat.id) < 0 && dialogsWithUnread.indexOfKey(-chat.id) < 0) {
|
||||
unreadCount--;
|
||||
} else {
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_GROUPS) == 0) {
|
||||
unreadCount--;
|
||||
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--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3868,6 +3979,9 @@ public class MessagesStorage extends BaseController {
|
||||
}
|
||||
for (int b = 0, N2 = filter.neverShow.size(); b < N2; b++) {
|
||||
int did = filter.neverShow.get(b);
|
||||
if (dialogsToUpdateMentions != null && dialogsToUpdateMentions.indexOfKey(did) >= 0 && mutedDialogs.indexOfKey(did) < 0) {
|
||||
continue;
|
||||
}
|
||||
if (did > 0) {
|
||||
TLRPC.User user = usersDict.get(did);
|
||||
if (user != null) {
|
||||
@ -3922,12 +4036,16 @@ public class MessagesStorage extends BaseController {
|
||||
unreadCount += groups[0][0];
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
|
||||
unreadCount += groups[0][1];
|
||||
} else {
|
||||
unreadCount += mentionGroups[0];
|
||||
}
|
||||
}
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED) == 0) {
|
||||
unreadCount += groups[1][0];
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
|
||||
unreadCount += groups[1][1];
|
||||
} else {
|
||||
unreadCount += mentionGroups[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3936,12 +4054,16 @@ public class MessagesStorage extends BaseController {
|
||||
unreadCount += channels[0][0];
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
|
||||
unreadCount += channels[0][1];
|
||||
} else {
|
||||
unreadCount += mentionChannels[0];
|
||||
}
|
||||
}
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED) == 0) {
|
||||
unreadCount += channels[1][0];
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
|
||||
unreadCount += channels[1][1];
|
||||
} else {
|
||||
unreadCount += mentionChannels[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3960,52 +4082,87 @@ public class MessagesStorage extends BaseController {
|
||||
}
|
||||
}
|
||||
if (filter != null) {
|
||||
for (int b = 0, N2 = filter.alwaysShow.size(); b < N2; b++) {
|
||||
int did = filter.alwaysShow.get(b);
|
||||
if (did > 0) {
|
||||
TLRPC.User user = usersDict.get(did);
|
||||
if (user != null) {
|
||||
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 (!filter.alwaysShow.isEmpty()) {
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) != 0) {
|
||||
for (int b = 0, N2 = dialogsToUpdateMentions.size(); b < N2; b++) {
|
||||
int did = (int) dialogsToUpdateMentions.keyAt(b);
|
||||
TLRPC.Chat chat = chatsDict.get(-did);
|
||||
if (ChatObject.isChannel(chat) && !chat.megagroup) {
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_CHANNELS) == 0) {
|
||||
unreadCount++;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
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++;
|
||||
} 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) {
|
||||
filter.pendingUnreadCount = unreadCount;
|
||||
/*if (BuildVars.DEBUG_VERSION) {
|
||||
FileLog.d("filter " + filter.name + " flags = " + flags + " read = " + read + " unread count = " + filter.pendingUnreadCount);
|
||||
}*/
|
||||
} else if (a == N) {
|
||||
pendingMainUnreadCount = unreadCount;
|
||||
} else if (a == N + 1) {
|
||||
|
@ -10,13 +10,13 @@ package org.telegram.messenger;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.os.Build;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Locale;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
@ -24,36 +24,105 @@ public class NativeLoader {
|
||||
|
||||
private final static int LIB_VERSION = 30;
|
||||
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 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) {
|
||||
if (!nativeLoaded) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||
if (!loadNativeLib(context, SHARED_LIB_NAME)) {
|
||||
throw new IllegalStateException("unable to load shared c++ library: " + SHARED_LIB_NAME);
|
||||
@SuppressLint({"UnsafeDynamicallyLoadedCode", "SetWorldReadable"})
|
||||
private static boolean loadFromZip(Context context, File destDir, File destLocalFile, String folder) {
|
||||
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_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)) {
|
||||
throw new IllegalStateException("unable to load native library: " + LIB_NAME);
|
||||
if (zipFile != null) {
|
||||
try {
|
||||
zipFile.close();
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
}
|
||||
nativeLoaded = true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressLint("UnsafeDynamicallyLoadedCode")
|
||||
private static boolean loadNativeLib(Context context, String libName) {
|
||||
public static synchronized void initNativeLibs(Context context) {
|
||||
if (nativeLoaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
try {
|
||||
System.loadLibrary(libName);
|
||||
System.loadLibrary(LIB_NAME);
|
||||
nativeLoaded = true;
|
||||
if (BuildVars.LOGS_ENABLED) {
|
||||
FileLog.d("loaded normal lib: " + libName);
|
||||
FileLog.d("loaded normal lib");
|
||||
}
|
||||
return true;
|
||||
return;
|
||||
} catch (Error e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
@ -89,17 +158,32 @@ public class NativeLoader {
|
||||
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");
|
||||
destDir.mkdirs();
|
||||
|
||||
File destLocalFile = new File(destDir, "lib" + libName + "loc.so");
|
||||
File destLocalFile = new File(destDir, LOCALE_LIB_SO_NAME);
|
||||
if (destLocalFile.exists()) {
|
||||
try {
|
||||
System.load(destLocalFile.getAbsolutePath());
|
||||
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) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
@ -107,89 +191,24 @@ public class NativeLoader {
|
||||
}
|
||||
|
||||
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)) {
|
||||
return true;
|
||||
if (loadFromZip(context, destDir, destLocalFile, folder)) {
|
||||
return;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
System.loadLibrary(libName);
|
||||
if (BuildVars.LOGS_ENABLED) {
|
||||
FileLog.d("loaded lib: " + libName);
|
||||
}
|
||||
return true;
|
||||
System.loadLibrary(LIB_NAME);
|
||||
nativeLoaded = true;
|
||||
} catch (Error e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressLint({"UnsafeDynamicallyLoadedCode", "SetWorldReadable"})
|
||||
private static boolean loadFromZip(Context context, File destDir, File destLocalFile, String folder, String libName) {
|
||||
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;
|
||||
}
|
||||
private static native void init(String path, boolean enable);
|
||||
//public static native void crash();
|
||||
}
|
||||
|
@ -3805,10 +3805,16 @@ public class NotificationsController extends BaseController {
|
||||
}
|
||||
|
||||
public boolean isGlobalNotificationsEnabled(long did) {
|
||||
return isGlobalNotificationsEnabled(did, null);
|
||||
}
|
||||
|
||||
public boolean isGlobalNotificationsEnabled(long did, TLRPC.Chat chat) {
|
||||
int type;
|
||||
int lower_id = (int) did;
|
||||
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) {
|
||||
type = TYPE_CHANNEL;
|
||||
} else {
|
||||
|
@ -250,7 +250,7 @@ public class SharedLinkCell extends FrameLayout {
|
||||
}
|
||||
}
|
||||
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);
|
||||
} else {
|
||||
links.add(link);
|
||||
|
@ -16626,15 +16626,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
return;
|
||||
}
|
||||
if (message.isDice()) {
|
||||
try {
|
||||
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();
|
||||
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));
|
||||
} else if (message.isAnimatedEmoji()) {
|
||||
restartSticker(cell);
|
||||
} else if (message.needDrawBluredPreview()) {
|
||||
|
@ -946,7 +946,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
float multilinTooltipOffset = 0;
|
||||
if (tooltipLayout.getLineCount() > 1) {
|
||||
if (tooltipLayout != null && tooltipLayout.getLineCount() > 1) {
|
||||
multilinTooltipOffset = tooltipLayout.getHeight() - tooltipLayout.getLineBottom(0);
|
||||
}
|
||||
int cx = getMeasuredWidth() - AndroidUtilities.dp2(26);
|
||||
@ -1194,47 +1194,50 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int alphaInt = (int) (tooltipAlpha * 255);
|
||||
|
||||
tooltipBackground.setAlpha(alphaInt);
|
||||
tooltipBackgroundArrow.setAlpha(alphaInt);
|
||||
tooltipPaint.setAlpha(alphaInt);
|
||||
|
||||
canvas.save();
|
||||
rectF.set(0, 0, getMeasuredWidth(), getMeasuredHeight());
|
||||
canvas.translate(getMeasuredWidth() - tooltipWidth - AndroidUtilities.dp(44), AndroidUtilities.dpf2(16));
|
||||
tooltipBackground.setBounds(
|
||||
-AndroidUtilities.dp(8), -AndroidUtilities.dp(2),
|
||||
(int) (tooltipWidth + AndroidUtilities.dp(36)), (int) (tooltipLayout.getHeight() + AndroidUtilities.dpf2(4))
|
||||
);
|
||||
tooltipBackground.draw(canvas);
|
||||
tooltipLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
if (tooltipLayout != null) {
|
||||
canvas.save();
|
||||
rectF.set(0, 0, getMeasuredWidth(), getMeasuredHeight());
|
||||
canvas.translate(getMeasuredWidth() - tooltipWidth - AndroidUtilities.dp(44), AndroidUtilities.dpf2(16));
|
||||
tooltipBackground.setBounds(
|
||||
-AndroidUtilities.dp(8), -AndroidUtilities.dp(2),
|
||||
(int) (tooltipWidth + AndroidUtilities.dp(36)), (int) (tooltipLayout.getHeight() + AndroidUtilities.dpf2(4))
|
||||
);
|
||||
tooltipBackground.draw(canvas);
|
||||
tooltipLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
|
||||
canvas.save();
|
||||
canvas.translate(cx, AndroidUtilities.dpf2(17) + tooltipLayout.getHeight() / 2f - idleProgress * AndroidUtilities.dpf2(3f));
|
||||
path.reset();
|
||||
path.setLastPoint(-AndroidUtilities.dpf2(5), AndroidUtilities.dpf2(4));
|
||||
path.lineTo(0, 0);
|
||||
path.lineTo(AndroidUtilities.dpf2(5), AndroidUtilities.dpf2(4));
|
||||
canvas.save();
|
||||
canvas.translate(cx, AndroidUtilities.dpf2(17) + tooltipLayout.getHeight() / 2f - idleProgress * AndroidUtilities.dpf2(3f));
|
||||
path.reset();
|
||||
path.setLastPoint(-AndroidUtilities.dpf2(5), AndroidUtilities.dpf2(4));
|
||||
path.lineTo(0, 0);
|
||||
path.lineTo(AndroidUtilities.dpf2(5), AndroidUtilities.dpf2(4));
|
||||
|
||||
Paint p = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
p.setColor(Color.WHITE);
|
||||
p.setAlpha(alphaInt);
|
||||
p.setStyle(Paint.Style.STROKE);
|
||||
p.setStrokeCap(Paint.Cap.ROUND);
|
||||
p.setStrokeJoin(Paint.Join.ROUND);
|
||||
p.setStrokeWidth(AndroidUtilities.dpf2(1.5f));
|
||||
canvas.drawPath(path, p);
|
||||
canvas.restore();
|
||||
Paint p = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
p.setColor(Color.WHITE);
|
||||
p.setAlpha(alphaInt);
|
||||
p.setStyle(Paint.Style.STROKE);
|
||||
p.setStrokeCap(Paint.Cap.ROUND);
|
||||
p.setStrokeJoin(Paint.Join.ROUND);
|
||||
p.setStrokeWidth(AndroidUtilities.dpf2(1.5f));
|
||||
canvas.drawPath(path, p);
|
||||
canvas.restore();
|
||||
|
||||
canvas.save();
|
||||
tooltipBackgroundArrow.setBounds(
|
||||
cx - tooltipBackgroundArrow.getIntrinsicWidth() / 2, (int) (tooltipLayout.getHeight() + AndroidUtilities.dpf2(20)),
|
||||
cx + tooltipBackgroundArrow.getIntrinsicWidth() / 2, (int) (tooltipLayout.getHeight() + AndroidUtilities.dpf2(20)) + tooltipBackgroundArrow.getIntrinsicHeight()
|
||||
);
|
||||
tooltipBackgroundArrow.draw(canvas);
|
||||
canvas.restore();
|
||||
canvas.save();
|
||||
tooltipBackgroundArrow.setBounds(
|
||||
cx - tooltipBackgroundArrow.getIntrinsicWidth() / 2, (int) (tooltipLayout.getHeight() + AndroidUtilities.dpf2(20)),
|
||||
cx + tooltipBackgroundArrow.getIntrinsicWidth() / 2, (int) (tooltipLayout.getHeight() + AndroidUtilities.dpf2(20)) + tooltipBackgroundArrow.getIntrinsicHeight()
|
||||
);
|
||||
tooltipBackgroundArrow.draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
}
|
||||
|
||||
canvas.save();
|
||||
@ -4437,9 +4440,12 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
|
||||
sendButton.setVisibility(GONE);
|
||||
cancelBotButton.setVisibility(GONE);
|
||||
setSlowModeButtonVisible(false);
|
||||
audioVideoButtonContainer.setVisibility(VISIBLE);
|
||||
runningAnimation = null;
|
||||
runningAnimationType = 0;
|
||||
|
||||
if (audioVideoButtonContainer != null) {
|
||||
audioVideoButtonContainer.setVisibility(VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -5112,7 +5118,9 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
|
||||
messageEditText.requestFocus();
|
||||
}
|
||||
recordedAudioBackground.setAlpha(1f);
|
||||
attachLayout.setTranslationX(0);
|
||||
if (attachLayout != null) {
|
||||
attachLayout.setTranslationX(0);
|
||||
}
|
||||
slideText.setCancelToProgress(0f);
|
||||
|
||||
delegate.onAudioVideoInterfaceUpdated();
|
||||
|
@ -87,6 +87,8 @@ public class UndoView extends FrameLayout {
|
||||
public final static int ACTION_QUIZ_CORRECT = 13;
|
||||
public final static int ACTION_QUIZ_INCORRECT = 14;
|
||||
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) {
|
||||
super(context);
|
||||
@ -267,6 +269,12 @@ public class UndoView extends FrameLayout {
|
||||
lastUpdateTime = SystemClock.elapsedRealtime();
|
||||
undoTextView.setText(LocaleController.getString("Undo", R.string.Undo).toUpperCase());
|
||||
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()) {
|
||||
CharSequence infoText;
|
||||
@ -328,7 +336,6 @@ public class UndoView extends FrameLayout {
|
||||
leftImageView.setAnimation(icon, size, size);
|
||||
|
||||
if (subInfoText != null) {
|
||||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) infoTextView.getLayoutParams();
|
||||
layoutParams.leftMargin = AndroidUtilities.dp(58);
|
||||
layoutParams.topMargin = AndroidUtilities.dp(6);
|
||||
layoutParams.rightMargin = 0;
|
||||
@ -339,7 +346,6 @@ public class UndoView extends FrameLayout {
|
||||
infoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||
infoTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
} else {
|
||||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) infoTextView.getLayoutParams();
|
||||
layoutParams.leftMargin = AndroidUtilities.dp(58);
|
||||
layoutParams.topMargin = AndroidUtilities.dp(13);
|
||||
layoutParams.rightMargin = 0;
|
||||
@ -359,7 +365,6 @@ public class UndoView extends FrameLayout {
|
||||
infoTextView.setText(LocaleController.getString("AuthAnotherClientOk", R.string.AuthAnotherClientOk));
|
||||
leftImageView.setAnimation(R.raw.contact_check, 36, 36);
|
||||
|
||||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) infoTextView.getLayoutParams();
|
||||
layoutParams.leftMargin = AndroidUtilities.dp(58);
|
||||
layoutParams.topMargin = AndroidUtilities.dp(6);
|
||||
subinfoTextView.setText(authorization.app_name);
|
||||
@ -381,7 +386,6 @@ public class UndoView extends FrameLayout {
|
||||
leftImageView.setAnimation(R.raw.filter_new, 36, 36);
|
||||
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.rightMargin = margin;
|
||||
layoutParams.topMargin = AndroidUtilities.dp(6);
|
||||
@ -408,13 +412,38 @@ public class UndoView extends FrameLayout {
|
||||
|
||||
leftImageView.setProgress(0);
|
||||
leftImageView.playAnimation();
|
||||
} else if (currentAction == ACTION_THEME_CHANGED) {
|
||||
TLRPC.TL_authorization authorization = (TLRPC.TL_authorization) infoObject;
|
||||
} else if (currentAction == ACTION_DICE_INFO || currentAction == ACTION_DICE_NO_SEND_INFO) {
|
||||
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));
|
||||
leftImageView.setImageResource(R.drawable.toast_pallete);
|
||||
|
||||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) infoTextView.getLayoutParams();
|
||||
layoutParams.leftMargin = AndroidUtilities.dp(58);
|
||||
layoutParams.rightMargin = AndroidUtilities.dp(48);
|
||||
layoutParams.topMargin = AndroidUtilities.dp(6);
|
||||
@ -445,7 +474,6 @@ public class UndoView extends FrameLayout {
|
||||
infoTextView.setText(LocaleController.getString("ChatsArchived", R.string.ChatsArchived));
|
||||
}
|
||||
|
||||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) infoTextView.getLayoutParams();
|
||||
layoutParams.leftMargin = AndroidUtilities.dp(58);
|
||||
layoutParams.topMargin = AndroidUtilities.dp(13);
|
||||
layoutParams.rightMargin = 0;
|
||||
@ -460,7 +488,6 @@ public class UndoView extends FrameLayout {
|
||||
leftImageView.setProgress(0);
|
||||
leftImageView.playAnimation();
|
||||
} else {
|
||||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) infoTextView.getLayoutParams();
|
||||
layoutParams.leftMargin = AndroidUtilities.dp(45);
|
||||
layoutParams.topMargin = AndroidUtilities.dp(13);
|
||||
layoutParams.rightMargin = 0;
|
||||
@ -509,7 +536,7 @@ public class UndoView extends FrameLayout {
|
||||
width = AndroidUtilities.displaySize.x;
|
||||
}
|
||||
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) {
|
||||
|
@ -1749,6 +1749,10 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
||||
if (viewPages[0].selectedType == id) {
|
||||
return;
|
||||
}
|
||||
ArrayList<MessagesController.DialogFilter> dialogFilters = getMessagesController().dialogFilters;
|
||||
if (id != Integer.MAX_VALUE && (id < 0 || id >= dialogFilters.size())) {
|
||||
return;
|
||||
}
|
||||
if (parentLayout != null) {
|
||||
parentLayout.getDrawerLayoutContainer().setAllowOpenDrawerBySwipe(id == filterTabsView.getFirstTabId());
|
||||
}
|
||||
@ -1792,9 +1796,12 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
||||
public int getTabCounter(int tabId) {
|
||||
if (tabId == Integer.MAX_VALUE) {
|
||||
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
|
||||
@ -3156,7 +3163,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
||||
} else if (actionBar != null && actionBar.isActionModeShowed()) {
|
||||
hideActionMode(true);
|
||||
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();
|
||||
return false;
|
||||
} else if (commentView != null && commentView.isPopupShowing()) {
|
||||
@ -4868,7 +4875,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
|
BIN
TMessagesProj/src/main/res/drawable-mdpi/dice.png
Normal file
BIN
TMessagesProj/src/main/res/drawable-mdpi/dice.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
BIN
TMessagesProj/src/main/res/drawable-xhdpi/dice.png
Normal file
BIN
TMessagesProj/src/main/res/drawable-xhdpi/dice.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
BIN
TMessagesProj/src/main/res/drawable-xxhdpi/dice.png
Normal file
BIN
TMessagesProj/src/main/res/drawable-xxhdpi/dice.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.9 KiB |
BIN
TMessagesProj/src/main/res/drawable/dice.png
Normal file
BIN
TMessagesProj/src/main/res/drawable/dice.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
@ -969,7 +969,8 @@
|
||||
<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="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-->
|
||||
<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>
|
||||
|
Loading…
Reference in New Issue
Block a user