use the same notification also for incoming calls
This commit is contained in:
@ -158,7 +158,7 @@ class BaresipService: Service() {
|
|||||||
nb.setVisibility(VISIBILITY_PUBLIC)
|
nb.setVisibility(VISIBILITY_PUBLIC)
|
||||||
.setSmallIcon(R.drawable.ic_stat)
|
.setSmallIcon(R.drawable.ic_stat)
|
||||||
.setContentIntent(npi)
|
.setContentIntent(npi)
|
||||||
.setPriority(Notification.PRIORITY_MAX)
|
.setPriority(Notification.PRIORITY_HIGH)
|
||||||
.setOngoing(true)
|
.setOngoing(true)
|
||||||
.setContent(RemoteViews(packageName, R.layout.notification))
|
.setContent(RemoteViews(packageName, R.layout.notification))
|
||||||
startForeground(STATUS_NOTIFICATION_ID, nb.build())
|
startForeground(STATUS_NOTIFICATION_ID, nb.build())
|
||||||
@ -202,7 +202,10 @@ class BaresipService: Service() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
"registered" -> {
|
"registered" -> {
|
||||||
MainActivity.images[account_index] = R.drawable.dot_green
|
if (ua.account.regint == 0)
|
||||||
|
MainActivity.images[account_index] = R.drawable.dot_yellow
|
||||||
|
else
|
||||||
|
MainActivity.images[account_index] = R.drawable.dot_green
|
||||||
updateNotification()
|
updateNotification()
|
||||||
if (!MainActivity.visible) return
|
if (!MainActivity.visible) return
|
||||||
}
|
}
|
||||||
@ -217,20 +220,20 @@ class BaresipService: Service() {
|
|||||||
"call incoming" -> {
|
"call incoming" -> {
|
||||||
if (!Utils.isVisible()) {
|
if (!Utils.isVisible()) {
|
||||||
Log.d(LOG_TAG, "Baresip is NOT visible")
|
Log.d(LOG_TAG, "Baresip is NOT visible")
|
||||||
val peer_uri = Api.call_peeruri(callp)
|
nb.setVibrate(LongArray(0))
|
||||||
val huBuilder = NotificationCompat.Builder(this)
|
val view = RemoteViews(getPackageName(), R.layout.notification)
|
||||||
.setSmallIcon(R.drawable.ic_stat)
|
view.setTextViewText(R.id.incoming, "Call from ${Api.call_peeruri(callp)}")
|
||||||
.setContentText("Incoming call from $peer_uri")
|
view.setViewVisibility(R.id.incoming, View.VISIBLE)
|
||||||
.setDefaults(Notification.DEFAULT_ALL)
|
nb.setContent(view)
|
||||||
.setPriority(Notification.PRIORITY_HIGH)
|
nm.notify(STATUS_NOTIFICATION_ID, nb.build())
|
||||||
.setAutoCancel(true)
|
|
||||||
.setContentIntent(npi)
|
|
||||||
nm.notify(INCOMING_NOTIFICATION_ID, huBuilder.build())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"call established", "call closed" -> {
|
"call established", "call closed" -> {
|
||||||
nb.mActions.clear()
|
nm.cancel(STATUS_NOTIFICATION_ID)
|
||||||
nb.mContentText = ""
|
val view = RemoteViews(getPackageName(), R.layout.notification)
|
||||||
|
view.setViewVisibility(R.id.incoming, View.GONE)
|
||||||
|
nb.setContent(view)
|
||||||
|
nb.setVibrate(null)
|
||||||
nm.notify(STATUS_NOTIFICATION_ID, nb.build())
|
nm.notify(STATUS_NOTIFICATION_ID, nb.build())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -278,7 +281,6 @@ class BaresipService: Service() {
|
|||||||
|
|
||||||
var IS_SERVICE_RUNNING = false
|
var IS_SERVICE_RUNNING = false
|
||||||
val STATUS_NOTIFICATION_ID = 101
|
val STATUS_NOTIFICATION_ID = 101
|
||||||
val INCOMING_NOTIFICATION_ID = 102
|
|
||||||
var disconnected = false
|
var disconnected = false
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,58 +1,79 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/notificationLayout"
|
android:id="@+id/notificationLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="horizontal" >
|
android:orientation="vertical" >
|
||||||
|
|
||||||
<ImageView android:id="@+id/image"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="wrap_content"
|
android:id="@+id/mainRow"
|
||||||
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_marginTop="14dp"
|
||||||
android:paddingLeft="10dp"
|
android:orientation="horizontal" >
|
||||||
android:paddingRight="5dp"
|
|
||||||
android:src="@drawable/baresip" />
|
|
||||||
|
|
||||||
<TextView android:id="@+id/text"
|
<ImageView android:id="@+id/image"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:paddingLeft="10dp"
|
||||||
|
android:paddingRight="5dp"
|
||||||
|
android:src="@drawable/baresip" />
|
||||||
|
|
||||||
|
<TextView android:id="@+id/text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:textSize="15dp"
|
||||||
|
android:textColor="#000000"
|
||||||
|
android:text="Baresip "
|
||||||
|
style = "@android:style/TextAppearance.Medium" />
|
||||||
|
|
||||||
|
<ImageView android:id="@+id/status0"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:paddingLeft="10dp" />
|
||||||
|
|
||||||
|
<ImageView android:id="@+id/status1"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:paddingLeft="10dp" />
|
||||||
|
|
||||||
|
<ImageView android:id="@+id/status2"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:paddingLeft="10dp" />
|
||||||
|
|
||||||
|
<ImageView android:id="@+id/status3"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:paddingLeft="10dp" />
|
||||||
|
|
||||||
|
<TextView android:id="@+id/etc"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:paddingLeft="5dp"
|
||||||
|
android:text="..."
|
||||||
|
android:textColor="#000000"
|
||||||
|
style = "@android:style/TextAppearance.Medium" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView android:id="@+id/incoming"
|
||||||
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_below="@id/mainRow"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:layout_marginLeft="16dp"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
android:textSize="15dp"
|
android:textSize="15dp"
|
||||||
android:textColor="#000000"
|
android:text="Call from"
|
||||||
android:text="Baresip "
|
android:visibility="gone"
|
||||||
style = "@android:style/TextAppearance.Medium" />
|
style = "@android:style/TextAppearance.Medium" />
|
||||||
|
|
||||||
<ImageView android:id="@+id/status0"
|
</RelativeLayout>
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:paddingLeft="10dp" />
|
|
||||||
|
|
||||||
<ImageView android:id="@+id/status1"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:paddingLeft="10dp" />
|
|
||||||
|
|
||||||
<ImageView android:id="@+id/status2"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:paddingLeft="10dp" />
|
|
||||||
|
|
||||||
<ImageView android:id="@+id/status3"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:paddingLeft="10dp" />
|
|
||||||
|
|
||||||
<TextView android:id="@+id/etc"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:paddingLeft="5dp"
|
|
||||||
android:text="..."
|
|
||||||
android:textColor="#000000"
|
|
||||||
style = "@android:style/TextAppearance.Medium" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user