<commit_before>/**
 * benCoding.AlarmManager Project
 * Copyright (c) 2009-2012 by <NAME>. All Rights Reserved.
 * Licensed under the terms of the Apache Public License
 * Please see the LICENSE included with this distribution for details.
 */
package bencoding.alarmmanager;

import java.util.Calendar;
import java.util.GregorianCalendar;
import java.text.SimpleDateFormat;
import java.util.HashMap;

import org.appcelerator.kroll.KrollDict;
import org.appcelerator.kroll.KrollProxy;
import org.appcelerator.kroll.annotations.Kroll;
import org.appcelerator.titanium.TiApplication;
import org.appcelerator.titanium.TiC;
import org.appcelerator.titanium.util.TiConvert;
import org.appcelerator.titanium.util.TiUIHelper;

import android.app.AlarmManager;
import android.app.NotificationManager;
import android.app.PendingIntent;

import android.content.Intent;
import android.net.Uri;

@Kroll.proxy(creatableInModule=AlarmmanagerModule.class)
public class AlarmManagerProxy extends KrollProxy {
	NotificationManager mNotificationManager;
	public static String rootActivityClassName = "";

	public AlarmManagerProxy() {
		super();
	}

	private Calendar getSecondBasedCalendar(KrollDict args){
		int interval = args.getInt("second");
		Calendar cal = Calendar.getInstance();
		cal.add(Calendar.SECOND, interval);
		return cal;
	}

	private Calendar getMinuteBasedCalendar(KrollDict args){
		int interval = args.getInt("minute");
		Calendar cal = Calendar.getInstance();
		cal.add(Calendar.MINUTE, interval);
		return cal;
	}

	private Calendar getFullCalendar(KrollDict args){
		Calendar defaultDay = Calendar.getInstance();
		int day = args.optInt("day", defaultDay.get(Calendar.DAY_OF_MONTH));
		int month = args.optInt("month", defaultDay.get(Calendar.MONTH));
		int year = args.optInt("year", defaultDay.get(Calendar.YEAR));
		int hour = args.optInt("hour", defaultDay.get(Calendar.HOUR_OF_DAY));
		int minute = args.optInt("minute", defaultDay.get(Calendar.MINUTE));
		int second = args.optInt("second", defaultDay.get(Calendar.SECOND));
		Calendar cal =  new GregorianCalendar(year, month, day);
		cal.add(Calendar.HOUR_OF_DAY, hour);
		cal.add(Calendar.MINUTE, minute);
		cal.add(Calendar.SECOND, second);
		return cal;
	}

	private Intent createAlarmNotifyIntent(KrollDict args,int requestCode){
		int notificationIcon = 0;
		String contentTitle = "";
		String contentText = "";
		String notificationSound = "";
		boolean playSound = optionIsEnabled(args,"playSound");
		boolean doVibrate = optionIsEnabled(args,"vibrate");
		boolean showLights = optionIsEnabled(args,"showLights");
		if (args.containsKeyAndNotNull(TiC.PROPERTY_CONTENT_TITLE)
				|| args.containsKeyAndNotNull(TiC.PROPERTY_CONTENT_TEXT))
			{
				if (args.containsKeyAndNotNull(TiC.PROPERTY_CONTENT_TITLE)) {
					contentTitle = TiConvert.toString(args, TiC.PROPERTY_CONTENT_TITLE);
				}
				if (args.containsKeyAndNotNull(TiC.PROPERTY_CONTENT_TEXT)) {
					contentText = TiConvert.toString(args, TiC.PROPERTY_CONTENT_TEXT);
				};
			}

		if (args.containsKey(TiC.PROPERTY_ICON)) {
			Object icon = args.get(TiC.PROPERTY_ICON);
			if (icon instanceof Number) {
				notificationIcon = ((Number)icon).intValue();
			} else {
				String iconUrl = TiConvert.toString(icon);
				String iconFullUrl = resolveUrl(null, iconUrl);
				notificationIcon = TiUIHelper.getResourceId(iconFullUrl);
				if (notificationIcon == 0) {
					utils.debugLog("No image found for " + iconUrl);
					utils.debugLog("Default icon will be used");
				}
			}
		}
		
		if (args.containsKey(TiC.PROPERTY_SOUND)){
			notificationSound = TiConvert.toString(args, TiC.PROPERTY_SOUND);
		}

		Intent intent = new Intent(TiApplication.getInstance().getApplicationContext(), AlarmNotificationListener.class);<commit_msg>AlarmManagerProxy: fixed sound url<commit_after>/**
 * benCoding.AlarmManager Project
 * Copyright (c) 2009-2012 by <NAME>. All Rights Reserved.
 * Licensed under the terms of the Apache Public License
 * Please see the LICENSE included with this distribution for details.
 */
package bencoding.alarmmanager;

import java.util.Calendar;
import java.util.GregorianCalendar;
import java.text.SimpleDateFormat;
import java.util.HashMap;

import org.appcelerator.kroll.KrollDict;
import org.appcelerator.kroll.KrollProxy;
import org.appcelerator.kroll.annotations.Kroll;
import org.appcelerator.titanium.TiApplication;
import org.appcelerator.titanium.TiC;
import org.appcelerator.titanium.util.TiConvert;
import org.appcelerator.titanium.util.TiUIHelper;

import android.app.AlarmManager;
import android.app.NotificationManager;
import android.app.PendingIntent;

import android.content.Intent;
import android.net.Uri;

@Kroll.proxy(creatableInModule=AlarmmanagerModule.class)
public class AlarmManagerProxy extends KrollProxy {
	NotificationManager mNotificationManager;
	public static String rootActivityClassName = "";

	public AlarmManagerProxy() {
		super();
	}

	private Calendar getSecondBasedCalendar(KrollDict args){
		int interval = args.getInt("second");
		Calendar cal = Calendar.getInstance();
		cal.add(Calendar.SECOND, interval);
		return cal;
	}

	private Calendar getMinuteBasedCalendar(KrollDict args){
		int interval = args.getInt("minute");
		Calendar cal = Calendar.getInstance();
		cal.add(Calendar.MINUTE, interval);
		return cal;
	}

	private Calendar getFullCalendar(KrollDict args){
		Calendar defaultDay = Calendar.getInstance();
		int day = args.optInt("day", defaultDay.get(Calendar.DAY_OF_MONTH));
		int month = args.optInt("month", defaultDay.get(Calendar.MONTH));
		int year = args.optInt("year", defaultDay.get(Calendar.YEAR));
		int hour = args.optInt("hour", defaultDay.get(Calendar.HOUR_OF_DAY));
		int minute = args.optInt("minute", defaultDay.get(Calendar.MINUTE));
		int second = args.optInt("second", defaultDay.get(Calendar.SECOND));
		Calendar cal =  new GregorianCalendar(year, month, day);
		cal.add(Calendar.HOUR_OF_DAY, hour);
		cal.add(Calendar.MINUTE, minute);
		cal.add(Calendar.SECOND, second);
		return cal;
	}

	private Intent createAlarmNotifyIntent(KrollDict args,int requestCode){
		int notificationIcon = 0;
		String contentTitle = "";
		String contentText = "";
		String notificationSound = "";
		boolean playSound = optionIsEnabled(args,"playSound");
		boolean doVibrate = optionIsEnabled(args,"vibrate");
		boolean showLights = optionIsEnabled(args,"showLights");
		if (args.containsKeyAndNotNull(TiC.PROPERTY_CONTENT_TITLE)
				|| args.containsKeyAndNotNull(TiC.PROPERTY_CONTENT_TEXT))
			{
				if (args.containsKeyAndNotNull(TiC.PROPERTY_CONTENT_TITLE)) {
					contentTitle = TiConvert.toString(args, TiC.PROPERTY_CONTENT_TITLE);
				}
				if (args.containsKeyAndNotNull(TiC.PROPERTY_CONTENT_TEXT)) {
					contentText = TiConvert.toString(args, TiC.PROPERTY_CONTENT_TEXT);
				};
			}

		if (args.containsKey(TiC.PROPERTY_ICON)) {
			Object icon = args.get(TiC.PROPERTY_ICON);
			if (icon instanceof Number) {
				notificationIcon = ((Number)icon).intValue();
			} else {
				String iconUrl = TiConvert.toString(icon);
				String iconFullUrl = resolveUrl(null, iconUrl);
				notificationIcon = TiUIHelper.getResourceId(iconFullUrl);
				if (notificationIcon == 0) {
					utils.debugLog("No image found for " + iconUrl);
					utils.debugLog("Default icon will be used");
				}
			}
		}
		
		if (args.containsKey(TiC.PROPERTY_SOUND)){
		    notificationSound = resolveUrl(null, TiConvert.toString(args, TiC.PROPERTY_SOUND));
		}

		Intent intent = new Intent(TiApplication.getInstance().getApplicationContext(), AlarmNotificationListener.class);
{'fraction_non_alphanumeric': 0.11322751322751323, 'fraction_numerical': 0.0026455026455026454, 'mean_word_length': 5.343120805369128, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3827132', 'n_tokens_mistral': 2577, 'n_tokens_neox': 2330, 'n_words': 467}