Set ongoing flag for notifications that needs to be
This commit is contained in:
parent
89941db572
commit
33caa7ce92
6 changed files with 16 additions and 8 deletions
|
@ -186,7 +186,7 @@ public final class LinphoneService extends Service {
|
||||||
return START_STICKY;
|
return START_STICKY;
|
||||||
}
|
}
|
||||||
|
|
||||||
mLinphoneManager = new LinphoneManager(this);
|
mLinphoneManager = new LinphoneManager(getApplicationContext());
|
||||||
sInstance = this; // sInstance is ready once linphone manager has been created
|
sInstance = this; // sInstance is ready once linphone manager has been created
|
||||||
|
|
||||||
mNotificationManager = new NotificationsManager(this);
|
mNotificationManager = new NotificationsManager(this);
|
||||||
|
|
|
@ -114,6 +114,7 @@ class ApiTwentyFourPlus {
|
||||||
.setPriority(Notification.PRIORITY_HIGH)
|
.setPriority(Notification.PRIORITY_HIGH)
|
||||||
.setWhen(System.currentTimeMillis())
|
.setWhen(System.currentTimeMillis())
|
||||||
.setShowWhen(true)
|
.setShowWhen(true)
|
||||||
|
.setOngoing(true)
|
||||||
.setColor(context.getColor(R.color.notification_led_color))
|
.setColor(context.getColor(R.color.notification_led_color))
|
||||||
.addAction(getCallDeclineAction(context, callId));
|
.addAction(getCallDeclineAction(context, callId));
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,8 @@ class ApiTwentyOnePlus {
|
||||||
int level,
|
int level,
|
||||||
Bitmap largeIcon,
|
Bitmap largeIcon,
|
||||||
PendingIntent intent,
|
PendingIntent intent,
|
||||||
int priority) {
|
int priority,
|
||||||
|
boolean ongoing) {
|
||||||
Notification notif;
|
Notification notif;
|
||||||
|
|
||||||
if (largeIcon != null) {
|
if (largeIcon != null) {
|
||||||
|
@ -128,6 +129,7 @@ class ApiTwentyOnePlus {
|
||||||
.setWhen(System.currentTimeMillis())
|
.setWhen(System.currentTimeMillis())
|
||||||
.setPriority(priority)
|
.setPriority(priority)
|
||||||
.setShowWhen(true)
|
.setShowWhen(true)
|
||||||
|
.setOngoing(ongoing)
|
||||||
.build();
|
.build();
|
||||||
} else {
|
} else {
|
||||||
notif =
|
notif =
|
||||||
|
|
|
@ -165,6 +165,7 @@ class ApiTwentySixPlus {
|
||||||
.setPriority(Notification.PRIORITY_HIGH)
|
.setPriority(Notification.PRIORITY_HIGH)
|
||||||
.setWhen(System.currentTimeMillis())
|
.setWhen(System.currentTimeMillis())
|
||||||
.setShowWhen(true)
|
.setShowWhen(true)
|
||||||
|
.setOngoing(true)
|
||||||
.setColor(context.getColor(R.color.notification_led_color))
|
.setColor(context.getColor(R.color.notification_led_color))
|
||||||
.addAction(ApiTwentyFourPlus.getCallDeclineAction(context, callId));
|
.addAction(ApiTwentyFourPlus.getCallDeclineAction(context, callId));
|
||||||
|
|
||||||
|
@ -182,7 +183,8 @@ class ApiTwentySixPlus {
|
||||||
int level,
|
int level,
|
||||||
Bitmap largeIcon,
|
Bitmap largeIcon,
|
||||||
PendingIntent intent,
|
PendingIntent intent,
|
||||||
int priority) {
|
int priority,
|
||||||
|
boolean ongoing) {
|
||||||
|
|
||||||
if (largeIcon != null) {
|
if (largeIcon != null) {
|
||||||
return new Notification.Builder(
|
return new Notification.Builder(
|
||||||
|
@ -197,6 +199,7 @@ class ApiTwentySixPlus {
|
||||||
.setPriority(priority)
|
.setPriority(priority)
|
||||||
.setWhen(System.currentTimeMillis())
|
.setWhen(System.currentTimeMillis())
|
||||||
.setShowWhen(true)
|
.setShowWhen(true)
|
||||||
|
.setOngoing(ongoing)
|
||||||
.setColor(context.getColor(R.color.notification_led_color))
|
.setColor(context.getColor(R.color.notification_led_color))
|
||||||
.build();
|
.build();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -88,7 +88,7 @@ public class Compatibility {
|
||||||
String msg,
|
String msg,
|
||||||
Bitmap contactIcon,
|
Bitmap contactIcon,
|
||||||
PendingIntent intent) {
|
PendingIntent intent) {
|
||||||
if (Version.sdkAboveOrEqual(28)) {
|
if (Version.sdkAboveOrEqual(Version.API28_PIE_90)) {
|
||||||
return ApiTwentyEightPlus.createMessageNotification(
|
return ApiTwentyEightPlus.createMessageNotification(
|
||||||
context, notif, contactIcon, intent);
|
context, notif, contactIcon, intent);
|
||||||
} else if (Version.sdkAboveOrEqual(Version.API26_O_80)) {
|
} else if (Version.sdkAboveOrEqual(Version.API26_O_80)) {
|
||||||
|
@ -151,13 +151,14 @@ public class Compatibility {
|
||||||
int iconLevel,
|
int iconLevel,
|
||||||
Bitmap largeIcon,
|
Bitmap largeIcon,
|
||||||
PendingIntent intent,
|
PendingIntent intent,
|
||||||
int priority) {
|
int priority,
|
||||||
|
boolean ongoing) {
|
||||||
if (Version.sdkAboveOrEqual(Version.API26_O_80)) {
|
if (Version.sdkAboveOrEqual(Version.API26_O_80)) {
|
||||||
return ApiTwentySixPlus.createNotification(
|
return ApiTwentySixPlus.createNotification(
|
||||||
context, title, message, icon, iconLevel, largeIcon, intent, priority);
|
context, title, message, icon, iconLevel, largeIcon, intent, priority, ongoing);
|
||||||
}
|
}
|
||||||
return ApiTwentyOnePlus.createNotification(
|
return ApiTwentyOnePlus.createNotification(
|
||||||
context, title, message, icon, iconLevel, largeIcon, intent, priority);
|
context, title, message, icon, iconLevel, largeIcon, intent, priority, ongoing);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canDrawOverlays(Context context) {
|
public static boolean canDrawOverlays(Context context) {
|
||||||
|
|
|
@ -111,7 +111,8 @@ public class NotificationsManager {
|
||||||
R.mipmap.ic_launcher,
|
R.mipmap.ic_launcher,
|
||||||
bm,
|
bm,
|
||||||
pendingIntent,
|
pendingIntent,
|
||||||
Notification.PRIORITY_MIN);
|
Notification.PRIORITY_MIN,
|
||||||
|
true);
|
||||||
|
|
||||||
if (isServiceNotificationDisplayed()) {
|
if (isServiceNotificationDisplayed()) {
|
||||||
startForeground();
|
startForeground();
|
||||||
|
|
Loading…
Reference in a new issue