Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
Try getting decrypt going
Browse files Browse the repository at this point in the history
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
  • Loading branch information
msfjarvis committed May 25, 2020
1 parent 8e4e950 commit 1bdf9bc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
11 changes: 6 additions & 5 deletions app/src/main/java/com/zeapo/pwdstore/crypto/BasePgpActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,13 @@ open class BasePgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBou
}
}

override fun onDestroy() {
super.onDestroy()
serviceConnection?.unbindFromService()
}

override fun onBound(service: IOpenPgpService2) {
initOpenPgpApi()
api = OpenPgpApi(this, service)
}

override fun onError(e: Exception) {
Expand Down Expand Up @@ -103,10 +108,6 @@ open class BasePgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBou
}
}

private fun initOpenPgpApi() {
api = api ?: OpenPgpApi(this, serviceConnection!!.service!!)
}

/**
* Gets a relative string describing when this shape was last changed
* (e.g. "one hour ago")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import com.zeapo.pwdstore.databinding.DecryptLayoutBinding
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import me.msfjarvis.openpgpktx.util.OpenPgpApi
import org.apache.commons.io.FileUtils
import org.openintents.openpgp.IOpenPgpService2
import java.io.ByteArrayOutputStream
import java.io.File

Expand Down Expand Up @@ -91,6 +91,11 @@ class DecryptActivity : BasePgpActivity() {
}
}

override fun onBound(service: IOpenPgpService2) {
super.onBound(service)
decryptAndVerify()
}

private fun copyUsernameToClipboard(username: String?) {
val clipboard = clipboard ?: return
val clip = ClipData.newPlainText("pgp_handler_result_pm", username)
Expand Down Expand Up @@ -133,7 +138,7 @@ class DecryptActivity : BasePgpActivity() {
val data = receivedIntent ?: Intent()
data.action = OpenPgpApi.ACTION_DECRYPT_VERIFY

val inputStream = FileUtils.openInputStream(File(fullPath))
val inputStream = File(fullPath).inputStream()
val outputStream = ByteArrayOutputStream()

lifecycleScope.launch(Dispatchers.IO) {
Expand Down

0 comments on commit 1bdf9bc

Please sign in to comment.