Added ability to select between two messages

This commit is contained in:
NekoInverter 2021-01-08 16:42:50 +08:00 committed by 世界
parent 424fe8e585
commit 5c610deb1b
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
3 changed files with 73 additions and 0 deletions

View File

@ -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<Integer> 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);

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFF"
android:pathData="M14,10H2v2h12V10zM14,6H2v2h12V6zM2,16h8v-2H2V16zM21.5,11.5L23,13l-6.99,7l-4.51,-4.5L13,14l3.01,3L21.5,11.5z"/>
</vector>

View File

@ -110,4 +110,39 @@
<string name="AutoPauseVideoAbout">When lock screen/switch to background.</string>
<string name="DisableProximityEvents">Disable proximity events</string>
<string name="IncreaseVoiceMessageQuality">Increase voice messages quality</string>
<string name="DisableInstantCamera">Disable instant camera</string>
<string name="OpenAllLinksInInstantView">Try to open all links in InstantView</string>
<string name="DonateThankYou">Thank you!</string>
<string name="DonateEvilGoogle">Google will take 30 percent of your donation.</string>
<string name="DonateAlipay">Alipay</string>
<string name="formatterDay24HSec">HH:mm:ss</string>
<string name="formatterDay12HSec">h:mm:ss a</string>
<string name="FormatWithSeconds">Format time with seconds</string>
<string name="JumpToBeginning">Jump to beginning</string>
<string name="ProviderDeepLTranslate">DeepL Translate</string>
<string name="Halloween">Halloween</string>
<string name="CheckUpdate">Check for update</string>
<string name="LastUpdateFormatted">Last successfully checked %1$s.</string>
<string name="LastUpdateDateFormatted">Last successfully checked on %1$s.</string>
<string name="LastUpdateRecently">Last successfully checked just now.</string>
<string name="LastUpdateNever">Never checked since install.</string>
<string name="CheckingUpdate">Checking for update…</string>
<string name="NewUpdateAvailable">A new update available</string>
<string name="GuGuGu">Later</string>
<string name="DownloadNow">Download now</string>
<string name="DownloadingUpdate">Downloading app update</string>
<string name="DownloadingUpdateFinish">Downloaded app update, click to install</string>
<string name="DownloadingUpdateFail">Downloaded app failed</string>
<string name="ClickToRetry">Click to retry.</string>
<string name="ProviderMicrosoftTranslator">Microsoft Translator</string>
<string name="ProviderYouDao">YouDao Translate</string>
<string name="TranslationProviderShort">Provider</string>
<string name="ViewSourceCode">View source code</string>
<string name="AvatarAsBackground">Profile picture as background</string>
<string name="BlurAvatarBackground">Blur profile picture</string>
<string name="DarkenAvatarBackground">Darken profile picture</string>
<string name="AccentAsNotificationColor">Accent color as notification color</string>
<string name="SilenceNonContacts">Silence Non-Contacts</string>
<string name="SilenceNonContactsAbout">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.</string>
<string name="SelectBetween">Select between</string>
</resources>