- Fixed placing call from call history
- Use singleTask launch mode in order to avoid creating multiple activity stacks - Small call history related edits
This commit is contained in:
@@ -38,7 +38,7 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||||
android:launchMode="singleTop">
|
android:launchMode="singleTask">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
|||||||
@@ -24,6 +24,9 @@ import java.io.File
|
|||||||
import java.nio.charset.StandardCharsets
|
import java.nio.charset.StandardCharsets
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import android.content.Intent
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class BaresipService: Service() {
|
class BaresipService: Service() {
|
||||||
|
|
||||||
@@ -170,8 +173,7 @@ class BaresipService: Service() {
|
|||||||
|
|
||||||
"Call Show", "Call Answer" -> {
|
"Call Show", "Call Answer" -> {
|
||||||
val newIntent = Intent(this, MainActivity::class.java)
|
val newIntent = Intent(this, MainActivity::class.java)
|
||||||
newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or
|
newIntent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||||
Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
|
||||||
newIntent.putExtra("action", action.toLowerCase())
|
newIntent.putExtra("action", action.toLowerCase())
|
||||||
newIntent.putExtra("callp", intent!!.getStringExtra("callp"))
|
newIntent.putExtra("callp", intent!!.getStringExtra("callp"))
|
||||||
startActivity(newIntent)
|
startActivity(newIntent)
|
||||||
@@ -199,8 +201,7 @@ class BaresipService: Service() {
|
|||||||
Log.w(LOG_TAG, "onStartCommand did not find ua $uap")
|
Log.w(LOG_TAG, "onStartCommand did not find ua $uap")
|
||||||
} else {
|
} else {
|
||||||
val newIntent = Intent(this, MainActivity::class.java)
|
val newIntent = Intent(this, MainActivity::class.java)
|
||||||
newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or
|
newIntent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||||
Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
|
||||||
newIntent.putExtra("action", action.toLowerCase())
|
newIntent.putExtra("action", action.toLowerCase())
|
||||||
newIntent.putExtra("callp", intent.getStringExtra("callp"))
|
newIntent.putExtra("callp", intent.getStringExtra("callp"))
|
||||||
newIntent.putExtra("uri", intent.getStringExtra("uri"))
|
newIntent.putExtra("uri", intent.getStringExtra("uri"))
|
||||||
@@ -221,8 +222,7 @@ class BaresipService: Service() {
|
|||||||
|
|
||||||
"Message Show", "Message Reply" -> {
|
"Message Show", "Message Reply" -> {
|
||||||
val newIntent = Intent(this, MainActivity::class.java)
|
val newIntent = Intent(this, MainActivity::class.java)
|
||||||
newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or
|
newIntent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||||
Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
|
||||||
newIntent.putExtra("action", action.toLowerCase())
|
newIntent.putExtra("action", action.toLowerCase())
|
||||||
newIntent.putExtra("uap", intent!!.getStringExtra("uap"))
|
newIntent.putExtra("uap", intent!!.getStringExtra("uap"))
|
||||||
newIntent.putExtra("time", intent.getStringExtra("time"))
|
newIntent.putExtra("time", intent.getStringExtra("time"))
|
||||||
@@ -519,8 +519,7 @@ class BaresipService: Service() {
|
|||||||
return
|
return
|
||||||
if (newEvent == null) newEvent = event
|
if (newEvent == null) newEvent = event
|
||||||
val intent = Intent("service event")
|
val intent = Intent("service event")
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or
|
intent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||||
Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
|
||||||
intent.putExtra("event", newEvent)
|
intent.putExtra("event", newEvent)
|
||||||
intent.putExtra("params", arrayListOf(uap, callp))
|
intent.putExtra("params", arrayListOf(uap, callp))
|
||||||
LocalBroadcastManager.getInstance(this).sendBroadcast(intent)
|
LocalBroadcastManager.getInstance(this).sendBroadcast(intent)
|
||||||
@@ -590,8 +589,7 @@ class BaresipService: Service() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
val intent = Intent("service event")
|
val intent = Intent("service event")
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or
|
intent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||||
Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
|
||||||
intent.putExtra("event", "message show")
|
intent.putExtra("event", "message show")
|
||||||
intent.putExtra("params", arrayListOf(uap, timeStamp))
|
intent.putExtra("params", arrayListOf(uap, timeStamp))
|
||||||
LocalBroadcastManager.getInstance(this).sendBroadcast(intent)
|
LocalBroadcastManager.getInstance(this).sendBroadcast(intent)
|
||||||
|
|||||||
@@ -17,10 +17,6 @@ class CallHistory(val aor: String, val peerURI: String, val direction: String,
|
|||||||
return BaresipService.history
|
return BaresipService.history
|
||||||
}
|
}
|
||||||
|
|
||||||
fun historySet(history: ArrayList<CallHistory>) {
|
|
||||||
BaresipService.history = history
|
|
||||||
}
|
|
||||||
|
|
||||||
fun add(history: CallHistory) {
|
fun add(history: CallHistory) {
|
||||||
BaresipService.history.add(history)
|
BaresipService.history.add(history)
|
||||||
if (aorHistorySize(history.aor) > CALL_HISTORY_SIZE) {
|
if (aorHistorySize(history.aor) > CALL_HISTORY_SIZE) {
|
||||||
@@ -49,11 +45,12 @@ class CallHistory(val aor: String, val peerURI: String, val direction: String,
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun save(path: String) {
|
fun save(path: String) {
|
||||||
|
Log.d("Baresip", "Saving history of size ${BaresipService.history.size}")
|
||||||
val file = File(path, "history")
|
val file = File(path, "history")
|
||||||
try {
|
try {
|
||||||
val fos = FileOutputStream(file)
|
val fos = FileOutputStream(file)
|
||||||
val oos = ObjectOutputStream(fos)
|
val oos = ObjectOutputStream(fos)
|
||||||
oos.writeObject(history())
|
oos.writeObject(BaresipService.history)
|
||||||
oos.close()
|
oos.close()
|
||||||
fos.close()
|
fos.close()
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
@@ -68,9 +65,10 @@ class CallHistory(val aor: String, val peerURI: String, val direction: String,
|
|||||||
try {
|
try {
|
||||||
val fis = FileInputStream(file)
|
val fis = FileInputStream(file)
|
||||||
val ois = ObjectInputStream(fis)
|
val ois = ObjectInputStream(fis)
|
||||||
historySet(ois.readObject() as ArrayList<CallHistory>)
|
BaresipService.history = ois.readObject() as ArrayList<CallHistory>
|
||||||
ois.close()
|
ois.close()
|
||||||
fis.close()
|
fis.close()
|
||||||
|
Log.d("Baresip", "Restored history of size ${BaresipService.history.size}")
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e("Baresip", "InputStream exception: - " + e.toString())
|
Log.e("Baresip", "InputStream exception: - " + e.toString())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -507,8 +507,10 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
"call reject" ->
|
"call reject" ->
|
||||||
rejectButton.performClick()
|
rejectButton.performClick()
|
||||||
"call" ->
|
"call" -> {
|
||||||
|
callUri.setText(resumeUri)
|
||||||
callButton.performClick()
|
callButton.performClick()
|
||||||
|
}
|
||||||
"transfer show", "transfer accept" ->
|
"transfer show", "transfer accept" ->
|
||||||
handleServiceEvent("$resumeAction,$resumeUri",
|
handleServiceEvent("$resumeAction,$resumeUri",
|
||||||
arrayListOf(resumeCall!!.ua.uap, resumeCall!!.callp))
|
arrayListOf(resumeCall!!.ua.uap, resumeCall!!.callp))
|
||||||
|
|||||||
Reference in New Issue
Block a user