Skip to content

Commit

Permalink
feat: Set only delete messages before a date
Browse files Browse the repository at this point in the history
Co-authored-by: tehcneko <[email protected]>
  • Loading branch information
omg-xtao and tehcneko committed Sep 10, 2023
1 parent ff4b1b9 commit 993996c
Show file tree
Hide file tree
Showing 4 changed files with 344 additions and 47 deletions.
95 changes: 48 additions & 47 deletions TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -33641,53 +33641,54 @@ private void nkbtn_onclick_actionbar(int id) {
updateActionModeTitle();
updateVisibleRows();
} else if (id == nkheaderbtn_zibi) {
Context context = getParentActivity();
AlertDialog.Builder builder = new AlertDialog.Builder(context);
TextView messageTextView = new TextView(context);
messageTextView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
messageTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
messageTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
FrameLayout frameLayout = new FrameLayout(context);
builder.setView(frameLayout);
AvatarDrawable avatarDrawable = new AvatarDrawable();
avatarDrawable.setTextSize(AndroidUtilities.dp(12));
BackupImageView imageView = new BackupImageView(context);
imageView.setRoundRadius(AndroidUtilities.dp(20));
frameLayout.addView(imageView, LayoutHelper.createFrame(40, 40, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 22, 5, 22, 0));
if (currentChat != null) {
avatarDrawable.setInfo(currentChat);
imageView.setImage(ImageLocation.getForChat(currentChat, ImageLocation.TYPE_SMALL), "50_50", avatarDrawable, currentChat);
} else if (currentUser != null) {
avatarDrawable.setInfo(currentUser);
imageView.setImage(ImageLocation.getForUser(currentUser, ImageLocation.TYPE_SMALL), "50_50", avatarDrawable, currentUser);
}
TextView textView = new TextView(context);
textView.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem));
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
textView.setLines(1);
textView.setMaxLines(1);
textView.setSingleLine(true);
textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
textView.setEllipsize(TextUtils.TruncateAt.END);
textView.setText(LocaleController.getString("DeleteAllFromSelf", R.string.DeleteAllFromSelf));

frameLayout.addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 21 : 76), 11, (LocaleController.isRTL ? 76 : 21), 0));
frameLayout.addView(messageTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 24, 57, 24, 9));
messageTextView.setText(AndroidUtilities.replaceTags(LocaleController.getString("DeleteAllFromSelfAlert", R.string.DeleteAllFromSelfAlert)));
builder.setPositiveButton(LocaleController.getString("DeleteAll", R.string.DeleteAll), (dialogInterface, i) -> {
if (ChatObject.isChannel(currentChat) && currentChat.megagroup && ChatObject.canUserDoAction(currentChat, ChatObject.ACTION_DELETE_MESSAGES)) {
getMessagesController().deleteUserChannelHistory(currentChat, UserConfig.getInstance(currentAccount).getCurrentUser(), null, 0);
}
getMessageHelper().deleteUserChannelHistoryWithSearch(getParentActivity(), dialog_id, UserConfig.getInstance(currentAccount).getCurrentUser());
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
AlertDialog alertDialog = builder.create();
showDialog(alertDialog);
TextView button = (TextView) alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
if (button != null) {
button.setTextColor(Theme.getColor(Theme.key_dialogTextRed));
}
getMessageHelper().createDeleteHistoryAlert(ChatActivity.this, currentChat, forumTopic, mergeDialogId, themeDelegate);
// Context context = getParentActivity();
// AlertDialog.Builder builder = new AlertDialog.Builder(context);
// TextView messageTextView = new TextView(context);
// messageTextView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
// messageTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
// messageTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
// FrameLayout frameLayout = new FrameLayout(context);
// builder.setView(frameLayout);
// AvatarDrawable avatarDrawable = new AvatarDrawable();
// avatarDrawable.setTextSize(AndroidUtilities.dp(12));
// BackupImageView imageView = new BackupImageView(context);
// imageView.setRoundRadius(AndroidUtilities.dp(20));
// frameLayout.addView(imageView, LayoutHelper.createFrame(40, 40, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 22, 5, 22, 0));
// if (currentChat != null) {
// avatarDrawable.setInfo(currentChat);
// imageView.setImage(ImageLocation.getForChat(currentChat, ImageLocation.TYPE_SMALL), "50_50", avatarDrawable, currentChat);
// } else if (currentUser != null) {
// avatarDrawable.setInfo(currentUser);
// imageView.setImage(ImageLocation.getForUser(currentUser, ImageLocation.TYPE_SMALL), "50_50", avatarDrawable, currentUser);
// }
// TextView textView = new TextView(context);
// textView.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem));
// textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
// textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
// textView.setLines(1);
// textView.setMaxLines(1);
// textView.setSingleLine(true);
// textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
// textView.setEllipsize(TextUtils.TruncateAt.END);
// textView.setText(LocaleController.getString("DeleteAllFromSelf", R.string.DeleteAllFromSelf));
//
// frameLayout.addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 21 : 76), 11, (LocaleController.isRTL ? 76 : 21), 0));
// frameLayout.addView(messageTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 24, 57, 24, 9));
// messageTextView.setText(AndroidUtilities.replaceTags(LocaleController.getString("DeleteAllFromSelfAlert", R.string.DeleteAllFromSelfAlert)));
// builder.setPositiveButton(LocaleController.getString("DeleteAll", R.string.DeleteAll), (dialogInterface, i) -> {
// if (ChatObject.isChannel(currentChat) && currentChat.megagroup && ChatObject.canUserDoAction(currentChat, ChatObject.ACTION_DELETE_MESSAGES)) {
// getMessagesController().deleteUserChannelHistory(currentChat, UserConfig.getInstance(currentAccount).getCurrentUser(), null, 0);
// }
// getMessageHelper().deleteUserChannelHistoryWithSearch(getParentActivity(), dialog_id, UserConfig.getInstance(currentAccount).getCurrentUser());
// });
// builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
// AlertDialog alertDialog = builder.create();
// showDialog(alertDialog);
// TextView button = (TextView) alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
// if (button != null) {
// button.setTextColor(Theme.getColor(Theme.key_dialogTextRed));
// }
} else if (id == nkheaderbtn_upgrade) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setMessage(LocaleController.getString("ConvertGroupAlert", R.string.ConvertGroupAlert));
Expand Down
Loading

0 comments on commit 993996c

Please sign in to comment.