adding some crashfixes
This commit is contained in:
parent
9734743705
commit
9928ed46c1
|
@ -57,6 +57,6 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.simplemobiletools:commons:5.30.12'
|
implementation 'com.simplemobiletools:commons:5.31.25'
|
||||||
implementation 'androidx.documentfile:documentfile:1.0.1'
|
implementation 'androidx.documentfile:documentfile:1.0.1'
|
||||||
}
|
}
|
||||||
|
|
|
@ -448,7 +448,7 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showToggleCameraIfNeeded() {
|
private fun showToggleCameraIfNeeded() {
|
||||||
toggle_camera?.beInvisibleIf(mCameraImpl.getCountOfCameras() <= 1)
|
toggle_camera?.beInvisibleIf(mCameraImpl.getCountOfCameras() ?: 1 <= 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun hasStorageAndCameraPermissions() = hasPermission(PERMISSION_WRITE_STORAGE) && hasPermission(PERMISSION_CAMERA)
|
private fun hasStorageAndCameraPermissions() = hasPermission(PERMISSION_WRITE_STORAGE) && hasPermission(PERMISSION_CAMERA)
|
||||||
|
|
|
@ -9,8 +9,12 @@ class MyCameraImpl(val context: Context) {
|
||||||
|
|
||||||
fun getBackCameraId() = CameraCharacteristics.LENS_FACING_BACK
|
fun getBackCameraId() = CameraCharacteristics.LENS_FACING_BACK
|
||||||
|
|
||||||
fun getCountOfCameras(): Int {
|
fun getCountOfCameras(): Int? {
|
||||||
val manager = context.getSystemService(Context.CAMERA_SERVICE) as CameraManager
|
return try {
|
||||||
return manager.cameraIdList.size
|
val manager = context.getSystemService(Context.CAMERA_SERVICE) as CameraManager
|
||||||
|
manager.cameraIdList.size
|
||||||
|
} catch (e: Exception) {
|
||||||
|
null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -577,6 +577,10 @@ class CameraPreview : ViewGroup, TextureView.SurfaceTextureListener, MyPreview {
|
||||||
mRotationAtCapture = mActivity.mLastHandledOrientation
|
mRotationAtCapture = mActivity.mLastHandledOrientation
|
||||||
val jpegOrientation = (mSensorOrientation + compensateDeviceRotation(mRotationAtCapture)) % 360
|
val jpegOrientation = (mSensorOrientation + compensateDeviceRotation(mRotationAtCapture)) % 360
|
||||||
val captureBuilder = mCameraDevice!!.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE).apply {
|
val captureBuilder = mCameraDevice!!.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE).apply {
|
||||||
|
if (mImageReader!!.surface == null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
addTarget(mImageReader!!.surface)
|
addTarget(mImageReader!!.surface)
|
||||||
setFlashAndExposure(this)
|
setFlashAndExposure(this)
|
||||||
set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE)
|
set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE)
|
||||||
|
@ -605,7 +609,7 @@ class CameraPreview : ViewGroup, TextureView.SurfaceTextureListener, MyPreview {
|
||||||
abortCaptures()
|
abortCaptures()
|
||||||
capture(captureBuilder.build(), captureCallback, null)
|
capture(captureBuilder.build(), captureCallback, null)
|
||||||
}
|
}
|
||||||
} catch (e: CameraAccessException) {
|
} catch (e: Exception) {
|
||||||
mActivity.showErrorToast("Capture picture $e")
|
mActivity.showErrorToast("Capture picture $e")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -845,7 +849,12 @@ class CameraPreview : ViewGroup, TextureView.SurfaceTextureListener, MyPreview {
|
||||||
updatePreview()
|
updatePreview()
|
||||||
mIsRecording = true
|
mIsRecording = true
|
||||||
mActivity.runOnUiThread {
|
mActivity.runOnUiThread {
|
||||||
mMediaRecorder?.start()
|
try {
|
||||||
|
mMediaRecorder?.start()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
mActivity.showErrorToast(e)
|
||||||
|
mCameraState = STATE_PREVIEW
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mActivity.setRecordingState(true)
|
mActivity.setRecordingState(true)
|
||||||
mCameraState = STATE_RECORDING
|
mCameraState = STATE_RECORDING
|
||||||
|
|
|
@ -9,7 +9,7 @@ buildscript {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:4.0.1'
|
classpath 'com.android.tools.build:gradle:4.1.0'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#Sat Sep 05 21:36:09 CEST 2020
|
#Sat Nov 07 19:34:59 CET 2020
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
|
||||||
|
|
Loading…
Reference in New Issue