From 66ea7e39dd376a55365205c669033edf084bbdca Mon Sep 17 00:00:00 2001 From: xtaodada Date: Sat, 21 Dec 2024 14:58:56 +0800 Subject: [PATCH] feat: Disable Bot Open Button --- .../src/main/java/org/telegram/ui/Cells/DialogCell.java | 2 +- .../main/java/org/telegram/ui/Cells/ProfileSearchCell.java | 3 ++- .../nekogram/settings/NekoChatSettingsActivity.java | 3 +++ .../src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt | 6 ++++++ TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml | 1 + TMessagesProj/src/main/res/values/strings_na.xml | 1 + 6 files changed, 14 insertions(+), 2 deletions(-) diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java index 02aef5cd80..707b4089b8 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java @@ -406,7 +406,7 @@ public void setOpenBotButton(boolean show) { private boolean allowBotOpenButton; private Utilities.Callback onOpenButtonClick; public DialogCell allowBotOpenButton(boolean allow, Utilities.Callback onOpenClick) { - allowBotOpenButton = allow; + allowBotOpenButton = allow && !NaConfig.INSTANCE.getDisableBotOpenButton().Bool(); onOpenButtonClick = onOpenClick; return this; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ProfileSearchCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ProfileSearchCell.java index c38e81d7b6..bd648de271 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ProfileSearchCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ProfileSearchCell.java @@ -61,6 +61,7 @@ import java.util.Locale; +import xyz.nextalone.nagram.NaConfig; import xyz.nextalone.nagram.helper.MessageHelper; public class ProfileSearchCell extends BaseCell implements NotificationCenter.NotificationCenterDelegate, Theme.Colorable { @@ -152,7 +153,7 @@ public ProfileSearchCell(Context context, Theme.ResourcesProvider resourcesProvi private boolean allowBotOpenButton; private Utilities.Callback onOpenButtonClick; public ProfileSearchCell allowBotOpenButton(boolean allow, Utilities.Callback onOpenClick) { - allowBotOpenButton = allow; + allowBotOpenButton = allow && !NaConfig.INSTANCE.getDisableBotOpenButton().Bool(); onOpenButtonClick = onOpenClick; return this; } 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 d88d0640bb..e2b061afda 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoChatSettingsActivity.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoChatSettingsActivity.java @@ -158,6 +158,7 @@ public class NekoChatSettingsActivity extends BaseNekoXSettingsActivity implemen private final AbstractConfigCell showQuickReplyInBotCommandsRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getShowQuickReplyInBotCommands())); private final AbstractConfigCell disablePreviewVideoSoundShortcutRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getDisablePreviewVideoSoundShortcut(), LocaleController.getString(R.string.DisablePreviewVideoSoundShortcutNotice))); private final AbstractConfigCell showTimeHintRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getShowTimeHint())); + private final AbstractConfigCell disableBotOpenButtonRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getDisableBotOpenButton())); private final AbstractConfigCell dividerInteractions = cellGroup.appendCell(new ConfigCellDivider()); // Sticker @@ -354,6 +355,8 @@ public void onItemClick(int id) { MediaController.getInstance().recreateProximityWakeLock(); } else if (key.equals(NekoConfig.showSeconds.getKey())) { tooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null); + } else if (key.equals(NaConfig.INSTANCE.getDisableBotOpenButton().getKey())) { + tooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null); } }; diff --git a/TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt b/TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt index a50512d955..07d93f2fe5 100644 --- a/TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt +++ b/TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt @@ -658,6 +658,12 @@ object NaConfig { ConfigItem.configTypeInt, 0 ) + val disableBotOpenButton = + addConfig( + "DisableBotOpenButton", + ConfigItem.configTypeBool, + false + ) 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 3a45c9a058..ebdf2f1916 100644 --- a/TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml +++ b/TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml @@ -166,4 +166,5 @@ 使用 Pangu 发送 不使用 Pangu 发送 默认 Hls 视频质量 + 禁用 Bot 的打开小程序按钮 diff --git a/TMessagesProj/src/main/res/values/strings_na.xml b/TMessagesProj/src/main/res/values/strings_na.xml index 9564d4b69c..9df17d0048 100644 --- a/TMessagesProj/src/main/res/values/strings_na.xml +++ b/TMessagesProj/src/main/res/values/strings_na.xml @@ -167,4 +167,5 @@ Send with Pangu Send without Pangu Default Hls Video Quality + Disable Bot Open Button