diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 212adb8dd..4cbdc541f 100755 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -48,7 +48,7 @@ - + diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml index d252e8878..e4df67c2e 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -464,5 +464,6 @@ Vos amis pourront vous joindre plus facilement si vous associez votre compte à Options d\'appel Route audio Quitter la conférence - Linphone Service + Linphone service notification + Linphone instant messages notifications diff --git a/res/values/strings.xml b/res/values/strings.xml index 0796484a1..401bcebee 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -521,8 +521,8 @@ Call options Audio route Exit conference - Linphone Service - Linphone Notification + Linphone service notification + Linphone instant messages notifications Group chat room subject Group chat room info diff --git a/src/android/org/linphone/LinphoneService.java b/src/android/org/linphone/LinphoneService.java index 75eb56f99..6fedb3176 100644 --- a/src/android/org/linphone/LinphoneService.java +++ b/src/android/org/linphone/LinphoneService.java @@ -470,7 +470,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); diff --git a/src/android/org/linphone/activities/LinphoneActivity.java b/src/android/org/linphone/activities/LinphoneActivity.java index 9c5e375e4..ad5c7d026 100644 --- a/src/android/org/linphone/activities/LinphoneActivity.java +++ b/src/android/org/linphone/activities/LinphoneActivity.java @@ -1333,6 +1333,8 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick ContactsManager.getInstance().fetchContactsAsync(); } } + // This one is to allow floating notifications + permissionsList.add(Manifest.permission.SYSTEM_ALERT_WINDOW); if (permissionsList.size() > 0) { String[] permissions = new String[permissionsList.size()]; diff --git a/src/android/org/linphone/compatibility/ApiTwentySixPlus.java b/src/android/org/linphone/compatibility/ApiTwentySixPlus.java index f9f72561f..5b44115d1 100644 --- a/src/android/org/linphone/compatibility/ApiTwentySixPlus.java +++ b/src/android/org/linphone/compatibility/ApiTwentySixPlus.java @@ -13,6 +13,7 @@ import android.graphics.Bitmap; import android.view.ViewTreeObserver; import org.linphone.R; +import org.linphone.mediastream.Log; /* ApiTwentyOnePlus.java @@ -36,31 +37,37 @@ 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); - // 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); + 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 + 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, int msgCount, String msgSender, String msg, Bitmap contactIcon, PendingIntent intent) { diff --git a/src/android/org/linphone/compatibility/Compatibility.java b/src/android/org/linphone/compatibility/Compatibility.java index ad6e0930d..06c7bcc1f 100644 --- a/src/android/org/linphone/compatibility/Compatibility.java +++ b/src/android/org/linphone/compatibility/Compatibility.java @@ -37,9 +37,10 @@ import android.widget.TextView; import org.linphone.mediastream.Version; 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); } }