Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #554

Merged
merged 20 commits into from
Jan 10, 2019
Merged

Dev #554

Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add style attribute cameraQuality for Android
  • Loading branch information
JoshLipan committed Jan 9, 2019
commit eb0b163e9955188e620d66622eedd455ff9bbd2b
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class ChatInputStyle extends Style {
private int sendBtnPressedIcon;
private Drawable sendCountBg;
private boolean showSelectAlbumBtn;
private float cameraQuality;

public static ChatInputStyle parse(Context context, AttributeSet attrs) {
ChatInputStyle style = new ChatInputStyle(context, attrs);
Expand Down Expand Up @@ -94,6 +95,7 @@ public static ChatInputStyle parse(Context context, AttributeSet attrs) {
style.getDimension(R.dimen.aurora_padding_input_right));
style.inputPaddingBottom = typedArray.getDimensionPixelSize(R.styleable.ChatInputView_inputPaddingBottom,
style.getDimension(R.dimen.aurora_padding_input_bottom));
style.cameraQuality = typedArray.getFloat(R.styleable.ChatInputView_cameraQuality,0.5f);
typedArray.recycle();
return style;
}
Expand Down Expand Up @@ -216,4 +218,8 @@ public int getInputPaddingBottom() {
public boolean getShowSelectAlbum() {
return this.showSelectAlbumBtn;
}

public float getCameraQuality() {
return this.cameraQuality;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ public void run() {
mCaptureBtn.setBackgroundResource(R.drawable.aurora_preview_record_video_start);
mMediaPlayer.stop();
mMediaPlayer.release();
mCameraSupport.open(mCameraId, mWidth, mHeight, mIsBackCamera);
mCameraSupport.open(mCameraId, mWidth, mHeight, mIsBackCamera, mStyle.getCameraQuality());
} else {
for (int i = 0; i < Camera.getNumberOfCameras(); i++) {
Camera.CameraInfo info = new Camera.CameraInfo();
Expand All @@ -706,7 +706,7 @@ public void run() {
mIsBackCamera = false;
mCameraSupport.release();
mCameraSupport.open(mCameraId, mTextureView.getWidth(), mTextureView.getHeight(),
mIsBackCamera);
mIsBackCamera, mStyle.getCameraQuality());
break;
}
} else {
Expand All @@ -715,7 +715,7 @@ public void run() {
mIsBackCamera = true;
mCameraSupport.release();
mCameraSupport.open(mCameraId, mTextureView.getWidth(), mTextureView.getHeight(),
mIsBackCamera);
mIsBackCamera, mStyle.getCameraQuality());
break;
}
}
Expand Down Expand Up @@ -839,7 +839,7 @@ public void initCamera() {
}
}
if (mTextureView.isAvailable()) {
mCameraSupport.open(mCameraId, mWidth, sMenuHeight, mIsBackCamera);
mCameraSupport.open(mCameraId, mWidth, sMenuHeight, mIsBackCamera, mStyle.getCameraQuality());
} else {
mTextureView.setSurfaceTextureListener(new TextureView.SurfaceTextureListener() {
@Override
Expand All @@ -848,7 +848,7 @@ public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int width,
if (mCameraSupport == null) {
initCamera();
} else {
mCameraSupport.open(mCameraId, width, height, mIsBackCamera);
mCameraSupport.open(mCameraId, width, height, mIsBackCamera, mStyle.getCameraQuality());
}

}
Expand All @@ -857,7 +857,7 @@ public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int width,
public void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture, int width, int height) {
Log.d("ChatInputView", "Texture size changed, Opening camera");
if (mTextureView.getVisibility() == VISIBLE && mCameraSupport != null) {
mCameraSupport.open(mCameraId, width, height, mIsBackCamera);
mCameraSupport.open(mCameraId, width, height, mIsBackCamera, mStyle.getCameraQuality());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public CameraOld(Context context, TextureView textureView) {
}

@Override
public CameraSupport open(int cameraId, int width, int height, boolean isFacingBack) {
public CameraSupport open(int cameraId, int width, int height, boolean isFacingBack, float cameraQuality) {
try {
this.mCameraId = cameraId;
this.mCamera = Camera.open(cameraId);
Expand Down Expand Up @@ -96,7 +96,7 @@ public CameraSupport open(int cameraId, int width, int height, boolean isFacingB
ViewGroup.LayoutParams layoutParams = new FrameLayout.LayoutParams((int) (height * (w / h)), height);
mTextureView.setLayoutParams(layoutParams);

params.setJpegQuality(100); // 设置照片质量
params.setJpegQuality((int)(100*cameraQuality)); // 设置照片质量
if (params.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {
params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


public interface CameraSupport {
CameraSupport open(int cameraId, int width, int height, boolean isFacingBack);
CameraSupport open(int cameraId, int width, int height, boolean isFacingBack,float cameraQuality);
void release();
void takePicture();
void setCameraCallbackListener(OnCameraCallbackListener listener);
Expand Down
1 change: 1 addition & 0 deletions Android/chatinput/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<attr name="photoBtnBg" format="reference" />
<attr name="photoBtnIcon" format="reference" />
<attr name="showSelectAlbum" format="boolean" />
<attr name="cameraQuality" format="float" />
</declare-styleable>

<declare-styleable name="RecordVoiceButton">
Expand Down