Search in sources :

Example 1 with NumberAdapter

use of cx.ring.adapters.NumberAdapter in project ring-client-android by savoirfairelinux.

the class ConversationFragment method displayNumberSpinner.

@Override
public void displayNumberSpinner(final Conversation conversation, final Uri number) {
    getActivity().runOnUiThread(() -> {
        mNumberSpinner.setVisibility(View.VISIBLE);
        mNumberAdapter = new NumberAdapter(getActivity(), conversation.getContact(), false);
        mNumberSpinner.setAdapter(mNumberAdapter);
        mNumberSpinner.setSelection(getIndex(mNumberSpinner, number));
    });
}
Also used : NumberAdapter(cx.ring.adapters.NumberAdapter)

Example 2 with NumberAdapter

use of cx.ring.adapters.NumberAdapter in project ring-client-android by savoirfairelinux.

the class ActionHelper method launchCopyNumberToClipboardFromContact.

public static void launchCopyNumberToClipboardFromContact(final Context context, final CallContact callContact, final Conversation.ConversationActionCallback callback) {
    if (callContact == null) {
        Log.d(TAG, "launchCopyNumberToClipboardFromContact: callContact is null");
        return;
    }
    if (context == null) {
        Log.d(TAG, "launchCopyNumberToClipboardFromContact: activity is null");
        return;
    }
    if (callContact.getPhones().isEmpty()) {
        Log.d(TAG, "launchCopyNumberToClipboardFromContact: no number to copy");
        return;
    }
    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 AlertDialog.Builder(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();
    }
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) Context(android.content.Context) Uri(cx.ring.model.Uri) Intent(android.content.Intent) R(cx.ring.R) ArrayList(java.util.ArrayList) AlertDialog(android.support.v7.app.AlertDialog) ContactsContract(android.provider.ContactsContract) Phone(cx.ring.model.Phone) ActivityNotFoundException(android.content.ActivityNotFoundException) CallContact(cx.ring.model.CallContact) ContentValues(android.content.ContentValues) NumberAdapter(cx.ring.adapters.NumberAdapter) Conversation(cx.ring.model.Conversation) NumberAdapter(cx.ring.adapters.NumberAdapter) Phone(cx.ring.model.Phone)

Aggregations

NumberAdapter (cx.ring.adapters.NumberAdapter)2 ActivityNotFoundException (android.content.ActivityNotFoundException)1 ContentValues (android.content.ContentValues)1 Context (android.content.Context)1 Intent (android.content.Intent)1 ContactsContract (android.provider.ContactsContract)1 AlertDialog (android.support.v7.app.AlertDialog)1 R (cx.ring.R)1 CallContact (cx.ring.model.CallContact)1 Conversation (cx.ring.model.Conversation)1 Phone (cx.ring.model.Phone)1 Uri (cx.ring.model.Uri)1 ArrayList (java.util.ArrayList)1