Commit d55c9b12 authored by Sébastien Blin's avatar Sébastien Blin

smartlistpresenter: fix copy number

Change-Id: I02c7e3cc868c6a69cf4daa9a47c1b421cf8267f8
GitLab: #859
parent d398fca3
......@@ -101,10 +101,10 @@ public class ActionHelper {
}
public static void launchCopyNumberToClipboardFromContact(final Context context,
final Uri callContact,
final Uri uri,
final Conversation.ConversationActionCallback callback) {
/*if (callContact == null) {
Log.d(TAG, "launchCopyNumberToClipboardFromContact: callContact is null");
if (uri == null) {
Log.d(TAG, "launchCopyNumberToClipboardFromContact: uri is null");
return;
}
......@@ -113,31 +113,9 @@ public class ActionHelper {
return;
}
if (callContact.getPhones().isEmpty()) {
Log.d(TAG, "launchCopyNumberToClipboardFromContact: no number to copy");
return;
if (callback != null) {
callback.copyContactNumberToClipboard(uri.toString());
}
if (callContact.getPhones().size() == 1 && callback != null) {
String number = callContact.getPhones().get(0).getNumber().toString();
callback.copyContactNumberToClipboard(number);
} else {
final NumberAdapter adapter = new NumberAdapter(context, callContact, true);
AlertDialog alertDialog = new MaterialAlertDialogBuilder(context)
.setTitle(R.string.conversation_action_select_peer_number)
.setAdapter(adapter, (dialog, which) -> {
if (callback != null) {
Phone selectedPhone = (Phone) adapter.getItem(which);
callback.copyContactNumberToClipboard(selectedPhone.getNumber().toString());
}
})
.create();
final int listViewSidePadding = (int) context
.getResources()
.getDimension(R.dimen.alert_dialog_side_padding_list_view);
alertDialog.getListView().setPadding(listViewSidePadding, 0, listViewSidePadding, 0);
alertDialog.show();
}*/
}
public static Intent getAddNumberIntentForContact(Contact contact) {
......
......@@ -22,6 +22,7 @@ package net.jami.smartlist;
import net.jami.facades.ConversationFacade;
import net.jami.model.Account;
import net.jami.model.Contact;
import net.jami.model.Uri;
import net.jami.mvp.RootPresenter;
import net.jami.services.AccountService;
......@@ -131,7 +132,14 @@ public class SmartListPresenter extends RootPresenter<SmartListView> {
}
public void copyNumber(SmartListViewModel smartListViewModel) {
getView().copyNumber(smartListViewModel.getUri());
if (smartListViewModel.isSwarm()) {
// Copy first contact's URI for a swarm
// TODO other modes
Contact contact = smartListViewModel.getContacts().get(0);
getView().copyNumber(contact.getUri());
} else {
getView().copyNumber(smartListViewModel.getUri());
}
}
public void clearConversation(SmartListViewModel smartListViewModel) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment