diff options
| author | Harsh Shandilya <me@msfjarvis.dev> | 2021-09-14 22:37:55 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-14 22:37:55 +0530 |
| commit | 571ab4e78e022ba7c9f0b8e20d3dd81f371d1b3c (patch) | |
| tree | ad2d5d61878da9889803a973ceba8326e29be001 /app/src/main/java/dev/msfjarvis/aps/ui/crypto | |
| parent | 30cb8cfceb54054e18dc8d10206008fcfa10693d (diff) | |
| download | HardenedPass-571ab4e78e022ba7c9f0b8e20d3dd81f371d1b3c.tar.gz HardenedPass-571ab4e78e022ba7c9f0b8e20d3dd81f371d1b3c.zip | |
Gopenpgp related fixes (#1503)
* app: rename new crypto activities
(cherry picked from commit 89be012f995b878affb7e7a592750e130c7f0f2c)
* app: allow alt backends to work without OpenKeychain
(cherry picked from commit 7bf9f01e5ef7bb24700ce3f242e5aabbabbff09e)
* app: rename ENABLE_GOPENPGP to ENABLE_PGP_V2_BACKEND
Diffstat (limited to 'app/src/main/java/dev/msfjarvis/aps/ui/crypto')
| -rw-r--r-- | app/src/main/java/dev/msfjarvis/aps/ui/crypto/BasePgpActivity.kt | 2 | ||||
| -rw-r--r-- | app/src/main/java/dev/msfjarvis/aps/ui/crypto/DecryptActivityV2.kt (renamed from app/src/main/java/dev/msfjarvis/aps/ui/crypto/GopenpgpDecryptActivity.kt) | 15 | ||||
| -rw-r--r-- | app/src/main/java/dev/msfjarvis/aps/ui/crypto/PasswordCreationActivityV2.kt (renamed from app/src/main/java/dev/msfjarvis/aps/ui/crypto/GopenpgpPasswordCreationActivity.kt) | 14 |
3 files changed, 18 insertions, 13 deletions
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/crypto/BasePgpActivity.kt b/app/src/main/java/dev/msfjarvis/aps/ui/crypto/BasePgpActivity.kt index ee753fe5..0a114827 100644 --- a/app/src/main/java/dev/msfjarvis/aps/ui/crypto/BasePgpActivity.kt +++ b/app/src/main/java/dev/msfjarvis/aps/ui/crypto/BasePgpActivity.kt @@ -27,6 +27,7 @@ import com.google.android.material.snackbar.Snackbar import dagger.hilt.android.AndroidEntryPoint import dev.msfjarvis.aps.R import dev.msfjarvis.aps.injection.prefs.SettingsPreferences +import dev.msfjarvis.aps.util.FeatureFlags import dev.msfjarvis.aps.util.extensions.OPENPGP_PROVIDER import dev.msfjarvis.aps.util.extensions.clipboard import dev.msfjarvis.aps.util.extensions.getString @@ -126,6 +127,7 @@ open class BasePgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBou /** Method for subclasses to initiate binding with [OpenPgpServiceConnection]. */ fun bindToOpenKeychain(onBoundListener: OpenPgpServiceConnection.OnBound) { + if (FeatureFlags.ENABLE_PGP_V2_BACKEND) return val installed = runCatching { packageManager.getPackageInfo(OPENPGP_PROVIDER, 0) diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/crypto/GopenpgpDecryptActivity.kt b/app/src/main/java/dev/msfjarvis/aps/ui/crypto/DecryptActivityV2.kt index 159354d2..b000d21d 100644 --- a/app/src/main/java/dev/msfjarvis/aps/ui/crypto/GopenpgpDecryptActivity.kt +++ b/app/src/main/java/dev/msfjarvis/aps/ui/crypto/DecryptActivityV2.kt @@ -31,7 +31,7 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.withContext @AndroidEntryPoint -class GopenpgpDecryptActivity : BasePgpActivity() { +class DecryptActivityV2 : BasePgpActivity() { private val binding by viewBinding(DecryptLayoutBinding::inflate) @Inject lateinit var passwordEntryFactory: PasswordEntryFactory @@ -96,13 +96,16 @@ class GopenpgpDecryptActivity : BasePgpActivity() { * result triggers they can be repopulated with new data. */ private fun editPassword() { - val intent = Intent(this, PasswordCreationActivity::class.java) + val intent = Intent(this, PasswordCreationActivityV2::class.java) intent.putExtra("FILE_PATH", relativeParentPath) intent.putExtra("REPO_PATH", repoPath) - intent.putExtra(PasswordCreationActivity.EXTRA_FILE_NAME, name) - intent.putExtra(PasswordCreationActivity.EXTRA_PASSWORD, passwordEntry?.password) - intent.putExtra(PasswordCreationActivity.EXTRA_EXTRA_CONTENT, passwordEntry?.extraContentString) - intent.putExtra(PasswordCreationActivity.EXTRA_EDITING, true) + intent.putExtra(PasswordCreationActivityV2.EXTRA_FILE_NAME, name) + intent.putExtra(PasswordCreationActivityV2.EXTRA_PASSWORD, passwordEntry?.password) + intent.putExtra( + PasswordCreationActivityV2.EXTRA_EXTRA_CONTENT, + passwordEntry?.extraContentString + ) + intent.putExtra(PasswordCreationActivityV2.EXTRA_EDITING, true) startActivity(intent) finish() } diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/crypto/GopenpgpPasswordCreationActivity.kt b/app/src/main/java/dev/msfjarvis/aps/ui/crypto/PasswordCreationActivityV2.kt index bbce67f3..645d6c47 100644 --- a/app/src/main/java/dev/msfjarvis/aps/ui/crypto/GopenpgpPasswordCreationActivity.kt +++ b/app/src/main/java/dev/msfjarvis/aps/ui/crypto/PasswordCreationActivityV2.kt @@ -51,7 +51,7 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.withContext @AndroidEntryPoint -class GopenpgpPasswordCreationActivity : BasePgpActivity() { +class PasswordCreationActivityV2 : BasePgpActivity() { private val binding by viewBinding(PasswordCreationActivityBinding::inflate) @Inject lateinit var passwordEntryFactory: PasswordEntryFactory @@ -96,7 +96,7 @@ class GopenpgpPasswordCreationActivity : BasePgpActivity() { otpImportButton.setOnClickListener { supportFragmentManager.setFragmentResultListener( OTP_RESULT_REQUEST_KEY, - this@GopenpgpPasswordCreationActivity + this@PasswordCreationActivityV2 ) { requestKey, bundle -> if (requestKey == OTP_RESULT_REQUEST_KEY) { val contents = bundle.getString(RESULT) @@ -113,12 +113,12 @@ class GopenpgpPasswordCreationActivity : BasePgpActivity() { getString(R.string.otp_import_qr_code), getString(R.string.otp_import_manual_entry) ) - MaterialAlertDialogBuilder(this@GopenpgpPasswordCreationActivity) + MaterialAlertDialogBuilder(this@PasswordCreationActivityV2) .setItems(items) { _, index -> when (index) { 0 -> otpImportAction.launch( - IntentIntegrator(this@GopenpgpPasswordCreationActivity) + IntentIntegrator(this@PasswordCreationActivityV2) .setOrientationLocked(false) .setBeepEnabled(false) .setDesiredBarcodeFormats(QR_CODE) @@ -156,7 +156,7 @@ class GopenpgpPasswordCreationActivity : BasePgpActivity() { // in the encrypted extras. This only makes sense if the directory structure is // FileBased. if (suggestedName == null && - AutofillPreferences.directoryStructure(this@GopenpgpPasswordCreationActivity) == + AutofillPreferences.directoryStructure(this@PasswordCreationActivityV2) == DirectoryStructure.FileBased ) { encryptUsername.apply { @@ -367,7 +367,7 @@ class GopenpgpPasswordCreationActivity : BasePgpActivity() { val oldFile = File("$repoPath/${oldCategory?.trim('/')}/$oldFileName.gpg") if (oldFile.path != file.path && !oldFile.delete()) { setResult(RESULT_CANCELED) - MaterialAlertDialogBuilder(this@GopenpgpPasswordCreationActivity) + MaterialAlertDialogBuilder(this@PasswordCreationActivityV2) .setTitle(R.string.password_creation_file_fail_title) .setMessage( getString(R.string.password_creation_file_delete_fail_message, oldFileName) @@ -395,7 +395,7 @@ class GopenpgpPasswordCreationActivity : BasePgpActivity() { if (e is IOException) { e(e) { "Failed to write password file" } setResult(RESULT_CANCELED) - MaterialAlertDialogBuilder(this@GopenpgpPasswordCreationActivity) + MaterialAlertDialogBuilder(this@PasswordCreationActivityV2) .setTitle(getString(R.string.password_creation_file_fail_title)) .setMessage(getString(R.string.password_creation_file_write_fail_message)) .setCancelable(false) |
