Checking volume paths before opening
This commit is contained in:
parent
7fad08ae66
commit
b482b96322
@ -110,7 +110,14 @@ class ChangePasswordActivity : BaseActivity() {
|
||||
if (rootCipherDir.isEmpty()) {
|
||||
Toast.makeText(this, R.string.enter_volume_path, Toast.LENGTH_SHORT).show()
|
||||
} else {
|
||||
if (!File(rootCipherDir).canWrite()){
|
||||
val rootCipherDirFile = File(rootCipherDir)
|
||||
if (!GocryptfsVolume.isGocryptfsVolume(rootCipherDirFile)){
|
||||
ColoredAlertDialogBuilder(this)
|
||||
.setTitle(R.string.error)
|
||||
.setMessage(R.string.error_not_a_volume)
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.show()
|
||||
} else if (!rootCipherDirFile.canWrite()){
|
||||
ColoredAlertDialogBuilder(this)
|
||||
.setTitle(R.string.warning)
|
||||
.setMessage(R.string.change_pwd_cant_write_error_msg)
|
||||
|
@ -6,6 +6,7 @@ import java.io.File
|
||||
class ConstValues {
|
||||
companion object {
|
||||
const val creator = "DroidFS"
|
||||
const val gocryptfsConfFilename = "gocryptfs.conf"
|
||||
const val saved_volumes_key = "saved_volumes"
|
||||
const val sort_order_key = "sort_order"
|
||||
val fakeUri: Uri = Uri.parse("fakeuri://droidfs")
|
||||
|
@ -115,7 +115,14 @@ class OpenActivity : BaseActivity() {
|
||||
if (rootCipherDir.isEmpty()) {
|
||||
Toast.makeText(this, R.string.enter_volume_path, Toast.LENGTH_SHORT).show()
|
||||
} else {
|
||||
if (!File(rootCipherDir).canWrite()){
|
||||
val rootCipherDirFile = File(rootCipherDir)
|
||||
if (!GocryptfsVolume.isGocryptfsVolume(rootCipherDirFile)){
|
||||
ColoredAlertDialogBuilder(this)
|
||||
.setTitle(R.string.error)
|
||||
.setMessage(R.string.error_not_a_volume)
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.show()
|
||||
} else if (!rootCipherDirFile.canWrite()) {
|
||||
ColoredAlertDialogBuilder(this)
|
||||
.setTitle(R.string.warning)
|
||||
.setMessage(R.string.open_cant_write_warning)
|
||||
|
@ -2,7 +2,9 @@ package sushi.hardcore.droidfs.util
|
||||
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import sushi.hardcore.droidfs.ConstValues
|
||||
import sushi.hardcore.droidfs.explorers.ExplorerElement
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.io.InputStream
|
||||
import java.io.OutputStream
|
||||
@ -32,6 +34,13 @@ class GocryptfsVolume(var sessionID: Int) {
|
||||
external fun init(root_cipher_dir: String, password: CharArray?, givenHash: ByteArray?, returnedHash: ByteArray?): Int
|
||||
external fun changePassword(root_cipher_dir: String, old_password: CharArray?, givenHash: ByteArray?, new_password: CharArray, returnedHash: ByteArray?): Boolean
|
||||
|
||||
fun isGocryptfsVolume(path: File): Boolean {
|
||||
if (path.isDirectory){
|
||||
return File(path, ConstValues.gocryptfsConfFilename).isFile
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
init {
|
||||
System.loadLibrary("gocryptfs_jni")
|
||||
}
|
||||
|
@ -33,7 +33,7 @@
|
||||
<string name="success_volume_create_msg">The volume has been successfully created.</string>
|
||||
<string name="create_volume_failed">The volume creation has failed.</string>
|
||||
<string name="open_volume_failed">Open failed</string>
|
||||
<string name="open_volume_failed_msg">Failed to open the volume. Check the selected volume path and the entered password.</string>
|
||||
<string name="open_volume_failed_msg">Failed to open the volume. Please check your password.</string>
|
||||
<string name="share_chooser">Share File</string>
|
||||
<string name="storage_unavailable">Storage unavailable</string>
|
||||
<string name="storage_unavailable_msg">DroidFS can\'t work without storage access.</string>
|
||||
@ -68,7 +68,7 @@
|
||||
<string name="new_password_confirmation">New Password (confirmation):</string>
|
||||
<string name="success_change_password">Password successfully changed !</string>
|
||||
<string name="success_change_password_msg">The volume\'s password has been successfully changed.</string>
|
||||
<string name="change_password_failed">Failed to change the volume\'s password. Check the selected volume path and the entered old password.</string>
|
||||
<string name="change_password_failed">Operation failed. Please check your old password.</string>
|
||||
<string name="share_menu_label">Encrypt with DroidFS</string>
|
||||
<string name="share_intent_parsing_failed">Failed to handle the share request.</string>
|
||||
<string name="listdir_null_error_msg">Unable to access this directory</string>
|
||||
@ -177,4 +177,5 @@
|
||||
<string name="image_saved_successfully">Image changes successfully saved.</string>
|
||||
<string name="bitmap_compress_failed">Failed to compress the bitmap.</string>
|
||||
<string name="file_write_failed">Failed to write the file.</string>
|
||||
<string name="error_not_a_volume">Gocryptfs volume not recognized. Please check the selected path.</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user