feat: remember all clicked replies

This commit is contained in:
luvletter2333 2021-11-18 02:22:54 +08:00
parent fb3a2b88fd
commit 3c8ea5d10b
No known key found for this signature in database
GPG Key ID: A26A8880836E1978
4 changed files with 19 additions and 1 deletions

View File

@ -260,6 +260,7 @@ import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Stack;
import java.util.concurrent.CountDownLatch;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -660,6 +661,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private int startFromVideoMessageId;
private boolean needSelectFromMessageId;
private int returnToMessageId;
private final Stack<Integer> returnToMessageIdsStack = new Stack<>();
private int returnToLoadIndex;
private int createUnreadMessageAfterId;
private boolean createUnreadMessageAfterIdLoading;
@ -6041,7 +6043,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
textSelectionHelper.cancelTextSelectionRunnable();
if (createUnreadMessageAfterId != 0) {
scrollToMessageId(createUnreadMessageAfterId, 0, false, returnToLoadIndex, true, 0);
} else if (returnToMessageId > 0) {
} else if (returnToMessageId > 0 || (NekomuraConfig.rememberAllBackMessages.Bool() && !returnToMessageIdsStack.empty())) {
returnToMessageId = returnToMessageIdsStack.pop();
scrollToMessageId(returnToMessageId, 0, true, returnToLoadIndex, true, 0);
} else {
scrollToLastMessage(false);
@ -6051,6 +6054,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
});
if (NekomuraConfig.rememberAllBackMessages.Bool()) {
pagedownButton.setOnLongClickListener(view -> {
returnToMessageId = 0;
returnToMessageIdsStack.clear();
scrollToLastMessage(true);
return true;
});
}
mentiondownButton = new FrameLayout(context);
mentiondownButton.setVisibility(View.INVISIBLE);
@ -12262,6 +12273,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
returnToMessageId = fromMessageId;
if (NekomuraConfig.rememberAllBackMessages.Bool() && fromMessageId > 0)
returnToMessageIdsStack.push(returnToMessageId);
returnToLoadIndex = loadIndex;
needSelectFromMessageId = select;
}
@ -12325,6 +12338,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
} else {
returnToMessageId = 0;
returnToMessageIdsStack.clear();
newUnreadMessageCount = 0;
if (pagedownButton.getTag() != null) {
pagedownButton.setTag(null);
@ -12386,6 +12400,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
} else {
returnToMessageId = 0;
returnToMessageIdsStack.clear();
if (mentiondownButton.getTag() != null) {
mentiondownButton.setTag(null);
if (mentiondownButtonAnimation != null) {

View File

@ -100,6 +100,7 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
showMessageMenuAlert();
}));
private final AbstractCell repeatConfirmRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.repeatConfirm));
private final AbstractCell rememberAllBackMessagesRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.rememberAllBackMessages));
private final AbstractCell divider1 = cellGroup.appendCell(new NekomuraTGDivider());
private final AbstractCell header2 = cellGroup.appendCell(new NekomuraTGHeader(LocaleController.getString("AutoDownload")));
private final AbstractCell win32Row = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.disableAutoDownloadingWin32Executable));

View File

@ -163,6 +163,7 @@ public class NekomuraConfig {
public static ConfigItem disableChoosingSticker = addConfig("disableChoosingSticker", configTypeBool, false);
public static ConfigItem hideGroupSticker = addConfig("hideGroupSticker", configTypeBool, false);
public static ConfigItem hideSponsoredMessage = addConfig("hideSponsoredMessage", configTypeBool, false);
public static ConfigItem rememberAllBackMessages = addConfig("rememberAllBackMessages", configTypeBool, false);
public static ConfigItem disableAutoDownloadingWin32Executable = addConfig("Win32ExecutableFiles", configTypeBool, true);
public static ConfigItem disableAutoDownloadingArchive = addConfig("ArchiveFiles", configTypeBool, true);

View File

@ -261,4 +261,5 @@
<string name="valuesLargeAvatarInDrawer">Telegram Default\nAvatar as background\nBig avatar as background</string>
<string name="hideSponsoredMessage">Hide sponsored messages</string>
<string name="rememberAllBackMessages">Remember all clicked replies</string>
</resources>