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();
}
}
}
});
}
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());
}
}
}
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;
}
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();
}
}
Aggregations