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