diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java
index 8914dd78a11..a4658cd33cf 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java
@@ -6565,15 +6565,45 @@ public boolean isChatNoForwards(TLRPC.Chat chat) {
if (chat == null) {
return false;
}
+ if (shouldBypassNoForwardsForCurrentUser(chat)) {
+ return false;
+ }
if (chat.migrated_to != null) {
TLRPC.Chat migratedTo = getChat(chat.migrated_to.channel_id);
if (migratedTo != null) {
+ if (shouldBypassNoForwardsForCurrentUser(migratedTo)) {
+ return false;
+ }
return migratedTo.noforwards;
}
}
return chat.noforwards;
}
+ private boolean shouldBypassNoForwardsForCurrentUser(TLRPC.Chat chat) {
+ if (chat == null || !chat.noforwards) {
+ return false;
+ }
+ if (chat.creator) {
+ return true;
+ }
+ return ChatObject.hasAdminRights(chat) && isNoForwardsAdminsBypassEnabled(chat.id);
+ }
+
+ private String getNoForwardsAdminsBypassKey(long chatId) {
+ return "noforwards_admins_bypass_" + chatId;
+ }
+
+ public boolean isNoForwardsAdminsBypassEnabled(long chatId) {
+ return getMainSettings().getBoolean(getNoForwardsAdminsBypassKey(chatId), false);
+ }
+
+ public void setNoForwardsAdminsBypassEnabled(long chatId, boolean enabled) {
+ SharedPreferences.Editor editor = getMainSettings().edit();
+ editor.putBoolean(getNoForwardsAdminsBypassKey(chatId), enabled);
+ editor.apply();
+ }
+
public boolean isChatNoForwards(long chatId) {
return isChatNoForwards(getChat(chatId));
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatEditTypeActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatEditTypeActivity.java
index 2b9ac895815..52dc495b296 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ChatEditTypeActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatEditTypeActivity.java
@@ -125,6 +125,7 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
private LinearLayout saveContainer;
private HeaderCell saveHeaderCell;
private TextCheckCell saveRestrictCell;
+ private TextCheckCell saveRestrictAdminBypassCell;
private TextInfoPrivacyCell saveRestrictInfoCell;
private JoinToSendSettingsView joinContainer;
@@ -136,6 +137,7 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
private long chatId;
private boolean isChannel;
private boolean isSaveRestricted;
+ private boolean isAdminsSavingRestrictionBypassed;
private boolean canCreatePublic = true;
private boolean loadingAdminedChannels;
@@ -183,6 +185,7 @@ public boolean onFragmentCreate() {
isPrivate = !isForcePublic && !ChatObject.isPublic(currentChat);
isChannel = ChatObject.isChannel(currentChat) && !currentChat.megagroup;
isSaveRestricted = currentChat.noforwards;
+ isAdminsSavingRestrictionBypassed = getMessagesController().isNoForwardsAdminsBypassEnabled(chatId);
if (isForcePublic && !ChatObject.isPublic(currentChat) || isPrivate && currentChat.creator) {
TLRPC.TL_channels_checkUsername req = new TLRPC.TL_channels_checkUsername();
req.username = "1";
@@ -601,8 +604,21 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto
saveRestrictCell.setOnClickListener(v -> {
isSaveRestricted = !isSaveRestricted;
((TextCheckCell) v).setChecked(isSaveRestricted);
+ if (saveRestrictAdminBypassCell != null) {
+ saveRestrictAdminBypassCell.setVisibility(currentChat.creator && isSaveRestricted ? View.VISIBLE : View.GONE);
+ }
});
saveContainer.addView(saveRestrictCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
+
+ saveRestrictAdminBypassCell = new TextCheckCell(context);
+ saveRestrictAdminBypassCell.setTextAndCheck(LocaleController.getString(R.string.OverrideRestriction), isAdminsSavingRestrictionBypassed, false);
+ saveRestrictAdminBypassCell.setOnClickListener(v -> {
+ isAdminsSavingRestrictionBypassed = !isAdminsSavingRestrictionBypassed;
+ ((TextCheckCell) v).setChecked(isAdminsSavingRestrictionBypassed);
+ });
+ saveRestrictAdminBypassCell.setVisibility(currentChat.creator && isSaveRestricted ? View.VISIBLE : View.GONE);
+ saveContainer.addView(saveRestrictAdminBypassCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
+
saveRestrictInfoCell = new TextInfoPrivacyCell(context, 12, resourceProvider);
if (isChannel && !ChatObject.isMegagroup(currentChat)) {
saveRestrictInfoCell.setText(LocaleController.getString(R.string.RestrictSavingContentInfoChannel));
@@ -1124,6 +1140,12 @@ protected void dispatchDraw(Canvas canvas) {
}
private boolean trySetRestrict() {
+ if (!isSaveRestricted) {
+ isAdminsSavingRestrictionBypassed = false;
+ }
+ if (currentChat.creator) {
+ getMessagesController().setNoForwardsAdminsBypassEnabled(chatId, isAdminsSavingRestrictionBypassed);
+ }
if (currentChat.noforwards != isSaveRestricted) {
if (!ChatObject.isChannel(currentChat)) {
updateDoneProgress(true);
@@ -1131,6 +1153,7 @@ private boolean trySetRestrict() {
if (param != 0) {
chatId = param;
currentChat = getMessagesController().getChat(param);
+ getMessagesController().setNoForwardsAdminsBypassEnabled(chatId, isAdminsSavingRestrictionBypassed);
getMessagesController().toggleChatNoForwards(chatId, currentChat.noforwards = isSaveRestricted);
processDone();
}
diff --git a/TMessagesProj/src/main/res/values-ar/strings.xml b/TMessagesProj/src/main/res/values-ar/strings.xml
index 462998ad26b..7c5fd2cf829 100644
--- a/TMessagesProj/src/main/res/values-ar/strings.xml
+++ b/TMessagesProj/src/main/res/values-ar/strings.xml
@@ -1243,4 +1243,5 @@
\'ذكّرني اليوم عند\' HH:mm
\'ذكّرني بتاريخ\' d MMM \'عند\' HH:mm
\'ذكّرني بتاريخ\' d MMM yyyy \'عند\' HH:mm
+ تجاوز التقييد
\ No newline at end of file
diff --git a/TMessagesProj/src/main/res/values-es/strings.xml b/TMessagesProj/src/main/res/values-es/strings.xml
index 39ef9b7a5e4..650527d8b73 100644
--- a/TMessagesProj/src/main/res/values-es/strings.xml
+++ b/TMessagesProj/src/main/res/values-es/strings.xml
@@ -1316,4 +1316,5 @@
\'Recordar el\' d \'de\' MMM \'de\' yyyy \'a las\' HH:mm
Menu
👍 Entendido
+ Anular restricción
\ No newline at end of file
diff --git a/TMessagesProj/src/main/res/values-pt-rBR/strings.xml b/TMessagesProj/src/main/res/values-pt-rBR/strings.xml
index 87597c284a8..aa088f457aa 100644
--- a/TMessagesProj/src/main/res/values-pt-rBR/strings.xml
+++ b/TMessagesProj/src/main/res/values-pt-rBR/strings.xml
@@ -1249,4 +1249,5 @@
\'Lembrar em\' d \'de\' MMM \'às\' HH:mm
\'Lembrar em\' d \'de\' MMM \'de\' yyyy \'às\' HH:mm
Menu
+ Anular restrição
\ No newline at end of file
diff --git a/TMessagesProj/src/main/res/values-ru/strings.xml b/TMessagesProj/src/main/res/values-ru/strings.xml
index 56f337aafdb..eef742a208d 100644
--- a/TMessagesProj/src/main/res/values-ru/strings.xml
+++ b/TMessagesProj/src/main/res/values-ru/strings.xml
@@ -263,4 +263,5 @@
\'Отправить сегодня в\' HH:mm
\'Отправить\' d MMM \'в\' HH:mm
\'Напомнить\' d MMM yyyy \'в\' HH:mm
+ Отменить ограничение
\ No newline at end of file
diff --git a/TMessagesProj/src/main/res/values/strings.xml b/TMessagesProj/src/main/res/values/strings.xml
index 21a9d8cf7df..b6e040250b5 100644
--- a/TMessagesProj/src/main/res/values/strings.xml
+++ b/TMessagesProj/src/main/res/values/strings.xml
@@ -10428,4 +10428,5 @@
On Message
Pop-up Dialogue
Google Translator
+ Override restriction
\ No newline at end of file