mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Improved push notification received notification by inheriting PushService from SDK
This commit is contained in:
parent
e618992fb5
commit
9c3102392b
4 changed files with 94 additions and 1 deletions
|
|
@ -135,7 +135,7 @@
|
|||
android:label="@string/app_name" />
|
||||
|
||||
<service
|
||||
android:name="org.linphone.core.tools.service.PushService"
|
||||
android:name=".core.CorePushService"
|
||||
android:exported="false"
|
||||
android:foregroundServiceType="dataSync"
|
||||
android:stopWithTask="false"
|
||||
|
|
|
|||
77
app/src/main/java/org/linphone/core/CorePushService.kt
Normal file
77
app/src/main/java/org/linphone/core/CorePushService.kt
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* Copyright (c) 2010-2023 Belledonne Communications SARL.
|
||||
*
|
||||
* This file is part of linphone-android
|
||||
* (see https://www.linphone.org).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.linphone.core
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.IBinder
|
||||
import androidx.annotation.MainThread
|
||||
import androidx.core.app.NotificationCompat
|
||||
import org.linphone.R
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.core.tools.service.PushService
|
||||
import org.linphone.notifications.NotificationsManager
|
||||
|
||||
@MainThread
|
||||
class CorePushService : PushService() {
|
||||
companion object {
|
||||
private const val TAG = "[Core Push Service]"
|
||||
}
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
Log.i("$TAG Created")
|
||||
}
|
||||
|
||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||
Log.i("$TAG onStartCommand")
|
||||
return super.onStartCommand(intent, flags, startId)
|
||||
}
|
||||
|
||||
override fun onTaskRemoved(rootIntent: Intent?) {
|
||||
Log.i("$TAG Task removed, doing nothing")
|
||||
super.onTaskRemoved(rootIntent)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
Log.i("$TAG onDestroy")
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
override fun onBind(p0: Intent?): IBinder? {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun createServiceNotification() {
|
||||
mServiceNotification = NotificationCompat.Builder(
|
||||
this,
|
||||
SERVICE_NOTIFICATION_CHANNEL_ID
|
||||
)
|
||||
.setContentTitle(getString(R.string.notification_push_received_title))
|
||||
.setSmallIcon(R.drawable.linphone_notification)
|
||||
.setAutoCancel(false)
|
||||
.setCategory(NotificationCompat.CATEGORY_SERVICE)
|
||||
.setGroup(NotificationsManager.CHAT_NOTIFICATIONS_GROUP)
|
||||
.setVisibility(NotificationCompat.VISIBILITY_SECRET)
|
||||
.setWhen(System.currentTimeMillis())
|
||||
.setShowWhen(true)
|
||||
.setOngoing(true)
|
||||
.build()
|
||||
}
|
||||
}
|
||||
15
app/src/main/res/drawable/linphone_notification.xml
Normal file
15
app/src/main/res/drawable/linphone_notification.xml
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:name="vector"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<group android:name="group">
|
||||
<path
|
||||
android:name="path"
|
||||
android:pathData="M 2.086 4.711 C 2.086 4.711 -0.336 7.988 0.039 9.461 C 0.027 9.402 1.625 7.742 1.625 7.742 C 1.711 8.191 5.59 9.297 5.59 9.297 C 6.105 9.617 6.285 9.852 6.383 10.359 L 6.383 12.324 C 7.727 13.145 8.957 13.414 11.938 13.594 C 15.102 13.461 16.41 13.188 17.57 12.324 C 17.57 12.324 17.445 10.809 17.57 10.277 C 17.695 9.746 17.977 9.441 18.406 9.297 C 20.016 8.934 20.813 8.539 22.332 7.781 L 24 9.461 C 23.746 7.613 23.309 6.594 21.996 4.793 C 20.953 3.625 20.285 3.012 18.906 2.012 C 17.41 1.145 16.578 0.813 15.109 0.414 C 12.555 -0.098 11.148 -0.094 8.68 0.414 C 7.168 0.863 6.414 1.199 5.301 2.012 C 5.301 2.012 1.082 -0.363 0.539 0.047 C -0.004 0.457 2.086 4.711 2.086 4.711 Z M 2.086 4.711 M 4.969 17.395 C 3.027 16.563 1.977 15.934 0.168 14.527 C 0.602 16.297 1.008 17.227 2.004 18.785 C 3.063 20.191 3.715 20.82 4.969 21.691 C 6.32 22.602 7.133 23 8.684 23.492 C 10.074 23.82 10.852 23.922 12.23 23.941 C 13.637 23.871 14.367 23.723 15.57 23.449 C 16.898 22.93 17.574 22.602 18.699 21.977 C 20.566 23.008 22.875 24.188 23.211 23.695 C 23.543 23.203 21.707 19.234 21.707 19.234 C 22.93 17.516 23.434 16.355 23.918 14.406 C 22.242 15.695 21.152 16.449 19.078 17.395 C 16.508 18.387 15.012 18.703 12.23 18.785 C 8.988 18.73 7.406 18.414 4.969 17.395 Z M 4.969 17.395"
|
||||
android:fillColor="#ffffff"
|
||||
android:strokeWidth="1"/>
|
||||
</group>
|
||||
</vector>
|
||||
|
|
@ -67,6 +67,7 @@
|
|||
<string name="notification_missed_call">Missed call from %s</string>
|
||||
<string name="notification_missed_calls">%s missed calls</string>
|
||||
<string name="notification_missed_call_title">Missed call</string>
|
||||
<string name="notification_push_received_title">Push notification received</string> <!-- TODO: improve -->
|
||||
|
||||
<string name="welcome_page_title">Welcome</string>
|
||||
<string name="welcome_page_subtitle">in Linphone</string>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue