Skip to content

Commit

Permalink
Merge pull request #144 from nikitasius/noshit_9.3.3
Browse files Browse the repository at this point in the history
Telegraher 9.33.18
  • Loading branch information
nikitasius authored Jan 22, 2023
2 parents 7edc8b1 + d7c10c2 commit 88ae3b9
Show file tree
Hide file tree
Showing 14 changed files with 222 additions and 61 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/Dockerfile_bundle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions README_CHANGES.md
Original file line number Diff line number Diff line change
@@ -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 :)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
72 changes: 59 additions & 13 deletions TMessagesProj/src/main/java/org/telegram/ui/ChatEditActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)));
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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++;
}
Expand All @@ -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);
Expand Down
Loading

0 comments on commit 88ae3b9

Please sign in to comment.