From 04e2ee012216507322a8bebba3265b35c30ead78 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Thu, 27 Jun 2024 22:17:10 +0800 Subject: [PATCH] feat: Custom Search Hashtag Default Page --- .../src/main/java/org/telegram/ui/ChatActivity.java | 10 ++++++++++ .../nekogram/settings/NekoChatSettingsActivity.java | 11 +++++++++++ .../src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt | 12 ++++++++++++ .../src/main/res/values-zh-rCN/strings_na.xml | 2 ++ TMessagesProj/src/main/res/values/strings_na.xml | 2 ++ 5 files changed, 37 insertions(+) diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index aab83e15a8..749d9eee46 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -32953,8 +32953,18 @@ public void openHashtagSearch(String hashtag) { } if (ChatObject.isChannelAndNotMegaGroup(currentChat) && ChatObject.isPublic(currentChat) && searchingHashtag != null) { defaultSearchPage = 2; + +// ----- Nagram Hook Start ----- + defaultSearchPage = NaConfig.INSTANCE.getSearchHashtagDefaultPageChannel().Int(); +// ----- Nagram Hook End ----- + } else { defaultSearchPage = 0; + +// ----- Nagram Hook Start ----- + defaultSearchPage = NaConfig.INSTANCE.getSearchHashtagDefaultPageChat().Int(); +// ----- Nagram Hook End ----- + } openSearchKeyboard = false; if (searchItem != null) { diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoChatSettingsActivity.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoChatSettingsActivity.java index ba8d924d7c..d88d0640bb 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoChatSettingsActivity.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoChatSettingsActivity.java @@ -190,6 +190,17 @@ public class NekoChatSettingsActivity extends BaseNekoXSettingsActivity implemen private final AbstractConfigCell repeatConfirmRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.repeatConfirm)); private final AbstractConfigCell dividerConfirms = cellGroup.appendCell(new ConfigCellDivider()); + // search tag + private final AbstractConfigCell headerSearchTag = cellGroup.appendCell(new ConfigCellHeader(LocaleController.getString("SavedTagSearchHint"))); + private final String[] searchPagesString = new String[]{ + LocaleController.getString(R.string.SearchThisChat), + LocaleController.getString(R.string.SearchMyMessages), + LocaleController.getString(R.string.SearchPublicPosts), + }; + private final AbstractConfigCell searchHashtagDefaultPageChannelRow = cellGroup.appendCell(new ConfigCellSelectBox(null, NaConfig.INSTANCE.getSearchHashtagDefaultPageChannel(), searchPagesString, null)); + private final AbstractConfigCell searchHashtagDefaultPageChatRow = cellGroup.appendCell(new ConfigCellSelectBox(null, NaConfig.INSTANCE.getSearchHashtagDefaultPageChat(), searchPagesString, null)); + private final AbstractConfigCell dividerSearchTag = cellGroup.appendCell(new ConfigCellDivider()); + private ListAdapter listAdapter; private ActionBarMenuItem menuItem; private StickerSizeCell stickerSizeCell; diff --git a/TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt b/TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt index a1acd698de..23e6e9494c 100644 --- a/TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt +++ b/TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt @@ -626,6 +626,18 @@ object NaConfig { ConfigItem.configTypeBool, false ) + val searchHashtagDefaultPageChannel = + addConfig( + "SearchHashtagDefaultPageChannel", + ConfigItem.configTypeInt, + 0 + ) + val searchHashtagDefaultPageChat = + addConfig( + "SearchHashtagDefaultPageChat", + ConfigItem.configTypeInt, + 0 + ) private fun addConfig( k: String, diff --git a/TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml b/TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml index 1e2582f44c..b1e4506a15 100644 --- a/TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml +++ b/TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml @@ -156,4 +156,6 @@ 您也可以使用纯文本,但请不要忘记使用转义符号。 正则表达式语法错误 点击消息时间显示详细信息 + 在频道点击标签默认搜索页面 + 在其他对话点击标签默认搜索页面 diff --git a/TMessagesProj/src/main/res/values/strings_na.xml b/TMessagesProj/src/main/res/values/strings_na.xml index 8cabff3709..75e83dff0e 100644 --- a/TMessagesProj/src/main/res/values/strings_na.xml +++ b/TMessagesProj/src/main/res/values/strings_na.xml @@ -156,4 +156,6 @@ You can also use plain text, but don\'t forget to escape brackets. Regex syntax error Click message time to display details + Channel Click Hashtag Default Search Page + Chat Click Hashtag Default Search Page