Don't close volume just after creating it

This commit is contained in:
Matéo Duparc 2021-03-17 15:49:59 +01:00
parent d570d9b0ef
commit e92804ae34
Signed by untrusted user: hardcoresushi
GPG Key ID: 007F84120107191E
2 changed files with 7 additions and 5 deletions

View File

@ -198,7 +198,7 @@ class CameraActivity : BaseActivity(), SensorOrientationListener.Listener {
if (gocryptfsVolume.importFile(ByteArrayInputStream(outputBuff.toByteArray()), PathUtils.pathJoin(outputDirectory, fileName))){
Toast.makeText(applicationContext, getString(R.string.picture_save_success, fileName), Toast.LENGTH_SHORT).show()
} else {
ColoredAlertDialogBuilder(applicationContext)
ColoredAlertDialogBuilder(this@CameraActivity)
.setTitle(R.string.error)
.setMessage(R.string.picture_save_failed)
.setCancelable(false)

View File

@ -21,6 +21,7 @@ class CreateActivity : VolumeActionActivity() {
private const val PICK_DIRECTORY_REQUEST_CODE = 1
}
private var sessionID = -1
private var isStartingExplorer = false
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_create)
@ -129,7 +130,7 @@ class CreateActivity : VolumeActionActivity() {
sessionID = GocryptfsVolume.init(currentVolumePath, password, null, returnedHash)
if (sessionID != -1) {
if (checkbox_remember_path.isChecked) {
if (volumeDatabase.isVolumeSaved(currentVolumeName)) {
if (volumeDatabase.isVolumeSaved(currentVolumeName)) { //cleaning old saved path
volumeDatabase.removeVolume(Volume(currentVolumeName))
}
volumeDatabase.saveVolume(Volume(currentVolumeName, switch_hidden_volume.isChecked))
@ -172,10 +173,11 @@ class CreateActivity : VolumeActionActivity() {
.setMessage(R.string.success_volume_create_msg)
.setCancelable(false)
.setPositiveButton(R.string.ok) { _, _ ->
val intent = Intent(applicationContext, ExplorerActivity::class.java)
val intent = Intent(this, ExplorerActivity::class.java)
intent.putExtra("sessionID", sessionID)
intent.putExtra("volume_name", File(currentVolumeName).name)
startActivity(intent)
isStartingExplorer = true
finish()
}
.show()
@ -190,7 +192,7 @@ class CreateActivity : VolumeActionActivity() {
override fun onPause() {
super.onPause()
//Closing volume if leaving activity while showing dialog
if (sessionID != -1){
if (sessionID != -1 && !isStartingExplorer) {
GocryptfsVolume(sessionID).close()
finish()
}