9
0
mirror of https://gitee.com/shuto/customCamera.git synced 2026-05-02 00:07:24 +08:00

Fix design of seekbars.

This commit is contained in:
Christophe BOUCAUT
2015-06-04 11:35:15 +02:00
parent 3937a06501
commit 12321868f3
4 changed files with 51 additions and 16 deletions
@@ -2,16 +2,16 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<solid android:color="@android:color/darker_gray" />
<solid android:color="@android:color/white" />
<stroke
android:width="14dp"
android:color="@android:color/transparent" />
</shape>
</item>
<item android:id="@android:id/progress">
<item android:id="@+id/seekbarProgress">
<clip>
<shape>
<solid android:color="#33b5e5" />
<solid android:color="#444444" />
<stroke
android:width="12dp"
android:color="@android:color/transparent" />
@@ -5,12 +5,6 @@
<size
android:height="25dp"
android:width="25dp" />
<solid android:color="#33b5e5" />
<stroke
android:width="10dp"
android:color="#8833b5e5" />
</shape>
</item>
</selector>
@@ -107,8 +107,7 @@
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:visibility="visible"
android:progressDrawable="@drawable/custom_seekbar"
android:thumb="@drawable/custom_thumb" />
android:progressDrawable="@drawable/custom_seekbar" />
<TextView
android:id="@+id/textZoomMax"
@@ -178,7 +177,6 @@
android:layout_centerVertical="true"
android:max="10"
android:progress="5"
android:progressDrawable="@drawable/custom_seekbar"
android:thumb="@drawable/custom_thumb" />
android:progressDrawable="@drawable/custom_seekbar" />
</RelativeLayout>
@@ -4,12 +4,17 @@ import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.Resources.NotFoundException;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.DrawableContainer.DrawableContainerState;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.StateListDrawable;
import android.hardware.Camera;
import android.hardware.Camera.CameraInfo;
import android.hardware.Camera.PictureCallback;
@@ -18,6 +23,8 @@ import android.hardware.Camera.Size;
import android.os.Bundle;
import android.os.Environment;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
import android.view.Display;
import android.view.Gravity;
import android.view.MotionEvent;
@@ -26,7 +33,6 @@ 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.ImageButton;
import android.widget.ImageView;
@@ -39,6 +45,7 @@ import android.widget.TextView;
import org.geneanet.customcamera.CameraPreview;
import org.geneanet.customcamera.ManagerCamera;
import org.geneanet.customcamera.TransferBigData;
import org.xmlpull.v1.XmlPullParserException;
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
@@ -186,7 +193,10 @@ public class CameraActivity extends Activity {
ImageButton imgIcon = (ImageButton)findViewById(R.id.capture);
final Activity currentActivity = this;
this.setCameraBackgroundColor(this.getIntent().getStringExtra("cameraBackgroundColor"));
String backgroundColor = this.getIntent().getStringExtra("cameraBackgroundColor");
this.setCameraBackgroundColor(backgroundColor);
this.setThumbAtSeekBar((SeekBar)findViewById(R.id.zoomLevel), backgroundColor);
this.setThumbAtSeekBar((SeekBar)findViewById(R.id.switchOpacity), backgroundColor);
imgIcon.setOnTouchListener(new View.OnTouchListener() {
@Override
@@ -353,6 +363,40 @@ public class CameraActivity extends Activity {
}
}
/**
* Set thumb at a seekbar.
*
* @param color
*/
protected void setThumbAtSeekBar(SeekBar seekBar, String color) {
int colorParsed = Color.parseColor(color);
String colorAlpha = color.substring(1);
colorAlpha = "#88"+colorAlpha;
int colorAlphaParsed = Color.parseColor(colorAlpha);
StateListDrawable selectorThumb;
Resources res = getResources();
try {
selectorThumb = (StateListDrawable) Drawable.createFromXml(res, res.getXml(R.drawable.custom_thumb));
DrawableContainerState thumbState = (DrawableContainerState) selectorThumb.getConstantState();
GradientDrawable thumb = (GradientDrawable) thumbState.getChildren()[0];
thumb.setColor(colorParsed);
Resources r = getResources();
int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, r.getDisplayMetrics());
thumb.setStroke(px, colorAlphaParsed);
seekBar.setThumb(thumb);
} catch (NotFoundException e) {
Log.e("customCamera", "Xml resource is not found.");
e.printStackTrace();
} catch (XmlPullParserException e) {
Log.e("customCamera", "Xml can't be parsed.");
e.printStackTrace();
} catch (IOException e) {
Log.e("customCamera", "Error to create the thumb");
e.printStackTrace();
}
}
/**
* Determine the space between the first two fingers.
* @param MotionEvent event Current event which start this calculation.
@@ -555,7 +599,6 @@ public class CameraActivity extends Activity {
ImageButton photo = (ImageButton) findViewById(R.id.capture);
ImageButton switchCamera = (ImageButton) findViewById(R.id.switchCamera);
ImageView background = (ImageView) findViewById(R.id.background);
SeekBar zoomLevel = (SeekBar) findViewById(R.id.zoomLevel);
SeekBar switchOpacity = (SeekBar) findViewById(R.id.switchOpacity);
LayoutParams paramsLayoutMiniature = (LinearLayout.LayoutParams) miniature.getLayoutParams();