Panagiotis Triantafyllou

crash fixes

......@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
ext {
PUBLISH_GROUP_ID = 'ly.warp'
PUBLISH_VERSION = '4.5.5.3'
PUBLISH_VERSION = '4.5.5.4'
PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
}
......
......@@ -257,7 +257,7 @@ public class FCMBaseMessagingService extends FirebaseMessagingService {
// b.setFullScreenIntent(pi, true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ID, "notification_channel", NotificationManager.IMPORTANCE_DEFAULT);
NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ID, "notification_channel", NotificationManager.IMPORTANCE_HIGH);
// notificationChannel.setDescription("Channel description");
// notificationChannel.enableLights(true);
// notificationChannel.setLightColor(color);
......@@ -270,7 +270,7 @@ public class FCMBaseMessagingService extends FirebaseMessagingService {
notification_build_with_largeicon.flags = Notification.FLAG_AUTO_CANCEL; //notification with only large icon due to the two build notificaition is not canceled from bar
nm.notify(pc.getSessionUUID(), uid, notification_build_with_largeicon);
} else {
NotificationManager nm = (NotificationManager) context.getSystemService(NotificationManager.class);
NotificationManager nm = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);
Notification notification_build_with_largeicon = b.build();
notification_build_with_largeicon.flags = Notification.FLAG_AUTO_CANCEL; //notification with only large icon due to the two build notificaition is not canceled from bar
if (nm != null) {
......@@ -296,58 +296,6 @@ public class FCMBaseMessagingService extends FirebaseMessagingService {
}
/*
public void showNotification(Context context, String title, String ticker,
String message, Intent newIntent, String tag, int id) {
SecureRandom randomGenerator = new SecureRandom();
int uid = randomGenerator.nextInt(1000);
WarpUtils.log("Showing notification with tag: " + tag + " and id: "
+ id);
NotificationCompat.Builder builder = new NotificationCompat.Builder(
context);
int imageResource;
int colorResource = 0;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
imageResource = context.getResources().getIdentifier("ic_notification_24dp",
"drawable", context.getPackageName());
colorResource = context.getResources().getIdentifier("push_notifications_color", "color", context.getPackageName());
} else {
imageResource = context.getResources().getIdentifier("ic_notification_logo",
"drawable", context.getPackageName());
}
if (imageResource == 0) {
imageResource = android.R.drawable.btn_star;
}
if (colorResource != 0) {
builder.setColor(context.getResources().getColor(colorResource));
}
builder.setSmallIcon(imageResource);
builder.setContentTitle(title).setContentText(message)
.setSmallIcon(imageResource)
.setAutoCancel(true);
builder.setDefaults(Notification.DEFAULT_ALL);
builder.setAutoCancel(true);
builder.setOngoing(true);
newIntent.setAction(Long.toString(System.currentTimeMillis()));
PendingIntent pi;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
pi = PendingIntent.getActivity(context, uid, newIntent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_MUTABLE);
} else {
pi = PendingIntent.getActivity(context, uid, newIntent, PendingIntent.FLAG_ONE_SHOT);
}
builder.setContentIntent(pi);
NotificationManager nm = (NotificationManager) context
.getSystemService(NotificationManager.class);
Notification notification_build = builder.build();
notification_build.flags = Notification.FLAG_AUTO_CANCEL;
nm.notify(tag, uid, notification_build);
}*/
public void showNotification(Context context, PushCampaign pc, Intent newIntent, List<NotificationCompat.Action> actions, RemoteViews remoteViews, String tag, int id) {
SecureRandom randomGenerator = new SecureRandom();
......@@ -462,7 +410,7 @@ public class FCMBaseMessagingService extends FirebaseMessagingService {
notification_build.flags = Notification.FLAG_AUTO_CANCEL;
nm.notify(pc.getSessionUUID(), uid, notification_build);
} else {
NotificationManager nm = (NotificationManager) context.getSystemService(NotificationManager.class);
NotificationManager nm = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);
Notification notification_build = b.build();
notification_build.flags = Notification.FLAG_AUTO_CANCEL;
if (nm != null) {
......
......@@ -316,7 +316,7 @@ public class HMSBaseMessagingService extends HmsMessageService {
notification_build_with_largeicon.flags = Notification.FLAG_AUTO_CANCEL; //notification with only large icon due to the two build notificaition is not canceled from bar
nm.notify(pc.getSessionUUID(), uid, notification_build_with_largeicon);
} else {
NotificationManager nm = (NotificationManager) context.getSystemService(NotificationManager.class);
NotificationManager nm = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);
Notification notification_build_with_largeicon = b.build();
notification_build_with_largeicon.flags = Notification.FLAG_AUTO_CANCEL; //notification with only large icon due to the two build notificaition is not canceled from bar
nm.notify(pc.getSessionUUID(), uid, notification_build_with_largeicon);
......@@ -341,58 +341,6 @@ public class HMSBaseMessagingService extends HmsMessageService {
}
/*
public void showNotification(Context context, String title, String ticker,
String message, Intent newIntent, String tag, int id) {
SecureRandom randomGenerator = new SecureRandom();
int uid = randomGenerator.nextInt(1000);
WarpUtils.log("Showing notification with tag: " + tag + " and id: "
+ id);
NotificationCompat.Builder builder = new NotificationCompat.Builder(
context);
int imageResource;
int colorResource = 0;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
imageResource = context.getResources().getIdentifier("ic_notification_24dp",
"drawable", context.getPackageName());
colorResource = context.getResources().getIdentifier("push_notifications_color", "color", context.getPackageName());
} else {
imageResource = context.getResources().getIdentifier("ic_notification_logo",
"drawable", context.getPackageName());
}
if (imageResource == 0) {
imageResource = android.R.drawable.btn_star;
}
if (colorResource != 0) {
builder.setColor(context.getResources().getColor(colorResource));
}
builder.setSmallIcon(imageResource);
builder.setContentTitle(title).setContentText(message)
.setSmallIcon(imageResource)
.setAutoCancel(true);
builder.setDefaults(Notification.DEFAULT_ALL);
builder.setAutoCancel(true);
builder.setOngoing(true);
newIntent.setAction(Long.toString(System.currentTimeMillis()));
PendingIntent pi;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
pi = PendingIntent.getActivity(context, uid, newIntent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_MUTABLE);
} else {
pi = PendingIntent.getActivity(context, uid, newIntent, PendingIntent.FLAG_ONE_SHOT);
}
builder.setContentIntent(pi);
NotificationManager nm = (NotificationManager) context
.getSystemService(NotificationManager.class);
Notification notification_build = builder.build();
notification_build.flags = Notification.FLAG_AUTO_CANCEL;
nm.notify(tag, uid, notification_build);
}*/
public void showNotification(Context context, PushCampaign pc, Intent newIntent, List<NotificationCompat.Action> actions, RemoteViews remoteViews, String tag, int id) {
SecureRandom randomGenerator = new SecureRandom();
......@@ -506,7 +454,7 @@ public class HMSBaseMessagingService extends HmsMessageService {
notification_build.flags = Notification.FLAG_AUTO_CANCEL;
nm.notify(pc.getSessionUUID(), uid, notification_build);
} else {
NotificationManager nm = (NotificationManager) context.getSystemService(NotificationManager.class);
NotificationManager nm = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);
Notification notification_build = b.build();
notification_build.flags = Notification.FLAG_AUTO_CANCEL;
nm.notify(pc.getSessionUUID(), uid, notification_build);
......
......@@ -196,7 +196,7 @@ public abstract class WarpBaseIntentService extends IntentService {
b.build().flags = Notification.FLAG_AUTO_CANCEL; //notification with only large icon due to the two build notificaition is not canceled from bar
nm.notify(pc.getSessionUUID(), uid, b.build());
} else {
NotificationManager nm = (NotificationManager) context.getSystemService(NotificationManager.class);
NotificationManager nm = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);
Notification notification_build_with_largeicon = b.build();
b.build().flags = Notification.FLAG_AUTO_CANCEL; //notification with only large icon due to the two build notificaition is not canceled from bar
nm.notify(pc.getSessionUUID(), uid, b.build());
......@@ -222,58 +222,6 @@ public abstract class WarpBaseIntentService extends IntentService {
}
/*
public void showNotification(Context context, String title, String ticker,
String message, Intent newIntent, String tag, int id) {
SecureRandom randomGenerator = new SecureRandom();
int uid = randomGenerator.nextInt(1000);
WarpUtils.log("Showing notification with tag: " + tag + " and id: "
+ id);
NotificationCompat.Builder builder = new NotificationCompat.Builder(
context);
int imageResource;
int colorResource = 0;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
imageResource = context.getResources().getIdentifier("ic_notification_24dp",
"drawable", context.getPackageName());
colorResource = context.getResources().getIdentifier("push_notifications_color", "color", context.getPackageName());
} else {
imageResource = context.getResources().getIdentifier("ic_notification_logo",
"drawable", context.getPackageName());
}
if (imageResource == 0) {
imageResource = android.R.drawable.btn_star;
}
if (colorResource != 0) {
builder.setColor(context.getResources().getColor(colorResource));
}
builder.setSmallIcon(imageResource);
builder.setContentTitle(title).setContentText(message)
.setSmallIcon(imageResource)
.setAutoCancel(true);
builder.setDefaults(Notification.DEFAULT_ALL);
builder.setAutoCancel(true);
builder.setOngoing(true);
newIntent.setAction(Long.toString(System.currentTimeMillis()));
PendingIntent pi;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
pi = PendingIntent.getActivity(context, uid, newIntent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_MUTABLE);
} else {
pi = PendingIntent.getActivity(context, uid, newIntent, PendingIntent.FLAG_ONE_SHOT);
}
builder.setContentIntent(pi);
NotificationManager nm = (NotificationManager) context
.getSystemService(NotificationManager.class);
Notification notification_build = builder.build();
notification_build.flags = Notification.FLAG_AUTO_CANCEL;
nm.notify(tag, uid, notification_build);
}*/
public void showNotification(Context context, PushCampaign pc, Intent newIntent, List<NotificationCompat.Action> actions, RemoteViews remoteViews, String tag, int id) {
SecureRandom randomGenerator = new SecureRandom();
......@@ -381,7 +329,7 @@ public abstract class WarpBaseIntentService extends IntentService {
b.build().flags = Notification.FLAG_AUTO_CANCEL;
nm.notify(pc.getSessionUUID(), uid, b.build());
} else {
NotificationManager nm = (NotificationManager) context.getSystemService(NotificationManager.class);
NotificationManager nm = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);
// Notification notification_build = b.build();
b.build().flags = Notification.FLAG_AUTO_CANCEL;
nm.notify(pc.getSessionUUID(), uid, b.build());
......
......@@ -30,7 +30,7 @@ public class WarpConstants {
/**
* The version of the SDK installed in the device
*/
public static final String SDK_VERSION = "4.5.5.3";
public static final String SDK_VERSION = "4.5.5.4";
/**
* The URL of the server where it should ping
......