single-click on a member can be used to start a chat

This commit is contained in:
B. Petersen
2019-05-23 13:34:57 +02:00
parent 43d122fdfe
commit 0ea15b738f
2 changed files with 26 additions and 5 deletions
@@ -138,26 +138,27 @@ public class ProfileSettingsAdapter extends RecyclerView.Adapter
if (holder.itemView instanceof ContactSelectionListItem) {
ContactSelectionListItem contactItem = (ContactSelectionListItem) holder.itemView;
int id = itemData.get(i).contactId;
int contactId = itemData.get(i).contactId;
DcContact dcContact = null;
String label = null;
String name;
String addr = null;
if (id == DcContact.DC_CONTACT_ID_ADD_MEMBER) {
if (contactId == DcContact.DC_CONTACT_ID_ADD_MEMBER) {
name = context.getString(R.string.group_add_members);
}
else if (id == DcContact.DC_CONTACT_ID_QR_INVITE) {
else if (contactId == DcContact.DC_CONTACT_ID_QR_INVITE) {
name = context.getString(R.string.qrshow_title);
}
else {
dcContact = dcContext.getContact(itemData.get(i).contactId);
dcContact = dcContext.getContact(contactId);
name = dcContact.getDisplayName();
addr = dcContact.getAddr();
}
contactItem.unbind(glideRequests);
contactItem.set(glideRequests, id, dcContact, name, addr, label, false, true);
contactItem.set(glideRequests, contactId, dcContact, name, addr, label, false, true);
contactItem.setOnClickListener(view -> clickListener.onMemberClicked(contactId));
}
else if (holder.itemView instanceof ConversationListItem) {
ConversationListItem conversationListItem = (ConversationListItem) holder.itemView;
@@ -188,6 +189,7 @@ public class ProfileSettingsAdapter extends RecyclerView.Adapter
public interface ItemClickListener {
void onSettingsClicked(int settingsId);
void onSharedChatClicked(int chatId);
void onMemberClicked(int contactId);
}
@Override
@@ -144,6 +144,25 @@ public class ProfileSettingsFragment extends Fragment
break;
}
}
@Override
public void onMemberClicked(int contactId) {
if(contactId>DcContact.DC_CONTACT_ID_LAST_SPECIAL) {
new AlertDialog.Builder(getContext())
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
int chatId = dcContext.createChatByContactId(contactId);
if( chatId != 0 ) {
Intent intent = new Intent(getContext(), ConversationActivity.class);
intent.putExtra(ConversationActivity.CHAT_ID_EXTRA, chatId);
getContext().startActivity(intent);
}
})
.setNegativeButton(android.R.string.cancel, null)
.setMessage(getString(R.string.ask_start_chat_with, dcContext.getContact(contactId).getDisplayName()))
.show();
}
}
@Override
public void onSharedChatClicked(int chatId) {
Intent intent = new Intent(getContext(), ConversationActivity.class);