diff options
| author | Harsh Shandilya <msfjarvis@gmail.com> | 2019-05-29 00:42:09 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-05-29 00:42:09 +0530 |
| commit | 53b42905f17553b74160eaae7d5352fc7aa648d7 (patch) | |
| tree | 6df5e28bdcf4b10eabda3c15f89410114114862d /app/src/main/java/com/zeapo/pwdstore/crypto | |
| parent | 321035c319979010cafb10ce8bd83890d0c0a195 (diff) | |
| download | HardenedPass-53b42905f17553b74160eaae7d5352fc7aa648d7.tar.gz HardenedPass-53b42905f17553b74160eaae7d5352fc7aa648d7.zip | |
Convert autofill package to Kotlin (#515)
Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
Diffstat (limited to 'app/src/main/java/com/zeapo/pwdstore/crypto')
| -rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt | 26 |
1 files changed, 13 insertions, 13 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 f6f0b9a8..7d782a05 100644 --- a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt +++ b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt @@ -435,8 +435,8 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound { val path = if (intent.getBooleanExtra("fromDecrypt", false)) fullPath else "$fullPath/$editName.gpg" api?.executeApiAsync(data, iStream, oStream) { result: Intent? -> - when (result?.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)) { - OpenPgpApi.RESULT_CODE_SUCCESS -> { + when (result?.getIntExtra(RESULT_CODE, RESULT_CODE_ERROR)) { + RESULT_CODE_SUCCESS -> { try { // TODO This might fail, we should check that the write is successful val outputStream = FileUtils.openOutputStream(File(path)) @@ -459,7 +459,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound { Log.e(TAG, "An Exception occurred", e) } } - OpenPgpApi.RESULT_CODE_ERROR -> handleError(result) + RESULT_CODE_ERROR -> handleError(result) } } @@ -516,7 +516,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound { private fun calculateHotp(entry: PasswordEntry) { copyOtpToClipBoard(Otp.calculateCode(entry.hotpSecret, entry.hotpCounter!! + 1, "sha1", entry.digits)) - crypto_otp_show.text = Otp.calculateCode(entry.hotpSecret, entry.hotpCounter!! + 1, "sha1", entry.digits) + crypto_otp_show.text = Otp.calculateCode(entry.hotpSecret, entry.hotpCounter + 1, "sha1", entry.digits) crypto_extra_show.text = entry.extraContent } @@ -539,8 +539,8 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound { val data = receivedIntent ?: Intent() data.action = OpenPgpApi.ACTION_GET_KEY_IDS api?.executeApiAsync(data, null, null) { result: Intent? -> - when (result?.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)) { - OpenPgpApi.RESULT_CODE_SUCCESS -> { + when (result?.getIntExtra(RESULT_CODE, RESULT_CODE_ERROR)) { + RESULT_CODE_SUCCESS -> { try { val ids = result.getLongArrayExtra(OpenPgpApi.RESULT_KEY_IDS) val keys = ids.map { it.toString() }.toSet() @@ -557,7 +557,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound { } } RESULT_CODE_USER_INTERACTION_REQUIRED -> handleUserInteractionRequest(result, REQUEST_KEY_ID) - OpenPgpApi.RESULT_CODE_ERROR -> handleError(result) + RESULT_CODE_ERROR -> handleError(result) } } } @@ -580,23 +580,23 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound { Log.d(TAG, "onActivityResult resultCode: $resultCode") if (data == null) { - setResult(AppCompatActivity.RESULT_CANCELED, null) + setResult(RESULT_CANCELED, null) finish() return } // try again after user interaction - if (resultCode == AppCompatActivity.RESULT_OK) { + if (resultCode == RESULT_OK) { when (requestCode) { REQUEST_DECRYPT -> decryptAndVerify(data) REQUEST_KEY_ID -> getKeyIds(data) else -> { - setResult(AppCompatActivity.RESULT_OK) + setResult(RESULT_OK) finish() } } - } else if (resultCode == AppCompatActivity.RESULT_CANCELED) { - setResult(AppCompatActivity.RESULT_CANCELED, data) + } else if (resultCode == RESULT_CANCELED) { + setResult(RESULT_CANCELED, data) finish() } } @@ -786,7 +786,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound { if (crypto_password_show != null) { // clear password; if decrypt changed to encrypt layout via edit button, no need if (passwordEntry?.hotpIsIncremented() == false) { - setResult(AppCompatActivity.RESULT_CANCELED) + setResult(RESULT_CANCELED) } passwordEntry = null crypto_password_show.text = "" |
