<commit_before>package com.mobilesns.notificationtest;

import java.io.Console;
import java.util.Calendar;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.unity3d.player.*;
import android.app.Activity;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

public class UnityPlayerActivity extends Activity
{
	protected UnityPlayer mUnityPlayer; // don't change the name of this variable; referenced from native code
	// added by cpeng
	private static Context mContext = null;
	private static final int INTERVAL		= 1000 * 60 * 60 * 24;// 24h
	private static final int REQUEST_CODE	= 10001;
	public static String PushAction = "AlarmAction";
	// added end
	
	// Setup activity layout
	@Override protected void onCreate (Bundle savedInstanceState)
	{
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		super.onCreate(savedInstanceState);

		getWindow().setFormat(PixelFormat.RGBX_8888); // <--- This makes xperia play happy

		mUnityPlayer = new UnityPlayer(this);
		setContentView(mUnityPlayer);
		mUnityPlayer.requestFocus();
		mContext = this;
		
		//AlarmNotificationReceiver.sendNotify(0, "cpeng hardcode test", this);
	}
	public void SetupNotificationMessage1(String message, int hour, int minute, int second, int repeatMode)
	{
	}
	// repeatMode, 0: none, 1: everyday, 2: week
	public void SetupNotificationMessage(String message, int hour, int minute, int second, int repeatMode)
    {
		Log.v("cpeng > ", "SetupNoficationMessage");
		if (repeatMode == 0) {
		}
		else if (repeatMode ==1) {
			Log.v("cpeng > ", "SetupNoficationMessage > repeatMode: 1");
			Intent intent = new Intent(getApplicationContext(), AlarmNotificationReceiver.class);
			intent.setAction(PushAction);
			intent.putExtra("id", 0);
			intent.putExtra("msg", message);
			PendingIntent sender = PendingIntent.getBroadcast(getApplicationContext(),
					REQUEST_CODE, intent, PendingIntent.FLAG_CANCEL_CURRENT);

			// Schedule the alarm!
			AlarmManager am = (AlarmManager) getApplicationContext()
				.getSystemService(Context.ALARM_SERVICE);

			Calendar calendar = Calendar.getInstance();
			calendar.set(Calendar.HOUR_OF_DAY, hour);
			calendar.set(Calendar.MINUTE, minute);
			calendar.set(Calendar.SECOND, second);
			calendar.set(Calendar.MILLISECOND, 0);

			am.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),
					INTERVAL, sender);
		}
		else if (repeatMode ==2) {
		}
    }
	
	public void CancelNotification(int index) {
		Intent intent = new Intent(getApplicationContext(), AlarmNotificationReceiver.class);
        PendingIntent sender = PendingIntent.getBroadcast(getApplicationContext(), 0, intent, 0);
<commit_msg>support weekly repeat mode. not tested yet.<commit_after>package com.mobilesns.notificationtest;

import java.io.Console;
import java.util.Calendar;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.unity3d.player.*;
import android.app.Activity;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

public class UnityPlayerActivity extends Activity
{
	protected UnityPlayer mUnityPlayer; // don't change the name of this variable; referenced from native code
	// added by cpeng
	private static Context mContext = null;
	private static final int INTERVAL_DAILY		= 1000 * 60 * 60 * 24;// 24h
	private static final int INTERVAL_WEEKLY	= 1000 * 60 * 60 * 24 * 7; // a week 
	private static final int INTERVAL			= 1000 * 30;// 30 seconds
	private static final int REQUEST_CODE		= 10001;
	public static String PushAction = "AlarmAction";
	// added end
	
	// Setup activity layout
	@Override protected void onCreate (Bundle savedInstanceState)
	{
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		super.onCreate(savedInstanceState);

		getWindow().setFormat(PixelFormat.RGBX_8888); // <--- This makes xperia play happy

		mUnityPlayer = new UnityPlayer(this);
		setContentView(mUnityPlayer);
		mUnityPlayer.requestFocus();
		mContext = this;
	}
	
	// repeatMode, 0: none, 1: everyday, 2: week
	public void SetupNotificationMessage(String message, int hour, int minute, int second, int repeatMode, int id)
    {
		Log.v("cpeng > ", "SetupNoficationMessage");
		if (repeatMode == 0) {
			Log.v("cpeng > ", "SetupNoficationMessage > do not support non-repeat mode yet");
			return;
		}
		
		int interval = INTERVAL_DAILY;
		if (repeatMode == 1) {
			interval = INTERVAL_DAILY;
		}
		else if (repeatMode == 2) {
			interval = INTERVAL_WEEKLY;
		}
		
		Log.v("cpeng > ", "SetupNoficationMessage > repeatMode: 1");
		Intent intent = new Intent(getApplicationContext(), AlarmNotificationReceiver.class);
		intent.setAction(PushAction);
		intent.putExtra("id", id);
		intent.putExtra("msg", message);
		PendingIntent sender = PendingIntent.getBroadcast(getApplicationContext(),
				REQUEST_CODE, intent, PendingIntent.FLAG_CANCEL_CURRENT);

		// Schedule the alarm!
		AlarmManager am = (AlarmManager) getApplicationContext()
			.getSystemService(Context.ALARM_SERVICE);

		Calendar calendar = Calendar.getInstance();
		calendar.set(Calendar.HOUR_OF_DAY, hour);
		calendar.set(Calendar.MINUTE, minute);
		calendar.set(Calendar.SECOND, second);
		calendar.set(Calendar.MILLISECOND, 0);

		am.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),
				interval, sender);
    }
	
	public void CancelNotification(int id) {
		Intent intent = new Intent(getApplicationContext(), AlarmNotificationReceiver.class);
        PendingIntent sender = PendingIntent.getBroadcast(getApplicationContext(), id, intent, 0);

{'fraction_non_alphanumeric': 0.10479285134037368, 'fraction_numerical': 0.01380991064175467, 'mean_word_length': 4.976699029126213, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '5010050', 'n_tokens_mistral': 2042, 'n_tokens_neox': 1800, 'n_words': 465}