mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-24 23:28:10 +00:00
Enhance notification
This commit is contained in:
parent
488b4d10ee
commit
ad30045834
5 changed files with 30 additions and 20 deletions
|
|
@ -48,7 +48,7 @@
|
|||
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS"/>
|
||||
<!-- Needed for in-app purchase -->
|
||||
<!-- <uses-permission android:name="com.android.vending.BILLING"/> -->
|
||||
<!-- Needed for overlay widget -->
|
||||
<!-- Needed for overlay widget and floating notifications -->
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
|
||||
<!-- Needed for kill application yourself -->
|
||||
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES"/>
|
||||
|
|
|
|||
|
|
@ -475,7 +475,7 @@ public final class LinphoneService extends Service {
|
|||
|
||||
mNM = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||
mNM.cancel(INCALL_NOTIF_ID); // in case of crash the icon is not removed
|
||||
Compatibility.CreateChannel(this);
|
||||
Compatibility.createNotificationChannels(this);
|
||||
|
||||
Intent notifIntent = new Intent(this, incomingReceivedActivity);
|
||||
notifIntent.putExtra("Notification", true);
|
||||
|
|
|
|||
|
|
@ -1407,6 +1407,9 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
}
|
||||
//}
|
||||
|
||||
// This one is to allow floating notifications
|
||||
permissionsList.add(Manifest.permission.SYSTEM_ALERT_WINDOW);
|
||||
|
||||
if (permissionsList.size() > 0) {
|
||||
String[] permissions = new String[permissionsList.size()];
|
||||
permissions = permissionsList.toArray(permissions);
|
||||
|
|
|
|||
|
|
@ -37,29 +37,35 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
@TargetApi(26)
|
||||
public class ApiTwentySixPlus {
|
||||
|
||||
public static void CreateChannel(Context context) {
|
||||
public static void createServiceChannel(Context context) {
|
||||
NotificationManager notificationManager =
|
||||
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
// Create service/call notification channel
|
||||
String id = context.getString(R.string.notification_service_channel_id);
|
||||
CharSequence name = context.getString(R.string.content_title_notification_service);
|
||||
String description = context.getString(R.string.content_title_notification_service);
|
||||
int importance = NotificationManager.IMPORTANCE_NONE;
|
||||
NotificationChannel mChannel = new NotificationChannel(id, name, importance);
|
||||
mChannel.setDescription(description);
|
||||
mChannel.enableVibration(false);
|
||||
mChannel.enableLights(false);
|
||||
notificationManager.createNotificationChannel(mChannel);
|
||||
NotificationChannel channel = new NotificationChannel(id, name, NotificationManager.IMPORTANCE_NONE);
|
||||
channel.setDescription(description);
|
||||
channel.enableVibration(false);
|
||||
channel.enableLights(false);
|
||||
channel.setShowBadge(false);
|
||||
notificationManager.createNotificationChannel(channel);
|
||||
}
|
||||
|
||||
public static void createMessageChannel(Context context) {
|
||||
NotificationManager notificationManager =
|
||||
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
// Create message notification channel
|
||||
id = context.getString(R.string.notification_channel_id);
|
||||
name = context.getString(R.string.content_title_notification);
|
||||
description = context.getString(R.string.content_title_notification);
|
||||
importance = NotificationManager.IMPORTANCE_HIGH;
|
||||
mChannel = new NotificationChannel(id, name, importance);
|
||||
mChannel.setDescription(description);
|
||||
mChannel.setLightColor(context.getColor(R.color.notification_color_led));
|
||||
mChannel.enableLights(true);
|
||||
notificationManager.createNotificationChannel(mChannel);
|
||||
String id = context.getString(R.string.notification_channel_id);
|
||||
String name = context.getString(R.string.content_title_notification);
|
||||
String description = context.getString(R.string.content_title_notification);
|
||||
NotificationChannel channel = new NotificationChannel(id, name, NotificationManager.IMPORTANCE_HIGH);
|
||||
channel.setDescription(description);
|
||||
channel.setLightColor(context.getColor(R.color.notification_color_led));
|
||||
channel.enableLights(true);
|
||||
channel.enableVibration(true);
|
||||
channel.setShowBadge(true);
|
||||
notificationManager.createNotificationChannel(channel);
|
||||
}
|
||||
|
||||
public static Notification createMessageNotification(Context context,
|
||||
|
|
|
|||
|
|
@ -36,9 +36,10 @@ import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
|||
import android.widget.TextView;
|
||||
|
||||
public class Compatibility {
|
||||
public static void CreateChannel(Context context) {
|
||||
public static void createNotificationChannels(Context context) {
|
||||
if (Version.sdkAboveOrEqual(Version.API26_O_80)) {
|
||||
ApiTwentySixPlus.CreateChannel(context);
|
||||
ApiTwentySixPlus.createServiceChannel(context);
|
||||
ApiTwentySixPlus.createMessageChannel(context);
|
||||
}
|
||||
}
|
||||
public static Notification createSimpleNotification(Context context, String title, String text, PendingIntent intent) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue