diff options
author | Fabian Henneke <FabianHenneke@users.noreply.github.com> | 2020-03-26 19:49:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-26 19:49:28 +0100 |
commit | 57771c4dfee862c8eb87777c59ad1b1dced04de3 (patch) | |
tree | cac3d0a7da18613ad91b0820acf9b65029ad066d /app | |
parent | de4cc638609da49c55766ea8cf3428a637badb7f (diff) |
Fix: Commit file after Autofill generate/save (#669)
Currently, password files generated via the Autofill generate or save
flow are not committed to the Git repository and therefore also not
synchronized to the remote.
The root cause is that it was missed that PgpActivity relies on
PasswordStore to commit the changes when it returns an appropriate
result code.
The fix is to extract the commit code into the companion object of
PasswordStore and call it from AutofillSaveActivity's onActivityResult.
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt | 23 | ||||
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/autofill/oreo/ui/AutofillSaveActivity.kt | 14 |
2 files changed, 24 insertions, 13 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt index 9ee28f09..72fbee8d 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt @@ -548,14 +548,7 @@ class PasswordStore : AppCompatActivity() { get() = plist?.currentDir ?: getRepositoryDirectory(applicationContext) private fun commitChange(message: String) { - object : GitOperation(getRepositoryDirectory(activity), activity) { - override fun execute() { - Timber.tag(TAG).d("Committing with message $message") - val git = Git(repository) - val tasks = GitAsyncTask(activity, false, true, this) - tasks.execute(git.add().addFilepattern("."), git.commit().setAll(true).setMessage(message)) - } - }.execute() + Companion.commitChange(activity, message) } override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { @@ -772,5 +765,19 @@ class PasswordStore : AppCompatActivity() { return (!Character.isISOControl(c) && block != null && block !== UnicodeBlock.SPECIALS) } + + fun commitChange(activity: Activity, message: String) { + object : GitOperation(getRepositoryDirectory(activity), activity) { + override fun execute() { + Timber.tag(TAG).d("Committing with message $message") + val git = Git(repository) + val tasks = GitAsyncTask(activity, false, true, this) + tasks.execute( + git.add().addFilepattern("."), + git.commit().setAll(true).setMessage(message) + ) + } + }.execute() + } } } diff --git a/app/src/main/java/com/zeapo/pwdstore/autofill/oreo/ui/AutofillSaveActivity.kt b/app/src/main/java/com/zeapo/pwdstore/autofill/oreo/ui/AutofillSaveActivity.kt index e5def0fb..3a4831d6 100644 --- a/app/src/main/java/com/zeapo/pwdstore/autofill/oreo/ui/AutofillSaveActivity.kt +++ b/app/src/main/java/com/zeapo/pwdstore/autofill/oreo/ui/AutofillSaveActivity.kt @@ -16,6 +16,7 @@ import androidx.annotation.RequiresApi import androidx.core.os.bundleOf import com.github.ajalt.timberkt.e import com.zeapo.pwdstore.PasswordStore +import com.zeapo.pwdstore.R import com.zeapo.pwdstore.autofill.oreo.AutofillAction import com.zeapo.pwdstore.autofill.oreo.AutofillMatcher import com.zeapo.pwdstore.autofill.oreo.AutofillPreferences @@ -114,12 +115,15 @@ class AutofillSaveActivity : Activity() { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) if (requestCode == PasswordStore.REQUEST_CODE_ENCRYPT && resultCode == RESULT_OK && data != null) { - val createdPath = data.getStringExtra("CREATED_FILE") - if (createdPath != null) { - formOrigin?.let { - AutofillMatcher.addMatchFor(this, it, File(createdPath)) - } + val createdPath = data.getStringExtra("CREATED_FILE")!! + formOrigin?.let { + AutofillMatcher.addMatchFor(this, it, File(createdPath)) } + val longName = data.getStringExtra("LONG_NAME")!! + // PgpActivity delegates committing the added file to PasswordStore. Since PasswordStore + // is not involved in an AutofillScenario, we have to commit the file ourself. + PasswordStore.commitChange(this, getString(R.string.git_commit_add_text, longName)) + val password = data.getStringExtra("PASSWORD") val username = data.getStringExtra("USERNAME") if (password != null) { |