Skip to content

Commit

Permalink
feat: disable repeat in channel
Browse files Browse the repository at this point in the history
Signed-off-by: Next Alone <[email protected]>
  • Loading branch information
NextAlone committed Feb 8, 2025
1 parent 95c2ef9 commit 68efb3a
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -41416,6 +41416,10 @@ public boolean processRepeatMessage(boolean asCopy) {
}

public boolean processRepeatMessage(boolean asCopy, boolean longClick) {
if (Config.disableRepeatInChannel && isChannel()) {
BulletinFactory.of(this).createSimpleBulletin(R.raw.error, getString(R.string.disableRepeatInChannelError)).show();
return false;
}
if (asCopy || longClick || (isThreadChat() && !isTopic) || getMessagesController().isChatNoForwards(currentChat) || selectedObject.messageOwner.noforwards) {
var messageObject = getMessageUtils().getMessageForRepeat(selectedObject, selectedObjectGroup);
if (messageObject != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ public class ChatSettingActivity extends BaseActivity {
private int sendMp4DocumentAsVideoRow;
private int disableGravityDetectionInVideoRow;
private int autoMuteAfterJoiningChannelRow;
private int disableRepeatInChannelRow;
private int chat2Row;

private int markdownRow;
Expand Down Expand Up @@ -484,6 +485,11 @@ protected void onItemClick(View view, int position, float x, float y) {
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(Config.autoMuteAfterJoiningChannel);
}
} else if (position == disableRepeatInChannelRow) {
Config.toggleDisableRepeatInChannel();
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(Config.disableRepeatInChannel);
}
}
}

Expand Down Expand Up @@ -555,6 +561,7 @@ protected void updateRows() {
sendMp4DocumentAsVideoRow = addRow("sendMp4DocumentAsVideo");
disableGravityDetectionInVideoRow = addRow("disableGravityDetectionInVideo");
autoMuteAfterJoiningChannelRow = addRow("autoMuteAfterJoiningChannel");
disableRepeatInChannelRow = addRow("disableRepeatInChannel");
chat2Row = addRow();

markdownRow = addRow();
Expand Down Expand Up @@ -740,6 +747,8 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position, boole
textCell.setTextAndCheck(LocaleController.getString("disableGravityDetectionInVideo", R.string.disableGravityDetectionInVideo), Config.disableGravityDetectionInVideo, true);
} else if (position == autoMuteAfterJoiningChannelRow) {
textCell.setTextAndCheck(LocaleController.getString(R.string.autoMuteAfterJoiningChannel), Config.autoMuteAfterJoiningChannel, true);
} else if (position == disableRepeatInChannelRow) {
textCell.setTextAndCheck(LocaleController.getString(R.string.disableRepeatInChannel), Config.disableRepeatInChannel, true);
}
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ object Defines {
@BooleanConfig const val disableGravityDetectionInVideo = "disableGravityDetectionInVideo"
@BooleanConfig const val hideProxyEntryInTitle = "hideProxyEntryInTitle"
@BooleanConfig const val autoMuteAfterJoiningChannel = "autoMuteAfterJoinChannel"
@BooleanConfig const val disableRepeatInChannel = "disableRepeatInChannel"

// Drawer List
@BooleanConfig(true) const val showNewGroup = "showNewGroup"
Expand Down
2 changes: 2 additions & 0 deletions TMessagesProj/src/main/res/values-zh-rTW/strings_nullgram.xml
Original file line number Diff line number Diff line change
Expand Up @@ -370,4 +370,6 @@
<string name="hideKeyboardWhenScrolling">滑動時隱藏鍵盤</string>
<string name="searchInPlace">在当前位置中开始搜索</string>
<string name="ProviderDeepLXTranslate">DeepLX 翻譯</string>
<string name="disableRepeatInChannel">在頻道中禁用复读</string>
<string name="disableRepeatInChannelError">已禁止在頻道中使用复读</string>
</resources>
2 changes: 2 additions & 0 deletions TMessagesProj/src/main/res/values-zh/strings_nullgram.xml
Original file line number Diff line number Diff line change
Expand Up @@ -380,4 +380,6 @@
<string name="autoMuteAfterJoiningChannel">加入频道后自动静音</string>
<string name="enableXiaomiHyperAi">在输入框中显示小米澎湃 AI</string>
<string name="ProviderDeepLXTranslate">DeepLX 翻译</string>
<string name="disableRepeatInChannel">在频道中禁用复读</string>
<string name="disableRepeatInChannelError">已禁止在频道中使用复读</string>
</resources>
2 changes: 2 additions & 0 deletions TMessagesProj/src/main/res/values/strings_nullgram.xml
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,6 @@
<string name="enableXiaomiHyperAi">Enable Xiaomi HyperAI in editor</string>
<string name="ProviderDeepLXTranslate">DeepLX Translate</string>
<string name="DeepLxApi">DeepLX API</string>
<string name="disableRepeatInChannel">Disable repeat in channel</string>
<string name="disableRepeatInChannelError">Repeat is disabled in channel</string>
</resources>

0 comments on commit 68efb3a

Please sign in to comment.