Toute la semaine dernière -> miniature, opacite, orientation ...
@@ -30,4 +30,7 @@
|
||||
|
||||
</application>
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-feature android:name="android.hardware.camera"
|
||||
android:required="true" />
|
||||
|
||||
</manifest>
|
||||
|
||||
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 343 KiB |
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@android:id/background">
|
||||
<shape>
|
||||
<corners android:radius="5dip" />
|
||||
<gradient
|
||||
android:startColor="#ffffffff"
|
||||
android:centerColor="#ffdddddd"
|
||||
android:centerY="0.50"
|
||||
android:endColor="#ffffffff"
|
||||
android:angle="270" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:id="@android:id/secondaryProgress">
|
||||
<clip>
|
||||
<shape>
|
||||
<corners android:radius="5dip" />
|
||||
<gradient
|
||||
android:startColor="#FBFCFA"
|
||||
android:endColor="#FBFCFA"
|
||||
android:angle="90" />
|
||||
</shape>
|
||||
</clip>
|
||||
</item>
|
||||
<item android:id="@android:id/progress">
|
||||
<clip>
|
||||
<shape>
|
||||
<corners android:radius="5dip" />
|
||||
<gradient
|
||||
android:startColor="#777777"
|
||||
android:endColor="#777777"
|
||||
android:angle="90" />
|
||||
</shape>
|
||||
</clip>
|
||||
</item>
|
||||
</layer-list>
|
||||
|
After Width: | Height: | Size: 802 KiB |
|
After Width: | Height: | Size: 585 KiB |
|
After Width: | Height: | Size: 1.3 MiB |
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval" >
|
||||
|
||||
<gradient
|
||||
android:angle="270"
|
||||
android:endColor="#e26760"
|
||||
android:startColor="#e26760"
|
||||
/>
|
||||
|
||||
<size
|
||||
android:height="40dp"
|
||||
android:width="40dp" />
|
||||
|
||||
</shape>
|
||||
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@android:id/secondaryProgress">
|
||||
<clip>
|
||||
<shape>
|
||||
<corners android:radius="5dip" />
|
||||
<gradient
|
||||
android:startColor="#80ffd300"
|
||||
android:centerColor="#80ffb600"
|
||||
android:centerY="0.75"
|
||||
android:endColor="#a0ffcb00"
|
||||
android:angle="270" />
|
||||
</shape>
|
||||
</clip>
|
||||
</item>
|
||||
<item android:id="@android:id/progress">
|
||||
<clip>
|
||||
<shape>
|
||||
<corners android:radius="5dip" />
|
||||
<gradient
|
||||
android:startColor="#ffffd300"
|
||||
android:centerColor="#ffffb600"
|
||||
android:centerY="0.75"
|
||||
android:endColor="#ffffcb00"
|
||||
android:angle="270" />
|
||||
</shape>
|
||||
</clip>
|
||||
</item>
|
||||
</layer-list>
|
||||
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 343 KiB |
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@android:id/background">
|
||||
<shape>
|
||||
<corners android:radius="5dip" />
|
||||
<gradient
|
||||
android:startColor="#ffffffff"
|
||||
android:centerColor="#ffdddddd"
|
||||
android:centerY="0.50"
|
||||
android:endColor="#ffffffff"
|
||||
android:angle="270" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:id="@android:id/secondaryProgress">
|
||||
<clip>
|
||||
<shape>
|
||||
<corners android:radius="5dip" />
|
||||
<gradient
|
||||
android:startColor="#FBFCFA"
|
||||
android:endColor="#FBFCFA"
|
||||
android:angle="90" />
|
||||
</shape>
|
||||
</clip>
|
||||
</item>
|
||||
<item android:id="@android:id/progress">
|
||||
<clip>
|
||||
<shape>
|
||||
<corners android:radius="5dip" />
|
||||
<gradient
|
||||
android:startColor="#777777"
|
||||
android:endColor="#777777"
|
||||
android:angle="90" />
|
||||
</shape>
|
||||
</clip>
|
||||
</item>
|
||||
</layer-list>
|
||||
|
After Width: | Height: | Size: 802 KiB |
|
After Width: | Height: | Size: 585 KiB |
|
After Width: | Height: | Size: 1.3 MiB |
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval" >
|
||||
|
||||
<gradient
|
||||
android:angle="270"
|
||||
android:endColor="#e26760"
|
||||
android:startColor="#e26760"
|
||||
/>
|
||||
|
||||
<size
|
||||
android:height="40dp"
|
||||
android:width="40dp" />
|
||||
|
||||
</shape>
|
||||
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 343 KiB |
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@android:id/background">
|
||||
<shape>
|
||||
<corners android:radius="5dip" />
|
||||
<gradient
|
||||
android:startColor="#ffffffff"
|
||||
android:centerColor="#ffdddddd"
|
||||
android:centerY="0.50"
|
||||
android:endColor="#ffffffff"
|
||||
android:angle="270" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:id="@android:id/secondaryProgress">
|
||||
<clip>
|
||||
<shape>
|
||||
<corners android:radius="5dip" />
|
||||
<gradient
|
||||
android:startColor="#FBFCFA"
|
||||
android:endColor="#FBFCFA"
|
||||
android:angle="90" />
|
||||
</shape>
|
||||
</clip>
|
||||
</item>
|
||||
<item android:id="@android:id/progress">
|
||||
<clip>
|
||||
<shape>
|
||||
<corners android:radius="5dip" />
|
||||
<gradient
|
||||
android:startColor="#777777"
|
||||
android:endColor="#777777"
|
||||
android:angle="90" />
|
||||
</shape>
|
||||
</clip>
|
||||
</item>
|
||||
</layer-list>
|
||||
|
After Width: | Height: | Size: 802 KiB |
|
After Width: | Height: | Size: 585 KiB |
|
After Width: | Height: | Size: 1.3 MiB |
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval" >
|
||||
|
||||
<gradient
|
||||
android:angle="270"
|
||||
android:endColor="#e26760"
|
||||
android:startColor="#e26760"
|
||||
/>
|
||||
|
||||
<size
|
||||
android:height="40dp"
|
||||
android:width="40dp" />
|
||||
|
||||
</shape>
|
||||
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 343 KiB |
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@android:id/background">
|
||||
<shape>
|
||||
<corners android:radius="5dip" />
|
||||
<gradient
|
||||
android:startColor="#ffffffff"
|
||||
android:centerColor="#ffdddddd"
|
||||
android:centerY="0.50"
|
||||
android:endColor="#ffffffff"
|
||||
android:angle="270" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:id="@android:id/secondaryProgress">
|
||||
<clip>
|
||||
<shape>
|
||||
<corners android:radius="5dip" />
|
||||
<gradient
|
||||
android:startColor="#FBFCFA"
|
||||
android:endColor="#FBFCFA"
|
||||
android:angle="90" />
|
||||
</shape>
|
||||
</clip>
|
||||
</item>
|
||||
<item android:id="@android:id/progress">
|
||||
<clip>
|
||||
<shape>
|
||||
<corners android:radius="5dip" />
|
||||
<gradient
|
||||
android:startColor="#777777"
|
||||
android:endColor="#777777"
|
||||
android:angle="90" />
|
||||
</shape>
|
||||
</clip>
|
||||
</item>
|
||||
</layer-list>
|
||||
|
After Width: | Height: | Size: 802 KiB |
|
After Width: | Height: | Size: 585 KiB |
|
After Width: | Height: | Size: 1.3 MiB |
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval" >
|
||||
|
||||
<gradient
|
||||
android:angle="270"
|
||||
android:endColor="#e26760"
|
||||
android:startColor="#e26760"
|
||||
/>
|
||||
|
||||
<size
|
||||
android:height="40dp"
|
||||
android:width="40dp" />
|
||||
|
||||
</shape>
|
||||
@@ -2,28 +2,122 @@
|
||||
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" >
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/camera_preview"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView2"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:alpha="0.5"
|
||||
android:contentDescription="@string/sss"
|
||||
android:src="@drawable/labs" />
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_capture"
|
||||
android:text="@string/capture"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
/>
|
||||
<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:contentDescription="@string/descImage"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/normal" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/colorise"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:alpha="0"
|
||||
android:contentDescription="@string/descImage"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/colorise" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/paysage"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:alpha="0"
|
||||
android:contentDescription="@string/descImage"
|
||||
android:rotation="90"
|
||||
android:src="@drawable/paysage" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/couthenans"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:alpha="0"
|
||||
android:contentDescription="@string/descImage"
|
||||
android:rotation="90"
|
||||
android:src="@drawable/couthenans" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/hericourt"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:alpha="0"
|
||||
android:contentDescription="@string/descImage"
|
||||
android:rotation="90"
|
||||
android:src="@drawable/hericourt" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_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" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/Miniature"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:contentDescription="@string/BoutonMiniature"
|
||||
android:onClick="showMiniature"
|
||||
android:text="@string/Miniature" />
|
||||
|
||||
<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:text="@string/PHOTO" />
|
||||
|
||||
<org.geneanet.customcamera.utils.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"
|
||||
|
||||
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>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
android:text="@string/hello_world" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button1"
|
||||
android:id="@+id/capture"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignLeft="@+id/textView1"
|
||||
|
||||
@@ -9,5 +9,8 @@
|
||||
<string name="capture">Capture</string>
|
||||
<string name="todo">TODO</string>
|
||||
<string name="sss">sss</string>
|
||||
|
||||
<string name="Miniature">Miniature</string>
|
||||
<string name="PHOTO">Photo</string>
|
||||
<string name="BoutonMiniature">Ceci est le bouton permettant d\'afficher une miniature</string>
|
||||
<string name="descImage">Il s\'agit de l\'image de fond de l\'appareil photo</string>
|
||||
</resources>
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
<!-- Application theme. -->
|
||||
<style name="AppTheme" parent="AppBaseTheme">
|
||||
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
|
||||
</style>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -1,45 +1,56 @@
|
||||
package org.geneanet.customcamera;
|
||||
|
||||
import java.util.List;
|
||||
import java.lang.Math;
|
||||
|
||||
import org.geneanet.customcamera.utils.CameraPreview;
|
||||
import org.geneanet.customcamera.utils.CustomCamera;
|
||||
import org.geneanet.testcustomcamera.R;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Point;
|
||||
import android.content.pm.ActivityInfo;
|
||||
|
||||
import android.hardware.Camera;
|
||||
import android.os.Bundle;
|
||||
import android.view.Display;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.Gravity;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ImageView.ScaleType;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||
|
||||
public class CameraView extends Activity {
|
||||
|
||||
private Camera mCamera;
|
||||
private float mDist;
|
||||
private Camera mCamera;
|
||||
private int modeMiniature = 0;
|
||||
private CameraPreview mPreview;
|
||||
public static final int MEDIA_TYPE_IMAGE = 1;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
//Remove title bar
|
||||
/* Remove title bar */
|
||||
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
//Remove notification bar
|
||||
|
||||
/* Remove notification bar */
|
||||
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
|
||||
setContentView(R.layout.activity_camera_view);
|
||||
|
||||
// Récupère les infos sur le device.
|
||||
/* Get informations about the device */
|
||||
Display display = getWindowManager().getDefaultDisplay();
|
||||
|
||||
// récupère l'objet gérant la camera puis l'oriente en fonction de l'écran.
|
||||
/* Get object which use the camera and orient it in function of the screen */
|
||||
mCamera = CustomCamera.getCameraInstance();
|
||||
|
||||
switch (display.getRotation()) {
|
||||
case CustomCamera.LANDSCAPE:
|
||||
mCamera.setDisplayOrientation(0);
|
||||
@@ -55,9 +66,180 @@ public class CameraView extends Activity {
|
||||
break;
|
||||
}
|
||||
|
||||
// On assigne le rendu à la vue.
|
||||
/* Assign the render to the view */
|
||||
mPreview = new CameraPreview(this, mCamera);
|
||||
FrameLayout preview = (FrameLayout) findViewById(R.id.camera_preview);
|
||||
preview.addView(mPreview);
|
||||
|
||||
/* The opacity bar */
|
||||
SeekBar switchOpacity = (SeekBar) findViewById(R.id.switchOpacity);
|
||||
|
||||
switchOpacity.setOnSeekBarChangeListener(
|
||||
new OnSeekBarChangeListener() {
|
||||
int progress = 0;
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progresValue, boolean fromUser) {
|
||||
progress = progresValue;
|
||||
ImageView imageView = (ImageView) findViewById(R.id.normal);
|
||||
switch(progress){
|
||||
case 0 :
|
||||
imageView.setAlpha((float)0.2);
|
||||
break;
|
||||
case 1 :
|
||||
imageView.setAlpha((float)0.3);
|
||||
break;
|
||||
case 2 :
|
||||
imageView.setAlpha((float)0.4);
|
||||
break;
|
||||
case 3 :
|
||||
imageView.setAlpha((float)0.5);
|
||||
break;
|
||||
case 4 :
|
||||
imageView.setAlpha((float)0.6);
|
||||
break;
|
||||
case 5 :
|
||||
imageView.setAlpha((float)0.7);
|
||||
break;
|
||||
case 6 :
|
||||
imageView.setAlpha((float)0.8);
|
||||
break;
|
||||
case 7 :
|
||||
imageView.setAlpha((float)0.9);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {}
|
||||
});
|
||||
}
|
||||
|
||||
/*******************************************************/
|
||||
/** BLOCK THE ROTATION IN FUNCTION OF THE POSTAL CARD **/
|
||||
/*******************************************************/
|
||||
@Override
|
||||
public void onWindowFocusChanged(boolean hasFocus){
|
||||
ImageView imageView = (ImageView) findViewById(R.id.normal);
|
||||
int widthImage=imageView.getWidth();
|
||||
int heightImage=imageView.getHeight();
|
||||
|
||||
System.out.println("Largeur : "+widthImage);
|
||||
System.out.println("Hauteur : "+heightImage);
|
||||
|
||||
if(heightImage < widthImage || imageView.getRotation() != 0){
|
||||
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
imageView.setRotation(0);
|
||||
}
|
||||
else{
|
||||
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/******************/
|
||||
/** FOR THE ZOOM **/
|
||||
/******************/
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
Camera.Parameters params = mCamera.getParameters();
|
||||
int action = event.getAction();
|
||||
|
||||
if (event.getPointerCount() > 1) {
|
||||
// If we touch with more than one finger
|
||||
if (action == MotionEvent.ACTION_POINTER_UP) {
|
||||
mDist = getFingerSpacing(event);
|
||||
} else if (action == MotionEvent.ACTION_MOVE && params.isZoomSupported()) {
|
||||
mCamera.cancelAutoFocus();
|
||||
handleZoom(event, params, mDist);
|
||||
}
|
||||
} else {
|
||||
// If we touch with one finger -> auto-focus
|
||||
if (action == MotionEvent.ACTION_UP) {
|
||||
handleFocus(event, params);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/******************/
|
||||
/** GERE LE ZOOM **/
|
||||
/******************/
|
||||
private void handleZoom(MotionEvent event, Camera.Parameters params, float mDist) {
|
||||
int maxZoom = params.getMaxZoom();
|
||||
int zoom = params.getZoom();
|
||||
float newDist = getFingerSpacing(event);
|
||||
|
||||
if (newDist > mDist) {
|
||||
//zoom in
|
||||
if (zoom < maxZoom/2)
|
||||
zoom+=2;
|
||||
} else if (newDist < mDist) {
|
||||
//zoom out
|
||||
if (zoom > 0)
|
||||
zoom-=2;
|
||||
}
|
||||
mDist = newDist;
|
||||
params.setZoom(zoom);
|
||||
mCamera.setParameters(params);
|
||||
}
|
||||
|
||||
/*******************/
|
||||
/** GERE LE FOCUS **/
|
||||
/*******************/
|
||||
public void handleFocus(MotionEvent event, Camera.Parameters params) {
|
||||
List<String> supportedFocusModes = params.getSupportedFocusModes();
|
||||
if (supportedFocusModes != null && supportedFocusModes.contains(Camera.Parameters.FOCUS_MODE_AUTO)) {
|
||||
mCamera.autoFocus(new Camera.AutoFocusCallback() {
|
||||
@Override
|
||||
public void onAutoFocus(boolean b, Camera camera) {}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************/
|
||||
/** DETERMINE L'ESPACE ENTRE LES DEUX PREMIERS DOIGTS **/
|
||||
/*******************************************************/
|
||||
private float getFingerSpacing(MotionEvent event) {
|
||||
float x = event.getX(0) - event.getX(1);
|
||||
float y = event.getY(0) - event.getY(1);
|
||||
return (float) Math.sqrt(x * x + y * y);
|
||||
}
|
||||
|
||||
/***************************/
|
||||
/** AFFICHER LA MINIATURE **/
|
||||
/***************************/
|
||||
public void showMiniature(View view){
|
||||
ImageView imageView = (ImageView) findViewById(R.id.normal);
|
||||
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;
|
||||
imageView.setAlpha(imageView.getAlpha());
|
||||
|
||||
modeMiniature = 1;
|
||||
|
||||
imageView.setLayoutParams(paramsMiniature);
|
||||
|
||||
miniature.setEnabled(false);
|
||||
miniature.setVisibility(View.INVISIBLE);
|
||||
imageView.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
ImageView imageView = (ImageView) findViewById(R.id.normal);
|
||||
Button miniature = (Button) findViewById(R.id.Miniature);
|
||||
LayoutParams paramsReagrandissement = (LayoutParams) imageView.getLayoutParams();
|
||||
paramsReagrandissement.width = -1;
|
||||
paramsReagrandissement.height = -1;
|
||||
imageView.setAlpha(imageView.getAlpha());
|
||||
modeMiniature = 0;
|
||||
imageView.setLayoutParams(paramsReagrandissement);
|
||||
miniature.setVisibility(View.VISIBLE);
|
||||
miniature.setEnabled(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,14 +6,10 @@ import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.hardware.Camera;
|
||||
import android.os.Bundle;
|
||||
import android.provider.MediaStore;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
|
||||
public class MainActivity extends Activity {
|
||||
|
||||
@@ -29,7 +25,6 @@ public class MainActivity extends Activity {
|
||||
|
||||
public void startCamera(View view) {
|
||||
if(this.checkCameraHardware(this)){
|
||||
System.out.println("test");
|
||||
Intent intent = new Intent(this, CameraView.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package org.geneanet.customcamera.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.widget.SeekBar;
|
||||
|
||||
public class VerticalSeekBar extends SeekBar {
|
||||
|
||||
public VerticalSeekBar(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public VerticalSeekBar(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
public VerticalSeekBar(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||
super.onSizeChanged(h, w, oldh, oldw);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected synchronized void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(heightMeasureSpec, widthMeasureSpec);
|
||||
setMeasuredDimension(getMeasuredHeight(), getMeasuredWidth());
|
||||
}
|
||||
|
||||
|
||||
protected void onDraw(Canvas c) {
|
||||
c.rotate(-90);
|
||||
c.translate(-getHeight(), 0);
|
||||
super.onDraw(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
if (!isEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (event.getAction()) {
|
||||
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
|
||||
case MotionEvent.ACTION_UP:
|
||||
setProgress(getMax() - (int) (getMax() * event.getY() / getHeight()));
|
||||
onSizeChanged(getWidth(), getHeight(), 0, 0);
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||