diff options
author | Harsh Shandilya <me@msfjarvis.dev> | 2021-11-04 23:28:40 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-04 23:28:40 +0530 |
commit | 223960d8d3e60af0b1bbd39ded0ae4957bf3d6de (patch) | |
tree | 307f8bad445eeab826556e993a54a770acf89349 /app/src/main/java/dev/msfjarvis | |
parent | 52f4ce06f533ffc4f0eb0031801f52d3ebdab595 (diff) |
Fix password saving for V2 backend (#1534)
Diffstat (limited to 'app/src/main/java/dev/msfjarvis')
5 files changed, 29 insertions, 10 deletions
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/autofill/AutofillDecryptActivityV2.kt b/app/src/main/java/dev/msfjarvis/aps/ui/autofill/AutofillDecryptActivityV2.kt index 5351c5d2..b1ad3156 100644 --- a/app/src/main/java/dev/msfjarvis/aps/ui/autofill/AutofillDecryptActivityV2.kt +++ b/app/src/main/java/dev/msfjarvis/aps/ui/autofill/AutofillDecryptActivityV2.kt @@ -35,7 +35,6 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import logcat.LogPriority.ERROR -import logcat.asLog import logcat.logcat @RequiresApi(Build.VERSION_CODES.O) diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/autofill/AutofillSaveActivity.kt b/app/src/main/java/dev/msfjarvis/aps/ui/autofill/AutofillSaveActivity.kt index c6feec1e..49b14ea4 100644 --- a/app/src/main/java/dev/msfjarvis/aps/ui/autofill/AutofillSaveActivity.kt +++ b/app/src/main/java/dev/msfjarvis/aps/ui/autofill/AutofillSaveActivity.kt @@ -20,6 +20,8 @@ import com.github.androidpasswordstore.autofillparser.Credentials import com.github.androidpasswordstore.autofillparser.FormOrigin import dev.msfjarvis.aps.data.repo.PasswordRepository import dev.msfjarvis.aps.ui.crypto.PasswordCreationActivity +import dev.msfjarvis.aps.ui.crypto.PasswordCreationActivityV2 +import dev.msfjarvis.aps.util.FeatureFlags import dev.msfjarvis.aps.util.autofill.AutofillMatcher import dev.msfjarvis.aps.util.autofill.AutofillPreferences import dev.msfjarvis.aps.util.autofill.AutofillResponseBuilder @@ -85,7 +87,7 @@ class AutofillSaveActivity : AppCompatActivity() { context, saveRequestCode++, intent, - PendingIntent.FLAG_CANCEL_CURRENT + PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE ) .intentSender } @@ -106,8 +108,11 @@ class AutofillSaveActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) val repo = PasswordRepository.getRepositoryDirectory() + val creationActivity = + if (FeatureFlags.ENABLE_PGP_V2_BACKEND) PasswordCreationActivityV2::class.java + else PasswordCreationActivity::class.java val saveIntent = - Intent(this, PasswordCreationActivity::class.java).apply { + Intent(this, creationActivity).apply { putExtras( bundleOf( "REPO_PATH" to repo.absolutePath, 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 6920bba2..7c74a621 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 @@ -250,6 +250,8 @@ open class BasePgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBou companion object { private const val TAG = "APS/BasePgpActivity" + const val EXTRA_FILE_PATH = "FILE_PATH" + const val EXTRA_REPO_PATH = "REPO_PATH" /** Gets the relative path to the repository */ fun getRelativePath(fullPath: String, repositoryPath: String): String = diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/main/LaunchActivity.kt b/app/src/main/java/dev/msfjarvis/aps/ui/main/LaunchActivity.kt index e3c59a50..629ddb9c 100644 --- a/app/src/main/java/dev/msfjarvis/aps/ui/main/LaunchActivity.kt +++ b/app/src/main/java/dev/msfjarvis/aps/ui/main/LaunchActivity.kt @@ -10,6 +10,7 @@ import android.os.Handler import android.os.Looper import androidx.appcompat.app.AppCompatActivity import androidx.core.content.edit +import dev.msfjarvis.aps.ui.crypto.BasePgpActivity import dev.msfjarvis.aps.ui.crypto.DecryptActivity import dev.msfjarvis.aps.ui.passwords.PasswordStore import dev.msfjarvis.aps.util.auth.BiometricAuthenticator @@ -45,10 +46,14 @@ class LaunchActivity : AppCompatActivity() { val intentToStart = if (intent.action == ACTION_DECRYPT_PASS) Intent(this, DecryptActivity::class.java).apply { - putExtra("NAME", intent.getStringExtra("NAME")) - putExtra("FILE_PATH", intent.getStringExtra("FILE_PATH")) - putExtra("REPO_PATH", intent.getStringExtra("REPO_PATH")) - putExtra("LAST_CHANGED_TIMESTAMP", intent.getLongExtra("LAST_CHANGED_TIMESTAMP", 0L)) + putExtra( + BasePgpActivity.EXTRA_FILE_PATH, + intent.getStringExtra(BasePgpActivity.EXTRA_FILE_PATH) + ) + putExtra( + BasePgpActivity.EXTRA_REPO_PATH, + intent.getStringExtra(BasePgpActivity.EXTRA_REPO_PATH) + ) } else Intent(this, PasswordStore::class.java) startActivity(intentToStart) diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/passwords/PasswordStore.kt b/app/src/main/java/dev/msfjarvis/aps/ui/passwords/PasswordStore.kt index 74c46ef6..b42c30e9 100644 --- a/app/src/main/java/dev/msfjarvis/aps/ui/passwords/PasswordStore.kt +++ b/app/src/main/java/dev/msfjarvis/aps/ui/passwords/PasswordStore.kt @@ -34,10 +34,12 @@ import dagger.hilt.android.AndroidEntryPoint import dev.msfjarvis.aps.R import dev.msfjarvis.aps.data.password.PasswordItem import dev.msfjarvis.aps.data.repo.PasswordRepository +import dev.msfjarvis.aps.ui.crypto.BasePgpActivity import dev.msfjarvis.aps.ui.crypto.BasePgpActivity.Companion.getLongName import dev.msfjarvis.aps.ui.crypto.DecryptActivity import dev.msfjarvis.aps.ui.crypto.DecryptActivityV2 import dev.msfjarvis.aps.ui.crypto.PasswordCreationActivity +import dev.msfjarvis.aps.ui.crypto.PasswordCreationActivityV2 import dev.msfjarvis.aps.ui.dialogs.BasicBottomSheet import dev.msfjarvis.aps.ui.dialogs.FolderCreationDialogFragment import dev.msfjarvis.aps.ui.folderselect.SelectFolderActivity @@ -455,9 +457,15 @@ class PasswordStore : BaseGitActivity() { if (!validateState()) return val currentDir = currentDir logcat(INFO) { "Adding file to : ${currentDir.absolutePath}" } - val intent = Intent(this, PasswordCreationActivity::class.java) - intent.putExtra("FILE_PATH", currentDir.absolutePath) - intent.putExtra("REPO_PATH", PasswordRepository.getRepositoryDirectory().absolutePath) + val creationActivity = + if (FeatureFlags.ENABLE_PGP_V2_BACKEND) PasswordCreationActivityV2::class.java + else PasswordCreationActivity::class.java + val intent = Intent(this, creationActivity) + intent.putExtra(BasePgpActivity.EXTRA_FILE_PATH, currentDir.absolutePath) + intent.putExtra( + BasePgpActivity.EXTRA_REPO_PATH, + PasswordRepository.getRepositoryDirectory().absolutePath + ) listRefreshAction.launch(intent) } |