1
0
mirror of https://github.com/MGislv/NekoX.git synced 2024-07-06 23:53:47 +00:00

Extra futures

This commit is contained in:
世界 2020-06-25 15:29:04 +00:00
parent 8727ccbd79
commit b0277d41de
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
21 changed files with 2109 additions and 817 deletions

View File

@ -313,7 +313,7 @@ public class ContactsController extends BaseController {
public void checkAppAccount() { public void checkAppAccount() {
AccountManager am = AccountManager.get(ApplicationLoader.applicationContext); AccountManager am = AccountManager.get(ApplicationLoader.applicationContext);
try { try {
Account[] accounts = am.getAccountsByType("tw.nekomimi.nekogram"); Account[] accounts = am.getAccountsByType(BuildConfig.APPLICATION_ID);
systemAccount = null; systemAccount = null;
for (int a = 0; a < accounts.length; a++) { for (int a = 0; a < accounts.length; a++) {
Account acc = accounts[a]; Account acc = accounts[a];
@ -321,7 +321,7 @@ public class ContactsController extends BaseController {
for (int b = 0; b < UserConfig.MAX_ACCOUNT_COUNT; b++) { for (int b = 0; b < UserConfig.MAX_ACCOUNT_COUNT; b++) {
TLRPC.User user = UserConfig.getInstance(b).getCurrentUser(); TLRPC.User user = UserConfig.getInstance(b).getCurrentUser();
if (user != null) { if (user != null) {
if (acc.name.equals("" + user.id)) { if (acc.name.equals(formatName(user.first_name, user.last_name))) {
if (b == currentAccount) { if (b == currentAccount) {
systemAccount = acc; systemAccount = acc;
} }
@ -330,26 +330,26 @@ public class ContactsController extends BaseController {
} }
} }
} }
if (!found) { if (!found || NekoConfig.disableSystemAccount) {
try { try {
am.removeAccount(accounts[a], null, null); am.removeAccount(accounts[a], null, null);
} catch (Exception ignore) { } catch (Exception ignore) {
} }
} }
} }
} catch (Throwable ignore) { } catch (Throwable e) {
FileLog.e(e);
} }
if (getUserConfig().isClientActivated()) { if (getUserConfig().isClientActivated()) {
readContacts(); readContacts();
if (systemAccount == null) { if (systemAccount == null && !NekoConfig.disableSystemAccount) {
try { try {
systemAccount = new Account("" + UserConfig.getInstance(currentAccount).getClientUserId(), "tw.nekomimi.nekogram"); TLRPC.User user = UserConfig.getInstance(currentAccount).getCurrentUser();
systemAccount = new Account(formatName(user.first_name, user.last_name), BuildConfig.APPLICATION_ID);
am.addAccountExplicitly(systemAccount, "", null); am.addAccountExplicitly(systemAccount, "", null);
} catch (Exception ignore) { } catch (Exception e) {
FileLog.e(e);
} }
} }
} }
@ -359,25 +359,33 @@ public class ContactsController extends BaseController {
try { try {
systemAccount = null; systemAccount = null;
AccountManager am = AccountManager.get(ApplicationLoader.applicationContext); AccountManager am = AccountManager.get(ApplicationLoader.applicationContext);
Account[] accounts = am.getAccountsByType("tw.nekomimi.nekogram"); Account[] accounts = am.getAccountsByType(BuildConfig.APPLICATION_ID);
for (int a = 0; a < accounts.length; a++) { for (int a = 0; a < accounts.length; a++) {
Account acc = accounts[a]; Account acc = accounts[a];
boolean found = false; if (NekoConfig.disableSystemAccount) {
for (int b = 0; b < UserConfig.MAX_ACCOUNT_COUNT; b++) {
TLRPC.User user = UserConfig.getInstance(b).getCurrentUser();
if (user != null) {
if (acc.name.equals("" + user.id)) {
found = true;
break;
}
}
}
if (!found) {
try { try {
am.removeAccount(accounts[a], null, null); am.removeAccount(accounts[a], null, null);
} catch (Exception ignore) { } catch (Exception ignore) {
} }
} else {
boolean found = false;
for (int b = 0; b < UserConfig.MAX_ACCOUNT_COUNT; b++) {
TLRPC.User user = UserConfig.getInstance(b).getCurrentUser();
if (user != null) {
if (acc.name.equals(formatName(user.first_name, user.last_name))) {
found = true;
break;
}
}
}
if (!found) {
try {
am.removeAccount(accounts[a], null, null);
} catch (Exception ignore) {
}
}
} }
} }
} catch (Exception e) { } catch (Exception e) {
@ -435,7 +443,7 @@ public class ContactsController extends BaseController {
AndroidUtilities.runOnUIThread(() -> { AndroidUtilities.runOnUIThread(() -> {
AccountManager am = AccountManager.get(ApplicationLoader.applicationContext); AccountManager am = AccountManager.get(ApplicationLoader.applicationContext);
try { try {
Account[] accounts = am.getAccountsByType("tw.nekomimi.nekogram"); Account[] accounts = am.getAccountsByType(BuildConfig.APPLICATION_ID);
systemAccount = null; systemAccount = null;
for (int a = 0; a < accounts.length; a++) { for (int a = 0; a < accounts.length; a++) {
Account acc = accounts[a]; Account acc = accounts[a];
@ -453,7 +461,7 @@ public class ContactsController extends BaseController {
} }
try { try {
systemAccount = new Account("" + UserConfig.getInstance(currentAccount).getClientUserId(), "tw.nekomimi.nekogram"); systemAccount = new Account("" + UserConfig.getInstance(currentAccount).getClientUserId(), BuildConfig.APPLICATION_ID);
am.addAccountExplicitly(systemAccount, "", null); am.addAccountExplicitly(systemAccount, "", null);
} catch (Exception ignore) { } catch (Exception ignore) {
@ -1600,7 +1608,7 @@ public class ContactsController extends BaseController {
private void saveContactsLoadTime() { private void saveContactsLoadTime() {
try { try {
SharedPreferences preferences = MessagesController.getMainSettings(currentAccount); SharedPreferences preferences = MessagesController.getMainSettings(currentAccount);
preferences.edit().putLong("lastReloadStatusTime", System.currentTimeMillis()).commit(); preferences.edit().putLong("lastReloadStatusTime", System.currentTimeMillis()).apply();
} catch (Exception e) { } catch (Exception e) {
FileLog.e(e); FileLog.e(e);
} }
@ -2246,7 +2254,7 @@ public class ContactsController extends BaseController {
getMessagesController().clearFullUsers(); getMessagesController().clearFullUsers();
SharedPreferences preferences = MessagesController.getMainSettings(currentAccount); SharedPreferences preferences = MessagesController.getMainSettings(currentAccount);
final SharedPreferences.Editor editor = preferences.edit(); final SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("needGetStatuses", true).commit(); editor.putBoolean("needGetStatuses", true).apply();
TLRPC.TL_contacts_getStatuses req = new TLRPC.TL_contacts_getStatuses(); TLRPC.TL_contacts_getStatuses req = new TLRPC.TL_contacts_getStatuses();
getConnectionsManager().sendRequest(req, (response, error) -> { getConnectionsManager().sendRequest(req, (response, error) -> {
if (error == null) { if (error == null) {

View File

@ -86,6 +86,8 @@ import java.util.Locale;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import tw.nekomimi.nekogram.NekoXConfig;
public class MediaController implements AudioManager.OnAudioFocusChangeListener, NotificationCenter.NotificationCenterDelegate, SensorEventListener { public class MediaController implements AudioManager.OnAudioFocusChangeListener, NotificationCenter.NotificationCenterDelegate, SensorEventListener {
private native int startRecord(String path, int sampleRate); private native int startRecord(String path, int sampleRate);
@ -1133,7 +1135,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
} }
} }
} }
if (send) { if (send && !NekoXConfig.disableScreenshotDetection) {
if (lastSecretChat != null) { if (lastSecretChat != null) {
SecretChatHelper.getInstance(lastChatAccount).sendScreenshotMessage(lastSecretChat, lastChatVisibleMessages, null); SecretChatHelper.getInstance(lastChatAccount).sendScreenshotMessage(lastSecretChat, lastChatVisibleMessages, null);
} else { } else {
@ -1142,6 +1144,10 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
} }
} }
public ArrayList<Long> getLastVisibleMessageIds() {
return lastChatVisibleMessages;
}
public void setLastVisibleMessageIds(int account, long enterTime, long leaveTime, TLRPC.User user, TLRPC.EncryptedChat encryptedChat, ArrayList<Long> visibleMessages, int visibleMessage) { public void setLastVisibleMessageIds(int account, long enterTime, long leaveTime, TLRPC.User user, TLRPC.EncryptedChat encryptedChat, ArrayList<Long> visibleMessages, int visibleMessage) {
lastChatEnterTime = enterTime; lastChatEnterTime = enterTime;
lastChatLeaveTime = leaveTime; lastChatLeaveTime = leaveTime;

View File

@ -55,7 +55,12 @@ import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import tw.nekomimi.nekogram.ExternalGcm;
import tw.nekomimi.nekogram.InternalFilters;
import tw.nekomimi.nekogram.NekoConfig; import tw.nekomimi.nekogram.NekoConfig;
import tw.nekomimi.nekogram.utils.AlertUtil;
import tw.nekomimi.nekogram.utils.ThreadUtil;
import tw.nekomimi.nekogram.utils.UIUtil;
public class MessagesController extends BaseController implements NotificationCenter.NotificationCenterDelegate { public class MessagesController extends BaseController implements NotificationCenter.NotificationCenterDelegate {
@ -234,6 +239,8 @@ public class MessagesController extends BaseController implements NotificationCe
private boolean loadingAppConfig; private boolean loadingAppConfig;
public int thisDc;
public boolean enableJoined; public boolean enableJoined;
public String linkPrefix; public String linkPrefix;
public int maxGroupCount; public int maxGroupCount;
@ -348,16 +355,16 @@ public class MessagesController extends BaseController implements NotificationCe
public TLRPC.SendMessageAction action; public TLRPC.SendMessageAction action;
} }
public static int DIALOG_FILTER_FLAG_CONTACTS = 0x00000001; public static int DIALOG_FILTER_FLAG_CONTACTS = 0x00000001;
public static int DIALOG_FILTER_FLAG_NON_CONTACTS = 0x00000002; public static int DIALOG_FILTER_FLAG_NON_CONTACTS = 0x00000002;
public static int DIALOG_FILTER_FLAG_GROUPS = 0x00000004; public static int DIALOG_FILTER_FLAG_GROUPS = 0x00000004;
public static int DIALOG_FILTER_FLAG_CHANNELS = 0x00000008; public static int DIALOG_FILTER_FLAG_CHANNELS = 0x00000008;
public static int DIALOG_FILTER_FLAG_BOTS = 0x00000010; public static int DIALOG_FILTER_FLAG_BOTS = 0x00000010;
public static int DIALOG_FILTER_FLAG_EXCLUDE_MUTED = 0x00000020; public static int DIALOG_FILTER_FLAG_EXCLUDE_MUTED = 0x00000020;
public static int DIALOG_FILTER_FLAG_EXCLUDE_READ = 0x00000040; public static int DIALOG_FILTER_FLAG_EXCLUDE_READ = 0x00000040;
public static int DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED = 0x00000080; public static int DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED = 0x00000080;
public static int DIALOG_FILTER_FLAG_ONLY_ARCHIVED = 0x00000100; public static int DIALOG_FILTER_FLAG_ONLY_ARCHIVED = 0x00000100;
public static int DIALOG_FILTER_FLAG_ALL_CHATS = DIALOG_FILTER_FLAG_CONTACTS | DIALOG_FILTER_FLAG_NON_CONTACTS | DIALOG_FILTER_FLAG_GROUPS | DIALOG_FILTER_FLAG_CHANNELS | DIALOG_FILTER_FLAG_BOTS; public static int DIALOG_FILTER_FLAG_ALL_CHATS = DIALOG_FILTER_FLAG_CONTACTS | DIALOG_FILTER_FLAG_NON_CONTACTS | DIALOG_FILTER_FLAG_GROUPS | DIALOG_FILTER_FLAG_CHANNELS | DIALOG_FILTER_FLAG_BOTS;
public static class DialogFilter { public static class DialogFilter {
@ -435,6 +442,7 @@ public class MessagesController extends BaseController implements NotificationCe
} }
private DialogFilter sortingDialogFilter; private DialogFilter sortingDialogFilter;
private final Comparator<TLRPC.Dialog> dialogDateComparator = (dialog1, dialog2) -> { private final Comparator<TLRPC.Dialog> dialogDateComparator = (dialog1, dialog2) -> {
int pinnedNum1 = sortingDialogFilter.pinnedDialogs.get(dialog1.id, Integer.MIN_VALUE); int pinnedNum1 = sortingDialogFilter.pinnedDialogs.get(dialog1.id, Integer.MIN_VALUE);
int pinnedNum2 = sortingDialogFilter.pinnedDialogs.get(dialog2.id, Integer.MIN_VALUE); int pinnedNum2 = sortingDialogFilter.pinnedDialogs.get(dialog2.id, Integer.MIN_VALUE);
@ -484,6 +492,82 @@ public class MessagesController extends BaseController implements NotificationCe
return 0; return 0;
} }
} }
boolean is1user = !DialogObject.isChannel(dialog1) && dialog1.id > 0;
boolean is2user = !DialogObject.isChannel(dialog2) && dialog2.id > 0;
if (NekoConfig.sortByUnread) {
if (dialog1.unread_count == 0 && dialog2.unread_count > 0) {
return 1;
} else if (dialog1.unread_count > 0 && dialog2.unread_count == 0) {
return -1;
} else if (dialog1.unread_count > 0 && dialog2.unread_count > 0) {
if (NekoConfig.sortByUnmuted) {
if (isDialogMuted(dialog1.id) && !isDialogMuted(dialog2.id)) {
return 1;
} else if (!isDialogMuted(dialog1.id) && isDialogMuted(dialog2.id)) {
return -1;
} else if (!isDialogMuted(dialog1.id) && !isDialogMuted(dialog2.id)) {
if (NekoConfig.sortByUser) {
if (!is1user && is2user) {
return 1;
} else if (is1user && !is2user) {
return -1;
} else if (is1user && is2user) {
if (NekoConfig.sortByContacts) {
boolean is1contact = is1user && getContactsController().isContact((int) dialog1.id);
boolean is2contact = is2user && getContactsController().isContact((int) dialog2.id);
if (!is1contact && is2contact) {
return 1;
} else if (is1contact && !is2contact) {
return -1;
} else {
return 0;
}
} else {
return 0;
}
}
} else {
return 0;
}
}
} else {
return 0;
}
}
} else if (NekoConfig.sortByUnmuted) {
if (dialog1.unread_count == 0 && dialog2.unread_count > 0 && isDialogMuted(dialog1.id) && !isDialogMuted(dialog2.id)) {
return 1;
} else if (dialog1.unread_count > 0 && dialog2.unread_count == 0 && !isDialogMuted(dialog1.id) && isDialogMuted(dialog2.id)) {
return -1;
} else if (dialog1.unread_count > 0 && dialog2.unread_count > 0 && !isDialogMuted(dialog1.id) && !isDialogMuted(dialog2.id)) {
if (NekoConfig.sortByUser) {
if (!is1user && is2user) {
return 1;
} else if (is1user && !is2user) {
return -1;
} else if (is1user && is2user) {
if (NekoConfig.sortByContacts) {
boolean is1contact = is1user && getContactsController().isContact((int) dialog1.id);
boolean is2contact = is2user && getContactsController().isContact((int) dialog2.id);
if (!is1contact && is2contact) {
return 1;
} else if (is1contact && !is2contact) {
return -1;
} else {
return 0;
}
} else {
return 0;
}
}
} else {
return 0;
}
}
}
final MediaDataController mediaDataController = getMediaDataController(); final MediaDataController mediaDataController = getMediaDataController();
final long date1 = DialogObject.getLastMessageOrDraftDate(dialog1, mediaDataController.getDraft(dialog1.id)); final long date1 = DialogObject.getLastMessageOrDraftDate(dialog1, mediaDataController.getDraft(dialog1.id));
final long date2 = DialogObject.getLastMessageOrDraftDate(dialog2, mediaDataController.getDraft(dialog2.id)); final long date2 = DialogObject.getLastMessageOrDraftDate(dialog2, mediaDataController.getDraft(dialog2.id));
@ -492,6 +576,7 @@ public class MessagesController extends BaseController implements NotificationCe
} else if (date1 > date2) { } else if (date1 > date2) {
return -1; return -1;
} }
return 0; return 0;
}; };
@ -517,6 +602,7 @@ public class MessagesController extends BaseController implements NotificationCe
}; };
private static volatile MessagesController[] Instance = new MessagesController[UserConfig.MAX_ACCOUNT_COUNT]; private static volatile MessagesController[] Instance = new MessagesController[UserConfig.MAX_ACCOUNT_COUNT];
public static MessagesController getInstance(int num) { public static MessagesController getInstance(int num) {
MessagesController localInstance = Instance[num]; MessagesController localInstance = Instance[num];
if (localInstance == null) { if (localInstance == null) {
@ -607,8 +693,8 @@ public class MessagesController extends BaseController implements NotificationCe
canRevokePmInbox = mainPreferences.getBoolean("canRevokePmInbox", canRevokePmInbox); canRevokePmInbox = mainPreferences.getBoolean("canRevokePmInbox", canRevokePmInbox);
preloadFeaturedStickers = mainPreferences.getBoolean("preloadFeaturedStickers", false); preloadFeaturedStickers = mainPreferences.getBoolean("preloadFeaturedStickers", false);
youtubePipType = mainPreferences.getString("youtubePipType", "disabled"); youtubePipType = mainPreferences.getString("youtubePipType", "disabled");
keepAliveService = mainPreferences.getBoolean("keepAliveService", false); keepAliveService = mainPreferences.getBoolean("keepAliveService", true);
backgroundConnection = mainPreferences.getBoolean("keepAliveService", false); backgroundConnection = mainPreferences.getBoolean("keepAliveService", true);
promoDialogId = mainPreferences.getLong("proxy_dialog", 0); promoDialogId = mainPreferences.getLong("proxy_dialog", 0);
nextPromoInfoCheckTime = mainPreferences.getInt("nextPromoInfoCheckTime", 0); nextPromoInfoCheckTime = mainPreferences.getInt("nextPromoInfoCheckTime", 0);
promoDialogType = mainPreferences.getInt("promo_dialog_type", 0); promoDialogType = mainPreferences.getInt("promo_dialog_type", 0);
@ -1038,6 +1124,8 @@ public class MessagesController extends BaseController implements NotificationCe
} }
loadingSuggestedFilters = true; loadingSuggestedFilters = true;
/*
TLRPC.TL_messages_getSuggestedDialogFilters req = new TLRPC.TL_messages_getSuggestedDialogFilters(); TLRPC.TL_messages_getSuggestedDialogFilters req = new TLRPC.TL_messages_getSuggestedDialogFilters();
getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
loadingSuggestedFilters = false; loadingSuggestedFilters = false;
@ -1050,6 +1138,27 @@ public class MessagesController extends BaseController implements NotificationCe
} }
getNotificationCenter().postNotificationName(NotificationCenter.suggestedFiltersLoaded); getNotificationCenter().postNotificationName(NotificationCenter.suggestedFiltersLoaded);
})); }));
*/
suggestedFilters.clear();
s:
for (TLRPC.TL_dialogFilterSuggested suggested : InternalFilters.internalFilters) {
for (DialogFilter filter : dialogFilters) {
if (suggested.filter.flags == filter.flags) continue s;
}
suggestedFilters.add(suggested);
}
loadingSuggestedFilters = false;
getNotificationCenter().postNotificationName(NotificationCenter.suggestedFiltersLoaded);
} }
public void loadRemoteFilters(boolean force) { public void loadRemoteFilters(boolean force) {
@ -1062,11 +1171,12 @@ public class MessagesController extends BaseController implements NotificationCe
} }
TLRPC.TL_messages_getDialogFilters req = new TLRPC.TL_messages_getDialogFilters(); TLRPC.TL_messages_getDialogFilters req = new TLRPC.TL_messages_getDialogFilters();
getConnectionsManager().sendRequest(req, (response, error) -> { getConnectionsManager().sendRequest(req, (response, error) -> {
if (response instanceof TLRPC.Vector) { if (response instanceof TLRPC.Vector) {
getMessagesStorage().checkLoadedRemoteFilters((TLRPC.Vector) response); getMessagesStorage().checkLoadedRemoteFilters((TLRPC.Vector) response);
} else {
AndroidUtilities.runOnUIThread(() -> loadingRemoteFilters = false); } else {
} AndroidUtilities.runOnUIThread(() -> loadingRemoteFilters = false);
}
}); });
} }
@ -1338,6 +1448,7 @@ public class MessagesController extends BaseController implements NotificationCe
AndroidUtilities.runOnUIThread(() -> { AndroidUtilities.runOnUIThread(() -> {
getDownloadController().loadAutoDownloadConfig(false); getDownloadController().loadAutoDownloadConfig(false);
loadAppConfig(); loadAppConfig();
thisDc = config.this_dc;
maxMegagroupCount = config.megagroup_size_max; maxMegagroupCount = config.megagroup_size_max;
maxGroupCount = config.chat_size_max; maxGroupCount = config.chat_size_max;
maxEditTime = config.edit_time_limit; maxEditTime = config.edit_time_limit;
@ -2189,7 +2300,7 @@ public class MessagesController extends BaseController implements NotificationCe
oldUser.photo = user.photo; oldUser.photo = user.photo;
oldUser.flags |= 32; oldUser.flags |= 32;
} else { } else {
oldUser.flags = oldUser.flags &~ 32; oldUser.flags = oldUser.flags & ~32;
oldUser.photo = null; oldUser.photo = null;
} }
} }
@ -2223,7 +2334,7 @@ public class MessagesController extends BaseController implements NotificationCe
user.photo = oldUser.photo; user.photo = oldUser.photo;
user.flags |= 32; user.flags |= 32;
} else { } else {
user.flags = user.flags &~ 32; user.flags = user.flags & ~32;
user.photo = null; user.photo = null;
} }
users.put(user.id, user); users.put(user.id, user);
@ -2287,7 +2398,7 @@ public class MessagesController extends BaseController implements NotificationCe
oldChat.username = chat.username; oldChat.username = chat.username;
oldChat.flags |= 64; oldChat.flags |= 64;
} else { } else {
oldChat.flags = oldChat.flags &~ 64; oldChat.flags = oldChat.flags & ~64;
oldChat.username = null; oldChat.username = null;
} }
if (chat.participants_count != 0) { if (chat.participants_count != 0) {
@ -2314,19 +2425,19 @@ public class MessagesController extends BaseController implements NotificationCe
int newFlags2 = chat.default_banned_rights != null ? chat.default_banned_rights.flags : 0; int newFlags2 = chat.default_banned_rights != null ? chat.default_banned_rights.flags : 0;
oldChat.default_banned_rights = chat.default_banned_rights; oldChat.default_banned_rights = chat.default_banned_rights;
if (oldChat.default_banned_rights == null) { if (oldChat.default_banned_rights == null) {
oldChat.flags &=~ 262144; oldChat.flags &= ~262144;
} else { } else {
oldChat.flags |= 262144; oldChat.flags |= 262144;
} }
oldChat.banned_rights = chat.banned_rights; oldChat.banned_rights = chat.banned_rights;
if (oldChat.banned_rights == null) { if (oldChat.banned_rights == null) {
oldChat.flags &=~ 32768; oldChat.flags &= ~32768;
} else { } else {
oldChat.flags |= 32768; oldChat.flags |= 32768;
} }
oldChat.admin_rights = chat.admin_rights; oldChat.admin_rights = chat.admin_rights;
if (oldChat.admin_rights == null) { if (oldChat.admin_rights == null) {
oldChat.flags &=~ 16384; oldChat.flags &= ~16384;
} else { } else {
oldChat.flags |= 16384; oldChat.flags |= 16384;
} }
@ -2361,7 +2472,7 @@ public class MessagesController extends BaseController implements NotificationCe
chat.username = oldChat.username; chat.username = oldChat.username;
chat.flags |= 64; chat.flags |= 64;
} else { } else {
chat.flags = chat.flags &~ 64; chat.flags = chat.flags & ~64;
chat.username = null; chat.username = null;
} }
if (oldChat.participants_count != 0 && chat.participants_count == 0) { if (oldChat.participants_count != 0 && chat.participants_count == 0) {
@ -2925,7 +3036,7 @@ public class MessagesController extends BaseController implements NotificationCe
SharedPreferences.Editor editor = notificationsPreferences.edit(); SharedPreferences.Editor editor = notificationsPreferences.edit();
boolean bar_hidden = !settings.report_spam && !settings.add_contact && !settings.block_contact && !settings.share_contact && !settings.report_geo; boolean bar_hidden = !settings.report_spam && !settings.add_contact && !settings.block_contact && !settings.share_contact && !settings.report_geo;
if (BuildVars.LOGS_ENABLED) { if (BuildVars.LOGS_ENABLED) {
FileLog.d("peer settings loaded for " + dialogId + " add = " + settings.add_contact + " block = " + settings.block_contact + " spam = " + settings.report_spam + " share = " + settings.share_contact + " geo = " + settings.report_geo + " hide = " + bar_hidden); FileLog.d("peer settings loaded for " + dialogId + " add = " + settings.add_contact + " block = " + settings.block_contact + " spam = " + settings.report_spam + " share = " + settings.share_contact + " geo = " + settings.report_geo + " hide = " + bar_hidden);
} }
editor.putInt("dialog_bar_vis3" + dialogId, bar_hidden ? 1 : 2); editor.putInt("dialog_bar_vis3" + dialogId, bar_hidden ? 1 : 2);
editor.putBoolean("dialog_bar_share" + dialogId, settings.share_contact); editor.putBoolean("dialog_bar_share" + dialogId, settings.share_contact);
@ -2976,7 +3087,7 @@ public class MessagesController extends BaseController implements NotificationCe
})); }));
} }
protected void processNewChannelDifferenceParams(int pts, int pts_count, int channelId) { public void processNewChannelDifferenceParams(int pts, int pts_count, int channelId) {
if (BuildVars.LOGS_ENABLED) { if (BuildVars.LOGS_ENABLED) {
FileLog.d("processNewChannelDifferenceParams pts = " + pts + " pts_count = " + pts_count + " channeldId = " + channelId); FileLog.d("processNewChannelDifferenceParams pts = " + pts + " pts_count = " + pts_count + " channeldId = " + channelId);
} }
@ -3322,7 +3433,7 @@ public class MessagesController extends BaseController implements NotificationCe
loadingBlockedUsers = true; loadingBlockedUsers = true;
TLRPC.TL_contacts_getBlocked req = new TLRPC.TL_contacts_getBlocked(); TLRPC.TL_contacts_getBlocked req = new TLRPC.TL_contacts_getBlocked();
req.offset = reset ? 0 : blockedUsers.size(); req.offset = reset ? 0 : blockedUsers.size();
req.limit = reset ? 20 : 100; req.limit = 100;
getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
if (response != null) { if (response != null) {
TLRPC.contacts_Blocked res = (TLRPC.contacts_Blocked) response; TLRPC.contacts_Blocked res = (TLRPC.contacts_Blocked) response;
@ -3343,6 +3454,38 @@ public class MessagesController extends BaseController implements NotificationCe
})); }));
} }
public void unblockAllUsers() {
if (totalBlockedCount == 0) return;
if (blockedUsers.size() == 0) getBlockedUsers(true);
SparseIntArray blockedCopy = blockedUsers.clone();
if (blockedCopy.size() == 0) return;
for (int index = 0; index < blockedCopy.size(); index++) {
TLRPC.TL_contacts_unblock req = new TLRPC.TL_contacts_unblock();
int user_id = blockedCopy.keyAt(index);
req.id = getInputUser(user_id);
getConnectionsManager().sendRequest(req, (response, error) -> {
totalBlockedCount--;
blockedUsers.delete(user_id);
UIUtil.runOnUIThread(() -> getNotificationCenter().postNotificationName(NotificationCenter.blockedUsersDidLoad));
});
ThreadUtil.sleep(233);
}
unblockAllUsers();
}
public void deleteUserPhoto(TLRPC.InputPhoto photo) { public void deleteUserPhoto(TLRPC.InputPhoto photo) {
if (photo == null) { if (photo == null) {
TLRPC.TL_photos_updateProfilePhoto req = new TLRPC.TL_photos_updateProfilePhoto(); TLRPC.TL_photos_updateProfilePhoto req = new TLRPC.TL_photos_updateProfilePhoto();
@ -4135,7 +4278,7 @@ public class MessagesController extends BaseController implements NotificationCe
} }
public void saveRecentSticker(Object parentObject, TLRPC.Document document, boolean asMask) { public void saveRecentSticker(Object parentObject, TLRPC.Document document, boolean asMask) {
if (parentObject == null || document == null) { if (document == null) {
return; return;
} }
TLRPC.TL_messages_saveRecentSticker req = new TLRPC.TL_messages_saveRecentSticker(); TLRPC.TL_messages_saveRecentSticker req = new TLRPC.TL_messages_saveRecentSticker();
@ -4226,6 +4369,7 @@ public class MessagesController extends BaseController implements NotificationCe
checkReadTasks(); checkReadTasks();
if (getUserConfig().isClientActivated() && !getUserConfig().isBot) { if (getUserConfig().isClientActivated() && !getUserConfig().isBot) {
if (getConnectionsManager().getPauseTime() == 0 && ApplicationLoader.isScreenOn && !ApplicationLoader.mainInterfacePausedStageQueue) { if (getConnectionsManager().getPauseTime() == 0 && ApplicationLoader.isScreenOn && !ApplicationLoader.mainInterfacePausedStageQueue) {
if (ApplicationLoader.mainInterfacePausedStageQueueTime != 0 && Math.abs(ApplicationLoader.mainInterfacePausedStageQueueTime - System.currentTimeMillis()) > 1000) { if (ApplicationLoader.mainInterfacePausedStageQueueTime != 0 && Math.abs(ApplicationLoader.mainInterfacePausedStageQueueTime - System.currentTimeMillis()) > 1000) {
if (statusSettingState != 1 && (lastStatusUpdateTime == 0 || Math.abs(System.currentTimeMillis() - lastStatusUpdateTime) >= 55000 || offlineSent)) { if (statusSettingState != 1 && (lastStatusUpdateTime == 0 || Math.abs(System.currentTimeMillis() - lastStatusUpdateTime) >= 55000 || offlineSent)) {
@ -4485,6 +4629,9 @@ public class MessagesController extends BaseController implements NotificationCe
AndroidUtilities.runOnUIThread(passwordCheckRunnable); AndroidUtilities.runOnUIThread(passwordCheckRunnable);
lastPasswordCheckTime = currentTime; lastPasswordCheckTime = currentTime;
} }
if (lastPushRegisterSendTime != 0 && Math.abs(SystemClock.elapsedRealtime() - lastPushRegisterSendTime) >= 3 * 60 * 60 * 1000) {
ExternalGcm.sendRegistrationToServer();
}
getLocationController().update(); getLocationController().update();
checkPromoInfoInternal(false); checkPromoInfoInternal(false);
checkTosUpdate(); checkTosUpdate();
@ -4532,12 +4679,12 @@ public class MessagesController extends BaseController implements NotificationCe
String proxyAddress = preferences.getString("proxy_ip", ""); String proxyAddress = preferences.getString("proxy_ip", "");
String proxySecret = preferences.getString("proxy_secret", ""); String proxySecret = preferences.getString("proxy_secret", "");
int removeCurrent = 0; int removeCurrent = 0;
if (promoDialogId != 0 && promoDialogType == PROMO_TYPE_PROXY && proxyDialogAddress != null && !proxyDialogAddress.equals(proxyAddress + proxySecret)) { if ((promoDialogId != 0 && promoDialogType == PROMO_TYPE_PROXY && proxyDialogAddress != null && !proxyDialogAddress.equals(proxyAddress + proxySecret))) {
removeCurrent = 1; removeCurrent = 1;
} }
lastCheckPromoId++; lastCheckPromoId++;
checkingPromoInfo = true; checkingPromoInfo = true;
int checkPromoId = lastCheckPromoId; int checkPromoId = lastCheckPromoId;
TLRPC.TL_help_getPromoData req = new TLRPC.TL_help_getPromoData(); TLRPC.TL_help_getPromoData req = new TLRPC.TL_help_getPromoData();
checkingPromoInfoRequestId = getConnectionsManager().sendRequest(req, (response, error) -> { checkingPromoInfoRequestId = getConnectionsManager().sendRequest(req, (response, error) -> {
@ -4552,204 +4699,207 @@ public class MessagesController extends BaseController implements NotificationCe
} else if (response instanceof TLRPC.TL_help_promoData) { } else if (response instanceof TLRPC.TL_help_promoData) {
final TLRPC.TL_help_promoData res = (TLRPC.TL_help_promoData) response; final TLRPC.TL_help_promoData res = (TLRPC.TL_help_promoData) response;
final long did; if (res.proxy && NekoConfig.hideProxySponsorChannel) {
if (res.peer.user_id != 0) { nextPromoInfoCheckTime = getConnectionsManager().getCurrentTime() + 60 * 60;
did = res.peer.user_id; noDialog = true;
} else if (res.peer.chat_id != 0) { } else {
did = -res.peer.chat_id;
for (int a = 0; a < res.chats.size(); a++) { final long did;
TLRPC.Chat chat = res.chats.get(a); if (res.peer.user_id != 0) {
if (chat.id == res.peer.chat_id) { did = res.peer.user_id;
if (chat.kicked || chat.restricted) { } else if (res.peer.chat_id != 0) {
noDialog = true; did = -res.peer.chat_id;
for (int a = 0; a < res.chats.size(); a++) {
TLRPC.Chat chat = res.chats.get(a);
if (chat.id == res.peer.chat_id) {
if (chat.kicked || chat.restricted) {
noDialog = true;
}
break;
}
}
} else {
did = -res.peer.channel_id;
for (int a = 0; a < res.chats.size(); a++) {
TLRPC.Chat chat = res.chats.get(a);
if (chat.id == res.peer.channel_id) {
if (chat.kicked || chat.restricted) {
noDialog = true;
}
break;
} }
break;
} }
} }
} else { promoDialogId = did;
did = -res.peer.channel_id; if (res.proxy) {
for (int a = 0; a < res.chats.size(); a++) { promoDialogType = PROMO_TYPE_PROXY;
TLRPC.Chat chat = res.chats.get(a); } else if (!TextUtils.isEmpty(res.psa_type)) {
if (chat.id == res.peer.channel_id) { promoDialogType = PROMO_TYPE_PSA;
if (chat.kicked || chat.restricted) { promoPsaType = res.psa_type;
noDialog = true; } else {
} promoDialogType = PROMO_TYPE_OTHER;
break;
}
} }
} proxyDialogAddress = proxyAddress + proxySecret;
promoDialogId = did; promoPsaMessage = res.psa_message;
if (res.proxy) { nextPromoInfoCheckTime = res.expires;
promoDialogType = PROMO_TYPE_PROXY; SharedPreferences.Editor editor = getGlobalMainSettings().edit();
if (NekoConfig.hideProxySponsorChannel) { editor.putLong("proxy_dialog", promoDialogId);
noDialog = true; editor.putString("proxyDialogAddress", proxyDialogAddress);
editor.putInt("promo_dialog_type", promoDialogType);
if (promoPsaMessage != null) {
editor.putString("promo_psa_message", promoPsaMessage);
} else {
editor.remove("promo_psa_message");
} }
} else if (!TextUtils.isEmpty(res.psa_type)) { if (promoPsaType != null) {
promoDialogType = PROMO_TYPE_PSA; editor.putString("promo_psa_type", promoPsaType);
promoPsaType = res.psa_type; } else {
} else { editor.remove("promo_psa_type");
promoDialogType = PROMO_TYPE_OTHER; }
} editor.putInt("nextPromoInfoCheckTime", nextPromoInfoCheckTime);
proxyDialogAddress = proxyAddress + proxySecret; editor.commit();
promoPsaMessage = res.psa_message;
nextPromoInfoCheckTime = res.expires;
SharedPreferences.Editor editor = getGlobalMainSettings().edit();
editor.putLong("proxy_dialog", promoDialogId);
editor.putString("proxyDialogAddress", proxyDialogAddress);
editor.putInt("promo_dialog_type", promoDialogType);
if (promoPsaMessage != null) {
editor.putString("promo_psa_message", promoPsaMessage);
} else {
editor.remove("promo_psa_message");
}
if (promoPsaType != null) {
editor.putString("promo_psa_type", promoPsaType);
} else {
editor.remove("promo_psa_type");
}
editor.putInt("nextPromoInfoCheckTime", nextPromoInfoCheckTime);
editor.commit();
if (!noDialog) { if (!noDialog) {
AndroidUtilities.runOnUIThread(() -> { AndroidUtilities.runOnUIThread(() -> {
if (promoDialog != null && did != promoDialog.id) { if (promoDialog != null && did != promoDialog.id) {
removePromoDialog(); removePromoDialog();
}
promoDialog = dialogs_dict.get(did);
if (promoDialog != null) {
checkingPromoInfo = false;
sortDialogs(null);
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, true);
} else {
final SparseArray<TLRPC.User> usersDict = new SparseArray<>();
final SparseArray<TLRPC.Chat> chatsDict = new SparseArray<>();
for (int a = 0; a < res.users.size(); a++) {
TLRPC.User u = res.users.get(a);
usersDict.put(u.id, u);
}
for (int a = 0; a < res.chats.size(); a++) {
TLRPC.Chat c = res.chats.get(a);
chatsDict.put(c.id, c);
} }
promoDialog = dialogs_dict.get(did);
TLRPC.TL_messages_getPeerDialogs req1 = new TLRPC.TL_messages_getPeerDialogs(); if (promoDialog != null) {
TLRPC.TL_inputDialogPeer peer = new TLRPC.TL_inputDialogPeer();
if (res.peer.user_id != 0) {
peer.peer = new TLRPC.TL_inputPeerUser();
peer.peer.user_id = res.peer.user_id;
TLRPC.User user = usersDict.get(res.peer.user_id);
if (user != null) {
peer.peer.access_hash = user.access_hash;
}
} else if (res.peer.chat_id != 0) {
peer.peer = new TLRPC.TL_inputPeerChat();
peer.peer.chat_id = res.peer.chat_id;
TLRPC.Chat chat = chatsDict.get(res.peer.chat_id);
if (chat != null) {
peer.peer.access_hash = chat.access_hash;
}
} else {
peer.peer = new TLRPC.TL_inputPeerChannel();
peer.peer.channel_id = res.peer.channel_id;
TLRPC.Chat chat = chatsDict.get(res.peer.channel_id);
if (chat != null) {
peer.peer.access_hash = chat.access_hash;
}
}
req1.peers.add(peer);
checkingPromoInfoRequestId = getConnectionsManager().sendRequest(req1, (response1, error1) -> {
if (checkPromoId != lastCheckPromoId) {
return;
}
checkingPromoInfoRequestId = 0;
final TLRPC.TL_messages_peerDialogs res2 = (TLRPC.TL_messages_peerDialogs) response1;
if (res2 != null && !res2.dialogs.isEmpty()) {
getMessagesStorage().putUsersAndChats(res.users, res.chats, true, true);
TLRPC.TL_messages_dialogs dialogs = new TLRPC.TL_messages_dialogs();
dialogs.chats = res2.chats;
dialogs.users = res2.users;
dialogs.dialogs = res2.dialogs;
dialogs.messages = res2.messages;
getMessagesStorage().putDialogs(dialogs, 2);
AndroidUtilities.runOnUIThread(() -> {
putUsers(res.users, false);
putChats(res.chats, false);
putUsers(res2.users, false);
putChats(res2.chats, false);
if (promoDialog != null) {
int lowerId = (int) promoDialog.id;
if (lowerId < 0) {
TLRPC.Chat chat = getChat(-lowerId);
if (ChatObject.isNotInChat(chat) || chat.restricted) {
removeDialog(promoDialog);
}
} else {
removeDialog(promoDialog);
}
}
promoDialog = res2.dialogs.get(0);
promoDialog.id = did;
promoDialog.folder_id = 0;
if (DialogObject.isChannel(promoDialog)) {
channelsPts.put(-(int) promoDialog.id, promoDialog.pts);
}
Integer value = dialogs_read_inbox_max.get(promoDialog.id);
if (value == null) {
value = 0;
}
dialogs_read_inbox_max.put(promoDialog.id, Math.max(value, promoDialog.read_inbox_max_id));
value = dialogs_read_outbox_max.get(promoDialog.id);
if (value == null) {
value = 0;
}
dialogs_read_outbox_max.put(promoDialog.id, Math.max(value, promoDialog.read_outbox_max_id));
dialogs_dict.put(did, promoDialog);
if (!res2.messages.isEmpty()) {
final SparseArray<TLRPC.User> usersDict1 = new SparseArray<>();
final SparseArray<TLRPC.Chat> chatsDict1 = new SparseArray<>();
for (int a = 0; a < res2.users.size(); a++) {
TLRPC.User u = res2.users.get(a);
usersDict1.put(u.id, u);
}
for (int a = 0; a < res2.chats.size(); a++) {
TLRPC.Chat c = res2.chats.get(a);
chatsDict1.put(c.id, c);
}
MessageObject messageObject = new MessageObject(currentAccount, res2.messages.get(0), usersDict1, chatsDict1, false);
dialogMessage.put(did, messageObject);
if (promoDialog.last_message_date == 0) {
promoDialog.last_message_date = messageObject.messageOwner.date;
}
}
sortDialogs(null);
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, true);
});
} else {
AndroidUtilities.runOnUIThread(() -> {
if (promoDialog != null) {
int lowerId = (int) promoDialog.id;
if (lowerId < 0) {
TLRPC.Chat chat = getChat(-lowerId);
if (ChatObject.isNotInChat(chat) || chat.restricted) {
removeDialog(promoDialog);
}
} else {
removeDialog(promoDialog);
}
promoDialog = null;
sortDialogs(null);
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload);
}
});
}
checkingPromoInfo = false; checkingPromoInfo = false;
}); sortDialogs(null);
} getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, true);
}); } else {
final SparseArray<TLRPC.User> usersDict = new SparseArray<>();
final SparseArray<TLRPC.Chat> chatsDict = new SparseArray<>();
for (int a = 0; a < res.users.size(); a++) {
TLRPC.User u = res.users.get(a);
usersDict.put(u.id, u);
}
for (int a = 0; a < res.chats.size(); a++) {
TLRPC.Chat c = res.chats.get(a);
chatsDict.put(c.id, c);
}
TLRPC.TL_messages_getPeerDialogs req1 = new TLRPC.TL_messages_getPeerDialogs();
TLRPC.TL_inputDialogPeer peer = new TLRPC.TL_inputDialogPeer();
if (res.peer.user_id != 0) {
peer.peer = new TLRPC.TL_inputPeerUser();
peer.peer.user_id = res.peer.user_id;
TLRPC.User user = usersDict.get(res.peer.user_id);
if (user != null) {
peer.peer.access_hash = user.access_hash;
}
} else if (res.peer.chat_id != 0) {
peer.peer = new TLRPC.TL_inputPeerChat();
peer.peer.chat_id = res.peer.chat_id;
TLRPC.Chat chat = chatsDict.get(res.peer.chat_id);
if (chat != null) {
peer.peer.access_hash = chat.access_hash;
}
} else {
peer.peer = new TLRPC.TL_inputPeerChannel();
peer.peer.channel_id = res.peer.channel_id;
TLRPC.Chat chat = chatsDict.get(res.peer.channel_id);
if (chat != null) {
peer.peer.access_hash = chat.access_hash;
}
}
req1.peers.add(peer);
checkingPromoInfoRequestId = getConnectionsManager().sendRequest(req1, (response1, error1) -> {
if (checkPromoId != lastCheckPromoId) {
return;
}
checkingPromoInfoRequestId = 0;
final TLRPC.TL_messages_peerDialogs res2 = (TLRPC.TL_messages_peerDialogs) response1;
if (res2 != null && !res2.dialogs.isEmpty()) {
getMessagesStorage().putUsersAndChats(res.users, res.chats, true, true);
TLRPC.TL_messages_dialogs dialogs = new TLRPC.TL_messages_dialogs();
dialogs.chats = res2.chats;
dialogs.users = res2.users;
dialogs.dialogs = res2.dialogs;
dialogs.messages = res2.messages;
getMessagesStorage().putDialogs(dialogs, 2);
AndroidUtilities.runOnUIThread(() -> {
putUsers(res.users, false);
putChats(res.chats, false);
putUsers(res2.users, false);
putChats(res2.chats, false);
if (promoDialog != null) {
int lowerId = (int) promoDialog.id;
if (lowerId < 0) {
TLRPC.Chat chat = getChat(-lowerId);
if (ChatObject.isNotInChat(chat) || chat.restricted) {
removeDialog(promoDialog);
}
} else {
removeDialog(promoDialog);
}
}
promoDialog = res2.dialogs.get(0);
promoDialog.id = did;
promoDialog.folder_id = 0;
if (DialogObject.isChannel(promoDialog)) {
channelsPts.put(-(int) promoDialog.id, promoDialog.pts);
}
Integer value = dialogs_read_inbox_max.get(promoDialog.id);
if (value == null) {
value = 0;
}
dialogs_read_inbox_max.put(promoDialog.id, Math.max(value, promoDialog.read_inbox_max_id));
value = dialogs_read_outbox_max.get(promoDialog.id);
if (value == null) {
value = 0;
}
dialogs_read_outbox_max.put(promoDialog.id, Math.max(value, promoDialog.read_outbox_max_id));
dialogs_dict.put(did, promoDialog);
if (!res2.messages.isEmpty()) {
final SparseArray<TLRPC.User> usersDict1 = new SparseArray<>();
final SparseArray<TLRPC.Chat> chatsDict1 = new SparseArray<>();
for (int a = 0; a < res2.users.size(); a++) {
TLRPC.User u = res2.users.get(a);
usersDict1.put(u.id, u);
}
for (int a = 0; a < res2.chats.size(); a++) {
TLRPC.Chat c = res2.chats.get(a);
chatsDict1.put(c.id, c);
}
MessageObject messageObject = new MessageObject(currentAccount, res2.messages.get(0), usersDict1, chatsDict1, false);
dialogMessage.put(did, messageObject);
if (promoDialog.last_message_date == 0) {
promoDialog.last_message_date = messageObject.messageOwner.date;
}
}
sortDialogs(null);
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, true);
});
} else {
AndroidUtilities.runOnUIThread(() -> {
if (promoDialog != null) {
int lowerId = (int) promoDialog.id;
if (lowerId < 0) {
TLRPC.Chat chat = getChat(-lowerId);
if (ChatObject.isNotInChat(chat) || chat.restricted) {
removeDialog(promoDialog);
}
} else {
removeDialog(promoDialog);
}
promoDialog = null;
sortDialogs(null);
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload);
}
});
}
checkingPromoInfo = false;
});
}
});
}
} }
} else { } else {
nextPromoInfoCheckTime = getConnectionsManager().getCurrentTime() + 60 * 60; nextPromoInfoCheckTime = getConnectionsManager().getCurrentTime() + 60 * 60;
@ -4931,6 +5081,7 @@ public class MessagesController extends BaseController implements NotificationCe
} }
public void sendTyping(final long dialog_id, final int action, int classGuid) { public void sendTyping(final long dialog_id, final int action, int classGuid) {
if (NekoConfig.disableChatAction) return;
if (dialog_id == 0) { if (dialog_id == 0) {
return; return;
} }
@ -8167,9 +8318,11 @@ public class MessagesController extends BaseController implements NotificationCe
if (ConnectionsManager.native_isTestBackend(currentAccount) != 0) { if (ConnectionsManager.native_isTestBackend(currentAccount) != 0) {
ConnectionsManager.native_switchBackend(currentAccount); ConnectionsManager.native_switchBackend(currentAccount);
} }
MessagesController.getMainSettings(currentAccount).edit().remove("custom_dc").apply();
} }
private boolean gettingAppChangelog; private boolean gettingAppChangelog;
public void generateUpdateMessage() { public void generateUpdateMessage() {
if (gettingAppChangelog || BuildVars.DEBUG_VERSION || SharedConfig.lastUpdateVersion == null || SharedConfig.lastUpdateVersion.equals(BuildVars.BUILD_VERSION_STRING)) { if (gettingAppChangelog || BuildVars.DEBUG_VERSION || SharedConfig.lastUpdateVersion == null || SharedConfig.lastUpdateVersion.equals(BuildVars.BUILD_VERSION_STRING)) {
return; return;
@ -12295,7 +12448,9 @@ public class MessagesController extends BaseController implements NotificationCe
continue; continue;
} }
sortingDialogFilter = selectedDialogFilter[b]; sortingDialogFilter = selectedDialogFilter[b];
Collections.sort(allDialogs, dialogDateComparator); Collections.sort(allDialogs, dialogDateComparator);
ArrayList<TLRPC.Dialog> dialogsByFilter = selectedDialogFilter[b].dialogs; ArrayList<TLRPC.Dialog> dialogsByFilter = selectedDialogFilter[b].dialogs;
for (int a = 0, N = allDialogs.size(); a < N; a++) { for (int a = 0, N = allDialogs.size(); a < N; a++) {
@ -12317,7 +12472,28 @@ public class MessagesController extends BaseController implements NotificationCe
} }
} }
Collections.sort(allDialogs, dialogComparator); try {
Collections.sort(allDialogs, dialogComparator);
} catch (Exception e) {
NekoConfig.sortByUnread = false;
NekoConfig.sortByUnmuted = false;
NekoConfig.sortByUser = false;
NekoConfig.sortByContacts = false;
try {
Collections.sort(allDialogs, dialogComparator);
} catch (Exception ex) {
FileLog.e(ex);
}
}
isLeftPromoChannel = true; isLeftPromoChannel = true;
if (promoDialog != null && promoDialog.id < 0) { if (promoDialog != null && promoDialog.id < 0) {
TLRPC.Chat chat = getChat(-(int) promoDialog.id); TLRPC.Chat chat = getChat(-(int) promoDialog.id);
@ -12447,14 +12623,7 @@ public class MessagesController extends BaseController implements NotificationCe
} }
private static void showCantOpenAlert(BaseFragment fragment, String reason) { private static void showCantOpenAlert(BaseFragment fragment, String reason) {
if (fragment == null || fragment.getParentActivity() == null) { AlertUtil.showToast(reason);
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(fragment.getParentActivity());
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
builder.setMessage(reason);
fragment.showDialog(builder.create());
} }
public boolean checkCanOpenChat(Bundle bundle, BaseFragment fragment) { public boolean checkCanOpenChat(Bundle bundle, BaseFragment fragment) {

View File

@ -14,6 +14,8 @@ import android.util.LongSparseArray;
import android.util.SparseArray; import android.util.SparseArray;
import android.util.SparseIntArray; import android.util.SparseIntArray;
import androidx.annotation.UiThread;
import org.telegram.PhoneFormat.PhoneFormat; import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.SQLite.SQLiteCursor; import org.telegram.SQLite.SQLiteCursor;
import org.telegram.SQLite.SQLiteDatabase; import org.telegram.SQLite.SQLiteDatabase;
@ -37,7 +39,7 @@ import java.util.Map;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import androidx.annotation.UiThread; import tw.nekomimi.nekogram.NekoConfig;
public class MessagesStorage extends BaseController { public class MessagesStorage extends BaseController {
@ -1874,6 +1876,9 @@ public class MessagesStorage extends BaseController {
continue; continue;
} }
flags = filter.flags; flags = filter.flags;
if (NekoConfig.ignoreMutedCount && (flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
flags |= MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED;
}
} else { } else {
filter = null; filter = null;
flags = MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS; flags = MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS;
@ -3897,6 +3902,9 @@ public class MessagesStorage extends BaseController {
} }
unreadCount = filter.pendingUnreadCount; unreadCount = filter.pendingUnreadCount;
flags = filter.flags; flags = filter.flags;
if (NekoConfig.ignoreMutedCount && (flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
flags |= MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED;
}
} else { } else {
filter = null; filter = null;
flags = MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS; flags = MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS;

View File

@ -89,6 +89,7 @@ public class CameraScanActivity extends BaseFragment implements Camera.PreviewCa
//private BarcodeDetector visionQrReader; //private BarcodeDetector visionQrReader;
private boolean needGalleryButton; private boolean needGalleryButton;
private boolean any;
private int currentType; private int currentType;
@ -160,6 +161,62 @@ public class CameraScanActivity extends BaseFragment implements Camera.PreviewCa
return actionBarLayout; return actionBarLayout;
} }
public static ActionBarLayout[] showAsSheet(BaseFragment parentFragment, CameraScanActivityDelegate delegate) {
if (parentFragment == null || parentFragment.getParentActivity() == null) {
return null;
}
ActionBarLayout[] actionBarLayout = new ActionBarLayout[]{new ActionBarLayout(parentFragment.getParentActivity())};
BottomSheet bottomSheet = new BottomSheet(parentFragment.getParentActivity(), false) {
{
actionBarLayout[0].init(new ArrayList<>());
CameraScanActivity fragment = new CameraScanActivity(TYPE_QR) {
@Override
public void finishFragment() {
dismiss();
}
@Override
public void removeSelfFromStack() {
dismiss();
}
};
fragment.needGalleryButton = true;
fragment.any = true;
actionBarLayout[0].addFragmentToStack(fragment);
actionBarLayout[0].showLastFragment();
actionBarLayout[0].setPadding(backgroundPaddingLeft, 0, backgroundPaddingLeft, 0);
fragment.setDelegate(delegate);
containerView = actionBarLayout[0];
setApplyBottomPadding(false);
setApplyBottomPadding(false);
setOnDismissListener(dialog -> fragment.onFragmentDestroy());
}
@Override
protected boolean canDismissWithSwipe() {
return false;
}
@Override
public void onBackPressed() {
if (actionBarLayout[0] == null || actionBarLayout[0].fragmentsStack.size() <= 1) {
super.onBackPressed();
} else {
actionBarLayout[0].onBackPressed();
}
}
@Override
public void dismiss() {
super.dismiss();
actionBarLayout[0] = null;
}
};
bottomSheet.show();
return actionBarLayout;
}
public CameraScanActivity(int type) { public CameraScanActivity(int type) {
super(); super();
CameraController.getInstance().initCamera(() -> { CameraController.getInstance().initCamera(() -> {
@ -627,6 +684,7 @@ public class CameraScanActivity extends BaseFragment implements Camera.PreviewCa
onNoQrFound(); onNoQrFound();
return null; return null;
} }
if (any) return text;
if (needGalleryButton) { if (needGalleryButton) {
if (!text.startsWith("ton://transfer/")) { if (!text.startsWith("ton://transfer/")) {
//onNoWalletFound(bitmap != null); //onNoWalletFound(bitmap != null);

View File

@ -8,9 +8,7 @@
package org.telegram.ui.Cells; package org.telegram.ui.Cells;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
@ -21,7 +19,6 @@ import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable; import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.RippleDrawable;
import android.os.Build; import android.os.Build;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.TypedValue; import android.util.TypedValue;
@ -29,23 +26,20 @@ import android.view.Gravity;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import org.telegram.PhoneFormat.PhoneFormat; import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.FileLog;
import org.telegram.messenger.ImageLocation; import org.telegram.messenger.ImageLocation;
import org.telegram.messenger.LocaleController; import org.telegram.messenger.LocaleController;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.UserObject;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.UserObject;
import org.telegram.tgnet.TLRPC; import org.telegram.tgnet.TLRPC;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.Components.AvatarDrawable; import org.telegram.ui.Components.AvatarDrawable;
import org.telegram.ui.Components.BackupImageView; import org.telegram.ui.Components.BackupImageView;
import org.telegram.ui.Components.CubicBezierInterpolator; import org.telegram.ui.Components.CubicBezierInterpolator;
import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.LayoutHelper;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.Components.SnowflakesEffect; import org.telegram.ui.Components.SnowflakesEffect;
import tw.nekomimi.nekogram.NekoConfig; import tw.nekomimi.nekogram.NekoConfig;
@ -58,7 +52,6 @@ public class DrawerProfileCell extends FrameLayout {
private TextView phoneTextView; private TextView phoneTextView;
private ImageView shadowView; private ImageView shadowView;
private ImageView arrowView; private ImageView arrowView;
private ImageView darkThemeView;
private Rect srcRect = new Rect(); private Rect srcRect = new Rect();
private Rect destRect = new Rect(); private Rect destRect = new Rect();
@ -70,6 +63,8 @@ public class DrawerProfileCell extends FrameLayout {
private boolean accountsShown; private boolean accountsShown;
private int darkThemeBackgroundColor; private int darkThemeBackgroundColor;
private TLRPC.User user;
public DrawerProfileCell(Context context) { public DrawerProfileCell(Context context) {
super(context); super(context);
@ -111,52 +106,6 @@ public class DrawerProfileCell extends FrameLayout {
addView(arrowView, LayoutHelper.createFrame(59, 59, Gravity.RIGHT | Gravity.BOTTOM)); addView(arrowView, LayoutHelper.createFrame(59, 59, Gravity.RIGHT | Gravity.BOTTOM));
setArrowState(false); setArrowState(false);
darkThemeView = new ImageView(context);
darkThemeView.setScaleType(ImageView.ScaleType.CENTER);
darkThemeView.setImageResource(R.drawable.menu_night);
darkThemeView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_menuName), PorterDuff.Mode.MULTIPLY));
if (Build.VERSION.SDK_INT >= 21) {
darkThemeView.setBackgroundDrawable(Theme.createSelectorDrawable(darkThemeBackgroundColor = Theme.getColor(Theme.key_listSelector), 1, AndroidUtilities.dp(17)));
Theme.setRippleDrawableForceSoftware((RippleDrawable) darkThemeView.getBackground());
}
darkThemeView.setOnClickListener(v -> {
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("themeconfig", Activity.MODE_PRIVATE);
String dayThemeName = preferences.getString("lastDayTheme", "Blue");
if (Theme.getTheme(dayThemeName) == null) {
dayThemeName = "Blue";
}
String nightThemeName = preferences.getString("lastDarkTheme", "Dark Blue");
if (Theme.getTheme(nightThemeName) == null) {
nightThemeName = "Dark Blue";
}
Theme.ThemeInfo themeInfo = Theme.getActiveTheme();
if (dayThemeName.equals(nightThemeName)) {
if (themeInfo.isDark()) {
dayThemeName = "Blue";
} else {
nightThemeName = "Dark Blue";
}
}
if (dayThemeName.equals(themeInfo.getKey())) {
themeInfo = Theme.getTheme(nightThemeName);
} else {
themeInfo = Theme.getTheme(dayThemeName);
}
if (Theme.selectedAutoNightType != Theme.AUTO_NIGHT_TYPE_NONE) {
Toast.makeText(getContext(), LocaleController.getString("AutoNightModeOff", R.string.AutoNightModeOff), Toast.LENGTH_SHORT).show();
Theme.selectedAutoNightType = Theme.AUTO_NIGHT_TYPE_NONE;
Theme.saveAutoNightThemeConfig();
Theme.cancelAutoNightThemeCallbacks();
}
int[] pos = new int[2];
darkThemeView.getLocationInWindow(pos);
pos[0] += darkThemeView.getMeasuredWidth() / 2;
pos[1] += darkThemeView.getMeasuredHeight() / 2;
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.needSetDayNightTheme, themeInfo, false, pos, -1);
});
addView(darkThemeView, LayoutHelper.createFrame(48, 48, Gravity.RIGHT | Gravity.BOTTOM, 0, 0, 6, 90));
if (Theme.getEventType() == 0) { if (Theme.getEventType() == 0) {
snowflakesEffect = new SnowflakesEffect(); snowflakesEffect = new SnowflakesEffect();
snowflakesEffect.setColorKey(Theme.key_chats_menuName); snowflakesEffect.setColorKey(Theme.key_chats_menuName);
@ -183,6 +132,12 @@ public class DrawerProfileCell extends FrameLayout {
} }
} }
private boolean useAdb() {
return NekoConfig.avatarAsDrawerBackground && ImageLocation.isUserHasPhoto(user);
}
@Override @Override
protected void onDraw(Canvas canvas) { protected void onDraw(Canvas canvas) {
Drawable backgroundDrawable = Theme.getCachedWallpaper(); Drawable backgroundDrawable = Theme.getCachedWallpaper();
@ -190,8 +145,7 @@ public class DrawerProfileCell extends FrameLayout {
boolean useImageBackground = !backgroundKey.equals(Theme.key_chats_menuTopBackground) && Theme.isCustomTheme() && !Theme.isPatternWallpaper() && backgroundDrawable != null && !(backgroundDrawable instanceof ColorDrawable) && !(backgroundDrawable instanceof GradientDrawable); boolean useImageBackground = !backgroundKey.equals(Theme.key_chats_menuTopBackground) && Theme.isCustomTheme() && !Theme.isPatternWallpaper() && backgroundDrawable != null && !(backgroundDrawable instanceof ColorDrawable) && !(backgroundDrawable instanceof GradientDrawable);
boolean drawCatsShadow = false; boolean drawCatsShadow = false;
int color; int color;
int darkBackColor = 0; if (!useAdb() && !useImageBackground && Theme.hasThemeKey(Theme.key_chats_menuTopShadowCats)) {
if (!NekoConfig.avatarAsDrawerBackground && !useImageBackground && Theme.hasThemeKey(Theme.key_chats_menuTopShadowCats)) {
color = Theme.getColor(Theme.key_chats_menuTopShadowCats); color = Theme.getColor(Theme.key_chats_menuTopShadowCats);
drawCatsShadow = true; drawCatsShadow = true;
} else { } else {
@ -203,15 +157,10 @@ public class DrawerProfileCell extends FrameLayout {
} }
if (currentColor == null || currentColor != color) { if (currentColor == null || currentColor != color) {
currentColor = color; currentColor = color;
shadowView.getDrawable().setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY)); shadowView.getDrawable().setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN));
}
color = Theme.getColor(Theme.key_chats_menuName);
if (currentMoonColor == null || currentColor != color) {
currentMoonColor = color;
darkThemeView.getDrawable().setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
} }
nameTextView.setTextColor(Theme.getColor(Theme.key_chats_menuName)); nameTextView.setTextColor(Theme.getColor(Theme.key_chats_menuName));
if (NekoConfig.avatarAsDrawerBackground || useImageBackground) { if (useAdb() || useImageBackground) {
phoneTextView.setTextColor(Theme.getColor(Theme.key_chats_menuPhone)); phoneTextView.setTextColor(Theme.getColor(Theme.key_chats_menuPhone));
if (shadowView.getVisibility() != VISIBLE) { if (shadowView.getVisibility() != VISIBLE) {
shadowView.setVisibility(VISIBLE); shadowView.setVisibility(VISIBLE);
@ -219,7 +168,6 @@ public class DrawerProfileCell extends FrameLayout {
if (backgroundDrawable instanceof ColorDrawable || backgroundDrawable instanceof GradientDrawable) { if (backgroundDrawable instanceof ColorDrawable || backgroundDrawable instanceof GradientDrawable) {
backgroundDrawable.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight()); backgroundDrawable.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight());
backgroundDrawable.draw(canvas); backgroundDrawable.draw(canvas);
darkBackColor = Theme.getColor(Theme.key_listSelector);
} else if (backgroundDrawable instanceof BitmapDrawable) { } else if (backgroundDrawable instanceof BitmapDrawable) {
Bitmap bitmap = ((BitmapDrawable) backgroundDrawable).getBitmap(); Bitmap bitmap = ((BitmapDrawable) backgroundDrawable).getBitmap();
float scaleX = (float) getMeasuredWidth() / (float) bitmap.getWidth(); float scaleX = (float) getMeasuredWidth() / (float) bitmap.getWidth();
@ -236,7 +184,6 @@ public class DrawerProfileCell extends FrameLayout {
} catch (Throwable e) { } catch (Throwable e) {
FileLog.e(e); FileLog.e(e);
} }
darkBackColor = (Theme.getServiceMessageColor() & 0x00ffffff) | 0x50000000;
} }
} else { } else {
int visibility = drawCatsShadow? VISIBLE : INVISIBLE; int visibility = drawCatsShadow? VISIBLE : INVISIBLE;
@ -245,19 +192,6 @@ public class DrawerProfileCell extends FrameLayout {
} }
phoneTextView.setTextColor(Theme.getColor(Theme.key_chats_menuPhoneCats)); phoneTextView.setTextColor(Theme.getColor(Theme.key_chats_menuPhoneCats));
super.onDraw(canvas); super.onDraw(canvas);
darkBackColor = Theme.getColor(Theme.key_listSelector);
}
if (darkBackColor != 0) {
if (darkBackColor != darkThemeBackgroundColor) {
backPaint.setColor(darkThemeBackgroundColor = darkBackColor);
if (Build.VERSION.SDK_INT >= 21) {
Theme.setSelectorDrawableColor(darkThemeView.getBackground(), darkThemeBackgroundColor = darkBackColor, true);
}
}
if (useImageBackground && backgroundDrawable instanceof BitmapDrawable) {
canvas.drawCircle(darkThemeView.getX() + darkThemeView.getMeasuredWidth() / 2, darkThemeView.getY() + darkThemeView.getMeasuredHeight() / 2, AndroidUtilities.dp(17), backPaint);
}
} }
if (snowflakesEffect != null) { if (snowflakesEffect != null) {
@ -281,6 +215,7 @@ public class DrawerProfileCell extends FrameLayout {
if (user == null) { if (user == null) {
return; return;
} }
this.user = user;
accountsShown = accounts; accountsShown = accounts;
setArrowState(false); setArrowState(false);
nameTextView.setText(UserObject.getUserName(user)); nameTextView.setText(UserObject.getUserName(user));
@ -294,7 +229,7 @@ public class DrawerProfileCell extends FrameLayout {
AvatarDrawable avatarDrawable = new AvatarDrawable(user); AvatarDrawable avatarDrawable = new AvatarDrawable(user);
avatarDrawable.setColor(Theme.getColor(Theme.key_avatar_backgroundInProfileBlue)); avatarDrawable.setColor(Theme.getColor(Theme.key_avatar_backgroundInProfileBlue));
avatarImageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user); avatarImageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user);
if (NekoConfig.avatarAsDrawerBackground) { if (useAdb()) {
avatarBackgroundView.setImage(ImageLocation.getForUser(user, true), "512_512", avatarDrawable, user); avatarBackgroundView.setImage(ImageLocation.getForUser(user, true), "512_512", avatarDrawable, user);
avatarBackgroundView.setVisibility(VISIBLE); avatarBackgroundView.setVisibility(VISIBLE);
avatarImageView.setVisibility(INVISIBLE); avatarImageView.setVisibility(INVISIBLE);

View File

@ -116,6 +116,10 @@ import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.HashMap; import java.util.HashMap;
import tw.nekomimi.nekogram.NekoConfig;
import tw.nekomimi.nekogram.NekoXConfig;
import tw.nekomimi.nekogram.utils.AlertUtil;
public class ChannelAdminLogActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate { public class ChannelAdminLogActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
protected TLRPC.Chat currentChat; protected TLRPC.Chat currentChat;
@ -891,7 +895,7 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
bottomOverlayImage = new ImageView(context); bottomOverlayImage = new ImageView(context);
bottomOverlayImage.setImageResource(R.drawable.log_info); bottomOverlayImage.setImageResource(R.drawable.log_info);
bottomOverlayImage.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_fieldOverlayText), PorterDuff.Mode.MULTIPLY)); bottomOverlayImage.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_fieldOverlayText), PorterDuff.Mode.SRC_IN));
bottomOverlayImage.setScaleType(ImageView.ScaleType.CENTER); bottomOverlayImage.setScaleType(ImageView.ScaleType.CENTER);
bottomOverlayChat.addView(bottomOverlayImage, LayoutHelper.createFrame(48, 48, Gravity.RIGHT | Gravity.TOP, 3, 0, 0, 0)); bottomOverlayChat.addView(bottomOverlayImage, LayoutHelper.createFrame(48, 48, Gravity.RIGHT | Gravity.TOP, 3, 0, 0, 0));
bottomOverlayImage.setContentDescription(LocaleController.getString("BotHelp", R.string.BotHelp)); bottomOverlayImage.setContentDescription(LocaleController.getString("BotHelp", R.string.BotHelp));
@ -927,7 +931,7 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
/*searchUpButton = new ImageView(context); /*searchUpButton = new ImageView(context);
searchUpButton.setScaleType(ImageView.ScaleType.CENTER); searchUpButton.setScaleType(ImageView.ScaleType.CENTER);
searchUpButton.setImageResource(R.drawable.msg_go_up); searchUpButton.setImageResource(R.drawable.msg_go_up);
searchUpButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_searchPanelIcons), PorterDuff.Mode.MULTIPLY)); searchUpButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_searchPanelIcons), PorterDuff.Mode.SRC_IN));
searchContainer.addView(searchUpButton, LayoutHelper.createFrame(48, 48)); searchContainer.addView(searchUpButton, LayoutHelper.createFrame(48, 48));
searchUpButton.setOnClickListener(new View.OnClickListener() { searchUpButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -939,7 +943,7 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
searchDownButton = new ImageView(context); searchDownButton = new ImageView(context);
searchDownButton.setScaleType(ImageView.ScaleType.CENTER); searchDownButton.setScaleType(ImageView.ScaleType.CENTER);
searchDownButton.setImageResource(R.drawable.msg_go_down); searchDownButton.setImageResource(R.drawable.msg_go_down);
searchDownButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_searchPanelIcons), PorterDuff.Mode.MULTIPLY)); searchDownButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_searchPanelIcons), PorterDuff.Mode.SRC_IN));
searchContainer.addView(searchDownButton, LayoutHelper.createFrame(48, 48, Gravity.LEFT | Gravity.TOP, 48, 0, 0, 0)); searchContainer.addView(searchDownButton, LayoutHelper.createFrame(48, 48, Gravity.LEFT | Gravity.TOP, 48, 0, 0, 0));
searchDownButton.setOnClickListener(new View.OnClickListener() { searchDownButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -950,8 +954,8 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
searchCalendarButton = new ImageView(context); searchCalendarButton = new ImageView(context);
searchCalendarButton.setScaleType(ImageView.ScaleType.CENTER); searchCalendarButton.setScaleType(ImageView.ScaleType.CENTER);
searchCalendarButton.setImageResource(R.drawable.msg_calendar); searchCalendarButton.setImageResource(R.drawable.baseline_date_range_24);
searchCalendarButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_searchPanelIcons), PorterDuff.Mode.MULTIPLY)); searchCalendarButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_searchPanelIcons), PorterDuff.Mode.SRC_IN));
searchContainer.addView(searchCalendarButton, LayoutHelper.createFrame(48, 48, Gravity.RIGHT | Gravity.TOP)); searchContainer.addView(searchCalendarButton, LayoutHelper.createFrame(48, 48, Gravity.RIGHT | Gravity.TOP));
searchCalendarButton.setOnClickListener(view -> { searchCalendarButton.setOnClickListener(view -> {
if (getParentActivity() == null) { if (getParentActivity() == null) {
@ -1320,11 +1324,7 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
selectedObject = null; selectedObject = null;
return; return;
} }
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); AlertUtil.showToast(LocaleController.getString("IncorrectTheme", R.string.IncorrectTheme));
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
builder.setMessage(LocaleController.getString("IncorrectTheme", R.string.IncorrectTheme));
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
showDialog(builder.create());
} }
} else { } else {
if (LocaleController.getInstance().applyLanguageFile(locFile, currentAccount)) { if (LocaleController.getInstance().applyLanguageFile(locFile, currentAccount)) {
@ -1334,11 +1334,7 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
selectedObject = null; selectedObject = null;
return; return;
} }
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); AlertUtil.showToast(LocaleController.getString("IncorrectLocalization", R.string.IncorrectLocalization));
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
builder.setMessage(LocaleController.getString("IncorrectLocalization", R.string.IncorrectLocalization));
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
showDialog(builder.create());
} }
} }
} }
@ -1836,7 +1832,7 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
} }
public void showOpenUrlAlert(final String url, boolean ask) { public void showOpenUrlAlert(final String url, boolean ask) {
if (Browser.isInternalUrl(url, null) || !ask) { if (Browser.isInternalUrl(url, null) || !ask || NekoConfig.skipOpenLinkConfirm) {
Browser.openUrl(getParentActivity(), url, true); Browser.openUrl(getParentActivity(), url, true);
} else { } else {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());

View File

@ -54,6 +54,8 @@ import org.telegram.ui.Components.LayoutHelper;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import tw.nekomimi.nekogram.utils.ProxyUtil;
public class ChatEditTypeActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate { public class ChatEditTypeActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
private EditTextBoldCursor usernameTextView; private EditTextBoldCursor usernameTextView;
@ -76,6 +78,7 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
private TextSettingsCell copyCell; private TextSettingsCell copyCell;
private TextSettingsCell revokeCell; private TextSettingsCell revokeCell;
private TextSettingsCell shareCell; private TextSettingsCell shareCell;
private TextSettingsCell shareQRCell;
private ShadowSectionCell sectionCell2; private ShadowSectionCell sectionCell2;
private TextInfoPrivacyCell infoCell; private TextInfoPrivacyCell infoCell;
private TextSettingsCell textCell; private TextSettingsCell textCell;
@ -234,9 +237,9 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
radioButtonCell2 = new RadioButtonCell(context); radioButtonCell2 = new RadioButtonCell(context);
radioButtonCell2.setBackgroundDrawable(Theme.getSelectorDrawable(false)); radioButtonCell2.setBackgroundDrawable(Theme.getSelectorDrawable(false));
if (isChannel) { if (isChannel) {
radioButtonCell2.setTextAndValue(LocaleController.getString("ChannelPrivate", R.string.ChannelPrivate), LocaleController.getString("ChannelPrivateInfo", R.string.ChannelPrivateInfo), false, isPrivate); radioButtonCell2.setTextAndValueAndCheck(LocaleController.getString("ChannelPrivate", R.string.ChannelPrivate), LocaleController.getString("ChannelPrivateInfo", R.string.ChannelPrivateInfo), false, isPrivate);
} else { } else {
radioButtonCell2.setTextAndValue(LocaleController.getString("MegaPrivate", R.string.MegaPrivate), LocaleController.getString("MegaPrivateInfo", R.string.MegaPrivateInfo), false, isPrivate); radioButtonCell2.setTextAndValueAndCheck(LocaleController.getString("MegaPrivate", R.string.MegaPrivate), LocaleController.getString("MegaPrivateInfo", R.string.MegaPrivateInfo), false, isPrivate);
} }
linearLayoutTypeContainer.addView(radioButtonCell2, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); linearLayoutTypeContainer.addView(radioButtonCell2, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
radioButtonCell2.setOnClickListener(v -> { radioButtonCell2.setOnClickListener(v -> {
@ -250,9 +253,9 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
radioButtonCell1 = new RadioButtonCell(context); radioButtonCell1 = new RadioButtonCell(context);
radioButtonCell1.setBackgroundDrawable(Theme.getSelectorDrawable(false)); radioButtonCell1.setBackgroundDrawable(Theme.getSelectorDrawable(false));
if (isChannel) { if (isChannel) {
radioButtonCell1.setTextAndValue(LocaleController.getString("ChannelPublic", R.string.ChannelPublic), LocaleController.getString("ChannelPublicInfo", R.string.ChannelPublicInfo), false, !isPrivate); radioButtonCell1.setTextAndValueAndCheck(LocaleController.getString("ChannelPublic", R.string.ChannelPublic), LocaleController.getString("ChannelPublicInfo", R.string.ChannelPublicInfo), false, !isPrivate);
} else { } else {
radioButtonCell1.setTextAndValue(LocaleController.getString("MegaPublic", R.string.MegaPublic), LocaleController.getString("MegaPublicInfo", R.string.MegaPublicInfo), false, !isPrivate); radioButtonCell1.setTextAndValueAndCheck(LocaleController.getString("MegaPublic", R.string.MegaPublic), LocaleController.getString("MegaPublicInfo", R.string.MegaPublicInfo), false, !isPrivate);
} }
linearLayoutTypeContainer.addView(radioButtonCell1, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); linearLayoutTypeContainer.addView(radioButtonCell1, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
radioButtonCell1.setOnClickListener(v -> { radioButtonCell1.setOnClickListener(v -> {
@ -406,6 +409,17 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
} }
}); });
shareQRCell = new TextSettingsCell(context);
shareQRCell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
shareQRCell.setText(LocaleController.getString("ShareQRCode", R.string.ShareQRCode), false);
privateContainer.addView(shareQRCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
shareQRCell.setOnClickListener(v -> {
if (invite == null) {
return;
}
ProxyUtil.showQrDialog(getParentActivity(),invite.link);
});
checkTextView = new TextInfoPrivacyCell(context); checkTextView = new TextInfoPrivacyCell(context);
checkTextView.setBackgroundDrawable(Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow)); checkTextView.setBackgroundDrawable(Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
checkTextView.setBottomPadding(6); checkTextView.setBottomPadding(6);

View File

@ -15,8 +15,10 @@ import android.animation.ObjectAnimator;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.graphics.*; import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build; import android.os.Build;
import android.text.Selection; import android.text.Selection;
@ -34,15 +36,18 @@ import android.widget.FrameLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.MediaDataController;
import org.telegram.messenger.Emoji; import org.telegram.messenger.Emoji;
import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.messenger.FileRefController; import org.telegram.messenger.FileRefController;
import org.telegram.messenger.ImageLocation; import org.telegram.messenger.ImageLocation;
import org.telegram.messenger.LocaleController; import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MediaDataController;
import org.telegram.messenger.MessagesController; import org.telegram.messenger.MessagesController;
import org.telegram.messenger.NotificationCenter; import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.R; import org.telegram.messenger.R;
@ -66,8 +71,7 @@ import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import androidx.recyclerview.widget.GridLayoutManager; import tw.nekomimi.nekogram.utils.ProxyUtil;
import androidx.recyclerview.widget.RecyclerView;
public class StickersAlert extends BottomSheet implements NotificationCenter.NotificationCenterDelegate { public class StickersAlert extends BottomSheet implements NotificationCenter.NotificationCenterDelegate {
@ -118,6 +122,8 @@ public class StickersAlert extends BottomSheet implements NotificationCenter.Not
private Activity parentActivity; private Activity parentActivity;
private int itemSize; private int itemSize;
private int menu_archive = 4;
private TLRPC.TL_messages_stickerSet stickerSet; private TLRPC.TL_messages_stickerSet stickerSet;
private TLRPC.Document selectedSticker; private TLRPC.Document selectedSticker;
private TLRPC.InputStickerSet inputStickerSet; private TLRPC.InputStickerSet inputStickerSet;
@ -569,8 +575,11 @@ public class StickersAlert extends BottomSheet implements NotificationCenter.Not
optionsButton.setIcon(R.drawable.ic_ab_other); optionsButton.setIcon(R.drawable.ic_ab_other);
optionsButton.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_player_actionBarSelector), 1)); optionsButton.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_player_actionBarSelector), 1));
containerView.addView(optionsButton, LayoutHelper.createFrame(40, 40, Gravity.TOP | Gravity.RIGHT, 0, 5, 5, 0)); containerView.addView(optionsButton, LayoutHelper.createFrame(40, 40, Gravity.TOP | Gravity.RIGHT, 0, 5, 5, 0));
optionsButton.addSubItem(1, R.drawable.msg_share, LocaleController.getString("StickersShare", R.string.StickersShare)); optionsButton.addSubItem(1, R.drawable.baseline_forward_24, LocaleController.getString("StickersShare", R.string.StickersShare));
optionsButton.addSubItem(2, R.drawable.msg_link, LocaleController.getString("CopyLink", R.string.CopyLink)); optionsButton.addSubItem(2, R.drawable.baseline_link_24, LocaleController.getString("CopyLink", R.string.CopyLink));
optionsButton.addSubItem(3, R.drawable.wallet_qr, LocaleController.getString("ShareQRCode", R.string.ShareQRCode));
optionsButton.addSubItem(menu_archive, R.drawable.baseline_archive_24, LocaleController.getString("Archive", R.string.Archive));
optionsButton.setOnClickListener(v -> optionsButton.toggleSubMenu()); optionsButton.setOnClickListener(v -> optionsButton.toggleSubMenu());
optionsButton.setDelegate(this::onSubItemClick); optionsButton.setDelegate(this::onSubItemClick);
optionsButton.setContentDescription(LocaleController.getString("AccDescrMoreOptions", R.string.AccDescrMoreOptions)); optionsButton.setContentDescription(LocaleController.getString("AccDescrMoreOptions", R.string.AccDescrMoreOptions));
@ -677,6 +686,11 @@ public class StickersAlert extends BottomSheet implements NotificationCenter.Not
} catch (Exception e) { } catch (Exception e) {
FileLog.e(e); FileLog.e(e);
} }
} else if (id == 3) {
ProxyUtil.showQrDialog(getContext(), stickersUrl);
} else if (id == menu_archive) {
dismiss();
MediaDataController.getInstance(currentAccount).toggleStickerSet(parentActivity, stickerSet, 1, parentFragment, false, true);
} }
} }
@ -684,7 +698,8 @@ public class StickersAlert extends BottomSheet implements NotificationCenter.Not
if (titleTextView == null) { if (titleTextView == null) {
return; return;
} }
if (stickerSet != null) { if (stickerSet != null && stickerSet.set != null) {
SpannableStringBuilder stringBuilder = null; SpannableStringBuilder stringBuilder = null;
try { try {
if (urlPattern == null) { if (urlPattern == null) {
@ -717,7 +732,8 @@ public class StickersAlert extends BottomSheet implements NotificationCenter.Not
} }
titleTextView.setText(stringBuilder != null ? stringBuilder : stickerSet.set.title); titleTextView.setText(stringBuilder != null ? stringBuilder : stickerSet.set.title);
if (stickerSet.set == null || !MediaDataController.getInstance(currentAccount).isStickerPackInstalled(stickerSet.set.id)) { if (!MediaDataController.getInstance(currentAccount).isStickerPackInstalled(stickerSet.set.id)) {
optionsButton.hideSubItem(menu_archive);
String text; String text;
if (stickerSet.set.masks) { if (stickerSet.set.masks) {
text = LocaleController.formatString("AddStickersCount", R.string.AddStickersCount, LocaleController.formatPluralString("MasksCount", stickerSet.documents.size())).toUpperCase(); text = LocaleController.formatString("AddStickersCount", R.string.AddStickersCount, LocaleController.formatPluralString("MasksCount", stickerSet.documents.size())).toUpperCase();
@ -754,6 +770,7 @@ public class StickersAlert extends BottomSheet implements NotificationCenter.Not
})); }));
}, text, Theme.key_dialogTextBlue2); }, text, Theme.key_dialogTextBlue2);
} else { } else {
optionsButton.showSubItem(menu_archive);
String text; String text;
if (stickerSet.set.masks) { if (stickerSet.set.masks) {
text = LocaleController.formatString("RemoveStickersCount", R.string.RemoveStickersCount, LocaleController.formatPluralString("MasksCount", stickerSet.documents.size())).toUpperCase(); text = LocaleController.formatString("RemoveStickersCount", R.string.RemoveStickersCount, LocaleController.formatPluralString("MasksCount", stickerSet.documents.size())).toUpperCase();

View File

@ -43,6 +43,8 @@ import org.telegram.messenger.UserObject;
import org.telegram.tgnet.TLRPC; import org.telegram.tgnet.TLRPC;
import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.ActionBar.Theme;
import tw.nekomimi.nekogram.NekoConfig;
@SuppressWarnings("FieldCanBeLocal") @SuppressWarnings("FieldCanBeLocal")
public class UndoView extends FrameLayout { public class UndoView extends FrameLayout {
@ -184,7 +186,7 @@ public class UndoView extends FrameLayout {
undoImageView = new ImageView(context); undoImageView = new ImageView(context);
undoImageView.setImageResource(R.drawable.chats_undo); undoImageView.setImageResource(R.drawable.chats_undo);
undoImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_undo_cancelColor), PorterDuff.Mode.MULTIPLY)); undoImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_undo_cancelColor), PorterDuff.Mode.SRC_IN));
undoButton.addView(undoImageView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL | Gravity.LEFT)); undoButton.addView(undoImageView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL | Gravity.LEFT));
undoTextView = new TextView(context); undoTextView = new TextView(context);
@ -313,6 +315,10 @@ public class UndoView extends FrameLayout {
if (currentActionRunnable != null) { if (currentActionRunnable != null) {
currentActionRunnable.run(); currentActionRunnable.run();
} }
if (NekoConfig.disableUndo && action < ACTION_QUIZ_CORRECT) {
if (actionRunnable != null) actionRunnable.run();
return;
}
isShown = true; isShown = true;
currentActionRunnable = actionRunnable; currentActionRunnable = actionRunnable;
currentCancelRunnable = cancelRunnable; currentCancelRunnable = cancelRunnable;

View File

@ -39,14 +39,6 @@ import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Vibrator; import android.os.Vibrator;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.LinearSmoothScrollerCustom;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager.widget.ViewPager;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Property; import android.util.Property;
import android.util.StateSet; import android.util.StateSet;
@ -71,41 +63,54 @@ import android.widget.LinearLayout;
import android.widget.ScrollView; import android.widget.ScrollView;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.LinearSmoothScrollerCustom;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager.widget.ViewPager;
import org.telegram.messenger.AccountInstance; import org.telegram.messenger.AccountInstance;
import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.BuildVars;
import org.telegram.messenger.ChatObject; import org.telegram.messenger.ChatObject;
import org.telegram.messenger.MediaDataController; import org.telegram.messenger.ContactsController;
import org.telegram.messenger.DialogObject; import org.telegram.messenger.DialogObject;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.ImageLoader; import org.telegram.messenger.ImageLoader;
import org.telegram.messenger.ImageLocation; import org.telegram.messenger.ImageLocation;
import org.telegram.messenger.LocaleController; import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MediaDataController;
import org.telegram.messenger.MessageObject; import org.telegram.messenger.MessageObject;
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.NotificationsController; import org.telegram.messenger.NotificationsController;
import org.telegram.messenger.R;
import org.telegram.messenger.SharedConfig; import org.telegram.messenger.SharedConfig;
import org.telegram.messenger.UserConfig;
import org.telegram.messenger.UserObject; import org.telegram.messenger.UserObject;
import org.telegram.messenger.Utilities; import org.telegram.messenger.Utilities;
import org.telegram.messenger.XiaomiUtilities; import org.telegram.messenger.XiaomiUtilities;
import org.telegram.messenger.FileLog;
import org.telegram.tgnet.ConnectionsManager; import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.TLObject; import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC; import org.telegram.tgnet.TLRPC;
import org.telegram.messenger.ContactsController; import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.messenger.MessagesController; import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.messenger.NotificationCenter; import org.telegram.ui.ActionBar.ActionBarMenuItem;
import org.telegram.messenger.R;
import org.telegram.messenger.UserConfig;
import org.telegram.ui.ActionBar.ActionBarMenuSubItem; import org.telegram.ui.ActionBar.ActionBarMenuSubItem;
import org.telegram.ui.ActionBar.ActionBarPopupWindow; import org.telegram.ui.ActionBar.ActionBarPopupWindow;
import org.telegram.ui.ActionBar.AlertDialog; import org.telegram.ui.ActionBar.AlertDialog;
import org.telegram.ui.ActionBar.BackDrawable; import org.telegram.ui.ActionBar.BackDrawable;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.ActionBar.BottomSheet; import org.telegram.ui.ActionBar.BottomSheet;
import org.telegram.ui.ActionBar.MenuDrawable;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.ActionBar.ThemeDescription; import org.telegram.ui.ActionBar.ThemeDescription;
import org.telegram.ui.Adapters.DialogsAdapter; import org.telegram.ui.Adapters.DialogsAdapter;
import org.telegram.ui.Adapters.DialogsSearchAdapter; import org.telegram.ui.Adapters.DialogsSearchAdapter;
import org.telegram.ui.Cells.AccountSelectCell; import org.telegram.ui.Cells.AccountSelectCell;
import org.telegram.ui.Cells.ArchiveHintInnerCell; import org.telegram.ui.Cells.ArchiveHintInnerCell;
import org.telegram.ui.Cells.DialogCell;
import org.telegram.ui.Cells.DialogsEmptyCell; import org.telegram.ui.Cells.DialogsEmptyCell;
import org.telegram.ui.Cells.DividerCell; import org.telegram.ui.Cells.DividerCell;
import org.telegram.ui.Cells.DrawerActionCell; import org.telegram.ui.Cells.DrawerActionCell;
@ -120,36 +125,29 @@ import org.telegram.ui.Cells.ProfileSearchCell;
import org.telegram.ui.Cells.ShadowSectionCell; import org.telegram.ui.Cells.ShadowSectionCell;
import org.telegram.ui.Cells.TextCell; import org.telegram.ui.Cells.TextCell;
import org.telegram.ui.Cells.UserCell; import org.telegram.ui.Cells.UserCell;
import org.telegram.ui.Cells.DialogCell;
import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.ActionBar.ActionBarMenuItem;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.ActionBar.MenuDrawable;
import org.telegram.ui.Components.AlertsCreator; import org.telegram.ui.Components.AlertsCreator;
import org.telegram.ui.Components.AnimatedArrowDrawable; import org.telegram.ui.Components.AnimatedArrowDrawable;
import org.telegram.ui.Components.AnimationProperties; import org.telegram.ui.Components.AnimationProperties;
import org.telegram.ui.Components.FilterTabsView;
import org.telegram.ui.Components.FiltersListBottomSheet;
import org.telegram.ui.Components.PullForegroundDrawable;
import org.telegram.ui.Components.AvatarDrawable; import org.telegram.ui.Components.AvatarDrawable;
import org.telegram.ui.Components.BackupImageView; import org.telegram.ui.Components.BackupImageView;
import org.telegram.ui.Components.ChatActivityEnterView; import org.telegram.ui.Components.ChatActivityEnterView;
import org.telegram.ui.Components.CombinedDrawable; import org.telegram.ui.Components.CombinedDrawable;
import org.telegram.ui.Components.CubicBezierInterpolator; import org.telegram.ui.Components.CubicBezierInterpolator;
import org.telegram.ui.Components.DialogsItemAnimator; import org.telegram.ui.Components.DialogsItemAnimator;
import org.telegram.ui.Components.FragmentContextView;
import org.telegram.ui.Components.EmptyTextProgressView; import org.telegram.ui.Components.EmptyTextProgressView;
import org.telegram.ui.Components.FilterTabsView;
import org.telegram.ui.Components.FiltersListBottomSheet;
import org.telegram.ui.Components.FragmentContextView;
import org.telegram.ui.Components.JoinGroupAlert; import org.telegram.ui.Components.JoinGroupAlert;
import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.LayoutHelper;
import org.telegram.ui.Components.NumberTextView; import org.telegram.ui.Components.NumberTextView;
import org.telegram.ui.Components.PacmanAnimation; import org.telegram.ui.Components.PacmanAnimation;
import org.telegram.ui.Components.ProxyDrawable; import org.telegram.ui.Components.ProxyDrawable;
import org.telegram.ui.Components.PullForegroundDrawable;
import org.telegram.ui.Components.RLottieDrawable; import org.telegram.ui.Components.RLottieDrawable;
import org.telegram.ui.Components.RadialProgressView; import org.telegram.ui.Components.RadialProgressView;
import org.telegram.ui.Components.RecyclerAnimationScrollHelper; import org.telegram.ui.Components.RecyclerAnimationScrollHelper;
import org.telegram.ui.Components.RecyclerListView; import org.telegram.ui.Components.RecyclerListView;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.Components.SizeNotifierFrameLayout; import org.telegram.ui.Components.SizeNotifierFrameLayout;
import org.telegram.ui.Components.StickersAlert; import org.telegram.ui.Components.StickersAlert;
import org.telegram.ui.Components.UndoView; import org.telegram.ui.Components.UndoView;
@ -157,6 +155,8 @@ import org.telegram.ui.Components.UndoView;
import java.util.ArrayList; import java.util.ArrayList;
import tw.nekomimi.nekogram.NekoConfig; import tw.nekomimi.nekogram.NekoConfig;
import tw.nekomimi.nekogram.utils.PrivacyUtil;
import tw.nekomimi.nekogram.utils.ProxyUtil;
public class DialogsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate { public class DialogsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
@ -193,6 +193,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
private boolean passcodeItemVisible; private boolean passcodeItemVisible;
private ActionBarMenuItem proxyItem; private ActionBarMenuItem proxyItem;
private boolean proxyItemVisible; private boolean proxyItemVisible;
private ActionBarMenuItem scanItem;
private ActionBarMenuItem searchItem; private ActionBarMenuItem searchItem;
private ActionBarMenuItem doneItem; private ActionBarMenuItem doneItem;
private ProxyDrawable proxyDrawable; private ProxyDrawable proxyDrawable;
@ -667,7 +668,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
@Override @Override
public boolean onTouchEvent(MotionEvent ev) { public boolean onTouchEvent(MotionEvent ev) {
if (filterTabsView != null && !filterTabsView.isEditing() && !searching && if (filterTabsView != null && !filterTabsView.isEditing() && !searching &&
!parentLayout.checkTransitionAnimation() && !parentLayout.isInPreviewMode() && !parentLayout.isPreviewOpenAnimationInProgress() && !parentLayout.getDrawerLayoutContainer().isDrawerOpened() && !parentLayout.checkTransitionAnimation() && !parentLayout.isInPreviewMode() && !parentLayout.isPreviewOpenAnimationInProgress() && !parentLayout.getDrawerLayoutContainer().isDrawerOpened() &&
(ev == null || startedTracking || ev.getY() > actionBar.getMeasuredHeight() + actionBar.getTranslationY())) { (ev == null || startedTracking || ev.getY() > actionBar.getMeasuredHeight() + actionBar.getTranslationY())) {
if (ev != null) { if (ev != null) {
@ -1298,7 +1299,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
SharedPreferences preferences = MessagesController.getGlobalMainSettings(); SharedPreferences preferences = MessagesController.getGlobalMainSettings();
boolean hintShowed = preferences.getBoolean("archivehint_l", false) || SharedConfig.archiveHidden; boolean hintShowed = preferences.getBoolean("archivehint_l", false) || SharedConfig.archiveHidden;
if (!hintShowed) { if (!hintShowed) {
preferences.edit().putBoolean("archivehint_l", true).commit(); preferences.edit().putBoolean("archivehint_l", true).apply();
} }
getUndoView().showWithAction(dialog.id, hintShowed ? UndoView.ACTION_ARCHIVE : UndoView.ACTION_ARCHIVE_HINT, null, () -> { getUndoView().showWithAction(dialog.id, hintShowed ? UndoView.ACTION_ARCHIVE : UndoView.ACTION_ARCHIVE_HINT, null, () -> {
dialogsListFrozen = true; dialogsListFrozen = true;
@ -1404,6 +1405,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
public boolean onFragmentCreate() { public boolean onFragmentCreate() {
super.onFragmentCreate(); super.onFragmentCreate();
getConnectionsManager().updateDcSettings();
getMessagesController().getBlockedUsers(true); getMessagesController().getBlockedUsers(true);
if (getArguments() != null) { if (getArguments() != null) {
@ -1424,7 +1426,6 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
if (initialDialogsType == 0) { if (initialDialogsType == 0) {
askAboutContacts = MessagesController.getGlobalNotificationsSettings().getBoolean("askAboutContacts", true); askAboutContacts = MessagesController.getGlobalNotificationsSettings().getBoolean("askAboutContacts", true);
SharedConfig.loadProxyList();
} }
if (searchString == null) { if (searchString == null) {
@ -1564,6 +1565,11 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
updatePasscodeButton(); updatePasscodeButton();
updateProxyButton(false); updateProxyButton(false);
} }
scanItem = menu.addItem(3, R.drawable.wallet_qr);
scanItem.setContentDescription(LocaleController.getString("ScanQRCode", R.string.ScanQRCode));
scanItem.setVisibility(View.GONE);
searchItem = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() { searchItem = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() {
@Override @Override
public void onSearchExpand() { public void onSearchExpand() {
@ -1574,6 +1580,9 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
if (proxyItem != null && proxyItemVisible) { if (proxyItem != null && proxyItemVisible) {
proxyItem.setVisibility(View.GONE); proxyItem.setVisibility(View.GONE);
} }
if (scanItem != null) {
scanItem.setVisibility(View.VISIBLE);
}
if (viewPages[0] != null) { if (viewPages[0] != null) {
if (searchString != null) { if (searchString != null) {
viewPages[0].listView.hide(); viewPages[0].listView.hide();
@ -1596,6 +1605,9 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
if (proxyItem != null && proxyItemVisible) { if (proxyItem != null && proxyItemVisible) {
proxyItem.setVisibility(View.VISIBLE); proxyItem.setVisibility(View.VISIBLE);
} }
if (scanItem != null) {
scanItem.setVisibility(View.GONE);
}
if (searchString != null) { if (searchString != null) {
finishFragment(); finishFragment();
return false; return false;
@ -1657,13 +1669,9 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
actionBar.setBackButtonContentDescription(LocaleController.getString("AccDescrOpenMenu", R.string.AccDescrOpenMenu)); actionBar.setBackButtonContentDescription(LocaleController.getString("AccDescrOpenMenu", R.string.AccDescrOpenMenu));
} }
if (folderId != 0) { if (folderId != 0) {
actionBar.setTitle(getNekoTitle(LocaleController.getString("ArchivedChats", R.string.ArchivedChats))); actionBar.setTitle(LocaleController.getString("ArchivedChats", R.string.ArchivedChats));
} else { } else {
if (BuildVars.DEBUG_VERSION) { actionBar.setTitle(getNekoTitle(LocaleController.getString("NekoX", R.string.NekoX)));
actionBar.setTitle("Telegram Beta");
} else {
actionBar.setTitle(getNekoTitle(LocaleController.getString("Nekogram", R.string.Nekogram)));
}
} }
if (folderId == 0) { if (folderId == 0) {
actionBar.setSupportsHolidayImage(true); actionBar.setSupportsHolidayImage(true);
@ -1824,7 +1832,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
if (tabId < 0 || tabId >= dialogFilters.size()) { if (tabId < 0 || tabId >= dialogFilters.size()) {
return 0; return 0;
} }
return getMessagesController().dialogFilters.get(tabId).unreadCount; return dialogFilters.get(tabId).unreadCount;
} }
@Override @Override
@ -1910,12 +1918,12 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
cell.setTextAndIcon(LocaleController.getString("FilterReorder", R.string.FilterReorder), R.drawable.tabs_reorder); cell.setTextAndIcon(LocaleController.getString("FilterReorder", R.string.FilterReorder), R.drawable.tabs_reorder);
} else if (a == 1) { } else if (a == 1) {
if (N == 2) { if (N == 2) {
cell.setTextAndIcon(LocaleController.getString("FilterEditAll", R.string.FilterEditAll), R.drawable.msg_edit); cell.setTextAndIcon(LocaleController.getString("FilterEditAll", R.string.FilterEditAll), R.drawable.baseline_edit_24);
} else { } else {
cell.setTextAndIcon(LocaleController.getString("FilterEdit", R.string.FilterEdit), R.drawable.msg_edit); cell.setTextAndIcon(LocaleController.getString("FilterEdit", R.string.FilterEdit), R.drawable.baseline_edit_24);
} }
} else { } else {
cell.setTextAndIcon(LocaleController.getString("FilterDeleteItem", R.string.FilterDeleteItem), R.drawable.msg_delete); cell.setTextAndIcon(LocaleController.getString("FilterDeleteItem", R.string.FilterDeleteItem), R.drawable.baseline_delete_24);
} }
scrimPopupWindowItems[a] = cell; scrimPopupWindowItems[a] = cell;
linearLayout.addView(cell); linearLayout.addView(cell);
@ -2069,6 +2077,26 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
updatePasscodeButton(); updatePasscodeButton();
} else if (id == 2) { } else if (id == 2) {
presentFragment(new ProxyListActivity()); presentFragment(new ProxyListActivity());
} else if (id == 3) {
if (Build.VERSION.SDK_INT >= 23) {
if (getParentActivity().checkSelfPermission(Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
getParentActivity().requestPermissions(new String[]{Manifest.permission.CAMERA}, 22);
return;
}
}
CameraScanActivity.showAsSheet(DialogsActivity.this, new CameraScanActivity.CameraScanActivityDelegate() {
@Override
public void didFindQr(String text) {
ProxyUtil.showLinkAlert(getParentActivity(), text);
}
});
} else if (id >= 10 && id < 10 + UserConfig.MAX_ACCOUNT_COUNT) { } else if (id >= 10 && id < 10 + UserConfig.MAX_ACCOUNT_COUNT) {
if (getParentActivity() == null) { if (getParentActivity() == null) {
return; return;
@ -2167,18 +2195,18 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
actionMode.addView(selectedDialogsCountTextView, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1.0f, 72, 0, 0, 0)); actionMode.addView(selectedDialogsCountTextView, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1.0f, 72, 0, 0, 0));
selectedDialogsCountTextView.setOnTouchListener((v, event) -> true); selectedDialogsCountTextView.setOnTouchListener((v, event) -> true);
pinItem = actionMode.addItemWithWidth(pin, R.drawable.msg_pin, AndroidUtilities.dp(54)); pinItem = actionMode.addItemWithWidth(pin, R.drawable.deproko_baseline_pin_24, AndroidUtilities.dp(54));
muteItem = actionMode.addItemWithWidth(mute, R.drawable.msg_mute, AndroidUtilities.dp(54)); muteItem = actionMode.addItemWithWidth(mute, R.drawable.baseline_volume_off_24_white, AndroidUtilities.dp(54));
archive2Item = actionMode.addItemWithWidth(archive2, R.drawable.msg_archive, AndroidUtilities.dp(54)); archive2Item = actionMode.addItemWithWidth(archive2, R.drawable.baseline_archive_24, AndroidUtilities.dp(54));
deleteItem = actionMode.addItemWithWidth(delete, R.drawable.msg_delete, AndroidUtilities.dp(54), LocaleController.getString("Delete", R.string.Delete)); deleteItem = actionMode.addItemWithWidth(delete, R.drawable.baseline_delete_24, AndroidUtilities.dp(54), LocaleController.getString("Delete", R.string.Delete));
ActionBarMenuItem otherItem = actionMode.addItemWithWidth(0, R.drawable.ic_ab_other, AndroidUtilities.dp(54), LocaleController.getString("AccDescrMoreOptions", R.string.AccDescrMoreOptions)); ActionBarMenuItem otherItem = actionMode.addItemWithWidth(0, R.drawable.ic_ab_other, AndroidUtilities.dp(54), LocaleController.getString("AccDescrMoreOptions", R.string.AccDescrMoreOptions));
archiveItem = otherItem.addSubItem(archive, R.drawable.msg_archive, LocaleController.getString("Archive", R.string.Archive)); archiveItem = otherItem.addSubItem(archive, R.drawable.baseline_archive_24, LocaleController.getString("Archive", R.string.Archive));
pin2Item = otherItem.addSubItem(pin2, R.drawable.msg_pin, LocaleController.getString("DialogPin", R.string.DialogPin)); pin2Item = otherItem.addSubItem(pin2, R.drawable.deproko_baseline_pin_24, LocaleController.getString("DialogPin", R.string.DialogPin));
addToFolderItem = otherItem.addSubItem(add_to_folder, R.drawable.msg_addfolder, LocaleController.getString("FilterAddTo", R.string.FilterAddTo)); addToFolderItem = otherItem.addSubItem(add_to_folder, R.drawable.msg_addfolder, LocaleController.getString("FilterAddTo", R.string.FilterAddTo));
removeFromFolderItem = otherItem.addSubItem(remove_from_folder, R.drawable.msg_removefolder, LocaleController.getString("FilterRemoveFrom", R.string.FilterRemoveFrom)); removeFromFolderItem = otherItem.addSubItem(remove_from_folder, R.drawable.msg_removefolder, LocaleController.getString("FilterRemoveFrom", R.string.FilterRemoveFrom));
readItem = otherItem.addSubItem(read, R.drawable.msg_markread, LocaleController.getString("MarkAsRead", R.string.MarkAsRead)); readItem = otherItem.addSubItem(read, R.drawable.deproko_baseline_check_double_24, LocaleController.getString("MarkAsRead", R.string.MarkAsRead));
clearItem = otherItem.addSubItem(clear, R.drawable.msg_clear, LocaleController.getString("ClearHistory", R.string.ClearHistory)); clearItem = otherItem.addSubItem(clear, R.drawable.baseline_delete_sweep_24, LocaleController.getString("ClearHistory", R.string.ClearHistory));
blockItem = otherItem.addSubItem(block, R.drawable.msg_block, LocaleController.getString("BlockUser", R.string.BlockUser)); blockItem = otherItem.addSubItem(block, R.drawable.baseline_block_24, LocaleController.getString("BlockUser", R.string.BlockUser));
actionModeViews.add(pinItem); actionModeViews.add(pinItem);
actionModeViews.add(archive2Item); actionModeViews.add(archive2Item);
@ -2738,13 +2766,13 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
Drawable drawable = Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(56), Theme.getColor(Theme.key_chats_actionBackground), Theme.getColor(Theme.key_chats_actionPressedBackground)); Drawable drawable = Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(56), Theme.getColor(Theme.key_chats_actionBackground), Theme.getColor(Theme.key_chats_actionPressedBackground));
if (Build.VERSION.SDK_INT < 21) { if (Build.VERSION.SDK_INT < 21) {
Drawable shadowDrawable = context.getResources().getDrawable(R.drawable.floating_shadow).mutate(); Drawable shadowDrawable = context.getResources().getDrawable(R.drawable.floating_shadow).mutate();
shadowDrawable.setColorFilter(new PorterDuffColorFilter(0xff000000, PorterDuff.Mode.MULTIPLY)); shadowDrawable.setColorFilter(new PorterDuffColorFilter(0xff000000, PorterDuff.Mode.SRC_IN));
CombinedDrawable combinedDrawable = new CombinedDrawable(shadowDrawable, drawable, 0, 0); CombinedDrawable combinedDrawable = new CombinedDrawable(shadowDrawable, drawable, 0, 0);
combinedDrawable.setIconSize(AndroidUtilities.dp(56), AndroidUtilities.dp(56)); combinedDrawable.setIconSize(AndroidUtilities.dp(56), AndroidUtilities.dp(56));
drawable = combinedDrawable; drawable = combinedDrawable;
} }
floatingButton.setBackgroundDrawable(drawable); floatingButton.setBackgroundDrawable(drawable);
floatingButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_actionIcon), PorterDuff.Mode.MULTIPLY)); floatingButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_actionIcon), PorterDuff.Mode.SRC_IN));
floatingButton.setImageResource(R.drawable.floating_pencil); floatingButton.setImageResource(R.drawable.floating_pencil);
if (Build.VERSION.SDK_INT >= 21) { if (Build.VERSION.SDK_INT >= 21) {
StateListAnimator animator = new StateListAnimator(); StateListAnimator animator = new StateListAnimator();
@ -2979,6 +3007,8 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
updateFilterTabs(false); updateFilterTabs(false);
PrivacyUtil.postCheckAll(getParentActivity(), currentAccount);
return fragmentView; return fragmentView;
} }
@ -3008,6 +3038,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
} }
private boolean scrollBarVisible = true; private boolean scrollBarVisible = true;
private void showScrollbars(boolean show) { private void showScrollbars(boolean show) {
if (viewPages == null || scrollBarVisible == show) { if (viewPages == null || scrollBarVisible == show) {
return; return;
@ -3055,7 +3086,8 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
filterTabsView.resetTabId(); filterTabsView.resetTabId();
} }
filterTabsView.removeTabs(); filterTabsView.removeTabs();
if (!NekoConfig.hideAllTab) filterTabsView.addTab(Integer.MAX_VALUE, LocaleController.getString("FilterAllChats", R.string.FilterAllChats)); if (!NekoConfig.hideAllTab)
filterTabsView.addTab(Integer.MAX_VALUE, LocaleController.getString("FilterAllChats", R.string.FilterAllChats));
for (int a = 0, N = filters.size(); a < N; a++) { for (int a = 0, N = filters.size(); a < N; a++) {
MessagesController.DialogFilter dialogFilter = filters.get(a); MessagesController.DialogFilter dialogFilter = filters.get(a);
switch (NekoConfig.tabsTitleType) { switch (NekoConfig.tabsTitleType) {
@ -3203,7 +3235,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
if (hasNotContactsPermission && askAboutContacts && getUserConfig().syncContacts && activity.shouldShowRequestPermissionRationale(Manifest.permission.READ_CONTACTS)) { if (hasNotContactsPermission && askAboutContacts && getUserConfig().syncContacts && activity.shouldShowRequestPermissionRationale(Manifest.permission.READ_CONTACTS)) {
AlertDialog.Builder builder = AlertsCreator.createContactsPermissionDialog(activity, param -> { AlertDialog.Builder builder = AlertsCreator.createContactsPermissionDialog(activity, param -> {
askAboutContacts = param != 0; askAboutContacts = param != 0;
MessagesController.getGlobalNotificationsSettings().edit().putBoolean("askAboutContacts", askAboutContacts).commit(); MessagesController.getGlobalNotificationsSettings().edit().putBoolean("askAboutContacts", askAboutContacts).apply();
askForPermissons(false); askForPermissons(false);
}); });
showDialog(permissionDialog = builder.create()); showDialog(permissionDialog = builder.create());
@ -3812,8 +3844,8 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
final boolean hasUnread = getMessagesStorage().getArchiveUnreadCount() != 0; final boolean hasUnread = getMessagesStorage().getArchiveUnreadCount() != 0;
int[] icons = new int[]{ int[] icons = new int[]{
hasUnread ? R.drawable.menu_read : 0, hasUnread ? R.drawable.deproko_baseline_check_double_24 : 0,
SharedConfig.archiveHidden ? R.drawable.chats_pin : R.drawable.chats_unpin, SharedConfig.archiveHidden ? R.drawable.deproko_baseline_pin_24 : R.drawable.deproko_baseline_pin_undo_24,
}; };
CharSequence[] items = new CharSequence[]{ CharSequence[] items = new CharSequence[]{
hasUnread ? LocaleController.getString("MarkAllAsRead", R.string.MarkAllAsRead) : null, hasUnread ? LocaleController.getString("MarkAllAsRead", R.string.MarkAllAsRead) : null,
@ -4033,7 +4065,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
SharedPreferences preferences = MessagesController.getGlobalMainSettings(); SharedPreferences preferences = MessagesController.getGlobalMainSettings();
boolean hintShowed = preferences.getBoolean("archivehint_l", false) || SharedConfig.archiveHidden; boolean hintShowed = preferences.getBoolean("archivehint_l", false) || SharedConfig.archiveHidden;
if (!hintShowed) { if (!hintShowed) {
preferences.edit().putBoolean("archivehint_l", true).commit(); preferences.edit().putBoolean("archivehint_l", true).apply();
} }
int undoAction; int undoAction;
if (hintShowed) { if (hintShowed) {
@ -4513,8 +4545,8 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
} }
} }
if (canUnarchiveCount != 0) { if (canUnarchiveCount != 0) {
archiveItem.setTextAndIcon(LocaleController.getString("Unarchive", R.string.Unarchive), R.drawable.msg_unarchive); archiveItem.setTextAndIcon(LocaleController.getString("Unarchive", R.string.Unarchive), R.drawable.baseline_unarchive_24);
archive2Item.setIcon(R.drawable.msg_unarchive); archive2Item.setIcon(R.drawable.baseline_unarchive_24);
if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE) { if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE) {
archive2Item.setVisibility(View.VISIBLE); archive2Item.setVisibility(View.VISIBLE);
archiveItem.setVisibility(View.GONE); archiveItem.setVisibility(View.GONE);
@ -4523,8 +4555,8 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
archive2Item.setVisibility(View.GONE); archive2Item.setVisibility(View.GONE);
} }
} else if (canArchiveCount != 0) { } else if (canArchiveCount != 0) {
archiveItem.setTextAndIcon(LocaleController.getString("Archive", R.string.Archive), R.drawable.msg_archive); archiveItem.setTextAndIcon(LocaleController.getString("Archive", R.string.Archive), R.drawable.baseline_archive_24);
archive2Item.setIcon(R.drawable.msg_archive); archive2Item.setIcon(R.drawable.baseline_archive_24);
if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE) { if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE) {
archive2Item.setVisibility(View.VISIBLE); archive2Item.setVisibility(View.VISIBLE);
archiveItem.setVisibility(View.GONE); archiveItem.setVisibility(View.GONE);
@ -4564,23 +4596,23 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
addToFolderItem.setVisibility(View.GONE); addToFolderItem.setVisibility(View.GONE);
} }
if (canUnmuteCount != 0) { if (canUnmuteCount != 0) {
muteItem.setIcon(R.drawable.msg_unmute); muteItem.setIcon(R.drawable.baseline_bullhorn_24);
muteItem.setContentDescription(LocaleController.getString("ChatsUnmute", R.string.ChatsUnmute)); muteItem.setContentDescription(LocaleController.getString("ChatsUnmute", R.string.ChatsUnmute));
} else { } else {
muteItem.setIcon(R.drawable.msg_mute); muteItem.setIcon(R.drawable.baseline_volume_off_24_white);
muteItem.setContentDescription(LocaleController.getString("ChatsMute", R.string.ChatsMute)); muteItem.setContentDescription(LocaleController.getString("ChatsMute", R.string.ChatsMute));
} }
if (canReadCount != 0) { if (canReadCount != 0) {
readItem.setTextAndIcon(LocaleController.getString("MarkAsRead", R.string.MarkAsRead), R.drawable.msg_markread); readItem.setTextAndIcon(LocaleController.getString("MarkAsRead", R.string.MarkAsRead), R.drawable.deproko_baseline_check_double_24);
} else { } else {
readItem.setTextAndIcon(LocaleController.getString("MarkAsUnread", R.string.MarkAsUnread), R.drawable.msg_markunread); readItem.setTextAndIcon(LocaleController.getString("MarkAsUnread", R.string.MarkAsUnread), R.drawable.baseline_unsubscribe_24);
} }
if (canPinCount != 0) { if (canPinCount != 0) {
pinItem.setIcon(R.drawable.msg_pin); pinItem.setIcon(R.drawable.deproko_baseline_pin_24);
pinItem.setContentDescription(LocaleController.getString("PinToTop", R.string.PinToTop)); pinItem.setContentDescription(LocaleController.getString("PinToTop", R.string.PinToTop));
pin2Item.setText(LocaleController.getString("DialogPin", R.string.DialogPin)); pin2Item.setText(LocaleController.getString("DialogPin", R.string.DialogPin));
} else { } else {
pinItem.setIcon(R.drawable.msg_unpin); pinItem.setIcon(R.drawable.deproko_baseline_pin_undo_24);
pinItem.setContentDescription(LocaleController.getString("UnpinFromTop", R.string.UnpinFromTop)); pinItem.setContentDescription(LocaleController.getString("UnpinFromTop", R.string.UnpinFromTop));
pin2Item.setText(LocaleController.getString("DialogUnpin", R.string.DialogUnpin)); pin2Item.setText(LocaleController.getString("DialogUnpin", R.string.DialogUnpin));
} }
@ -4698,12 +4730,12 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
String proxyAddress = preferences.getString("proxy_ip", ""); String proxyAddress = preferences.getString("proxy_ip", "");
boolean proxyEnabled; boolean proxyEnabled;
if ((proxyEnabled = preferences.getBoolean("proxy_enabled", false) && !TextUtils.isEmpty(proxyAddress)) || getMessagesController().blockedCountry && !SharedConfig.proxyList.isEmpty()) { if (!NekoConfig.useProxyItem && (!NekoConfig.hideProxyByDefault || (proxyEnabled = preferences.getBoolean("proxy_enabled", false) && !TextUtils.isEmpty(proxyAddress)) || getMessagesController().blockedCountry && !SharedConfig.proxyList.isEmpty())) {
if (!actionBar.isSearchFieldVisible() && (doneItem == null || doneItem.getVisibility() != View.VISIBLE)) { if (!actionBar.isSearchFieldVisible() && (doneItem == null || doneItem.getVisibility() != View.VISIBLE)) {
proxyItem.setVisibility(View.VISIBLE); proxyItem.setVisibility(View.VISIBLE);
} }
proxyItemVisible = true; proxyItemVisible = true;
proxyDrawable.setConnected(proxyEnabled, currentConnectionState == ConnectionsManager.ConnectionStateConnected || currentConnectionState == ConnectionsManager.ConnectionStateUpdating, animated); proxyDrawable.setConnected(true, currentConnectionState == ConnectionsManager.ConnectionStateConnected || currentConnectionState == ConnectionsManager.ConnectionStateUpdating, animated);
} else { } else {
proxyItemVisible = false; proxyItemVisible = false;
proxyItem.setVisibility(View.GONE); proxyItem.setVisibility(View.GONE);
@ -4711,6 +4743,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
} }
private AnimatorSet doneItemAnimator; private AnimatorSet doneItemAnimator;
private void showDoneItem(boolean show) { private void showDoneItem(boolean show) {
if (doneItem == null) { if (doneItem == null) {
return; return;
@ -4834,7 +4867,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
if (alert) { if (alert) {
AlertDialog.Builder builder = AlertsCreator.createContactsPermissionDialog(activity, param -> { AlertDialog.Builder builder = AlertsCreator.createContactsPermissionDialog(activity, param -> {
askAboutContacts = param != 0; askAboutContacts = param != 0;
MessagesController.getGlobalNotificationsSettings().edit().putBoolean("askAboutContacts", askAboutContacts).commit(); MessagesController.getGlobalNotificationsSettings().edit().putBoolean("askAboutContacts", askAboutContacts).apply();
askForPermissons(false); askForPermissons(false);
}); });
showDialog(permissionDialog = builder.create()); showDialog(permissionDialog = builder.create());
@ -4903,7 +4936,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
if (grantResults[a] == PackageManager.PERMISSION_GRANTED) { if (grantResults[a] == PackageManager.PERMISSION_GRANTED) {
getContactsController().forceImportContacts(); getContactsController().forceImportContacts();
} else { } else {
MessagesController.getGlobalNotificationsSettings().edit().putBoolean("askAboutContacts", askAboutContacts = false).commit(); MessagesController.getGlobalNotificationsSettings().edit().putBoolean("askAboutContacts", askAboutContacts = false).apply();
} }
break; break;
case Manifest.permission.WRITE_EXTERNAL_STORAGE: case Manifest.permission.WRITE_EXTERNAL_STORAGE:
@ -4921,7 +4954,15 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
} }
private String getNekoTitle(String title) { private String getNekoTitle(String title) {
return LocaleController.getString("NekogramEmojiDialogs", R.string.NekogramEmojiDialogs) + " " + title;
if (!NekoConfig.removeTitleEmoji) {
title = LocaleController.getString("NekogramEmojiDialogs", R.string.NekogramEmojiDialogs) + " " + title;
}
return title;
//if (FilterPopup.getInstance(currentAccount).getTotalUnreadCount() == 0) { //if (FilterPopup.getInstance(currentAccount).getTotalUnreadCount() == 0) {
// return LocaleController.getString("NekogramEmojiDialogs", R.string.NekogramEmojiDialogs) + " " + title; // return LocaleController.getString("NekogramEmojiDialogs", R.string.NekogramEmojiDialogs) + " " + title;
//} //}
@ -5086,7 +5127,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
if (preferences.getBoolean("filterhint", false)) { if (preferences.getBoolean("filterhint", false)) {
return; return;
} }
preferences.edit().putBoolean("filterhint", true).commit(); preferences.edit().putBoolean("filterhint", true).apply();
AndroidUtilities.runOnUIThread(() -> getUndoView().showWithAction(0, UndoView.ACTION_FILTERS_AVAILABLE, null, () -> presentFragment(new FiltersSetupActivity())), 1000); AndroidUtilities.runOnUIThread(() -> getUndoView().showWithAction(0, UndoView.ACTION_FILTERS_AVAILABLE, null, () -> presentFragment(new FiltersSetupActivity())), 1000);
} }
@ -5170,7 +5211,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
} }
floatingHidden = hide; floatingHidden = hide;
AnimatorSet animatorSet = new AnimatorSet(); AnimatorSet animatorSet = new AnimatorSet();
ValueAnimator valueAnimator = ValueAnimator.ofFloat(floatingButtonHideProgress,floatingHidden ? 1f : 0f); ValueAnimator valueAnimator = ValueAnimator.ofFloat(floatingButtonHideProgress, floatingHidden ? 1f : 0f);
valueAnimator.addUpdateListener(animation -> { valueAnimator.addUpdateListener(animation -> {
floatingButtonHideProgress = (float) animation.getAnimatedValue(); floatingButtonHideProgress = (float) animation.getAnimatedValue();
floatingButtonTranslation = AndroidUtilities.dp(100) * floatingButtonHideProgress; floatingButtonTranslation = AndroidUtilities.dp(100) * floatingButtonHideProgress;

View File

@ -49,6 +49,8 @@ import org.telegram.ui.Components.PasscodeView;
import java.util.ArrayList; import java.util.ArrayList;
import tw.nekomimi.nekogram.NekoXConfig;
public class ExternalActionActivity extends Activity implements ActionBarLayout.ActionBarLayoutDelegate { public class ExternalActionActivity extends Activity implements ActionBarLayout.ActionBarLayoutDelegate {
private boolean finished; private boolean finished;
@ -76,7 +78,7 @@ public class ExternalActionActivity extends Activity implements ActionBarLayout.
requestWindowFeature(Window.FEATURE_NO_TITLE); requestWindowFeature(Window.FEATURE_NO_TITLE);
setTheme(R.style.Theme_TMessages); setTheme(R.style.Theme_TMessages);
getWindow().setBackgroundDrawableResource(R.drawable.transparent); getWindow().setBackgroundDrawableResource(R.drawable.transparent);
if (SharedConfig.passcodeHash.length() > 0 && !SharedConfig.allowScreenCapture) { if (SharedConfig.passcodeHash.length() > 0 && !SharedConfig.allowScreenCapture && !NekoXConfig.disableFlagSecure) {
try { try {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
} catch (Exception e) { } catch (Exception e) {

View File

@ -252,7 +252,7 @@ public class FiltersSetupActivity extends BaseFragment implements NotificationCe
moveImageView.setFocusable(false); moveImageView.setFocusable(false);
moveImageView.setScaleType(ImageView.ScaleType.CENTER); moveImageView.setScaleType(ImageView.ScaleType.CENTER);
moveImageView.setImageResource(R.drawable.list_reorder); moveImageView.setImageResource(R.drawable.list_reorder);
moveImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_stickers_menu), PorterDuff.Mode.MULTIPLY)); moveImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_stickers_menu), PorterDuff.Mode.SRC_IN));
moveImageView.setClickable(true); moveImageView.setClickable(true);
addView(moveImageView, LayoutHelper.createFrame(48, 48, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL, 6, 0, 6, 0)); addView(moveImageView, LayoutHelper.createFrame(48, 48, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL, 6, 0, 6, 0));
@ -282,7 +282,7 @@ public class FiltersSetupActivity extends BaseFragment implements NotificationCe
optionsImageView.setFocusable(false); optionsImageView.setFocusable(false);
optionsImageView.setScaleType(ImageView.ScaleType.CENTER); optionsImageView.setScaleType(ImageView.ScaleType.CENTER);
optionsImageView.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_stickers_menuSelector))); optionsImageView.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_stickers_menuSelector)));
optionsImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_stickers_menu), PorterDuff.Mode.MULTIPLY)); optionsImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_stickers_menu), PorterDuff.Mode.SRC_IN));
optionsImageView.setImageResource(R.drawable.msg_actions); optionsImageView.setImageResource(R.drawable.msg_actions);
addView(optionsImageView, LayoutHelper.createFrame(40, 40, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, 6, 0, 6, 0)); addView(optionsImageView, LayoutHelper.createFrame(40, 40, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, 6, 0, 6, 0));
} }
@ -372,10 +372,6 @@ public class FiltersSetupActivity extends BaseFragment implements NotificationCe
updateRows(true); updateRows(true);
getMessagesController().loadRemoteFilters(true); getMessagesController().loadRemoteFilters(true);
getNotificationCenter().addObserver(this, NotificationCenter.dialogFiltersUpdated); getNotificationCenter().addObserver(this, NotificationCenter.dialogFiltersUpdated);
getNotificationCenter().addObserver(this, NotificationCenter.suggestedFiltersLoaded);
if (getMessagesController().suggestedFilters.isEmpty()) {
getMessagesController().loadSuggestedFilters();
}
return super.onFragmentCreate(); return super.onFragmentCreate();
} }
@ -491,6 +487,10 @@ public class FiltersSetupActivity extends BaseFragment implements NotificationCe
return; return;
} }
updateRows(true); updateRows(true);
getNotificationCenter().addObserver(this, NotificationCenter.suggestedFiltersLoaded);
if (getMessagesController().suggestedFilters.isEmpty()) {
getMessagesController().loadSuggestedFilters();
}
} else if (id == NotificationCenter.suggestedFiltersLoaded) { } else if (id == NotificationCenter.suggestedFiltersLoaded) {
updateRows(true); updateRows(true);
} }
@ -548,8 +548,8 @@ public class FiltersSetupActivity extends BaseFragment implements NotificationCe
LocaleController.getString("FilterDeleteItem", R.string.FilterDeleteItem), LocaleController.getString("FilterDeleteItem", R.string.FilterDeleteItem),
}; };
final int[] icons = new int[]{ final int[] icons = new int[]{
R.drawable.msg_edit, R.drawable.baseline_edit_24,
R.drawable.msg_delete R.drawable.baseline_delete_24
}; };
builder1.setItems(items, icons, (dialog, which) -> { builder1.setItems(items, icons, (dialog, which) -> {
if (which == 0) { if (which == 0) {
@ -746,8 +746,8 @@ public class FiltersSetupActivity extends BaseFragment implements NotificationCe
if (position == createFilterRow) { if (position == createFilterRow) {
Drawable drawable1 = mContext.getResources().getDrawable(R.drawable.poll_add_circle); Drawable drawable1 = mContext.getResources().getDrawable(R.drawable.poll_add_circle);
Drawable drawable2 = mContext.getResources().getDrawable(R.drawable.poll_add_plus); Drawable drawable2 = mContext.getResources().getDrawable(R.drawable.poll_add_plus);
drawable1.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_switchTrackChecked), PorterDuff.Mode.MULTIPLY)); drawable1.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_switchTrackChecked), PorterDuff.Mode.SRC_IN));
drawable2.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_checkboxCheck), PorterDuff.Mode.MULTIPLY)); drawable2.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_checkboxCheck), PorterDuff.Mode.SRC_IN));
CombinedDrawable combinedDrawable = new CombinedDrawable(drawable1, drawable2); CombinedDrawable combinedDrawable = new CombinedDrawable(drawable1, drawable2);
textCell.setTextAndIcon(LocaleController.getString("CreateNewFilter", R.string.CreateNewFilter), combinedDrawable, false); textCell.setTextAndIcon(LocaleController.getString("CreateNewFilter", R.string.CreateNewFilter), combinedDrawable, false);

View File

@ -16,13 +16,16 @@ import android.view.ViewGroup;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.Toast; import android.widget.Toast;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.ChatObject; import org.telegram.messenger.ChatObject;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.LocaleController; import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MessagesController; import org.telegram.messenger.MessagesController;
import org.telegram.messenger.NotificationCenter; import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.tgnet.ConnectionsManager; import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.TLRPC; import org.telegram.tgnet.TLRPC;
@ -40,8 +43,7 @@ import org.telegram.ui.Components.RecyclerListView;
import java.util.ArrayList; import java.util.ArrayList;
import androidx.recyclerview.widget.LinearLayoutManager; import tw.nekomimi.nekogram.utils.ProxyUtil;
import androidx.recyclerview.widget.RecyclerView;
public class GroupInviteActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate { public class GroupInviteActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
@ -58,6 +60,7 @@ public class GroupInviteActivity extends BaseFragment implements NotificationCen
private int copyLinkRow; private int copyLinkRow;
private int revokeLinkRow; private int revokeLinkRow;
private int shareLinkRow; private int shareLinkRow;
private int shareQrCodeRow;
private int shadowRow; private int shadowRow;
private int rowCount; private int rowCount;
@ -80,6 +83,7 @@ public class GroupInviteActivity extends BaseFragment implements NotificationCen
copyLinkRow = rowCount++; copyLinkRow = rowCount++;
revokeLinkRow = rowCount++; revokeLinkRow = rowCount++;
shareLinkRow = rowCount++; shareLinkRow = rowCount++;
shareQrCodeRow = rowCount++;
shadowRow = rowCount++; shadowRow = rowCount++;
return true; return true;
@ -148,6 +152,11 @@ public class GroupInviteActivity extends BaseFragment implements NotificationCen
} catch (Exception e) { } catch (Exception e) {
FileLog.e(e); FileLog.e(e);
} }
} else if (position == shareQrCodeRow) {
if (invite == null) {
return;
}
ProxyUtil.showQrDialog(getParentActivity(),invite.link);
} else if (position == revokeLinkRow) { } else if (position == revokeLinkRow) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setMessage(LocaleController.getString("RevokeAlert", R.string.RevokeAlert)); builder.setMessage(LocaleController.getString("RevokeAlert", R.string.RevokeAlert));
@ -226,7 +235,7 @@ public class GroupInviteActivity extends BaseFragment implements NotificationCen
@Override @Override
public boolean isEnabled(RecyclerView.ViewHolder holder) { public boolean isEnabled(RecyclerView.ViewHolder holder) {
int position = holder.getAdapterPosition(); int position = holder.getAdapterPosition();
return position == revokeLinkRow || position == copyLinkRow || position == shareLinkRow || position == linkRow; return position == revokeLinkRow || position == copyLinkRow || position == shareLinkRow || position == shareQrCodeRow || position == linkRow;
} }
@Override @Override
@ -263,6 +272,8 @@ public class GroupInviteActivity extends BaseFragment implements NotificationCen
textCell.setText(LocaleController.getString("CopyLink", R.string.CopyLink), true); textCell.setText(LocaleController.getString("CopyLink", R.string.CopyLink), true);
} else if (position == shareLinkRow) { } else if (position == shareLinkRow) {
textCell.setText(LocaleController.getString("ShareLink", R.string.ShareLink), false); textCell.setText(LocaleController.getString("ShareLink", R.string.ShareLink), false);
} else if (position == shareQrCodeRow) {
textCell.setText(LocaleController.getString("ShareQRCode", R.string.ShareQRCode), false);
} else if (position == revokeLinkRow) { } else if (position == revokeLinkRow) {
textCell.setText(LocaleController.getString("RevokeLink", R.string.RevokeLink), true); textCell.setText(LocaleController.getString("RevokeLink", R.string.RevokeLink), true);
} }
@ -291,7 +302,7 @@ public class GroupInviteActivity extends BaseFragment implements NotificationCen
@Override @Override
public int getItemViewType(int position) { public int getItemViewType(int position) {
if (position == copyLinkRow || position == shareLinkRow || position == revokeLinkRow) { if (position == copyLinkRow || position == shareLinkRow || position == shareQrCodeRow || position == revokeLinkRow) {
return 0; return 0;
} else if (position == shadowRow || position == linkInfoRow) { } else if (position == shadowRow || position == linkInfoRow) {
return 1; return 1;

View File

@ -16,21 +16,27 @@ import android.widget.EditText;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.TextView; import android.widget.TextView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.messenger.LocaleController; import org.telegram.messenger.LocaleController;
import org.telegram.messenger.NotificationCenter; import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.Utilities; import org.telegram.messenger.Utilities;
import org.telegram.ui.ActionBar.AlertDialog; import org.telegram.tgnet.ConnectionsManager;
import org.telegram.ui.ActionBar.Theme; import org.telegram.tgnet.TLRPC;
import org.telegram.ui.ActionBar.ThemeDescription;
import org.telegram.ui.Cells.LanguageCell;
import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.ActionBar.ActionBarMenuItem; import org.telegram.ui.ActionBar.ActionBarMenuItem;
import org.telegram.ui.ActionBar.AlertDialog;
import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.ActionBar.ThemeDescription;
import org.telegram.ui.Cells.LanguageCell;
import org.telegram.ui.Cells.ShadowSectionCell; import org.telegram.ui.Cells.ShadowSectionCell;
import org.telegram.ui.Components.AlertsCreator;
import org.telegram.ui.Components.EmptyTextProgressView; import org.telegram.ui.Components.EmptyTextProgressView;
import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.LayoutHelper;
import org.telegram.ui.Components.RecyclerListView; import org.telegram.ui.Components.RecyclerListView;
@ -38,11 +44,16 @@ import org.telegram.ui.Components.RecyclerListView;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.Locale;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import androidx.recyclerview.widget.LinearLayoutManager; import kotlin.Unit;
import androidx.recyclerview.widget.RecyclerView; import tw.nekomimi.nekogram.BottomBuilder;
import tw.nekomimi.nekogram.transtale.TranslateDb;
import tw.nekomimi.nekogram.utils.AlertUtil;
import tw.nekomimi.nekogram.utils.ShareUtil;
import tw.nekomimi.nekogram.utils.UIUtil;
public class LanguageSelectActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate { public class LanguageSelectActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
@ -150,6 +161,12 @@ public class LanguageSelectActivity extends BaseFragment implements Notification
LanguageCell cell = (LanguageCell) view; LanguageCell cell = (LanguageCell) view;
LocaleController.LocaleInfo localeInfo = cell.getCurrentLocale(); LocaleController.LocaleInfo localeInfo = cell.getCurrentLocale();
if (localeInfo != null) { if (localeInfo != null) {
if (localeInfo.toInstall) {
AlertsCreator.createLanguageAlert((LaunchActivity) getParentActivity(),localeInfo.pack,() -> {
finishFragment();
}).show();
return;
}
LocaleController.getInstance().applyLanguage(localeInfo, true, false, false, true, currentAccount); LocaleController.getInstance().applyLanguage(localeInfo, true, false, false, true, currentAccount);
parentLayout.rebuildAllFragmentViews(false, false); parentLayout.rebuildAllFragmentViews(false, false);
} }
@ -162,34 +179,57 @@ public class LanguageSelectActivity extends BaseFragment implements Notification
} }
LanguageCell cell = (LanguageCell) view; LanguageCell cell = (LanguageCell) view;
LocaleController.LocaleInfo localeInfo = cell.getCurrentLocale(); LocaleController.LocaleInfo localeInfo = cell.getCurrentLocale();
if (localeInfo == null || localeInfo.pathToFile == null || localeInfo.isRemote() && localeInfo.serverIndex != Integer.MAX_VALUE) { if (localeInfo == null || localeInfo.pathToFile == null || localeInfo.isRemote() && localeInfo.serverIndex != Integer.MAX_VALUE) {
return false; return false;
} }
final LocaleController.LocaleInfo finalLocaleInfo = localeInfo;
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); BottomBuilder builder = new BottomBuilder(getParentActivity());
builder.setTitle(LocaleController.getString("DeleteLocalizationTitle", R.string.DeleteLocalizationTitle));
builder.setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("DeleteLocalizationText", R.string.DeleteLocalizationText, localeInfo.name))); builder.addItem(LocaleController.getString("BotShare",R.string.BotShare),R.drawable.baseline_send_24,false,(__) -> {
builder.setPositiveButton(LocaleController.getString("Delete", R.string.Delete), (dialogInterface, i) -> {
if (LocaleController.getInstance().deleteLanguage(finalLocaleInfo, currentAccount)) { builder.dismiss();
fillLanguages();
if (searchResult != null) { ShareUtil.shareText(getParentActivity(),"https://t.me/setlanguage/" + localeInfo.shortName.replace('_','-'));
searchResult.remove(finalLocaleInfo);
} return Unit.INSTANCE;
if (listAdapter != null) {
listAdapter.notifyDataSetChanged();
}
if (searchListViewAdapter != null) {
searchListViewAdapter.notifyDataSetChanged();
}
}
}); });
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
AlertDialog alertDialog = builder.create(); if (!localeInfo.isBuiltIn()) {
showDialog(alertDialog);
TextView button = (TextView) alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); builder.addItem(LocaleController.getString("DeleteLocalizationTitle", R.string.DeleteLocalizationTitle), R.drawable.baseline_delete_24, true, (__) -> {
if (button != null) {
button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2)); builder.dismiss();
AlertUtil.showConfirm(getParentActivity(),
LocaleController.getString("DeleteLocalizationTitle", R.string.DeleteLocalizationTitle),
R.drawable.baseline_delete_24,
LocaleController.getString("Delete", R.string.Delete), true, () -> {
if (LocaleController.getInstance().deleteLanguage(localeInfo, currentAccount)) {
fillLanguages();
if (searchResult != null) {
searchResult.remove(localeInfo);
}
if (listAdapter != null) {
listAdapter.notifyDataSetChanged();
}
if (searchListViewAdapter != null) {
searchListViewAdapter.notifyDataSetChanged();
}
}
});
return Unit.INSTANCE;
});
} }
builder.show();
return true; return true;
}); });
@ -295,21 +335,64 @@ public class LanguageSelectActivity extends BaseFragment implements Notification
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
ArrayList<LocaleController.LocaleInfo> resultArray = new ArrayList<>(); ArrayList<LocaleController.LocaleInfo> resultArray = new ArrayList<>();
boolean noSearch = false;
for (int a = 0, N = unofficialLanguages.size(); a < N; a++) { for (int a = 0, N = unofficialLanguages.size(); a < N; a++) {
LocaleController.LocaleInfo c = unofficialLanguages.get(a); LocaleController.LocaleInfo c = unofficialLanguages.get(a);
if (c.name.toLowerCase().startsWith(query) || c.nameEnglish.toLowerCase().startsWith(query)) { if (c.name.toLowerCase().contains(query) || c.nameEnglish.toLowerCase().contains(query)) {
resultArray.add(c); resultArray.add(c);
} else if (c.shortName.contains(query)) {
resultArray.add(c);
if (c.shortName.equals(query)) {
noSearch = true;
}
} }
} }
for (int a = 0, N = sortedLanguages.size(); a < N; a++) { for (int a = 0, N = sortedLanguages.size(); a < N; a++) {
LocaleController.LocaleInfo c = sortedLanguages.get(a); LocaleController.LocaleInfo c = sortedLanguages.get(a);
if (c.name.toLowerCase().startsWith(query) || c.nameEnglish.toLowerCase().startsWith(query)) { if (c.name.toLowerCase().contains(query) || c.nameEnglish.toLowerCase().contains(query)) {
resultArray.add(c); resultArray.add(c);
} else if (c.shortName.contains(query)) {
resultArray.add(c);
if (c.shortName.equals(query)) {
noSearch = true;
}
} }
} }
updateSearchResults(resultArray); updateSearchResults(resultArray);
if (!noSearch) {
TLRPC.TL_langpack_getLanguage req = new TLRPC.TL_langpack_getLanguage();
req.lang_code = query.replace('_', '-');
req.lang_pack = "android";
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
if (response instanceof TLRPC.TL_langPackLanguage) {
TLRPC.TL_langPackLanguage res = (TLRPC.TL_langPackLanguage) response;
if (res.strings_count == 0) return;
resultArray.add(new LocaleController.LocaleInfo() {{
name = res.native_name;
nameEnglish = res.name;
shortName = res.lang_code;
pluralLangCode = res.plural_code;
baseLangCode = res.base_lang_code;
isRtl = res.rtl;
if (res.official) {
pathToFile = "remote";
} else {
pathToFile = "unofficial";
}
toInstall = true;
pack = res;
}});
updateSearchResults(resultArray);
}
}));
}
}); });
} }

File diff suppressed because it is too large Load Diff

View File

@ -11,6 +11,7 @@ package org.telegram.ui;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.SparseIntArray;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.FrameLayout; import android.widget.FrameLayout;
@ -21,6 +22,8 @@ import org.telegram.tgnet.TLRPC;
import org.telegram.messenger.MessagesController; import org.telegram.messenger.MessagesController;
import org.telegram.messenger.NotificationCenter; import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.ActionBar.ActionBarMenuItem;
import org.telegram.ui.ActionBar.AlertDialog; import org.telegram.ui.ActionBar.AlertDialog;
import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.ActionBar.ThemeDescription; import org.telegram.ui.ActionBar.ThemeDescription;
@ -69,6 +72,8 @@ public class PrivacyUsersActivity extends BaseFragment implements NotificationCe
public static final int TYPE_BLOCKED = 1; public static final int TYPE_BLOCKED = 1;
public static final int TYPE_FILTER = 2; public static final int TYPE_FILTER = 2;
private int unblock_all = 1;
public interface PrivacyActivityDelegate { public interface PrivacyActivityDelegate {
void didUpdateUserList(ArrayList<Integer> ids, boolean added); void didUpdateUserList(ArrayList<Integer> ids, boolean added);
} }
@ -139,10 +144,34 @@ public class PrivacyUsersActivity extends BaseFragment implements NotificationCe
public void onItemClick(int id) { public void onItemClick(int id) {
if (id == -1) { if (id == -1) {
finishFragment(); finishFragment();
} else if (id == unblock_all) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("UnblockAll", R.string.UnblockAll));
if (getMessagesController().totalBlockedCount != 0) {
builder.setMessage(LocaleController.getString("UnblockAllWarn", R.string.UnblockAllWarn));
builder.setPositiveButton(LocaleController.getString("UnblockAll", R.string.UnblockAll), (dialog, which) -> {
new Thread(() -> getMessagesController().unblockAllUsers()).start();
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
} else {
builder.setMessage(LocaleController.getString("BlockedListEmpty",R.string.BlockedListEmpty));
builder.setPositiveButton(LocaleController.getString("OK",R.string.OK),null);
}
showDialog(builder.create());
} }
} }
}); });
if (blockedUsersActivity) {
ActionBarMenu menu = actionBar.createMenu();
ActionBarMenuItem otherItem = menu.addItem(0, R.drawable.ic_ab_other);
otherItem.setContentDescription(LocaleController.getString("AccDescrMoreOptions", R.string.AccDescrMoreOptions));
otherItem.addSubItem(unblock_all, LocaleController.getString("UnblockAll", R.string.UnblockAll));
}
fragmentView = new FrameLayout(context); fragmentView = new FrameLayout(context);
FrameLayout frameLayout = (FrameLayout) fragmentView; FrameLayout frameLayout = (FrameLayout) fragmentView;
frameLayout.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray)); frameLayout.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray));
@ -470,9 +499,9 @@ public class PrivacyUsersActivity extends BaseFragment implements NotificationCe
ManageChatTextCell actionCell = (ManageChatTextCell) holder.itemView; ManageChatTextCell actionCell = (ManageChatTextCell) holder.itemView;
actionCell.setColors(Theme.key_windowBackgroundWhiteBlueIcon, Theme.key_windowBackgroundWhiteBlueButton); actionCell.setColors(Theme.key_windowBackgroundWhiteBlueIcon, Theme.key_windowBackgroundWhiteBlueButton);
if (currentType == TYPE_BLOCKED) { if (currentType == TYPE_BLOCKED) {
actionCell.setText(LocaleController.getString("BlockUser", R.string.BlockUser), null, R.drawable.actions_addmember2, false); actionCell.setText(LocaleController.getString("BlockUser", R.string.BlockUser), null, R.drawable.baseline_person_add_24, false);
} else { } else {
actionCell.setText(LocaleController.getString("PrivacyAddAnException", R.string.PrivacyAddAnException), null, R.drawable.actions_addmember2, false); actionCell.setText(LocaleController.getString("PrivacyAddAnException", R.string.PrivacyAddAnException), null, R.drawable.baseline_person_add_24, false);
} }
break; break;
case 3: case 3:

View File

@ -140,6 +140,7 @@ import java.util.HashMap;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import tw.nekomimi.nekogram.NekoConfig; import tw.nekomimi.nekogram.NekoConfig;
import tw.nekomimi.nekogram.utils.ProxyUtil;
public class ProfileActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, DialogsActivity.DialogsActivityDelegate, SharedMediaLayout.SharedMediaPreloaderDelegate { public class ProfileActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, DialogsActivity.DialogsActivityDelegate, SharedMediaLayout.SharedMediaPreloaderDelegate {
@ -251,6 +252,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
private final static int leave_group = 7; private final static int leave_group = 7;
private final static int invite_to_group = 9; private final static int invite_to_group = 9;
private final static int share = 10; private final static int share = 10;
private final static int qr_code = 11;
private final static int edit_channel = 12; private final static int edit_channel = 12;
private final static int add_shortcut = 14; private final static int add_shortcut = 14;
private final static int call_item = 15; private final static int call_item = 15;
@ -519,15 +521,15 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
selectedBarPaint = new Paint(Paint.ANTI_ALIAS_FLAG); selectedBarPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
selectedBarPaint.setColor(0xffffffff); selectedBarPaint.setColor(0xffffffff);
topOverlayGradient = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] {0x42000000, 0}); topOverlayGradient = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[]{0x42000000, 0});
topOverlayGradient.setShape(GradientDrawable.RECTANGLE); topOverlayGradient.setShape(GradientDrawable.RECTANGLE);
bottomOverlayGradient = new GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP, new int[] {0x42000000, 0}); bottomOverlayGradient = new GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP, new int[]{0x42000000, 0});
bottomOverlayGradient.setShape(GradientDrawable.RECTANGLE); bottomOverlayGradient.setShape(GradientDrawable.RECTANGLE);
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
final GradientDrawable.Orientation orientation = i == 0 ? GradientDrawable.Orientation.LEFT_RIGHT : GradientDrawable.Orientation.RIGHT_LEFT; final GradientDrawable.Orientation orientation = i == 0 ? GradientDrawable.Orientation.LEFT_RIGHT : GradientDrawable.Orientation.RIGHT_LEFT;
pressedOverlayGradient[i] = new GradientDrawable(orientation, new int[] {0x32000000, 0}); pressedOverlayGradient[i] = new GradientDrawable(orientation, new int[]{0x32000000, 0});
pressedOverlayGradient[i].setShape(GradientDrawable.RECTANGLE); pressedOverlayGradient[i].setShape(GradientDrawable.RECTANGLE);
} }
@ -1279,7 +1281,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
removeSelfFromStack(); removeSelfFromStack();
}); });
presentFragment(fragment); presentFragment(fragment);
} else if (id == share) { } else if (id == share || id == qr_code) {
try { try {
String text = null; String text = null;
if (user_id != 0) { if (user_id != 0) {
@ -1287,7 +1289,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
if (user == null) { if (user == null) {
return; return;
} }
if (botInfo != null && userInfo != null && !TextUtils.isEmpty(userInfo.about)) { if (botInfo != null && userInfo != null && !TextUtils.isEmpty(userInfo.about) && id == share) {
text = String.format("%s https://" + MessagesController.getInstance(currentAccount).linkPrefix + "/%s", userInfo.about, user.username); text = String.format("%s https://" + MessagesController.getInstance(currentAccount).linkPrefix + "/%s", userInfo.about, user.username);
} else { } else {
text = String.format("https://" + MessagesController.getInstance(currentAccount).linkPrefix + "/%s", user.username); text = String.format("https://" + MessagesController.getInstance(currentAccount).linkPrefix + "/%s", user.username);
@ -1297,7 +1299,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
if (chat == null) { if (chat == null) {
return; return;
} }
if (chatInfo != null && !TextUtils.isEmpty(chatInfo.about)) { if (chatInfo != null && !TextUtils.isEmpty(chatInfo.about) && id == share) {
text = String.format("%s\nhttps://" + MessagesController.getInstance(currentAccount).linkPrefix + "/%s", chatInfo.about, chat.username); text = String.format("%s\nhttps://" + MessagesController.getInstance(currentAccount).linkPrefix + "/%s", chatInfo.about, chat.username);
} else { } else {
text = String.format("https://" + MessagesController.getInstance(currentAccount).linkPrefix + "/%s", chat.username); text = String.format("https://" + MessagesController.getInstance(currentAccount).linkPrefix + "/%s", chat.username);
@ -1306,10 +1308,14 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
if (TextUtils.isEmpty(text)) { if (TextUtils.isEmpty(text)) {
return; return;
} }
Intent intent = new Intent(Intent.ACTION_SEND); if (id == share) {
intent.setType("text/plain"); Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, text); intent.setType("text/plain");
startActivityForResult(Intent.createChooser(intent, LocaleController.getString("BotShare", R.string.BotShare)), 500); intent.putExtra(Intent.EXTRA_TEXT, text);
startActivityForResult(Intent.createChooser(intent, LocaleController.getString("BotShare", R.string.BotShare)), 500);
} else {
ProxyUtil.showQrDialog(getParentActivity(), text);
}
} catch (Exception e) { } catch (Exception e) {
FileLog.e(e); FileLog.e(e);
} }
@ -2031,6 +2037,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
idTextView.setTextSize(14); idTextView.setTextSize(14);
idTextView.setGravity(Gravity.LEFT); idTextView.setGravity(Gravity.LEFT);
idTextView.setAlpha(1.0f); idTextView.setAlpha(1.0f);
frameLayout.addView(idTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 118, 0, 48, 0)); frameLayout.addView(idTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 118, 0, 48, 0));
updateProfileData(); updateProfileData();
@ -2040,7 +2047,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
Drawable drawable = Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(56), Theme.getColor(Theme.key_profile_actionBackground), Theme.getColor(Theme.key_profile_actionPressedBackground)); Drawable drawable = Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(56), Theme.getColor(Theme.key_profile_actionBackground), Theme.getColor(Theme.key_profile_actionPressedBackground));
if (Build.VERSION.SDK_INT < 21) { if (Build.VERSION.SDK_INT < 21) {
Drawable shadowDrawable = context.getResources().getDrawable(R.drawable.floating_shadow_profile).mutate(); Drawable shadowDrawable = context.getResources().getDrawable(R.drawable.floating_shadow_profile).mutate();
shadowDrawable.setColorFilter(new PorterDuffColorFilter(0xff000000, PorterDuff.Mode.MULTIPLY)); shadowDrawable.setColorFilter(new PorterDuffColorFilter(0xff000000, PorterDuff.Mode.SRC_IN));
CombinedDrawable combinedDrawable = new CombinedDrawable(shadowDrawable, drawable, 0, 0); CombinedDrawable combinedDrawable = new CombinedDrawable(shadowDrawable, drawable, 0, 0);
combinedDrawable.setIconSize(AndroidUtilities.dp(56), AndroidUtilities.dp(56)); combinedDrawable.setIconSize(AndroidUtilities.dp(56), AndroidUtilities.dp(56));
drawable = combinedDrawable; drawable = combinedDrawable;
@ -2048,7 +2055,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
writeButton.setBackgroundDrawable(drawable); writeButton.setBackgroundDrawable(drawable);
writeButton.setImageResource(R.drawable.profile_newmsg); writeButton.setImageResource(R.drawable.profile_newmsg);
writeButton.setContentDescription(LocaleController.getString("AccDescrOpenChat", R.string.AccDescrOpenChat)); writeButton.setContentDescription(LocaleController.getString("AccDescrOpenChat", R.string.AccDescrOpenChat));
writeButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_profile_actionIcon), PorterDuff.Mode.MULTIPLY)); writeButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_profile_actionIcon), PorterDuff.Mode.SRC_IN));
writeButton.setScaleType(ImageView.ScaleType.CENTER); writeButton.setScaleType(ImageView.ScaleType.CENTER);
if (Build.VERSION.SDK_INT >= 21) { if (Build.VERSION.SDK_INT >= 21) {
StateListAnimator animator = new StateListAnimator(); StateListAnimator animator = new StateListAnimator();
@ -2065,7 +2072,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
} }
frameLayout.addView(writeButton, LayoutHelper.createFrame(Build.VERSION.SDK_INT >= 21 ? 56 : 60, Build.VERSION.SDK_INT >= 21 ? 56 : 60, Gravity.RIGHT | Gravity.TOP, 0, 0, 16, 0)); frameLayout.addView(writeButton, LayoutHelper.createFrame(Build.VERSION.SDK_INT >= 21 ? 56 : 60, Build.VERSION.SDK_INT >= 21 ? 56 : 60, Gravity.RIGHT | Gravity.TOP, 0, 0, 16, 0));
writeButton.setOnClickListener(v -> { writeButton.setOnClickListener(v -> {
if (playProfileAnimation != 0 && parentLayout.fragmentsStack.get(parentLayout.fragmentsStack.size() - 2) instanceof ChatActivity) { if (playProfileAnimation != 0 && parentLayout.fragmentsStack.get(parentLayout.fragmentsStack.size() - 2) instanceof ChatActivity && !AndroidUtilities.isTablet()) {
finishFragment(); finishFragment();
} else { } else {
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(user_id); TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(user_id);
@ -2134,7 +2141,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
} }
if (lockIconDrawable != null) { if (lockIconDrawable != null) {
lockIconDrawable.setColorFilter(ColorUtils.blendARGB(Theme.getColor(Theme.key_chat_lockIcon), Color.WHITE, value), PorterDuff.Mode.MULTIPLY); lockIconDrawable.setColorFilter(ColorUtils.blendARGB(Theme.getColor(Theme.key_chat_lockIcon), Color.WHITE, value), PorterDuff.Mode.SRC_IN);
} }
if (verifiedCrossfadeDrawable != null) { if (verifiedCrossfadeDrawable != null) {
@ -2256,6 +2263,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
} }
} }
} }
public boolean onMemberClick(TLRPC.ChatParticipant participant, boolean isLong) { public boolean onMemberClick(TLRPC.ChatParticipant participant, boolean isLong) {
return onMemberClick(participant, isLong, false); return onMemberClick(participant, isLong, false);
} }
@ -2303,7 +2311,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
return true; return true;
} }
items.add(editingAdmin ? LocaleController.getString("EditAdminRights", R.string.EditAdminRights) : LocaleController.getString("SetAsAdmin", R.string.SetAsAdmin)); items.add(editingAdmin ? LocaleController.getString("EditAdminRights", R.string.EditAdminRights) : LocaleController.getString("SetAsAdmin", R.string.SetAsAdmin));
icons.add(R.drawable.actions_addadmin); icons.add(R.drawable.baseline_stars_18);
actions.add(0); actions.add(0);
} }
if (canRestrict) { if (canRestrict) {
@ -2311,7 +2319,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
return true; return true;
} }
items.add(LocaleController.getString("ChangePermissions", R.string.ChangePermissions)); items.add(LocaleController.getString("ChangePermissions", R.string.ChangePermissions));
icons.add(R.drawable.actions_permissions); icons.add(R.drawable.baseline_block_24);
actions.add(1); actions.add(1);
} }
if (allowKick) { if (allowKick) {
@ -2319,7 +2327,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
return true; return true;
} }
items.add(LocaleController.getString("KickFromGroup", R.string.KickFromGroup)); items.add(LocaleController.getString("KickFromGroup", R.string.KickFromGroup));
icons.add(R.drawable.actions_remove_user); icons.add(R.drawable.baseline_remove_circle_24);
actions.add(2); actions.add(2);
hasRemove = true; hasRemove = true;
} }
@ -2338,7 +2346,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
int action = actions.get(i); int action = actions.get(i);
if (action == 1 && (channelParticipant instanceof TLRPC.TL_channelParticipantAdmin || participant instanceof TLRPC.TL_chatParticipantAdmin)) { if (action == 1 && (channelParticipant instanceof TLRPC.TL_channelParticipantAdmin || participant instanceof TLRPC.TL_chatParticipantAdmin)) {
AlertDialog.Builder builder2 = new AlertDialog.Builder(getParentActivity()); AlertDialog.Builder builder2 = new AlertDialog.Builder(getParentActivity());
builder2.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder2.setTitle(LocaleController.getString("NekoX", R.string.NekoX));
builder2.setMessage(LocaleController.formatString("AdminWillBeRemoved", R.string.AdminWillBeRemoved, ContactsController.formatName(user.first_name, user.last_name))); builder2.setMessage(LocaleController.formatString("AdminWillBeRemoved", R.string.AdminWillBeRemoved, ContactsController.formatName(user.first_name, user.last_name)));
builder2.setPositiveButton(LocaleController.getString("OK", R.string.OK), (dialog, which) -> { builder2.setPositiveButton(LocaleController.getString("OK", R.string.OK), (dialog, which) -> {
if (channelParticipant != null) { if (channelParticipant != null) {
@ -2488,7 +2496,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
} else if (position == phoneRow) { } else if (position == phoneRow) {
final TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(user_id); final TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(user_id);
if (user == null || user.phone == null || user.phone.length() == 0 || getParentActivity() == null if (user == null || user.phone == null || user.phone.length() == 0 || getParentActivity() == null
|| (NekoConfig.hidePhone && user.id == UserConfig.getInstance(currentAccount).getClientUserId())) { || (NekoConfig.hidePhone && user.id == UserConfig.getInstance(currentAccount).getClientUserId())) {
return false; return false;
} }
@ -2627,7 +2635,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
int c = AndroidUtilities.getOffsetColor(color1, color2, value, 1.0f); int c = AndroidUtilities.getOffsetColor(color1, color2, value, 1.0f);
nameTextView[1].setTextColor(c); nameTextView[1].setTextColor(c);
if (lockIconDrawable != null) { if (lockIconDrawable != null) {
lockIconDrawable.setColorFilter(c, PorterDuff.Mode.MULTIPLY); lockIconDrawable.setColorFilter(c, PorterDuff.Mode.SRC_IN);
} }
if (scamDrawable != null) { if (scamDrawable != null) {
color1 = Theme.getColor(Theme.key_avatar_subtitleInProfileBlue); color1 = Theme.getColor(Theme.key_avatar_subtitleInProfileBlue);
@ -2650,13 +2658,13 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
if (verifiedDrawable != null) { if (verifiedDrawable != null) {
color1 = Theme.getColor(Theme.key_profile_verifiedBackground); color1 = Theme.getColor(Theme.key_profile_verifiedBackground);
color2 = Theme.getColor(Theme.key_player_actionBarTitle); color2 = Theme.getColor(Theme.key_player_actionBarTitle);
verifiedDrawable.setColorFilter(AndroidUtilities.getOffsetColor(color1, color2, value, 1.0f), PorterDuff.Mode.MULTIPLY); verifiedDrawable.setColorFilter(AndroidUtilities.getOffsetColor(color1, color2, value, 1.0f), PorterDuff.Mode.SRC_IN);
} }
if (verifiedCheckDrawable != null) { if (verifiedCheckDrawable != null) {
color1 = Theme.getColor(Theme.key_profile_verifiedCheck); color1 = Theme.getColor(Theme.key_profile_verifiedCheck);
color2 = Theme.getColor(Theme.key_windowBackgroundWhite); color2 = Theme.getColor(Theme.key_windowBackgroundWhite);
verifiedCheckDrawable.setColorFilter(AndroidUtilities.getOffsetColor(color1, color2, value, 1.0f), PorterDuff.Mode.MULTIPLY); verifiedCheckDrawable.setColorFilter(AndroidUtilities.getOffsetColor(color1, color2, value, 1.0f), PorterDuff.Mode.SRC_IN);
} }
} }
@ -3038,7 +3046,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
scamDrawable.setColor(ColorUtils.blendARGB(Theme.getColor(Theme.key_avatar_subtitleInProfileBlue), Color.argb(179, 255, 255, 255), animationProgress)); scamDrawable.setColor(ColorUtils.blendARGB(Theme.getColor(Theme.key_avatar_subtitleInProfileBlue), Color.argb(179, 255, 255, 255), animationProgress));
} }
if (lockIconDrawable != null) { if (lockIconDrawable != null) {
lockIconDrawable.setColorFilter(ColorUtils.blendARGB(Theme.getColor(Theme.key_chat_lockIcon), Color.WHITE, animationProgress), PorterDuff.Mode.MULTIPLY); lockIconDrawable.setColorFilter(ColorUtils.blendARGB(Theme.getColor(Theme.key_chat_lockIcon), Color.WHITE, animationProgress), PorterDuff.Mode.SRC_IN);
} }
if (verifiedCrossfadeDrawable != null) { if (verifiedCrossfadeDrawable != null) {
verifiedCrossfadeDrawable.setProgress(animationProgress); verifiedCrossfadeDrawable.setProgress(animationProgress);
@ -3085,7 +3093,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
nameTextView[a].setScaleY(nameScale); nameTextView[a].setScaleY(nameScale);
} }
if (diff > 0.85) { if (diff > 0.85 && NekoConfig.showIdAndDc) {
idTextView.setVisibility(View.VISIBLE); idTextView.setVisibility(View.VISIBLE);
} else { } else {
idTextView.setVisibility(View.GONE); idTextView.setVisibility(View.GONE);
@ -3287,7 +3295,9 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
TLRPC.EncryptedChat encryptedChat = (TLRPC.EncryptedChat) args[0]; TLRPC.EncryptedChat encryptedChat = (TLRPC.EncryptedChat) args[0];
Bundle args2 = new Bundle(); Bundle args2 = new Bundle();
args2.putInt("enc_id", encryptedChat.id); args2.putInt("enc_id", encryptedChat.id);
presentFragment(new ChatActivity(args2), true); if (MessagesController.getInstance(currentAccount).checkCanOpenChat(args2, ProfileActivity.this)) {
presentFragment(new ChatActivity(args2), true);
}
}); });
} }
} else if (id == NotificationCenter.encryptedChatUpdated) { } else if (id == NotificationCenter.encryptedChatUpdated) {
@ -3365,7 +3375,9 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
FileLog.e(e); FileLog.e(e);
} }
} }
sharedMediaLayout.setCommonGroupsCount(userInfo.common_chats_count); if (sharedMediaLayout != null) {
sharedMediaLayout.setCommonGroupsCount(userInfo.common_chats_count);
}
updateSelectedMediaTabText(); updateSelectedMediaTabText();
} }
} else if (id == NotificationCenter.didReceiveNewMessages) { } else if (id == NotificationCenter.didReceiveNewMessages) {
@ -4348,39 +4360,40 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
if (isBot || ContactsController.getInstance(currentAccount).contactsDict.get(user_id) == null) { if (isBot || ContactsController.getInstance(currentAccount).contactsDict.get(user_id) == null) {
if (MessagesController.isSupportUser(user)) { if (MessagesController.isSupportUser(user)) {
if (userBlocked) { if (userBlocked) {
otherItem.addSubItem(block_contact, R.drawable.msg_block, LocaleController.getString("Unblock", R.string.Unblock)); otherItem.addSubItem(block_contact, R.drawable.baseline_block_24, LocaleController.getString("Unblock", R.string.Unblock));
} }
} else { } else {
if (isBot) { if (isBot) {
if (!user.bot_nochats) { if (!user.bot_nochats) {
otherItem.addSubItem(invite_to_group, R.drawable.msg_addbot, LocaleController.getString("BotInvite", R.string.BotInvite)); otherItem.addSubItem(invite_to_group, R.drawable.baseline_group_add_24, LocaleController.getString("BotInvite", R.string.BotInvite));
} }
otherItem.addSubItem(share, R.drawable.msg_share, LocaleController.getString("BotShare", R.string.BotShare)); otherItem.addSubItem(share, R.drawable.baseline_forward_24, LocaleController.getString("BotShare", R.string.BotShare));
otherItem.addSubItem(qr_code, R.drawable.wallet_qr, LocaleController.getString("ShareQRCode", R.string.ShareQRCode));
} else { } else {
otherItem.addSubItem(add_contact, R.drawable.msg_addcontact, LocaleController.getString("AddContact", R.string.AddContact)); otherItem.addSubItem(add_contact, R.drawable.baseline_person_add_24, LocaleController.getString("AddContact", R.string.AddContact));
} }
if (!TextUtils.isEmpty(user.phone)) { if (!TextUtils.isEmpty(user.phone)) {
otherItem.addSubItem(share_contact, R.drawable.msg_share, LocaleController.getString("ShareContact", R.string.ShareContact)); otherItem.addSubItem(share_contact, R.drawable.baseline_forward_24, LocaleController.getString("ShareContact", R.string.ShareContact));
} }
if (isBot) { if (isBot) {
otherItem.addSubItem(block_contact, !userBlocked ? R.drawable.msg_block : R.drawable.msg_retry, !userBlocked ? LocaleController.getString("BotStop", R.string.BotStop) : LocaleController.getString("BotRestart", R.string.BotRestart)); otherItem.addSubItem(block_contact, !userBlocked ? R.drawable.baseline_block_24 : R.drawable.baseline_replay_24, !userBlocked ? LocaleController.getString("BotStop", R.string.BotStop) : LocaleController.getString("BotRestart", R.string.BotRestart));
} else { } else {
otherItem.addSubItem(block_contact, !userBlocked ? R.drawable.msg_block : R.drawable.msg_block, !userBlocked ? LocaleController.getString("BlockContact", R.string.BlockContact) : LocaleController.getString("Unblock", R.string.Unblock)); otherItem.addSubItem(block_contact, !userBlocked ? R.drawable.baseline_block_24 : R.drawable.baseline_block_24, !userBlocked ? LocaleController.getString("BlockContact", R.string.BlockContact) : LocaleController.getString("Unblock", R.string.Unblock));
} }
} }
} else { } else {
if (!TextUtils.isEmpty(user.phone)) { if (!TextUtils.isEmpty(user.phone)) {
otherItem.addSubItem(share_contact, R.drawable.msg_share, LocaleController.getString("ShareContact", R.string.ShareContact)); otherItem.addSubItem(share_contact, R.drawable.baseline_forward_24, LocaleController.getString("ShareContact", R.string.ShareContact));
} }
otherItem.addSubItem(block_contact, !userBlocked ? R.drawable.msg_block : R.drawable.msg_block, !userBlocked ? LocaleController.getString("BlockContact", R.string.BlockContact) : LocaleController.getString("Unblock", R.string.Unblock)); otherItem.addSubItem(block_contact, !userBlocked ? R.drawable.baseline_block_24 : R.drawable.baseline_block_24, !userBlocked ? LocaleController.getString("BlockContact", R.string.BlockContact) : LocaleController.getString("Unblock", R.string.Unblock));
otherItem.addSubItem(edit_contact, R.drawable.msg_edit, LocaleController.getString("EditContact", R.string.EditContact)); otherItem.addSubItem(edit_contact, R.drawable.baseline_edit_24, LocaleController.getString("EditContact", R.string.EditContact));
otherItem.addSubItem(delete_contact, R.drawable.msg_delete, LocaleController.getString("DeleteContact", R.string.DeleteContact)); otherItem.addSubItem(delete_contact, R.drawable.baseline_delete_24, LocaleController.getString("DeleteContact", R.string.DeleteContact));
} }
} else { } else {
otherItem.addSubItem(share_contact, R.drawable.msg_share, LocaleController.getString("ShareContact", R.string.ShareContact)); otherItem.addSubItem(share_contact, R.drawable.baseline_forward_24, LocaleController.getString("ShareContact", R.string.ShareContact));
} }
if (!UserObject.isDeleted(user) && !isBot && currentEncryptedChat == null && user_id != getUserConfig().getClientUserId() && !userBlocked && user_id != 333000 && user_id != 777000 && user_id != 42777) { if (!UserObject.isDeleted(user) && !isBot && currentEncryptedChat == null && user_id != getUserConfig().getClientUserId() && !userBlocked && user_id != 333000 && user_id != 777000 && user_id != 42777) {
otherItem.addSubItem(start_secret_chat, R.drawable.msg_start_secret, LocaleController.getString("StartEncryptedChat", R.string.StartEncryptedChat)); otherItem.addSubItem(start_secret_chat, R.drawable.deproko_baseline_lock_24, LocaleController.getString("StartEncryptedChat", R.string.StartEncryptedChat));
} }
} else if (chat_id != 0) { } else if (chat_id != 0) {
if (chat_id > 0) { if (chat_id > 0) {
@ -4392,18 +4405,19 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
if (!chat.megagroup && chatInfo != null && chatInfo.can_view_stats) { if (!chat.megagroup && chatInfo != null && chatInfo.can_view_stats) {
otherItem.addSubItem(statistics, R.drawable.msg_stats, LocaleController.getString("Statistics", R.string.Statistics)); otherItem.addSubItem(statistics, R.drawable.msg_stats, LocaleController.getString("Statistics", R.string.Statistics));
} }
if (!TextUtils.isEmpty(chat.username)) {
otherItem.addSubItem(share, R.drawable.baseline_forward_24, LocaleController.getString("BotShare", R.string.BotShare));
otherItem.addSubItem(qr_code, R.drawable.wallet_qr, LocaleController.getString("ShareQRCode", R.string.ShareQRCode));
}
if (chat.megagroup) { if (chat.megagroup) {
canSearchMembers = true; canSearchMembers = true;
otherItem.addSubItem(search_members, R.drawable.msg_search, LocaleController.getString("SearchMembers", R.string.SearchMembers)); otherItem.addSubItem(search_members, R.drawable.baseline_search_24, LocaleController.getString("SearchMembers", R.string.SearchMembers));
if (!chat.creator && !chat.left && !chat.kicked) { if (!chat.creator && !chat.left && !chat.kicked) {
otherItem.addSubItem(leave_group, R.drawable.msg_leave, LocaleController.getString("LeaveMegaMenu", R.string.LeaveMegaMenu)); otherItem.addSubItem(leave_group, R.drawable.baseline_exit_to_app_24, LocaleController.getString("LeaveMegaMenu", R.string.LeaveMegaMenu));
} }
} else { } else {
if (!TextUtils.isEmpty(chat.username)) {
otherItem.addSubItem(share, R.drawable.msg_share, LocaleController.getString("BotShare", R.string.BotShare));
}
if (!currentChat.creator && !currentChat.left && !currentChat.kicked) { if (!currentChat.creator && !currentChat.left && !currentChat.kicked) {
otherItem.addSubItem(leave_group, R.drawable.msg_leave, LocaleController.getString("LeaveChannelMenu", R.string.LeaveChannelMenu)); otherItem.addSubItem(leave_group, R.drawable.baseline_exit_to_app_24, LocaleController.getString("LeaveChannelMenu", R.string.LeaveChannelMenu));
} }
} }
if (ChatObject.hasAdminRights(currentChat)) { if (ChatObject.hasAdminRights(currentChat)) {
@ -4413,14 +4427,14 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
editItemVisible = true; editItemVisible = true;
if (!ChatObject.isKickedFromChat(chat) && !ChatObject.isLeftFromChat(chat)) { if (!ChatObject.isKickedFromChat(chat) && !ChatObject.isLeftFromChat(chat)) {
canSearchMembers = true; canSearchMembers = true;
otherItem.addSubItem(search_members, R.drawable.msg_search, LocaleController.getString("SearchMembers", R.string.SearchMembers)); otherItem.addSubItem(search_members, R.drawable.baseline_search_24, LocaleController.getString("SearchMembers", R.string.SearchMembers));
} }
otherItem.addSubItem(leave_group, R.drawable.msg_leave, LocaleController.getString("DeleteAndExit", R.string.DeleteAndExit)); otherItem.addSubItem(leave_group, R.drawable.baseline_exit_to_app_24, LocaleController.getString("DeleteAndExit", R.string.DeleteAndExit));
} }
} }
} }
otherItem.addSubItem(add_shortcut, R.drawable.msg_home, LocaleController.getString("AddShortcut", R.string.AddShortcut)); otherItem.addSubItem(add_shortcut, R.drawable.baseline_home_24, LocaleController.getString("AddShortcut", R.string.AddShortcut));
otherItem.addSubItem(gallery_menu_save, R.drawable.msg_gallery, LocaleController.getString("SaveToGallery", R.string.SaveToGallery)); otherItem.addSubItem(gallery_menu_save, R.drawable.baseline_image_24, LocaleController.getString("SaveToGallery", R.string.SaveToGallery));
if (!isPulledDown) { if (!isPulledDown) {
otherItem.hideSubItem(gallery_menu_save); otherItem.hideSubItem(gallery_menu_save);
} }
@ -4742,22 +4756,22 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
} else if (position == subscribersRow) { } else if (position == subscribersRow) {
if (chatInfo != null) { if (chatInfo != null) {
if (ChatObject.isChannel(currentChat) && !currentChat.megagroup) { if (ChatObject.isChannel(currentChat) && !currentChat.megagroup) {
textCell.setTextAndValueAndIcon(LocaleController.getString("ChannelSubscribers", R.string.ChannelSubscribers), String.format("%d", chatInfo.participants_count), R.drawable.actions_viewmembers, position != membersSectionRow - 1); textCell.setTextAndValueAndIcon(LocaleController.getString("ChannelSubscribers", R.string.ChannelSubscribers), String.format("%d", chatInfo.participants_count), R.drawable.baseline_group_24, position != membersSectionRow - 1);
} else { } else {
textCell.setTextAndValueAndIcon(LocaleController.getString("ChannelMembers", R.string.ChannelMembers), String.format("%d", chatInfo.participants_count), R.drawable.actions_viewmembers, position != membersSectionRow - 1); textCell.setTextAndValueAndIcon(LocaleController.getString("ChannelMembers", R.string.ChannelMembers), String.format("%d", chatInfo.participants_count), R.drawable.baseline_group_24, position != membersSectionRow - 1);
} }
} else { } else {
if (ChatObject.isChannel(currentChat) && !currentChat.megagroup) { if (ChatObject.isChannel(currentChat) && !currentChat.megagroup) {
textCell.setTextAndIcon(LocaleController.getString("ChannelSubscribers", R.string.ChannelSubscribers), R.drawable.actions_viewmembers, position != membersSectionRow - 1); textCell.setTextAndIcon(LocaleController.getString("ChannelSubscribers", R.string.ChannelSubscribers), R.drawable.baseline_group_24, position != membersSectionRow - 1);
} else { } else {
textCell.setTextAndIcon(LocaleController.getString("ChannelMembers", R.string.ChannelMembers), R.drawable.actions_viewmembers, position != membersSectionRow - 1); textCell.setTextAndIcon(LocaleController.getString("ChannelMembers", R.string.ChannelMembers), R.drawable.baseline_group_24, position != membersSectionRow - 1);
} }
} }
} else if (position == administratorsRow) { } else if (position == administratorsRow) {
if (chatInfo != null) { if (chatInfo != null) {
textCell.setTextAndValueAndIcon(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators), String.format("%d", chatInfo.admins_count), R.drawable.actions_addadmin, position != membersSectionRow - 1); textCell.setTextAndValueAndIcon(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators), String.format("%d", chatInfo.admins_count), R.drawable.baseline_stars_18, position != membersSectionRow - 1);
} else { } else {
textCell.setTextAndIcon(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators), R.drawable.actions_addadmin, position != membersSectionRow - 1); textCell.setTextAndIcon(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators), R.drawable.baseline_stars_18, position != membersSectionRow - 1);
} }
} else if (position == blockedUsersRow) { } else if (position == blockedUsersRow) {
if (chatInfo != null) { if (chatInfo != null) {
@ -4767,7 +4781,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
} }
} else if (position == addMemberRow) { } else if (position == addMemberRow) {
textCell.setColors(Theme.key_windowBackgroundWhiteBlueIcon, Theme.key_windowBackgroundWhiteBlueButton); textCell.setColors(Theme.key_windowBackgroundWhiteBlueIcon, Theme.key_windowBackgroundWhiteBlueButton);
textCell.setTextAndIcon(LocaleController.getString("AddMember", R.string.AddMember), R.drawable.actions_addmember2, membersSectionRow == -1); textCell.setTextAndIcon(LocaleController.getString("AddMember", R.string.AddMember), R.drawable.baseline_person_add_24, membersSectionRow == -1);
} else if (position == sendMessageRow) { } else if (position == sendMessageRow) {
textCell.setText(LocaleController.getString("SendMessageLocation", R.string.SendMessageLocation), true); textCell.setText(LocaleController.getString("SendMessageLocation", R.string.SendMessageLocation), true);
} else if (position == reportRow) { } else if (position == reportRow) {
@ -4951,7 +4965,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
onlineTextView[1].setTextColor(Theme.getColor((String) onlineTextViewTag)); onlineTextView[1].setTextColor(Theme.getColor((String) onlineTextViewTag));
} }
if (lockIconDrawable != null) { if (lockIconDrawable != null) {
lockIconDrawable.setColorFilter(Theme.getColor(Theme.key_chat_lockIcon), PorterDuff.Mode.MULTIPLY); lockIconDrawable.setColorFilter(Theme.getColor(Theme.key_chat_lockIcon), PorterDuff.Mode.SRC_IN);
} }
if (scamDrawable != null) { if (scamDrawable != null) {
scamDrawable.setColor(Theme.getColor(Theme.key_avatar_subtitleInProfileBlue)); scamDrawable.setColor(Theme.getColor(Theme.key_avatar_subtitleInProfileBlue));

View File

@ -66,6 +66,8 @@ import org.telegram.ui.Components.VideoPlayer;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import tw.nekomimi.nekogram.NekoXConfig;
public class SecretMediaViewer implements NotificationCenter.NotificationCenterDelegate, GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener { public class SecretMediaViewer implements NotificationCenter.NotificationCenterDelegate, GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener {
private class FrameLayoutDrawer extends FrameLayout { private class FrameLayoutDrawer extends FrameLayout {
@ -653,7 +655,9 @@ public class SecretMediaViewer implements NotificationCenter.NotificationCenterD
} else { } else {
windowLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; windowLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
} }
windowLayoutParams.flags |= WindowManager.LayoutParams.FLAG_SECURE; if (!NekoXConfig.disableFlagSecure) {
windowLayoutParams.flags |= WindowManager.LayoutParams.FLAG_SECURE;
}
centerImage.setParentView(containerView); centerImage.setParentView(containerView);
centerImage.setForceCrossfade(true); centerImage.setForceCrossfade(true);
} }

View File

@ -8,11 +8,15 @@
package org.telegram.ui; package org.telegram.ui;
import android.Manifest;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.os.Build;
import android.text.SpannableStringBuilder; import android.text.SpannableStringBuilder;
import android.text.Spanned; import android.text.Spanned;
import android.text.TextUtils; import android.text.TextUtils;
@ -24,14 +28,30 @@ import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.collection.LongSparseArray;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.DiffUtil;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.ListUpdateCallback;
import androidx.recyclerview.widget.RecyclerView;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.internal.Streams;
import com.google.gson.stream.JsonWriter;
import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.MediaDataController;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MediaDataController;
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.SendMessagesHelper;
import org.telegram.messenger.SharedConfig; import org.telegram.messenger.SharedConfig;
import org.telegram.tgnet.ConnectionsManager; import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.TLRPC; import org.telegram.tgnet.TLRPC;
@ -60,24 +80,30 @@ import org.telegram.ui.Components.TrendingStickersAlert;
import org.telegram.ui.Components.TrendingStickersLayout; import org.telegram.ui.Components.TrendingStickersLayout;
import org.telegram.ui.Components.URLSpanNoUnderline; import org.telegram.ui.Components.URLSpanNoUnderline;
import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import androidx.annotation.NonNull; import kotlin.Unit;
import androidx.annotation.Nullable; import tw.nekomimi.nekogram.BottomBuilder;
import androidx.collection.LongSparseArray; import tw.nekomimi.nekogram.utils.AlertUtil;
import androidx.recyclerview.widget.DefaultItemAnimator; import tw.nekomimi.nekogram.utils.FileUtil;
import androidx.recyclerview.widget.DiffUtil; import tw.nekomimi.nekogram.utils.ShareUtil;
import androidx.recyclerview.widget.ItemTouchHelper; import tw.nekomimi.nekogram.utils.StickersUtil;
import androidx.recyclerview.widget.LinearLayoutManager; import tw.nekomimi.nekogram.utils.UIUtil;
import androidx.recyclerview.widget.ListUpdateCallback;
import androidx.recyclerview.widget.RecyclerView;
public class StickersActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate { public class StickersActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
private static final int MENU_ARCHIVE = 0; private static final int MENU_ARCHIVE = 0;
private static final int MENU_DELETE = 1; private static final int MENU_DELETE = 1;
private static final int MENU_EXPORT = 5;
private RecyclerListView listView; private RecyclerListView listView;
private ListAdapter listAdapter; private ListAdapter listAdapter;
@ -88,6 +114,7 @@ public class StickersActivity extends BaseFragment implements NotificationCenter
private NumberTextView selectedCountTextView; private NumberTextView selectedCountTextView;
private TrendingStickersAlert trendingStickersAlert; private TrendingStickersAlert trendingStickersAlert;
private ActionBarMenuItem exportMenuItem;
private ActionBarMenuItem archiveMenuItem; private ActionBarMenuItem archiveMenuItem;
private ActionBarMenuItem deleteMenuItem; private ActionBarMenuItem deleteMenuItem;
@ -166,6 +193,13 @@ public class StickersActivity extends BaseFragment implements NotificationCenter
currentType = type; currentType = type;
} }
private File stickersFile;
public StickersActivity(File stickersFile) {
this(MediaDataController.TYPE_IMAGE);
this.stickersFile = stickersFile;
}
@Override @Override
public boolean onFragmentCreate() { public boolean onFragmentCreate() {
super.onFragmentCreate(); super.onFragmentCreate();
@ -189,6 +223,10 @@ public class StickersActivity extends BaseFragment implements NotificationCenter
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.featuredStickersDidLoad); NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.featuredStickersDidLoad);
} }
private int menu_other = 2;
private int menu_export = 3;
private int menu_import = 4;
@Override @Override
public View createView(Context context) { public View createView(Context context) {
actionBar.setBackButtonDrawable(new BackDrawable(false)); actionBar.setBackButtonDrawable(new BackDrawable(false));
@ -205,7 +243,7 @@ public class StickersActivity extends BaseFragment implements NotificationCenter
if (onBackPressed()) { if (onBackPressed()) {
finishFragment(); finishFragment();
} }
} else if (id == MENU_ARCHIVE || id == MENU_DELETE) { } else if (id == MENU_EXPORT || id == MENU_ARCHIVE || id == MENU_DELETE) {
if (!needReorder) { if (!needReorder) {
if (activeReorderingRequests == 0) { if (activeReorderingRequests == 0) {
listAdapter.processSelectionMenu(id); listAdapter.processSelectionMenu(id);
@ -213,10 +251,45 @@ public class StickersActivity extends BaseFragment implements NotificationCenter
} else { } else {
sendReorder(); sendReorder();
} }
} else if (id == menu_export) {
exportStickers();
} else if (id == menu_import) {
try {
if (Build.VERSION.SDK_INT >= 23 && getParentActivity().checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
getParentActivity().requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 4);
return;
}
} catch (Throwable ignore) {
}
DocumentSelectActivity fragment = new DocumentSelectActivity(false);
fragment.setMaxSelectedFiles(1);
fragment.setAllowPhoto(false);
fragment.setDelegate(new DocumentSelectActivity.DocumentSelectActivityDelegate() {
@Override
public void didSelectFiles(DocumentSelectActivity activity, ArrayList<String> files, String caption, boolean notify, int scheduleDate) {
activity.finishFragment();
processStickersFile(new File(files.get(0)), false);
}
@Override
public void didSelectPhotos(ArrayList<SendMessagesHelper.SendingMediaInfo> photos, boolean notify, int scheduleDate) {
}
@Override
public void startDocumentSelectActivity() {
}
});
presentFragment(fragment);
} }
} }
}); });
ActionBarMenu menu = actionBar.createMenu();
ActionBarMenuItem otherItem = menu.addItem(menu_other, R.drawable.ic_ab_other);
otherItem.addSubItem(menu_export, R.drawable.baseline_file_download_24, LocaleController.getString("ExportStickers", R.string.ExportStickers));
otherItem.addSubItem(menu_import, R.drawable.baseline_playlist_add_24, LocaleController.getString("ImportStickers", R.string.ImportStickers));
final ActionBarMenu actionMode = actionBar.createActionMode(); final ActionBarMenu actionMode = actionBar.createActionMode();
selectedCountTextView = new NumberTextView(actionMode.getContext()); selectedCountTextView = new NumberTextView(actionMode.getContext());
@ -226,8 +299,9 @@ public class StickersActivity extends BaseFragment implements NotificationCenter
actionMode.addView(selectedCountTextView, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1.0f, 72, 0, 0, 0)); actionMode.addView(selectedCountTextView, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1.0f, 72, 0, 0, 0));
selectedCountTextView.setOnTouchListener((v, event) -> true); selectedCountTextView.setOnTouchListener((v, event) -> true);
archiveMenuItem = actionMode.addItemWithWidth(MENU_ARCHIVE, R.drawable.msg_archive, AndroidUtilities.dp(54)); exportMenuItem = actionMode.addItemWithWidth(MENU_EXPORT, R.drawable.baseline_file_download_24, AndroidUtilities.dp(54));
deleteMenuItem = actionMode.addItemWithWidth(MENU_DELETE, R.drawable.msg_delete, AndroidUtilities.dp(54)); archiveMenuItem = actionMode.addItemWithWidth(MENU_ARCHIVE, R.drawable.baseline_archive_24, AndroidUtilities.dp(54));
deleteMenuItem = actionMode.addItemWithWidth(MENU_DELETE, R.drawable.baseline_delete_24, AndroidUtilities.dp(54));
listAdapter = new ListAdapter(context, MediaDataController.getInstance(currentAccount).getStickerSets(currentType)); listAdapter = new ListAdapter(context, MediaDataController.getInstance(currentAccount).getStickerSets(currentType));
@ -333,10 +407,175 @@ public class StickersActivity extends BaseFragment implements NotificationCenter
} }
}); });
if (stickersFile != null) {
processStickersFile(stickersFile, true);
stickersFile = null;
}
return fragmentView; return fragmentView;
} }
public void processStickersFile(File file, boolean exitOnFail) {
if (!file.isFile() || !file.getName().endsWith("nekox-stickers.json")) {
showError("not a stickers file", exitOnFail);
return;
} else if (file.length() > 3 * 1024 * 1024L) {
showError("file too large", exitOnFail);
return;
}
AlertDialog pro = new AlertDialog(getParentActivity(), 1);
pro.show();
UIUtil.runOnIoDispatcher(() -> {
JsonObject stickerObj = new Gson().fromJson(FileUtil.readUtf8String(file), JsonObject.class);
StickersUtil.importStickers(stickerObj, this, pro);
UIUtil.runOnUIThread(() -> {
pro.dismiss();
MediaDataController.getInstance(currentAccount).checkStickers(currentType);
updateRows();
});
});
}
private void showError(String msg, boolean exitOnFail) {
AlertUtil.showSimpleAlert(getParentActivity(), LocaleController.getString("InvalidStickersFile", R.string.InvalidStickersFile) + msg, (__) -> {
if (exitOnFail) finishFragment();
return Unit.INSTANCE;
});
}
public void exportStickers() {
BottomBuilder builder = new BottomBuilder(getParentActivity());
builder.addTitle(LocaleController.getString("", R.string.ExportStickers), true);
AtomicBoolean exportSets = new AtomicBoolean(true);
AtomicBoolean exportArchived = new AtomicBoolean(true);
final AtomicReference<TextView> exportButton = new AtomicReference<>();
builder.addCheckItems(new String[]{
LocaleController.getString("StickerSets", R.string.StickerSets),
LocaleController.getString("ArchivedStickers", R.string.ArchivedStickers)
}, (__) -> true, false, (index, text, cell) -> {
boolean export;
switch (index) {
case 0: {
export = exportSets.get();
exportSets.set(export = !export);
}
break;
default: {
export = exportArchived.get();
exportArchived.set(export = !export);
}
break;
}
cell.setChecked(export);
if (!exportSets.get() && !exportArchived.get()) {
exportButton.get().setEnabled(false);
} else {
exportButton.get().setEnabled(true);
}
return Unit.INSTANCE;
});
builder.addCancelButton();
exportButton.set(builder.addButton(LocaleController.getString("Export", R.string.ExportStickers), (it) -> {
builder.dismiss();
exportStickersFinal(exportSets.get(), exportArchived.get());
return Unit.INSTANCE;
}));
builder.show();
}
public void exportStickersFinal(boolean exportSets, boolean exportArchived) {
AlertDialog pro = new AlertDialog(getParentActivity(), 3);
pro.setCanCacnel(false);
pro.show();
UIUtil.runOnIoDispatcher(() -> {
Activity ctx = getParentActivity();
JsonObject exportObj = StickersUtil.exportStickers(currentAccount, exportSets, exportArchived);
File cacheFile = new File(ApplicationLoader.applicationContext.getCacheDir(), new Date().toLocaleString() + ".nekox-stickers.json");
StringWriter stringWriter = new StringWriter();
JsonWriter jsonWriter = new JsonWriter(stringWriter);
jsonWriter.setLenient(true);
jsonWriter.setIndent(" ");
try {
Streams.write(exportObj, jsonWriter);
} catch (IOException e) {
}
FileUtil.writeUtf8String(stringWriter.toString(), cacheFile);
UIUtil.runOnUIThread(() -> {
pro.dismiss();
ShareUtil.shareFile(ctx, cacheFile);
});
});
}
@Override @Override
public boolean onBackPressed() { public boolean onBackPressed() {
@ -558,7 +797,7 @@ public class StickersActivity extends BaseFragment implements NotificationCenter
} }
private void processSelectionMenu(int which) { private void processSelectionMenu(int which) {
if (which == MENU_ARCHIVE || which == MENU_DELETE) { if (which == MENU_EXPORT || which == MENU_ARCHIVE || which == MENU_DELETE) {
final ArrayList<TLRPC.StickerSet> stickerSetList = new ArrayList<>(selectedItems.size()); final ArrayList<TLRPC.StickerSet> stickerSetList = new ArrayList<>(selectedItems.size());
for (int i = 0, size = stickerSets.size(); i < size; i++) { for (int i = 0, size = stickerSets.size(); i < size; i++) {
@ -568,6 +807,38 @@ public class StickersActivity extends BaseFragment implements NotificationCenter
} }
} }
if (which == MENU_EXPORT) {
AlertDialog pro = new AlertDialog(getParentActivity(), 3);
pro.setCanCacnel(false);
pro.show();
UIUtil.runOnIoDispatcher(() -> {
JsonObject exportObj = StickersUtil.exportStickers(stickerSetList);
File cacheFile = new File(ApplicationLoader.applicationContext.getCacheDir(), new Date().toLocaleString() + ".nekox-stickers.json");
StringWriter stringWriter = new StringWriter();
JsonWriter jsonWriter = new JsonWriter(stringWriter);
jsonWriter.setLenient(true);
jsonWriter.setIndent(" ");
try {
Streams.write(exportObj, jsonWriter);
} catch (IOException e) {
}
FileUtil.writeUtf8String(stringWriter.toString(), cacheFile);
UIUtil.runOnUIThread(() -> {
pro.dismiss();
ShareUtil.shareFile(getParentActivity(), cacheFile);
});
});
}
final int count = stickerSetList.size(); final int count = stickerSetList.size();
switch (count) { switch (count) {
@ -785,7 +1056,7 @@ public class StickersActivity extends BaseFragment implements NotificationCenter
LocaleController.getString("StickersHide", R.string.StickersHide), LocaleController.getString("StickersHide", R.string.StickersHide),
LocaleController.getString("StickersReorder", R.string.StickersReorder) LocaleController.getString("StickersReorder", R.string.StickersReorder)
}; };
icons = new int[]{R.drawable.msg_archive, R.drawable.msg_reorder}; icons = new int[]{R.drawable.baseline_archive_24, R.drawable.msg_reorder};
} else { } else {
options = new int[]{MENU_ARCHIVE, 3, 4, 2, MENU_DELETE}; options = new int[]{MENU_ARCHIVE, 3, 4, 2, MENU_DELETE};
items = new CharSequence[]{ items = new CharSequence[]{
@ -796,11 +1067,11 @@ public class StickersActivity extends BaseFragment implements NotificationCenter
LocaleController.getString("StickersRemove", R.string.StickersRemove), LocaleController.getString("StickersRemove", R.string.StickersRemove),
}; };
icons = new int[]{ icons = new int[]{
R.drawable.msg_archive, R.drawable.baseline_archive_24,
R.drawable.msg_link, R.drawable.baseline_link_24,
R.drawable.msg_reorder, R.drawable.msg_reorder,
R.drawable.msg_share, R.drawable.baseline_forward_24,
R.drawable.msg_delete R.drawable.baseline_delete_24
}; };
} }
builder.setItems(items, icons, (dialog, which) -> processSelectionOption(options[which], stickerSet)); builder.setItems(items, icons, (dialog, which) -> processSelectionOption(options[which], stickerSet));

View File

@ -28,18 +28,21 @@ import android.widget.LinearLayout;
import android.widget.ScrollView; import android.widget.ScrollView;
import android.widget.TextView; import android.widget.TextView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.LocaleController; import org.telegram.messenger.LocaleController;
import org.telegram.messenger.NotificationCenter; import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.SRPHelper; import org.telegram.messenger.SRPHelper;
import org.telegram.messenger.UserConfig; import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities;
import org.telegram.messenger.browser.Browser; import org.telegram.messenger.browser.Browser;
import org.telegram.tgnet.ConnectionsManager; import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.RequestDelegate; import org.telegram.tgnet.RequestDelegate;
import org.telegram.tgnet.TLRPC; import org.telegram.tgnet.TLRPC;
import org.telegram.messenger.Utilities;
import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.ActionBar.ActionBarMenuItem; import org.telegram.ui.ActionBar.ActionBarMenuItem;
@ -58,9 +61,6 @@ import org.telegram.ui.Components.RecyclerListView;
import java.util.ArrayList; import java.util.ArrayList;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import tw.nekomimi.nekogram.EditTextAutoFill; import tw.nekomimi.nekogram.EditTextAutoFill;
public class TwoStepVerificationActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate { public class TwoStepVerificationActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
@ -120,6 +120,13 @@ public class TwoStepVerificationActivity extends BaseFragment implements Notific
currentPassword = password; currentPassword = password;
} }
public TwoStepVerificationActivity(int account, TLRPC.TL_account_password password) {
this(account);
currentPassword = password;
passwordEntered = currentPasswordHash != null && currentPasswordHash.length > 0 || !currentPassword.has_password;
initPasswordNewAlgo(currentPassword);
}
public void setCurrentPasswordParams(TLRPC.TL_account_password password, byte[] passwordHash, long secretId, byte[] secret) { public void setCurrentPasswordParams(TLRPC.TL_account_password password, byte[] passwordHash, long secretId, byte[] secret) {
currentPassword = password; currentPassword = password;
currentPasswordHash = passwordHash; currentPasswordHash = passwordHash;
@ -270,9 +277,9 @@ public class TwoStepVerificationActivity extends BaseFragment implements Notific
} else { } else {
timeString = LocaleController.formatPluralString("Minutes", time / 60); timeString = LocaleController.formatPluralString("Minutes", time / 60);
} }
showAlertWithText(LocaleController.getString("AppName", R.string.AppName), LocaleController.formatString("FloodWaitTime", R.string.FloodWaitTime, timeString)); showAlertWithText(LocaleController.getString("NekoX", R.string.NekoX), LocaleController.formatString("FloodWaitTime", R.string.FloodWaitTime, timeString));
} else { } else {
showAlertWithText(LocaleController.getString("AppName", R.string.AppName), error.text); showAlertWithText(LocaleController.getString("NekoX", R.string.NekoX), error.text);
} }
} }
}), ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin); }), ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin);
@ -384,7 +391,8 @@ public class TwoStepVerificationActivity extends BaseFragment implements Notific
currentPassword = password; currentPassword = password;
} }
public void setDelegate(TwoStepVerificationActivityDelegate twoStepVerificationActivityDelegate) { public void setDelegate(TwoStepVerificationActivityDelegate
twoStepVerificationActivityDelegate) {
delegate = twoStepVerificationActivityDelegate; delegate = twoStepVerificationActivityDelegate;
} }
@ -638,9 +646,9 @@ public class TwoStepVerificationActivity extends BaseFragment implements Notific
} else { } else {
timeString = LocaleController.formatPluralString("Minutes", time / 60); timeString = LocaleController.formatPluralString("Minutes", time / 60);
} }
showAlertWithText(LocaleController.getString("AppName", R.string.AppName), LocaleController.formatString("FloodWaitTime", R.string.FloodWaitTime, timeString)); showAlertWithText(LocaleController.getString("NekoX", R.string.NekoX), LocaleController.formatString("FloodWaitTime", R.string.FloodWaitTime, timeString));
} else { } else {
showAlertWithText(LocaleController.getString("AppName", R.string.AppName), error.text); showAlertWithText(LocaleController.getString("NekoX", R.string.NekoX), error.text);
} }
} }
}); });
@ -656,7 +664,8 @@ public class TwoStepVerificationActivity extends BaseFragment implements Notific
return null; return null;
} }
private boolean checkSecretValues(byte[] passwordBytes, TLRPC.TL_account_passwordSettings passwordSettings) { private boolean checkSecretValues(byte[] passwordBytes, TLRPC.
TL_account_passwordSettings passwordSettings) {
if (passwordSettings.secure_settings != null) { if (passwordSettings.secure_settings != null) {
currentSecret = passwordSettings.secure_settings.secure_secret; currentSecret = passwordSettings.secure_settings.secure_secret;
byte[] passwordHash; byte[] passwordHash;
@ -777,9 +786,9 @@ public class TwoStepVerificationActivity extends BaseFragment implements Notific
} else { } else {
timeString = LocaleController.formatPluralString("Minutes", time / 60); timeString = LocaleController.formatPluralString("Minutes", time / 60);
} }
showAlertWithText(LocaleController.getString("AppName", R.string.AppName), LocaleController.formatString("FloodWaitTime", R.string.FloodWaitTime, timeString)); showAlertWithText(LocaleController.getString("NekoX", R.string.NekoX), LocaleController.formatString("FloodWaitTime", R.string.FloodWaitTime, timeString));
} else { } else {
showAlertWithText(LocaleController.getString("AppName", R.string.AppName), error.text); showAlertWithText(LocaleController.getString("NekoX", R.string.NekoX), error.text);
} }
}); });
} }
@ -892,6 +901,7 @@ public class TwoStepVerificationActivity extends BaseFragment implements Notific
} }
return 0; return 0;
} }
} }
@Override @Override