Long press to mention by name
This commit is contained in:
@@ -1376,7 +1376,7 @@ public class MentionsAdapter extends RecyclerListView.SelectionAdapter implement
|
||||
}
|
||||
|
||||
public boolean isLongClickEnabled() {
|
||||
return searchResultHashtags != null || searchResultCommands != null;
|
||||
return searchResultHashtags != null || searchResultCommands != null || searchResultUsernames != null;
|
||||
}
|
||||
|
||||
public boolean isBotCommands() {
|
||||
|
||||
@@ -6982,6 +6982,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
if (getParentActivity() == null || !mentionsAdapter.isLongClickEnabled()) {
|
||||
return false;
|
||||
}
|
||||
int len = mentionsAdapter.getResultLength();
|
||||
int start = mentionsAdapter.getResultStartPosition();
|
||||
Object object = mentionsAdapter.getItem(position);
|
||||
if (object instanceof String) {
|
||||
if (mentionsAdapter.isBotCommands()) {
|
||||
@@ -7000,6 +7002,15 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
showDialog(builder.create());
|
||||
return true;
|
||||
}
|
||||
} else if (object instanceof TLRPC.User) {
|
||||
TLRPC.User user = (TLRPC.User) object;
|
||||
if (!(searchingForUser && searchContainer.getVisibility() == View.VISIBLE) && user != null) {
|
||||
String name = UserObject.getFirstName(user, false);
|
||||
Spannable spannable = new SpannableString(name + " ");
|
||||
spannable.setSpan(new URLSpanUserMention("" + user.id, 3), 0, spannable.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
chatActivityEnterView.replaceWithText(start, len, spannable, false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
@@ -223,6 +223,7 @@ import org.telegram.ui.Components.StickersAlert;
|
||||
import org.telegram.ui.Components.TextViewSwitcher;
|
||||
import org.telegram.ui.Components.Tooltip;
|
||||
import org.telegram.ui.Components.URLSpanReplacement;
|
||||
import org.telegram.ui.Components.URLSpanUserMention;
|
||||
import org.telegram.ui.Components.URLSpanUserMentionPhotoViewer;
|
||||
import org.telegram.ui.Components.UndoView;
|
||||
import org.telegram.ui.Components.VideoEditTextureView;
|
||||
@@ -5990,6 +5991,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
});
|
||||
|
||||
mentionListView.setOnItemLongClickListener((view, position) -> {
|
||||
int len = mentionsAdapter.getResultLength();
|
||||
int start = mentionsAdapter.getResultStartPosition();
|
||||
Object object = mentionsAdapter.getItem(position);
|
||||
if (object instanceof String) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity, resourcesProvider);
|
||||
@@ -5999,6 +6002,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;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user