From 8ed4449e4b67c6832f50c1a29e59f146eaeb6f92 Mon Sep 17 00:00:00 2001 From: Matthew Wong Date: Wed, 16 Sep 2015 11:26:51 -0400 Subject: Use intent for ensuring commit after decrypt->edit button->save --- app/src/main/java/com/zeapo/pwdstore/PasswordStore.java | 7 ++++--- app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java index d6e18995..33b6bd29 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java @@ -442,10 +442,11 @@ public class PasswordStore extends AppCompatActivity { // if we get here with a RESULT_OK then it's probably OK :) settings.edit().putBoolean("repository_initialized", true).apply(); break; - case PgpHandler.REQUEST_CODE_ENCRYPT: case PgpHandler.REQUEST_CODE_DECRYPT_AND_VERIFY: - // RESULT_OK and REQUEST_CODE_DECRYPT_AND_VERIFY only when a file has been edited - // since normally REQUEST_CODE_DECRYPT_AND_VERIFY returns RESULT_CANCELLED + if (!data.getBooleanExtra("needCommit", false)) { + break; + } + case PgpHandler.REQUEST_CODE_ENCRYPT: Git git = new Git(PasswordRepository.getRepository(new File(""))); GitAsyncTask tasks = new GitAsyncTask(this, false, false, CommitCommand.class); tasks.execute( diff --git a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java index 131e8e51..6c8a1a61 100644 --- a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java +++ b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java @@ -176,6 +176,7 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne Intent intent = new Intent(this, PgpHandler.class); intent.putExtra("FILE_PATH", directoryPath); intent.putExtra("Operation", "ENCRYPT"); + intent.putExtra("fromDecrypt", true); setIntent(intent); } @@ -427,6 +428,10 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne Intent data = new Intent(); data.putExtra("CREATED_FILE", path); data.putExtra("NAME", ((EditText) findViewById(R.id.crypto_password_file_edit)).getText().toString()); + // if coming from decrypt screen->edit button + if (getIntent().getBooleanExtra("fromDecrypt", false)) { + data.putExtra("needCommit", true); + } setResult(RESULT_OK, data); finish(); } catch (Exception e) { -- cgit v1.2.3