package es.softwareprocess.bogopicgen;
/*
 * Copyright 2012  Bryan Liles <iam@smartic.us> and Abram Hindle <abram.hindle@softwareprocess.es> . All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:

   1. Redistributions of source code must retain the above copyright notice, this list of
      conditions and the following disclaimer.

   2. Redistributions in binary form must reproduce the above copyright notice, this list
      of conditions and the following disclaimer in the documentation and/or other materials
      provided with the distribution.

THIS SOFTWARE IS PROVIDED BY Bryan Liles <iam@smartic.us> and Abram Hindle <abram.hindle@softwareprocess.es> ''AS IS'' AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those of the
authors and should not be interpreted as representing official policies, either expressed
or implied, of Bryan Liles <iam@smartic.us> and Abram Hindle <abram.hindle@softwareprocess.es>.

 * 
 */

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

import es.softwareprocess.bogopicgen.*;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;

import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.Toast;
import android.view.View.OnClickListener;
public class BogoPicGenActivity extends Activity {

	Uri imageFileUri;
	private Bitmap newBMP;
	int numberOfAttempts = 1;
	/** Called when the activity is first created. */
	//----------------------------------------------------------------------------------------------------
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		setBogoPic();
		ImageButton button = (ImageButton)findViewById(R.id.TakeAPhoto);

		button.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				//takeAPhoto();
				setBogoPic();
				numberOfAttempts++;
			}
		}); 
		Button acceptButton = (Button)findViewById(R.id.Accept);
		acceptButton.setOnClickListener( new OnClickListener() {
			public void onClick(View v) {
				processIntent(true);
			}        	
		});
		Button cancelButton = (Button)findViewById(R.id.Cancel);
		cancelButton.setOnClickListener( new OnClickListener() {
			public void onClick(View v) {
				processIntent(false);
			}        	
		});
		//takeAPhoto();
	}
	//----------------------------------------------------------------------------------------------------
	private void setBogoPic() {
		//TODO: Add your code here...
		//TODO: Add your code here...
		//TODO: Add your code here...
		//TODO: Add your code here...
	}
	//----------------------------------------------------------------------------------------------------
	//----------------------------------------------------------------------------------------------------
	// call this to accept
	private void processIntent(boolean okPressed) {
		Intent intent = getIntent();
		if (intent != null) {
			try {
				if (intent.getExtras() != null) {    
					if (okPressed) {
						//TODO: Add your code here...
						//TODO: Add your code here...
						//TODO: Add your code here...
						//TODO: Add your code here...
						//TODO: Add your code here...
						//TODO: Add your code here...
						//setResult(RESULT_OK);
					}//if (okPressed).
					else{//cancel is pressed:
						Toast.makeText(this, "Photo Cancelled!", Toast.LENGTH_LONG).show();
						setResult(RESULT_CANCELED);
						finish();
					}
				} else {
					Toast.makeText(this, "Photo Cancelled: No Reciever?", Toast.LENGTH_LONG).show();
					setResult(RESULT_CANCELED);
				}
			} catch (FileNotFoundException e) {
				Toast.makeText(this, "Couldn't Find File to Write to?", Toast.LENGTH_LONG).show();
				setResult(RESULT_CANCELED);    	
			} catch (IOException e) {
				Toast.makeText(this, "Couldn't Write File!", Toast.LENGTH_LONG).show();
				setResult(RESULT_CANCELED);
			}
		}//if (intent != null).
		finish();
	}	
	//----------------------------------------------------------------------------------------------------
	//----------------------------------------------------------------------------------------------------
}
@@ -3446,16 +3446,183 @@
 -------%0A
+%09//This method generates a random igame by calling BogoPicGen.generateBitmap():%0A%09//The result should be saved in newBMP%0A%09//Also should be reflected in the imageButton%0A
 %09private
@@ -4004,16 +4004,132 @@
 o accept
+ the generated photo or cancel it. %0A%09//If it is accepted, the result is set to RESULT_OK, otherwise RESULT_CANCELED.
 %0A%09privat
@@ -5424,8 +5424,9 @@
 ------%0A%7D
+%0A

Update BogoPicGenActivity.java