diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 05aa1799..75df544c 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -36,7 +36,7 @@
+
+
+
+
-
+
diff --git a/app/src/main/cpp/baresip.c b/app/src/main/cpp/baresip.c
index e2301dce..90f99331 100644
--- a/app/src/main/cpp/baresip.c
+++ b/app/src/main/cpp/baresip.c
@@ -468,8 +468,7 @@ Java_com_tutpro_baresip_MainActivity_ua_1hangup(JNIEnv *env, jobject thiz,
const uint16_t native_code = code;
const char *native_reason = (*env)->GetStringUTFChars(env, reason, 0);
LOGD("hanging up call %s/%s\n", native_ua, native_call);
- // ua_hangup(ua, call, native_code, native_reason);
- ua_hangup(uag_current(), NULL, 0, NULL);
+ ua_hangup(ua, call, native_code, native_reason);
(*env)->ReleaseStringUTFChars(env, javaUA, native_ua);
(*env)->ReleaseStringUTFChars(env, javaCall, native_call);
(*env)->ReleaseStringUTFChars(env, reason, native_reason);
diff --git a/app/src/main/java/com/tutpro/baresip/AboutActivity.java b/app/src/main/java/com/tutpro/baresip/AboutActivity.java
index dc667ec9..a13d75f0 100644
--- a/app/src/main/java/com/tutpro/baresip/AboutActivity.java
+++ b/app/src/main/java/com/tutpro/baresip/AboutActivity.java
@@ -1,7 +1,10 @@
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.widget.TextView;
public class AboutActivity extends AppCompatActivity {
@@ -17,5 +20,16 @@ public class AboutActivity extends AppCompatActivity {
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;
+ }
}
diff --git a/app/src/main/java/com/tutpro/baresip/EditAccountsActivity.java b/app/src/main/java/com/tutpro/baresip/EditAccountsActivity.java
index 0b9544aa..348e8cac 100644
--- a/app/src/main/java/com/tutpro/baresip/EditAccountsActivity.java
+++ b/app/src/main/java/com/tutpro/baresip/EditAccountsActivity.java
@@ -69,34 +69,35 @@ public class EditAccountsActivity extends AppCompatActivity {
public boolean onOptionsItemSelected(MenuItem item) {
Intent i = new Intent();
switch (item.getItemId()) {
- case R.id.save:
- try {
- FileOutputStream fOut =
- new FileOutputStream(file.getAbsoluteFile(), false);
- OutputStreamWriter fWriter = new OutputStreamWriter(fOut);
- String res = editText.getText().toString();
+ case R.id.save:
try {
- fWriter.write(res);
- fWriter.close();
- fOut.close();
- } catch (java.io.IOException e) {
- Log.e("Baresip", "Failed to write accounts file: " +
- e.toString());
+ FileOutputStream fOut =
+ new FileOutputStream(file.getAbsoluteFile(), false);
+ OutputStreamWriter fWriter = new OutputStreamWriter(fOut);
+ String res = editText.getText().toString();
+ try {
+ fWriter.write(res);
+ fWriter.close();
+ fOut.close();
+ } catch (java.io.IOException e) {
+ Log.e("Baresip", "Failed to write accounts file: " +
+ e.toString());
+ }
+ } catch (java.io.FileNotFoundException e) {
+ Log.e("Baresip", "Failed to find accounts file: " +
+ e.toString());
}
- } catch (java.io.FileNotFoundException e) {
- Log.e("Baresip", "Failed to find accounts file: " +
- e.toString());
- }
- Log.d("Baresip", "Updated accounts file");
- setResult(RESULT_OK, i);
- finish();
- return true;
- case R.id.cancel:
- setResult(RESULT_CANCELED, i);
- finish();
- return true;
- default:
- return super.onOptionsItemSelected(item);
+ Log.d("Baresip", "Updated accounts file");
+ setResult(RESULT_OK, i);
+ finish();
+ return true;
+ case R.id.cancel:
+ case android.R.id.home:
+ setResult(RESULT_CANCELED, i);
+ finish();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
}
}
diff --git a/app/src/main/java/com/tutpro/baresip/EditConfigActivity.java b/app/src/main/java/com/tutpro/baresip/EditConfigActivity.java
index 9b41610f..3832e0df 100644
--- a/app/src/main/java/com/tutpro/baresip/EditConfigActivity.java
+++ b/app/src/main/java/com/tutpro/baresip/EditConfigActivity.java
@@ -70,36 +70,35 @@ public class EditConfigActivity extends AppCompatActivity {
public boolean onOptionsItemSelected(MenuItem item) {
Intent i = new Intent(this, MainActivity.class);
switch (item.getItemId()) {
- case R.id.save:
- try {
- FileOutputStream fOut =
- new FileOutputStream(file.getAbsoluteFile(), false);
- OutputStreamWriter fWriter = new OutputStreamWriter(fOut);
- String res = editText.getText().toString();
+ case R.id.save:
try {
- fWriter.write(res);
- fWriter.close();
- fOut.close();
- } catch (java.io.IOException e) {
- Log.e("Baresip", "Failed to write config file: " +
+ FileOutputStream fOut =
+ new FileOutputStream(file.getAbsoluteFile(), false);
+ OutputStreamWriter fWriter = new OutputStreamWriter(fOut);
+ String res = editText.getText().toString();
+ try {
+ fWriter.write(res);
+ fWriter.close();
+ fOut.close();
+ } catch (java.io.IOException e) {
+ Log.e("Baresip", "Failed to write config file: " +
+ e.toString());
+ }
+ } catch (java.io.FileNotFoundException e) {
+ Log.e("Baresip", "Failed to find config file: " +
e.toString());
}
- } catch (java.io.FileNotFoundException e) {
- Log.e("Baresip", "Failed to find config file: " +
- e.toString());
- }
- Log.d("Baresip", "Updated config file");
- i.putExtra("action", "save");
- setResult(RESULT_OK, i);
- finish();
- return true;
- case R.id.cancel:
- i.putExtra("action", "cancel");
- setResult(RESULT_OK, i);
- finish();
- return true;
- default:
- return super.onOptionsItemSelected(item);
+ Log.d("Baresip", "Updated config file");
+ setResult(RESULT_OK, i);
+ finish();
+ return true;
+ case R.id.cancel:
+ case android.R.id.home:
+ setResult(RESULT_CANCELED, i);
+ finish();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
}
}
diff --git a/app/src/main/java/com/tutpro/baresip/EditContactsActivity.java b/app/src/main/java/com/tutpro/baresip/EditContactsActivity.java
index d27d12a4..a5cc3c34 100644
--- a/app/src/main/java/com/tutpro/baresip/EditContactsActivity.java
+++ b/app/src/main/java/com/tutpro/baresip/EditContactsActivity.java
@@ -44,31 +44,32 @@ public class EditContactsActivity extends AppCompatActivity {
public boolean onOptionsItemSelected(MenuItem item) {
Intent i = new Intent(this, MainActivity.class);
- switch (item.getItemId()) {
- case R.id.save:
- String path = getApplicationContext().getFilesDir().getAbsolutePath() + "/contacts";
- File file = new File(path);
- Utils.putFileContents(file, editText.getText().toString());
- Log.d("Baresip", "Updated contacts file");
- MainActivity.contacts_remove();
- updateContactsAndNames();
- // MainActivity.CalleeAdapter.notifyDataSetChanged();
- MainActivity.CalleeAdapter = new ArrayAdapter
- (this,android.R.layout.select_dialog_item, Names);
- MainActivity.callee.setThreshold(2);
- MainActivity.callee.setAdapter(MainActivity.CalleeAdapter);
- i.putExtra("action", "save");
- setResult(RESULT_OK, i);
- finish();
- return true;
- case R.id.cancel:
- i.putExtra("action", "cancel");
- setResult(RESULT_OK, i);
- finish();
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
+ switch (item.getItemId()) {
+ case R.id.save:
+ String path = getApplicationContext().getFilesDir().getAbsolutePath() + "/contacts";
+ File file = new File(path);
+ Utils.putFileContents(file, editText.getText().toString());
+ Log.d("Baresip", "Updated contacts file");
+ MainActivity.contacts_remove();
+ updateContactsAndNames();
+ // MainActivity.CalleeAdapter.notifyDataSetChanged();
+ MainActivity.CalleeAdapter = new ArrayAdapter
+ (this,android.R.layout.select_dialog_item, Names);
+ MainActivity.callee.setThreshold(2);
+ MainActivity.callee.setAdapter(MainActivity.CalleeAdapter);
+ i.putExtra("action", "save");
+ setResult(RESULT_OK, i);
+ finish();
+ return true;
+ case R.id.cancel:
+ case android.R.id.home:
+ i.putExtra("action", "cancel");
+ setResult(RESULT_OK, i);
+ finish();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
}
static public void updateContactsAndNames() {
diff --git a/app/src/main/java/com/tutpro/baresip/HistoryActivity.java b/app/src/main/java/com/tutpro/baresip/HistoryActivity.java
new file mode 100644
index 00000000..e1b490b2
--- /dev/null
+++ b/app/src/main/java/com/tutpro/baresip/HistoryActivity.java
@@ -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 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 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 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;
+ }
+
+}
diff --git a/app/src/main/java/com/tutpro/baresip/MainActivity.java b/app/src/main/java/com/tutpro/baresip/MainActivity.java
index d32be9be..fea19384 100644
--- a/app/src/main/java/com/tutpro/baresip/MainActivity.java
+++ b/app/src/main/java/com/tutpro/baresip/MainActivity.java
@@ -17,9 +17,11 @@ import android.widget.RelativeLayout.LayoutParams;
import android.widget.AutoCompleteTextView;
import android.view.*;
import android.util.Log;
+import android.content.Context;
+import android.text.format.Time;
+
import java.util.*;
import java.io.*;
-import android.content.Context;
public class MainActivity extends AppCompatActivity {
@@ -36,8 +38,15 @@ public class MainActivity extends AppCompatActivity {
static ArrayAdapter CalleeAdapter = null;
static ArrayList In = new ArrayList<>();
static ArrayList Out = new ArrayList<>();
+ static ArrayList History = new ArrayList();
+ static String CurrentUA = null;
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
protected void onCreate(Bundle savedInstanceState) {
@@ -57,11 +66,17 @@ public class MainActivity extends AppCompatActivity {
String aor = AoRs.get(position);
Log.i("Baresip", "Setting " + aor + " current");
ua_current_set(aor);
- ArrayList out = uaCalls(Out, ua_current());
+ CurrentUA = ua_current();
+ ArrayList out = uaCalls(Out, CurrentUA);
if (out.size() == 0) {
callee.setHint("Callee");
callButton.setText("Call");
- holdButton.setVisibility(View.INVISIBLE);
+ if (aorHasHistory(History, aor)) {
+ holdButton.setText("History");
+ holdButton.setVisibility(View.VISIBLE);
+ } else {
+ holdButton.setVisibility(View.INVISIBLE);
+ }
} else {
callee.setText(out.get(0).getPeerURI());
callButton.setText(out.get(0).getStatus());
@@ -76,7 +91,7 @@ public class MainActivity extends AppCompatActivity {
holdButton.setVisibility(View.INVISIBLE);
}
}
- ArrayList in = uaCalls(In, ua_current());
+ ArrayList in = uaCalls(In, CurrentUA);
int view_count = layout.getChildCount();
Log.d("Baresip", "View count is " + view_count);
if (view_count > 5) {
@@ -150,50 +165,45 @@ public class MainActivity extends AppCompatActivity {
callButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- String ua = ua_current();
if (callButton.getText().toString().equals("Call")) {
- String callee = ((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");
- }
+ call(((EditText) findViewById(R.id.callee)).getText().toString());
} else {
- Log.i("Baresip", "Hanging up " +
+ Log.i("Baresip", "Canceling UA " + CurrentUA + " call " +
+ Out.get(0).getCall() + " to " +
((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.setVisibility(View.INVISIBLE);
+ if (aorHasHistory(History, ua_aor(ua_current()))) {
+ holdButton.setText("History");
+ } else {
+ holdButton.setVisibility(View.INVISIBLE);
+ }
holdButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- if (holdButton.getText().toString().equals("Hold")) {
- Log.i("Baresip", "Holding up " +
+ switch (holdButton.getText().toString()) {
+ case "Hold":
+ Log.i("Baresip", "Holding up " +
((EditText) findViewById(R.id.callee)).getText());
- call_hold(Out.get(0).getCall());
- Out.get(0).setHold(true);
- holdButton.setText("Unhold");
- } else {
- Log.i("Baresip", "Unholding " +
+ call_hold(Out.get(0).getCall());
+ Out.get(0).setHold(true);
+ holdButton.setText("Unhold");
+ break;
+ case "Unhold":
+ Log.i("Baresip", "Unholding " +
((EditText) findViewById(R.id.callee)).getText());
- call_unhold(Out.get(0).getCall());
- Out.get(0).setHold(false);
- holdButton.setText("Hold");
+ call_unhold(Out.get(0).getCall());
+ Out.get(0).setHold(false);
+ 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()) {
case R.id.accounts:
i = new Intent(this, EditAccountsActivity.class);
- startActivityForResult(i, 1);
+ startActivityForResult(i, EDIT_ACCOUNTS_CODE);
return true;
case R.id.contacts:
- startActivity(new Intent(MainActivity.this,
- EditContactsActivity.class));
-
+ i = new Intent(this, EditContactsActivity.class);
+ startActivityForResult(i, EDIT_CONTACTS_CODE);
return true;
case R.id.config:
i = new Intent(this, EditConfigActivity.class);
- startActivityForResult(i, 2);
+ startActivityForResult(i, EDIT_CONFIG_CODE);
return true;
case R.id.about:
- startActivity(new Intent(MainActivity.this,
- AboutActivity.class));
+ i = new Intent(this, AboutActivity.class);
+ startActivityForResult(i, ABOUT_CODE);
return true;
case R.id.quit:
if (running) {
@@ -273,7 +282,7 @@ public class MainActivity extends AppCompatActivity {
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- if (requestCode == 1) {
+ if (requestCode == EDIT_ACCOUNTS_CODE) {
if(resultCode == RESULT_OK) {
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("Alert");
@@ -290,16 +299,27 @@ public class MainActivity extends AppCompatActivity {
Log.d("Baresip", "Edit accounts canceled");
}
}
- if (requestCode == 2) {
+ if (requestCode == EDIT_CONFIG_CODE) {
if(resultCode == RESULT_OK) {
Utils.alertView(this,
"You need to restart baresip in order to activate saved config!");
reload_config();
}
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) {
@@ -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) {
try {
AssetManager assetManager = getAssets();
@@ -474,15 +516,21 @@ public class MainActivity extends AppCompatActivity {
return result;
}
+ private Boolean aorHasHistory(ArrayList 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) {
String aor = ua_aor(ua);
- int index, call_index;
-
+ int call_index;
Log.d("Baresip", "Handling event " + event + " for " + ua + "/" + call + "/" +
aor);
- for (index = 0; index < Accounts.size(); index++) {
- if (Accounts.get(index).getAoR().equals(aor)) {
- Log.d("Baresip", "Found AoR at index " + index);
+ for (int account_index = 0; account_index < Accounts.size(); account_index++) {
+ if (Accounts.get(account_index).getAoR().equals(aor)) {
+ Log.d("Baresip", "Found AoR at index " + account_index);
switch (event) {
case "registering":
case "unregistering":
@@ -490,9 +538,9 @@ public class MainActivity extends AppCompatActivity {
break;
case "registered":
Log.d("Baresip", "Setting status to green");
- Accounts.get(index).setStatus("OK");
- AoRs.set(index, aor);
- Images.set(index, R.drawable.green);
+ Accounts.get(account_index).setStatus("OK");
+ AoRs.set(account_index, aor);
+ Images.set(account_index, R.drawable.green);
runOnUiThread(new Runnable() {
@Override
public void run() {
@@ -502,9 +550,9 @@ public class MainActivity extends AppCompatActivity {
break;
case "registering failed":
Log.d("Baresip", "Setting status to red");
- Accounts.get(index).setStatus("FAIL");
- AoRs.set(index, aor);
- Images.set(index, R.drawable.red);
+ Accounts.get(account_index).setStatus("FAIL");
+ AoRs.set(account_index, aor);
+ Images.set(account_index, R.drawable.red);
runOnUiThread(new Runnable() {
@Override
public void run() {
@@ -521,7 +569,7 @@ public class MainActivity extends AppCompatActivity {
Log.d("Baresip", "Update Hangup and Hold");
Out.get(out_index).setStatus("Hangup");
Out.get(out_index).setHold(false);
- if (ua.equals(ua_current())) {
+ if (ua.equals(CurrentUA)) {
runOnUiThread(new Runnable() {
@Override
public void run() {
@@ -540,11 +588,11 @@ public class MainActivity extends AppCompatActivity {
final String peer_uri = call_peeruri(call);
Log.d("Baresip", "Incoming call " + ua + "/" + call + "/" +
peer_uri);
-
final Call new_call = new Call(ua, call, peer_uri, "Answer");
In.add(new_call);
- Log.d("Baresip", "Current UA is " + ua_current());
- if (ua.equals(ua_current())) {
+ History.add(new History(aor, peer_uri, "in"));
+ Log.d("Baresip", "Current UA is " + CurrentUA);
+ if (ua.equals(CurrentUA)) {
runOnUiThread(new Runnable() {
@Override
public void run() {
@@ -555,18 +603,23 @@ public class MainActivity extends AppCompatActivity {
break;
case "call closed":
call_index = callIndex(In, ua, call);
+ Log.d("Baresip", "Incoming call index is " + call_index);
if (call_index != -1) {
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 remove_count = In.size() - call_index;
final int final_call_index = call_index;
In.remove(call_index);
- Log.d("Baresip", "Current UA is " + ua_current());
- if (ua.equals(ua_current())) {
+ Log.d("Baresip", "Current UA is " + CurrentUA);
+ if (ua.equals(CurrentUA)) {
runOnUiThread(new Runnable() {
@Override
public void run() {
+ if (callButton.getText().equals("Call")) {
+ holdButton.setText("History");
+ holdButton.setVisibility(View.VISIBLE);
+ }
View caller_heading = layout.findViewById(view_id);
int view_index = layout.indexOfChild(caller_heading);
Log.d("Baresip", "Index of caller heading is " +
@@ -581,17 +634,21 @@ public class MainActivity extends AppCompatActivity {
break;
}
call_index = callIndex(Out, ua, call);
+ Log.d("Baresip", "Outgoing call index is " + call_index);
if (call_index != -1) {
Log.d("Baresip", "Removing called call " + ua + "/" +
- call + "/" + Out.get(index).getPeerURI());
+ call + "/" + Out.get(call_index).getPeerURI());
Out.remove(call_index);
- if (ua.equals(ua_current())) {
+ if (ua.equals(CurrentUA)) {
runOnUiThread(new Runnable() {
@Override
public void run() {
callButton.setText("Call");
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 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 String ua_call(String ua);
public native String call_peeruri(String call);
- public native String ua_current();
public static native void ua_current_set(String s);
public native String ua_connect(String s);
public native void ua_answer(String ua, String call);
diff --git a/app/src/main/res/layout/activity_history.xml b/app/src/main/res/layout/activity_history.xml
new file mode 100644
index 00000000..5738106c
--- /dev/null
+++ b/app/src/main/res/layout/activity_history.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+