/**
   * Retrieve the value of the selected sip uri
   *
   * @return the contact to call as a ToCall object containing account to use and number to call
   */
  public ToCall getValue() {
    String userName = dialUser.getText().toString();
    String toCall = "";
    Long accountToUse = null;
    if (TextUtils.isEmpty(userName)) {
      return null;
    }
    userName = userName.replaceAll("[ \t]", "");
    SipProfile acc = accountChooserButtonText.getSelectedAccount();
    if (acc != null) {
      accountToUse = acc.id;
      // If this is a sip account
      if (accountToUse > SipProfile.INVALID_ID) {
        if (Pattern.matches(".*@.*", userName)) {
          toCall = "sip:" + userName + "";
        } else if (!TextUtils.isEmpty(acc.getDefaultDomain())) {
          toCall = "sip:" + userName + "@" + acc.getDefaultDomain();
        } else {
          toCall = "sip:" + userName;
        }
      } else {
        toCall = userName;
      }
    } else {
      toCall = userName;
    }

    return new ToCall(accountToUse, toCall);
  }
 @Override
 public void onItemClick(AdapterView<?> ad, View view, int position, long arg3) {
   String number = (String) view.getTag();
   SipProfile account = accountChooserButtonText.getSelectedAccount();
   String rewritten = Filter.rewritePhoneNumber(getContext(), account.id, number);
   setTextValue(rewritten);
   Log.d(THIS_FILE, "Clicked contact " + number);
 }
  private void updateDialTextHelper() {

    String dialUserValue = dialUser.getText().toString();

    accountChooserButtonText.setChangeable(TextUtils.isEmpty(dialUserValue));

    SipProfile acc = accountChooserButtonText.getSelectedAccount();
    if (!Pattern.matches(".*@.*", dialUserValue) && acc != null && acc.id > SipProfile.INVALID_ID) {
      domainTextHelper.setText("@" + acc.getDefaultDomain());
    } else {
      domainTextHelper.setText("");
    }
  }
 public SipProfile getSelectedAccount() {
   return accountChooserButtonText.getSelectedAccount();
 }