<commit_before>package com.example.schwusch.iotap_app;

import android.app.Activity;
import android.content.Context;
import android.os.Vibrator;
import android.util.Log;

import java.io.ObjectInputStream;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.List;

import weka.classifiers.Classifier;

class GestureDetector {
    private ArrayList<LinkedList<Integer>> movingWindow = new ArrayList<>();
    private ArrayList<LinkedList<Integer>> filteredMovingWindow = new ArrayList<>();
    private Classifier cls;
    private Activity mainActivity;
    private boolean record = false;
    private int recordCounter = 0;

    GestureDetector(Activity mainActivity) throws Exception {
        initMovingWindows();
        this.mainActivity = mainActivity;
    }

    void addSample(String sample) {
        Integer[] values = parseStringSample(sample);
        if (values != null) {
            // If window is full, dequeue one sample from head before queuing another
            if (movingWindow.get(0).size() > Constants.MOVING_WINDOW_SIZE - 1) {
                for (int i = 0; i < movingWindow.size(); i++) {
                    movingWindow.get(i).poll();
                    filteredMovingWindow.get(i).poll();
                }
            }

            // Save sample to moving window tail
            for (int i = 0; i < Constants.SENSOR_VALUES; i++) {
                movingWindow.get(i).add(values[i]);
                filteredMovingWindow.get(i).add(
                        filterFIR(movingWindow.get(i))
                );
            }
            if (!record && isThresholdExceeded()) {
                record = true;
                Vibrator v = (Vibrator) mainActivity.getSystemService(Context.VIBRATOR_SERVICE);
                v.vibrate(100);
            }

            if (record && recordCounter < Constants.MOVING_WINDOW_SIZE + 1) {
                recordCounter++;
            } else if(record) {
                record = false;
                recordCounter = 0;
            }
        }
    }

    private boolean isThresholdExceeded() {
        boolean exceeded = false;
        if(filteredMovingWindow.get(0).size() > 2) {<commit_msg>Little bit more notifications<commit_after>package com.example.schwusch.iotap_app;

import android.app.Activity;
import android.content.Context;
import android.os.Vibrator;
import android.util.Log;

import java.io.ObjectInputStream;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.List;

import weka.classifiers.Classifier;

class GestureDetector {
    private ArrayList<LinkedList<Integer>> movingWindow = new ArrayList<>();
    private ArrayList<LinkedList<Integer>> filteredMovingWindow = new ArrayList<>();
    private Classifier cls;
    private MainActivity mainActivity;
    private boolean record = false;
    private int recordCounter = 0;

    GestureDetector(MainActivity mainActivity) throws Exception {
        initMovingWindows();
        this.mainActivity = mainActivity;
    }

    void addSample(String sample) {
        Integer[] values = parseStringSample(sample);
        if (values != null) {
            // If window is full, dequeue one sample from head before queuing another
            if (movingWindow.get(0).size() > Constants.MOVING_WINDOW_SIZE - 1) {
                for (int i = 0; i < movingWindow.size(); i++) {
                    movingWindow.get(i).poll();
                    filteredMovingWindow.get(i).poll();
                }
            }

            // Save sample to moving window tail
            for (int i = 0; i < Constants.SENSOR_VALUES; i++) {
                movingWindow.get(i).add(values[i]);
                filteredMovingWindow.get(i).add(
                        filterFIR(movingWindow.get(i))
                );
            }
            if (!record && isThresholdExceeded()) {
                record = true;
                Vibrator v = (Vibrator) mainActivity.getSystemService(Context.VIBRATOR_SERVICE);
                v.vibrate(100);
                mainActivity.runOnUiThread(() -> mainActivity.snack("Gesture Detected!"));
            }

            if (record && recordCounter < Constants.MOVING_WINDOW_SIZE + 1) {
                recordCounter++;
            } else if(record) {
                record = false;
                recordCounter = 0;
            }
        }
    }

    private boolean isThresholdExceeded() {
        boolean exceeded = false;
        if(filteredMovingWindow.get(0).size() > 2) {
{'fraction_non_alphanumeric': 0.10216372964532679, 'fraction_numerical': 0.005353557885344635, 'mean_word_length': 2.1117279666897986, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 20, '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': '3634232', 'n_tokens_mistral': 1247, 'n_tokens_neox': 1166, 'n_words': 272}