Commit 358364eb authored by Simon MacDonald's avatar Simon MacDonald
Browse files

Merge branch 'master' of https://github.com/GreyDekart/phonegap-plugin-push into GreyDekart-master

Conflicts:
	src/android/com/adobe/phonegap/push/GCMIntentService.java
parents ff236ff5 dec88881
Loading
Loading
Loading
Loading
+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
@@ -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 {
@@ -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);
@@ -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);
@@ -197,7 +206,7 @@ public class GCMIntentService extends GCMBaseIntentService {
        /*
         * Notification message
         */
        setNotificationMessage(extras, mBuilder);
        setNotificationMessage(notId, extras, mBuilder);

        /*
         * Notification count
@@ -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());
    }

@@ -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();
@@ -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")));
@@ -306,7 +314,7 @@ public class GCMIntentService extends GCMBaseIntentService {

            mBuilder.setStyle(bigPicture);
        } else {
            setNotification("");
            setNotification(notId, "");

            NotificationCompat.BigTextStyle bigText = new NotificationCompat.BigTextStyle();

+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
@@ -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");