Loading src/android/com/adobe/phonegap/push/GCMIntentService.java +18 −10 Changes for src/android/com/adobe/phonegap/push/GCMIntentService.java: 18 added lines, 10 removed lines. Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.text.Html; import com.google.android.gcm.GCMBaseIntentService; import java.util.ArrayList; import java.util.HashMap; @SuppressLint("NewApi") public class GCMIntentService extends GCMBaseIntentService { Loading @@ -41,11 +42,17 @@ public class GCMIntentService extends GCMBaseIntentService { private static final String STYLE_INBOX = "inbox"; private static final String STYLE_PICTURE = "picture"; private static final String STYLE_TEXT = "text"; private static ArrayList<String> messageList = new ArrayList(); private static HashMap<Integer, ArrayList<String>> messageMap = new HashMap<Integer, ArrayList<String>>(); public void setNotification(String message){ if(message == ""){ public void setNotification(int notId, String message){ ArrayList<String> messageList = messageMap.get(notId); if(messageList == null) { messageList = new ArrayList<String>(); messageMap.put(notId, messageList); } if(message.isEmpty()){ messageList.clear(); }else{ messageList.add(message); Loading Loading @@ -109,9 +116,11 @@ public class GCMIntentService extends GCMBaseIntentService { String packageName = context.getPackageName(); Resources resources = context.getResources(); int notId = parseInt("notId", extras); Intent notificationIntent = new Intent(this, PushHandlerActivity.class); notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); notificationIntent.putExtra("pushBundle", extras); notificationIntent.putExtra("notId", notId); int requestCode = new Random().nextInt(); PendingIntent contentIntent = PendingIntent.getActivity(this, requestCode, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); Loading Loading @@ -197,7 +206,7 @@ public class GCMIntentService extends GCMBaseIntentService { /* * Notification message */ setNotificationMessage(extras, mBuilder); setNotificationMessage(notId, extras, mBuilder); /* * Notification count Loading @@ -209,8 +218,6 @@ public class GCMIntentService extends GCMBaseIntentService { */ createActions(extras, mBuilder, resources, packageName); int notId = parseInt("notId", extras); mNotificationManager.notify((String) appName, notId, mBuilder.build()); } Loading Loading @@ -266,15 +273,16 @@ public class GCMIntentService extends GCMBaseIntentService { } } private void setNotificationMessage(Bundle extras, NotificationCompat.Builder mBuilder) { private void setNotificationMessage(int notId, Bundle extras, NotificationCompat.Builder mBuilder) { String message = getMessageText(extras); String style = getString(extras, "style", STYLE_TEXT); if(STYLE_INBOX.equals(style)) { setNotification(message); setNotification(notId, message); mBuilder.setContentText(message); ArrayList<String> messageList = messageMap.get(notId); Integer sizeList = messageList.size(); if (sizeList > 1) { String sizeListMessage = sizeList.toString(); Loading @@ -294,7 +302,7 @@ public class GCMIntentService extends GCMBaseIntentService { mBuilder.setStyle(notificationInbox); } } else if (STYLE_PICTURE.equals(style)) { setNotification(""); setNotification(notId, ""); NotificationCompat.BigPictureStyle bigPicture = new NotificationCompat.BigPictureStyle(); bigPicture.bigPicture(getBitmapFromURL(getString(extras, "picture"))); Loading @@ -306,7 +314,7 @@ public class GCMIntentService extends GCMBaseIntentService { mBuilder.setStyle(bigPicture); } else { setNotification(""); setNotification(notId, ""); NotificationCompat.BigTextStyle bigText = new NotificationCompat.BigTextStyle(); Loading src/android/com/adobe/phonegap/push/PushHandlerActivity.java +1 −1 Changes for src/android/com/adobe/phonegap/push/PushHandlerActivity.java: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ public class PushHandlerActivity extends Activity @Override public void onCreate(Bundle savedInstanceState) { GCMIntentService gcm = new GCMIntentService(); gcm.setNotification(""); gcm.setNotification(getIntent().getIntExtra("notId", 0), ""); super.onCreate(savedInstanceState); Log.v(LOG_TAG, "onCreate"); Loading Loading
src/android/com/adobe/phonegap/push/GCMIntentService.java +18 −10 Changes for src/android/com/adobe/phonegap/push/GCMIntentService.java: 18 added lines, 10 removed lines. Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.text.Html; import com.google.android.gcm.GCMBaseIntentService; import java.util.ArrayList; import java.util.HashMap; @SuppressLint("NewApi") public class GCMIntentService extends GCMBaseIntentService { Loading @@ -41,11 +42,17 @@ public class GCMIntentService extends GCMBaseIntentService { private static final String STYLE_INBOX = "inbox"; private static final String STYLE_PICTURE = "picture"; private static final String STYLE_TEXT = "text"; private static ArrayList<String> messageList = new ArrayList(); private static HashMap<Integer, ArrayList<String>> messageMap = new HashMap<Integer, ArrayList<String>>(); public void setNotification(String message){ if(message == ""){ public void setNotification(int notId, String message){ ArrayList<String> messageList = messageMap.get(notId); if(messageList == null) { messageList = new ArrayList<String>(); messageMap.put(notId, messageList); } if(message.isEmpty()){ messageList.clear(); }else{ messageList.add(message); Loading Loading @@ -109,9 +116,11 @@ public class GCMIntentService extends GCMBaseIntentService { String packageName = context.getPackageName(); Resources resources = context.getResources(); int notId = parseInt("notId", extras); Intent notificationIntent = new Intent(this, PushHandlerActivity.class); notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); notificationIntent.putExtra("pushBundle", extras); notificationIntent.putExtra("notId", notId); int requestCode = new Random().nextInt(); PendingIntent contentIntent = PendingIntent.getActivity(this, requestCode, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); Loading Loading @@ -197,7 +206,7 @@ public class GCMIntentService extends GCMBaseIntentService { /* * Notification message */ setNotificationMessage(extras, mBuilder); setNotificationMessage(notId, extras, mBuilder); /* * Notification count Loading @@ -209,8 +218,6 @@ public class GCMIntentService extends GCMBaseIntentService { */ createActions(extras, mBuilder, resources, packageName); int notId = parseInt("notId", extras); mNotificationManager.notify((String) appName, notId, mBuilder.build()); } Loading Loading @@ -266,15 +273,16 @@ public class GCMIntentService extends GCMBaseIntentService { } } private void setNotificationMessage(Bundle extras, NotificationCompat.Builder mBuilder) { private void setNotificationMessage(int notId, Bundle extras, NotificationCompat.Builder mBuilder) { String message = getMessageText(extras); String style = getString(extras, "style", STYLE_TEXT); if(STYLE_INBOX.equals(style)) { setNotification(message); setNotification(notId, message); mBuilder.setContentText(message); ArrayList<String> messageList = messageMap.get(notId); Integer sizeList = messageList.size(); if (sizeList > 1) { String sizeListMessage = sizeList.toString(); Loading @@ -294,7 +302,7 @@ public class GCMIntentService extends GCMBaseIntentService { mBuilder.setStyle(notificationInbox); } } else if (STYLE_PICTURE.equals(style)) { setNotification(""); setNotification(notId, ""); NotificationCompat.BigPictureStyle bigPicture = new NotificationCompat.BigPictureStyle(); bigPicture.bigPicture(getBitmapFromURL(getString(extras, "picture"))); Loading @@ -306,7 +314,7 @@ public class GCMIntentService extends GCMBaseIntentService { mBuilder.setStyle(bigPicture); } else { setNotification(""); setNotification(notId, ""); NotificationCompat.BigTextStyle bigText = new NotificationCompat.BigTextStyle(); Loading
src/android/com/adobe/phonegap/push/PushHandlerActivity.java +1 −1 Changes for src/android/com/adobe/phonegap/push/PushHandlerActivity.java: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ public class PushHandlerActivity extends Activity @Override public void onCreate(Bundle savedInstanceState) { GCMIntentService gcm = new GCMIntentService(); gcm.setNotification(""); gcm.setNotification(getIntent().getIntExtra("notId", 0), ""); super.onCreate(savedInstanceState); Log.v(LOG_TAG, "onCreate"); Loading