Fixes & improvements
This commit is contained in:
parent
601259f15e
commit
0d78e2291a
11 changed files with 100 additions and 111 deletions
|
@ -1491,7 +1491,7 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
||||||
} else if (extras != null && extras.getBoolean("GoToInapp", false)) {
|
} else if (extras != null && extras.getBoolean("GoToInapp", false)) {
|
||||||
intent.putExtra("DoNotGoToCallActivity", true);
|
intent.putExtra("DoNotGoToCallActivity", true);
|
||||||
displayInapp();
|
displayInapp();
|
||||||
} else if (extras != null && extras.getBoolean("Notifiable", false)) {
|
} else if (extras != null && extras.getBoolean("Notification", false)) {
|
||||||
if (LinphoneManager.getLc().getCallsNb() > 0) {
|
if (LinphoneManager.getLc().getCallsNb() > 0) {
|
||||||
startIncallActivity();
|
startIncallActivity();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +1,5 @@
|
||||||
package org.linphone.compatibility;
|
package org.linphone.compatibility;
|
||||||
|
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
|
||||||
import android.app.Notification;
|
|
||||||
import android.app.PendingIntent;
|
|
||||||
import android.app.Person;
|
|
||||||
import android.app.RemoteInput;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
|
|
||||||
import org.linphone.R;
|
|
||||||
import org.linphone.notifications.Notifiable;
|
|
||||||
import org.linphone.notifications.NotifiableMessage;
|
|
||||||
import org.linphone.notifications.NotificationBroadcastReceiver;
|
|
||||||
|
|
||||||
import static org.linphone.compatibility.Compatibility.INTENT_ANSWER_CALL_NOTIF_ACTION;
|
|
||||||
import static org.linphone.compatibility.Compatibility.INTENT_CALL_ID;
|
|
||||||
import static org.linphone.compatibility.Compatibility.INTENT_HANGUP_CALL_NOTIF_ACTION;
|
|
||||||
import static org.linphone.compatibility.Compatibility.INTENT_LOCAL_IDENTITY;
|
|
||||||
import static org.linphone.compatibility.Compatibility.INTENT_NOTIF_ID;
|
|
||||||
import static org.linphone.compatibility.Compatibility.INTENT_REPLY_NOTIF_ACTION;
|
|
||||||
import static org.linphone.compatibility.Compatibility.KEY_TEXT_REPLY;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ApiTwentyEightPlus.java
|
ApiTwentyEightPlus.java
|
||||||
Copyright (C) 2017 Belledonne Communications, Grenoble, France
|
Copyright (C) 2017 Belledonne Communications, Grenoble, France
|
||||||
|
@ -42,16 +19,27 @@ along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import android.annotation.TargetApi;
|
||||||
|
import android.app.Notification;
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.app.Person;
|
||||||
|
import android.app.RemoteInput;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
|
||||||
|
import org.linphone.R;
|
||||||
|
import org.linphone.notifications.Notifiable;
|
||||||
|
import org.linphone.notifications.NotifiableMessage;
|
||||||
|
import org.linphone.notifications.NotificationBroadcastReceiver;
|
||||||
|
|
||||||
|
import static org.linphone.compatibility.Compatibility.INTENT_LOCAL_IDENTITY;
|
||||||
|
import static org.linphone.compatibility.Compatibility.INTENT_NOTIF_ID;
|
||||||
|
import static org.linphone.compatibility.Compatibility.INTENT_REPLY_NOTIF_ACTION;
|
||||||
|
import static org.linphone.compatibility.Compatibility.KEY_TEXT_REPLY;
|
||||||
|
|
||||||
@TargetApi(28)
|
@TargetApi(28)
|
||||||
public class ApiTwentyEightPlus {
|
public class ApiTwentyEightPlus {
|
||||||
|
|
||||||
public static Notification createRepliedNotification(Context context, String reply) {
|
|
||||||
return new Notification.Builder(context)
|
|
||||||
.setSmallIcon(R.drawable.topbar_chat_notification)
|
|
||||||
.setContentText(context.getString(R.string.notification_replied_label).replace("%s", reply))
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Notification createMessageNotification(Context context, Notifiable notif, Bitmap contactIcon, PendingIntent intent) {
|
public static Notification createMessageNotification(Context context, Notifiable notif, Bitmap contactIcon, PendingIntent intent) {
|
||||||
String replyLabel = context.getResources().getString(R.string.notification_reply_label);
|
String replyLabel = context.getResources().getString(R.string.notification_reply_label);
|
||||||
RemoteInput remoteInput = new RemoteInput.Builder(KEY_TEXT_REPLY).setLabel(replyLabel).build();
|
RemoteInput remoteInput = new RemoteInput.Builder(KEY_TEXT_REPLY).setLabel(replyLabel).build();
|
||||||
|
@ -81,7 +69,7 @@ public class ApiTwentyEightPlus {
|
||||||
}
|
}
|
||||||
style.setGroupConversation(notif.isGroup());
|
style.setGroupConversation(notif.isGroup());
|
||||||
|
|
||||||
return new Notification.Builder(context)
|
return new Notification.Builder(context, context.getString(R.string.notification_channel_id))
|
||||||
.setSmallIcon(R.drawable.topbar_chat_notification)
|
.setSmallIcon(R.drawable.topbar_chat_notification)
|
||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
.setContentIntent(intent)
|
.setContentIntent(intent)
|
||||||
|
|
|
@ -1,27 +1,5 @@
|
||||||
package org.linphone.compatibility;
|
package org.linphone.compatibility;
|
||||||
|
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
|
||||||
import android.app.Notification;
|
|
||||||
import android.app.PendingIntent;
|
|
||||||
import android.app.RemoteInput;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
|
|
||||||
import org.linphone.R;
|
|
||||||
import org.linphone.notifications.Notifiable;
|
|
||||||
import org.linphone.notifications.NotifiableMessage;
|
|
||||||
import org.linphone.notifications.NotificationBroadcastReceiver;
|
|
||||||
|
|
||||||
import static org.linphone.compatibility.Compatibility.INTENT_ANSWER_CALL_NOTIF_ACTION;
|
|
||||||
import static org.linphone.compatibility.Compatibility.INTENT_CALL_ID;
|
|
||||||
import static org.linphone.compatibility.Compatibility.INTENT_HANGUP_CALL_NOTIF_ACTION;
|
|
||||||
import static org.linphone.compatibility.Compatibility.INTENT_LOCAL_IDENTITY;
|
|
||||||
import static org.linphone.compatibility.Compatibility.INTENT_NOTIF_ID;
|
|
||||||
import static org.linphone.compatibility.Compatibility.INTENT_REPLY_NOTIF_ACTION;
|
|
||||||
import static org.linphone.compatibility.Compatibility.KEY_TEXT_REPLY;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ApiTwentyFourPlus.java
|
ApiTwentyFourPlus.java
|
||||||
Copyright (C) 2017 Belledonne Communications, Grenoble, France
|
Copyright (C) 2017 Belledonne Communications, Grenoble, France
|
||||||
|
@ -41,6 +19,26 @@ along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import android.annotation.TargetApi;
|
||||||
|
import android.app.Notification;
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.app.RemoteInput;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
|
||||||
|
import org.linphone.R;
|
||||||
|
import org.linphone.notifications.Notifiable;
|
||||||
|
import org.linphone.notifications.NotifiableMessage;
|
||||||
|
import org.linphone.notifications.NotificationBroadcastReceiver;
|
||||||
|
|
||||||
|
import static org.linphone.compatibility.Compatibility.INTENT_ANSWER_CALL_NOTIF_ACTION;
|
||||||
|
import static org.linphone.compatibility.Compatibility.INTENT_HANGUP_CALL_NOTIF_ACTION;
|
||||||
|
import static org.linphone.compatibility.Compatibility.INTENT_LOCAL_IDENTITY;
|
||||||
|
import static org.linphone.compatibility.Compatibility.INTENT_NOTIF_ID;
|
||||||
|
import static org.linphone.compatibility.Compatibility.INTENT_REPLY_NOTIF_ACTION;
|
||||||
|
import static org.linphone.compatibility.Compatibility.KEY_TEXT_REPLY;
|
||||||
|
|
||||||
@TargetApi(24)
|
@TargetApi(24)
|
||||||
public class ApiTwentyFourPlus {
|
public class ApiTwentyFourPlus {
|
||||||
|
|
||||||
|
@ -100,7 +98,7 @@ public class ApiTwentyFourPlus {
|
||||||
|
|
||||||
Intent hangupIntent = new Intent(context, NotificationBroadcastReceiver.class);
|
Intent hangupIntent = new Intent(context, NotificationBroadcastReceiver.class);
|
||||||
hangupIntent.setAction(INTENT_HANGUP_CALL_NOTIF_ACTION);
|
hangupIntent.setAction(INTENT_HANGUP_CALL_NOTIF_ACTION);
|
||||||
hangupIntent.putExtra(INTENT_CALL_ID, callId);
|
hangupIntent.putExtra(INTENT_NOTIF_ID, callId);
|
||||||
|
|
||||||
PendingIntent hangupPendingIntent = PendingIntent.getBroadcast(context,
|
PendingIntent hangupPendingIntent = PendingIntent.getBroadcast(context,
|
||||||
callId, hangupIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
callId, hangupIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
|
@ -123,7 +121,7 @@ public class ApiTwentyFourPlus {
|
||||||
if (showAnswerAction) {
|
if (showAnswerAction) {
|
||||||
Intent answerIntent = new Intent(context, NotificationBroadcastReceiver.class);
|
Intent answerIntent = new Intent(context, NotificationBroadcastReceiver.class);
|
||||||
answerIntent.setAction(INTENT_ANSWER_CALL_NOTIF_ACTION);
|
answerIntent.setAction(INTENT_ANSWER_CALL_NOTIF_ACTION);
|
||||||
answerIntent.putExtra(INTENT_CALL_ID, callId);
|
answerIntent.putExtra(INTENT_NOTIF_ID, callId);
|
||||||
|
|
||||||
PendingIntent answerPendingIntent = PendingIntent.getBroadcast(context,
|
PendingIntent answerPendingIntent = PendingIntent.getBroadcast(context,
|
||||||
callId, answerIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
callId, answerIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
|
|
|
@ -1,15 +1,5 @@
|
||||||
package org.linphone.compatibility;
|
package org.linphone.compatibility;
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
|
||||||
import android.app.Notification;
|
|
||||||
import android.app.PendingIntent;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.support.v4.content.ContextCompat;
|
|
||||||
import android.view.ViewTreeObserver;
|
|
||||||
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
|
||||||
|
|
||||||
import org.linphone.R;
|
|
||||||
/*
|
/*
|
||||||
ApiTwentyOnePlus.java
|
ApiTwentyOnePlus.java
|
||||||
Copyright (C) 2017 Belledonne Communications, Grenoble, France
|
Copyright (C) 2017 Belledonne Communications, Grenoble, France
|
||||||
|
@ -29,6 +19,17 @@ along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import android.annotation.TargetApi;
|
||||||
|
import android.app.Notification;
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.support.v4.content.ContextCompat;
|
||||||
|
import android.view.ViewTreeObserver;
|
||||||
|
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
||||||
|
|
||||||
|
import org.linphone.R;
|
||||||
|
|
||||||
@TargetApi(21)
|
@TargetApi(21)
|
||||||
public class ApiTwentyOnePlus {
|
public class ApiTwentyOnePlus {
|
||||||
|
|
||||||
|
|
|
@ -1,30 +1,5 @@
|
||||||
package org.linphone.compatibility;
|
package org.linphone.compatibility;
|
||||||
|
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
|
||||||
import android.app.FragmentTransaction;
|
|
||||||
import android.app.Notification;
|
|
||||||
import android.app.NotificationChannel;
|
|
||||||
import android.app.NotificationManager;
|
|
||||||
import android.app.PendingIntent;
|
|
||||||
import android.app.RemoteInput;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
|
|
||||||
import org.linphone.R;
|
|
||||||
import org.linphone.notifications.Notifiable;
|
|
||||||
import org.linphone.notifications.NotifiableMessage;
|
|
||||||
import org.linphone.notifications.NotificationBroadcastReceiver;
|
|
||||||
|
|
||||||
import static org.linphone.compatibility.Compatibility.INTENT_ANSWER_CALL_NOTIF_ACTION;
|
|
||||||
import static org.linphone.compatibility.Compatibility.INTENT_CALL_ID;
|
|
||||||
import static org.linphone.compatibility.Compatibility.INTENT_HANGUP_CALL_NOTIF_ACTION;
|
|
||||||
import static org.linphone.compatibility.Compatibility.INTENT_LOCAL_IDENTITY;
|
|
||||||
import static org.linphone.compatibility.Compatibility.INTENT_NOTIF_ID;
|
|
||||||
import static org.linphone.compatibility.Compatibility.INTENT_REPLY_NOTIF_ACTION;
|
|
||||||
import static org.linphone.compatibility.Compatibility.KEY_TEXT_REPLY;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ApiTwentySixPlus.java
|
ApiTwentySixPlus.java
|
||||||
Copyright (C) 2017 Belledonne Communications, Grenoble, France
|
Copyright (C) 2017 Belledonne Communications, Grenoble, France
|
||||||
|
@ -44,6 +19,29 @@ along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import android.annotation.TargetApi;
|
||||||
|
import android.app.FragmentTransaction;
|
||||||
|
import android.app.Notification;
|
||||||
|
import android.app.NotificationChannel;
|
||||||
|
import android.app.NotificationManager;
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.app.RemoteInput;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
|
||||||
|
import org.linphone.R;
|
||||||
|
import org.linphone.notifications.Notifiable;
|
||||||
|
import org.linphone.notifications.NotifiableMessage;
|
||||||
|
import org.linphone.notifications.NotificationBroadcastReceiver;
|
||||||
|
|
||||||
|
import static org.linphone.compatibility.Compatibility.INTENT_ANSWER_CALL_NOTIF_ACTION;
|
||||||
|
import static org.linphone.compatibility.Compatibility.INTENT_HANGUP_CALL_NOTIF_ACTION;
|
||||||
|
import static org.linphone.compatibility.Compatibility.INTENT_LOCAL_IDENTITY;
|
||||||
|
import static org.linphone.compatibility.Compatibility.INTENT_NOTIF_ID;
|
||||||
|
import static org.linphone.compatibility.Compatibility.INTENT_REPLY_NOTIF_ACTION;
|
||||||
|
import static org.linphone.compatibility.Compatibility.KEY_TEXT_REPLY;
|
||||||
|
|
||||||
@TargetApi(26)
|
@TargetApi(26)
|
||||||
public class ApiTwentySixPlus {
|
public class ApiTwentySixPlus {
|
||||||
public static Notification createRepliedNotification(Context context, String reply) {
|
public static Notification createRepliedNotification(Context context, String reply) {
|
||||||
|
@ -133,7 +131,7 @@ public class ApiTwentySixPlus {
|
||||||
|
|
||||||
Intent hangupIntent = new Intent(context, NotificationBroadcastReceiver.class);
|
Intent hangupIntent = new Intent(context, NotificationBroadcastReceiver.class);
|
||||||
hangupIntent.setAction(INTENT_HANGUP_CALL_NOTIF_ACTION);
|
hangupIntent.setAction(INTENT_HANGUP_CALL_NOTIF_ACTION);
|
||||||
hangupIntent.putExtra(INTENT_CALL_ID, callId);
|
hangupIntent.putExtra(INTENT_NOTIF_ID, callId);
|
||||||
|
|
||||||
PendingIntent hangupPendingIntent = PendingIntent.getBroadcast(context,
|
PendingIntent hangupPendingIntent = PendingIntent.getBroadcast(context,
|
||||||
callId, hangupIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
callId, hangupIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
|
@ -156,7 +154,7 @@ public class ApiTwentySixPlus {
|
||||||
if (showAnswerAction) {
|
if (showAnswerAction) {
|
||||||
Intent answerIntent = new Intent(context, NotificationBroadcastReceiver.class);
|
Intent answerIntent = new Intent(context, NotificationBroadcastReceiver.class);
|
||||||
answerIntent.setAction(INTENT_ANSWER_CALL_NOTIF_ACTION);
|
answerIntent.setAction(INTENT_ANSWER_CALL_NOTIF_ACTION);
|
||||||
answerIntent.putExtra(INTENT_CALL_ID, callId);
|
answerIntent.putExtra(INTENT_NOTIF_ID, callId);
|
||||||
|
|
||||||
PendingIntent answerPendingIntent = PendingIntent.getBroadcast(context,
|
PendingIntent answerPendingIntent = PendingIntent.getBroadcast(context,
|
||||||
callId, answerIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
callId, answerIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package org.linphone.compatibility;
|
package org.linphone.compatibility;
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ApiTwentyThreePlus.java
|
ApiTwentyThreePlus.java
|
||||||
Copyright (C) 2017 Belledonne Communications, Grenoble, France
|
Copyright (C) 2017 Belledonne Communications, Grenoble, France
|
||||||
|
@ -22,6 +19,9 @@ along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import android.annotation.TargetApi;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
@TargetApi(23)
|
@TargetApi(23)
|
||||||
public class ApiTwentyThreePlus {
|
public class ApiTwentyThreePlus {
|
||||||
public static void setTextAppearance(TextView textview, int style) {
|
public static void setTextAppearance(TextView textview, int style) {
|
||||||
|
|
|
@ -34,7 +34,6 @@ import org.linphone.notifications.Notifiable;
|
||||||
public class Compatibility {
|
public class Compatibility {
|
||||||
public static final String KEY_TEXT_REPLY = "key_text_reply";
|
public static final String KEY_TEXT_REPLY = "key_text_reply";
|
||||||
public static final String INTENT_NOTIF_ID = "NOTIFICATION_ID";
|
public static final String INTENT_NOTIF_ID = "NOTIFICATION_ID";
|
||||||
public static final String INTENT_CALL_ID = "CALL_ID";
|
|
||||||
public static final String INTENT_REPLY_NOTIF_ACTION = "org.linphone.REPLY_ACTION";
|
public static final String INTENT_REPLY_NOTIF_ACTION = "org.linphone.REPLY_ACTION";
|
||||||
public static final String INTENT_HANGUP_CALL_NOTIF_ACTION = "org.linphone.HANGUP_CALL_ACTION";
|
public static final String INTENT_HANGUP_CALL_NOTIF_ACTION = "org.linphone.HANGUP_CALL_ACTION";
|
||||||
public static final String INTENT_ANSWER_CALL_NOTIF_ACTION = "org.linphone.ANSWER_CALL_ACTION";
|
public static final String INTENT_ANSWER_CALL_NOTIF_ACTION = "org.linphone.ANSWER_CALL_ACTION";
|
||||||
|
@ -73,9 +72,7 @@ public class Compatibility {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Notification createRepliedNotification(Context context, String reply) {
|
public static Notification createRepliedNotification(Context context, String reply) {
|
||||||
if (Version.sdkAboveOrEqual(28)) {
|
if (Version.sdkAboveOrEqual(Version.API26_O_80)) {
|
||||||
return ApiTwentyEightPlus.createRepliedNotification(context, reply);
|
|
||||||
} else if (Version.sdkAboveOrEqual(Version.API26_O_80)) {
|
|
||||||
return ApiTwentySixPlus.createRepliedNotification(context, reply);
|
return ApiTwentySixPlus.createRepliedNotification(context, reply);
|
||||||
} else if (Version.sdkAboveOrEqual(Version.API24_NOUGAT_70)) {
|
} else if (Version.sdkAboveOrEqual(Version.API24_NOUGAT_70)) {
|
||||||
return ApiTwentyFourPlus.createRepliedNotification(context, reply);
|
return ApiTwentyFourPlus.createRepliedNotification(context, reply);
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class FirebaseIdService extends FirebaseInstanceIdService {
|
||||||
public void onTokenRefresh() {
|
public void onTokenRefresh() {
|
||||||
// Get updated InstanceID token.
|
// Get updated InstanceID token.
|
||||||
final String refreshedToken = FirebaseInstanceId.getInstance().getToken();
|
final String refreshedToken = FirebaseInstanceId.getInstance().getToken();
|
||||||
android.util.Log.i("FirebaseIdService", "[Push Notifiable] Refreshed token: " + refreshedToken);
|
android.util.Log.i("FirebaseIdService", "[Push Notification] Refreshed token: " + refreshedToken);
|
||||||
|
|
||||||
LinphoneUtils.dispatchOnUIThread(new Runnable() {
|
LinphoneUtils.dispatchOnUIThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -36,10 +36,10 @@ public class FirebaseMessaging extends FirebaseMessagingService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMessageReceived(RemoteMessage remoteMessage) {
|
public void onMessageReceived(RemoteMessage remoteMessage) {
|
||||||
android.util.Log.i("FirebaseMessaging", "[Push Notifiable] Received");
|
android.util.Log.i("FirebaseMessaging", "[Push Notification] Received");
|
||||||
|
|
||||||
if (!LinphoneService.isReady()) {
|
if (!LinphoneService.isReady()) {
|
||||||
android.util.Log.i("FirebaseMessaging", "[Push Notifiable] Starting Service");
|
android.util.Log.i("FirebaseMessaging", "[Push Notification] Starting Service");
|
||||||
startService(new Intent(ACTION_MAIN).setClass(this, LinphoneService.class));
|
startService(new Intent(ACTION_MAIN).setClass(this, LinphoneService.class));
|
||||||
} else if (LinphoneManager.isInstanciated() && LinphoneManager.getLc().getCallsNb() == 0) {
|
} else if (LinphoneManager.isInstanciated() && LinphoneManager.getLc().getCallsNb() == 0) {
|
||||||
LinphoneUtils.dispatchOnUIThread(new Runnable() {
|
LinphoneUtils.dispatchOnUIThread(new Runnable() {
|
||||||
|
|
|
@ -107,9 +107,15 @@ public class NotificationBroadcastReceiver extends BroadcastReceiver {
|
||||||
String remoteAddr = LinphoneService.instance().getNotificationManager().getSipUriForCallNotificationId(notifId);
|
String remoteAddr = LinphoneService.instance().getNotificationManager().getSipUriForCallNotificationId(notifId);
|
||||||
|
|
||||||
Core core = LinphoneManager.getLc();
|
Core core = LinphoneManager.getLc();
|
||||||
if (core == null) return;
|
if (core == null) {
|
||||||
|
Log.e("Couldn't get Core instance");
|
||||||
|
return;
|
||||||
|
}
|
||||||
Call call = core.findCallFromUri(remoteAddr);
|
Call call = core.findCallFromUri(remoteAddr);
|
||||||
if (call == null) return;
|
if (call == null) {
|
||||||
|
Log.e("Couldn't find call from remote address " + remoteAddr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (intent.getAction() == Compatibility.INTENT_ANSWER_CALL_NOTIF_ACTION) {
|
if (intent.getAction() == Compatibility.INTENT_ANSWER_CALL_NOTIF_ACTION) {
|
||||||
call.accept();
|
call.accept();
|
||||||
|
|
|
@ -55,7 +55,6 @@ public class NotificationsManager {
|
||||||
private NotificationManager mNM;
|
private NotificationManager mNM;
|
||||||
private HashMap<String, Notifiable> mChatNotifMap, mCallNotifMap;
|
private HashMap<String, Notifiable> mChatNotifMap, mCallNotifMap;
|
||||||
private int mLastNotificationId;
|
private int mLastNotificationId;
|
||||||
private PendingIntent mPendingIntent;
|
|
||||||
private Notification mServiceNotification;
|
private Notification mServiceNotification;
|
||||||
|
|
||||||
public NotificationsManager(Context context) {
|
public NotificationsManager(Context context) {
|
||||||
|
@ -71,8 +70,7 @@ public class NotificationsManager {
|
||||||
Compatibility.createNotificationChannels(mContext);
|
Compatibility.createNotificationChannels(mContext);
|
||||||
|
|
||||||
Intent notifIntent = new Intent(mContext, LinphoneService.instance().getIncomingReceivedActivity());
|
Intent notifIntent = new Intent(mContext, LinphoneService.instance().getIncomingReceivedActivity());
|
||||||
notifIntent.putExtra("Notifiable", true);
|
notifIntent.putExtra("Notification", true);
|
||||||
mPendingIntent = PendingIntent.getActivity(mContext, 0, notifIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
||||||
|
|
||||||
//Disable service notification for Android O
|
//Disable service notification for Android O
|
||||||
if (Version.sdkAboveOrEqual(Version.API26_O_80)) {
|
if (Version.sdkAboveOrEqual(Version.API26_O_80)) {
|
||||||
|
@ -84,8 +82,9 @@ public class NotificationsManager {
|
||||||
bm = BitmapFactory.decodeResource(mContext.getResources(), R.mipmap.ic_launcher);
|
bm = BitmapFactory.decodeResource(mContext.getResources(), R.mipmap.ic_launcher);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
|
PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, notifIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
mServiceNotification = Compatibility.createNotification(mContext, mContext.getString(R.string.service_name), "",
|
mServiceNotification = Compatibility.createNotification(mContext, mContext.getString(R.string.service_name), "",
|
||||||
R.drawable.linphone_notification_icon, R.mipmap.ic_launcher, bm, mPendingIntent, true,
|
R.drawable.linphone_notification_icon, R.mipmap.ic_launcher, bm, pendingIntent, true,
|
||||||
Notification.PRIORITY_MIN);
|
Notification.PRIORITY_MIN);
|
||||||
|
|
||||||
if (isServiceNotificationDisplayed()) {
|
if (isServiceNotificationDisplayed()) {
|
||||||
|
@ -226,6 +225,8 @@ public class NotificationsManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayCallNotification(Call call) {
|
public void displayCallNotification(Call call) {
|
||||||
|
Intent callNotifIntent = new Intent(mContext, LinphoneService.instance().getIncomingReceivedActivity());
|
||||||
|
PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, callNotifIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
if (call == null) return;
|
if (call == null) return;
|
||||||
|
|
||||||
Address address = call.getRemoteAddress();
|
Address address = call.getRemoteAddress();
|
||||||
|
@ -283,7 +284,7 @@ public class NotificationsManager {
|
||||||
boolean showAnswerAction = call.getState() == Call.State.IncomingReceived || call.getState() == Call.State.IncomingEarlyMedia;
|
boolean showAnswerAction = call.getState() == Call.State.IncomingReceived || call.getState() == Call.State.IncomingEarlyMedia;
|
||||||
Notification notification = Compatibility.createInCallNotification(mContext, notif.getNotificationId(),
|
Notification notification = Compatibility.createInCallNotification(mContext, notif.getNotificationId(),
|
||||||
showAnswerAction, mContext.getString(R.string.service_name),
|
showAnswerAction, mContext.getString(R.string.service_name),
|
||||||
mContext.getString(notificationTextId), iconId, bm, name, mPendingIntent);
|
mContext.getString(notificationTextId), iconId, bm, name, pendingIntent);
|
||||||
|
|
||||||
sendNotification(notif.getNotificationId(), notification);
|
sendNotification(notif.getNotificationId(), notification);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue