Search in sources :

Example 1 with Phone

use of cx.ring.model.Phone in project ring-client-android by savoirfairelinux.

the class ConversationFragment method updateView.

@Override
public void updateView(final String address, final String name, final int state) {
    getActivity().runOnUiThread(() -> {
        if (state != 0 || mNumberAdapter == null || mNumberAdapter.isEmpty()) {
            return;
        }
        for (int i = 0; i < mNumberAdapter.getCount(); i++) {
            Phone phone = (Phone) mNumberAdapter.getItem(i);
            if (phone.getNumber() != null) {
                String ringID = phone.getNumber().getRawUriString();
                if (address.equals(ringID)) {
                    phone.getNumber().setUsername(name);
                    mNumberAdapter.notifyDataSetChanged();
                }
            }
        }
    });
}
Also used : Phone(cx.ring.model.Phone)

Example 2 with Phone

use of cx.ring.model.Phone in project ring-client-android by savoirfairelinux.

the class SmartListPresenter method quickCallClicked.

public void quickCallClicked() {
    if (mCallContact != null) {
        if (mCallContact.getPhones().size() > 1) {
            CharSequence[] numbers = new CharSequence[mCallContact.getPhones().size()];
            int i = 0;
            for (Phone p : mCallContact.getPhones()) {
                numbers[i++] = p.getNumber().getRawUriString();
            }
            getView().displayChooseNumberDialog(numbers);
        } else {
            if (!mHardwareService.isVideoAvailable() && !mHardwareService.hasMicrophone()) {
                getView().displayErrorToast(RingError.NO_INPUT);
                return;
            }
            getView().goToCallActivity(mAccountService.getCurrentAccount().getAccountID(), mCallContact.getPhones().get(0).getNumber().getRawUriString());
        }
    }
}
Also used : Phone(cx.ring.model.Phone)

Example 3 with Phone

use of cx.ring.model.Phone in project ring-client-android by savoirfairelinux.

the class NumberAdapter method getViewWithLongNumber.

private View getViewWithLongNumber(boolean longView, int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        if (longView) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_number, parent, false);
        } else {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_number_selected, parent, false);
        }
    }
    Phone number = mNumbers.get(position);
    ImageView numberIcon = convertView.findViewById(R.id.number_icon);
    numberIcon.setImageResource(number.getNumber().isRingId() ? R.drawable.ring_logo_24dp : R.drawable.ic_dialer_sip_black);
    if (longView) {
        TextView numberTxt = convertView.findViewById(R.id.number_txt);
        TextView numberLabelTxt = convertView.findViewById(R.id.number_label_txt);
        numberTxt.setText(number.getNumber().getRawUriString());
        numberLabelTxt.setText(ContactsContract.CommonDataKinds.Phone.getTypeLabel(mContext.getResources(), number.getCategory(), number.getLabel()));
    }
    return convertView;
}
Also used : Phone(cx.ring.model.Phone) TextView(android.widget.TextView) ImageView(android.widget.ImageView)

Example 4 with Phone

use of cx.ring.model.Phone 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

Phone (cx.ring.model.Phone)4 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 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 R (cx.ring.R)1 NumberAdapter (cx.ring.adapters.NumberAdapter)1 CallContact (cx.ring.model.CallContact)1 Conversation (cx.ring.model.Conversation)1 Uri (cx.ring.model.Uri)1 ArrayList (java.util.ArrayList)1