Update to openpgp-ktx 1.0.0 (#585)
Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
This commit is contained in:
parent
fdbbb467b2
commit
0a01911d87
3 changed files with 173 additions and 164 deletions
|
@ -567,12 +567,12 @@ class AutofillService : AccessibilityService() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private inner class OnBoundListener : OpenPgpServiceConnection.OnBound {
|
private inner class OnBoundListener : OpenPgpServiceConnection.OnBound {
|
||||||
override fun onBound(service: IOpenPgpService2?) {
|
override fun onBound(service: IOpenPgpService2) {
|
||||||
decryptAndVerify()
|
decryptAndVerify()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onError(e: Exception?) {
|
override fun onError(e: Exception) {
|
||||||
e?.printStackTrace()
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,9 @@ import kotlinx.android.synthetic.main.encrypt_layout.crypto_password_category
|
||||||
import kotlinx.android.synthetic.main.encrypt_layout.crypto_password_edit
|
import kotlinx.android.synthetic.main.encrypt_layout.crypto_password_edit
|
||||||
import kotlinx.android.synthetic.main.encrypt_layout.crypto_password_file_edit
|
import kotlinx.android.synthetic.main.encrypt_layout.crypto_password_file_edit
|
||||||
import kotlinx.android.synthetic.main.encrypt_layout.generate_password
|
import kotlinx.android.synthetic.main.encrypt_layout.generate_password
|
||||||
|
import kotlinx.coroutines.Dispatchers.IO
|
||||||
|
import kotlinx.coroutines.GlobalScope
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
import me.msfjarvis.openpgpktx.OpenPgpError
|
import me.msfjarvis.openpgpktx.OpenPgpError
|
||||||
import me.msfjarvis.openpgpktx.util.OpenPgpApi
|
import me.msfjarvis.openpgpktx.util.OpenPgpApi
|
||||||
import me.msfjarvis.openpgpktx.util.OpenPgpApi.Companion.ACTION_DECRYPT_VERIFY
|
import me.msfjarvis.openpgpktx.util.OpenPgpApi.Companion.ACTION_DECRYPT_VERIFY
|
||||||
|
@ -243,6 +246,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
|
||||||
val iStream = FileUtils.openInputStream(File(fullPath))
|
val iStream = FileUtils.openInputStream(File(fullPath))
|
||||||
val oStream = ByteArrayOutputStream()
|
val oStream = ByteArrayOutputStream()
|
||||||
|
|
||||||
|
GlobalScope.launch(IO) {
|
||||||
api?.executeApiAsync(data, iStream, oStream, object : OpenPgpApi.IOpenPgpCallback {
|
api?.executeApiAsync(data, iStream, oStream, object : OpenPgpApi.IOpenPgpCallback {
|
||||||
override fun onReturn(result: Intent?) {
|
override fun onReturn(result: Intent?) {
|
||||||
when (result?.getIntExtra(RESULT_CODE, RESULT_CODE_ERROR)) {
|
when (result?.getIntExtra(RESULT_CODE, RESULT_CODE_ERROR)) {
|
||||||
|
@ -413,6 +417,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encrypts the password and the extra content
|
* Encrypts the password and the extra content
|
||||||
|
@ -453,6 +458,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
|
||||||
|
|
||||||
val path = if (intent.getBooleanExtra("fromDecrypt", false)) fullPath else "$fullPath/$editName.gpg"
|
val path = if (intent.getBooleanExtra("fromDecrypt", false)) fullPath else "$fullPath/$editName.gpg"
|
||||||
|
|
||||||
|
GlobalScope.launch(IO) {
|
||||||
api?.executeApiAsync(data, iStream, oStream, object : OpenPgpApi.IOpenPgpCallback {
|
api?.executeApiAsync(data, iStream, oStream, object : OpenPgpApi.IOpenPgpCallback {
|
||||||
override fun onReturn(result: Intent?) {
|
override fun onReturn(result: Intent?) {
|
||||||
when (result?.getIntExtra(RESULT_CODE, RESULT_CODE_ERROR)) {
|
when (result?.getIntExtra(RESULT_CODE, RESULT_CODE_ERROR)) {
|
||||||
|
@ -484,6 +490,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens EncryptActivity with the information for this file to be edited
|
* Opens EncryptActivity with the information for this file to be edited
|
||||||
|
@ -559,6 +566,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
|
||||||
private fun getKeyIds(receivedIntent: Intent? = null) {
|
private fun getKeyIds(receivedIntent: Intent? = null) {
|
||||||
val data = receivedIntent ?: Intent()
|
val data = receivedIntent ?: Intent()
|
||||||
data.action = OpenPgpApi.ACTION_GET_KEY_IDS
|
data.action = OpenPgpApi.ACTION_GET_KEY_IDS
|
||||||
|
GlobalScope.launch(IO) {
|
||||||
api?.executeApiAsync(data, null, null, object : OpenPgpApi.IOpenPgpCallback {
|
api?.executeApiAsync(data, null, null, object : OpenPgpApi.IOpenPgpCallback {
|
||||||
override fun onReturn(result: Intent?) {
|
override fun onReturn(result: Intent?) {
|
||||||
when (result?.getIntExtra(RESULT_CODE, RESULT_CODE_ERROR)) {
|
when (result?.getIntExtra(RESULT_CODE, RESULT_CODE_ERROR)) {
|
||||||
|
@ -585,13 +593,14 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onError(e: Exception?) {}
|
override fun onError(e: Exception) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The action to take when the PGP service is bound
|
* The action to take when the PGP service is bound
|
||||||
*/
|
*/
|
||||||
override fun onBound(service: IOpenPgpService2?) {
|
override fun onBound(service: IOpenPgpService2) {
|
||||||
initOpenPgpApi()
|
initOpenPgpApi()
|
||||||
when (operation) {
|
when (operation) {
|
||||||
"EDIT", "DECRYPT" -> decryptAndVerify()
|
"EDIT", "DECRYPT" -> decryptAndVerify()
|
||||||
|
|
|
@ -40,7 +40,7 @@ ext.deps = [
|
||||||
commons_codec: 'commons-codec:commons-codec:1.13',
|
commons_codec: 'commons-codec:commons-codec:1.13',
|
||||||
jsch: 'com.jcraft:jsch:0.1.55',
|
jsch: 'com.jcraft:jsch:0.1.55',
|
||||||
jgit: 'org.eclipse.jgit:org.eclipse.jgit:3.7.1.201504261725-r',
|
jgit: 'org.eclipse.jgit:org.eclipse.jgit:3.7.1.201504261725-r',
|
||||||
openpgp_ktx: 'com.github.android-password-store:openpgp-ktx:0.1.0',
|
openpgp_ktx: 'com.github.android-password-store:openpgp-ktx:1.0.0',
|
||||||
ssh_auth: 'org.sufficientlysecure:sshauthentication-api:1.0'
|
ssh_auth: 'org.sufficientlysecure:sshauthentication-api:1.0'
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue