<commit_before>package com.martin.kiss;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.DateFormat;
import java.util.Date;

import android.app.AlarmManager;
import android.app.IntentService;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.TaskStackBuilder;
import android.text.format.DateUtils;
import android.text.format.Time;

import com.martin.kantidroid.Check;
import com.martin.kantidroid.MOTD;
import com.martin.kantidroid.R;
import com.martin.kantidroid.WidgetProvider;

public class Background extends IntentService {

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

	@Override
	protected void onHandleIntent(Intent intent) {
		if (isNetworkAvailable()) {
			String result = "";
			String motd = "";
			try {
				URL url = new URL("https://kpf.bks-campus.ch/infoscreen");
				URL urlmotd = new URL("http://androiddev.bplaced.net/motd.txt");

				// KISS
				HttpURLConnection con = (HttpURLConnection) url
						.openConnection();
				InputStream in = con.getInputStream();
				BufferedReader reader = null;
				reader = new BufferedReader(new InputStreamReader(in));
				String line = "";
				while ((line = reader.readLine()) != null) {
					result += line;
				}

				// MOTD
				con = (HttpURLConnection) urlmotd.openConnection();
				in = con.getInputStream();
				reader = null;
				reader = new BufferedReader(new InputStreamReader(in));
				line = "";
				while ((line = reader.readLine()) != null) {
					motd += line;
				}
				if (reader != null) {
					reader.close();
				}
			} catch (final Exception e) {
				e.printStackTrace();
			}
			if (!result.contentEquals("")) {
				SharedPreferences spKISS = getApplicationContext()
						.getSharedPreferences("KISS",
								getApplicationContext().MODE_PRIVATE);
				SharedPreferences.Editor editor = spKISS.edit();
				editor.putString("KISS", result);
				editor.putString("last_refresh", DateFormat
						.getDateTimeInstance().format(new Date()));
				editor.commit();
				checkLehrer();
			}
			if (!motd.contentEquals("")) {
				checkMOTD(motd);
			}
		}
		ScheduleNextUpdate();
	}

	private void checkMOTD(String motd) {
		String[] lines = motd.split("/");
		SharedPreferences spKISS = getApplicationContext()
				.getSharedPreferences("KISS", this.MODE_PRIVATE);
		Check check = new Check();
		if (!check.getSeen(lines[0], this)) {
			int idCounter = spKISS.getInt("idCounter", 0);
			NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(<commit_msg>Fixed motd html bug<commit_after>package com.martin.kiss;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.DateFormat;
import java.util.Date;

import android.app.AlarmManager;
import android.app.IntentService;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.TaskStackBuilder;
import android.text.format.DateUtils;
import android.text.format.Time;

import com.martin.kantidroid.Check;
import com.martin.kantidroid.MOTD;
import com.martin.kantidroid.R;
import com.martin.kantidroid.WidgetProvider;

public class Background extends IntentService {

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

	@Override
	protected void onHandleIntent(Intent intent) {
		if (isNetworkAvailable()) {
			String result = "";
			String motd = "";
			try {
				URL url = new URL("https://kpf.bks-campus.ch/infoscreen");
				URL urlmotd = new URL("http://androiddev.bplaced.net/motd.txt");

				// KISS
				HttpURLConnection con = (HttpURLConnection) url
						.openConnection();
				InputStream in = con.getInputStream();
				BufferedReader reader = null;
				reader = new BufferedReader(new InputStreamReader(in));
				String line = "";
				while ((line = reader.readLine()) != null) {
					result += line;
				}

				// MOTD
				con = (HttpURLConnection) urlmotd.openConnection();
				in = con.getInputStream();
				reader = null;
				reader = new BufferedReader(new InputStreamReader(in));
				line = "";
				while ((line = reader.readLine()) != null) {
					motd += line;
				}
				if (reader != null) {
					reader.close();
				}
			} catch (final Exception e) {
				e.printStackTrace();
			}
			if (!result.contentEquals("")) {
				SharedPreferences spKISS = getApplicationContext()
						.getSharedPreferences("KISS",
								getApplicationContext().MODE_PRIVATE);
				SharedPreferences.Editor editor = spKISS.edit();
				editor.putString("KISS", result);
				editor.putString("last_refresh", DateFormat
						.getDateTimeInstance().format(new Date()));
				editor.commit();
				checkLehrer();
			}
			if (!motd.contentEquals("")) {
				checkMOTD(motd);
			}
		}
		ScheduleNextUpdate();
	}

	private void checkMOTD(String motd) {
		String[] lines = motd.split("/");
		SharedPreferences spKISS = getApplicationContext()
				.getSharedPreferences("KISS", this.MODE_PRIVATE);
		Check check = new Check();
		if (!check.getSeen(lines[0], this) && !lines[0].contains("html") && !lines[1].contains("html")) {
			int idCounter = spKISS.getInt("idCounter", 0);
			NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
{'fraction_non_alphanumeric': 0.12924281984334204, 'fraction_numerical': 0.0016318537859007832, 'mean_word_length': 4.229522184300341, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '2746394', 'n_tokens_mistral': 2173, 'n_tokens_neox': 1839, 'n_words': 382}