From e783e02398bd00fb2b90990c02db011be5a82958 Mon Sep 17 00:00:00 2001 From: Hardcore Sushi Date: Thu, 31 Dec 2020 16:24:04 +0100 Subject: [PATCH] Toast on file operation success & handle usf_keep_open on CameraActivity --- app/build.gradle | 6 ++-- .../sushi/hardcore/droidfs/CameraActivity.kt | 10 +++++-- .../droidfs/explorers/BaseExplorerActivity.kt | 1 - .../droidfs/explorers/ExplorerActivity.kt | 30 ++++++------------- .../file_viewers/FileViewerActivity.kt | 2 +- app/src/main/res/values/strings.xml | 2 -- 6 files changed, 21 insertions(+), 30 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 05e61a1..7f6cd3c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -4,7 +4,7 @@ apply plugin: 'kotlin-android-extensions' android { compileSdkVersion 29 - buildToolsVersion "30.0.2" + buildToolsVersion "30.0.3" ndkVersion '21.3.6528147' compileOptions { @@ -15,8 +15,8 @@ android { applicationId "sushi.hardcore.droidfs" minSdkVersion 21 targetSdkVersion 29 - versionCode 7 - versionName "1.3.0" + versionCode 8 + versionName "1.4.0" ndk { abiFilters 'x86_64', 'armeabi-v7a', 'arm64-v8a' diff --git a/app/src/main/java/sushi/hardcore/droidfs/CameraActivity.kt b/app/src/main/java/sushi/hardcore/droidfs/CameraActivity.kt index bb58530..1750beb 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/CameraActivity.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/CameraActivity.kt @@ -9,6 +9,7 @@ import android.os.Build import android.os.Bundle import android.text.InputType import android.util.DisplayMetrics +import android.util.Log import android.util.Size import android.view.MotionEvent import android.view.ScaleGestureDetector @@ -55,6 +56,7 @@ class CameraActivity : BaseActivity(), SensorOrientationListener.Listener { image_timer.setImageResource(R.drawable.icon_timer_off) } } + private var usf_keep_open = false private lateinit var sensorOrientationListener: SensorOrientationListener private var previousOrientation: Float = 0f private lateinit var orientedIcons: List @@ -69,6 +71,7 @@ class CameraActivity : BaseActivity(), SensorOrientationListener.Listener { private var isBackCamera = true override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + usf_keep_open = sharedPrefs.getBoolean("usf_keep_open", false) setContentView(R.layout.activity_camera) gocryptfsVolume = GocryptfsVolume(intent.getIntExtra("sessionID", -1)) outputDirectory = intent.getStringExtra("path")!! @@ -319,7 +322,7 @@ class CameraActivity : BaseActivity(), SensorOrientationListener.Listener { override fun onStop() { super.onStop() - if (!isFinishing){ + if (!isFinishing && !usf_keep_open){ finish() } } @@ -327,7 +330,10 @@ class CameraActivity : BaseActivity(), SensorOrientationListener.Listener { override fun onPause() { super.onPause() sensorOrientationListener.remove(this) - if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED){ //if not asking for permission + if ( + (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) //not asking for permission + && !usf_keep_open + ){ finish() } } diff --git a/app/src/main/java/sushi/hardcore/droidfs/explorers/BaseExplorerActivity.kt b/app/src/main/java/sushi/hardcore/droidfs/explorers/BaseExplorerActivity.kt index bbcca70..ec2e705 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/explorers/BaseExplorerActivity.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/explorers/BaseExplorerActivity.kt @@ -65,7 +65,6 @@ open class BaseExplorerActivity : BaseActivity() { super.onCreate(savedInstanceState) usf_open = sharedPrefs.getBoolean("usf_open", false) usf_keep_open = sharedPrefs.getBoolean("usf_keep_open", false) - val intent = intent volumeName = intent.getStringExtra("volume_name") ?: "" val sessionID = intent.getIntExtra("sessionID", -1) gocryptfsVolume = GocryptfsVolume(sessionID) diff --git a/app/src/main/java/sushi/hardcore/droidfs/explorers/ExplorerActivity.kt b/app/src/main/java/sushi/hardcore/droidfs/explorers/ExplorerActivity.kt index 8b10cec..306d60d 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/explorers/ExplorerActivity.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/explorers/ExplorerActivity.kt @@ -160,11 +160,7 @@ class ExplorerActivity : BaseExplorerActivity() { fileOperationService.wipeUris(uris) { errorMsg -> runOnUiThread { if (errorMsg == null){ - ColoredAlertDialogBuilder(this) - .setTitle(R.string.wipe_successful) - .setMessage(R.string.wipe_success_msg) - .setPositiveButton(R.string.ok, null) - .show() + Toast.makeText(this, R.string.wipe_successful, Toast.LENGTH_SHORT).show() } else { ColoredAlertDialogBuilder(this) .setTitle(R.string.error) @@ -194,11 +190,7 @@ class ExplorerActivity : BaseExplorerActivity() { fileOperationService.exportFiles(uri, explorerAdapter.selectedItems.map { i -> explorerElements[i] }){ failedItem -> runOnUiThread { if (failedItem == null){ - ColoredAlertDialogBuilder(this) - .setTitle(R.string.success_export) - .setMessage(R.string.success_export_msg) - .setPositiveButton(R.string.ok, null) - .show() + Toast.makeText(this, R.string.success_export, Toast.LENGTH_SHORT).show() } else { ColoredAlertDialogBuilder(this) .setTitle(R.string.error) @@ -249,11 +241,7 @@ class ExplorerActivity : BaseExplorerActivity() { fileOperationService.copyElements(items, remoteGocryptfsVolume){ failedItem -> runOnUiThread { if (failedItem == null){ - ColoredAlertDialogBuilder(this) - .setTitle(R.string.success_import) - .setMessage(R.string.success_import_msg) - .setPositiveButton(R.string.ok, null) - .show() + Toast.makeText(this, R.string.success_import, Toast.LENGTH_SHORT).show() } else { ColoredAlertDialogBuilder(this) .setTitle(R.string.error) @@ -344,14 +332,14 @@ class ExplorerActivity : BaseExplorerActivity() { items?.let { fileOperationService.copyElements(it.toMutableList() as ArrayList){ failedItem -> runOnUiThread { - if (failedItem != null){ + if (failedItem == null){ + Toast.makeText(this, R.string.copy_success, Toast.LENGTH_SHORT).show() + } else { ColoredAlertDialogBuilder(this) .setTitle(R.string.error) .setMessage(getString(R.string.copy_failed, failedItem)) .setPositiveButton(R.string.ok, null) .show() - } else { - Toast.makeText(this, R.string.copy_success, Toast.LENGTH_SHORT).show() } setCurrentPath(currentDirectoryPath) } @@ -366,14 +354,14 @@ class ExplorerActivity : BaseExplorerActivity() { items?.let { fileOperationService.moveElements(it.toMutableList() as ArrayList){ failedItem -> runOnUiThread { - if (failedItem != null){ + if (failedItem == null){ + Toast.makeText(this, R.string.move_success, Toast.LENGTH_SHORT).show() + } else { ColoredAlertDialogBuilder(this) .setTitle(R.string.error) .setMessage(getString(R.string.move_failed, failedItem)) .setPositiveButton(R.string.ok, null) .show() - } else { - Toast.makeText(this, R.string.move_success, Toast.LENGTH_SHORT).show() } setCurrentPath(currentDirectoryPath) } diff --git a/app/src/main/java/sushi/hardcore/droidfs/file_viewers/FileViewerActivity.kt b/app/src/main/java/sushi/hardcore/droidfs/file_viewers/FileViewerActivity.kt index 12dae83..aa03d4e 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/file_viewers/FileViewerActivity.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/file_viewers/FileViewerActivity.kt @@ -12,7 +12,7 @@ abstract class FileViewerActivity: BaseActivity() { lateinit var gocryptfsVolume: GocryptfsVolume lateinit var filePath: String private var isFinishingIntentionally = false - protected var usf_keep_open = false + private var usf_keep_open = false override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) filePath = intent.getStringExtra("path")!! diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5273fb3..90bb5d6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -26,7 +26,6 @@ Import of %s failed. Export of %s failed. Export successful ! - The selected files have been successfully exported. Deletion of %s failed. Passwords don\'t match The selected directory isn\'t empty @@ -57,7 +56,6 @@ Do you want to wipe the original files ? Wiping failed: %s Files successfully wiped ! - The imported files have been successfully wiped from their original locations. Warning !\nThis password will be the only way to decrypt the volume and access the files inside.\nChoose a very strong password (not \"123456\" or \"password\"), do not lose it and keep it secure (preferably only in your mind).\n\nDroidFS cannot protect you from screen recording apps, keyloggers, apk backdooring, compromised root accesses, memory dumps etc.\nDo not type passwords in insecure environments. Warning !\nOpening volumes in insecure environments can lead to data leaks.\nDroidFS cannot protect you from screen recording apps, keyloggers, apk backdooring, compromised root accesses, memory dumps etc.\nDo not open volumes containing sensitive data unless you know exactly what you are doing. Rename