8
0
mirror of https://gitee.com/shuto/customCamera.git synced 2026-06-08 00:00:19 +08:00

Refonte des layout (plus simple) et modifications en conséquence dans le code

This commit is contained in:
Thomas BOY
2014-12-01 13:05:35 +01:00
parent fabfc0d477
commit 53431cb5af
2 changed files with 79 additions and 81 deletions
@@ -13,7 +13,9 @@
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
<ImageView
android:id="@+id/normal"
@@ -24,86 +26,71 @@
android:src="@drawable/normal" />
</FrameLayout>
<GridLayout
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnCount="4" >
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:gravity="bottom" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<RelativeLayout
android:id="@+id/miniature_layout"
android:layout_width="wrap_content"
android:layout_height="match_parent" >
<Button
android:id="@+id/miniature"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:onClick="showMiniature"
android:text="@string/miniature" />
</RelativeLayout>
<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="@string/capture"
android:onClick="takePhoto" />
<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" />
</LinearLayout>
</GridLayout>
<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnCount="2" >
<LinearLayout
android:id="@+id/keepPhoto"
android:layout_width="fill_parent"
<Button
android:id="@+id/miniature"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="0.2"
android:onClick="showMiniature"
android:text="@string/miniature" />
<Button
android:id="@+id/capture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="takePhoto"
android:text="@string/capture" />
<org.geneanet.customcamera.VerticalSeekBar
android:id="@+id/switchOpacity"
android:layout_width="wrap_content"
android:layout_height="300dp"
android:layout_gravity="center_vertical"
android:layout_weight="0"
android:alpha="0.6"
android:background="@color/black"
android:visibility="invisible" >
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"
android:thumbOffset="-0.9px" />
</LinearLayout>
<Button
android:id="@+id/accept"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/acceptePicture" />
<LinearLayout
android:id="@+id/keepPhoto"
android:layout_width="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
android:id="@+id/decline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/declinePicture" />
</LinearLayout>
</GridLayout>
<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>
</RelativeLayout>
@@ -11,6 +11,7 @@ import android.app.Activity;
import android.content.Intent;
import android.content.res.Configuration;
import android.hardware.Camera;
import android.hardware.Camera.Parameters;
import android.hardware.Camera.PictureCallback;
import android.hardware.Camera.ShutterCallback;
import android.os.Bundle;
@@ -318,7 +319,6 @@ 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);
@@ -330,10 +330,22 @@ public class CameraActivity extends Activity {
// 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);
final LayoutParams params = (LinearLayout.LayoutParams)miniature.getLayoutParams();
((LinearLayout.LayoutParams) params).gravity = Gravity.TOP;
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;
@@ -375,8 +387,7 @@ public class CameraActivity extends Activity {
@Override
public void onClick(View v) {
photoTaken = false;
((RelativeLayout.LayoutParams) params).addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
((RelativeLayout.LayoutParams) params).addRule(RelativeLayout.ALIGN_PARENT_TOP, 0);
((LinearLayout.LayoutParams) params).gravity = Gravity.BOTTOM;
miniature.setLayoutParams(params);
// If mode miniature and photo is declined, the miniature goes back to the bottom