Improved notifications
This commit is contained in:
parent
9c8a3ca9ad
commit
9a2bdfc2c4
7 changed files with 35 additions and 24 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"/>
|
||||
|
|
|
@ -464,5 +464,6 @@ Vos amis pourront vous joindre plus facilement si vous associez votre compte à
|
|||
<string name="content_description_call_options">Options d\'appel</string>
|
||||
<string name="content_description_audio_route">Route audio</string>
|
||||
<string name="content_description_exit_conference">Quitter la conférence</string>
|
||||
<string name="content_title_notification_service">Linphone Service</string>
|
||||
<string name="content_title_notification_service">Linphone service notification</string>
|
||||
<string name="content_title_notification">Linphone instant messages notifications</string>
|
||||
</resources>
|
||||
|
|
|
@ -521,8 +521,8 @@
|
|||
<string name="content_description_call_options">Call options</string>
|
||||
<string name="content_description_audio_route">Audio route</string>
|
||||
<string name="content_description_exit_conference">Exit conference</string>
|
||||
<string name="content_title_notification_service">Linphone Service</string>
|
||||
<string name="content_title_notification">Linphone Notification</string>
|
||||
<string name="content_title_notification_service">Linphone service notification</string>
|
||||
<string name="content_title_notification">Linphone instant messages notifications</string>
|
||||
<string name="content_description_conversation_subject">Group chat room subject</string>
|
||||
<string name="content_description_conversation_infos">Group chat room info</string>
|
||||
</resources>
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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()];
|
||||
|
|
|
@ -13,6 +13,7 @@ import android.graphics.Bitmap;
|
|||
import android.view.ViewTreeObserver;
|
||||
|
||||
import org.linphone.R;
|
||||
import org.linphone.mediastream.Log;
|
||||
|
||||
/*
|
||||
ApiTwentyOnePlus.java
|
||||
|
@ -36,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,
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue