From 5c610deb1bee6048de2c5eda7ac09b37a5f38a12 Mon Sep 17 00:00:00 2001 From: NekoInverter <42698724+nekoinverter@users.noreply.github.com> Date: Fri, 8 Jan 2021 16:42:50 +0800 Subject: [PATCH] Added ability to select between two messages --- .../java/org/telegram/ui/ChatActivity.java | 29 +++++++++++++++ .../main/res/drawable/ic_select_between.xml | 9 +++++ .../src/main/res/values/strings_neko.xml | 35 +++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 TMessagesProj/src/main/res/drawable/ic_select_between.xml diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index fe39ccc39..c2ccd136f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -1023,6 +1023,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not private final static int copy = 10; private final static int forward = 11; private final static int forward_noquote = 95; + private final static int select_between = 86; private final static int delete = 12; private final static int chat_enc_timer = 13; private final static int chat_menu_attach = 14; @@ -1792,6 +1793,31 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not return; } createDeleteMessagesAlert(null, null); + } else if (id == select_between) { + ArrayList ids = new ArrayList<>(); + for (int a = 1; a >= 0; a--) { + for (int b = 0; b < selectedMessagesIds[a].size(); b++) { + ids.add(selectedMessagesIds[a].keyAt(b)); + } + } + Collections.sort(ids); + Integer begin = ids.get(0); + Integer end = ids.get(ids.size() - 1); + for (int i = 0; i < messages.size(); i++) { + int msgId = messages.get(i).getId(); + if (msgId > begin && msgId < end && selectedMessagesIds[0].indexOfKey(msgId) < 0) { + MessageObject message = messages.get(i); + int type = getMessageType(message); + + if (type < 2 || type == 20) { + continue; + } + + addToSelectedMessages(message, true); + } + } + updateActionModeTitle(); + updateVisibleRows(); } else if (id == forward || id == forward_noquote) { noForwardQuote = id == forward_noquote; openForward(); @@ -2344,6 +2370,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not selectedMessagesCountTextView.setOnTouchListener((v, event) -> true); actionModeViews.add(actionMode.addItemWithWidth(edit, R.drawable.baseline_edit_24, AndroidUtilities.dp(54), LocaleController.getString("Edit", R.string.Edit))); + actionModeViews.add(actionMode.addItemWithWidth(select_between, R.drawable.ic_select_between, AndroidUtilities.dp(54), LocaleController.getString("SelectBetween", R.string.SelectBetween))); actionModeViews.add(actionMode.addItemWithWidth(star, R.drawable.baseline_favorite_20, AndroidUtilities.dp(54), LocaleController.getString("AddToFavorites", R.string.AddToFavorites))); actionModeViews.add(actionMode.addItemWithWidth(copy, R.drawable.baseline_content_copy_24, AndroidUtilities.dp(54), LocaleController.getString("Copy", R.string.Copy))); @@ -11393,6 +11420,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not ActionBarMenuItem starItem = actionBar.createActionMode().getItem(star); ActionBarMenuItem editItem = actionBar.createActionMode().getItem(edit); ActionBarMenuItem forwardItem = actionBar.createActionMode().getItem(forward); + ActionBarMenuItem selectItem = actionBar.createActionMode().getItem(select_between); ActionBarMenuItem translateItem = actionBar.createActionMode().getItem(translate); @@ -11434,6 +11462,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not int copyVisible = copyItem.getVisibility(); int starVisible = starItem.getVisibility(); copyItem.setVisibility(selectedMessagesCanCopyIds[0].size() + selectedMessagesCanCopyIds[1].size() != 0 ? View.VISIBLE : View.GONE); + selectItem.setVisibility(selectedMessagesIds[0].size() > 1 ? View.VISIBLE : View.GONE); int newCopyVisible = copyItem.getVisibility(); int newStarVisible = starItem.getVisibility(); actionBar.createActionMode().getItem(delete).setVisibility(cantDeleteMessagesCount == 0 ? View.VISIBLE : View.GONE); diff --git a/TMessagesProj/src/main/res/drawable/ic_select_between.xml b/TMessagesProj/src/main/res/drawable/ic_select_between.xml new file mode 100644 index 000000000..3e783ae49 --- /dev/null +++ b/TMessagesProj/src/main/res/drawable/ic_select_between.xml @@ -0,0 +1,9 @@ + + + diff --git a/TMessagesProj/src/main/res/values/strings_neko.xml b/TMessagesProj/src/main/res/values/strings_neko.xml index 89137d04a..1840589c2 100644 --- a/TMessagesProj/src/main/res/values/strings_neko.xml +++ b/TMessagesProj/src/main/res/values/strings_neko.xml @@ -110,4 +110,39 @@ When lock screen/switch to background. Disable proximity events Increase voice messages quality + Disable instant camera + Try to open all links in InstantView + Thank you! + Google will take 30 percent of your donation. + Alipay + HH:mm:ss + h:mm:ss a + Format time with seconds + Jump to beginning + DeepL Translate + Halloween + Check for update + Last successfully checked %1$s. + Last successfully checked on %1$s. + Last successfully checked just now. + Never checked since install. + Checking for update… + A new update available + Later + Download now + Downloading app update + Downloaded app update, click to install + Downloaded app failed + Click to retry. + Microsoft Translator + YouDao Translate + Provider + View source code + Profile picture as background + Blur profile picture + Darken profile picture + Accent color as notification color + Silence Non-Contacts + Notifications from people that are not your contacts will appear without sound. You can add users to contacts from their profile without knowing their phone number. + Select between \ No newline at end of file