Take photo on read-only volume crash fix
This commit is contained in:
parent
73189d9d32
commit
b23cb7b8ce
@ -1,6 +1,7 @@
|
|||||||
package sushi.hardcore.droidfs
|
package sushi.hardcore.droidfs
|
||||||
|
|
||||||
import android.Manifest
|
import android.Manifest
|
||||||
|
import android.content.Context
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.InputType
|
import android.text.InputType
|
||||||
@ -56,24 +57,29 @@ class CameraActivity : BaseActivity(), SensorOrientationListener.Listener {
|
|||||||
private lateinit var outputDirectory: String
|
private lateinit var outputDirectory: String
|
||||||
private lateinit var fileName: String
|
private lateinit var fileName: String
|
||||||
private var isFinishingIntentionally = false
|
private var isFinishingIntentionally = false
|
||||||
|
private lateinit var context: Context
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_camera)
|
setContentView(R.layout.activity_camera)
|
||||||
gocryptfsVolume = GocryptfsVolume(intent.getIntExtra("sessionID", -1))
|
gocryptfsVolume = GocryptfsVolume(intent.getIntExtra("sessionID", -1))
|
||||||
outputDirectory = intent.getStringExtra("path")!!
|
outputDirectory = intent.getStringExtra("path")!!
|
||||||
|
context = this
|
||||||
camera.setLifecycleOwner(this)
|
camera.setLifecycleOwner(this)
|
||||||
camera.addCameraListener(object: CameraListener(){
|
camera.addCameraListener(object: CameraListener(){
|
||||||
override fun onPictureTaken(result: PictureResult) {
|
override fun onPictureTaken(result: PictureResult) {
|
||||||
take_photo_button.onPhotoTaken()
|
take_photo_button.onPhotoTaken()
|
||||||
val inputStream = ByteArrayInputStream(result.data)
|
val inputStream = ByteArrayInputStream(result.data)
|
||||||
if (gocryptfsVolume.importFile(inputStream, PathUtils.pathJoin(outputDirectory, fileName))){
|
if (gocryptfsVolume.importFile(inputStream, PathUtils.pathJoin(outputDirectory, fileName))){
|
||||||
Toast.makeText(applicationContext, getString(R.string.picture_save_success, fileName), Toast.LENGTH_SHORT).show()
|
Toast.makeText(context, getString(R.string.picture_save_success, fileName), Toast.LENGTH_SHORT).show()
|
||||||
} else {
|
} else {
|
||||||
ColoredAlertDialogBuilder(applicationContext)
|
ColoredAlertDialogBuilder(context)
|
||||||
.setTitle(R.string.error)
|
.setTitle(R.string.error)
|
||||||
.setMessage(R.string.picture_save_failed)
|
.setMessage(R.string.picture_save_failed)
|
||||||
.setCancelable(false)
|
.setCancelable(false)
|
||||||
.setPositiveButton(R.string.ok) { _, _ -> finish() }
|
.setPositiveButton(R.string.ok) { _, _ ->
|
||||||
|
isFinishingIntentionally = true
|
||||||
|
finish()
|
||||||
|
}
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user