Search in sources :

Example 1 with DialHelper

use of com.voipgrid.vialer.util.DialHelper in project vialer-android by VoIPGRID.

the class CallRecordAdapter method onClick.

@Override
public void onClick(View view) {
    // Get the position of the list item the buttons is clicked for.
    View parentRow = (View) view.getParent();
    ListView listView = (ListView) parentRow.getParent();
    final int position = listView.getPositionForView(parentRow);
    // Get the call record.
    CallRecord callRecord = getItem(position);
    String direction = callRecord.getDirection();
    String numberToCall = null;
    // Determine direction and the number we need to call.
    if (direction.equals(CallRecord.DIRECTION_OUTBOUND)) {
        numberToCall = callRecord.getDialedNumber();
    } else if (direction.equals(CallRecord.DIRECTION_INBOUND)) {
        numberToCall = callRecord.getCaller();
    }
    if (numberToCall != null && !mCallAlreadySetup) {
        mCallAlreadySetup = true;
        new DialHelper(mActivity, new JsonStorage(mActivity), ConnectivityHelper.get(mActivity), new AnalyticsHelper(((AnalyticsApplication) mActivity.getApplication()).getDefaultTracker())).callNumber(numberToCall, "");
        PreferenceManager.getDefaultSharedPreferences(mActivity).edit().putString(DialerActivity.LAST_DIALED, numberToCall).apply();
    }
}
Also used : ListView(android.widget.ListView) DialHelper(com.voipgrid.vialer.util.DialHelper) JsonStorage(com.voipgrid.vialer.util.JsonStorage) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView) CallRecord(com.voipgrid.vialer.api.models.CallRecord) AnalyticsHelper(com.voipgrid.vialer.analytics.AnalyticsHelper)

Example 2 with DialHelper

use of com.voipgrid.vialer.util.DialHelper in project vialer-android by VoIPGRID.

the class DialerActivity method onCallNumber.

/**
 * Initiate an outgoing call by starting CallActivity and pass a SipUri based on the number
 *
 * @param number      number to call
 * @param contactName contact name to display
 */
public void onCallNumber(String number, String contactName) {
    DialHelper dialHelper = new DialHelper(this, mJsonStorage, mConnectivityHelper, mAnalyticsHelper);
    String phoneNumberToCall = PhoneNumberUtils.format(number);
    if (number.length() < 1) {
        Toast.makeText(this, getString(R.string.dialer_invalid_number), Toast.LENGTH_LONG).show();
    } else {
        dialHelper.callNumber(phoneNumberToCall, contactName);
        mSharedPreferences.edit().putString(LAST_DIALED, number).apply();
        mNumberInputView.clear();
    }
}
Also used : DialHelper(com.voipgrid.vialer.util.DialHelper)

Aggregations

DialHelper (com.voipgrid.vialer.util.DialHelper)2 View (android.view.View)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 AnalyticsHelper (com.voipgrid.vialer.analytics.AnalyticsHelper)1 CallRecord (com.voipgrid.vialer.api.models.CallRecord)1 JsonStorage (com.voipgrid.vialer.util.JsonStorage)1 CircleImageView (de.hdodenhof.circleimageview.CircleImageView)1