mirror of
https://gitee.com/shuto/customCamera.git
synced 2026-05-02 00:07:24 +08:00
Meilleur layout + correction d'un bug sur l'autofocus
This commit is contained in:
@@ -67,30 +67,33 @@
|
|||||||
android:thumbOffset="-0.9px" />
|
android:thumbOffset="-0.9px" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<FrameLayout
|
||||||
android:id="@+id/keepPhoto"
|
android:id="@+id/FrameLayout1"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent" >
|
||||||
android:layout_alignParentLeft="true"
|
|
||||||
android:layout_alignParentTop="true"
|
|
||||||
android:alpha="0.6"
|
|
||||||
android:background="@color/black"
|
|
||||||
android:gravity="bottom"
|
|
||||||
android:visibility="invisible" >
|
|
||||||
|
|
||||||
<Button
|
<LinearLayout
|
||||||
android:id="@+id/accept"
|
android:id="@+id/keepPhoto"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_gravity="bottom"
|
||||||
android:text="@string/acceptePicture" />
|
android:alpha="0.8"
|
||||||
|
android:background="@color/black"
|
||||||
<Button
|
android:visibility="invisible" >
|
||||||
android:id="@+id/decline"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@string/declinePicture" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/accept"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@string/acceptePicture" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/decline"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@string/declinePicture" />
|
||||||
|
</LinearLayout>
|
||||||
|
</FrameLayout>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import android.app.Activity;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.hardware.Camera;
|
import android.hardware.Camera;
|
||||||
import android.hardware.Camera.Parameters;
|
|
||||||
import android.hardware.Camera.PictureCallback;
|
import android.hardware.Camera.PictureCallback;
|
||||||
import android.hardware.Camera.ShutterCallback;
|
import android.hardware.Camera.ShutterCallback;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -28,7 +27,6 @@ import android.widget.Button;
|
|||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.RelativeLayout;
|
|
||||||
import android.widget.SeekBar;
|
import android.widget.SeekBar;
|
||||||
import android.widget.SeekBar.OnSeekBarChangeListener;
|
import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||||
|
|
||||||
@@ -191,7 +189,7 @@ public class CameraActivity extends Activity {
|
|||||||
//zoom out
|
//zoom out
|
||||||
if (zoom > 0)
|
if (zoom > 0)
|
||||||
zoom-=2;
|
zoom-=2;
|
||||||
}
|
}
|
||||||
distanceBetweenFingers = newDist;
|
distanceBetweenFingers = newDist;
|
||||||
params.setZoom(zoom);
|
params.setZoom(zoom);
|
||||||
mCamera.setParameters(params);
|
mCamera.setParameters(params);
|
||||||
@@ -204,12 +202,16 @@ public class CameraActivity extends Activity {
|
|||||||
* @param Parameters params Camera's parameter.
|
* @param Parameters params Camera's parameter.
|
||||||
*/
|
*/
|
||||||
public void handleFocus(MotionEvent event, Camera.Parameters params) {
|
public void handleFocus(MotionEvent event, Camera.Parameters params) {
|
||||||
List<String> supportedFocusModes = params.getSupportedFocusModes();
|
try {
|
||||||
if (supportedFocusModes != null && supportedFocusModes.contains(Camera.Parameters.FOCUS_MODE_AUTO)) {
|
List<String> supportedFocusModes = params.getSupportedFocusModes();
|
||||||
mCamera.autoFocus(new Camera.AutoFocusCallback() {
|
if (supportedFocusModes != null && supportedFocusModes.contains(Camera.Parameters.FOCUS_MODE_AUTO)) {
|
||||||
@Override
|
mCamera.autoFocus(new Camera.AutoFocusCallback() {
|
||||||
public void onAutoFocus(boolean b, Camera camera) {}
|
@Override
|
||||||
});
|
public void onAutoFocus(boolean b, Camera camera) {}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,8 +256,6 @@ public class CameraActivity extends Activity {
|
|||||||
paramsReagrandissement.width = -1;
|
paramsReagrandissement.width = -1;
|
||||||
paramsReagrandissement.height = -1;
|
paramsReagrandissement.height = -1;
|
||||||
imageView.setLayoutParams(paramsReagrandissement);
|
imageView.setLayoutParams(paramsReagrandissement);
|
||||||
|
|
||||||
// imageView.setAlpha(imageView.getAlpha());
|
|
||||||
miniature.setVisibility(View.VISIBLE);
|
miniature.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -333,19 +333,6 @@ public class CameraActivity extends Activity {
|
|||||||
final LayoutParams params = (LinearLayout.LayoutParams)miniature.getLayoutParams();
|
final LayoutParams params = (LinearLayout.LayoutParams)miniature.getLayoutParams();
|
||||||
((LinearLayout.LayoutParams) params).gravity = Gravity.TOP;
|
((LinearLayout.LayoutParams) params).gravity = Gravity.TOP;
|
||||||
miniature.setLayoutParams(params);
|
miniature.setLayoutParams(params);
|
||||||
|
|
||||||
try {
|
|
||||||
Camera.Parameters test = mCamera.getParameters();
|
|
||||||
test.setWhiteBalance(Parameters.WHITE_BALANCE_AUTO);
|
|
||||||
test.setSceneMode(Parameters.SCENE_MODE_AUTO);
|
|
||||||
int index = test.getExposureCompensation ();
|
|
||||||
// to set maximum Exposure
|
|
||||||
test.setExposureCompensation(test.getMaxExposureCompensation());
|
|
||||||
|
|
||||||
mCamera.setParameters(test);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
photoTaken = true;
|
photoTaken = true;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user