<commit_before>package com.kuxhausen.huemore.timing;

import java.util.ArrayList;
import java.util.Calendar;

import com.google.gson.Gson;
import com.kuxhausen.huemore.R;
import com.kuxhausen.huemore.network.TransmitGroupMood;
import com.kuxhausen.huemore.persistence.DatabaseDefinitions;
import com.kuxhausen.huemore.persistence.DatabaseDefinitions.GroupColumns;
import com.kuxhausen.huemore.persistence.DatabaseDefinitions.MoodColumns;
import com.kuxhausen.huemore.state.BulbState;

import android.app.Activity;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.text.format.DateUtils;
import android.util.Log;
import android.widget.TextView;
import android.widget.Toast;

public class AlarmReciever extends BroadcastReceiver {

	private final static String ALARM_DETAILS = "alarmDetailsBundle";

	public static AlarmState createAlarms(Context context, String group, String mood, int transitiontime, int brightness, Boolean[] repeats, int currentHour, int currentMin){
		Gson gson = new Gson();
		AlarmState as = new AlarmState();
		as.group = group;
		as.mood = mood;
		as.transitiontime = transitiontime;
		as.brightness = brightness;
		as.repeats = repeats;
		as.scheduledForFuture=true;
		
		Calendar projectedTime = Calendar.getInstance();
		projectedTime.setLenient(true);
        projectedTime.set(Calendar.HOUR_OF_DAY, currentHour);
        projectedTime.set(Calendar.MINUTE, currentMin);
        projectedTime.set(Calendar.SECOND, 0);
        
        return createAlarms(context, as, projectedTime);
        
	}
	public static AlarmState createAlarms(Context context, AlarmState as, Calendar timeAdjustedCal){
		boolean none = false;
		for(boolean bool : as.repeats){
			none|=bool;
		}
		none=!none;
		if(none){
			if(timeAdjustedCal.before(Calendar.getInstance())) //make sure this hour & minute is in the future
				timeAdjustedCal.set(Calendar.DATE, timeAdjustedCal.get(Calendar.DATE)+1);<commit_msg>subtracted out transitiontime in alarm start<commit_after>package com.kuxhausen.huemore.timing;

import java.util.ArrayList;
import java.util.Calendar;

import com.google.gson.Gson;
import com.kuxhausen.huemore.R;
import com.kuxhausen.huemore.network.TransmitGroupMood;
import com.kuxhausen.huemore.persistence.DatabaseDefinitions;
import com.kuxhausen.huemore.persistence.DatabaseDefinitions.GroupColumns;
import com.kuxhausen.huemore.persistence.DatabaseDefinitions.MoodColumns;
import com.kuxhausen.huemore.state.BulbState;

import android.app.Activity;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.text.format.DateUtils;
import android.util.Log;
import android.widget.TextView;
import android.widget.Toast;

public class AlarmReciever extends BroadcastReceiver {

	private final static String ALARM_DETAILS = "alarmDetailsBundle";

	public static AlarmState createAlarms(Context context, String group, String mood, int transitiontime, int brightness, Boolean[] repeats, int currentHour, int currentMin){
		Gson gson = new Gson();
		AlarmState as = new AlarmState();
		as.group = group;
		as.mood = mood;
		as.transitiontime = transitiontime;
		as.brightness = brightness;
		as.repeats = repeats;
		as.scheduledForFuture=true;
		
		Calendar projectedTime = Calendar.getInstance();
		projectedTime.setLenient(true);
        projectedTime.set(Calendar.HOUR_OF_DAY, currentHour);
        projectedTime.set(Calendar.MINUTE, currentMin);
        projectedTime.set(Calendar.SECOND, 0);
        //ensure transition starts ahead of time to culminate at the specified time
        projectedTime.add(Calendar.SECOND, -transitiontime/10);
        
        return createAlarms(context, as, projectedTime);
        
	}
	public static AlarmState createAlarms(Context context, AlarmState as, Calendar timeAdjustedCal){
		boolean none = false;
		for(boolean bool : as.repeats){
			none|=bool;
		}
		none=!none;
		if(none){
			if(timeAdjustedCal.before(Calendar.getInstance())) //make sure this hour & minute is in the future
				timeAdjustedCal.set(Calendar.DATE, timeAdjustedCal.get(Calendar.DATE)+1);
{'fraction_non_alphanumeric': 0.09547624460104569, 'fraction_numerical': 0.00136394635144351, 'mean_word_length': 5.145251396648045, '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': '6739695', 'n_tokens_mistral': 1389, 'n_tokens_neox': 1338, 'n_words': 292}