<commit_before>package org.matrix.matrixandroidsdk.gcm;

import android.app.IntentService;
import android.app.Notification;
import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import com.google.android.gms.gcm.GoogleCloudMessaging;

import org.matrix.matrixandroidsdk.ViewedRoomTracker;
import org.matrix.matrixandroidsdk.util.NotificationUtils;

/**
 * Service that receives messages from GCM.
 */
public class GcmIntentService extends IntentService {

    private static final String LOG_TAG = "GcmIntentService";
    private static final int MSG_NOTIFICATION_ID = 43;

    public GcmIntentService() {
        super("GcmIntentService");
    }

    @Override
    protected void onHandleIntent(Intent intent) {
        Bundle extras = intent.getExtras();
        GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
        String messageType = gcm.getMessageType(intent);

        if (messageType.equals(GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE)) {
            handlePushNotification(extras);
        }

        GcmBroadcastReceiver.completeWakefulIntent(intent);
    }

    private void handlePushNotification(Bundle bundle) {
        final String roomId = bundle.getString("room_id");

        // Just don't bing for the room the user's currently in
        if ((roomId != null) && roomId.equals(ViewedRoomTracker.getInstance().getViewedRoomId())) {
            return;
        }

        String from = bundle.getString("sender");

        final String body = bundle.getString("body");
        // FIXME: Support event contents with no body
        if (body == null) {
            return;
        }

        Notification n = NotificationUtils.buildMessageNotification(this, from, body, roomId, true);
        NotificationManager nm =(NotificationManager) GcmIntentService.this
                .getSystemService(Context.NOTIFICATION_SERVICE);
        nm.notify(MSG_NOTIFICATION_ID, n);
    }
}
<commit_msg>Room name will be picked up if passed to GcmIntentService.<commit_after>package org.matrix.matrixandroidsdk.gcm;

import android.app.IntentService;
import android.app.Notification;
import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import com.google.android.gms.gcm.GoogleCloudMessaging;

import org.matrix.matrixandroidsdk.ViewedRoomTracker;
import org.matrix.matrixandroidsdk.util.NotificationUtils;

/**
 * Service that receives messages from GCM.
 */
public class GcmIntentService extends IntentService {

    private static final String LOG_TAG = "GcmIntentService";
    private static final int MSG_NOTIFICATION_ID = 43;

    public GcmIntentService() {
        super("GcmIntentService");
    }

    @Override
    protected void onHandleIntent(Intent intent) {
        Bundle extras = intent.getExtras();
        GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
        String messageType = gcm.getMessageType(intent);

        if (messageType.equals(GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE)) {
            handlePushNotification(extras);
        }

        GcmBroadcastReceiver.completeWakefulIntent(intent);
    }

    private void handlePushNotification(Bundle bundle) {
        final String roomId = bundle.getString("room_id");
        final String roomName = bundle.getString("room_name");

        // Just don't bing for the room the user's currently in
        if ((roomId != null) && roomId.equals(ViewedRoomTracker.getInstance().getViewedRoomId())) {
            return;
        }

        String from = bundle.getString("sender");

        final String body = bundle.getString("body");
        // FIXME: Support event contents with no body
        if (body == null) {
            return;
        }

        Notification n = NotificationUtils.buildMessageNotification(this, from, body, roomId, roomName, true);
        NotificationManager nm =(NotificationManager) GcmIntentService.this
                .getSystemService(Context.NOTIFICATION_SERVICE);
        nm.notify(MSG_NOTIFICATION_ID, n);
    }
}

{'fraction_non_alphanumeric': 0.09009227780475959, 'fraction_numerical': 0.0009713453132588635, 'mean_word_length': 3.3819148936170214, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1220346', 'n_tokens_mistral': 1125, 'n_tokens_neox': 1078, 'n_words': 252}