Skip to content

Commit

Permalink
fix: Chat Rights Count
Browse files Browse the repository at this point in the history
  • Loading branch information
omg-xtao committed Jan 15, 2024
1 parent 33226fd commit 3cb5722
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1934,9 +1934,9 @@ private void updateFields(boolean updateChat, boolean animated) {
count++;
}
} else {
count = forum ? 14 : 13;
count = forum ? 17 : 16;
}
blockCell.setTextAndValueAndIcon(LocaleController.getString("ChannelPermissions", R.string.ChannelPermissions), String.format("%d/%d", count, forum ? 14 : 13), R.drawable.msg_permissions, true);
blockCell.setTextAndValueAndIcon(LocaleController.getString("ChannelPermissions", R.string.ChannelPermissions), String.format("%d/%d", count, forum ? 17 : 16), R.drawable.msg_permissions, true);
}
if (memberRequestsCell != null) {
memberRequestsCell.setTextAndValueAndIcon(LocaleController.getString("MemberRequests", R.string.MemberRequests), String.format("%d", info.requests_pending), R.drawable.msg_requests, logCell != null && logCell.getVisibility() == View.VISIBLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ public class ChatRightsEditActivity extends BaseFragment {
private int sendRoundRow;
private int sendStickersRow;

// private int sendGamesRow;
// private int sendInlineRow;
//
// private int sendGifsRow;
private int sendGamesRow;
private int sendInlineRow;

private int sendGifsRow;
private int sendPollsRow;
private int embedLinksRow;
private int startVoiceChatRow;
Expand Down Expand Up @@ -824,7 +824,13 @@ public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
} else if (position == sendVoiceRow) {
value = bannedRights.send_voices = !bannedRights.send_voices;
} else if (position == sendStickersRow) {
value = bannedRights.send_stickers = bannedRights.send_games = bannedRights.send_gifs = bannedRights.send_inline = !bannedRights.send_stickers;
value = bannedRights.send_stickers = !bannedRights.send_stickers;
} else if (position == sendGifsRow) {
value = bannedRights.send_gifs = !bannedRights.send_gifs;
} else if (position == sendGamesRow) {
value = bannedRights.send_games = !bannedRights.send_games;
} else if (position == sendInlineRow) {
value = bannedRights.send_inline = !bannedRights.send_inline;
} else if (position == embedLinksRow) {
if (bannedRights.send_plain || defaultBannedRights.send_plain) {
View senMessagesView = linearLayoutManager.findViewByPosition(sendMessagesRow);
Expand Down Expand Up @@ -1165,6 +1171,9 @@ private void updateRows(boolean update) {
sendVoiceRow = -1;
sendRoundRow = -1;
sendStickersRow = -1;
sendGifsRow = -1;
sendGamesRow = -1;
sendInlineRow = -1;
sendPollsRow = -1;
embedLinksRow = -1;
startVoiceChatRow = -1;
Expand Down Expand Up @@ -1220,6 +1229,9 @@ private void updateRows(boolean update) {
sendVoiceRow = rowCount++;
sendRoundRow = rowCount++;
sendStickersRow = rowCount++;
sendGifsRow = rowCount++;
sendGamesRow = rowCount++;
sendInlineRow = rowCount++;
sendPollsRow = rowCount++;
embedLinksRow = rowCount++;
}
Expand Down Expand Up @@ -1739,8 +1751,18 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
boolean animated = checkBoxCell.getTag() != null && (Integer) checkBoxCell.getTag() == position;
checkBoxCell.setTag(position);
if (position == sendStickersRow) {
checkBoxCell.setText(LocaleController.getString("SendMediaPermissionStickersGifs", R.string.SendMediaPermissionStickersGifs), "", !bannedRights.send_stickers && !defaultBannedRights.send_stickers, true, animated);
checkBoxCell.setText(LocaleController.getString("UserRestrictionsSendStickers2", R.string.UserRestrictionsSendStickers2), "", !bannedRights.send_stickers && !defaultBannedRights.send_stickers, true, animated);
// checkBoxCell.setText(LocaleController.getString("SendMediaPermissionStickersGifs", R.string.SendMediaPermissionStickersGifs), "", !bannedRights.send_stickers && !defaultBannedRights.send_stickers, true, animated);
checkBoxCell.setIcon(defaultBannedRights.send_stickers ? R.drawable.permission_locked : 0);
} else if (position == sendGifsRow) {
checkBoxCell.setText(LocaleController.getString("UserRestrictionsSendGifs", R.string.UserRestrictionsSendGifs), "", !bannedRights.send_gifs && !defaultBannedRights.send_gifs, true, animated);
checkBoxCell.setIcon(defaultBannedRights.send_gifs ? R.drawable.permission_locked : 0);
} else if (position == sendGamesRow) {
checkBoxCell.setText(LocaleController.getString("UserRestrictionsSendGames", R.string.UserRestrictionsSendGames), "", !bannedRights.send_games && !defaultBannedRights.send_games, true, animated);
checkBoxCell.setIcon(defaultBannedRights.send_games ? R.drawable.permission_locked : 0);
} else if (position == sendInlineRow) {
checkBoxCell.setText(LocaleController.getString("UserRestrictionsSendInline", R.string.UserRestrictionsSendInline), "", !bannedRights.send_inline && !defaultBannedRights.send_inline, true, animated);
checkBoxCell.setIcon(defaultBannedRights.send_inline ? R.drawable.permission_locked : 0);
} else if (position == embedLinksRow) {
checkBoxCell.setText(LocaleController.getString("UserRestrictionsEmbedLinks", R.string.UserRestrictionsEmbedLinks), "", !bannedRights.embed_links && !defaultBannedRights.embed_links && !bannedRights.send_plain && !defaultBannedRights.send_plain, true, animated);
checkBoxCell.setIcon(defaultBannedRights.embed_links ? R.drawable.permission_locked : 0);
Expand Down Expand Up @@ -1843,7 +1865,7 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (position == sendMediaRow) {
int sentMediaCount = getSendMediaSelectedCount();
checkCell.setTextAndCheck(LocaleController.getString("UserRestrictionsSendMedia", R.string.UserRestrictionsSendMedia), sentMediaCount > 0, true, true);
checkCell.setCollapseArrow(String.format(Locale.US, "%d/9", sentMediaCount), !sendMediaExpanded, () -> {
checkCell.setCollapseArrow(String.format(Locale.US, "%d/12", sentMediaCount), !sendMediaExpanded, () -> {
if (allDefaultMediaBanned()) {
new AlertDialog.Builder(getParentActivity())
.setTitle(LocaleController.getString("UserRestrictionsCantModify", R.string.UserRestrictionsCantModify))
Expand Down Expand Up @@ -2167,7 +2189,7 @@ private boolean allDefaultMediaBanned() {
}

private boolean isExpandableSendMediaRow(int position) {
if (position == sendStickersRow || position == embedLinksRow || position == sendPollsRow ||
if (position == sendStickersRow || position == sendGifsRow || position == sendGamesRow || position == sendInlineRow || position == embedLinksRow || position == sendPollsRow ||
position == sendPhotosRow || position == sendVideosRow || position == sendFilesRow ||
position == sendMusicRow || position == sendRoundRow || position == sendVoiceRow ||
position == channelPostMessagesRow || position == channelEditMessagesRow || position == channelDeleteMessagesRow ||
Expand Down

0 comments on commit 3cb5722

Please sign in to comment.