Skip to content

Commit

Permalink
feat: Show joined date in menu
Browse files Browse the repository at this point in the history
Co-authored-by: tehcneko <chsqwyx@gmail.com>
  • Loading branch information
omg-xtao and tehcneko committed Nov 24, 2024
1 parent bd33850 commit af84ffb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7470,7 +7470,7 @@ private TLRPC.ChatFull loadChatInfoInternal(long chatId, boolean isChannel, bool
user.status.expires = cursor.intValue(1);
}
loadedUsers.add(user);
participant.date = cursor.intValue(3);
//participant.date = cursor.intValue(3);
TLRPC.TL_chatChannelParticipant chatChannelParticipant = new TLRPC.TL_chatChannelParticipant();
chatChannelParticipant.user_id = MessageObject.getPeerId(participant.peer);
chatChannelParticipant.date = participant.date;
Expand Down
16 changes: 12 additions & 4 deletions TMessagesProj/src/main/java/org/telegram/ui/ChatUsersActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -1793,6 +1793,7 @@ private boolean createMenuForParticipant(final TLObject participant, boolean res
TLRPC.TL_chatBannedRights bannedRights;
TLRPC.TL_chatAdminRights adminRights;
String rank;
int joined;
if (participant instanceof TLRPC.ChannelParticipant) {
TLRPC.ChannelParticipant channelParticipant = (TLRPC.ChannelParticipant) participant;
peerId = MessageObject.getPeerId(channelParticipant.peer);
Expand All @@ -1801,6 +1802,7 @@ private boolean createMenuForParticipant(final TLObject participant, boolean res
adminRights = channelParticipant.admin_rights;
date = channelParticipant.date;
rank = channelParticipant.rank;
joined = channelParticipant.date;
} else if (participant instanceof TLRPC.ChatParticipant) {
TLRPC.ChatParticipant chatParticipant = (TLRPC.ChatParticipant) participant;
peerId = chatParticipant.user_id;
Expand All @@ -1809,13 +1811,15 @@ private boolean createMenuForParticipant(final TLObject participant, boolean res
bannedRights = null;
adminRights = null;
rank = "";
joined = chatParticipant.date;
} else {
peerId = 0;
canEdit = false;
bannedRights = null;
adminRights = null;
date = 0;
rank = null;
joined = 0;
}
if (peerId == 0 || peerId == getUserConfig().getClientUserId()) {
return false;
Expand All @@ -1832,14 +1836,14 @@ private boolean createMenuForParticipant(final TLObject participant, boolean res
}

boolean result = allowSetAdmin || (ChatObject.canBlockUsers(currentChat) && canEditAdmin);
if (resultOnly || !result) {
if (resultOnly || !result && joined == 0) {
return result;
}

Utilities.Callback<Integer> openRightsFor = action ->
openRightsEdit2(peerId, date, participant, adminRights, bannedRights, rank, canEditAdmin, action, false);

ItemOptions.makeOptions(this, view)
var options = ItemOptions.makeOptions(this, view)
.setScrimViewBackground(new ColorDrawable(Theme.getColor(Theme.key_windowBackgroundWhite)))
.addIf(allowSetAdmin, R.drawable.msg_admins, editingAdmin ? getString("EditAdminRights", R.string.EditAdminRights) : getString("SetAsAdmin", R.string.SetAsAdmin), () -> openRightsFor.run(0))
.addIf(canChangePermission, R.drawable.msg_permissions, getString("ChangePermissions", R.string.ChangePermissions), () -> {
Expand All @@ -1863,8 +1867,12 @@ private boolean createMenuForParticipant(final TLObject participant, boolean res
BulletinFactory.createRemoveFromChatBulletin(this, user, currentChat.title).show();
}
})
.setMinWidth(190)
.show();
.setMinWidth(190);
if (joined != 0) {
if (result) options.addGap();
options.addText(LocaleController.formatJoined(joined), 13);
}
options.show();
} else {

ItemOptions options = ItemOptions.makeOptions(this, view);
Expand Down
15 changes: 11 additions & 4 deletions TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -6443,6 +6443,7 @@ public boolean onMemberClick(TLRPC.ChatParticipant participant, boolean isLong,
boolean canEditAdmin;
boolean canRestrict;
boolean editingAdmin;
int joined;
final TLRPC.ChannelParticipant channelParticipant;

if (ChatObject.isChannel(currentChat)) {
Expand All @@ -6457,16 +6458,18 @@ public boolean onMemberClick(TLRPC.ChatParticipant participant, boolean isLong,
canRestrict = false;
}
editingAdmin = channelParticipant instanceof TLRPC.TL_channelParticipantAdmin;
joined = channelParticipant.date;
} else {
channelParticipant = null;
allowKick = currentChat.creator || participant instanceof TLRPC.TL_chatParticipant && (ChatObject.canBlockUsers(currentChat) || participant.inviter_id == getUserConfig().getClientUserId());
canEditAdmin = currentChat.creator;
canRestrict = currentChat.creator;
editingAdmin = participant instanceof TLRPC.TL_chatParticipantAdmin;
joined = participant.date;
}

boolean result = (canEditAdmin || canRestrict || allowKick);
if (resultOnly || !result) {
if (resultOnly || !result && joined == 0) {
return result;
}

Expand All @@ -6478,7 +6481,7 @@ public boolean onMemberClick(TLRPC.ChatParticipant participant, boolean isLong,
}
};

ItemOptions.makeOptions(this, view)
var options = ItemOptions.makeOptions(this, view)
.setScrimViewBackground(new ColorDrawable(Theme.getColor(Theme.key_windowBackgroundWhite)))
.addIf(canEditAdmin, R.drawable.msg_admins, editingAdmin ? LocaleController.getString(R.string.EditAdminRights) : LocaleController.getString(R.string.SetAsAdmin), () -> openRightsEdit.run(0))
.addIf(canRestrict, R.drawable.msg_permissions, LocaleController.getString(R.string.ChangePermissions), () -> {
Expand All @@ -6498,8 +6501,12 @@ public boolean onMemberClick(TLRPC.ChatParticipant participant, boolean isLong,
.addIf(allowKick, R.drawable.msg_remove, LocaleController.getString(R.string.KickFromGroup), true, () -> {
kickUser(selectedUser, participant);
})
.setMinWidth(190)
.show();
.setMinWidth(190);
if (joined != 0) {
if (result) options.addGap();
options.addText(LocaleController.formatJoined(joined), 13);
}
options.show();
} else {
if (participant.user_id == getUserConfig().getClientUserId()) {
return false;
Expand Down

0 comments on commit af84ffb

Please sign in to comment.