package de.fu_berlin.cdv.chasingpictures;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;


public class Camera extends Activity {

    ImageView iv;

    private static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100;
    private Uri fileUri;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_camera);

        iv = (ImageView) findViewById(R.id.imageView);

        Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
        startActivityForResult(intent, 100);

    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        // TODO Auto-generated method stub
        //super.onActivityResult(requestCode, resultCode, data);

        Intent intent = new Intent(this, MainActivity.class);

        if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) {
            if (resultCode == RESULT_OK) {
                // Image captured and saved to fileUri specified in the Intent
                Toast.makeText(this, "Image saved to:\n" + data.getData(), Toast.LENGTH_LONG).show();
                Bitmap bp = (Bitmap) data.getExtras().get("data");
                iv.setImageBitmap(bp);
            } else if (resultCode == RESULT_CANCELED) {
                // User cancelled the image capture

                startActivity(intent);
            } else {
                // Image capture failed, advise user
                startActivity(intent);
            }
        }

    }

    public void showNextActivity(View view){
        Intent intent = new Intent(this, MainActivity.class);
        startActivity(intent);
    }



}

@@ -132,32 +132,8 @@
 ap;%0A
-import android.net.Uri;%0A
 impo
@@ -378,33 +378,8 @@
 100;
-%0A    private Uri fileUri;
 %0A%0A  
@@ -723,19 +723,51 @@
 intent, 
-100
+CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE
 );%0A%0A    
@@ -870,116 +870,8 @@
 a) %7B
-%0A        // TODO Auto-generated method stub%0A        //super.onActivityResult(requestCode, resultCode, data);
 %0A%0A  

clear the camera activity