aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/main/java/com/zeapo/pwdstore/git
diff options
context:
space:
mode:
authorHarsh Shandilya <msfjarvis@gmail.com>2020-08-16 02:16:02 +0530
committerGitHub <noreply@github.com>2020-08-15 22:46:02 +0200
commit2ffd1abb279bb0e1a8895ef26b805a1a1651516c (patch)
treeddfa9512a7b6e8944286a23d0055174c4e16b406 /app/src/main/java/com/zeapo/pwdstore/git
parent7bb40d109aadf49efc6b4a8b42b36eb27dd502f4 (diff)
downloadHardenedPass-2ffd1abb279bb0e1a8895ef26b805a1a1651516c.tar.gz
HardenedPass-2ffd1abb279bb0e1a8895ef26b805a1a1651516c.zip
Fix external storage UX (#1022)
* build: update to Kotlin 1.4 Signed-off-by: Harsh Shandilya <me@msfjarvis.dev> * UserPreference: finish if directory selection was triggered from an intent Signed-off-by: Harsh Shandilya <me@msfjarvis.dev> * PasswordStore: switch permission request to ActivityResultContracts Signed-off-by: Harsh Shandilya <me@msfjarvis.dev> * PasswordStore: fix activity reference Signed-off-by: Harsh Shandilya <me@msfjarvis.dev> * GitOperationActivity: make invalid values more obvious Would have caught this issue much sooner if I had just done this Fixes: 3d8cea596600 ("Improve permission handling logic (#732)") Signed-off-by: Harsh Shandilya <me@msfjarvis.dev> * Assorted collection of hackery to make external storage use palatable Signed-off-by: Harsh Shandilya <me@msfjarvis.dev> * Update changelog Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'app/src/main/java/com/zeapo/pwdstore/git')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/git/GitOperationActivity.kt5
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/git/GitServerConfigActivity.kt13
2 files changed, 13 insertions, 5 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/git/GitOperationActivity.kt b/app/src/main/java/com/zeapo/pwdstore/git/GitOperationActivity.kt
index eda2a8fe..8b772747 100644
--- a/app/src/main/java/com/zeapo/pwdstore/git/GitOperationActivity.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/git/GitOperationActivity.kt
@@ -20,13 +20,12 @@ open class GitOperationActivity : BaseGitActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
- when (intent.extras?.getInt(REQUEST_ARG_OP)) {
+ when (val reqCode = intent.extras?.getInt(REQUEST_ARG_OP)) {
REQUEST_PULL -> lifecycleScope.launch { syncRepository(REQUEST_PULL) }
REQUEST_PUSH -> lifecycleScope.launch { syncRepository(REQUEST_PUSH) }
REQUEST_SYNC -> lifecycleScope.launch { syncRepository(REQUEST_SYNC) }
else -> {
- setResult(RESULT_CANCELED)
- finish()
+ throw IllegalArgumentException("Invalid request code: $reqCode")
}
}
}
diff --git a/app/src/main/java/com/zeapo/pwdstore/git/GitServerConfigActivity.kt b/app/src/main/java/com/zeapo/pwdstore/git/GitServerConfigActivity.kt
index 4d744821..82e97e17 100644
--- a/app/src/main/java/com/zeapo/pwdstore/git/GitServerConfigActivity.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/git/GitServerConfigActivity.kt
@@ -17,9 +17,12 @@ import com.zeapo.pwdstore.git.config.ConnectionMode
import com.zeapo.pwdstore.git.config.GitSettings
import com.zeapo.pwdstore.git.config.Protocol
import com.zeapo.pwdstore.utils.PasswordRepository
+import com.zeapo.pwdstore.utils.snackbar
import com.zeapo.pwdstore.utils.viewBinding
import java.io.IOException
+import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
+import kotlinx.coroutines.withContext
/**
* Activity that encompasses both the initial clone as well as editing the server config for future
@@ -125,8 +128,14 @@ class GitServerConfigActivity : BaseGitActivity() {
.setCancelable(false)
.setPositiveButton(R.string.dialog_delete) { dialog, _ ->
try {
- localDir.deleteRecursively()
- lifecycleScope.launch { launchGitOperation(REQUEST_CLONE) }
+ lifecycleScope.launch {
+ val snackbar = snackbar(message = getString(R.string.delete_directory_progress_text), length = Snackbar.LENGTH_INDEFINITE)
+ withContext(Dispatchers.IO) {
+ localDir.deleteRecursively()
+ }
+ snackbar.dismiss()
+ launchGitOperation(REQUEST_CLONE)
+ }
} catch (e: IOException) {
// TODO Handle the exception correctly if we are unable to delete the directory...
e.printStackTrace()