mirror of
https://github.com/NekoX-Dev/NekoX.git
synced 2024-11-30 07:00:21 +01:00
Long press to mention users by name in PhotoViewer
(cherry picked from commit fc2f81f1fe0ebd44a04b43f711cac6bed1c474a2)
This commit is contained in:
parent
9945aacf39
commit
69da1b17a8
@ -4666,6 +4666,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
|
||||
mentionListView.setOnItemLongClickListener((view, position) -> {
|
||||
Object object = mentionsAdapter.getItem(position);
|
||||
int start = mentionsAdapter.getResultStartPosition();
|
||||
int len = mentionsAdapter.getResultLength();
|
||||
if (object instanceof String) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
||||
builder.setTitle(LocaleController.getString("NekoX", R.string.NekoX));
|
||||
@ -4674,6 +4676,13 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||
showAlertDialog(builder);
|
||||
return true;
|
||||
} else if (object instanceof TLRPC.User) {
|
||||
TLRPC.User user = (TLRPC.User) object;
|
||||
String name = UserObject.getFirstName(user);
|
||||
Spannable spannable = new SpannableString("@" + name + " ");
|
||||
spannable.setSpan(new URLSpanUserMentionPhotoViewer("" + user.id, true), 0, spannable.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
captionEditText.replaceWithText(start, len, spannable, false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user