diff --git a/src/android/customCamera/res/layout/activity_camera_view.xml b/src/android/customCamera/res/layout/activity_camera_view.xml
index 4241124..5a41113 100644
--- a/src/android/customCamera/res/layout/activity_camera_view.xml
+++ b/src/android/customCamera/res/layout/activity_camera_view.xml
@@ -9,7 +9,6 @@
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
-
-
-
+ android:layout_height="match_parent" >
+
+
+
+
-
-
-
-
diff --git a/src/android/customCamera/res/values/strings.xml b/src/android/customCamera/res/values/strings.xml
index fb8296f..b9fad09 100644
--- a/src/android/customCamera/res/values/strings.xml
+++ b/src/android/customCamera/res/values/strings.xml
@@ -6,11 +6,12 @@
Settings
CameraActivityNative
Start Custom Camera
- Capture
TODO
sss
Miniature
Photo
Ceci est le bouton permettant d\'afficher une miniature
Il s\'agit de l\'image de fond de l\'appareil photo
+ Accepter Photo
+ Refuser Photo
diff --git a/src/android/customCamera/src/org/geneanet/customcamera/CameraActivity.java b/src/android/customCamera/src/org/geneanet/customcamera/CameraActivity.java
index 7d47843..c7f9e41 100644
--- a/src/android/customCamera/src/org/geneanet/customcamera/CameraActivity.java
+++ b/src/android/customCamera/src/org/geneanet/customcamera/CameraActivity.java
@@ -7,8 +7,6 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
-import android.util.Log;
-
import android.app.Activity;
import android.content.Intent;
import android.content.res.Configuration;
@@ -29,6 +27,7 @@ import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
@@ -41,6 +40,11 @@ public class CameraActivity extends Activity {
*/
private boolean modeMiniature = false;
+ /**
+ * Enable when a photo is taken
+ */
+ private boolean photoTaken = false;
+
/**
* Camera resource.
*/
@@ -227,21 +231,15 @@ public class CameraActivity extends Activity {
*/
public void showMiniature(View view) {
// Picture for the background.
- final ImageView imageView = (ImageView) findViewById(R.id.normal);
+ ImageView imageView = (ImageView) findViewById(R.id.normal);
// Button for show miniature picture.
final Button miniature = (Button) view;
// if it's not miniature mode.
if (!modeMiniature) {
modeMiniature = true;
-
// Set new size for miniature layout.
- FrameLayout.LayoutParams paramsMiniature = new FrameLayout.LayoutParams(imageView.getWidth()/4, imageView.getHeight()/4);
- paramsMiniature.gravity = Gravity.BOTTOM;
- imageView.setLayoutParams(paramsMiniature);
-
- // Set current opacity for the miniature.
- // imageView.setAlpha(imageView.getAlpha());
+ setParamsMiniature(imageView, true);
// Hide the miniature button.
miniature.setVisibility(View.INVISIBLE);
@@ -249,7 +247,7 @@ public class CameraActivity extends Activity {
imageView.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
modeMiniature = false;
-
+ ImageView imageView = (ImageView) findViewById(R.id.normal);
// resize miniature.
LayoutParams paramsReagrandissement = (LayoutParams) imageView.getLayoutParams();
paramsReagrandissement.width = -1;
@@ -320,6 +318,7 @@ public class CameraActivity extends Activity {
*/
public void onPictureTaken(final byte[] data, Camera camera) {
// Show buttons to accept or decline the picture.
+
final LinearLayout keepPhoto = (LinearLayout) findViewById(R.id.keepPhoto);
keepPhoto.setVisibility(View.VISIBLE);
Button accept = (Button)findViewById(R.id.accept);
@@ -329,6 +328,21 @@ public class CameraActivity extends Activity {
final Button photo = (Button)findViewById(R.id.capture);
photo.setVisibility(View.INVISIBLE);
+ // Put button miniature at the top of the page
+ final Button miniature = (Button)findViewById(R.id.miniature);
+ final LayoutParams params = (RelativeLayout.LayoutParams)miniature.getLayoutParams();
+ ((RelativeLayout.LayoutParams) params).addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0);
+ ((RelativeLayout.LayoutParams) params).addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
+ miniature.setLayoutParams(params);
+
+ photoTaken = true;
+
+ // If miniature mode when photo is taken, the miniature goes to the top
+ if(modeMiniature){
+ ImageView imageView = (ImageView) findViewById(R.id.normal);
+ setParamsMiniature(imageView, false);
+ }
+
// Stop link between view and camera to start the preview picture.
mCamera.stopPreview();
@@ -337,6 +351,7 @@ public class CameraActivity extends Activity {
@Override
public void onClick(View v) {
try {
+ photoTaken = false;
// Get path picture to storage.
String pathPicture = Environment.getExternalStorageDirectory().getPath()+"/"+Environment.DIRECTORY_DCIM+"/Camera/";
pathPicture = pathPicture+String.format("%d.jpeg", System.currentTimeMillis());
@@ -359,14 +374,24 @@ public class CameraActivity extends Activity {
decline.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- keepPhoto.setVisibility(View.INVISIBLE);
- photo.setVisibility(View.VISIBLE);
- mCamera.startPreview();
+ photoTaken = false;
+ ((RelativeLayout.LayoutParams) params).addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
+ ((RelativeLayout.LayoutParams) params).addRule(RelativeLayout.ALIGN_PARENT_TOP, 0);
+ miniature.setLayoutParams(params);
+
+ // If mode miniature and photo is declined, the miniature goes back to the bottom
+ if(modeMiniature) {
+ ImageView imageView = (ImageView) findViewById(R.id.normal);
+ setParamsMiniature(imageView, false);
+ }
+
+ keepPhoto.setVisibility(View.INVISIBLE);
+ photo.setVisibility(View.VISIBLE);
+ mCamera.startPreview();
}
});
};
};
-
// Start capture picture.
mCamera.takePicture(shutterCallback, rawCallback, jpegCallback);
}
@@ -389,10 +414,34 @@ public class CameraActivity extends Activity {
return true;
}
-
+
+ /**
+ * When the back button is pressed
+ */
@Override
public void onBackPressed() {
this.setResult(3);
this.finish();
}
+
+ /**
+ * Set the size and the gravity of the miniature function of photo is taken or not.
+ *
+ * @param ImageView imageView Reference to the background image.
+ * @param Boolean Resize Should we resize or not ? Only when click on "miniature"
+ */
+ public void setParamsMiniature(ImageView imageView, boolean resize){
+ FrameLayout.LayoutParams paramsMiniature = new FrameLayout.LayoutParams(imageView.getWidth(), imageView.getHeight());
+ if (resize == true){
+ paramsMiniature.width = imageView.getWidth()/4;
+ paramsMiniature.height = imageView.getHeight()/4;
+ }
+ if (!photoTaken){
+ paramsMiniature.gravity = Gravity.BOTTOM;
+ }
+ else {
+ paramsMiniature.gravity = Gravity.TOP;
+ }
+ imageView.setLayoutParams(paramsMiniature);
+ }
}