split the video and image capture intent checks
This commit is contained in:
parent
39a235141e
commit
7e42da897a
|
@ -168,36 +168,41 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleIntent() {
|
private fun isImageCaptureIntent() = intent?.action == MediaStore.ACTION_IMAGE_CAPTURE || intent?.action == MediaStore.ACTION_IMAGE_CAPTURE_SECURE
|
||||||
|
|
||||||
|
private fun checkImageCaptureIntent() {
|
||||||
if (isImageCaptureIntent()) {
|
if (isImageCaptureIntent()) {
|
||||||
hideIntentButtons()
|
hideIntentButtons()
|
||||||
val output = intent.extras?.get(MediaStore.EXTRA_OUTPUT)
|
val output = intent.extras?.get(MediaStore.EXTRA_OUTPUT)
|
||||||
if (output != null && output is Uri) {
|
if (output != null && output is Uri) {
|
||||||
mPreview?.setTargetUri(output)
|
mPreview?.setTargetUri(output)
|
||||||
}
|
}
|
||||||
} else if (intent?.action == MediaStore.ACTION_VIDEO_CAPTURE) {
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun checkVideoCaptureIntent() {
|
||||||
|
if (intent?.action == MediaStore.ACTION_VIDEO_CAPTURE) {
|
||||||
mIsVideoCaptureIntent = true
|
mIsVideoCaptureIntent = true
|
||||||
mIsInPhotoMode = false
|
mIsInPhotoMode = false
|
||||||
hideIntentButtons()
|
hideIntentButtons()
|
||||||
shutter.setImageResource(R.drawable.ic_video_rec)
|
shutter.setImageResource(R.drawable.ic_video_rec)
|
||||||
}
|
}
|
||||||
mPreview?.setIsImageCaptureIntent(isImageCaptureIntent())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isImageCaptureIntent() = intent?.action == MediaStore.ACTION_IMAGE_CAPTURE || intent?.action == MediaStore.ACTION_IMAGE_CAPTURE_SECURE
|
|
||||||
|
|
||||||
private fun initializeCamera() {
|
private fun initializeCamera() {
|
||||||
setContentView(R.layout.activity_main)
|
setContentView(R.layout.activity_main)
|
||||||
initButtons()
|
initButtons()
|
||||||
|
|
||||||
handleIntent()
|
|
||||||
camera_surface_view.beVisibleIf(!isLollipopPlus())
|
camera_surface_view.beVisibleIf(!isLollipopPlus())
|
||||||
camera_texture_view.beVisibleIf(isLollipopPlus())
|
camera_texture_view.beVisibleIf(isLollipopPlus())
|
||||||
|
|
||||||
(btn_holder.layoutParams as RelativeLayout.LayoutParams).setMargins(0, 0, 0, (navBarHeight + resources.getDimension(R.dimen.activity_margin)).toInt())
|
(btn_holder.layoutParams as RelativeLayout.LayoutParams).setMargins(0, 0, 0, (navBarHeight + resources.getDimension(R.dimen.activity_margin)).toInt())
|
||||||
|
|
||||||
|
checkVideoCaptureIntent()
|
||||||
mPreview = if (isLollipopPlus()) PreviewCameraTwo(this, camera_texture_view, mIsInPhotoMode) else PreviewCameraOne(this, camera_surface_view)
|
mPreview = if (isLollipopPlus()) PreviewCameraTwo(this, camera_texture_view, mIsInPhotoMode) else PreviewCameraOne(this, camera_surface_view)
|
||||||
view_holder.addView(mPreview as ViewGroup)
|
view_holder.addView(mPreview as ViewGroup)
|
||||||
|
checkImageCaptureIntent()
|
||||||
|
mPreview?.setIsImageCaptureIntent(isImageCaptureIntent())
|
||||||
|
|
||||||
val imageDrawable = if (config.lastUsedCamera == mCameraImpl.getBackCameraId().toString()) R.drawable.ic_camera_front else R.drawable.ic_camera_rear
|
val imageDrawable = if (config.lastUsedCamera == mCameraImpl.getBackCameraId().toString()) R.drawable.ic_camera_front else R.drawable.ic_camera_rear
|
||||||
toggle_camera.setImageResource(imageDrawable)
|
toggle_camera.setImageResource(imageDrawable)
|
||||||
|
|
Loading…
Reference in New Issue