aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/main/java/dev/msfjarvis/aps/ui/autofill
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2022-04-25 10:47:02 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2022-04-25 10:47:02 +0530
commitaaf6ceb8ecbc71f6948c84b1a19fb83abfe8a418 (patch)
treef688f0bf69ce4db3781cf40c76d4315165f8c24e /app/src/main/java/dev/msfjarvis/aps/ui/autofill
parent11720e95429f03be7a4903989fbd011dd630b847 (diff)
downloadHardenedPass-aaf6ceb8ecbc71f6948c84b1a19fb83abfe8a418.tar.gz
HardenedPass-aaf6ceb8ecbc71f6948c84b1a19fb83abfe8a418.zip
all: reformat with ktfmt 0.36
Diffstat (limited to 'app/src/main/java/dev/msfjarvis/aps/ui/autofill')
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/autofill/AutofillDecryptActivity.kt44
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/autofill/AutofillDecryptActivityV2.kt24
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/autofill/AutofillFilterView.kt44
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/autofill/AutofillPublisherChangedActivity.kt39
4 files changed, 76 insertions, 75 deletions
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/autofill/AutofillDecryptActivity.kt b/app/src/main/java/dev/msfjarvis/aps/ui/autofill/AutofillDecryptActivity.kt
index 291c654f..bd3141a8 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/autofill/AutofillDecryptActivity.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/autofill/AutofillDecryptActivity.kt
@@ -200,18 +200,18 @@ class AutofillDecryptActivity : AppCompatActivity() {
) {
OpenPgpApi.RESULT_CODE_SUCCESS -> {
runCatching {
- val entry =
- withContext(Dispatchers.IO) {
- @Suppress("BlockingMethodInNonBlockingContext")
- passwordEntryFactory.create(decryptedOutput.toByteArray())
- }
- AutofillPreferences.credentialsFromStoreEntry(
- this,
- file,
- entry,
- directoryStructure
- )
- }
+ val entry =
+ withContext(Dispatchers.IO) {
+ @Suppress("BlockingMethodInNonBlockingContext")
+ passwordEntryFactory.create(decryptedOutput.toByteArray())
+ }
+ AutofillPreferences.credentialsFromStoreEntry(
+ this,
+ file,
+ entry,
+ directoryStructure
+ )
+ }
.getOrElse { e ->
logcat(ERROR) { e.asLog("Failed to parse password entry") }
return null
@@ -221,17 +221,17 @@ class AutofillDecryptActivity : AppCompatActivity() {
val pendingIntent: PendingIntent =
result.getParcelableExtra(OpenPgpApi.RESULT_INTENT)!!
runCatching {
- val intentToResume =
- withContext(Dispatchers.Main) {
- suspendCoroutine<Intent> { cont ->
- continueAfterUserInteraction = cont
- decryptInteractionRequiredAction.launch(
- IntentSenderRequest.Builder(pendingIntent.intentSender).build()
- )
+ val intentToResume =
+ withContext(Dispatchers.Main) {
+ suspendCoroutine<Intent> { cont ->
+ continueAfterUserInteraction = cont
+ decryptInteractionRequiredAction.launch(
+ IntentSenderRequest.Builder(pendingIntent.intentSender).build()
+ )
+ }
}
- }
- decryptCredential(file, intentToResume)
- }
+ decryptCredential(file, intentToResume)
+ }
.getOrElse { e ->
logcat(ERROR) {
e.asLog("OpenPgpApi ACTION_DECRYPT_VERIFY failed with user interaction")
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 d7287605..af875e00 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
@@ -150,25 +150,25 @@ class AutofillDecryptActivityV2 : AppCompatActivity() {
}
.onSuccess { encryptedInput ->
runCatching {
- withContext(Dispatchers.IO) {
- val outputStream = ByteArrayOutputStream()
- repository.decrypt(
- password,
- encryptedInput,
- outputStream,
- )
- outputStream
+ withContext(Dispatchers.IO) {
+ val outputStream = ByteArrayOutputStream()
+ repository.decrypt(
+ password,
+ encryptedInput,
+ outputStream,
+ )
+ outputStream
+ }
}
- }
.onFailure { e ->
logcat(ERROR) { e.asLog("Decryption failed") }
return null
}
.onSuccess { result ->
return runCatching {
- val entry = passwordEntryFactory.create(result.toByteArray())
- AutofillPreferences.credentialsFromStoreEntry(this, file, entry, directoryStructure)
- }
+ val entry = passwordEntryFactory.create(result.toByteArray())
+ AutofillPreferences.credentialsFromStoreEntry(this, file, entry, directoryStructure)
+ }
.getOrElse { e ->
logcat(ERROR) { e.asLog("Failed to parse password entry") }
return null
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/autofill/AutofillFilterView.kt b/app/src/main/java/dev/msfjarvis/aps/ui/autofill/AutofillFilterView.kt
index 573e5337..6bf238a1 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/autofill/AutofillFilterView.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/autofill/AutofillFilterView.kt
@@ -149,31 +149,31 @@ class AutofillFilterView : AppCompatActivity() {
::PasswordViewHolder,
lifecycleScope,
) { item ->
- val file = item.file.relativeTo(item.rootDir)
- val pathToIdentifier = directoryStructure.getPathToIdentifierFor(file)
- val identifier = directoryStructure.getIdentifierFor(file)
- val accountPart = directoryStructure.getAccountPartFor(file)
- check(identifier != null || accountPart != null) {
- "At least one of identifier and accountPart should always be non-null"
- }
- title.text =
- if (identifier != null) {
- buildSpannedString {
- if (pathToIdentifier != null) append("$pathToIdentifier/")
- bold { underline { append(identifier) } }
- }
- } else {
- accountPart
+ val file = item.file.relativeTo(item.rootDir)
+ val pathToIdentifier = directoryStructure.getPathToIdentifierFor(file)
+ val identifier = directoryStructure.getIdentifierFor(file)
+ val accountPart = directoryStructure.getAccountPartFor(file)
+ check(identifier != null || accountPart != null) {
+ "At least one of identifier and accountPart should always be non-null"
}
- subtitle.apply {
- if (identifier != null && accountPart != null) {
- text = accountPart
- visibility = View.VISIBLE
- } else {
- visibility = View.GONE
+ title.text =
+ if (identifier != null) {
+ buildSpannedString {
+ if (pathToIdentifier != null) append("$pathToIdentifier/")
+ bold { underline { append(identifier) } }
+ }
+ } else {
+ accountPart
+ }
+ subtitle.apply {
+ if (identifier != null && accountPart != null) {
+ text = accountPart
+ visibility = View.VISIBLE
+ } else {
+ visibility = View.GONE
+ }
}
}
- }
.onItemClicked { _, item -> decryptAndFill(item) }
layoutManager = LinearLayoutManager(context)
}
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/autofill/AutofillPublisherChangedActivity.kt b/app/src/main/java/dev/msfjarvis/aps/ui/autofill/AutofillPublisherChangedActivity.kt
index 794fad8c..b0b5ea9c 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/autofill/AutofillPublisherChangedActivity.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/autofill/AutofillPublisherChangedActivity.kt
@@ -105,27 +105,28 @@ class AutofillPublisherChangedActivity : AppCompatActivity() {
private fun showPackageInfo() {
runCatching {
- with(binding) {
- val packageInfo = packageManager.getPackageInfo(appPackage, PackageManager.GET_META_DATA)
- val installTime = DateUtils.getRelativeTimeSpanString(packageInfo.firstInstallTime)
- warningAppInstallDate.text =
- getString(R.string.oreo_autofill_warning_publisher_install_time, installTime)
- val appInfo = packageManager.getApplicationInfo(appPackage, PackageManager.GET_META_DATA)
- warningAppName.text =
- getString(
- R.string.oreo_autofill_warning_publisher_app_name,
- packageManager.getApplicationLabel(appInfo)
- )
+ with(binding) {
+ val packageInfo = packageManager.getPackageInfo(appPackage, PackageManager.GET_META_DATA)
+ val installTime = DateUtils.getRelativeTimeSpanString(packageInfo.firstInstallTime)
+ warningAppInstallDate.text =
+ getString(R.string.oreo_autofill_warning_publisher_install_time, installTime)
+ val appInfo = packageManager.getApplicationInfo(appPackage, PackageManager.GET_META_DATA)
+ warningAppName.text =
+ getString(
+ R.string.oreo_autofill_warning_publisher_app_name,
+ packageManager.getApplicationLabel(appInfo)
+ )
- val currentHash = computeCertificatesHash(this@AutofillPublisherChangedActivity, appPackage)
- warningAppAdvancedInfo.text =
- getString(
- R.string.oreo_autofill_warning_publisher_advanced_info_template,
- appPackage,
- currentHash
- )
+ val currentHash =
+ computeCertificatesHash(this@AutofillPublisherChangedActivity, appPackage)
+ warningAppAdvancedInfo.text =
+ getString(
+ R.string.oreo_autofill_warning_publisher_advanced_info_template,
+ appPackage,
+ currentHash
+ )
+ }
}
- }
.onFailure { e ->
logcat(ERROR) { e.asLog("Failed to retrieve package info for $appPackage") }
finish()