create a PreviewCameraTwo to be used with Camera2 API on Android 5+

This commit is contained in:
tibbi 2018-05-28 20:12:02 +02:00
parent 0d71a4492b
commit 22d463f0e0
2 changed files with 74 additions and 1 deletions

View File

@ -24,6 +24,7 @@ import com.simplemobiletools.camera.interfaces.MyPreview
import com.simplemobiletools.camera.views.FocusCircleView
import com.simplemobiletools.camera.views.PreviewCameraOne
import com.simplemobiletools.camera.views.PreviewCameraOne.PreviewListener
import com.simplemobiletools.camera.views.PreviewCameraTwo
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.*
import com.simplemobiletools.commons.models.Release
@ -190,7 +191,7 @@ class MainActivity : SimpleActivity(), PreviewListener, PhotoProcessor.MediaSave
(btn_holder.layoutParams as RelativeLayout.LayoutParams).setMargins(0, 0, 0, (navBarHeight + resources.getDimension(R.dimen.activity_margin)).toInt())
mPreview = PreviewCameraOne(this, camera_surface_view, this)
mPreview = if (isLollipopPlus()) PreviewCameraTwo(this) else PreviewCameraOne(this, camera_surface_view, this)
view_holder.addView(mPreview as ViewGroup)
val imageDrawable = if (config.lastUsedCamera == mCameraImpl.getBackCameraId()) R.drawable.ic_camera_front else R.drawable.ic_camera_rear

View File

@ -0,0 +1,72 @@
package com.simplemobiletools.camera.views
import android.content.Context
import android.net.Uri
import android.view.ViewGroup
import com.simplemobiletools.camera.helpers.STATE_PREVIEW
import com.simplemobiletools.camera.interfaces.MyPreview
class PreviewCameraTwo(context: Context) : ViewGroup(context), MyPreview {
private var mTargetUri: Uri? = null
private var mIsImageCaptureIntent = false
override fun setTargetUri(uri: Uri) {
mTargetUri = uri
}
override fun setIsImageCaptureIntent(isImageCaptureIntent: Boolean) {
mIsImageCaptureIntent = isImageCaptureIntent
}
override fun setFlashlightState(state: Int) {
}
override fun setCamera(cameraId: Int): Boolean {
return false
}
override fun getCameraState(): Int {
return STATE_PREVIEW
}
override fun releaseCamera() {
}
override fun showChangeResolutionDialog() {
}
override fun toggleFrontBackCamera() {
}
override fun toggleFlashlight() {
}
override fun tryTakePicture() {
}
override fun toggleRecording(): Boolean {
return false
}
override fun tryInitVideoMode() {
}
override fun initPhotoMode() {
}
override fun initVideoMode(): Boolean {
return false
}
override fun checkFlashlight() {
}
override fun deviceOrientationChanged() {
}
override fun resumeCamera(): Boolean {
return false
}
override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {}
}