<commit_before>package com.martin.kantidroid.logic;

import android.app.AlarmManager;
import android.app.IntentService;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.support.v4.app.TaskStackBuilder;
import android.support.v7.app.NotificationCompat;
import android.util.Log;

import com.martin.kantidroid.R;
import com.martin.kantidroid.ui.main.MainActivity;
import com.martin.kantidroid.ui.motd.MOTD;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class Background extends IntentService {

    public Background() {
        super(Background.class.getSimpleName());
    }

    @Override
    protected void onHandleIntent(Intent intent) {
        Log.e("FFF", "Handling intent");
        if (isNetworkAvailable()) {
            Log.e("FFF", "Network available");
            String motd = "";
            try {
                URL urlmotd = new URL(getString(R.string.motd_url));
                InputStream in;
                BufferedReader reader;

                HttpURLConnection conh = (HttpURLConnection) urlmotd.openConnection();
                in = conh.getInputStream();
                reader = new BufferedReader(new InputStreamReader(in));
                String line;
                while ((line = reader.readLine()) != null) {
                    motd += line;
                }
                reader.close();
                if (!motd.contentEquals("")) {
                    checkMOTD(motd);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    private void checkMOTD(String motd) {
        String[] lines = motd.split("/");
        SharedPreferences prefs = getApplicationContext().getSharedPreferences("Kantidroid", Context.MODE_PRIVATE);
        Log.e("FFF", "Line 0: " + lines[0]);
        if (!Util.getSeen(getApplicationContext(), lines[0]) && !lines[0].contains("html") && !lines[1].contains("html")) {
            int idCounter = prefs.getInt("idCounter", 0);
            NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);
            mBuilder.setSmallIcon(R.drawable.ic_comment);
            mBuilder.setContentTitle(lines[0]);
            mBuilder.setContentText(lines[1]);
            mBuilder.setAutoCancel(true);
            long[] pattern = {0, 300, 200, 300};
            mBuilder.setVibrate(pattern);
            mBuilder.setDefaults(Notification.DEFAULT_LIGHTS);
            mBuilder.setDefaults(Notification.DEFAULT_SOUND);

            TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
            stackBuilder.addParentStack(MainActivity.class);
            Intent iMOTD = new Intent(Background.this, MOTD.class);
            Bundle data = new Bundle();
            data.putStringArray("data", lines);
            iMOTD.putExtras(data);
            stackBuilder.addNextIntent(iMOTD);
            PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
            mBuilder.setContentIntent(resultPendingIntent);

            NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
            mNotificationManager.notify(idCounter, mBuilder.build());
            idCounter++;

            // Remember notification id
            SharedPreferences.Editor editor = prefs.edit();
            editor.putInt("idCounter", idCounter);
            editor.commit();
            Util.setSeen(getApplicationContext(), lines[0]);
        }<commit_msg>Replacing linebreaks with spaces for notification<commit_after>package com.martin.kantidroid.logic;

import android.app.AlarmManager;
import android.app.IntentService;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.support.v4.app.TaskStackBuilder;
import android.support.v7.app.NotificationCompat;
import android.util.Log;

import com.martin.kantidroid.R;
import com.martin.kantidroid.ui.main.MainActivity;
import com.martin.kantidroid.ui.motd.MOTD;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class Background extends IntentService {

    public Background() {
        super(Background.class.getSimpleName());
    }

    @Override
    protected void onHandleIntent(Intent intent) {
        Log.e("FFF", "Handling intent");
        if (isNetworkAvailable()) {
            Log.e("FFF", "Network available");
            String motd = "";
            try {
                URL urlmotd = new URL(getString(R.string.motd_url));
                InputStream in;
                BufferedReader reader;

                HttpURLConnection conh = (HttpURLConnection) urlmotd.openConnection();
                in = conh.getInputStream();
                reader = new BufferedReader(new InputStreamReader(in));
                String line;
                while ((line = reader.readLine()) != null) {
                    motd += line;
                }
                reader.close();
                if (!motd.contentEquals("")) {
                    checkMOTD(motd);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    private void checkMOTD(String motd) {
        String[] lines = motd.split("/");
        SharedPreferences prefs = getApplicationContext().getSharedPreferences("Kantidroid", Context.MODE_PRIVATE);
        Log.e("FFF", "Line 0: " + lines[0]);
        if (!Util.getSeen(getApplicationContext(), lines[0]) && !lines[0].contains("html") && !lines[1].contains("html")) {
            int idCounter = prefs.getInt("idCounter", 0);
            NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);
            mBuilder.setSmallIcon(R.drawable.ic_comment);
            mBuilder.setContentTitle(lines[0]);
            mBuilder.setContentText(lines[1].replace("*", " "));
            mBuilder.setAutoCancel(true);
            long[] pattern = {0, 300, 200, 300};
            mBuilder.setVibrate(pattern);
            mBuilder.setDefaults(Notification.DEFAULT_LIGHTS);
            mBuilder.setDefaults(Notification.DEFAULT_SOUND);

            TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
            stackBuilder.addParentStack(MainActivity.class);
            Intent iMOTD = new Intent(Background.this, MOTD.class);
            Bundle data = new Bundle();
            data.putStringArray("data", lines);
            iMOTD.putExtras(data);
            stackBuilder.addNextIntent(iMOTD);
            PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
            mBuilder.setContentIntent(resultPendingIntent);

            NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
            mNotificationManager.notify(idCounter, mBuilder.build());
            idCounter++;

            // Remember notification id
            SharedPreferences.Editor editor = prefs.edit();
            editor.putInt("idCounter", idCounter);
            editor.commit();
            Util.setSeen(getApplicationContext(), lines[0]);
        }
{'fraction_non_alphanumeric': 0.10895484525621511, 'fraction_numerical': 0.005580923389142567, 'mean_word_length': 2.6252873563218393, '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': '3313864', 'n_tokens_mistral': 2145, 'n_tokens_neox': 2056, 'n_words': 379}