9
0
mirror of https://gitee.com/shuto/customCamera.git synced 2024-10-06 10:22:07 +08:00

Refonte des layout de l'appareil photo

This commit is contained in:
Thomas Boy 2014-11-19 14:07:26 +01:00
parent b917463e8b
commit 0526268a11
2 changed files with 91 additions and 120 deletions

View File

@ -1,143 +1,106 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="0dp"
android:paddingTop="0dp"
tools:context="org.geneanet.customcamera.CameraView" >
android:layout_height="match_parent" >
<FrameLayout
android:id="@+id/camera_preview"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
android:id="@+id/camera_preview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
</FrameLayout>
<LinearLayout
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/normal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:alpha="0.2"
android:scaleType="fitXY"
android:src="@drawable/normal" />
</FrameLayout>
<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
android:columnCount="4" >
<FrameLayout
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
android:layout_height="fill_parent"
android:orientation="horizontal" >
<ImageView
android:id="@+id/normal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:alpha="0.2"
android:scaleType="fitXY"
android:src="@drawable/normal" />
<Button
android:id="@+id/miniature"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:onClick="showMiniature"
android:text="Miniature" />
<ImageView
android:id="@+id/colorise"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:alpha="0"
android:scaleType="fitXY"
android:src="@drawable/colorise" />
<Button
android:id="@+id/capture"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="0.74"
android:text="PHOTO"
android:onClick="takePhoto" />
<ImageView
android:id="@+id/paysage"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:alpha="0"
android:rotation="90"
android:src="@drawable/paysage" />
<org.geneanet.customcamera.VerticalSeekBar
android:id="@+id/switchOpacity"
android:layout_width="wrap_content"
android:layout_height="300dp"
android:layout_gravity="center_vertical|right"
android:layout_weight="0"
android:alpha="0.6"
android:max="7"
android:maxHeight="13dp"
android:minHeight="0dp"
android:progress="0"
android:progressDrawable="@drawable/custom_opacity_bar"
android:secondaryProgress="7"
android:thumb="@drawable/thumb" />
<ImageView
android:id="@+id/couthenans"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:alpha="0"
android:rotation="90"
android:src="@drawable/couthenans" />
</LinearLayout>
<ImageView
android:id="@+id/hericourt"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:alpha="0"
android:rotation="90"
android:src="@drawable/hericourt" />
</GridLayout>
</FrameLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="false"
android:layout_alignParentRight="false"
android:layout_alignParentTop="false"
android:layout_centerHorizontal="false"
android:layout_centerInParent="false"
android:orientation="horizontal" >
android:columnCount="2" >
<Button
android:id="@+id/Miniature"
android:layout_width="wrap_content"
<LinearLayout
android:id="@+id/keepPhoto"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:onClick="showMiniature"
android:text="@string/Miniature" />
android:alpha="0.6"
android:background="@color/black" >
<Button
android:id="@+id/capture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="150"
android:minWidth="0dp"
android:onClick="takePhoto"
android:text="@string/PHOTO" />
<Button
android:id="@+id/accepter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Accepter photo" />
<org.geneanet.customcamera.VerticalSeekBar
android:id="@+id/switchOpacity"
android:layout_width="wrap_content"
android:layout_height="300dp"
android:layout_gravity="center_vertical"
android:layout_marginBottom="30dp"
android:layout_marginRight="5dp"
android:layout_marginTop="30dp"
android:layout_weight="0"
<Button
android:id="@+id/refuser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Refuser Photo" />
android:maxHeight="13dp"
android:minHeight="0dp"
android:progress="0"
android:max="7"
android:secondaryProgress="7"
android:thumb="@drawable/thumb"
android:progressDrawable="@drawable/custom_opacity_bar"
android:alpha="0.6" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/keepPhoto"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:alpha="0.6"
android:background="@color/black"
android:gravity="bottom" >
<Button
android:id="@+id/refuser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:alpha="1"
android:text="Refuser" />
<Button
android:id="@+id/accepter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Accepter" />
</LinearLayout>
</GridLayout>
</RelativeLayout>

View File

@ -1,10 +1,12 @@
package org.geneanet.customcamera;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.hardware.Camera;
import android.hardware.Camera.PictureCallback;
@ -67,6 +69,7 @@ public class CameraView extends Activity {
int defaultOrientation = getDeviceDefaultOrientation();
if (defaultOrientation == 1){ // We are in portrait orientation
System.out.println(display.getRotation());
switch(display.getRotation()){
case 0 :
mCamera.setDisplayOrientation(90);
@ -220,8 +223,8 @@ public class CameraView extends Activity {
/***************************/
public void showMiniature(View view){
ImageView imageView = (ImageView) findViewById(R.id.normal);
Button miniature = (Button) findViewById(R.id.Miniature);
Button miniature = (Button) findViewById(R.id.miniature);
if(modeMiniature == 0){
FrameLayout.LayoutParams paramsMiniature = new FrameLayout.LayoutParams(imageView.getWidth()/4, imageView.getHeight()/4);
paramsMiniature.gravity=Gravity.BOTTOM;
@ -235,7 +238,7 @@ public class CameraView extends Activity {
imageView.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
ImageView imageView = (ImageView) findViewById(R.id.normal);
Button miniature = (Button) findViewById(R.id.Miniature);
Button miniature = (Button) findViewById(R.id.miniature);
LayoutParams paramsReagrandissement = (LayoutParams) imageView.getLayoutParams();
paramsReagrandissement.width = -1;
paramsReagrandissement.height = -1;
@ -314,6 +317,9 @@ public class CameraView extends Activity {
keepPhoto.setVisibility(View.VISIBLE);
Button refuser = (Button)findViewById(R.id.refuser);
Button accepter = (Button)findViewById(R.id.accepter);
final Button photo = (Button)findViewById(R.id.capture);
Button miniature = (Button)findViewById(R.id.miniature);
photo.setVisibility(View.INVISIBLE);
mCamera.stopPreview();
accepter.setOnClickListener(new View.OnClickListener() {
@ -325,6 +331,7 @@ public class CameraView extends Activity {
outStream.write(data);
outStream.close();
keepPhoto.setVisibility(View.INVISIBLE);
photo.setVisibility(View.VISIBLE);
mCamera.startPreview();
} catch (IOException e) {
e.printStackTrace();
@ -336,6 +343,7 @@ public class CameraView extends Activity {
@Override
public void onClick(View v) {
keepPhoto.setVisibility(View.INVISIBLE);
photo.setVisibility(View.VISIBLE);
mCamera.startPreview();
}
});