diff options
author | Mohamed Zenadi <mohamed@zenadi.com> | 2017-08-02 12:23:30 +0100 |
---|---|---|
committer | Mohamed Zenadi <zeapo@users.noreply.github.com> | 2017-08-10 11:10:29 +0200 |
commit | 145c96f5da43ec69cc3684757406ebf5ea96c3e7 (patch) | |
tree | d9ed9dc7f1cbd03172e26017714f2bec3a98c5f7 /app/src/main/java/com | |
parent | de5edf6e9366b1544a982e7adf7f53f50e4d3dbf (diff) |
Fix edit operation with latest changes in FILE_PATH
Diffstat (limited to 'app/src/main/java/com')
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt index 594531a6..a88718e7 100644 --- a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt +++ b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt @@ -37,7 +37,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound { getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager } var passwordEntry: PasswordEntry? = null - var api : OpenPgpApi? = null + var api: OpenPgpApi? = null val operation: String by lazy { intent.getStringExtra("OPERATION") } val repoPath: String by lazy { intent.getStringExtra("REPO_PATH") } @@ -77,7 +77,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound { "ENCRYPT" -> { setContentView(R.layout.encrypt_layout) title = getString(R.string.new_password_title) - crypto_password_category.text = relativeParentPath + crypto_password_category.text = getRelativePath(fullPath, repoPath) } } } @@ -91,7 +91,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound { // Inflate the menu; this adds items to the action bar if it is present. // Do not use the value `operation` in this case as it is not valid when editing val menuId = when (intent.getStringExtra("OPERATION")) { - "ENCRYPT" -> R.menu.pgp_handler_new_password + "ENCRYPT", "EDIT" -> R.menu.pgp_handler_new_password "DECRYPT" -> R.menu.pgp_handler else -> R.menu.pgp_handler } @@ -196,7 +196,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound { passwordEntry = entry - if (operation == "EDIT") { + if (intent.getStringExtra("OPERATION") == "EDIT") { editPassword() return@executeApiAsync } @@ -279,7 +279,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound { val iStream = ByteArrayInputStream("$pass\n$extra".toByteArray(Charset.forName("UTF-8"))) val oStream = ByteArrayOutputStream() - val path = "$repoPath/$relativeParentPath/$name.gpg" + val path = if (intent.getStringExtra("OPERATION") == "EDIT") fullPath else "$fullPath/$name.gpg" api?.executeApiAsync(data, iStream, oStream, { result: Intent? -> when (result?.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)) { @@ -333,7 +333,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound { delayTask?.skip = true val data = Intent(this, PgpActivity::class.java) - data.putExtra("OPERATION", "ENCRYPT") + data.putExtra("OPERATION", "EDIT") data.putExtra("fromDecrypt", true) intent = data invalidateOptionsMenu() @@ -575,7 +575,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound { /** * Gets the Parent path, relative to the repository */ - fun getParentPath(fullPath: String, repositoryPath: String) : String { + fun getParentPath(fullPath: String, repositoryPath: String): String { val relativePath = getRelativePath(fullPath, repositoryPath) val index = relativePath.lastIndexOf("/") return "/${relativePath.substring(startIndex = 0, endIndex = index + 1)}/".replace("/+".toRegex(), "/") @@ -584,7 +584,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound { /** * Gets the name of the password (excluding .gpg) */ - fun getName(fullPath: String, repositoryPath: String) : String { + fun getName(fullPath: String, repositoryPath: String): String { val relativePath = getRelativePath(fullPath, repositoryPath) val index = relativePath.lastIndexOf("/") return relativePath.substring(index + 1).replace("\\.gpg$".toRegex(), "") |