started work on call history
This commit is contained in:
@@ -82,6 +82,16 @@
|
|||||||
android:value="com.tutpro.baresip.MainActivity" />
|
android:value="com.tutpro.baresip.MainActivity" />
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".HistoryActivity"
|
||||||
|
android:label="Call History"
|
||||||
|
android:parentActivityName=".MainActivity"
|
||||||
|
android:theme="@style/AppTheme">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
|
android:value="com.tutpro.baresip.MainActivity" />
|
||||||
|
</activity>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".AboutActivity"
|
android:name=".AboutActivity"
|
||||||
android:label="About"
|
android:label="About"
|
||||||
|
|||||||
@@ -468,8 +468,7 @@ Java_com_tutpro_baresip_MainActivity_ua_1hangup(JNIEnv *env, jobject thiz,
|
|||||||
const uint16_t native_code = code;
|
const uint16_t native_code = code;
|
||||||
const char *native_reason = (*env)->GetStringUTFChars(env, reason, 0);
|
const char *native_reason = (*env)->GetStringUTFChars(env, reason, 0);
|
||||||
LOGD("hanging up call %s/%s\n", native_ua, native_call);
|
LOGD("hanging up call %s/%s\n", native_ua, native_call);
|
||||||
// ua_hangup(ua, call, native_code, native_reason);
|
ua_hangup(ua, call, native_code, native_reason);
|
||||||
ua_hangup(uag_current(), NULL, 0, NULL);
|
|
||||||
(*env)->ReleaseStringUTFChars(env, javaUA, native_ua);
|
(*env)->ReleaseStringUTFChars(env, javaUA, native_ua);
|
||||||
(*env)->ReleaseStringUTFChars(env, javaCall, native_call);
|
(*env)->ReleaseStringUTFChars(env, javaCall, native_call);
|
||||||
(*env)->ReleaseStringUTFChars(env, reason, native_reason);
|
(*env)->ReleaseStringUTFChars(env, reason, native_reason);
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
package com.tutpro.baresip;
|
package com.tutpro.baresip;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.MenuItem;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class AboutActivity extends AppCompatActivity {
|
public class AboutActivity extends AppCompatActivity {
|
||||||
@@ -17,5 +20,16 @@ public class AboutActivity extends AppCompatActivity {
|
|||||||
aboutView.setText(getString(R.string.aboutText));
|
aboutView.setText(getString(R.string.aboutText));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case android.R.id.home:
|
||||||
|
Intent i = new Intent();
|
||||||
|
setResult(RESULT_CANCELED, i);
|
||||||
|
finish();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ public class EditAccountsActivity extends AppCompatActivity {
|
|||||||
finish();
|
finish();
|
||||||
return true;
|
return true;
|
||||||
case R.id.cancel:
|
case R.id.cancel:
|
||||||
|
case android.R.id.home:
|
||||||
setResult(RESULT_CANCELED, i);
|
setResult(RESULT_CANCELED, i);
|
||||||
finish();
|
finish();
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -89,13 +89,12 @@ public class EditConfigActivity extends AppCompatActivity {
|
|||||||
e.toString());
|
e.toString());
|
||||||
}
|
}
|
||||||
Log.d("Baresip", "Updated config file");
|
Log.d("Baresip", "Updated config file");
|
||||||
i.putExtra("action", "save");
|
|
||||||
setResult(RESULT_OK, i);
|
setResult(RESULT_OK, i);
|
||||||
finish();
|
finish();
|
||||||
return true;
|
return true;
|
||||||
case R.id.cancel:
|
case R.id.cancel:
|
||||||
i.putExtra("action", "cancel");
|
case android.R.id.home:
|
||||||
setResult(RESULT_OK, i);
|
setResult(RESULT_CANCELED, i);
|
||||||
finish();
|
finish();
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ public class EditContactsActivity extends AppCompatActivity {
|
|||||||
finish();
|
finish();
|
||||||
return true;
|
return true;
|
||||||
case R.id.cancel:
|
case R.id.cancel:
|
||||||
|
case android.R.id.home:
|
||||||
i.putExtra("action", "cancel");
|
i.putExtra("action", "cancel");
|
||||||
setResult(RESULT_OK, i);
|
setResult(RESULT_OK, i);
|
||||||
finish();
|
finish();
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
package com.tutpro.baresip;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.ListView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
|
||||||
|
public class HistoryActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
static ArrayList<String> history = new ArrayList<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_history);
|
||||||
|
|
||||||
|
final ListView listview = (ListView) findViewById(R.id.history);
|
||||||
|
|
||||||
|
ArrayList<String> history = new ArrayList<>();
|
||||||
|
for (Integer i = MainActivity.History.size() - 1; i >= 0; i--) {
|
||||||
|
History h = MainActivity.History.get(i);
|
||||||
|
if (h.getAoR().equals(MainActivity.ua_aor(MainActivity.ua_current()))) {
|
||||||
|
if (!history.contains(h.getPeerURI())) history.add(h.getPeerURI());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayAdapter<String> adapter = new ArrayAdapter<>(this,
|
||||||
|
android.R.layout.simple_list_item_1, history);
|
||||||
|
listview.setAdapter(adapter);
|
||||||
|
|
||||||
|
listview.setOnItemClickListener(new OnItemClickListener() {
|
||||||
|
public void onItemClick(AdapterView<?> parent, View view,
|
||||||
|
int position, long id) {
|
||||||
|
Intent i = new Intent();
|
||||||
|
i.putExtra("peer_uri", ((TextView) view).getText());
|
||||||
|
setResult(RESULT_OK, i);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case android.R.id.home:
|
||||||
|
Log.d("Baresip", "Back array was pressed");
|
||||||
|
Intent i = new Intent();
|
||||||
|
setResult(RESULT_CANCELED, i);
|
||||||
|
finish();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -17,9 +17,11 @@ import android.widget.RelativeLayout.LayoutParams;
|
|||||||
import android.widget.AutoCompleteTextView;
|
import android.widget.AutoCompleteTextView;
|
||||||
import android.view.*;
|
import android.view.*;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.text.format.Time;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
@@ -36,8 +38,15 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
static ArrayAdapter<String> CalleeAdapter = null;
|
static ArrayAdapter<String> CalleeAdapter = null;
|
||||||
static ArrayList<Call> In = new ArrayList<>();
|
static ArrayList<Call> In = new ArrayList<>();
|
||||||
static ArrayList<Call> Out = new ArrayList<>();
|
static ArrayList<Call> Out = new ArrayList<>();
|
||||||
|
static ArrayList<History> History = new ArrayList();
|
||||||
|
static String CurrentUA = null;
|
||||||
|
|
||||||
private static final int RECORD_AUDIO_PERMISSION = 1;
|
private static final int RECORD_AUDIO_PERMISSION = 1;
|
||||||
|
private static final int EDIT_ACCOUNTS_CODE = 1;
|
||||||
|
private static final int EDIT_CONTACTS_CODE = 2;
|
||||||
|
private static final int EDIT_CONFIG_CODE = 3;
|
||||||
|
private static final int HISTORY_CODE = 4;
|
||||||
|
private static final int ABOUT_CODE = 5;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -57,11 +66,17 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
String aor = AoRs.get(position);
|
String aor = AoRs.get(position);
|
||||||
Log.i("Baresip", "Setting " + aor + " current");
|
Log.i("Baresip", "Setting " + aor + " current");
|
||||||
ua_current_set(aor);
|
ua_current_set(aor);
|
||||||
ArrayList<Call> out = uaCalls(Out, ua_current());
|
CurrentUA = ua_current();
|
||||||
|
ArrayList<Call> out = uaCalls(Out, CurrentUA);
|
||||||
if (out.size() == 0) {
|
if (out.size() == 0) {
|
||||||
callee.setHint("Callee");
|
callee.setHint("Callee");
|
||||||
callButton.setText("Call");
|
callButton.setText("Call");
|
||||||
|
if (aorHasHistory(History, aor)) {
|
||||||
|
holdButton.setText("History");
|
||||||
|
holdButton.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
holdButton.setVisibility(View.INVISIBLE);
|
holdButton.setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
callee.setText(out.get(0).getPeerURI());
|
callee.setText(out.get(0).getPeerURI());
|
||||||
callButton.setText(out.get(0).getStatus());
|
callButton.setText(out.get(0).getStatus());
|
||||||
@@ -76,7 +91,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
holdButton.setVisibility(View.INVISIBLE);
|
holdButton.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ArrayList<Call> in = uaCalls(In, ua_current());
|
ArrayList<Call> in = uaCalls(In, CurrentUA);
|
||||||
int view_count = layout.getChildCount();
|
int view_count = layout.getChildCount();
|
||||||
Log.d("Baresip", "View count is " + view_count);
|
Log.d("Baresip", "View count is " + view_count);
|
||||||
if (view_count > 5) {
|
if (view_count > 5) {
|
||||||
@@ -150,50 +165,45 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
callButton.setOnClickListener(new View.OnClickListener() {
|
callButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
String ua = ua_current();
|
|
||||||
if (callButton.getText().toString().equals("Call")) {
|
if (callButton.getText().toString().equals("Call")) {
|
||||||
String callee = ((EditText) findViewById(R.id.callee)).getText().toString();
|
call(((EditText) findViewById(R.id.callee)).getText().toString());
|
||||||
String uri = EditContactsActivity.findContactURI(callee);
|
|
||||||
if (!uri.startsWith("sip:")) uri = "sip:" + uri;
|
|
||||||
if (!uri.contains("@")) {
|
|
||||||
String aor = ua_aor(ua);
|
|
||||||
String host = aor.substring(aor.indexOf("@") + 1);
|
|
||||||
uri = uri + "@" + host;
|
|
||||||
}
|
|
||||||
((EditText) findViewById(R.id.callee)).setText(uri);
|
|
||||||
Log.i("Baresip", "Calling " + uri);
|
|
||||||
String call = ua_connect(uri);
|
|
||||||
if (!call.equals("")) {
|
|
||||||
Log.i("Baresip", "Adding outgoing call " + ua + "/" + call +
|
|
||||||
"/" + uri);
|
|
||||||
Out.add(new Call(ua, call, uri,"Cancel"));
|
|
||||||
callButton.setText("Cancel");
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Log.i("Baresip", "Hanging up " +
|
Log.i("Baresip", "Canceling UA " + CurrentUA + " call " +
|
||||||
|
Out.get(0).getCall() + " to " +
|
||||||
((EditText) findViewById(R.id.callee)).getText());
|
((EditText) findViewById(R.id.callee)).getText());
|
||||||
ua_hangup(ua, "", 486, "Rejected");
|
ua_hangup(CurrentUA, Out.get(0).getCall(), 486, "Rejected");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
holdButton = (Button)findViewById(R.id.holdButton);
|
holdButton = (Button)findViewById(R.id.holdButton);
|
||||||
|
if (aorHasHistory(History, ua_aor(ua_current()))) {
|
||||||
|
holdButton.setText("History");
|
||||||
|
} else {
|
||||||
holdButton.setVisibility(View.INVISIBLE);
|
holdButton.setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
holdButton.setOnClickListener(new View.OnClickListener() {
|
holdButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (holdButton.getText().toString().equals("Hold")) {
|
switch (holdButton.getText().toString()) {
|
||||||
|
case "Hold":
|
||||||
Log.i("Baresip", "Holding up " +
|
Log.i("Baresip", "Holding up " +
|
||||||
((EditText) findViewById(R.id.callee)).getText());
|
((EditText) findViewById(R.id.callee)).getText());
|
||||||
call_hold(Out.get(0).getCall());
|
call_hold(Out.get(0).getCall());
|
||||||
Out.get(0).setHold(true);
|
Out.get(0).setHold(true);
|
||||||
holdButton.setText("Unhold");
|
holdButton.setText("Unhold");
|
||||||
} else {
|
break;
|
||||||
|
case "Unhold":
|
||||||
Log.i("Baresip", "Unholding " +
|
Log.i("Baresip", "Unholding " +
|
||||||
((EditText) findViewById(R.id.callee)).getText());
|
((EditText) findViewById(R.id.callee)).getText());
|
||||||
call_unhold(Out.get(0).getCall());
|
call_unhold(Out.get(0).getCall());
|
||||||
Out.get(0).setHold(false);
|
Out.get(0).setHold(false);
|
||||||
holdButton.setText("Hold");
|
holdButton.setText("Hold");
|
||||||
|
break;
|
||||||
|
case "History":
|
||||||
|
Intent i = new Intent(MainActivity.this, HistoryActivity.class);
|
||||||
|
startActivityForResult(i, HISTORY_CODE);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -239,20 +249,19 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.accounts:
|
case R.id.accounts:
|
||||||
i = new Intent(this, EditAccountsActivity.class);
|
i = new Intent(this, EditAccountsActivity.class);
|
||||||
startActivityForResult(i, 1);
|
startActivityForResult(i, EDIT_ACCOUNTS_CODE);
|
||||||
return true;
|
return true;
|
||||||
case R.id.contacts:
|
case R.id.contacts:
|
||||||
startActivity(new Intent(MainActivity.this,
|
i = new Intent(this, EditContactsActivity.class);
|
||||||
EditContactsActivity.class));
|
startActivityForResult(i, EDIT_CONTACTS_CODE);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
case R.id.config:
|
case R.id.config:
|
||||||
i = new Intent(this, EditConfigActivity.class);
|
i = new Intent(this, EditConfigActivity.class);
|
||||||
startActivityForResult(i, 2);
|
startActivityForResult(i, EDIT_CONFIG_CODE);
|
||||||
return true;
|
return true;
|
||||||
case R.id.about:
|
case R.id.about:
|
||||||
startActivity(new Intent(MainActivity.this,
|
i = new Intent(this, AboutActivity.class);
|
||||||
AboutActivity.class));
|
startActivityForResult(i, ABOUT_CODE);
|
||||||
return true;
|
return true;
|
||||||
case R.id.quit:
|
case R.id.quit:
|
||||||
if (running) {
|
if (running) {
|
||||||
@@ -273,7 +282,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
if (requestCode == 1) {
|
if (requestCode == EDIT_ACCOUNTS_CODE) {
|
||||||
if(resultCode == RESULT_OK) {
|
if(resultCode == RESULT_OK) {
|
||||||
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
|
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
|
||||||
alertDialog.setTitle("Alert");
|
alertDialog.setTitle("Alert");
|
||||||
@@ -290,16 +299,27 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
Log.d("Baresip", "Edit accounts canceled");
|
Log.d("Baresip", "Edit accounts canceled");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (requestCode == 2) {
|
if (requestCode == EDIT_CONFIG_CODE) {
|
||||||
if(resultCode == RESULT_OK) {
|
if(resultCode == RESULT_OK) {
|
||||||
Utils.alertView(this,
|
Utils.alertView(this,
|
||||||
"You need to restart baresip in order to activate saved config!");
|
"You need to restart baresip in order to activate saved config!");
|
||||||
reload_config();
|
reload_config();
|
||||||
}
|
}
|
||||||
if (resultCode == RESULT_CANCELED) {
|
if (resultCode == RESULT_CANCELED) {
|
||||||
Log.d("Baresip", "Edit accounts canceled");
|
Log.d("Baresip", "Edit config canceled");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (requestCode == HISTORY_CODE) {
|
||||||
|
if(resultCode == RESULT_OK) {
|
||||||
|
callee.setText(data.getStringExtra("peer_uri"));
|
||||||
|
}
|
||||||
|
if(resultCode == RESULT_CANCELED) {
|
||||||
|
Log.d("Baresip", "History canceled");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((requestCode == EDIT_CONTACTS_CODE) || (requestCode == ABOUT_CODE)) {
|
||||||
|
Log.d("Baresip", "Back arrow or Cancel pressed at request: " + requestCode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addAccount(String ua) {
|
public void addAccount(String ua) {
|
||||||
@@ -316,6 +336,28 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void call(String callee) {
|
||||||
|
if (callee.length() == 0) return;
|
||||||
|
String uri = EditContactsActivity.findContactURI(callee);
|
||||||
|
if (!uri.startsWith("sip:")) uri = "sip:" + uri;
|
||||||
|
if (!uri.contains("@")) {
|
||||||
|
String aor = ua_aor(CurrentUA);
|
||||||
|
String host = aor.substring(aor.indexOf("@") + 1);
|
||||||
|
uri = uri + "@" + host;
|
||||||
|
}
|
||||||
|
((EditText) findViewById(R.id.callee)).setText(uri);
|
||||||
|
Log.i("Baresip", "Calling " + uri);
|
||||||
|
String call = ua_connect(uri);
|
||||||
|
if (!call.equals("")) {
|
||||||
|
Log.i("Baresip", "Adding outgoing call " + CurrentUA + "/" + call +
|
||||||
|
"/" + uri);
|
||||||
|
Out.add(new Call(CurrentUA, call, uri, "Cancel"));
|
||||||
|
History.add(new History(ua_aor(CurrentUA), uri, "out"));
|
||||||
|
callButton.setText("Cancel");
|
||||||
|
holdButton.setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void copyAsset(String asset, String path) {
|
private void copyAsset(String asset, String path) {
|
||||||
try {
|
try {
|
||||||
AssetManager assetManager = getAssets();
|
AssetManager assetManager = getAssets();
|
||||||
@@ -474,15 +516,21 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Boolean aorHasHistory(ArrayList<History> history, String aor) {
|
||||||
|
for (History h : history) {
|
||||||
|
if (h.getAoR().equals(aor)) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private void updateStatus(String event, final String ua, final String call) {
|
private void updateStatus(String event, final String ua, final String call) {
|
||||||
String aor = ua_aor(ua);
|
String aor = ua_aor(ua);
|
||||||
int index, call_index;
|
int call_index;
|
||||||
|
|
||||||
Log.d("Baresip", "Handling event " + event + " for " + ua + "/" + call + "/" +
|
Log.d("Baresip", "Handling event " + event + " for " + ua + "/" + call + "/" +
|
||||||
aor);
|
aor);
|
||||||
for (index = 0; index < Accounts.size(); index++) {
|
for (int account_index = 0; account_index < Accounts.size(); account_index++) {
|
||||||
if (Accounts.get(index).getAoR().equals(aor)) {
|
if (Accounts.get(account_index).getAoR().equals(aor)) {
|
||||||
Log.d("Baresip", "Found AoR at index " + index);
|
Log.d("Baresip", "Found AoR at index " + account_index);
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case "registering":
|
case "registering":
|
||||||
case "unregistering":
|
case "unregistering":
|
||||||
@@ -490,9 +538,9 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
break;
|
break;
|
||||||
case "registered":
|
case "registered":
|
||||||
Log.d("Baresip", "Setting status to green");
|
Log.d("Baresip", "Setting status to green");
|
||||||
Accounts.get(index).setStatus("OK");
|
Accounts.get(account_index).setStatus("OK");
|
||||||
AoRs.set(index, aor);
|
AoRs.set(account_index, aor);
|
||||||
Images.set(index, R.drawable.green);
|
Images.set(account_index, R.drawable.green);
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@@ -502,9 +550,9 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
break;
|
break;
|
||||||
case "registering failed":
|
case "registering failed":
|
||||||
Log.d("Baresip", "Setting status to red");
|
Log.d("Baresip", "Setting status to red");
|
||||||
Accounts.get(index).setStatus("FAIL");
|
Accounts.get(account_index).setStatus("FAIL");
|
||||||
AoRs.set(index, aor);
|
AoRs.set(account_index, aor);
|
||||||
Images.set(index, R.drawable.red);
|
Images.set(account_index, R.drawable.red);
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@@ -521,7 +569,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
Log.d("Baresip", "Update Hangup and Hold");
|
Log.d("Baresip", "Update Hangup and Hold");
|
||||||
Out.get(out_index).setStatus("Hangup");
|
Out.get(out_index).setStatus("Hangup");
|
||||||
Out.get(out_index).setHold(false);
|
Out.get(out_index).setHold(false);
|
||||||
if (ua.equals(ua_current())) {
|
if (ua.equals(CurrentUA)) {
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@@ -540,11 +588,11 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
final String peer_uri = call_peeruri(call);
|
final String peer_uri = call_peeruri(call);
|
||||||
Log.d("Baresip", "Incoming call " + ua + "/" + call + "/" +
|
Log.d("Baresip", "Incoming call " + ua + "/" + call + "/" +
|
||||||
peer_uri);
|
peer_uri);
|
||||||
|
|
||||||
final Call new_call = new Call(ua, call, peer_uri, "Answer");
|
final Call new_call = new Call(ua, call, peer_uri, "Answer");
|
||||||
In.add(new_call);
|
In.add(new_call);
|
||||||
Log.d("Baresip", "Current UA is " + ua_current());
|
History.add(new History(aor, peer_uri, "in"));
|
||||||
if (ua.equals(ua_current())) {
|
Log.d("Baresip", "Current UA is " + CurrentUA);
|
||||||
|
if (ua.equals(CurrentUA)) {
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@@ -555,18 +603,23 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
break;
|
break;
|
||||||
case "call closed":
|
case "call closed":
|
||||||
call_index = callIndex(In, ua, call);
|
call_index = callIndex(In, ua, call);
|
||||||
|
Log.d("Baresip", "Incoming call index is " + call_index);
|
||||||
if (call_index != -1) {
|
if (call_index != -1) {
|
||||||
Log.d("Baresip", "Removing inbound call " + ua + "/" +
|
Log.d("Baresip", "Removing inbound call " + ua + "/" +
|
||||||
call + "/" + In.get(index).getPeerURI());
|
call + "/" + In.get(call_index).getPeerURI());
|
||||||
final int view_id = (call_index + 1) * 10;
|
final int view_id = (call_index + 1) * 10;
|
||||||
final int remove_count = In.size() - call_index;
|
final int remove_count = In.size() - call_index;
|
||||||
final int final_call_index = call_index;
|
final int final_call_index = call_index;
|
||||||
In.remove(call_index);
|
In.remove(call_index);
|
||||||
Log.d("Baresip", "Current UA is " + ua_current());
|
Log.d("Baresip", "Current UA is " + CurrentUA);
|
||||||
if (ua.equals(ua_current())) {
|
if (ua.equals(CurrentUA)) {
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
if (callButton.getText().equals("Call")) {
|
||||||
|
holdButton.setText("History");
|
||||||
|
holdButton.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
View caller_heading = layout.findViewById(view_id);
|
View caller_heading = layout.findViewById(view_id);
|
||||||
int view_index = layout.indexOfChild(caller_heading);
|
int view_index = layout.indexOfChild(caller_heading);
|
||||||
Log.d("Baresip", "Index of caller heading is " +
|
Log.d("Baresip", "Index of caller heading is " +
|
||||||
@@ -581,17 +634,21 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
call_index = callIndex(Out, ua, call);
|
call_index = callIndex(Out, ua, call);
|
||||||
|
Log.d("Baresip", "Outgoing call index is " + call_index);
|
||||||
if (call_index != -1) {
|
if (call_index != -1) {
|
||||||
Log.d("Baresip", "Removing called call " + ua + "/" +
|
Log.d("Baresip", "Removing called call " + ua + "/" +
|
||||||
call + "/" + Out.get(index).getPeerURI());
|
call + "/" + Out.get(call_index).getPeerURI());
|
||||||
Out.remove(call_index);
|
Out.remove(call_index);
|
||||||
if (ua.equals(ua_current())) {
|
if (ua.equals(CurrentUA)) {
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
callButton.setText("Call");
|
callButton.setText("Call");
|
||||||
callButton.setEnabled(true);
|
callButton.setEnabled(true);
|
||||||
holdButton.setVisibility(View.INVISIBLE);
|
callee.setText("");
|
||||||
|
callee.setHint("Callee");
|
||||||
|
holdButton.setText("History");
|
||||||
|
holdButton.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -610,11 +667,11 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
public native void baresipStart(String path);
|
public native void baresipStart(String path);
|
||||||
public native void baresipStop();
|
public native void baresipStop();
|
||||||
public native String ua_aor(String ua);
|
public static native String ua_current();
|
||||||
|
public static native String ua_aor(String ua);
|
||||||
public native Boolean ua_isregistered(long ua_ptr);
|
public native Boolean ua_isregistered(long ua_ptr);
|
||||||
public native String ua_call(String ua);
|
public native String ua_call(String ua);
|
||||||
public native String call_peeruri(String call);
|
public native String call_peeruri(String call);
|
||||||
public native String ua_current();
|
|
||||||
public static native void ua_current_set(String s);
|
public static native void ua_current_set(String s);
|
||||||
public native String ua_connect(String s);
|
public native String ua_connect(String s);
|
||||||
public native void ua_answer(String ua, String call);
|
public native void ua_answer(String ua, String call);
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||||
|
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingTop="@dimen/activity_vertical_margin"
|
||||||
|
tools:context="com.tutpro.baresip.HistoryActivity">
|
||||||
|
|
||||||
|
<ListView
|
||||||
|
android:id="@+id/history"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user