From 7e0d0678833b74e8d7c02051c84366cca0258b98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Fri, 1 Jan 2021 22:41:06 +0800 Subject: [PATCH] Split chat banned rights --- .../telegram/ui/ChatRightsEditActivity.java | 63 ++++++++++++++----- .../org/telegram/ui/ChatUsersActivity.java | 38 +++++++++-- .../src/main/res/values/strings_nekox.xml | 3 + 3 files changed, 84 insertions(+), 20 deletions(-) diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatRightsEditActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatRightsEditActivity.java index 97f72c752..264ffa0cc 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatRightsEditActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatRightsEditActivity.java @@ -114,6 +114,10 @@ public class ChatRightsEditActivity extends BaseFragment { private int sendMessagesRow; private int sendMediaRow; private int sendStickersRow; + + private int sendGamesRow; + private int sendInlineRow; + private int sendGifsRow; private int sendPollsRow; private int embedLinksRow; @@ -131,6 +135,7 @@ public class ChatRightsEditActivity extends BaseFragment { public interface ChatRightsEditActivityDelegate { void didSetRights(int rights, TLRPC.TL_chatAdminRights rightsAdmin, TLRPC.TL_chatBannedRights rightsBanned, String rank); + void didChangeOwner(TLRPC.User user); } @@ -160,8 +165,8 @@ public class ChatRightsEditActivity extends BaseFragment { if (myAdminRights == null) { myAdminRights = new TLRPC.TL_chatAdminRights(); myAdminRights.change_info = myAdminRights.post_messages = myAdminRights.edit_messages = - myAdminRights.delete_messages = myAdminRights.ban_users = myAdminRights.invite_users = - myAdminRights.pin_messages = myAdminRights.add_admins = true; + myAdminRights.delete_messages = myAdminRights.ban_users = myAdminRights.invite_users = + myAdminRights.pin_messages = myAdminRights.add_admins = true; if (!isChannel) { myAdminRights.manage_call = true; } @@ -199,17 +204,17 @@ public class ChatRightsEditActivity extends BaseFragment { if (defaultBannedRights == null) { defaultBannedRights = new TLRPC.TL_chatBannedRights(); defaultBannedRights.view_messages = defaultBannedRights.send_media = defaultBannedRights.send_messages = - defaultBannedRights.embed_links = defaultBannedRights.send_stickers = defaultBannedRights.send_gifs = - defaultBannedRights.send_games = defaultBannedRights.send_inline = defaultBannedRights.send_polls = - defaultBannedRights.invite_users = defaultBannedRights.change_info = defaultBannedRights.pin_messages = false; + defaultBannedRights.embed_links = defaultBannedRights.send_stickers = defaultBannedRights.send_gifs = + defaultBannedRights.send_games = defaultBannedRights.send_inline = defaultBannedRights.send_polls = + defaultBannedRights.invite_users = defaultBannedRights.change_info = defaultBannedRights.pin_messages = false; } bannedRights = new TLRPC.TL_chatBannedRights(); if (rightsBanned == null) { bannedRights.view_messages = bannedRights.send_media = bannedRights.send_messages = - bannedRights.embed_links = bannedRights.send_stickers = bannedRights.send_gifs = - bannedRights.send_games = bannedRights.send_inline = bannedRights.send_polls = - bannedRights.invite_users = bannedRights.change_info = bannedRights.pin_messages = false; + bannedRights.embed_links = bannedRights.send_stickers = bannedRights.send_gifs = + bannedRights.send_games = bannedRights.send_inline = bannedRights.send_polls = + bannedRights.invite_users = bannedRights.change_info = bannedRights.pin_messages = false; } else { bannedRights.view_messages = rightsBanned.view_messages; bannedRights.send_messages = rightsBanned.send_messages; @@ -537,7 +542,11 @@ public class ChatRightsEditActivity extends BaseFragment { } else if (position == sendMediaRow) { bannedRights.send_media = !bannedRights.send_media; } else if (position == sendStickersRow) { - bannedRights.send_stickers = bannedRights.send_games = bannedRights.send_inline = !bannedRights.send_stickers; + bannedRights.send_stickers = !bannedRights.send_stickers; + } else if (position == sendGamesRow) { + bannedRights.send_games = !bannedRights.send_games; + } else if (position == sendInlineRow) { + bannedRights.send_inline = !bannedRights.send_inline; } else if (position == sendGifsRow) { bannedRights.send_gifs = !bannedRights.send_gifs; } else if (position == embedLinksRow) { @@ -568,12 +577,26 @@ public class ChatRightsEditActivity extends BaseFragment { } } if ((bannedRights.view_messages || bannedRights.send_messages) && !bannedRights.send_stickers) { - bannedRights.send_stickers = bannedRights.send_games = bannedRights.send_inline = true; + bannedRights.send_stickers = true; RecyclerListView.ViewHolder holder = listView.findViewHolderForAdapterPosition(sendStickersRow); if (holder != null) { ((TextCheckCell2) holder.itemView).setChecked(false); } } + if ((bannedRights.view_messages || bannedRights.send_messages) && !bannedRights.send_games) { + bannedRights.send_games = true; + RecyclerListView.ViewHolder holder = listView.findViewHolderForAdapterPosition(sendGamesRow); + if (holder != null) { + ((TextCheckCell2) holder.itemView).setChecked(false); + } + } + if ((bannedRights.view_messages || bannedRights.send_inline) && !bannedRights.send_inline) { + bannedRights.send_inline = true; + RecyclerListView.ViewHolder holder = listView.findViewHolderForAdapterPosition(sendInlineRow); + if (holder != null) { + ((TextCheckCell2) holder.itemView).setChecked(false); + } + } if ((bannedRights.view_messages || bannedRights.send_messages) && !bannedRights.send_gifs) { bannedRights.send_gifs = true; RecyclerListView.ViewHolder holder = listView.findViewHolderForAdapterPosition(sendGifsRow); @@ -811,6 +834,8 @@ public class ChatRightsEditActivity extends BaseFragment { sendMessagesRow = -1; sendMediaRow = -1; sendStickersRow = -1; + sendGamesRow = -1; + sendInlineRow = -1; sendGifsRow = -1; sendPollsRow = -1; embedLinksRow = -1; @@ -841,6 +866,8 @@ public class ChatRightsEditActivity extends BaseFragment { sendMessagesRow = rowCount++; sendMediaRow = rowCount++; sendStickersRow = rowCount++; + sendGamesRow = rowCount++; + sendInlineRow = rowCount++; sendGifsRow = rowCount++; sendPollsRow = rowCount++; embedLinksRow = rowCount++; @@ -931,8 +958,8 @@ public class ChatRightsEditActivity extends BaseFragment { if (delegate != null) { delegate.didSetRights( adminRights.change_info || adminRights.post_messages || adminRights.edit_messages || - adminRights.delete_messages || adminRights.ban_users || adminRights.invite_users || - adminRights.pin_messages || adminRights.add_admins || adminRights.anonymous || adminRights.manage_call ? 1 : 0, adminRights, bannedRights, currentRank); + adminRights.delete_messages || adminRights.ban_users || adminRights.invite_users || + adminRights.pin_messages || adminRights.add_admins || adminRights.anonymous || adminRights.manage_call ? 1 : 0, adminRights, bannedRights, currentRank); } } else if (currentType == TYPE_BANNED) { MessagesController.getInstance(currentAccount).setUserBannedRole(chatId, currentUser, bannedRights, isChannel, getFragmentForAlert(1)); @@ -1224,6 +1251,12 @@ public class ChatRightsEditActivity extends BaseFragment { } else if (position == sendStickersRow) { checkCell.setTextAndCheck(LocaleController.getString("UserRestrictionsSendStickers2", R.string.UserRestrictionsSendStickers2), !bannedRights.send_stickers && !defaultBannedRights.send_stickers, true); checkCell.setIcon(defaultBannedRights.send_stickers ? R.drawable.permission_locked : 0); + } else if (position == sendGamesRow) { + checkCell.setTextAndCheck(LocaleController.getString("UserRestrictionsSendGames", R.string.UserRestrictionsSendGames), !bannedRights.send_games && !defaultBannedRights.send_games, true); + checkCell.setIcon(defaultBannedRights.send_stickers ? R.drawable.permission_locked : 0); + } else if (position == sendInlineRow) { + checkCell.setTextAndCheck(LocaleController.getString("UserRestrictionsSendInline", R.string.UserRestrictionsSendInline), !bannedRights.send_inline && !defaultBannedRights.send_inline, true); + checkCell.setIcon(defaultBannedRights.send_stickers ? R.drawable.permission_locked : 0); } else if (position == sendGifsRow) { checkCell.setTextAndCheck(LocaleController.getString("UserRestrictionsSendGifs", R.string.UserRestrictionsSendGifs), !bannedRights.send_gifs && !defaultBannedRights.send_gifs, true); checkCell.setIcon(defaultBannedRights.send_gifs ? R.drawable.permission_locked : 0); @@ -1235,7 +1268,7 @@ public class ChatRightsEditActivity extends BaseFragment { checkCell.setIcon(defaultBannedRights.send_polls ? R.drawable.permission_locked : 0); } - if (position == sendMediaRow || position == sendStickersRow || position == sendGifsRow || position == embedLinksRow || position == sendPollsRow) { + if (position == sendMediaRow || position == sendStickersRow || position == sendGamesRow || position == sendInlineRow || position == sendGifsRow || position == embedLinksRow || position == sendPollsRow) { checkCell.setEnabled(!bannedRights.send_messages && !bannedRights.view_messages && !defaultBannedRights.send_messages && !defaultBannedRights.view_messages); } else if (position == sendMessagesRow) { checkCell.setEnabled(!bannedRights.view_messages && !defaultBannedRights.view_messages); @@ -1307,8 +1340,8 @@ public class ChatRightsEditActivity extends BaseFragment { return 3; } else if (position == changeInfoRow || position == postMessagesRow || position == editMesagesRow || position == deleteMessagesRow || position == addAdminsRow || position == banUsersRow || position == addUsersRow || position == pinMessagesRow || - position == sendMessagesRow || position == sendMediaRow || position == sendStickersRow || position == sendGifsRow || - position == embedLinksRow || position == sendPollsRow || position == anonymousRow || position == startVoiceChatRow) { + position == sendMessagesRow || position == sendMediaRow || position == sendStickersRow || position == sendGamesRow || position == sendInlineRow || + position == sendGifsRow || position == embedLinksRow || position == sendPollsRow || position == anonymousRow || position == startVoiceChatRow) { return 4; } else if (position == cantEditInfoRow || position == rankInfoRow) { return 1; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatUsersActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatUsersActivity.java index 3442b9a1b..956dd3889 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatUsersActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatUsersActivity.java @@ -122,6 +122,8 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente private int sendMessagesRow; private int sendMediaRow; private int sendStickersRow; + private int sendGamesRow; + private int sendInlineRow; private int sendGifsRow; private int sendPollsRow; private int embedLinksRow; @@ -444,6 +446,8 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente sendMessagesRow = -1; sendMediaRow = -1; sendStickersRow = -1; + sendGamesRow = -1; + sendInlineRow = -1; sendGifsRow = -1; sendPollsRow = -1; embedLinksRow = -1; @@ -470,6 +474,8 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente sendMessagesRow = rowCount++; sendMediaRow = rowCount++; sendStickersRow = rowCount++; + sendGamesRow = rowCount ++; + sendInlineRow = rowCount ++; sendGifsRow = rowCount++; sendPollsRow = rowCount++; embedLinksRow = rowCount++; @@ -867,7 +873,11 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente } else if (position == sendMediaRow) { defaultBannedRights.send_media = !defaultBannedRights.send_media; } else if (position == sendStickersRow) { - defaultBannedRights.send_stickers = defaultBannedRights.send_games = defaultBannedRights.send_inline = !defaultBannedRights.send_stickers; + defaultBannedRights.send_stickers = !defaultBannedRights.send_stickers; + } else if (position == sendGamesRow) { + defaultBannedRights.send_games = !defaultBannedRights.send_games; + } else if (position == sendInlineRow) { + defaultBannedRights.send_inline = !defaultBannedRights.send_inline; } else if (position == sendGifsRow) { defaultBannedRights.send_gifs = !defaultBannedRights.send_gifs; } else if (position == embedLinksRow) { @@ -898,12 +908,26 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente } } if ((defaultBannedRights.view_messages || defaultBannedRights.send_messages) && !defaultBannedRights.send_stickers) { - defaultBannedRights.send_stickers = defaultBannedRights.send_games = defaultBannedRights.send_inline = true; + defaultBannedRights.send_stickers = true; RecyclerListView.ViewHolder holder = listView.findViewHolderForAdapterPosition(sendStickersRow); if (holder != null) { ((TextCheckCell2) holder.itemView).setChecked(false); } } + if ((defaultBannedRights.view_messages || defaultBannedRights.send_messages) && !defaultBannedRights.send_games) { + defaultBannedRights.send_games = true; + RecyclerListView.ViewHolder holder = listView.findViewHolderForAdapterPosition(sendGamesRow); + if (holder != null) { + ((TextCheckCell2) holder.itemView).setChecked(false); + } + } + if ((defaultBannedRights.view_messages || defaultBannedRights.send_messages) && !defaultBannedRights.send_inline) { + defaultBannedRights.send_inline = true; + RecyclerListView.ViewHolder holder = listView.findViewHolderForAdapterPosition(sendInlineRow); + if (holder != null) { + ((TextCheckCell2) holder.itemView).setChecked(false); + } + } if ((defaultBannedRights.view_messages || defaultBannedRights.send_messages) && !defaultBannedRights.send_gifs) { defaultBannedRights.send_gifs = true; RecyclerListView.ViewHolder holder = listView.findViewHolderForAdapterPosition(sendGifsRow); @@ -3010,6 +3034,10 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente checkCell.setTextAndCheck(LocaleController.getString("UserRestrictionsSendMedia", R.string.UserRestrictionsSendMedia), !defaultBannedRights.send_media, true); } else if (position == sendStickersRow) { checkCell.setTextAndCheck(LocaleController.getString("UserRestrictionsSendStickers2", R.string.UserRestrictionsSendStickers2), !defaultBannedRights.send_stickers, true); + } else if (position == sendGamesRow) { + checkCell.setTextAndCheck(LocaleController.getString("UserRestrictionsSendGames", R.string.UserRestrictionsSendGames), !defaultBannedRights.send_games, true); + } else if (position == sendInlineRow) { + checkCell.setTextAndCheck(LocaleController.getString("UserRestrictionsSendInline", R.string.UserRestrictionsSendInline), !defaultBannedRights.send_inline, true); } else if (position == sendGifsRow) { checkCell.setTextAndCheck(LocaleController.getString("UserRestrictionsSendGifs", R.string.UserRestrictionsSendGifs), !defaultBannedRights.send_gifs, true); } else if (position == embedLinksRow) { @@ -3018,7 +3046,7 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente checkCell.setTextAndCheck(LocaleController.getString("UserRestrictionsSendPolls", R.string.UserRestrictionsSendPolls), !defaultBannedRights.send_polls, true); } - if (position == sendMediaRow || position == sendStickersRow || position == sendGifsRow || position == embedLinksRow || position == sendPollsRow) { + if (position == sendMediaRow || position == sendStickersRow || position == sendGamesRow || position == sendInlineRow || position == sendGifsRow || position == embedLinksRow || position == sendPollsRow) { checkCell.setEnabled(!defaultBannedRights.send_messages && !defaultBannedRights.view_messages); } else if (position == sendMessagesRow) { checkCell.setEnabled(!defaultBannedRights.view_messages); @@ -3083,8 +3111,8 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente } else if (position == removedUsersRow) { return 6; } else if (position == changeInfoRow || position == addUsersRow || position == pinMessagesRow || position == sendMessagesRow || - position == sendMediaRow || position == sendStickersRow || position == sendGifsRow || position == embedLinksRow || - position == sendPollsRow) { + position == sendMediaRow || position == sendStickersRow || position == sendGamesRow || position == sendInlineRow || + position == sendGifsRow || position == embedLinksRow || position == sendPollsRow) { return 7; } else if (position == membersHeaderRow || position == contactsHeaderRow || position == botHeaderRow) { return 8; diff --git a/TMessagesProj/src/main/res/values/strings_nekox.xml b/TMessagesProj/src/main/res/values/strings_nekox.xml index 58b98113c..199306d36 100644 --- a/TMessagesProj/src/main/res/values/strings_nekox.xml +++ b/TMessagesProj/src/main/res/values/strings_nekox.xml @@ -268,4 +268,7 @@ Simplified Chinese (China) New Japanese Kanji (Shinjitai) + Send Games + Send via Inline Bots + \ No newline at end of file