recheck the previews aspect ratio on resolution change
This commit is contained in:
parent
c8af745297
commit
4a13d766f0
|
@ -132,10 +132,7 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
|
|||
mMaxZoom = mParameters!!.maxZoom
|
||||
mZoomRatios = mParameters!!.zoomRatios
|
||||
mSupportedPreviewSizes = mParameters!!.supportedPreviewSizes.sortedByDescending { it.width * it.height }
|
||||
mIsSixteenToNine = isSixteenToNine()
|
||||
requestLayout()
|
||||
invalidate()
|
||||
mSetupPreviewAfterMeasure = true
|
||||
refreshPreview()
|
||||
|
||||
val focusModes = mParameters!!.supportedFocusModes
|
||||
if (focusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE))
|
||||
|
@ -163,6 +160,13 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
|
|||
return true
|
||||
}
|
||||
|
||||
private fun refreshPreview() {
|
||||
mIsSixteenToNine = isSixteenToNine()
|
||||
mSetupPreviewAfterMeasure = true
|
||||
requestLayout()
|
||||
invalidate()
|
||||
}
|
||||
|
||||
private fun isSixteenToNine(): Boolean {
|
||||
val selectedSize = getSelectedResolution()
|
||||
val selectedRatio = Math.abs(selectedSize.width / selectedSize.height.toFloat())
|
||||
|
@ -287,8 +291,6 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
|
|||
mCanTakePicture = true
|
||||
}
|
||||
|
||||
fun getSupportedVideoSizes(): List<Camera.Size> = mParameters!!.supportedVideoSizes ?: mParameters!!.supportedPreviewSizes
|
||||
|
||||
private fun focusArea(takePictureAfter: Boolean) {
|
||||
if (mCamera == null)
|
||||
return
|
||||
|
@ -332,9 +334,12 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
|
|||
}
|
||||
|
||||
fun showChangeResolutionDialog() {
|
||||
val oldResolution = getSelectedResolution()
|
||||
if (mCamera != null) {
|
||||
ChangeResolutionDialog(mActivity, config.lastUsedCamera == Camera.CameraInfo.CAMERA_FACING_BACK, mCamera!!) {
|
||||
|
||||
if (oldResolution != getSelectedResolution()) {
|
||||
refreshPreview()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ class ChangeResolutionDialog(val activity: SimpleActivity, val isBackCamera: Boo
|
|||
|
||||
AlertDialog.Builder(activity)
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.setOnDismissListener { callback() }
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this, if (isBackCamera) R.string.back_camera else R.string.front_camera)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue