From ae70fa17009a9ae4144f7f02415a64b5fd0173c4 Mon Sep 17 00:00:00 2001 From: Nikita S Date: Sat, 21 Jan 2023 23:34:55 +0100 Subject: [PATCH 1/4] new OutOfMemory crash fix lets try more smart also will see if i can use it widely in that app. --- .../org/telegram/ui/Components/ForegroundDetector.java | 7 +++++++ .../org/telegram/ui/Components/spoilers/SpoilerEffect.java | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ForegroundDetector.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ForegroundDetector.java index c2dfdc22b79..9cd4b33cb14 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ForegroundDetector.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ForegroundDetector.java @@ -27,6 +27,7 @@ public interface Listener { } private int refs; + private boolean isPaused; private boolean wasInBackground = true; private long enterBackgroundTime = 0; private CopyOnWriteArrayList listeners = new CopyOnWriteArrayList<>(); @@ -111,10 +112,16 @@ public void onActivityCreated(Activity activity, Bundle savedInstanceState) { @Override public void onActivityResumed(Activity activity) { + this.isPaused =false; } @Override public void onActivityPaused(Activity activity) { + this.isPaused =true; + } + + public boolean isPaused(){ + return this.isPaused; } @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/spoilers/SpoilerEffect.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/spoilers/SpoilerEffect.java index c67bc49b79f..6a23c24c7c0 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/spoilers/SpoilerEffect.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/spoilers/SpoilerEffect.java @@ -41,6 +41,7 @@ import org.telegram.messenger.*; import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.Components.Easings; +import org.telegram.ui.Components.ForegroundDetector; import org.telegram.ui.Components.TextStyleSpan; import java.util.ArrayList; @@ -522,10 +523,12 @@ public int getOpacity() { * @return Measured key points */ public static synchronized List measureKeyPoints(Layout textLayout) { + if (ForegroundDetector.getInstance().isPaused()) return Collections.emptyList(); + int w = textLayout.getWidth(); int h = textLayout.getHeight(); - if (w <= 0 || h <= 0 || w > 16384) //fix bitch + if (w <= 0 || h <= 0) return Collections.emptyList(); Bitmap measureBitmap = Bitmap.createBitmap(Math.round(w), Math.round(h), Bitmap.Config.ARGB_4444); // We can use 4444 as we don't need accuracy here From b1aa60784243c2211f9f0ccf1b275d87100d5681 Mon Sep 17 00:00:00 2001 From: Nikita S Date: Sun, 22 Jan 2023 00:15:21 +0100 Subject: [PATCH 2/4] disable emoji status for chats also --- TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index ab0f0dc5600..332536377ab 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -21511,7 +21511,7 @@ public void onClick(View view) { } int topChatPanelHeight; - if (showEmojiStatusReport != null) { + if (showEmojiStatusReport != null && !(MessagesController.getGlobalTelegraherSettings().getBoolean("GraheriumDisableEmojiStatus", false))) { emojiStatusSpamHint.setVisibility(View.VISIBLE); topViewSeparator1.setVisibility(View.VISIBLE); topViewSeparator2.setVisibility(View.VISIBLE); From 583efe5839bd0f31fc9d86055578b5fb29822ea7 Mon Sep 17 00:00:00 2001 From: Nikita S Date: Sun, 22 Jan 2023 23:18:21 +0100 Subject: [PATCH 3/4] some handy features * extended admin rights to restrict gifs, stickers, games or inline bots for users in chat * the idea and main code from @arsLan and his Cherrygram * custom error messages if you got resticted for gifs only or stickers only * actually i track well strickers forbidden and let you to use gifs, but if gifs are forbidden (but stickers are allowed) you can use both (but gifs will not pass). Thats somewhere in the vanilla code i need to debug later. * channels and groups have edit icon now, so you can list all members (if not hidden) and admins. * the code which display admin numbers is from @arsLan, but i adapted it for channels only. * added english & russian translations for new options --- .../org/telegram/ui/ChatEditActivity.java | 72 +++++++++++++++---- .../telegram/ui/ChatRightsEditActivity.java | 60 ++++++++++++++-- .../org/telegram/ui/ChatUsersActivity.java | 53 ++++++++++++-- .../org/telegram/ui/Components/EmojiView.java | 39 +++++----- .../java/org/telegram/ui/ProfileActivity.java | 14 +--- .../src/main/res/values-ru/strings.xml | 4 ++ TMessagesProj/src/main/res/values/strings.xml | 4 ++ 7 files changed, 193 insertions(+), 53 deletions(-) diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatEditActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatEditActivity.java index a5858ed8ea1..97cb7ff3007 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatEditActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatEditActivity.java @@ -82,6 +82,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.concurrent.CountDownLatch; public class ChatEditActivity extends BaseFragment implements ImageUpdater.ImageUpdaterDelegate, NotificationCenter.NotificationCenterDelegate { @@ -152,6 +153,8 @@ public class ChatEditActivity extends BaseFragment implements ImageUpdater.Image private final static int done_button = 1; + private int realAdminCount = 0; + private PhotoViewer.PhotoViewerProvider provider = new PhotoViewer.EmptyPhotoViewerProvider() { @Override @@ -842,7 +845,7 @@ public void afterTextChanged(Editable editable) { blockCell = new TextCell(context); blockCell.setBackground(Theme.getSelectorDrawable(false)); - blockCell.setVisibility(ChatObject.isChannel(currentChat) || currentChat.creator || ChatObject.hasAdminRights(currentChat) && ChatObject.canChangeChatInfo(currentChat) ? View.VISIBLE : View.GONE); + blockCell.setVisibility(View.VISIBLE); blockCell.setOnClickListener(v -> { Bundle args = new Bundle(); args.putLong("chat_id", chatId); @@ -901,9 +904,9 @@ public void afterTextChanged(Editable editable) { }); } - if (ChatObject.isChannel(currentChat) || currentChat.gigagroup) { + if ((ChatObject.isChannel(currentChat) || currentChat.gigagroup) && ChatObject.hasAdminRights(currentChat)) { logCell = new TextCell(context); - logCell.setTextAndIcon(LocaleController.getString("EventLog", R.string.EventLog), R.drawable.msg_log, false); + logCell.setTextAndIcon(LocaleController.getString("EventLog", R.string.EventLog), R.drawable.msg_log, !isChannel && info != null && info.can_set_stickers); logCell.setBackground(Theme.getSelectorDrawable(false)); logCell.setOnClickListener(v -> presentFragment(new ChannelAdminLogActivity(currentChat))); } @@ -942,13 +945,10 @@ public void afterTextChanged(Editable editable) { groupStickersActivity.setInfo(info); presentFragment(groupStickersActivity); }); - } else if (logCell != null) { - infoContainer.addView(logCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); } - if (!ChatObject.hasAdminRights(currentChat)) { - infoContainer.setVisibility(View.GONE); - settingsTopSectionCell.setVisibility(View.GONE); + if (logCell != null) { + infoContainer.addView(logCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); } if (stickersCell == null) { @@ -1187,6 +1187,34 @@ private int getAdminCount() { return count; } + private int getChannelAdminCount() { + if (info == null) { + return 1; + } + int count = 0; + for (int a = 0, N = info.participants.participants.size(); a < N; a++) { + TLRPC.ChatParticipant chatParticipant = info.participants.participants.get(a); + TLRPC.ChannelParticipant channelParticipant = ((TLRPC.TL_chatChannelParticipant) chatParticipant).channelParticipant; + if (channelParticipant instanceof TLRPC.TL_channelParticipantAdmin || + channelParticipant instanceof TLRPC.TL_channelParticipantCreator) { + count++; + } + } + return count; + } + + private void getRealChannelAdminCount() { + TLRPC.TL_channels_getParticipants req = new TLRPC.TL_channels_getParticipants(); + req.channel = getMessagesController().getInputChannel(chatId); + req.filter = new TLRPC.TL_channelParticipantsAdmins(); + int reqId = getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { + TLRPC.TL_channels_channelParticipants res = (TLRPC.TL_channels_channelParticipants) response; + realAdminCount = res == null ? 0 : res.count; + adminCell.setTextAndValueAndIcon(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators), String.format(Locale.getDefault(), "%d", realAdminCount), R.drawable.msg_admin_add, true); + })); + getConnectionsManager().bindRequestToGuid(reqId, classGuid); + } + private void processDone() { if (donePressed || nameTextView == null) { return; @@ -1370,7 +1398,7 @@ private void updateFields(boolean updateChat, boolean animated) { } if (logCell != null) { - logCell.setVisibility(!currentChat.megagroup || currentChat.gigagroup || info != null && info.participants_count > 200 ? View.VISIBLE : View.GONE); + logCell.setVisibility(!currentChat.megagroup || currentChat.gigagroup || info != null ? View.VISIBLE : View.GONE); } if (linkedCell != null) { @@ -1476,6 +1504,15 @@ private void updateFields(boolean updateChat, boolean animated) { if (!currentChat.default_banned_rights.send_stickers) { count++; } + if (!currentChat.default_banned_rights.send_gifs) { + count++; + } + if (!currentChat.default_banned_rights.send_games) { + count++; + } + if (!currentChat.default_banned_rights.send_inline) { + count++; + } if (!currentChat.default_banned_rights.send_media) { count++; } @@ -1501,15 +1538,24 @@ private void updateFields(boolean updateChat, boolean animated) { count++; } } else { - count = forum ? 9 : 8; + count = forum ? 12 : 11; } - blockCell.setTextAndValueAndIcon(LocaleController.getString("ChannelPermissions", R.string.ChannelPermissions), String.format("%d/%d", count, forum ? 9 : 8), animated, R.drawable.msg_permissions, true); + blockCell.setTextAndValueAndIcon(LocaleController.getString("ChannelPermissions", R.string.ChannelPermissions), String.format(Locale.getDefault(),"%d/%d", count, forum ? 12 : 11), animated, 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); + memberRequestsCell.setTextAndValueAndIcon(LocaleController.getString("MemberRequests", R.string.MemberRequests), String.format(Locale.getDefault(),"%d", info.requests_pending), R.drawable.msg_requests, logCell != null && logCell.getVisibility() == View.VISIBLE); + } + } + if (ChatObject.hasAdminRights(currentChat)) { + adminCell.setTextAndValueAndIcon(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators), String.format(Locale.getDefault(),"%d", ChatObject.isChannel(currentChat) ? info.admins_count : getAdminCount()), R.drawable.msg_admins, true); + } else if (info != null && info.participants != null) { + if (ChatObject.isChannel(currentChat)) { + adminCell.setTextAndIcon(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators), R.drawable.msg_admins, true); + getRealChannelAdminCount(); + } else { + adminCell.setTextAndValueAndIcon(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators), String.format(Locale.getDefault(),"%d", ChatObject.isChannel(currentChat) ? realAdminCount == 0 ? getChannelAdminCount() : realAdminCount : getAdminCount()), R.drawable.msg_admins, true); } } - adminCell.setTextAndValueAndIcon(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators), String.format("%d", ChatObject.isChannel(currentChat) ? info.admins_count : getAdminCount()), R.drawable.msg_admins, true); } else { if (isChannel) { membersCell.setTextAndIcon(LocaleController.getString("ChannelSubscribers", R.string.ChannelSubscribers), R.drawable.msg_groups, true); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatRightsEditActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatRightsEditActivity.java index c4426ad1586..1103a7ad866 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatRightsEditActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatRightsEditActivity.java @@ -136,6 +136,9 @@ public class ChatRightsEditActivity extends BaseFragment { private int sendMessagesRow; private int sendMediaRow; + private int sendGifsRow; + private int sendGamesRow; + private int useInlineBotRow; private int sendStickersRow; private int sendPollsRow; private int embedLinksRow; @@ -709,7 +712,13 @@ public void onScrollStateChanged(RecyclerView recyclerView, int newState) { } else if (position == sendMediaRow) { value = bannedRights.send_media = !bannedRights.send_media; } 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 == useInlineBotRow) { + value = bannedRights.send_inline = !bannedRights.send_inline; } else if (position == embedLinksRow) { value = bannedRights.embed_links = !bannedRights.embed_links; } else if (position == sendPollsRow) { @@ -738,12 +747,33 @@ public void onScrollStateChanged(RecyclerView recyclerView, int newState) { } } if ((bannedRights.view_messages || bannedRights.send_messages) && !bannedRights.send_stickers) { - bannedRights.send_stickers = bannedRights.send_games = bannedRights.send_gifs = 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_gifs) { + bannedRights.send_gifs = true; + RecyclerListView.ViewHolder holder = listView.findViewHolderForAdapterPosition(sendGifsRow); + 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_messages) && !bannedRights.send_inline) { + bannedRights.send_inline = true; + RecyclerListView.ViewHolder holder = listView.findViewHolderForAdapterPosition(useInlineBotRow); + if (holder != null) { + ((TextCheckCell2) holder.itemView).setChecked(false); + } + } if ((bannedRights.view_messages || bannedRights.send_messages) && !bannedRights.embed_links) { bannedRights.embed_links = true; RecyclerListView.ViewHolder holder = listView.findViewHolderForAdapterPosition(embedLinksRow); @@ -983,6 +1013,9 @@ private void updateRows(boolean update) { sendMessagesRow = -1; sendMediaRow = -1; sendStickersRow = -1; + sendGifsRow = -1; + sendGamesRow = -1; + useInlineBotRow = -1; sendPollsRow = -1; embedLinksRow = -1; startVoiceChatRow = -1; @@ -1022,6 +1055,9 @@ private void updateRows(boolean update) { sendMessagesRow = rowCount++; sendMediaRow = rowCount++; sendStickersRow = rowCount++; + sendGifsRow = rowCount++; + sendGamesRow = rowCount++; + useInlineBotRow = rowCount++; sendPollsRow = rowCount++; embedLinksRow = rowCount++; addUsersRow = rowCount++; @@ -1646,8 +1682,17 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { checkCell.setTextAndCheck(LocaleController.getString("UserRestrictionsSendMedia", R.string.UserRestrictionsSendMedia), !bannedRights.send_media && !defaultBannedRights.send_media, true); checkCell.setIcon(defaultBannedRights.send_media ? R.drawable.permission_locked : 0); } else if (position == sendStickersRow) { - checkCell.setTextAndCheck(LocaleController.getString("UserRestrictionsSendStickers", R.string.UserRestrictionsSendStickers), !bannedRights.send_stickers && !defaultBannedRights.send_stickers, true); + checkCell.setTextAndCheck(LocaleController.getString("THUserRestrictionsSendStickers", R.string.THUserRestrictionsSendStickers), !bannedRights.send_stickers && !defaultBannedRights.send_stickers, true); checkCell.setIcon(defaultBannedRights.send_stickers ? R.drawable.permission_locked : 0); + } else if (position == sendGifsRow) { + checkCell.setTextAndCheck(LocaleController.getString("THUserRestrictionsSendGifs", R.string.THUserRestrictionsSendGifs), !bannedRights.send_gifs && !defaultBannedRights.send_gifs, true); + checkCell.setIcon(defaultBannedRights.send_gifs ? R.drawable.permission_locked : 0); + } else if (position == sendGamesRow) { + checkCell.setTextAndCheck(LocaleController.getString("THUserRestrictionsSendGames", R.string.THUserRestrictionsSendGames), !bannedRights.send_games && !defaultBannedRights.send_games, true); + checkCell.setIcon(defaultBannedRights.send_games ? R.drawable.permission_locked : 0); + } else if (position == useInlineBotRow) { + checkCell.setTextAndCheck(LocaleController.getString("THUserRestrictionsUseInlineBots", R.string.THUserRestrictionsUseInlineBots), !bannedRights.send_inline && !defaultBannedRights.send_inline, true); + checkCell.setIcon(defaultBannedRights.send_inline ? R.drawable.permission_locked : 0); } else if (position == embedLinksRow) { checkCell.setTextAndCheck(LocaleController.getString("UserRestrictionsEmbedLinks", R.string.UserRestrictionsEmbedLinks), !bannedRights.embed_links && !defaultBannedRights.embed_links, true); checkCell.setIcon(defaultBannedRights.embed_links ? R.drawable.permission_locked : 0); @@ -1659,7 +1704,7 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (currentType == TYPE_ADD_BOT) { // checkCell.setEnabled((asAdmin || position == manageRow) && !checkCell.hasIcon(), false); } else { - if (position == sendMediaRow || position == sendStickersRow || position == embedLinksRow || position == sendPollsRow) { + if (position == sendMediaRow || position == sendStickersRow || position == sendGifsRow || position == sendGamesRow || position == useInlineBotRow || 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); @@ -1736,9 +1781,10 @@ public int getItemViewType(int position) { } else if (position == 2 || position == rankHeaderRow) { return VIEW_TYPE_HEADER_CELL; } 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 == embedLinksRow || - position == sendPollsRow || position == anonymousRow || position == startVoiceChatRow || position == manageRow || position == manageTopicsRow) { + position == addAdminsRow || position == banUsersRow || position == addUsersRow || position == pinMessagesRow || + position == sendMessagesRow || position == sendMediaRow || position == sendStickersRow || position == sendGifsRow || + position == sendGamesRow || position == useInlineBotRow || position == embedLinksRow || position == sendPollsRow || + position == anonymousRow || position == startVoiceChatRow || position == manageRow || position == manageTopicsRow) { return VIEW_TYPE_SWITCH_CELL; } else if (position == cantEditInfoRow || position == rankInfoRow) { return VIEW_TYPE_INFO_CELL; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatUsersActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatUsersActivity.java index 64c7fca6424..ab3d3060b3c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatUsersActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatUsersActivity.java @@ -114,6 +114,9 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente private int sendMessagesRow; private int sendMediaRow; private int sendStickersRow; + private int sendGifsRow; + private int sendGamesRow; + private int useInlineBotRow; private int sendPollsRow; private int embedLinksRow; private int changeInfoRow; @@ -262,6 +265,9 @@ private void updateRows() { sendMessagesRow = -1; sendMediaRow = -1; sendStickersRow = -1; + sendGifsRow = -1; + sendGamesRow = -1; + useInlineBotRow = -1; sendPollsRow = -1; embedLinksRow = -1; addUsersRow = -1; @@ -289,6 +295,9 @@ private void updateRows() { sendMessagesRow = rowCount++; sendMediaRow = rowCount++; sendStickersRow = rowCount++; + sendGifsRow = rowCount++; + sendGamesRow = rowCount++; + useInlineBotRow = rowCount++; sendPollsRow = rowCount++; embedLinksRow = rowCount++; addUsersRow = rowCount++; @@ -993,7 +1002,13 @@ protected void onCancel() { } else if (position == sendMediaRow) { defaultBannedRights.send_media = !defaultBannedRights.send_media; } else if (position == sendStickersRow) { - defaultBannedRights.send_stickers = defaultBannedRights.send_games = defaultBannedRights.send_gifs = defaultBannedRights.send_inline = !defaultBannedRights.send_stickers; + defaultBannedRights.send_stickers = !defaultBannedRights.send_stickers; + } else if (position == sendGifsRow) { + defaultBannedRights.send_gifs = !defaultBannedRights.send_gifs; + } else if (position == sendGamesRow) { + defaultBannedRights.send_games = !defaultBannedRights.send_games; + } else if (position == useInlineBotRow) { + defaultBannedRights.send_inline = !defaultBannedRights.send_inline; } else if (position == embedLinksRow) { defaultBannedRights.embed_links = !defaultBannedRights.embed_links; } else if (position == sendPollsRow) { @@ -1022,12 +1037,33 @@ protected void onCancel() { } } if ((defaultBannedRights.view_messages || defaultBannedRights.send_messages) && !defaultBannedRights.send_stickers) { - defaultBannedRights.send_stickers = defaultBannedRights.send_games = defaultBannedRights.send_gifs = 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_gifs) { + defaultBannedRights.send_gifs = true; + RecyclerListView.ViewHolder holder = listView.findViewHolderForAdapterPosition(sendGifsRow); + 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(useInlineBotRow); + if (holder != null) { + ((TextCheckCell2) holder.itemView).setChecked(false); + } + } if ((defaultBannedRights.view_messages || defaultBannedRights.send_messages) && !defaultBannedRights.embed_links) { defaultBannedRights.embed_links = true; RecyclerListView.ViewHolder holder = listView.findViewHolderForAdapterPosition(embedLinksRow); @@ -3289,7 +3325,13 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { } else if (position == sendMediaRow) { checkCell.setTextAndCheck(LocaleController.getString("UserRestrictionsSendMedia", R.string.UserRestrictionsSendMedia), !defaultBannedRights.send_media, true); } else if (position == sendStickersRow) { - checkCell.setTextAndCheck(LocaleController.getString("UserRestrictionsSendStickers", R.string.UserRestrictionsSendStickers), !defaultBannedRights.send_stickers, true); + checkCell.setTextAndCheck(LocaleController.getString("THUserRestrictionsSendStickers", R.string.THUserRestrictionsSendStickers), !defaultBannedRights.send_stickers, true); + } else if (position == sendGifsRow) { + checkCell.setTextAndCheck(LocaleController.getString("THUserRestrictionsSendGifs", R.string.THUserRestrictionsSendGifs), !defaultBannedRights.send_gifs, true); + } else if (position == sendGamesRow) { + checkCell.setTextAndCheck(LocaleController.getString("THUserRestrictionsSendGames", R.string.THUserRestrictionsSendGames), !defaultBannedRights.send_games, true); + } else if (position == useInlineBotRow) { + checkCell.setTextAndCheck(LocaleController.getString("THUserRestrictionsUseInlineBots", R.string.THUserRestrictionsUseInlineBots), !defaultBannedRights.send_inline, true); } else if (position == embedLinksRow) { checkCell.setTextAndCheck(LocaleController.getString("UserRestrictionsEmbedLinks", R.string.UserRestrictionsEmbedLinks), !defaultBannedRights.embed_links, true); } else if (position == sendPollsRow) { @@ -3298,7 +3340,7 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { checkCell.setTextAndCheck(LocaleController.getString("CreateTopicsPermission", R.string.CreateTopicsPermission), !defaultBannedRights.manage_topics, false); } - if (position == sendMediaRow || position == sendStickersRow || position == embedLinksRow || position == sendPollsRow) { + if (position == sendMediaRow || position == sendStickersRow || position == sendGifsRow || position == sendGamesRow || position == useInlineBotRow || position == embedLinksRow || position == sendPollsRow) { checkCell.setEnabled(!defaultBannedRights.send_messages && !defaultBannedRights.view_messages); } else if (position == sendMessagesRow) { checkCell.setEnabled(!defaultBannedRights.view_messages); @@ -3384,7 +3426,8 @@ public int getItemViewType(int position) { } else if (position == removedUsersRow) { return 6; } else if (position == changeInfoRow || position == addUsersRow || position == pinMessagesRow || position == sendMessagesRow || - position == sendMediaRow || position == sendStickersRow || position == embedLinksRow || position == sendPollsRow || position == manageTopicsRow) { + position == sendMediaRow || position == sendStickersRow || position == sendGifsRow || position == sendGamesRow || + position == useInlineBotRow || position == embedLinksRow || position == sendPollsRow || position == manageTopicsRow) { return 7; } else if (position == membersHeaderRow || position == contactsHeaderRow || position == botHeaderRow || position == loadingHeaderRow) { return 8; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiView.java index 288a20b0221..46a5deac60a 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiView.java @@ -5508,40 +5508,49 @@ public void setStickersBanned(boolean value, long chatId) { } } - public void showStickerBanHint(boolean gif) { + public boolean showStickerBanHint(boolean gif) { if (mediaBanTooltip.getVisibility() == VISIBLE) { - return; + return false; } TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(currentChatId); if (chat == null) { - return; + return false; } String text; - if (!ChatObject.hasAdminRights(chat) && chat.default_banned_rights != null && chat.default_banned_rights.send_stickers) { - if (gif) { + boolean returnValue=true; + if (!ChatObject.hasAdminRights(chat) && chat.default_banned_rights != null) { + if (gif && chat.default_banned_rights.send_gifs) { mediaBanTooltip.setText(LocaleController.getString("GlobalAttachGifRestricted", R.string.GlobalAttachGifRestricted)); - } else { + returnValue=false; + } else if (!gif && chat.default_banned_rights.send_stickers) { mediaBanTooltip.setText(LocaleController.getString("GlobalAttachStickersRestricted", R.string.GlobalAttachStickersRestricted)); + returnValue=false; } - } else { + } + if(returnValue) { if (chat.banned_rights == null) { - return; + return true; } if (AndroidUtilities.isBannedForever(chat.banned_rights)) { - if (gif) { + if (gif && chat.banned_rights.send_gifs) { mediaBanTooltip.setText(LocaleController.getString("AttachGifRestrictedForever", R.string.AttachGifRestrictedForever)); - } else { + returnValue=false; + } else if (!gif && chat.banned_rights.send_stickers) { mediaBanTooltip.setText(LocaleController.getString("AttachStickersRestrictedForever", R.string.AttachStickersRestrictedForever)); + returnValue=false; } } else { - if (gif) { + if (gif && chat.banned_rights.send_gifs) { mediaBanTooltip.setText(LocaleController.formatString("AttachGifRestricted", R.string.AttachGifRestricted, LocaleController.formatDateForBan(chat.banned_rights.until_date))); - } else { + returnValue=false; + } else if (!gif && chat.banned_rights.send_stickers) { mediaBanTooltip.setText(LocaleController.formatString("AttachStickersRestricted", R.string.AttachStickersRestricted, LocaleController.formatDateForBan(chat.banned_rights.until_date))); + returnValue=false; } } } + if(returnValue) return true; mediaBanTooltip.setVisibility(View.VISIBLE); AnimatorSet AnimatorSet = new AnimatorSet(); AnimatorSet.playTogether( @@ -5573,6 +5582,7 @@ public void onAnimationEnd(Animator animation1) { }); AnimatorSet.setDuration(300); AnimatorSet.start(); + return false; } private void updateVisibleTrendingSets() { @@ -7146,10 +7156,7 @@ public void destroyItem(ViewGroup viewGroup, int position, Object object) { @Override public boolean canScrollToTab(int position) { - if ((position == 1 || position == 2) && currentChatId != 0) { - showStickerBanHint(position == 1); - return false; - } + if ((position == 1 || position == 2) && currentChatId != 0) return showStickerBanHint(position == 1); return true; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java index 80d2e9aa6c5..dd8fdf94faa 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java @@ -7858,15 +7858,7 @@ private void createActionBarMenu(boolean animated) { createAutoDeleteItem(context); } if (ChatObject.isChannel(chat)) { - if (isTopic) { - if (ChatObject.canManageTopic(currentAccount, chat, topicId)) { - editItemVisible = true; - } - } else { - if (ChatObject.hasAdminRights(chat) || chat.megagroup && ChatObject.canChangeChatInfo(chat)) { - editItemVisible = true; - } - } + editItemVisible = true; if (chatInfo != null) { if (ChatObject.canManageCalls(chat) && chatInfo.call == null) { otherItem.addSubItem(call_item, R.drawable.msg_voicechat, chat.megagroup && !chat.gigagroup ? LocaleController.getString("StartVoipChat", R.string.StartVoipChat) : LocaleController.getString("StartVoipChannel", R.string.StartVoipChannel)); @@ -7909,9 +7901,7 @@ private void createActionBarMenu(boolean animated) { ChatObject.Call call = getMessagesController().getGroupCall(chatId, false); callItemVisible = call != null; } - if (ChatObject.canChangeChatInfo(chat)) { - editItemVisible = true; - } + editItemVisible = true; if (!ChatObject.isKickedFromChat(chat) && !ChatObject.isLeftFromChat(chat)) { if (chatInfo == null || !chatInfo.participants_hidden || ChatObject.hasAdminRights(chat)) { canSearchMembers = true; diff --git a/TMessagesProj/src/main/res/values-ru/strings.xml b/TMessagesProj/src/main/res/values-ru/strings.xml index 5b9125ed463..14408566795 100644 --- a/TMessagesProj/src/main/res/values-ru/strings.xml +++ b/TMessagesProj/src/main/res/values-ru/strings.xml @@ -112,4 +112,8 @@ Скрывать стикеры в чатах Максимальный размер фото Убрать emoji из статуса + Отправка Стикеров + Отправк Гифок + Отправка Игр + Использование Инлайн-Ботов diff --git a/TMessagesProj/src/main/res/values/strings.xml b/TMessagesProj/src/main/res/values/strings.xml index 44586524a65..31d14d0da69 100644 --- a/TMessagesProj/src/main/res/values/strings.xml +++ b/TMessagesProj/src/main/res/values/strings.xml @@ -6159,4 +6159,8 @@ Hide stickers in chats Max photo size Disable emoji status + Send Stickers + Send GIFs + Send Games + Use Inline Bots From d7c10c29dc2b58c719b44ab7945b7541e3e4d966 Mon Sep 17 00:00:00 2001 From: Nikita S Date: Sun, 22 Jan 2023 23:21:17 +0100 Subject: [PATCH 4/4] Telegraher 9.33.18 * new OutOfMemory crash fix via foreground service (modded) * disable emoji status for chats also (but need to debug more) * extended admin rights to restrict gifs, stickers, games or inline bots for users in chat * the idea and main code from @arsLan and his Cherrygram * custom error messages if you got resticted for gifs only or stickers only * actually i track well strickers forbidden and let you to use gifs, but if gifs are forbidden (but stickers are allowed) you can use both (but gifs will not pass). Thats somewhere in the vanilla code i need to debug later. * channels and groups have edit icon now, so you can list all members (if not hidden) and admins. * the code which display admin numbers is from @arsLan, but i adapted it for channels only. * added english & russian translations for new options --- .github/workflows/Dockerfile_bundle.yml | 6 +++--- README.md | 2 +- README_CHANGES.md | 11 +++++++++++ gradle.properties | 4 ++-- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/workflows/Dockerfile_bundle.yml b/.github/workflows/Dockerfile_bundle.yml index 6445369df92..00fedc8c003 100644 --- a/.github/workflows/Dockerfile_bundle.yml +++ b/.github/workflows/Dockerfile_bundle.yml @@ -45,7 +45,7 @@ jobs: asset_name: ${{ env.ANAME }}${{ env.AARCH }}.apk asset_content_type: application/gzip env: - RNAME: Telegraher 9.33.17 - TNAME: graher_9.33.17_ - ANAME: Telegraher.9.33.17. + RNAME: Telegraher 9.33.18 + TNAME: graher_9.33.18_ + ANAME: Telegraher.9.33.18. AARCH: bundle diff --git a/README.md b/README.md index 41d17e47901..af5d99ec8e3 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ different) * Realeases are here: [https://github.com/nikitasius/Telegraher/releases](https://github.com/nikitasius/Telegraher/releases) * if it contain `beta` it mean it's BETA -* Last release `9.33.16`: [bundle](https://github.com/nikitasius/Telegraher/releases/tag/graher_9.33.16_bundle) +* Last release `9.33.18`: [bundle](https://github.com/nikitasius/Telegraher/releases/tag/graher_9.33.18_bundle) * Last beta: write `!beta` in chat ### Issues/Wishlist diff --git a/README_CHANGES.md b/README_CHANGES.md index 963f27f49e0..c46a248f792 100644 --- a/README_CHANGES.md +++ b/README_CHANGES.md @@ -1,5 +1,16 @@ # Changes +* 9.33.18 + * new OutOfMemory crash fix via foreground service (modded) + * disable emoji status for chats also (but need to debug more) + * extended admin rights to restrict gifs, stickers, games or inline bots for users in chat + * the idea and main code from @arsLan and his Cherrygram + * custom error messages if you got resticted for gifs only or stickers only + * actually i track well strickers forbidden and let you to use gifs, but if gifs are forbidden (but stickers are + allowed) you can use both (but gifs will not pass). Thats somewhere in the vanilla code i need to debug later. + * channels and groups have edit icon now, so you can list all members (if not hidden) and admins. + * the code which display admin numbers is from @arsLan, but i adapted it for channels only. + * added english & russian translations for new options * 9.33.17 * fixed spoiler bug * it's because a features you can enable via settings :) diff --git a/gradle.properties b/gradle.properties index c4d5fd46160..59964ca00a3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,8 +13,8 @@ # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true #Sat Mar 12 05:53:50 MSK 2016 -APP_VERSION_NAME=9.33.17 -APP_VERSION_CODE=3026017 +APP_VERSION_NAME=9.33.18 +APP_VERSION_CODE=3026018 APP_PACKAGE=com.evildayz.code.telegraher2 RELEASE_KEY_PASSWORD=android RELEASE_KEY_ALIAS=androidkey