<commit_before>package com.ehpefi.iforgotthat;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.hardware.Camera;
import android.hardware.Camera.Parameters;
import android.hardware.Camera.PictureCallback;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.Display;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageButton;
import android.widget.TextView;

/**
 * Handles the camera
 *
 * @author <NAME>
 * @since 1.0
 */
public class CamTest extends Activity implements SurfaceHolder.Callback {
	// UI elements
	private TextView title;
	private ImageButton captureButton;
	private ImageButton flashButton;
	private String listTitle;

	// Camera
	private Camera camera;
	private SurfaceView surfaceView;
	private SurfaceHolder surfaceHolder;
	boolean isPreviewActive = false;
	private PictureCallback mPicture;

	// Helper class
	ListHelper listHelper = new ListHelper(this);
	private int listID;

	// Used for logging
	private static final String TAG = "CAMERA";

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_cam_test);

		// getWindow().setFormat(PixelFormat.UNKNOWN);
		surfaceView = (SurfaceView) findViewById(R.id.camerapreview);
		surfaceHolder = surfaceView.getHolder();
		surfaceHolder.addCallback(this);

		camera = getCameraInstance();

		// Check for incoming data and set list title
		Bundle bundle = getIntent().getExtras();
		if (bundle != null) {
			// Check for list id
			if (bundle.getInt("listID") > 0) {
				listID = bundle.getInt("listID");
				Log.d(TAG, "List id recieved: " + listID);

				ListObject list = listHelper.getList(listID);
				listTitle = list.getTitle();
				Log.d(TAG, "List title resolved: " + listTitle);

				// Get TextView for the list title and set its name
				title = (TextView) findViewById(R.id.listName);
				title.setText(listTitle);
			}
		}

		// Get the UI elements
		captureButton = (ImageButton) findViewById(R.id.button_capture);
		flashButton = (ImageButton) findViewById(R.id.button_flash);

		/**
		 * Callback function to get the capture image
		 * 
		 * @param byte[] data, Camere camera
		 * @since 1.0
		 * 
		 */
		mPicture = new PictureCallback() {
			@Override
			public void onPictureTaken(byte[] data, Camera camera) {

				Log.d(TAG, "Picture taken! Compressing image and passing it on to NewReminderActivity");
				// Compress the data
				data = compressImage(data);

				// Call the NewReminderActivity
				createNewReminder(data);
			}
		};
		
		
		
		/**
		 * Method to take the picture
		 * @param View v
		 * @since 1.0
		 */
		// Handle clicks for the captureButton
		ImageButton captureButton = (ImageButton) findViewById(R.id.button_capture);
		captureButton.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// get an image from the camera
				Log.d(TAG, "Photo in the taking!");
				
				camera.takePicture(null,null, mPicture);
				Log.d(TAG, "Picture captured");
			}
		});

	}

	/**
	 * Fires off the new intent to NewReminderActivity
	 * 
	 * @param image A compressed image as a byte array
	 * @since 1.0<commit_msg>Removed second instantiation of captureButton<commit_after>package com.ehpefi.iforgotthat;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.hardware.Camera;
import android.hardware.Camera.Parameters;
import android.hardware.Camera.PictureCallback;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.Display;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageButton;
import android.widget.TextView;

/**
 * Handles the camera
 *
 * @author <NAME>
 * @since 1.0
 */
public class CamTest extends Activity implements SurfaceHolder.Callback {
	// UI elements
	private TextView title;
	private ImageButton captureButton;
	private ImageButton flashButton;
	private String listTitle;

	// Camera
	private Camera camera;
	private SurfaceView surfaceView;
	private SurfaceHolder surfaceHolder;
	boolean isPreviewActive = false;
	private PictureCallback mPicture;

	// Helper class
	ListHelper listHelper = new ListHelper(this);
	private int listID;

	// Used for logging
	private static final String TAG = "CAMERA";

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_cam_test);

		// getWindow().setFormat(PixelFormat.UNKNOWN);
		surfaceView = (SurfaceView) findViewById(R.id.camerapreview);
		surfaceHolder = surfaceView.getHolder();
		surfaceHolder.addCallback(this);

		camera = getCameraInstance();

		// Check for incoming data and set list title
		Bundle bundle = getIntent().getExtras();
		if (bundle != null) {
			// Check for list id
			if (bundle.getInt("listID") > 0) {
				listID = bundle.getInt("listID");
				Log.d(TAG, "List id recieved: " + listID);

				ListObject list = listHelper.getList(listID);
				listTitle = list.getTitle();
				Log.d(TAG, "List title resolved: " + listTitle);

				// Get TextView for the list title and set its name
				title = (TextView) findViewById(R.id.listName);
				title.setText(listTitle);
			}
		}

		// Get the UI elements
		captureButton = (ImageButton) findViewById(R.id.button_capture);
		flashButton = (ImageButton) findViewById(R.id.button_flash);

		/**
		 * Callback function to get the capture image
		 * 
		 * @param byte[] data, Camere camera
		 * @since 1.0
		 * 
		 */
		mPicture = new PictureCallback() {
			@Override
			public void onPictureTaken(byte[] data, Camera camera) {

				Log.d(TAG, "Picture taken! Compressing image and passing it on to NewReminderActivity");
				// Compress the data
				data = compressImage(data);

				// Call the NewReminderActivity
				createNewReminder(data);
			}
		};
		
		
		
		/**
		 * Method to take the picture
		 * @param View v
		 * @since 1.0
		 */
		// Handle clicks for the captureButton
		captureButton.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// get an image from the camera
				Log.d(TAG, "Photo in the taking!");
				
				camera.takePicture(null,null, mPicture);
				Log.d(TAG, "Picture captured");
			}
		});

	}

	/**
	 * Fires off the new intent to NewReminderActivity
	 * 
	 * @param image A compressed image as a byte array
	 * @since 1.0
{'fraction_non_alphanumeric': 0.10447137484329294, 'fraction_numerical': 0.0025073129962390303, 'mean_word_length': 3.9654218533886585, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '5622919', 'n_tokens_mistral': 2395, 'n_tokens_neox': 2060, 'n_words': 587}