Compare commits
2 Commits
master
...
bugfix/#29
Author | SHA1 | Date |
---|---|---|
LucasGGamerM | f17eb9ebdc | |
LucasGGamerM | cca2fc4199 |
|
@ -38,6 +38,8 @@ public class PushNotificationReceiver extends BroadcastReceiver{
|
||||||
|
|
||||||
public static final int NOTIFICATION_ID=178;
|
public static final int NOTIFICATION_ID=178;
|
||||||
|
|
||||||
|
private static int notificationID;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent){
|
public void onReceive(Context context, Intent intent){
|
||||||
if(BuildConfig.DEBUG){
|
if(BuildConfig.DEBUG){
|
||||||
|
@ -125,17 +127,21 @@ public class PushNotificationReceiver extends BroadcastReceiver{
|
||||||
.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE);
|
.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE);
|
||||||
}
|
}
|
||||||
Drawable avatar=ImageCache.getInstance(context).get(new UrlImageLoaderRequest(pn.icon, V.dp(50), V.dp(50)));
|
Drawable avatar=ImageCache.getInstance(context).get(new UrlImageLoaderRequest(pn.icon, V.dp(50), V.dp(50)));
|
||||||
|
|
||||||
|
notificationID = GlobalUserPreferences.keepOnlyLatestNotification ? NOTIFICATION_ID : (int)System.currentTimeMillis();
|
||||||
|
|
||||||
Intent contentIntent=new Intent(context, MainActivity.class);
|
Intent contentIntent=new Intent(context, MainActivity.class);
|
||||||
contentIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
contentIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
contentIntent.putExtra("fromNotification", true);
|
contentIntent.putExtra("fromNotification", true);
|
||||||
contentIntent.putExtra("accountID", accountID);
|
contentIntent.putExtra("accountID", accountID);
|
||||||
|
contentIntent.putExtra("notificationID", notificationID);
|
||||||
if(notification!=null){
|
if(notification!=null){
|
||||||
contentIntent.putExtra("notification", Parcels.wrap(notification));
|
contentIntent.putExtra("notification", Parcels.wrap(notification));
|
||||||
}
|
}
|
||||||
builder.setContentTitle(pn.title)
|
builder.setContentTitle(pn.title)
|
||||||
.setContentText(pn.body)
|
.setContentText(pn.body)
|
||||||
.setStyle(new Notification.BigTextStyle().bigText(pn.body))
|
.setStyle(new Notification.BigTextStyle().bigText(pn.body))
|
||||||
.setContentIntent(PendingIntent.getActivity(context, accountID.hashCode() & 0xFFFF, contentIntent, PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT))
|
.setContentIntent(PendingIntent.getActivity(context, notificationID, contentIntent, PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT))
|
||||||
.setWhen(notification==null ? System.currentTimeMillis() : notification.createdAt.toEpochMilli())
|
.setWhen(notification==null ? System.currentTimeMillis() : notification.createdAt.toEpochMilli())
|
||||||
.setShowWhen(true)
|
.setShowWhen(true)
|
||||||
.setCategory(Notification.CATEGORY_SOCIAL)
|
.setCategory(Notification.CATEGORY_SOCIAL)
|
||||||
|
@ -160,6 +166,6 @@ public class PushNotificationReceiver extends BroadcastReceiver{
|
||||||
if(AccountSessionManager.getInstance().getLoggedInAccounts().size()>1){
|
if(AccountSessionManager.getInstance().getLoggedInAccounts().size()>1){
|
||||||
builder.setSubText(accountName);
|
builder.setSubText(accountName);
|
||||||
}
|
}
|
||||||
nm.notify(accountID, GlobalUserPreferences.keepOnlyLatestNotification ? NOTIFICATION_ID : (int)System.currentTimeMillis(), builder.build());
|
nm.notify(accountID, notificationID, builder.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue