Bug fixes & Allow export to SD cards
This commit is contained in:
parent
9d0a6e170e
commit
06efdb61c3
@ -37,6 +37,7 @@ class OpenActivity : BaseActivity() {
|
|||||||
private lateinit var fingerprintPasswordHashSaver: FingerprintPasswordHashSaver
|
private lateinit var fingerprintPasswordHashSaver: FingerprintPasswordHashSaver
|
||||||
private lateinit var rootCipherDir: String
|
private lateinit var rootCipherDir: String
|
||||||
private var sessionID = -1
|
private var sessionID = -1
|
||||||
|
private var isStartingActivity = false
|
||||||
private var isFinishingIntentionally = false
|
private var isFinishingIntentionally = false
|
||||||
private var usf_fingerprint = false
|
private var usf_fingerprint = false
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
@ -83,6 +84,7 @@ class OpenActivity : BaseActivity() {
|
|||||||
|
|
||||||
fun pickDirectory(view: View?) {
|
fun pickDirectory(view: View?) {
|
||||||
val i = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE)
|
val i = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE)
|
||||||
|
isStartingActivity = true
|
||||||
startActivityForResult(i, PICK_DIRECTORY_REQUEST_CODE)
|
startActivityForResult(i, PICK_DIRECTORY_REQUEST_CODE)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,8 +239,12 @@ class OpenActivity : BaseActivity() {
|
|||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
super.onPause()
|
super.onPause()
|
||||||
if (intent.action == "pick"){
|
if (intent.action == "pick"){
|
||||||
|
if (isStartingActivity){
|
||||||
|
isStartingActivity = false
|
||||||
|
} else {
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (::fingerprintPasswordHashSaver.isInitialized && fingerprintPasswordHashSaver.isListening){
|
if (::fingerprintPasswordHashSaver.isInitialized && fingerprintPasswordHashSaver.isListening){
|
||||||
fingerprintPasswordHashSaver.stopListening()
|
fingerprintPasswordHashSaver.stopListening()
|
||||||
if (fingerprintPasswordHashSaver.fingerprintFragment.isAdded){
|
if (fingerprintPasswordHashSaver.fingerprintFragment.isAdded){
|
||||||
|
@ -144,11 +144,10 @@ open class BaseExplorerActivity : BaseActivity() {
|
|||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
invalidateOptionsMenu()
|
invalidateOptionsMenu()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected open fun onExplorerItemLongClick(position: Int) {
|
protected open fun onExplorerItemLongClick(position: Int) {
|
||||||
explorerAdapter.onItemLongClick(position)
|
explorerAdapter.onItemLongClick(position)
|
||||||
@ -425,10 +424,14 @@ open class BaseExplorerActivity : BaseActivity() {
|
|||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
super.onPause()
|
super.onPause()
|
||||||
if (!isChangingConfigurations && !isStartingActivity){
|
if (!isChangingConfigurations){
|
||||||
|
if (isStartingActivity){
|
||||||
|
isStartingActivity = false
|
||||||
|
} else {
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
|
@ -11,6 +11,7 @@ import android.view.WindowManager
|
|||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.documentfile.provider.DocumentFile
|
||||||
import sushi.hardcore.droidfs.CameraActivity
|
import sushi.hardcore.droidfs.CameraActivity
|
||||||
import sushi.hardcore.droidfs.OpenActivity
|
import sushi.hardcore.droidfs.OpenActivity
|
||||||
import sushi.hardcore.droidfs.R
|
import sushi.hardcore.droidfs.R
|
||||||
@ -225,16 +226,17 @@ class ExplorerActivity : BaseExplorerActivity() {
|
|||||||
if (resultCode == Activity.RESULT_OK && data != null) {
|
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||||
object : LoadingTask(this, R.string.loading_msg_export){
|
object : LoadingTask(this, R.string.loading_msg_export){
|
||||||
override fun doTask(activity: AppCompatActivity) {
|
override fun doTask(activity: AppCompatActivity) {
|
||||||
val uri = data.data
|
data.data?.let {uri ->
|
||||||
val outputDir = PathUtils.getFullPathFromTreeUri(uri, activity)
|
contentResolver.takePersistableUriPermission(uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
|
||||||
|
DocumentFile.fromTreeUri(activity, uri)?.let { treeDocumentFile ->
|
||||||
var failedItem: String? = null
|
var failedItem: String? = null
|
||||||
for (i in explorerAdapter.selectedItems) {
|
for (i in explorerAdapter.selectedItems) {
|
||||||
val element = explorerAdapter.getItem(i)
|
val element = explorerAdapter.getItem(i)
|
||||||
val fullPath = PathUtils.path_join(currentDirectoryPath, element.name)
|
val fullPath = PathUtils.path_join(currentDirectoryPath, element.name)
|
||||||
failedItem = if (element.isDirectory) {
|
failedItem = if (element.isDirectory) {
|
||||||
recursiveExportDirectory(fullPath, outputDir)
|
recursiveExportDirectory(fullPath, treeDocumentFile)
|
||||||
} else {
|
} else {
|
||||||
if (gocryptfsVolume.exportFile(fullPath, PathUtils.path_join(outputDir, element.name))) null else fullPath
|
if (exportFileInto(fullPath, treeDocumentFile)) null else fullPath
|
||||||
}
|
}
|
||||||
if (failedItem != null) {
|
if (failedItem != null) {
|
||||||
stopTask {
|
stopTask {
|
||||||
@ -257,6 +259,8 @@ class ExplorerActivity : BaseExplorerActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
override fun doFinally(activity: AppCompatActivity) {
|
override fun doFinally(activity: AppCompatActivity) {
|
||||||
unselectAll()
|
unselectAll()
|
||||||
}
|
}
|
||||||
@ -631,7 +635,7 @@ class ExplorerActivity : BaseExplorerActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun recursiveImportDirectoryFromOtherVolume(remote_gocryptfsVolume: GocryptfsVolume, remote_directory_path: String, outputPath: String): String? {
|
private fun recursiveImportDirectoryFromOtherVolume(remote_gocryptfsVolume: GocryptfsVolume, remote_directory_path: String, outputPath: String): String? {
|
||||||
val mappedElements = gocryptfsVolume.recursiveMapFiles(remote_directory_path)
|
val mappedElements = remote_gocryptfsVolume.recursiveMapFiles(remote_directory_path)
|
||||||
val dstDirectoryPath = checkPathOverwrite(PathUtils.path_join(outputPath, File(remote_directory_path).name), true)
|
val dstDirectoryPath = checkPathOverwrite(PathUtils.path_join(outputPath, File(remote_directory_path).name), true)
|
||||||
if (dstDirectoryPath == null){
|
if (dstDirectoryPath == null){
|
||||||
return ""
|
return ""
|
||||||
@ -663,23 +667,34 @@ class ExplorerActivity : BaseExplorerActivity() {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun recursiveExportDirectory(plain_directory_path: String, output_dir: String?): String? {
|
private fun exportFileInto(srcPath: String, treeDocumentFile: DocumentFile): Boolean {
|
||||||
if (File(PathUtils.path_join(output_dir, plain_directory_path)).mkdir()) {
|
val outputStream = treeDocumentFile.createFile("*/*", File(srcPath).name)?.uri?.let {
|
||||||
|
contentResolver.openOutputStream(it)
|
||||||
|
}
|
||||||
|
return if (outputStream != null){
|
||||||
|
gocryptfsVolume.exportFile(srcPath, outputStream)
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun recursiveExportDirectory(plain_directory_path: String, treeDocumentFile: DocumentFile): String? {
|
||||||
|
treeDocumentFile.createDirectory(plain_directory_path)?.let {childTree ->
|
||||||
val explorerElements = gocryptfsVolume.listDir(plain_directory_path)
|
val explorerElements = gocryptfsVolume.listDir(plain_directory_path)
|
||||||
for (e in explorerElements) {
|
for (e in explorerElements) {
|
||||||
val fullPath = PathUtils.path_join(plain_directory_path, e.name)
|
val fullPath = PathUtils.path_join(plain_directory_path, e.name)
|
||||||
if (e.isDirectory) {
|
if (e.isDirectory) {
|
||||||
val failedItem = recursiveExportDirectory(fullPath, output_dir)
|
val failedItem = recursiveExportDirectory(fullPath, childTree)
|
||||||
failedItem?.let { return it }
|
failedItem?.let { return it }
|
||||||
} else {
|
} else {
|
||||||
if (!gocryptfsVolume.exportFile(fullPath, PathUtils.path_join(output_dir, fullPath))) {
|
if (!exportFileInto(fullPath, childTree)){
|
||||||
return fullPath
|
return fullPath
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
return output_dir
|
return treeDocumentFile.name
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun recursiveRemoveDirectory(plain_directory_path: String): String? {
|
private fun recursiveRemoveDirectory(plain_directory_path: String): String? {
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
app:showAsAction="ifRoom"
|
app:showAsAction="ifRoom"
|
||||||
android:visible="false"
|
android:visible="false"
|
||||||
android:icon="@drawable/icon_decrypt"
|
android:icon="@drawable/icon_decrypt"
|
||||||
android:title="@string/decrypt"/>
|
android:title="@string/decrypt_files"/>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/share"
|
android:id="@+id/share"
|
||||||
|
@ -138,7 +138,7 @@
|
|||||||
<string name="github">GitHub</string>
|
<string name="github">GitHub</string>
|
||||||
<string name="github_summary">Want to read the documentation, request feature, report bug, read the source code… Check the DroidFS\'s repository !</string>
|
<string name="github_summary">Want to read the documentation, request feature, report bug, read the source code… Check the DroidFS\'s repository !</string>
|
||||||
<string name="share">Share</string>
|
<string name="share">Share</string>
|
||||||
<string name="decrypt">Decrypt</string>
|
<string name="decrypt_files">Export/Decrypt</string>
|
||||||
<string name="loading_msg_copy">Copying selected items…</string>
|
<string name="loading_msg_copy">Copying selected items…</string>
|
||||||
<string name="copy_failed">Copy of %s failed.</string>
|
<string name="copy_failed">Copy of %s failed.</string>
|
||||||
<string name="copy_success_msg">The selected items have been successfully copied.</string>
|
<string name="copy_success_msg">The selected items have been successfully copied.</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user