diff options
Diffstat (limited to 'app/src/main')
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/PasswordStore.java | 27 | ||||
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java | 5 | ||||
-rw-r--r-- | app/src/main/res/values/strings.xml | 1 |
3 files changed, 24 insertions, 9 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java index adfd62ff..e120b758 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java @@ -506,6 +506,15 @@ public class PasswordStore extends AppCompatActivity { return PasswordRepository.getWorkTree(); } + private void commit(String message) { + Git git = new Git(PasswordRepository.getRepository(new File(""))); + GitAsyncTask tasks = new GitAsyncTask(this, false, false, CommitCommand.class); + tasks.execute( + git.add().addFilepattern("."), + git.commit().setMessage(message) + ); + } + protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK) { @@ -515,16 +524,18 @@ public class PasswordStore extends AppCompatActivity { settings.edit().putBoolean("repository_initialized", true).apply(); break; case PgpHandler.REQUEST_CODE_DECRYPT_AND_VERIFY: - if (!data.getBooleanExtra("needCommit", false)) { - break; + // if went from decrypt->edit and user saved changes, we need to commit + if (data.getBooleanExtra("needCommit", false)) { + commit(this.getResources().getString(R.string.edit_commit_text) + data.getExtras().getString("NAME")); + refreshListAdapter(); } + 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( - git.add().addFilepattern("."), - git.commit().setMessage(this.getResources().getString(R.string.add_commit_text) + data.getExtras().getString("NAME") + this.getResources().getString(R.string.from_store)) - ); + commit(this.getResources().getString(R.string.add_commit_text) + data.getExtras().getString("NAME") + this.getResources().getString(R.string.from_store)); + refreshListAdapter(); + break; + case PgpHandler.REQUEST_CODE_EDIT: + commit(this.getResources().getString(R.string.edit_commit_text) + data.getExtras().getString("NAME")); refreshListAdapter(); break; case GitActivity.REQUEST_INIT: 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 f984ad31..dc4d55e3 100644 --- a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java +++ b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java @@ -149,6 +149,7 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne break; case R.id.edit_password: editPassword(); + break; case R.id.crypto_confirm_add: encrypt(new Intent()); break; @@ -161,7 +162,6 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne } public void editPassword() { - // if in encrypt or in decrypt and password is invisible // (because !showPassword, so this will instantly close), do nothing if (findViewById(R.id.crypto_password_show) == null @@ -195,6 +195,9 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne intent.putExtra("Operation", "ENCRYPT"); intent.putExtra("fromDecrypt", true); setIntent(intent); + + // recreate the options menu to be the encrypt one + invalidateOptionsMenu(); } public void copyToClipBoard() { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d2d9ece5..6cd2120f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -25,6 +25,7 @@ <string name="initialization_commit_text">[ANDROID PwdStore] Initialized store with keyID: </string> <string name="add_commit_text">[ANDROID PwdStore] Add  </string> <string name="remove_commit_text">[ANDROID PwdStore] Remove  </string> + <string name="edit_commit_text">[ANDROID PwdStore] Edit  </string> <string name="from_store">  from store.</string> <!-- PGPHandler --> |