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

Merge pull request #23 from ChristopheBoucaut/optimisation#1-Refonte-layout

Optimisation#1 refonte layout
This commit is contained in:
ChristopheBoucaut 2014-12-01 17:36:08 +01:00
commit f5b81138cc
2 changed files with 59 additions and 71 deletions

View File

@ -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,46 +26,35 @@
android:src="@drawable/normal" />
</FrameLayout>
<GridLayout
<LinearLayout
android:id="@+id/beforePhoto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnCount="4" >
<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" >
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:gravity="bottom" >
<Button
android:id="@+id/miniature"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:layout_weight="0.2"
android:onClick="showMiniature"
android:text="@string/miniature" />
</RelativeLayout>
<Button
android:id="@+id/capture"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="0.74"
android:text="@string/capture"
android:onClick="takePhoto" />
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|right"
android:layout_gravity="center_vertical"
android:layout_weight="0"
android:alpha="0.6"
android:max="7"
@ -72,21 +63,21 @@
android:progress="0"
android:progressDrawable="@drawable/custom_opacity_bar"
android:secondaryProgress="7"
android:thumb="@drawable/thumb" />
android:thumb="@drawable/thumb"
android:thumbOffset="-0.9px" />
</LinearLayout>
</GridLayout>
<GridLayout
<FrameLayout
android:id="@+id/afterPhoto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnCount="2" >
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/keepPhoto"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:alpha="0.6"
android:alpha="0.8"
android:background="@color/black"
android:visibility="invisible" >
@ -104,6 +95,5 @@
android:layout_weight="1"
android:text="@string/declinePicture" />
</LinearLayout>
</GridLayout>
</FrameLayout>
</RelativeLayout>

View File

@ -27,7 +27,6 @@ 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;
@ -184,13 +183,15 @@ public class CameraActivity extends Activity {
if (newDist > distanceBetweenFingers) {
//zoom in
if (zoom < maxZoom/2)
if (zoom < maxZoom/2) {
zoom+=2;
}
} else if (newDist < distanceBetweenFingers) {
//zoom out
if (zoom > 0)
if (zoom > 0) {
zoom-=2;
}
}
distanceBetweenFingers = newDist;
params.setZoom(zoom);
mCamera.setParameters(params);
@ -203,6 +204,7 @@ public class CameraActivity extends Activity {
* @param Parameters params Camera's parameter.
*/
public void handleFocus(MotionEvent event, Camera.Parameters params) {
if (photoTaken == false) {
List<String> supportedFocusModes = params.getSupportedFocusModes();
if (supportedFocusModes != null && supportedFocusModes.contains(Camera.Parameters.FOCUS_MODE_AUTO)) {
mCamera.autoFocus(new Camera.AutoFocusCallback() {
@ -211,6 +213,7 @@ public class CameraActivity extends Activity {
});
}
}
}
/**
* Determine the space between the first two fingers.
@ -253,8 +256,6 @@ public class CameraActivity extends Activity {
paramsReagrandissement.width = -1;
paramsReagrandissement.height = -1;
imageView.setLayoutParams(paramsReagrandissement);
// imageView.setAlpha(imageView.getAlpha());
miniature.setVisibility(View.VISIBLE);
}
});
@ -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,9 +330,8 @@ 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);
photoTaken = true;
@ -375,8 +374,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