Toast on file operation success & handle usf_keep_open on CameraActivity

This commit is contained in:
Matéo Duparc 2020-12-31 16:24:04 +01:00
parent 966e78b66f
commit e783e02398
Signed by untrusted user: hardcoresushi
GPG Key ID: 007F84120107191E
6 changed files with 21 additions and 30 deletions

View File

@ -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'

View File

@ -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<ImageView>
@ -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()
}
}

View File

@ -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)

View File

@ -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<OperationFile>){ 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<OperationFile>){ 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)
}

View File

@ -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")!!

View File

@ -26,7 +26,6 @@
<string name="import_failed">Import of %s failed.</string>
<string name="export_failed">Export of %s failed.</string>
<string name="success_export">Export successful !</string>
<string name="success_export_msg">The selected files have been successfully exported.</string>
<string name="remove_failed">Deletion of %s failed.</string>
<string name="passwords_mismatch">Passwords don\'t match</string>
<string name="dir_not_empty">The selected directory isn\'t empty</string>
@ -57,7 +56,6 @@
<string name="ask_for_wipe">Do you want to wipe the original files ?</string>
<string name="wipe_failed">Wiping failed: %s</string>
<string name="wipe_successful">Files successfully wiped !</string>
<string name="wipe_success_msg">The imported files have been successfully wiped from their original locations.</string>
<string name="create_password_warning">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.</string>
<string name="open_activity_warning">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.</string>
<string name="rename">Rename</string>