package org.adaptlab.chpir.android.survey.QuestionFragments;

import org.adaptlab.chpir.android.survey.CameraFragment;
import org.adaptlab.chpir.android.survey.R;

import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;

public class FrontPictureQuestionFragment extends PictureQuestionFragment {
	private static final String TAG = "FrontPictureQuestionFragment";
	private Button mCameraButton;
    @Override
    protected void createQuestionComponent(ViewGroup questionComponent) {

		if (isCameraAvailable()) {
			mCameraButton = new Button(getActivity());
			mCameraButton.setText(R.string.enable_camera);
			LinearLayout.LayoutParams buttonLayout = new LinearLayout.LayoutParams(500, 120);
			buttonLayout.gravity = Gravity.CENTER;
			mCameraButton.setLayoutParams(buttonLayout);
			mCameraButton.setOnClickListener(new View.OnClickListener() {
				public void onClick(View v) {
					FragmentManager fm = getActivity().getSupportFragmentManager();
					FragmentTransaction transaction = fm.beginTransaction();
					mCameraFragment = CameraFragment.newCameraFragmentInstance(getResponsePhoto(), FRONT_CAMERA);
					transaction.replace(R.id.fragmentContainer, mCameraFragment);
					transaction.addToBackStack(null);
					transaction.commit();
				}
			});
			mPhotoView = new ImageView(getActivity());
			showPhoto();
			questionComponent.addView(mCameraButton);
			questionComponent.addView(mPhotoView);
		} else {
			Log.i(TAG, "Camera Not Available");
		}
    }

}

@@ -366,16 +366,60 @@
 wGroup;%0A
+import android.view.ViewGroup.LayoutParams;%0A
 import a
@@ -688,16 +688,18 @@
 on;%0A    
+%0A%09
 @Overrid
@@ -1596,16 +1596,223 @@
 ity());%0A
+%09%09%09LinearLayout.LayoutParams photoLayout = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);%0A%09%09%09photoLayout.topMargin = 300;%0A%09%09%09mPhotoView.setLayoutParams(photoLayout);%09%09%09%0A
 %09%09%09showP

add top marging to ImageView on FrontPictureQuestionFragment