Added simple notification method in compatibility
This commit is contained in:
parent
cbac917388
commit
6dec9d9392
5 changed files with 75 additions and 0 deletions
|
@ -166,4 +166,18 @@ public class ApiElevenPlus {
|
||||||
|
|
||||||
return intent;
|
return intent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public static Notification createSimpleNotification(Context context, String title, String text, PendingIntent intent) {
|
||||||
|
Notification notif = new Notification.Builder(context)
|
||||||
|
.setContentTitle(title)
|
||||||
|
.setContentText(text)
|
||||||
|
.setContentIntent(intent)
|
||||||
|
.setSmallIcon(R.drawable.logo_linphone_57x57)
|
||||||
|
.setAutoCancel(true)
|
||||||
|
.setDefaults(Notification.DEFAULT_LIGHTS | Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE)
|
||||||
|
.setWhen(System.currentTimeMillis()).getNotification();
|
||||||
|
|
||||||
|
return notif;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -401,4 +401,20 @@ public class ApiFivePlus {
|
||||||
|
|
||||||
return notif;
|
return notif;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Notification createSimpleNotification(Context context, String title, String text, PendingIntent intent) {
|
||||||
|
Notification notif = new Notification();
|
||||||
|
notif.icon = R.drawable.logo_linphone_57x57;
|
||||||
|
notif.iconLevel = 0;
|
||||||
|
notif.when = System.currentTimeMillis();
|
||||||
|
notif.flags &= Notification.FLAG_ONGOING_EVENT;
|
||||||
|
|
||||||
|
notif.defaults |= Notification.DEFAULT_VIBRATE;
|
||||||
|
notif.defaults |= Notification.DEFAULT_SOUND;
|
||||||
|
notif.defaults |= Notification.DEFAULT_LIGHTS;
|
||||||
|
|
||||||
|
notif.setLatestEventInfo(context, title, text, intent);
|
||||||
|
|
||||||
|
return notif;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,4 +107,18 @@ public class ApiSixteenPlus {
|
||||||
public static void removeGlobalLayoutListener(ViewTreeObserver viewTreeObserver, OnGlobalLayoutListener keyboardListener) {
|
public static void removeGlobalLayoutListener(ViewTreeObserver viewTreeObserver, OnGlobalLayoutListener keyboardListener) {
|
||||||
viewTreeObserver.removeOnGlobalLayoutListener(keyboardListener);
|
viewTreeObserver.removeOnGlobalLayoutListener(keyboardListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Notification createSimpleNotification(Context context, String title, String text, PendingIntent intent) {
|
||||||
|
Notification notif = new Notification.Builder(context)
|
||||||
|
.setContentTitle(title)
|
||||||
|
.setContentText(text)
|
||||||
|
.setSmallIcon(R.drawable.logo_linphone_57x57)
|
||||||
|
.setAutoCancel(true)
|
||||||
|
.setContentIntent(intent)
|
||||||
|
.setDefaults(Notification.DEFAULT_LIGHTS | Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE)
|
||||||
|
.setWhen(System.currentTimeMillis())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
return notif;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,4 +110,20 @@ public class ApiTwentyOnePlus {
|
||||||
public static void removeGlobalLayoutListener(ViewTreeObserver viewTreeObserver, OnGlobalLayoutListener keyboardListener) {
|
public static void removeGlobalLayoutListener(ViewTreeObserver viewTreeObserver, OnGlobalLayoutListener keyboardListener) {
|
||||||
viewTreeObserver.removeOnGlobalLayoutListener(keyboardListener);
|
viewTreeObserver.removeOnGlobalLayoutListener(keyboardListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Notification createSimpleNotification(Context context, String title, String text, PendingIntent intent) {
|
||||||
|
Notification notif = new NotificationCompat.Builder(context)
|
||||||
|
.setContentTitle(title)
|
||||||
|
.setContentText(text)
|
||||||
|
.setSmallIcon(R.drawable.logo_linphone_57x57)
|
||||||
|
.setAutoCancel(true)
|
||||||
|
.setContentIntent(intent)
|
||||||
|
.setDefaults(Notification.DEFAULT_ALL)
|
||||||
|
.setCategory(Notification.CATEGORY_MESSAGE)
|
||||||
|
.setVisibility(Notification.VISIBILITY_PRIVATE)
|
||||||
|
.setPriority(Notification.PRIORITY_HIGH)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
return notif;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,6 +153,21 @@ public class Compatibility {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Notification createSimpleNotification(Context context, String title, String text, PendingIntent intent) {
|
||||||
|
Notification notif = null;
|
||||||
|
|
||||||
|
if (Version.sdkAboveOrEqual(Version.API21_LOLLIPOP_50)) {
|
||||||
|
return ApiTwentyOnePlus.createSimpleNotification(context, title, text, intent);
|
||||||
|
} else if (Version.sdkAboveOrEqual(Version.API16_JELLY_BEAN_41)) {
|
||||||
|
notif = ApiSixteenPlus.createSimpleNotification(context, title, text, intent);
|
||||||
|
} else if (Version.sdkAboveOrEqual(Version.API11_HONEYCOMB_30)) {
|
||||||
|
notif = ApiElevenPlus.createSimpleNotification(context, title, text, intent);
|
||||||
|
} else {
|
||||||
|
notif = ApiFivePlus.createSimpleNotification(context, title, text, intent);
|
||||||
|
}
|
||||||
|
return notif;
|
||||||
|
}
|
||||||
|
|
||||||
public static Notification createMessageNotification(Context context, int msgCount, String msgSender, String msg, Bitmap contactIcon, PendingIntent intent) {
|
public static Notification createMessageNotification(Context context, int msgCount, String msgSender, String msg, Bitmap contactIcon, PendingIntent intent) {
|
||||||
Notification notif = null;
|
Notification notif = null;
|
||||||
String title;
|
String title;
|
||||||
|
|
Loading…
Reference in a new issue