Fix edit operation with latest changes in FILE_PATH

This commit is contained in:
Mohamed Zenadi 2017-08-02 12:23:30 +01:00 committed by Mohamed Zenadi
parent de5edf6e93
commit 145c96f5da

View file

@ -77,7 +77,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
"ENCRYPT" -> { "ENCRYPT" -> {
setContentView(R.layout.encrypt_layout) setContentView(R.layout.encrypt_layout)
title = getString(R.string.new_password_title) 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. // 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 // Do not use the value `operation` in this case as it is not valid when editing
val menuId = when (intent.getStringExtra("OPERATION")) { 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 "DECRYPT" -> R.menu.pgp_handler
else -> R.menu.pgp_handler else -> R.menu.pgp_handler
} }
@ -196,7 +196,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
passwordEntry = entry passwordEntry = entry
if (operation == "EDIT") { if (intent.getStringExtra("OPERATION") == "EDIT") {
editPassword() editPassword()
return@executeApiAsync return@executeApiAsync
} }
@ -279,7 +279,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
val iStream = ByteArrayInputStream("$pass\n$extra".toByteArray(Charset.forName("UTF-8"))) val iStream = ByteArrayInputStream("$pass\n$extra".toByteArray(Charset.forName("UTF-8")))
val oStream = ByteArrayOutputStream() 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? -> api?.executeApiAsync(data, iStream, oStream, { result: Intent? ->
when (result?.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)) { when (result?.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)) {
@ -333,7 +333,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
delayTask?.skip = true delayTask?.skip = true
val data = Intent(this, PgpActivity::class.java) val data = Intent(this, PgpActivity::class.java)
data.putExtra("OPERATION", "ENCRYPT") data.putExtra("OPERATION", "EDIT")
data.putExtra("fromDecrypt", true) data.putExtra("fromDecrypt", true)
intent = data intent = data
invalidateOptionsMenu() invalidateOptionsMenu()