added baresip icon (letter B) to notification bar

This commit is contained in:
Juha Heinanen
2018-05-10 12:38:28 +03:00
parent 5afafbe38c
commit 1597e4fd1d
5 changed files with 14 additions and 0 deletions

View File

@ -1,6 +1,8 @@
package com.tutpro.baresip
import android.Manifest
import android.app.Notification
import android.app.NotificationManager
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
@ -41,6 +43,7 @@ class MainActivity : AppCompatActivity() {
internal lateinit var aorSpinner: Spinner
internal lateinit var am: AudioManager
internal lateinit var imm: InputMethodManager
internal lateinit var nm: NotificationManager
override fun onCreate(savedInstanceState: Bundle?) {
@ -259,6 +262,7 @@ class MainActivity : AppCompatActivity() {
if (!running) {
Log.i("Baresip", "Starting Baresip with path $path")
Thread(Runnable { baresipStart(path) }).start()
addStatusBarIcon(10)
running = true
}
}
@ -335,6 +339,7 @@ class MainActivity : AppCompatActivity() {
}
baresipStop()
nm.cancel(10)
running = false
}
finish()
@ -571,6 +576,15 @@ class MainActivity : AppCompatActivity() {
layout.addView(reject_button)
}
private fun addStatusBarIcon(id: Int) {
nm = getSystemService(NOTIFICATION_SERVICE) as NotificationManager
val notification = Notification.Builder(this)
.setSmallIcon(R.drawable.ic_stat)
.setContentTitle("Baresip is running")
.setOngoing(true).build()
nm.notify(id, notification)
}
private fun callIndex(calls: ArrayList<Call>, ua: String, call: String): Int {
for (i in calls.indices) {
if (calls[i].ua.equals(ua) && calls[i].call == call)

Binary file not shown.

After

Width:  |  Height:  |  Size: 298 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 365 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 539 B