- 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:
Juha Heinanen
2019-04-19 21:37:22 +03:00
parent a917dd5624
commit 622e0f5c0f
4 changed files with 16 additions and 18 deletions

View File

@ -38,7 +38,7 @@
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:launchMode="singleTop">
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />

View File

@ -24,6 +24,9 @@ import java.io.File
import java.nio.charset.StandardCharsets
import java.io.InputStream
import java.util.*
import android.content.Intent
class BaresipService: Service() {
@ -170,8 +173,7 @@ class BaresipService: Service() {
"Call Show", "Call Answer" -> {
val newIntent = Intent(this, MainActivity::class.java)
newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or
Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP)
newIntent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP
newIntent.putExtra("action", action.toLowerCase())
newIntent.putExtra("callp", intent!!.getStringExtra("callp"))
startActivity(newIntent)
@ -199,8 +201,7 @@ class BaresipService: Service() {
Log.w(LOG_TAG, "onStartCommand did not find ua $uap")
} else {
val newIntent = Intent(this, MainActivity::class.java)
newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or
Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP)
newIntent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP
newIntent.putExtra("action", action.toLowerCase())
newIntent.putExtra("callp", intent.getStringExtra("callp"))
newIntent.putExtra("uri", intent.getStringExtra("uri"))
@ -221,8 +222,7 @@ class BaresipService: Service() {
"Message Show", "Message Reply" -> {
val newIntent = Intent(this, MainActivity::class.java)
newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or
Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP)
newIntent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP
newIntent.putExtra("action", action.toLowerCase())
newIntent.putExtra("uap", intent!!.getStringExtra("uap"))
newIntent.putExtra("time", intent.getStringExtra("time"))
@ -519,8 +519,7 @@ class BaresipService: Service() {
return
if (newEvent == null) newEvent = event
val intent = Intent("service event")
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or
Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP)
intent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP
intent.putExtra("event", newEvent)
intent.putExtra("params", arrayListOf(uap, callp))
LocalBroadcastManager.getInstance(this).sendBroadcast(intent)
@ -590,8 +589,7 @@ class BaresipService: Service() {
return
}
val intent = Intent("service event")
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or
Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP)
intent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP
intent.putExtra("event", "message show")
intent.putExtra("params", arrayListOf(uap, timeStamp))
LocalBroadcastManager.getInstance(this).sendBroadcast(intent)

View File

@ -17,10 +17,6 @@ class CallHistory(val aor: String, val peerURI: String, val direction: String,
return BaresipService.history
}
fun historySet(history: ArrayList<CallHistory>) {
BaresipService.history = history
}
fun add(history: CallHistory) {
BaresipService.history.add(history)
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) {
Log.d("Baresip", "Saving history of size ${BaresipService.history.size}")
val file = File(path, "history")
try {
val fos = FileOutputStream(file)
val oos = ObjectOutputStream(fos)
oos.writeObject(history())
oos.writeObject(BaresipService.history)
oos.close()
fos.close()
} catch (e: IOException) {
@ -68,9 +65,10 @@ class CallHistory(val aor: String, val peerURI: String, val direction: String,
try {
val fis = FileInputStream(file)
val ois = ObjectInputStream(fis)
historySet(ois.readObject() as ArrayList<CallHistory>)
BaresipService.history = ois.readObject() as ArrayList<CallHistory>
ois.close()
fis.close()
Log.d("Baresip", "Restored history of size ${BaresipService.history.size}")
} catch (e: Exception) {
Log.e("Baresip", "InputStream exception: - " + e.toString())
}

View File

@ -507,8 +507,10 @@ class MainActivity : AppCompatActivity() {
}
"call reject" ->
rejectButton.performClick()
"call" ->
"call" -> {
callUri.setText(resumeUri)
callButton.performClick()
}
"transfer show", "transfer accept" ->
handleServiceEvent("$resumeAction,$resumeUri",
arrayListOf(resumeCall!!.ua.uap, resumeCall!!.callp))