summaryrefslogtreecommitdiffstats
path: root/app/src/main/java/dev/msfjarvis/aps/ui
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2021-05-15 12:56:49 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2021-05-15 15:40:20 +0530
commit7e2eb2425e7b9b6ccb37b7b89f19de3fa7a20c44 (patch)
tree6b8a9557ac51b5fab5d2ad7611084cf0de6c57cf /app/src/main/java/dev/msfjarvis/aps/ui
parent2fcb285e276594842798be6990b92ba09e733f49 (diff)
downloadHardenedPass-7e2eb2425e7b9b6ccb37b7b89f19de3fa7a20c44.tar.gz
HardenedPass-7e2eb2425e7b9b6ccb37b7b89f19de3fa7a20c44.zip
all: reformat with Spotless again
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'app/src/main/java/dev/msfjarvis/aps/ui')
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/adapters/FieldItemAdapter.kt6
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/adapters/PasswordItemRecyclerAdapter.kt10
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/autofill/AutofillDecryptActivity.kt49
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/autofill/AutofillFilterActivity.kt40
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/autofill/AutofillPublisherChangedActivity.kt19
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/autofill/AutofillSaveActivity.kt48
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/crypto/BasePgpActivity.kt10
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/crypto/DecryptActivity.kt29
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/crypto/GetKeyIdsActivity.kt4
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/crypto/PasswordCreationActivity.kt128
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/dialogs/BasicBottomSheet.kt24
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/dialogs/ItemCreationBottomSheet.kt10
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/dialogs/PasswordGeneratorDialogFragment.kt9
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/dialogs/XkPasswordGeneratorDialogFragment.kt12
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/folderselect/SelectFolderActivity.kt9
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/folderselect/SelectFolderFragment.kt17
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/git/base/BaseGitActivity.kt10
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/git/config/GitConfigActivity.kt10
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/git/config/GitServerConfigActivity.kt39
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/git/log/GitLogAdapter.kt3
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/onboarding/fragments/CloneFragment.kt4
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/onboarding/fragments/KeySelectionFragment.kt12
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/onboarding/fragments/RepoLocationFragment.kt15
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/onboarding/fragments/WelcomeFragment.kt4
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/passwords/PasswordFragment.kt70
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/passwords/PasswordStore.kt71
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/proxy/ProxySelectorActivity.kt24
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/settings/AutofillSettings.kt19
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/settings/DirectorySelectionActivity.kt4
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/settings/GeneralSettings.kt6
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/settings/RepositorySettings.kt16
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/settings/SettingsActivity.kt4
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/sshkeygen/ShowSshKeyFragment.kt4
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/sshkeygen/SshKeyGenActivity.kt16
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/sshkeygen/SshKeyImportActivity.kt7
35 files changed, 578 insertions, 184 deletions
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/adapters/FieldItemAdapter.kt b/app/src/main/java/dev/msfjarvis/aps/ui/adapters/FieldItemAdapter.kt
index afb2a130..030f6056 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/adapters/FieldItemAdapter.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/adapters/FieldItemAdapter.kt
@@ -55,7 +55,8 @@ class FieldItemAdapter(
notifyDataSetChanged()
}
- class FieldItemViewHolder(itemView: View, val binding: ItemFieldBinding) : RecyclerView.ViewHolder(itemView) {
+ class FieldItemViewHolder(itemView: View, val binding: ItemFieldBinding) :
+ RecyclerView.ViewHolder(itemView) {
fun bind(fieldItem: FieldItem, showPassword: Boolean, copyTextToClipBoard: (String?) -> Unit) {
with(binding) {
@@ -66,7 +67,8 @@ class FieldItemAdapter(
when (fieldItem.action) {
FieldItem.ActionType.COPY -> {
itemTextContainer.apply {
- endIconDrawable = ContextCompat.getDrawable(itemView.context, R.drawable.ic_content_copy)
+ endIconDrawable =
+ ContextCompat.getDrawable(itemView.context, R.drawable.ic_content_copy)
endIconMode = TextInputLayout.END_ICON_CUSTOM
setEndIconOnClickListener { copyTextToClipBoard(itemText.text.toString()) }
}
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/adapters/PasswordItemRecyclerAdapter.kt b/app/src/main/java/dev/msfjarvis/aps/ui/adapters/PasswordItemRecyclerAdapter.kt
index fc3b1a7e..a551a8b1 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/adapters/PasswordItemRecyclerAdapter.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/adapters/PasswordItemRecyclerAdapter.kt
@@ -35,7 +35,9 @@ open class PasswordItemRecyclerAdapter :
return super.onItemClicked(listener) as PasswordItemRecyclerAdapter
}
- override fun onSelectionChanged(listener: (selection: Selection<String>) -> Unit): PasswordItemRecyclerAdapter {
+ override fun onSelectionChanged(
+ listener: (selection: Selection<String>) -> Unit
+ ): PasswordItemRecyclerAdapter {
return super.onSelectionChanged(listener) as PasswordItemRecyclerAdapter
}
@@ -59,7 +61,8 @@ open class PasswordItemRecyclerAdapter :
name.text = spannable
if (item.type == PasswordItem.TYPE_CATEGORY) {
folderIndicator.visibility = View.VISIBLE
- val count = item.file.listFiles { path -> path.isDirectory || path.extension == "gpg" }?.size ?: 0
+ val count =
+ item.file.listFiles { path -> path.isDirectory || path.extension == "gpg" }?.size ?: 0
childCount.visibility = if (count > 0) View.VISIBLE else View.GONE
childCount.text = "$count"
} else {
@@ -74,7 +77,8 @@ open class PasswordItemRecyclerAdapter :
}
}
- class PasswordItemDetailsLookup(private val recyclerView: RecyclerView) : ItemDetailsLookup<String>() {
+ class PasswordItemDetailsLookup(private val recyclerView: RecyclerView) :
+ ItemDetailsLookup<String>() {
override fun getItemDetails(event: MotionEvent): ItemDetails<String>? {
val view = recyclerView.findChildViewUnder(event.x, event.y) ?: return null
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 79fc44aa..07ae4c42 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
@@ -73,7 +73,12 @@ class AutofillDecryptActivity : AppCompatActivity() {
putExtra(EXTRA_SEARCH_ACTION, false)
putExtra(EXTRA_FILE_PATH, file.absolutePath)
}
- return PendingIntent.getActivity(context, decryptFileRequestCode++, intent, PendingIntent.FLAG_CANCEL_CURRENT)
+ return PendingIntent.getActivity(
+ context,
+ decryptFileRequestCode++,
+ intent,
+ PendingIntent.FLAG_CANCEL_CURRENT
+ )
.intentSender
}
}
@@ -124,9 +129,17 @@ class AutofillDecryptActivity : AppCompatActivity() {
setResult(RESULT_CANCELED)
} else {
val fillInDataset =
- AutofillResponseBuilder.makeFillInDataset(this@AutofillDecryptActivity, credentials, clientState, action)
+ AutofillResponseBuilder.makeFillInDataset(
+ this@AutofillDecryptActivity,
+ credentials,
+ clientState,
+ action
+ )
withContext(Dispatchers.Main) {
- setResult(RESULT_OK, Intent().apply { putExtra(AutofillManager.EXTRA_AUTHENTICATION_RESULT, fillInDataset) })
+ setResult(
+ RESULT_OK,
+ Intent().apply { putExtra(AutofillManager.EXTRA_AUTHENTICATION_RESULT, fillInDataset) }
+ )
}
}
withContext(Dispatchers.Main) { finish() }
@@ -137,7 +150,11 @@ class AutofillDecryptActivity : AppCompatActivity() {
super.onDestroy()
}
- private suspend fun executeOpenPgpApi(data: Intent, input: InputStream, output: OutputStream): Intent? {
+ private suspend fun executeOpenPgpApi(
+ data: Intent,
+ input: InputStream,
+ output: OutputStream
+ ): Intent? {
var openPgpServiceConnection: OpenPgpServiceConnection? = null
val openPgpService =
suspendCoroutine<IOpenPgpService2> { cont ->
@@ -177,7 +194,9 @@ class AutofillDecryptActivity : AppCompatActivity() {
return null
}
.onSuccess { result ->
- return when (val resultCode = result?.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)) {
+ return when (val resultCode =
+ result?.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)
+ ) {
OpenPgpApi.RESULT_CODE_SUCCESS -> {
runCatching {
val entry =
@@ -185,7 +204,12 @@ class AutofillDecryptActivity : AppCompatActivity() {
@Suppress("BlockingMethodInNonBlockingContext")
passwordEntryFactory.create(lifecycleScope, decryptedOutput.toByteArray())
}
- AutofillPreferences.credentialsFromStoreEntry(this, file, entry, directoryStructure)
+ AutofillPreferences.credentialsFromStoreEntry(
+ this,
+ file,
+ entry,
+ directoryStructure
+ )
}
.getOrElse { e ->
e(e) { "Failed to parse password entry" }
@@ -193,7 +217,8 @@ class AutofillDecryptActivity : AppCompatActivity() {
}
}
OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED -> {
- val pendingIntent: PendingIntent = result.getParcelableExtra(OpenPgpApi.RESULT_INTENT)!!
+ val pendingIntent: PendingIntent =
+ result.getParcelableExtra(OpenPgpApi.RESULT_INTENT)!!
runCatching {
val intentToResume =
withContext(Dispatchers.Main) {
@@ -215,10 +240,16 @@ class AutofillDecryptActivity : AppCompatActivity() {
val error = result.getParcelableExtra<OpenPgpError>(OpenPgpApi.RESULT_ERROR)
if (error != null) {
withContext(Dispatchers.Main) {
- Toast.makeText(applicationContext, "Error from OpenKeyChain: ${error.message}", Toast.LENGTH_LONG)
+ Toast.makeText(
+ applicationContext,
+ "Error from OpenKeyChain: ${error.message}",
+ Toast.LENGTH_LONG
+ )
.show()
}
- e { "OpenPgpApi ACTION_DECRYPT_VERIFY failed (${error.errorId}): ${error.message}" }
+ e {
+ "OpenPgpApi ACTION_DECRYPT_VERIFY failed (${error.errorId}): ${error.message}"
+ }
}
null
}
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/autofill/AutofillFilterActivity.kt b/app/src/main/java/dev/msfjarvis/aps/ui/autofill/AutofillFilterActivity.kt
index cf833a19..aac7008d 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/autofill/AutofillFilterActivity.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/autofill/AutofillFilterActivity.kt
@@ -46,11 +46,16 @@ class AutofillFilterView : AppCompatActivity() {
private const val HEIGHT_PERCENTAGE = 0.9
private const val WIDTH_PERCENTAGE = 0.75
- private const val EXTRA_FORM_ORIGIN_WEB = "dev.msfjarvis.aps.autofill.oreo.ui.EXTRA_FORM_ORIGIN_WEB"
- private const val EXTRA_FORM_ORIGIN_APP = "dev.msfjarvis.aps.autofill.oreo.ui.EXTRA_FORM_ORIGIN_APP"
+ private const val EXTRA_FORM_ORIGIN_WEB =
+ "dev.msfjarvis.aps.autofill.oreo.ui.EXTRA_FORM_ORIGIN_WEB"
+ private const val EXTRA_FORM_ORIGIN_APP =
+ "dev.msfjarvis.aps.autofill.oreo.ui.EXTRA_FORM_ORIGIN_APP"
private var matchAndDecryptFileRequestCode = 1
- fun makeMatchAndDecryptFileIntentSender(context: Context, formOrigin: FormOrigin): IntentSender {
+ fun makeMatchAndDecryptFileIntentSender(
+ context: Context,
+ formOrigin: FormOrigin
+ ): IntentSender {
val intent =
Intent(context, AutofillFilterView::class.java).apply {
when (formOrigin) {
@@ -108,7 +113,9 @@ class AutofillFilterView : AppCompatActivity() {
FormOrigin.App(intent!!.getStringExtra(EXTRA_FORM_ORIGIN_APP)!!)
}
else -> {
- e { "AutofillFilterActivity started without EXTRA_FORM_ORIGIN_WEB or EXTRA_FORM_ORIGIN_APP" }
+ e {
+ "AutofillFilterActivity started without EXTRA_FORM_ORIGIN_WEB or EXTRA_FORM_ORIGIN_APP"
+ }
finish()
return
}
@@ -125,7 +132,8 @@ class AutofillFilterView : AppCompatActivity() {
with(binding) {
rvPassword.apply {
adapter =
- SearchableRepositoryAdapter(R.layout.oreo_autofill_filter_row, ::PasswordViewHolder) { item ->
+ SearchableRepositoryAdapter(R.layout.oreo_autofill_filter_row, ::PasswordViewHolder) {
+ item ->
val file = item.file.relativeTo(item.rootDir)
val pathToIdentifier = directoryStructure.getPathToIdentifierFor(file)
val identifier = directoryStructure.getIdentifierFor(file)
@@ -171,10 +179,15 @@ class AutofillFilterView : AppCompatActivity() {
setOnCheckedChangeListener { _, _ -> updateSearch() }
}
shouldMatch.text =
- getString(R.string.oreo_autofill_match_with, formOrigin.getPrettyIdentifier(applicationContext))
+ getString(
+ R.string.oreo_autofill_match_with,
+ formOrigin.getPrettyIdentifier(applicationContext)
+ )
model.searchResult.observe(this@AutofillFilterView) { result ->
val list = result.passwordItems
- (rvPassword.adapter as SearchableRepositoryAdapter).submitList(list) { rvPassword.scrollToPosition(0) }
+ (rvPassword.adapter as SearchableRepositoryAdapter).submitList(list) {
+ rvPassword.scrollToPosition(0)
+ }
// Switch RecyclerView out for a "no results" message if the new list is empty and
// the message is not yet shown (and vice versa).
if ((list.isEmpty() && rvPasswordSwitcher.nextView.id == rvPasswordEmpty.id) ||
@@ -189,16 +202,21 @@ class AutofillFilterView : AppCompatActivity() {
private fun updateSearch() {
model.search(
binding.search.text.toString().trim(),
- filterMode = if (binding.strictDomainSearch.isChecked) FilterMode.StrictDomain else FilterMode.Fuzzy,
+ filterMode =
+ if (binding.strictDomainSearch.isChecked) FilterMode.StrictDomain else FilterMode.Fuzzy,
searchMode = SearchMode.RecursivelyInSubdirectories,
listMode = ListMode.FilesOnly
)
}
private fun decryptAndFill(item: PasswordItem) {
- if (binding.shouldClear.isChecked) AutofillMatcher.clearMatchesFor(applicationContext, formOrigin)
- if (binding.shouldMatch.isChecked) AutofillMatcher.addMatchFor(applicationContext, formOrigin, item.file)
+ if (binding.shouldClear.isChecked)
+ AutofillMatcher.clearMatchesFor(applicationContext, formOrigin)
+ if (binding.shouldMatch.isChecked)
+ AutofillMatcher.addMatchFor(applicationContext, formOrigin, item.file)
// intent?.extras? is checked to be non-null in onCreate
- decryptAction.launch(AutofillDecryptActivity.makeDecryptFileIntent(item.file, intent!!.extras!!, this))
+ decryptAction.launch(
+ AutofillDecryptActivity.makeDecryptFileIntent(item.file, intent!!.extras!!, this)
+ )
}
}
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 bea2bcd3..6ea47ea1 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
@@ -83,9 +83,15 @@ class AutofillPublisherChangedActivity : AppCompatActivity() {
resetButton.visibility = View.VISIBLE
}
resetButton.setOnClickListener {
- AutofillMatcher.clearMatchesFor(this@AutofillPublisherChangedActivity, FormOrigin.App(appPackage))
+ AutofillMatcher.clearMatchesFor(
+ this@AutofillPublisherChangedActivity,
+ FormOrigin.App(appPackage)
+ )
val fillResponse = intent.getParcelableExtra<FillResponse>(EXTRA_FILL_RESPONSE_AFTER_RESET)
- setResult(RESULT_OK, Intent().apply { putExtra(AutofillManager.EXTRA_AUTHENTICATION_RESULT, fillResponse) })
+ setResult(
+ RESULT_OK,
+ Intent().apply { putExtra(AutofillManager.EXTRA_AUTHENTICATION_RESULT, fillResponse) }
+ )
finish()
}
}
@@ -96,13 +102,18 @@ class AutofillPublisherChangedActivity : AppCompatActivity() {
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)
+ warningAppInstallDate.text =
+ getString(R.string.oreo_autofill_warning_publisher_install_time, installTime)
val appInfo = packageManager.getApplicationInfo(appPackage, PackageManager.GET_META_DATA)
warningAppName.text = "“${packageManager.getApplicationLabel(appInfo)}”"
val currentHash = computeCertificatesHash(this@AutofillPublisherChangedActivity, appPackage)
warningAppAdvancedInfo.text =
- getString(R.string.oreo_autofill_warning_publisher_advanced_info_template, appPackage, currentHash)
+ getString(
+ R.string.oreo_autofill_warning_publisher_advanced_info_template,
+ appPackage,
+ currentHash
+ )
}
}
.onFailure { e ->
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 dfec29be..ee3cf752 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
@@ -34,13 +34,20 @@ class AutofillSaveActivity : AppCompatActivity() {
private const val EXTRA_FOLDER_NAME = "dev.msfjarvis.aps.autofill.oreo.ui.EXTRA_FOLDER_NAME"
private const val EXTRA_PASSWORD = "dev.msfjarvis.aps.autofill.oreo.ui.EXTRA_PASSWORD"
private const val EXTRA_NAME = "dev.msfjarvis.aps.autofill.oreo.ui.EXTRA_NAME"
- private const val EXTRA_SHOULD_MATCH_APP = "dev.msfjarvis.aps.autofill.oreo.ui.EXTRA_SHOULD_MATCH_APP"
- private const val EXTRA_SHOULD_MATCH_WEB = "dev.msfjarvis.aps.autofill.oreo.ui.EXTRA_SHOULD_MATCH_WEB"
- private const val EXTRA_GENERATE_PASSWORD = "dev.msfjarvis.aps.autofill.oreo.ui.EXTRA_GENERATE_PASSWORD"
+ private const val EXTRA_SHOULD_MATCH_APP =
+ "dev.msfjarvis.aps.autofill.oreo.ui.EXTRA_SHOULD_MATCH_APP"
+ private const val EXTRA_SHOULD_MATCH_WEB =
+ "dev.msfjarvis.aps.autofill.oreo.ui.EXTRA_SHOULD_MATCH_WEB"
+ private const val EXTRA_GENERATE_PASSWORD =
+ "dev.msfjarvis.aps.autofill.oreo.ui.EXTRA_GENERATE_PASSWORD"
private var saveRequestCode = 1
- fun makeSaveIntentSender(context: Context, credentials: Credentials?, formOrigin: FormOrigin): IntentSender {
+ fun makeSaveIntentSender(
+ context: Context,
+ credentials: Credentials?,
+ formOrigin: FormOrigin
+ ): IntentSender {
val identifier = formOrigin.getPrettyIdentifier(context, untrusted = false)
// Prevent directory traversals
val sanitizedIdentifier =
@@ -52,7 +59,11 @@ class AutofillSaveActivity : AppCompatActivity() {
sanitizedIdentifier = sanitizedIdentifier,
username = credentials?.username
)
- val fileName = directoryStructure.getSaveFileName(username = credentials?.username, identifier = identifier)
+ val fileName =
+ directoryStructure.getSaveFileName(
+ username = credentials?.username,
+ identifier = identifier
+ )
val intent =
Intent(context, AutofillSaveActivity::class.java).apply {
putExtras(
@@ -60,13 +71,20 @@ class AutofillSaveActivity : AppCompatActivity() {
EXTRA_FOLDER_NAME to folderName,
EXTRA_NAME to fileName,
EXTRA_PASSWORD to credentials?.password,
- EXTRA_SHOULD_MATCH_APP to formOrigin.identifier.takeIf { formOrigin is FormOrigin.App },
- EXTRA_SHOULD_MATCH_WEB to formOrigin.identifier.takeIf { formOrigin is FormOrigin.Web },
+ EXTRA_SHOULD_MATCH_APP to
+ formOrigin.identifier.takeIf { formOrigin is FormOrigin.App },
+ EXTRA_SHOULD_MATCH_WEB to
+ formOrigin.identifier.takeIf { formOrigin is FormOrigin.Web },
EXTRA_GENERATE_PASSWORD to (credentials == null)
)
)
}
- return PendingIntent.getActivity(context, saveRequestCode++, intent, PendingIntent.FLAG_CANCEL_CURRENT)
+ return PendingIntent.getActivity(
+ context,
+ saveRequestCode++,
+ intent,
+ PendingIntent.FLAG_CANCEL_CURRENT
+ )
.intentSender
}
}
@@ -94,7 +112,8 @@ class AutofillSaveActivity : AppCompatActivity() {
"FILE_PATH" to repo.resolve(intent.getStringExtra(EXTRA_FOLDER_NAME)!!).absolutePath,
PasswordCreationActivity.EXTRA_FILE_NAME to intent.getStringExtra(EXTRA_NAME),
PasswordCreationActivity.EXTRA_PASSWORD to intent.getStringExtra(EXTRA_PASSWORD),
- PasswordCreationActivity.EXTRA_GENERATE_PASSWORD to intent.getBooleanExtra(EXTRA_GENERATE_PASSWORD, false)
+ PasswordCreationActivity.EXTRA_GENERATE_PASSWORD to
+ intent.getBooleanExtra(EXTRA_GENERATE_PASSWORD, false)
)
)
}
@@ -117,8 +136,15 @@ class AutofillSaveActivity : AppCompatActivity() {
}
val credentials = Credentials(username, password, null)
val fillInDataset =
- AutofillResponseBuilder.makeFillInDataset(this, credentials, clientState, AutofillAction.Generate)
- Intent().apply { putExtra(AutofillManager.EXTRA_AUTHENTICATION_RESULT, fillInDataset) }
+ AutofillResponseBuilder.makeFillInDataset(
+ this,
+ credentials,
+ clientState,
+ AutofillAction.Generate
+ )
+ Intent().apply {
+ putExtra(AutofillManager.EXTRA_AUTHENTICATION_RESULT, fillInDataset)
+ }
} else {
// Password was extracted from a form, there is nothing to fill.
Intent()
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 eea7f79a..f17ca72b 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
@@ -157,7 +157,10 @@ open class BasePgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBou
return
} else {
previousListener = null
- serviceConnection = OpenPgpServiceConnection(this, OPENPGP_PROVIDER, onBoundListener).also { it.bindToService() }
+ serviceConnection =
+ OpenPgpServiceConnection(this, OPENPGP_PROVIDER, onBoundListener).also {
+ it.bindToService()
+ }
}
}
@@ -250,7 +253,10 @@ open class BasePgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBou
fun getParentPath(fullPath: String, repositoryPath: String): String {
val relativePath = getRelativePath(fullPath, repositoryPath)
val index = relativePath.lastIndexOf("/")
- return "/${relativePath.substring(startIndex = 0, endIndex = index + 1)}/".replace("/+".toRegex(), "/")
+ return "/${relativePath.substring(startIndex = 0, endIndex = index + 1)}/".replace(
+ "/+".toRegex(),
+ "/"
+ )
}
/** /path/to/store/social/facebook.gpg -> social/facebook */
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/crypto/DecryptActivity.kt b/app/src/main/java/dev/msfjarvis/aps/ui/crypto/DecryptActivity.kt
index 24859852..e17ce612 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/crypto/DecryptActivity.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/crypto/DecryptActivity.kt
@@ -44,7 +44,9 @@ class DecryptActivity : BasePgpActivity(), OpenPgpServiceConnection.OnBound {
private val binding by viewBinding(DecryptLayoutBinding::inflate)
@Inject lateinit var passwordEntryFactory: PasswordEntryFactory
- private val relativeParentPath by lazy(LazyThreadSafetyMode.NONE) { getParentPath(fullPath, repoPath) }
+ private val relativeParentPath by lazy(LazyThreadSafetyMode.NONE) {
+ getParentPath(fullPath, repoPath)
+ }
private var passwordEntry: PasswordEntry? = null
private val userInteractionRequiredResult =
@@ -136,7 +138,10 @@ class DecryptActivity : BasePgpActivity(), OpenPgpServiceConnection.OnBound {
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?.extraContentWithoutAuthData)
+ intent.putExtra(
+ PasswordCreationActivity.EXTRA_EXTRA_CONTENT,
+ passwordEntry?.extraContentWithoutAuthData
+ )
intent.putExtra(PasswordCreationActivity.EXTRA_EDITING, true)
startActivity(intent)
finish()
@@ -150,7 +155,9 @@ class DecryptActivity : BasePgpActivity(), OpenPgpServiceConnection.OnBound {
type = "text/plain"
}
// Always show a picker to give the user a chance to cancel
- startActivity(Intent.createChooser(sendIntent, resources.getText(R.string.send_plaintext_password_to)))
+ startActivity(
+ Intent.createChooser(sendIntent, resources.getText(R.string.send_plaintext_password_to))
+ )
}
@OptIn(ExperimentalTime::class)
@@ -166,7 +173,10 @@ class DecryptActivity : BasePgpActivity(), OpenPgpServiceConnection.OnBound {
val outputStream = ByteArrayOutputStream()
lifecycleScope.launch(Dispatchers.Main) {
- val result = withContext(Dispatchers.IO) { checkNotNull(api).executeApi(data, inputStream, outputStream) }
+ val result =
+ withContext(Dispatchers.IO) {
+ checkNotNull(api).executeApi(data, inputStream, outputStream)
+ }
when (result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)) {
OpenPgpApi.RESULT_CODE_SUCCESS -> {
startAutoDismissTimer()
@@ -174,7 +184,8 @@ class DecryptActivity : BasePgpActivity(), OpenPgpServiceConnection.OnBound {
val showPassword = settings.getBoolean(PreferenceKeys.SHOW_PASSWORD, true)
val entry = passwordEntryFactory.create(lifecycleScope, outputStream.toByteArray())
val items = arrayListOf<FieldItem>()
- val adapter = FieldItemAdapter(emptyList(), showPassword) { text -> copyTextToClipboard(text) }
+ val adapter =
+ FieldItemAdapter(emptyList(), showPassword) { text -> copyTextToClipboard(text) }
if (settings.getBoolean(PreferenceKeys.COPY_ON_DECRYPT, false)) {
copyPasswordToClipboard(entry.password)
@@ -190,7 +201,9 @@ class DecryptActivity : BasePgpActivity(), OpenPgpServiceConnection.OnBound {
if (entry.hasTotp()) {
launch {
items.add(FieldItem.createOtpField(entry.totp.value))
- entry.totp.collect { code -> withContext(Dispatchers.Main) { adapter.updateOTPCode(code) } }
+ entry.totp.collect { code ->
+ withContext(Dispatchers.Main) { adapter.updateOTPCode(code) }
+ }
}
}
@@ -198,7 +211,9 @@ class DecryptActivity : BasePgpActivity(), OpenPgpServiceConnection.OnBound {
items.add(FieldItem.createUsernameField(entry.username!!))
}
- entry.extraContent.forEach { (key, value) -> items.add(FieldItem(key, value, FieldItem.ActionType.COPY)) }
+ entry.extraContent.forEach { (key, value) ->
+ items.add(FieldItem(key, value, FieldItem.ActionType.COPY))
+ }
binding.recyclerView.adapter = adapter
adapter.updateItems(items)
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/crypto/GetKeyIdsActivity.kt b/app/src/main/java/dev/msfjarvis/aps/ui/crypto/GetKeyIdsActivity.kt
index 120ccaab..c98ea877 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/crypto/GetKeyIdsActivity.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/crypto/GetKeyIdsActivity.kt
@@ -55,7 +55,9 @@ class GetKeyIdsActivity : BasePgpActivity() {
OpenPgpApi.RESULT_CODE_SUCCESS -> {
runCatching {
val ids =
- result.getLongArrayExtra(OpenPgpApi.RESULT_KEY_IDS)?.map { OpenPgpUtils.convertKeyIdToHex(it) }
+ result.getLongArrayExtra(OpenPgpApi.RESULT_KEY_IDS)?.map {
+ OpenPgpUtils.convertKeyIdToHex(it)
+ }
?: emptyList()
val keyResult = Intent().putExtra(OpenPgpApi.EXTRA_KEY_IDS, ids.toTypedArray())
setResult(RESULT_OK, keyResult)
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/crypto/PasswordCreationActivity.kt b/app/src/main/java/dev/msfjarvis/aps/ui/crypto/PasswordCreationActivity.kt
index b72b3b86..c9ae348a 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/crypto/PasswordCreationActivity.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/crypto/PasswordCreationActivity.kt
@@ -63,14 +63,24 @@ class PasswordCreationActivity : BasePgpActivity(), OpenPgpServiceConnection.OnB
private val binding by viewBinding(PasswordCreationActivityBinding::inflate)
@Inject lateinit var passwordEntryFactory: PasswordEntryFactory
- private val suggestedName by lazy(LazyThreadSafetyMode.NONE) { intent.getStringExtra(EXTRA_FILE_NAME) }
- private val suggestedPass by lazy(LazyThreadSafetyMode.NONE) { intent.getStringExtra(EXTRA_PASSWORD) }
- private val suggestedExtra by lazy(LazyThreadSafetyMode.NONE) { intent.getStringExtra(EXTRA_EXTRA_CONTENT) }
+ private val suggestedName by lazy(LazyThreadSafetyMode.NONE) {
+ intent.getStringExtra(EXTRA_FILE_NAME)
+ }
+ private val suggestedPass by lazy(LazyThreadSafetyMode.NONE) {
+ intent.getStringExtra(EXTRA_PASSWORD)
+ }
+ private val suggestedExtra by lazy(LazyThreadSafetyMode.NONE) {
+ intent.getStringExtra(EXTRA_EXTRA_CONTENT)
+ }
private val shouldGeneratePassword by lazy(LazyThreadSafetyMode.NONE) {
intent.getBooleanExtra(EXTRA_GENERATE_PASSWORD, false)
}
- private val editing by lazy(LazyThreadSafetyMode.NONE) { intent.getBooleanExtra(EXTRA_EDITING, false) }
- private val oldFileName by lazy(LazyThreadSafetyMode.NONE) { intent.getStringExtra(EXTRA_FILE_NAME) }
+ private val editing by lazy(LazyThreadSafetyMode.NONE) {
+ intent.getBooleanExtra(EXTRA_EDITING, false)
+ }
+ private val oldFileName by lazy(LazyThreadSafetyMode.NONE) {
+ intent.getStringExtra(EXTRA_FILE_NAME)
+ }
private var oldCategory: String? = null
private var copy: Boolean = false
private var encryptionIntent: Intent = Intent()
@@ -99,7 +109,8 @@ class PasswordCreationActivity : BasePgpActivity(), OpenPgpServiceConnection.OnB
val intentResult = IntentIntegrator.parseActivityResult(RESULT_OK, result.data)
val contents = "${intentResult.contents}\n"
val currentExtras = binding.extraContent.text.toString()
- if (currentExtras.isNotEmpty() && currentExtras.last() != '\n') binding.extraContent.append("\n$contents")
+ if (currentExtras.isNotEmpty() && currentExtras.last() != '\n')
+ binding.extraContent.append("\n$contents")
else binding.extraContent.append(contents)
snackbar(message = getString(R.string.otp_import_success))
} else {
@@ -113,18 +124,27 @@ class PasswordCreationActivity : BasePgpActivity(), OpenPgpServiceConnection.OnB
result.data?.getStringArrayExtra(OpenPgpApi.EXTRA_KEY_IDS)?.let { keyIds ->
lifecycleScope.launch {
val gpgIdentifierFile = File(PasswordRepository.getRepositoryDirectory(), ".gpg-id")
- withContext(Dispatchers.IO) { gpgIdentifierFile.writeText((keyIds + "").joinToString("\n")) }
+ withContext(Dispatchers.IO) {
+ gpgIdentifierFile.writeText((keyIds + "").joinToString("\n"))
+ }
commitChange(
getString(
R.string.git_commit_gpg_id,
- getLongName(gpgIdentifierFile.parentFile!!.absolutePath, repoPath, gpgIdentifierFile.name)
+ getLongName(
+ gpgIdentifierFile.parentFile!!.absolutePath,
+ repoPath,
+ gpgIdentifierFile.name
+ )
)
)
.onSuccess { encrypt(encryptionIntent) }
}
}
} else {
- snackbar(message = getString(R.string.gpg_key_select_mandatory), length = Snackbar.LENGTH_LONG)
+ snackbar(
+ message = getString(R.string.gpg_key_select_mandatory),
+ length = Snackbar.LENGTH_LONG
+ )
}
}
@@ -148,24 +168,31 @@ class PasswordCreationActivity : BasePgpActivity(), OpenPgpServiceConnection.OnB
super.onCreate(savedInstanceState)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
bindToOpenKeychain(this)
- title = if (editing) getString(R.string.edit_password) else getString(R.string.new_password_title)
+ title =
+ if (editing) getString(R.string.edit_password) else getString(R.string.new_password_title)
with(binding) {
setContentView(root)
generatePassword.setOnClickListener { generatePassword() }
otpImportButton.setOnClickListener {
- supportFragmentManager.setFragmentResultListener(OTP_RESULT_REQUEST_KEY, this@PasswordCreationActivity) {
- requestKey,
- bundle ->
+ supportFragmentManager.setFragmentResultListener(
+ OTP_RESULT_REQUEST_KEY,
+ this@PasswordCreationActivity
+ ) { requestKey, bundle ->
if (requestKey == OTP_RESULT_REQUEST_KEY) {
val contents = bundle.getString(RESULT)
val currentExtras = binding.extraContent.text.toString()
- if (currentExtras.isNotEmpty() && currentExtras.last() != '\n') binding.extraContent.append("\n$contents")
+ if (currentExtras.isNotEmpty() && currentExtras.last() != '\n')
+ binding.extraContent.append("\n$contents")
else binding.extraContent.append(contents)
}
}
val hasCamera = packageManager?.hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY) == true
if (hasCamera) {
- val items = arrayOf(getString(R.string.otp_import_qr_code), getString(R.string.otp_import_manual_entry))
+ val items =
+ arrayOf(
+ getString(R.string.otp_import_qr_code),
+ getString(R.string.otp_import_manual_entry)
+ )
MaterialAlertDialogBuilder(this@PasswordCreationActivity)
.setItems(items) { _, index ->
when (index) {
@@ -209,7 +236,8 @@ class PasswordCreationActivity : BasePgpActivity(), OpenPgpServiceConnection.OnB
// in the encrypted extras. This only makes sense if the directory structure is
// FileBased.
if (suggestedName == null &&
- AutofillPreferences.directoryStructure(this@PasswordCreationActivity) == DirectoryStructure.FileBased
+ AutofillPreferences.directoryStructure(this@PasswordCreationActivity) ==
+ DirectoryStructure.FileBased
) {
encryptUsername.apply {
visibility = View.VISIBLE
@@ -226,7 +254,10 @@ class PasswordCreationActivity : BasePgpActivity(), OpenPgpServiceConnection.OnB
// User wants to disable username encryption, so we extract the
// username from the encrypted extras and use it as the filename.
val entry =
- passwordEntryFactory.create(lifecycleScope, "PASSWORD\n${extraContent.text}".encodeToByteArray())
+ passwordEntryFactory.create(
+ lifecycleScope,
+ "PASSWORD\n${extraContent.text}".encodeToByteArray()
+ )
val username = entry.username
// username should not be null here by the logic in
@@ -239,7 +270,9 @@ class PasswordCreationActivity : BasePgpActivity(), OpenPgpServiceConnection.OnB
}
}
}
- listOf(filename, extraContent).forEach { it.doOnTextChanged { _, _, _, _ -> updateViewState() } }
+ listOf(filename, extraContent).forEach {
+ it.doOnTextChanged { _, _, _, _ -> updateViewState() }
+ }
}
suggestedPass?.let {
password.setText(it)
@@ -279,21 +312,29 @@ class PasswordCreationActivity : BasePgpActivity(), OpenPgpServiceConnection.OnB
}
private fun generatePassword() {
- supportFragmentManager.setFragmentResultListener(PASSWORD_RESULT_REQUEST_KEY, this) { requestKey, bundle ->
+ supportFragmentManager.setFragmentResultListener(PASSWORD_RESULT_REQUEST_KEY, this) {
+ requestKey,
+ bundle ->
if (requestKey == PASSWORD_RESULT_REQUEST_KEY) {
binding.password.setText(bundle.getString(RESULT))
}
}
when (settings.getString(PreferenceKeys.PREF_KEY_PWGEN_TYPE) ?: KEY_PWGEN_TYPE_CLASSIC) {
- KEY_PWGEN_TYPE_CLASSIC -> PasswordGeneratorDialogFragment().show(supportFragmentManager, "generator")
- KEY_PWGEN_TYPE_XKPASSWD -> XkPasswordGeneratorDialogFragment().show(supportFragmentManager, "xkpwgenerator")
+ KEY_PWGEN_TYPE_CLASSIC ->
+ PasswordGeneratorDialogFragment().show(supportFragmentManager, "generator")
+ KEY_PWGEN_TYPE_XKPASSWD ->
+ XkPasswordGeneratorDialogFragment().show(supportFragmentManager, "xkpwgenerator")
}
}
private fun updateViewState() =
with(binding) {
// Use PasswordEntry to parse extras for username
- val entry = passwordEntryFactory.create(lifecycleScope, "PLACEHOLDER\n${extraContent.text}".encodeToByteArray())
+ val entry =
+ passwordEntryFactory.create(
+ lifecycleScope,
+ "PLACEHOLDER\n${extraContent.text}".encodeToByteArray()
+ )
encryptUsername.apply {
if (visibility != View.VISIBLE) return@apply
val hasUsernameInFileName = filename.text.toString().isNotBlank()
@@ -354,14 +395,18 @@ class PasswordCreationActivity : BasePgpActivity(), OpenPgpServiceConnection.OnB
}
}
if (gpgIdentifiers.isEmpty()) {
- gpgKeySelectAction.launch(Intent(this@PasswordCreationActivity, GetKeyIdsActivity::class.java))
+ gpgKeySelectAction.launch(
+ Intent(this@PasswordCreationActivity, GetKeyIdsActivity::class.java)
+ )
return@with
}
- val keyIds = gpgIdentifiers.filterIsInstance<GpgIdentifier.KeyId>().map { it.id }.toLongArray()
+ val keyIds =
+ gpgIdentifiers.filterIsInstance<GpgIdentifier.KeyId>().map { it.id }.toLongArray()
if (keyIds.isNotEmpty()) {
encryptionIntent.putExtra(OpenPgpApi.EXTRA_KEY_IDS, keyIds)
}
- val userIds = gpgIdentifiers.filterIsInstance<GpgIdentifier.UserId>().map { it.email }.toTypedArray()
+ val userIds =
+ gpgIdentifiers.filterIsInstance<GpgIdentifier.UserId>().map { it.email }.toTypedArray()
if (userIds.isNotEmpty()) {
encryptionIntent.putExtra(OpenPgpApi.EXTRA_USER_IDS, userIds)
}
@@ -396,7 +441,9 @@ class PasswordCreationActivity : BasePgpActivity(), OpenPgpServiceConnection.OnB
lifecycleScope.launch(Dispatchers.Main) {
val result =
- withContext(Dispatchers.IO) { checkNotNull(api).executeApi(encryptionIntent, inputStream, outputStream) }
+ withContext(Dispatchers.IO) {
+ checkNotNull(api).executeApi(encryptionIntent, inputStream, outputStream)
+ }
when (result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)) {
OpenPgpApi.RESULT_CODE_SUCCESS -> {
runCatching {
@@ -405,7 +452,9 @@ class PasswordCreationActivity : BasePgpActivity(), OpenPgpServiceConnection.OnB
// Additionally, if we were editing and the incoming and outgoing
// filenames differ, it means we renamed. Ensure that the target
// doesn't already exist to prevent an accidental overwrite.
- if ((!editing || (editing && suggestedName != file.nameWithoutExtension)) && file.exists()) {
+ if ((!editing || (editing && suggestedName != file.nameWithoutExtension)) &&
+ file.exists()
+ ) {
snackbar(message = getString(R.string.password_creation_duplicate_error))
return@runCatching
}
@@ -415,7 +464,9 @@ class PasswordCreationActivity : BasePgpActivity(), OpenPgpServiceConnection.OnB
return@runCatching
}
- withContext(Dispatchers.IO) { file.outputStream().use { it.write(outputStream.toByteArray()) } }
+ withContext(Dispatchers.IO) {
+ file.outputStream().use { it.write(outputStream.toByteArray()) }
+ }
// associate the new password name with the last name's timestamp in
// history
@@ -432,7 +483,10 @@ class PasswordCreationActivity : BasePgpActivity(), OpenPgpServiceConnection.OnB
val returnIntent = Intent()
returnIntent.putExtra(RETURN_EXTRA_CREATED_FILE, path)
returnIntent.putExtra(RETURN_EXTRA_NAME, editName)
- returnIntent.putExtra(RETURN_EXTRA_LONG_NAME, getLongName(fullPath, repoPath, editName))
+ returnIntent.putExtra(
+ RETURN_EXTRA_LONG_NAME,
+ getLongName(fullPath, repoPath, editName)
+ )
if (shouldGeneratePassword) {
val directoryStructure = AutofillPreferences.directoryStructure(applicationContext)
@@ -442,13 +496,18 @@ class PasswordCreationActivity : BasePgpActivity(), OpenPgpServiceConnection.OnB
returnIntent.putExtra(RETURN_EXTRA_USERNAME, username)
}
- if (directoryInputLayout.isVisible && directoryInputLayout.isEnabled && oldFileName != null) {
+ if (directoryInputLayout.isVisible &&
+ directoryInputLayout.isEnabled &&
+ oldFileName != null
+ ) {
val oldFile = File("$repoPath/${oldCategory?.trim('/')}/$oldFileName.gpg")
if (oldFile.path != file.path && !oldFile.delete()) {
setResult(RESULT_CANCELED)
MaterialAlertDialogBuilder(this@PasswordCreationActivity)
.setTitle(R.string.password_creation_file_fail_title)
- .setMessage(getString(R.string.password_creation_file_delete_fail_message, oldFileName))
+ .setMessage(
+ getString(R.string.password_creation_file_delete_fail_message, oldFileName)
+ )
.setCancelable(false)
.setPositiveButton(android.R.string.ok) { _, _ -> finish() }
.show()
@@ -456,9 +515,12 @@ class PasswordCreationActivity : BasePgpActivity(), OpenPgpServiceConnection.OnB
}
}
- val commitMessageRes = if (editing) R.string.git_commit_edit_text else R.string.git_commit_add_text
+ val commitMessageRes =
+ if (editing) R.string.git_commit_edit_text else R.string.git_commit_add_text
lifecycleScope.launch {
- commitChange(resources.getString(commitMessageRes, getLongName(fullPath, repoPath, editName)))
+ commitChange(
+ resources.getString(commitMessageRes, getLongName(fullPath, repoPath, editName))
+ )
.onSuccess {
setResult(RESULT_OK, returnIntent)
finish()
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/dialogs/BasicBottomSheet.kt b/app/src/main/java/dev/msfjarvis/aps/ui/dialogs/BasicBottomSheet.kt
index fa188a22..dad86479 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/dialogs/BasicBottomSheet.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/dialogs/BasicBottomSheet.kt
@@ -52,7 +52,11 @@ private constructor(
}
}
- override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
+ override fun onCreateView(
+ inflater: LayoutInflater,
+ container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
if (savedInstanceState != null) dismiss()
return layoutInflater.inflate(R.layout.basic_bottom_sheet, container, false)
}
@@ -85,7 +89,9 @@ private constructor(
}
if (negativeButtonClickListener != null) {
binding.bottomSheetCancelButton.isVisible = true
- negativeButtonLabel?.let { buttonLbl -> binding.bottomSheetCancelButton.text = buttonLbl }
+ negativeButtonLabel?.let { buttonLbl ->
+ binding.bottomSheetCancelButton.text = buttonLbl
+ }
binding.bottomSheetCancelButton.setOnClickListener {
negativeButtonClickListener.onClick(it)
dismiss()
@@ -95,7 +101,9 @@ private constructor(
}
)
val gradientDrawable =
- GradientDrawable().apply { setColor(requireContext().resolveAttribute(android.R.attr.windowBackground)) }
+ GradientDrawable().apply {
+ setColor(requireContext().resolveAttribute(android.R.attr.windowBackground))
+ }
view.background = gradientDrawable
}
@@ -133,13 +141,19 @@ private constructor(
return this
}
- fun setPositiveButtonClickListener(buttonLabel: String? = null, listener: View.OnClickListener): Builder {
+ fun setPositiveButtonClickListener(
+ buttonLabel: String? = null,
+ listener: View.OnClickListener
+ ): Builder {
this.positiveButtonClickListener = listener
this.positiveButtonLabel = buttonLabel
return this
}
- fun setNegativeButtonClickListener(buttonLabel: String? = null, listener: View.OnClickListener): Builder {
+ fun setNegativeButtonClickListener(
+ buttonLabel: String? = null,
+ listener: View.OnClickListener
+ ): Builder {
this.negativeButtonClickListener = listener
this.negativeButtonLabel = buttonLabel
return this
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/dialogs/ItemCreationBottomSheet.kt b/app/src/main/java/dev/msfjarvis/aps/ui/dialogs/ItemCreationBottomSheet.kt
index fcf7b372..cb693d28 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/dialogs/ItemCreationBottomSheet.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/dialogs/ItemCreationBottomSheet.kt
@@ -37,7 +37,11 @@ class ItemCreationBottomSheet : BottomSheetDialogFragment() {
}
}
- override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
+ override fun onCreateView(
+ inflater: LayoutInflater,
+ container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
if (savedInstanceState != null) dismiss()
return inflater.inflate(R.layout.item_create_sheet, container, false)
}
@@ -67,7 +71,9 @@ class ItemCreationBottomSheet : BottomSheetDialogFragment() {
}
)
val gradientDrawable =
- GradientDrawable().apply { setColor(requireContext().resolveAttribute(android.R.attr.windowBackground)) }
+ GradientDrawable().apply {
+ setColor(requireContext().resolveAttribute(android.R.attr.windowBackground))
+ }
view.background = gradientDrawable
}
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/dialogs/PasswordGeneratorDialogFragment.kt b/app/src/main/java/dev/msfjarvis/aps/ui/dialogs/PasswordGeneratorDialogFragment.kt
index 16a9eefb..4820521f 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/dialogs/PasswordGeneratorDialogFragment.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/dialogs/PasswordGeneratorDialogFragment.kt
@@ -36,7 +36,10 @@ class PasswordGeneratorDialogFragment : DialogFragment() {
val callingActivity = requireActivity()
val binding = FragmentPwgenBinding.inflate(layoutInflater)
val monoTypeface = Typeface.createFromAsset(callingActivity.assets, "fonts/sourcecodepro.ttf")
- val prefs = requireActivity().applicationContext.getSharedPreferences("PasswordGenerator", Context.MODE_PRIVATE)
+ val prefs =
+ requireActivity()
+ .applicationContext
+ .getSharedPreferences("PasswordGenerator", Context.MODE_PRIVATE)
builder.setView(binding.root)
@@ -65,7 +68,9 @@ class PasswordGeneratorDialogFragment : DialogFragment() {
.apply {
setOnShowListener {
generate(binding.passwordText)
- getButton(AlertDialog.BUTTON_NEGATIVE).setOnClickListener { generate(binding.passwordText) }
+ getButton(AlertDialog.BUTTON_NEGATIVE).setOnClickListener {
+ generate(binding.passwordText)
+ }
}
}
}
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/dialogs/XkPasswordGeneratorDialogFragment.kt b/app/src/main/java/dev/msfjarvis/aps/ui/dialogs/XkPasswordGeneratorDialogFragment.kt
index e2e7426b..ad252975 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/dialogs/XkPasswordGeneratorDialogFragment.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/dialogs/XkPasswordGeneratorDialogFragment.kt
@@ -49,7 +49,9 @@ class XkPasswordGeneratorDialogFragment : DialogFragment() {
binding.xkNumWords.setText(prefs.getString(PREF_KEY_NUM_WORDS, DEFAULT_NUMBER_OF_WORDS))
binding.xkSeparator.setText(prefs.getString(PREF_KEY_SEPARATOR, DEFAULT_WORD_SEPARATOR))
- binding.xkNumberSymbolMask.setText(prefs.getString(PREF_KEY_EXTRA_SYMBOLS_MASK, DEFAULT_EXTRA_SYMBOLS_MASK))
+ binding.xkNumberSymbolMask.setText(
+ prefs.getString(PREF_KEY_EXTRA_SYMBOLS_MASK, DEFAULT_EXTRA_SYMBOLS_MASK)
+ )
binding.xkPasswordText.typeface = monoTypeface
@@ -85,8 +87,12 @@ class XkPasswordGeneratorDialogFragment : DialogFragment() {
.setMinimumWordLength(DEFAULT_MIN_WORD_LENGTH)
.setMaximumWordLength(DEFAULT_MAX_WORD_LENGTH)
.setSeparator(binding.xkSeparator.text.toString())
- .appendNumbers(binding.xkNumberSymbolMask.text!!.count { c -> c == EXTRA_CHAR_PLACEHOLDER_DIGIT })
- .appendSymbols(binding.xkNumberSymbolMask.text!!.count { c -> c == EXTRA_CHAR_PLACEHOLDER_SYMBOL })
+ .appendNumbers(
+ binding.xkNumberSymbolMask.text!!.count { c -> c == EXTRA_CHAR_PLACEHOLDER_DIGIT }
+ )
+ .appendSymbols(
+ binding.xkNumberSymbolMask.text!!.count { c -> c == EXTRA_CHAR_PLACEHOLDER_SYMBOL }
+ )
.setCapitalization(CapsType.valueOf(binding.xkCapType.selectedItem.toString()))
.create()
.fold(
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/folderselect/SelectFolderActivity.kt b/app/src/main/java/dev/msfjarvis/aps/ui/folderselect/SelectFolderActivity.kt
index 1c6a236e..48ed5b79 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/folderselect/SelectFolderActivity.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/folderselect/SelectFolderActivity.kt
@@ -24,7 +24,10 @@ class SelectFolderActivity : AppCompatActivity(R.layout.select_folder_layout) {
passwordList = SelectFolderFragment()
val args = Bundle()
- args.putString(PasswordStore.REQUEST_ARG_PATH, PasswordRepository.getRepositoryDirectory().absolutePath)
+ args.putString(
+ PasswordStore.REQUEST_ARG_PATH,
+ PasswordRepository.getRepositoryDirectory().absolutePath
+ )
passwordList.arguments = args
@@ -32,7 +35,9 @@ class SelectFolderActivity : AppCompatActivity(R.layout.select_folder_layout) {
supportFragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE)
- supportFragmentManager.commit { replace(R.id.pgp_handler_linearlayout, passwordList, PASSWORD_FRAGMENT_TAG) }
+ supportFragmentManager.commit {
+ replace(R.id.pgp_handler_linearlayout, passwordList, PASSWORD_FRAGMENT_TAG)
+ }
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/folderselect/SelectFolderFragment.kt b/app/src/main/java/dev/msfjarvis/aps/ui/folderselect/SelectFolderFragment.kt
index 1905aab0..8c9d5801 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/folderselect/SelectFolderFragment.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/folderselect/SelectFolderFragment.kt
@@ -35,7 +35,10 @@ class SelectFolderFragment : Fragment(R.layout.password_recycler_view) {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.fab.hide()
- recyclerAdapter = PasswordItemRecyclerAdapter().onItemClicked { _, item -> listener.onFragmentInteraction(item) }
+ recyclerAdapter =
+ PasswordItemRecyclerAdapter().onItemClicked { _, item ->
+ listener.onFragmentInteraction(item)
+ }
binding.passRecycler.apply {
layoutManager = LinearLayoutManager(requireContext())
itemAnimator = null
@@ -47,7 +50,9 @@ class SelectFolderFragment : Fragment(R.layout.password_recycler_view) {
val path = requireNotNull(requireArguments().getString(PasswordStore.REQUEST_ARG_PATH))
model.navigateTo(File(path), listMode = ListMode.DirectoriesOnly, pushPreviousLocation = false)
- model.searchResult.observe(viewLifecycleOwner) { result -> recyclerAdapter.submitList(result.passwordItems) }
+ model.searchResult.observe(viewLifecycleOwner) { result ->
+ recyclerAdapter.submitList(result.passwordItems)
+ }
}
override fun onAttach(context: Context) {
@@ -58,12 +63,16 @@ class SelectFolderFragment : Fragment(R.layout.password_recycler_view) {
override fun onFragmentInteraction(item: PasswordItem) {
if (item.type == PasswordItem.TYPE_CATEGORY) {
model.navigateTo(item.file, listMode = ListMode.DirectoriesOnly)
- (requireActivity() as AppCompatActivity).supportActionBar?.setDisplayHomeAsUpEnabled(true)
+ (requireActivity() as AppCompatActivity).supportActionBar?.setDisplayHomeAsUpEnabled(
+ true
+ )
}
}
}
}
- .onFailure { throw ClassCastException("$context must implement OnFragmentInteractionListener") }
+ .onFailure {
+ throw ClassCastException("$context must implement OnFragmentInteractionListener")
+ }
}
val currentDir: File
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/git/base/BaseGitActivity.kt b/app/src/main/java/dev/msfjarvis/aps/ui/git/base/BaseGitActivity.kt
index ac4c400d..b9bfd911 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/git/base/BaseGitActivity.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/git/base/BaseGitActivity.kt
@@ -116,7 +116,8 @@ abstract class BaseGitActivity : ContinuationContainerActivity() {
"Your local repository appears to be an incomplete Git clone, please delete and re-clone from settings"
)
}
- err is TransportException && err.disconnectReason == DisconnectReason.HOST_KEY_NOT_VERIFIABLE -> {
+ err is TransportException &&
+ err.disconnectReason == DisconnectReason.HOST_KEY_NOT_VERIFIABLE -> {
SSHException(
DisconnectReason.HOST_KEY_NOT_VERIFIABLE,
"WARNING: The remote host key has changed. If this is expected, please go to Git server settings and clear the saved host key."
@@ -135,7 +136,9 @@ abstract class BaseGitActivity : ContinuationContainerActivity() {
private fun isExplicitlyUserInitiatedError(throwable: Throwable): Boolean {
var cause: Throwable? = throwable
while (cause != null) {
- if (cause is SSHException && cause.disconnectReason == DisconnectReason.AUTH_CANCELLED_BY_USER) return true
+ if (cause is SSHException && cause.disconnectReason == DisconnectReason.AUTH_CANCELLED_BY_USER
+ )
+ return true
cause = cause.cause
}
return false
@@ -154,7 +157,8 @@ abstract class BaseGitActivity : ContinuationContainerActivity() {
while ((rootCause is org.eclipse.jgit.errors.TransportException ||
rootCause is org.eclipse.jgit.api.errors.TransportException ||
rootCause is org.eclipse.jgit.api.errors.InvalidRemoteException ||
- (rootCause is UserAuthException && rootCause.message == "Exhausted available authentication methods"))) {
+ (rootCause is UserAuthException &&
+ rootCause.message == "Exhausted available authentication methods"))) {
rootCause = rootCause.cause ?: break
}
return rootCause
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/git/config/GitConfigActivity.kt b/app/src/main/java/dev/msfjarvis/aps/ui/git/config/GitConfigActivity.kt
index a1125ef0..faaf426f 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/git/config/GitConfigActivity.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/git/config/GitConfigActivity.kt
@@ -55,7 +55,12 @@ class GitConfigActivity : BaseGitActivity() {
} else {
GitSettings.authorEmail = email
GitSettings.authorName = name
- Snackbar.make(binding.root, getString(R.string.git_server_config_save_success), Snackbar.LENGTH_SHORT).show()
+ Snackbar.make(
+ binding.root,
+ getString(R.string.git_server_config_save_success),
+ Snackbar.LENGTH_SHORT
+ )
+ .show()
Handler(Looper.getMainLooper()).postDelayed(500) { finish() }
}
}
@@ -77,7 +82,8 @@ class GitConfigActivity : BaseGitActivity() {
if (repo != null) {
binding.gitHeadStatus.text = headStatusMsg(repo)
// enable the abort button only if we're rebasing or merging
- val needsAbort = repo.repositoryState.isRebasing || repo.repositoryState == RepositoryState.MERGING
+ val needsAbort =
+ repo.repositoryState.isRebasing || repo.repositoryState == RepositoryState.MERGING
binding.gitAbortRebase.isEnabled = needsAbort
binding.gitAbortRebase.alpha = if (needsAbort) 1.0f else 0.5f
}
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/git/config/GitServerConfigActivity.kt b/app/src/main/java/dev/msfjarvis/aps/ui/git/config/GitServerConfigActivity.kt
index 372d5863..cab8d3ae 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/git/config/GitServerConfigActivity.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/git/config/GitServerConfigActivity.kt
@@ -89,7 +89,12 @@ class GitServerConfigActivity : BaseGitActivity() {
binding.clearHostKeyButton.isVisible = GitSettings.hasSavedHostKey()
binding.clearHostKeyButton.setOnClickListener {
GitSettings.clearSavedHostKey()
- Snackbar.make(binding.root, getString(R.string.clear_saved_host_key_success), Snackbar.LENGTH_LONG).show()
+ Snackbar.make(
+ binding.root,
+ getString(R.string.clear_saved_host_key_success),
+ Snackbar.LENGTH_LONG
+ )
+ .show()
it.isVisible = false
}
binding.saveButton.setOnClickListener {
@@ -102,7 +107,9 @@ class GitServerConfigActivity : BaseGitActivity() {
BasicBottomSheet.Builder(this)
.setTitleRes(R.string.https_scheme_with_port_title)
.setMessageRes(R.string.https_scheme_with_port_message)
- .setPositiveButtonClickListener { binding.serverUrl.setText(newUrl.replace(PORT_REGEX, "/")) }
+ .setPositiveButtonClickListener {
+ binding.serverUrl.setText(newUrl.replace(PORT_REGEX, "/"))
+ }
.build()
.show(supportFragmentManager, "SSH_SCHEME_WARNING")
return@setOnClickListener
@@ -110,7 +117,9 @@ class GitServerConfigActivity : BaseGitActivity() {
BasicBottomSheet.Builder(this)
.setTitleRes(R.string.ssh_scheme_needed_title)
.setMessageRes(R.string.ssh_scheme_needed_message)
- .setPositiveButtonClickListener { @Suppress("SetTextI18n") binding.serverUrl.setText("ssh://$newUrl") }
+ .setPositiveButtonClickListener {
+ @Suppress("SetTextI18n") binding.serverUrl.setText("ssh://$newUrl")
+ }
.build()
.show(supportFragmentManager, "SSH_SCHEME_WARNING")
return@setOnClickListener
@@ -133,7 +142,12 @@ class GitServerConfigActivity : BaseGitActivity() {
)
) {
GitSettings.UpdateConnectionSettingsResult.FailedToParseUrl -> {
- Snackbar.make(binding.root, getString(R.string.git_server_config_save_error), Snackbar.LENGTH_LONG).show()
+ Snackbar.make(
+ binding.root,
+ getString(R.string.git_server_config_save_error),
+ Snackbar.LENGTH_LONG
+ )
+ .show()
}
is GitSettings.UpdateConnectionSettingsResult.MissingUsername -> {
when (updateResult.newProtocol) {
@@ -154,9 +168,14 @@ class GitServerConfigActivity : BaseGitActivity() {
}
}
GitSettings.UpdateConnectionSettingsResult.Valid -> {
- if (isClone && PasswordRepository.getRepository(null) == null) PasswordRepository.initialize()
+ if (isClone && PasswordRepository.getRepository(null) == null)
+ PasswordRepository.initialize()
if (!isClone) {
- Snackbar.make(binding.root, getString(R.string.git_server_config_save_success), Snackbar.LENGTH_SHORT)
+ Snackbar.make(
+ binding.root,
+ getString(R.string.git_server_config_save_success),
+ Snackbar.LENGTH_SHORT
+ )
.show()
Handler(Looper.getMainLooper()).postDelayed(500) { finish() }
} else {
@@ -206,7 +225,9 @@ class GitServerConfigActivity : BaseGitActivity() {
val localDir = requireNotNull(PasswordRepository.getRepositoryDirectory())
val localDirFiles = localDir.listFiles() ?: emptyArray()
// Warn if non-empty folder unless it's a just-initialized store that has just a .git folder
- if (localDir.exists() && localDirFiles.isNotEmpty() && !(localDirFiles.size == 1 && localDirFiles[0].name == ".git")
+ if (localDir.exists() &&
+ localDirFiles.isNotEmpty() &&
+ !(localDirFiles.size == 1 && localDirFiles[0].name == ".git")
) {
MaterialAlertDialogBuilder(this)
.setTitle(R.string.dialog_delete_title)
@@ -269,7 +290,9 @@ class GitServerConfigActivity : BaseGitActivity() {
private val PORT_REGEX = ":[0-9]{1,5}/".toRegex()
fun createCloneIntent(context: Context): Intent {
- return Intent(context, GitServerConfigActivity::class.java).apply { putExtra("cloning", true) }
+ return Intent(context, GitServerConfigActivity::class.java).apply {
+ putExtra("cloning", true)
+ }
}
}
}
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/git/log/GitLogAdapter.kt b/app/src/main/java/dev/msfjarvis/aps/ui/git/log/GitLogAdapter.kt
index 4b29542e..1470d642 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/git/log/GitLogAdapter.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/git/log/GitLogAdapter.kt
@@ -45,7 +45,8 @@ class GitLogAdapter : RecyclerView.Adapter<GitLogAdapter.ViewHolder>() {
override fun getItemCount() = model.size
- class ViewHolder(private val binding: GitLogRowLayoutBinding) : RecyclerView.ViewHolder(binding.root) {
+ class ViewHolder(private val binding: GitLogRowLayoutBinding) :
+ RecyclerView.ViewHolder(binding.root) {
fun bind(commit: GitCommit) =
with(binding) {
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/onboarding/fragments/CloneFragment.kt b/app/src/main/java/dev/msfjarvis/aps/ui/onboarding/fragments/CloneFragment.kt
index 12a97d45..407da1d1 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/onboarding/fragments/CloneFragment.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/onboarding/fragments/CloneFragment.kt
@@ -24,7 +24,9 @@ class CloneFragment : Fragment(R.layout.fragment_clone) {
private val binding by viewBinding(FragmentCloneBinding::bind)
- private val settings by lazy(LazyThreadSafetyMode.NONE) { requireActivity().applicationContext.sharedPrefs }
+ private val settings by lazy(LazyThreadSafetyMode.NONE) {
+ requireActivity().applicationContext.sharedPrefs
+ }
private val cloneAction =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/onboarding/fragments/KeySelectionFragment.kt b/app/src/main/java/dev/msfjarvis/aps/ui/onboarding/fragments/KeySelectionFragment.kt
index 3d7a66b3..4123f031 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/onboarding/fragments/KeySelectionFragment.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/onboarding/fragments/KeySelectionFragment.kt
@@ -32,7 +32,9 @@ import me.msfjarvis.openpgpktx.util.OpenPgpApi
class KeySelectionFragment : Fragment(R.layout.fragment_key_selection) {
- private val settings by lazy(LazyThreadSafetyMode.NONE) { requireActivity().applicationContext.sharedPrefs }
+ private val settings by lazy(LazyThreadSafetyMode.NONE) {
+ requireActivity().applicationContext.sharedPrefs
+ }
private val binding by viewBinding(FragmentKeySelectionBinding::bind)
private val gpgKeySelectAction =
@@ -45,13 +47,17 @@ class KeySelectionFragment : Fragment(R.layout.fragment_key_selection) {
gpgIdentifierFile.writeText((keyIds + "").joinToString("\n"))
}
settings.edit { putBoolean(PreferenceKeys.REPOSITORY_INITIALIZED, true) }
- requireActivity().commitChange(getString(R.string.git_commit_gpg_id, getString(R.string.app_name)))
+ requireActivity()
+ .commitChange(getString(R.string.git_commit_gpg_id, getString(R.string.app_name)))
}
}
finish()
} else {
requireActivity()
- .snackbar(message = getString(R.string.gpg_key_select_mandatory), length = Snackbar.LENGTH_LONG)
+ .snackbar(
+ message = getString(R.string.gpg_key_select_mandatory),
+ length = Snackbar.LENGTH_LONG
+ )
}
}
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/onboarding/fragments/RepoLocationFragment.kt b/app/src/main/java/dev/msfjarvis/aps/ui/onboarding/fragments/RepoLocationFragment.kt
index 9adbc3e8..2fdb82e8 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/onboarding/fragments/RepoLocationFragment.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/onboarding/fragments/RepoLocationFragment.kt
@@ -35,7 +35,9 @@ import java.io.File
class RepoLocationFragment : Fragment(R.layout.fragment_repo_location) {
- private val settings by lazy(LazyThreadSafetyMode.NONE) { requireActivity().applicationContext.sharedPrefs }
+ private val settings by lazy(LazyThreadSafetyMode.NONE) {
+ requireActivity().applicationContext.sharedPrefs
+ }
private val directorySelectIntent by lazy(LazyThreadSafetyMode.NONE) {
Intent(requireContext(), DirectorySelectionActivity::class.java)
}
@@ -65,7 +67,9 @@ class RepoLocationFragment : Fragment(R.layout.fragment_repo_location) {
externalDirectorySelectAction.launch(directorySelectIntent)
}
- private val repositoryUsePermGrantedAction = createPermGrantedAction { initializeRepositoryInfo() }
+ private val repositoryUsePermGrantedAction = createPermGrantedAction {
+ initializeRepositoryInfo()
+ }
private val repositoryChangePermGrantedAction = createPermGrantedAction {
repositoryInitAction.launch(directorySelectIntent)
@@ -132,7 +136,12 @@ class RepoLocationFragment : Fragment(R.layout.fragment_repo_location) {
dir.isDirectory && // The directory, is really a directory
dir.listFilesRecursively().isNotEmpty() && // The directory contains files
// The directory contains a non-zero number of password files
- PasswordRepository.getPasswords(dir, PasswordRepository.getRepositoryDirectory(), sortOrder).isNotEmpty()
+ PasswordRepository.getPasswords(
+ dir,
+ PasswordRepository.getRepositoryDirectory(),
+ sortOrder
+ )
+ .isNotEmpty()
) {
PasswordRepository.closeRepository()
return true
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/onboarding/fragments/WelcomeFragment.kt b/app/src/main/java/dev/msfjarvis/aps/ui/onboarding/fragments/WelcomeFragment.kt
index 7c3788c7..e47eeffc 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/onboarding/fragments/WelcomeFragment.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/onboarding/fragments/WelcomeFragment.kt
@@ -27,6 +27,8 @@ class WelcomeFragment : Fragment(R.layout.fragment_welcome) {
binding.letsGo.setOnClickListener {
parentFragmentManager.performTransactionWithBackStack(CloneFragment.newInstance())
}
- binding.settingsButton.setOnClickListener { startActivity(Intent(requireContext(), SettingsActivity::class.java)) }
+ binding.settingsButton.setOnClickListener {
+ startActivity(Intent(requireContext(), SettingsActivity::class.java))
+ }
}
}
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/passwords/PasswordFragment.kt b/app/src/main/java/dev/msfjarvis/aps/ui/passwords/PasswordFragment.kt
index 3740404a..541a3f9e 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/passwords/PasswordFragment.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/passwords/PasswordFragment.kt
@@ -77,8 +77,12 @@ class PasswordFragment : Fragment(R.layout.password_recycler_view) {
super.onViewCreated(view, savedInstanceState)
settings = requireContext().sharedPrefs
initializePasswordList()
- binding.fab.setOnClickListener { ItemCreationBottomSheet().show(childFragmentManager, "BOTTOM_SHEET") }
- childFragmentManager.setFragmentResultListener(ITEM_CREATION_REQUEST_KEY, viewLifecycleOwner) { _, bundle ->
+ binding.fab.setOnClickListener {
+ ItemCreationBottomSheet().show(childFragmentManager, "BOTTOM_SHEET")
+ }
+ childFragmentManager.setFragmentResultListener(ITEM_CREATION_REQUEST_KEY, viewLifecycleOwner) {
+ _,
+ bundle ->
when (bundle.getString(ACTION_KEY)) {
ACTION_FOLDER -> requireStore().createFolder()
ACTION_PASSWORD -> requireStore().createPassword()
@@ -88,7 +92,8 @@ class PasswordFragment : Fragment(R.layout.password_recycler_view) {
private fun initializePasswordList() {
val gitDir = File(PasswordRepository.getRepositoryDirectory(), ".git")
- val hasGitDir = gitDir.exists() && gitDir.isDirectory && (gitDir.listFiles()?.isNotEmpty() == true)
+ val hasGitDir =
+ gitDir.exists() && gitDir.isDirectory && (gitDir.listFiles()?.isNotEmpty() == true)
binding.swipeRefresher.setOnRefreshListener {
if (!hasGitDir) {
requireStore().refreshPasswordList()
@@ -118,7 +123,9 @@ class PasswordFragment : Fragment(R.layout.password_recycler_view) {
binding.swipeRefresher.isRefreshing = false
refreshPasswordList()
},
- failure = { err -> promptOnErrorHandler(err) { binding.swipeRefresher.isRefreshing = false } },
+ failure = { err ->
+ promptOnErrorHandler(err) { binding.swipeRefresher.isRefreshing = false }
+ },
)
}
}
@@ -135,10 +142,16 @@ class PasswordFragment : Fragment(R.layout.password_recycler_view) {
binding.swipeRefresher.isEnabled = selection.isEmpty
if (actionMode == null)
- actionMode = requireStore().startSupportActionMode(actionModeCallback) ?: return@onSelectionChanged
+ actionMode =
+ requireStore().startSupportActionMode(actionModeCallback) ?: return@onSelectionChanged
if (!selection.isEmpty) {
- actionMode!!.title = resources.getQuantityString(R.plurals.delete_title, selection.size(), selection.size())
+ actionMode!!.title =
+ resources.getQuantityString(
+ R.plurals.delete_title,
+ selection.size(),
+ selection.size()
+ )
actionMode!!.invalidate()
} else {
actionMode!!.finish()
@@ -171,14 +184,18 @@ class PasswordFragment : Fragment(R.layout.password_recycler_view) {
recyclerView.scrollToPosition(0)
}
scrollTarget != null -> {
- scrollTarget?.let { recyclerView.scrollToPosition(recyclerAdapter.getPositionForFile(it)) }
+ scrollTarget?.let {
+ recyclerView.scrollToPosition(recyclerAdapter.getPositionForFile(it))
+ }
scrollTarget = null
}
else -> {
// When the result is not filtered and there is a saved scroll position for
// it,
// we try to restore it.
- recyclerViewStateToRestore?.let { recyclerView.layoutManager!!.onRestoreInstanceState(it) }
+ recyclerViewStateToRestore?.let {
+ recyclerView.layoutManager!!.onRestoreInstanceState(it)
+ }
recyclerViewStateToRestore = null
}
}
@@ -201,7 +218,8 @@ class PasswordFragment : Fragment(R.layout.password_recycler_view) {
// but may be called multiple times if the mode is invalidated.
override fun onPrepareActionMode(mode: ActionMode, menu: Menu): Boolean {
val selectedItems = recyclerAdapter.getSelectedItems()
- menu.findItem(R.id.menu_edit_password).isVisible = selectedItems.all { it.type == PasswordItem.TYPE_CATEGORY }
+ menu.findItem(R.id.menu_edit_password).isVisible =
+ selectedItems.all { it.type == PasswordItem.TYPE_CATEGORY }
menu.findItem(R.id.menu_pin_password).isVisible =
selectedItems.size == 1 && selectedItems[0].type == PasswordItem.TYPE_PASSWORD
return true
@@ -227,7 +245,10 @@ class PasswordFragment : Fragment(R.layout.password_recycler_view) {
}
R.id.menu_pin_password -> {
val passwordItem = recyclerAdapter.getSelectedItems()[0]
- shortcutHandler.addPinnedShortcut(passwordItem, passwordItem.createAuthEnabledIntent(requireContext()))
+ shortcutHandler.addPinnedShortcut(
+ passwordItem,
+ passwordItem.createAuthEnabledIntent(requireContext())
+ )
false
}
else -> false
@@ -244,7 +265,8 @@ class PasswordFragment : Fragment(R.layout.password_recycler_view) {
private fun animateFab(show: Boolean) =
with(binding.fab) {
- val animation = AnimationUtils.loadAnimation(context, if (show) R.anim.scale_up else R.anim.scale_down)
+ val animation =
+ AnimationUtils.loadAnimation(context, if (show) R.anim.scale_up else R.anim.scale_down)
animation.setAnimationListener(
object : Animation.AnimationListener {
override fun onAnimationRepeat(animation: Animation?) {}
@@ -258,7 +280,11 @@ class PasswordFragment : Fragment(R.layout.password_recycler_view) {
}
}
)
- animate().rotationBy(if (show) -90f else 90f).setStartDelay(if (show) 100 else 0).setDuration(100).start()
+ animate()
+ .rotationBy(if (show) -90f else 90f)
+ .setStartDelay(if (show) 100 else 0)
+ .setDuration(100)
+ .start()
startAnimation(animation)
}
}
@@ -269,10 +295,15 @@ class PasswordFragment : Fragment(R.layout.password_recycler_view) {
listener =
object : OnFragmentInteractionListener {
override fun onFragmentInteraction(item: PasswordItem) {
- if (settings.getString(PreferenceKeys.SORT_ORDER) == PasswordSortOrder.RECENTLY_USED.name) {
+ if (settings.getString(PreferenceKeys.SORT_ORDER) ==
+ PasswordSortOrder.RECENTLY_USED.name
+ ) {
// save the time when password was used
- val preferences = context.getSharedPreferences("recent_password_history", Context.MODE_PRIVATE)
- preferences.edit { putString(item.file.absolutePath.base64(), System.currentTimeMillis().toString()) }
+ val preferences =
+ context.getSharedPreferences("recent_password_history", Context.MODE_PRIVATE)
+ preferences.edit {
+ putString(item.file.absolutePath.base64(), System.currentTimeMillis().toString())
+ }
}
if (item.type == PasswordItem.TYPE_CATEGORY) {
@@ -287,7 +318,9 @@ class PasswordFragment : Fragment(R.layout.password_recycler_view) {
}
}
}
- .onFailure { throw ClassCastException("$context must implement OnFragmentInteractionListener") }
+ .onFailure {
+ throw ClassCastException("$context must implement OnFragmentInteractionListener")
+ }
}
private fun requireStore() = requireActivity() as PasswordStore
@@ -322,7 +355,10 @@ class PasswordFragment : Fragment(R.layout.password_recycler_view) {
fun navigateTo(file: File) {
requireStore().clearSearch()
- model.navigateTo(file, recyclerViewState = binding.passRecycler.layoutManager!!.onSaveInstanceState())
+ model.navigateTo(
+ file,
+ recyclerViewState = binding.passRecycler.layoutManager!!.onSaveInstanceState()
+ )
requireStore().supportActionBar?.setDisplayHomeAsUpEnabled(true)
}
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 8ab69552..b2591a92 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
@@ -82,7 +82,9 @@ class PasswordStore : BaseGitActivity() {
}
private val storagePermissionRequest =
- registerForActivityResult(RequestPermission()) { granted -> if (granted) checkLocalRepository() }
+ registerForActivityResult(RequestPermission()) { granted ->
+ if (granted) checkLocalRepository()
+ }
private val directorySelectAction =
registerForActivityResult(StartActivityForResult()) { result ->
@@ -128,7 +130,13 @@ class PasswordStore : BaseGitActivity() {
withContext(Dispatchers.Main) {
MaterialAlertDialogBuilder(this@PasswordStore)
.setTitle(resources.getString(R.string.password_exists_title))
- .setMessage(resources.getString(R.string.password_exists_message, destinationLongName, sourceLongName))
+ .setMessage(
+ resources.getString(
+ R.string.password_exists_message,
+ destinationLongName,
+ sourceLongName
+ )
+ )
.setPositiveButton(R.string.dialog_ok) { _, _ ->
launch(Dispatchers.IO) { moveFile(source, destinationFile) }
}
@@ -143,11 +151,16 @@ class PasswordStore : BaseGitActivity() {
1 -> {
val source = File(filesToMove[0])
val basename = source.nameWithoutExtension
- val sourceLongName = getLongName(requireNotNull(source.parent), repositoryPath, basename)
+ val sourceLongName =
+ getLongName(requireNotNull(source.parent), repositoryPath, basename)
val destinationLongName = getLongName(target.absolutePath, repositoryPath, basename)
withContext(Dispatchers.Main) {
commitChange(
- resources.getString(R.string.git_commit_move_text, sourceLongName, destinationLongName),
+ resources.getString(
+ R.string.git_commit_move_text,
+ sourceLongName,
+ destinationLongName
+ ),
)
}
}
@@ -168,8 +181,8 @@ class PasswordStore : BaseGitActivity() {
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
// open search view on search key, or Ctr+F
- if ((keyCode == KeyEvent.KEYCODE_SEARCH || keyCode == KeyEvent.KEYCODE_F && event.isCtrlPressed) &&
- !searchItem.isActionViewExpanded
+ if ((keyCode == KeyEvent.KEYCODE_SEARCH ||
+ keyCode == KeyEvent.KEYCODE_F && event.isCtrlPressed) && !searchItem.isActionViewExpanded
) {
searchItem.expandActionView()
return true
@@ -202,7 +215,9 @@ class PasswordStore : BaseGitActivity() {
model.currentDir.observe(this) { dir ->
val basePath = PasswordRepository.getRepositoryDirectory().absoluteFile
- supportActionBar!!.apply { if (dir != basePath) title = dir.name else setTitle(R.string.app_name) }
+ supportActionBar!!.apply {
+ if (dir != basePath) title = dir.name else setTitle(R.string.app_name)
+ }
}
}
@@ -253,7 +268,8 @@ class PasswordStore : BaseGitActivity() {
val filter = s.trim()
// List the contents of the current directory if the user enters a blank
// search term.
- if (filter.isEmpty()) model.navigateTo(newDirectory = model.currentDir.value!!, pushPreviousLocation = false)
+ if (filter.isEmpty())
+ model.navigateTo(newDirectory = model.currentDir.value!!, pushPreviousLocation = false)
else model.search(filter)
return true
}
@@ -288,7 +304,9 @@ class PasswordStore : BaseGitActivity() {
.setPositiveButton(resources.getString(R.string.dialog_ok), null)
when (id) {
R.id.user_pref -> {
- runCatching { startActivity(Intent(this, SettingsActivity::class.java)) }.onFailure { e -> e.printStackTrace() }
+ runCatching { startActivity(Intent(this, SettingsActivity::class.java)) }.onFailure { e ->
+ e.printStackTrace()
+ }
}
R.id.git_push -> {
if (!PasswordRepository.isInitialized) {
@@ -372,7 +390,8 @@ class PasswordStore : BaseGitActivity() {
if (localDir != null && settings.getBoolean(PreferenceKeys.REPOSITORY_INITIALIZED, false)) {
d { "Check, dir: ${localDir.absolutePath}" }
// do not push the fragment if we already have it
- if (getPasswordFragment() == null || settings.getBoolean(PreferenceKeys.REPO_CHANGED, false)) {
+ if (getPasswordFragment() == null || settings.getBoolean(PreferenceKeys.REPO_CHANGED, false)
+ ) {
settings.edit { putBoolean(PreferenceKeys.REPO_CHANGED, false) }
val args = Bundle()
args.putString(REQUEST_ARG_PATH, PasswordRepository.getRepositoryDirectory().absolutePath)
@@ -403,7 +422,9 @@ class PasswordStore : BaseGitActivity() {
fun decryptPassword(item: PasswordItem) {
val authDecryptIntent = item.createAuthEnabledIntent(this)
val decryptIntent =
- (authDecryptIntent.clone() as Intent).setComponent(ComponentName(this, DecryptActivity::class.java))
+ (authDecryptIntent.clone() as Intent).setComponent(
+ ComponentName(this, DecryptActivity::class.java)
+ )
startActivity(decryptIntent)
@@ -439,7 +460,9 @@ class PasswordStore : BaseGitActivity() {
fun deletePasswords(selectedItems: List<PasswordItem>) {
var size = 0
- selectedItems.forEach { if (it.file.isFile) size++ else size += it.file.listFilesRecursively().size }
+ selectedItems.forEach {
+ if (it.file.isFile) size++ else size += it.file.listFilesRecursively().size
+ }
if (size == 0) {
selectedItems.map { item -> item.file.deleteRecursively() }
refreshPasswordList()
@@ -497,7 +520,10 @@ class PasswordStore : BaseGitActivity() {
* @see [CategoryRenameError]
* @see [isInsideRepository]
*/
- private fun renameCategory(oldCategory: PasswordItem, error: CategoryRenameError = CategoryRenameError.None) {
+ private fun renameCategory(
+ oldCategory: PasswordItem,
+ error: CategoryRenameError = CategoryRenameError.None
+ ) {
val view = layoutInflater.inflate(R.layout.folder_dialog_fragment, null)
val newCategoryEditText = view.findViewById<TextInputEditText>(R.id.folder_name_text)
@@ -513,16 +539,19 @@ class PasswordStore : BaseGitActivity() {
.setPositiveButton(R.string.dialog_ok) { _, _ ->
val newCategory = File("${oldCategory.file.parent}/${newCategoryEditText.text}")
when {
- newCategoryEditText.text.isNullOrBlank() -> renameCategory(oldCategory, CategoryRenameError.EmptyField)
+ newCategoryEditText.text.isNullOrBlank() ->
+ renameCategory(oldCategory, CategoryRenameError.EmptyField)
newCategory.exists() -> renameCategory(oldCategory, CategoryRenameError.CategoryExists)
- !newCategory.isInsideRepository() -> renameCategory(oldCategory, CategoryRenameError.DestinationOutsideRepo)
+ !newCategory.isInsideRepository() ->
+ renameCategory(oldCategory, CategoryRenameError.DestinationOutsideRepo)
else ->
lifecycleScope.launch(Dispatchers.IO) {
moveFile(oldCategory.file, newCategory)
// associate the new category with the last category's timestamp in
// history
- val preference = getSharedPreferences("recent_password_history", Context.MODE_PRIVATE)
+ val preference =
+ getSharedPreferences("recent_password_history", Context.MODE_PRIVATE)
val timestamp = preference.getString(oldCategory.file.absolutePath.base64())
if (timestamp != null) {
preference.edit {
@@ -533,7 +562,11 @@ class PasswordStore : BaseGitActivity() {
withContext(Dispatchers.Main) {
commitChange(
- resources.getString(R.string.git_commit_move_text, oldCategory.name, newCategory.name),
+ resources.getString(
+ R.string.git_commit_move_text,
+ oldCategory.name,
+ newCategory.name
+ ),
)
}
}
@@ -584,7 +617,9 @@ class PasswordStore : BaseGitActivity() {
// Recursively list all files (not directories) below `source`, then
// obtain the corresponding target file by resolving the relative path
// starting at the destination folder.
- source.listFilesRecursively().associateWith { destinationFile.resolve(it.relativeTo(source)) }
+ source.listFilesRecursively().associateWith {
+ destinationFile.resolve(it.relativeTo(source))
+ }
} else {
mapOf(source to destinationFile)
}
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/proxy/ProxySelectorActivity.kt b/app/src/main/java/dev/msfjarvis/aps/ui/proxy/ProxySelectorActivity.kt
index 3841438e..e3761292 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/proxy/ProxySelectorActivity.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/proxy/ProxySelectorActivity.kt
@@ -28,7 +28,9 @@ private val WEB_ADDRESS_REGEX = Patterns.WEB_URL.toRegex()
class ProxySelectorActivity : AppCompatActivity() {
private val binding by viewBinding(ActivityProxySelectorBinding::inflate)
- private val proxyPrefs by lazy(LazyThreadSafetyMode.NONE) { applicationContext.getEncryptedProxyPrefs() }
+ private val proxyPrefs by lazy(LazyThreadSafetyMode.NONE) {
+ applicationContext.getEncryptedProxyPrefs()
+ }
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -36,7 +38,9 @@ class ProxySelectorActivity : AppCompatActivity() {
with(binding) {
proxyHost.setText(proxyPrefs.getString(PreferenceKeys.PROXY_HOST))
proxyUser.setText(proxyPrefs.getString(PreferenceKeys.PROXY_USERNAME))
- proxyPrefs.getInt(PreferenceKeys.PROXY_PORT, -1).takeIf { it != -1 }?.let { proxyPort.setText("$it") }
+ proxyPrefs.getInt(PreferenceKeys.PROXY_PORT, -1).takeIf { it != -1 }?.let {
+ proxyPort.setText("$it")
+ }
proxyPassword.setText(proxyPrefs.getString(PreferenceKeys.PROXY_PASSWORD))
save.setOnClickListener { saveSettings() }
proxyHost.doOnTextChanged { text, _, _, _ ->
@@ -54,10 +58,18 @@ class ProxySelectorActivity : AppCompatActivity() {
private fun saveSettings() {
proxyPrefs.edit {
- binding.proxyHost.text?.toString()?.takeIf { it.isNotEmpty() }.let { GitSettings.proxyHost = it }
- binding.proxyUser.text?.toString()?.takeIf { it.isNotEmpty() }.let { GitSettings.proxyUsername = it }
- binding.proxyPort.text?.toString()?.takeIf { it.isNotEmpty() }?.let { GitSettings.proxyPort = it.toInt() }
- binding.proxyPassword.text?.toString()?.takeIf { it.isNotEmpty() }.let { GitSettings.proxyPassword = it }
+ binding.proxyHost.text?.toString()?.takeIf { it.isNotEmpty() }.let {
+ GitSettings.proxyHost = it
+ }
+ binding.proxyUser.text?.toString()?.takeIf { it.isNotEmpty() }.let {
+ GitSettings.proxyUsername = it
+ }
+ binding.proxyPort.text?.toString()?.takeIf { it.isNotEmpty() }?.let {
+ GitSettings.proxyPort = it.toInt()
+ }
+ binding.proxyPassword.text?.toString()?.takeIf { it.isNotEmpty() }.let {
+ GitSettings.proxyPassword = it
+ }
}
ProxyUtils.setDefaultProxy()
Handler(Looper.getMainLooper()).postDelayed(500) { finish() }
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/settings/AutofillSettings.kt b/app/src/main/java/dev/msfjarvis/aps/ui/settings/AutofillSettings.kt
index ee6b468b..10dae205 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/settings/AutofillSettings.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/settings/AutofillSettings.kt
@@ -59,13 +59,18 @@ class AutofillSettings(private val activity: FragmentActivity) : SettingsProvide
val appLabel = it.first
val supportDescription =
when (it.second) {
- BrowserAutofillSupportLevel.None -> activity.getString(R.string.oreo_autofill_no_support)
- BrowserAutofillSupportLevel.FlakyFill -> activity.getString(R.string.oreo_autofill_flaky_fill_support)
+ BrowserAutofillSupportLevel.None ->
+ activity.getString(R.string.oreo_autofill_no_support)
+ BrowserAutofillSupportLevel.FlakyFill ->
+ activity.getString(R.string.oreo_autofill_flaky_fill_support)
BrowserAutofillSupportLevel.PasswordFill ->
activity.getString(R.string.oreo_autofill_password_fill_support)
BrowserAutofillSupportLevel.PasswordFillAndSaveIfNoAccessibility ->
- activity.getString(R.string.oreo_autofill_password_fill_and_conditional_save_support)
- BrowserAutofillSupportLevel.GeneralFill -> activity.getString(R.string.oreo_autofill_general_fill_support)
+ activity.getString(
+ R.string.oreo_autofill_password_fill_and_conditional_save_support
+ )
+ BrowserAutofillSupportLevel.GeneralFill ->
+ activity.getString(R.string.oreo_autofill_general_fill_support)
BrowserAutofillSupportLevel.GeneralFillAndSave ->
activity.getString(R.string.oreo_autofill_general_fill_and_save_support)
}
@@ -102,8 +107,10 @@ class AutofillSettings(private val activity: FragmentActivity) : SettingsProvide
false
}
}
- val values = activity.resources.getStringArray(R.array.oreo_autofill_directory_structure_values)
- val titles = activity.resources.getStringArray(R.array.oreo_autofill_directory_structure_entries)
+ val values =
+ activity.resources.getStringArray(R.array.oreo_autofill_directory_structure_values)
+ val titles =
+ activity.resources.getStringArray(R.array.oreo_autofill_directory_structure_entries)
val items = values.zip(titles).map { SelectionItem(it.first, it.second, null) }
singleChoice(PreferenceKeys.OREO_AUTOFILL_DIRECTORY_STRUCTURE, items) {
initialSelection = DirectoryStructure.DEFAULT.value
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/settings/DirectorySelectionActivity.kt b/app/src/main/java/dev/msfjarvis/aps/ui/settings/DirectorySelectionActivity.kt
index 475d3b5e..039b7a59 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/settings/DirectorySelectionActivity.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/settings/DirectorySelectionActivity.kt
@@ -39,7 +39,9 @@ class DirectorySelectionActivity : AppCompatActivity() {
MaterialAlertDialogBuilder(this)
.setTitle(resources.getString(R.string.sdcard_root_warning_title))
.setMessage(resources.getString(R.string.sdcard_root_warning_message))
- .setPositiveButton(resources.getString(R.string.sdcard_root_warning_remove_everything)) { _, _ ->
+ .setPositiveButton(resources.getString(R.string.sdcard_root_warning_remove_everything)) {
+ _,
+ _ ->
prefs.edit { putString(PreferenceKeys.GIT_EXTERNAL_REPO, uri.path) }
}
.setNegativeButton(R.string.dialog_cancel, null)
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/settings/GeneralSettings.kt b/app/src/main/java/dev/msfjarvis/aps/ui/settings/GeneralSettings.kt
index da93c3fe..1e67a2b5 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/settings/GeneralSettings.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/settings/GeneralSettings.kt
@@ -26,7 +26,8 @@ class GeneralSettings(private val activity: FragmentActivity) : SettingsProvider
builder.apply {
val themeValues = activity.resources.getStringArray(R.array.app_theme_values)
val themeOptions = activity.resources.getStringArray(R.array.app_theme_options)
- val themeItems = themeValues.zip(themeOptions).map { SelectionItem(it.first, it.second, null) }
+ val themeItems =
+ themeValues.zip(themeOptions).map { SelectionItem(it.first, it.second, null) }
singleChoice(PreferenceKeys.APP_THEME, themeItems) {
initialSelection = activity.resources.getString(R.string.app_theme_def)
titleRes = R.string.pref_app_theme_title
@@ -64,7 +65,8 @@ class GeneralSettings(private val activity: FragmentActivity) : SettingsProvider
defaultValue = false
enabled = canAuthenticate
summaryRes =
- if (canAuthenticate) R.string.pref_biometric_auth_summary else R.string.pref_biometric_auth_summary_error
+ if (canAuthenticate) R.string.pref_biometric_auth_summary
+ else R.string.pref_biometric_auth_summary_error
onClick {
enabled = false
val isChecked = checked
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/settings/RepositorySettings.kt b/app/src/main/java/dev/msfjarvis/aps/ui/settings/RepositorySettings.kt
index 3e99c890..ba871f91 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/settings/RepositorySettings.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/settings/RepositorySettings.kt
@@ -37,7 +37,9 @@ import dev.msfjarvis.aps.util.settings.PreferenceKeys
class RepositorySettings(private val activity: FragmentActivity) : SettingsProvider {
- private val encryptedPreferences by lazy(LazyThreadSafetyMode.NONE) { activity.getEncryptedGitPrefs() }
+ private val encryptedPreferences by lazy(LazyThreadSafetyMode.NONE) {
+ activity.getEncryptedGitPrefs()
+ }
private fun <T : FragmentActivity> launchActivity(clazz: Class<T>) {
activity.startActivity(Intent(activity, clazz))
@@ -47,7 +49,9 @@ class RepositorySettings(private val activity: FragmentActivity) : SettingsProvi
MaterialAlertDialogBuilder(activity)
.setTitle(activity.resources.getString(R.string.external_repository_dialog_title))
.setMessage(activity.resources.getString(R.string.external_repository_dialog_text))
- .setPositiveButton(R.string.dialog_ok) { _, _ -> launchActivity(DirectorySelectionActivity::class.java) }
+ .setPositiveButton(R.string.dialog_ok) { _, _ ->
+ launchActivity(DirectorySelectionActivity::class.java)
+ }
.setNegativeButton(R.string.dialog_cancel, null)
.show()
}
@@ -130,7 +134,9 @@ class RepositorySettings(private val activity: FragmentActivity) : SettingsProvi
}
pref(PreferenceKeys.SSH_OPENKEYSTORE_CLEAR_KEY_ID) {
titleRes = R.string.pref_title_openkeystore_clear_keyid
- visible = activity.sharedPrefs.getString(PreferenceKeys.SSH_OPENKEYSTORE_KEYID)?.isNotEmpty() ?: false
+ visible =
+ activity.sharedPrefs.getString(PreferenceKeys.SSH_OPENKEYSTORE_KEYID)?.isNotEmpty()
+ ?: false
onClick {
activity.sharedPrefs.edit { putString(PreferenceKeys.SSH_OPENKEYSTORE_KEYID, null) }
visible = false
@@ -160,7 +166,9 @@ class RepositorySettings(private val activity: FragmentActivity) : SettingsProvi
removeDynamicShortcuts(dynamicShortcuts.map { it.id }.toMutableList())
}
}
- activity.sharedPrefs.edit { putBoolean(PreferenceKeys.REPOSITORY_INITIALIZED, false) }
+ activity.sharedPrefs.edit {
+ putBoolean(PreferenceKeys.REPOSITORY_INITIALIZED, false)
+ }
dialogInterface.cancel()
activity.finish()
}
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/settings/SettingsActivity.kt b/app/src/main/java/dev/msfjarvis/aps/ui/settings/SettingsActivity.kt
index ceb6599b..91dd4908 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/settings/SettingsActivity.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/settings/SettingsActivity.kt
@@ -68,7 +68,9 @@ class SettingsActivity : AppCompatActivity() {
getString(subScreen.titleRes)
}
}
- savedInstanceState?.getParcelable<PreferencesAdapter.SavedState>("adapter")?.let(adapter::loadSavedState)
+ savedInstanceState
+ ?.getParcelable<PreferencesAdapter.SavedState>("adapter")
+ ?.let(adapter::loadSavedState)
binding.preferenceRecyclerView.adapter = adapter
}
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/sshkeygen/ShowSshKeyFragment.kt b/app/src/main/java/dev/msfjarvis/aps/ui/sshkeygen/ShowSshKeyFragment.kt
index ee54febe..73cd2ba1 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/sshkeygen/ShowSshKeyFragment.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/sshkeygen/ShowSshKeyFragment.kt
@@ -20,7 +20,9 @@ class ShowSshKeyFragment : DialogFragment() {
return MaterialAlertDialogBuilder(requireActivity()).run {
setMessage(getString(R.string.ssh_keygen_message, publicKey))
setTitle(R.string.your_public_key)
- setNegativeButton(R.string.ssh_keygen_later) { _, _ -> (activity as? SshKeyGenActivity)?.finish() }
+ setNegativeButton(R.string.ssh_keygen_later) { _, _ ->
+ (activity as? SshKeyGenActivity)?.finish()
+ }
setPositiveButton(R.string.ssh_keygen_share) { _, _ ->
val sendIntent =
Intent().apply {
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/sshkeygen/SshKeyGenActivity.kt b/app/src/main/java/dev/msfjarvis/aps/ui/sshkeygen/SshKeyGenActivity.kt
index ae420813..cc2cd4c7 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/sshkeygen/SshKeyGenActivity.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/sshkeygen/SshKeyGenActivity.kt
@@ -30,9 +30,15 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
private enum class KeyGenType(val generateKey: suspend (requireAuthentication: Boolean) -> Unit) {
- Rsa({ requireAuthentication -> SshKey.generateKeystoreNativeKey(SshKey.Algorithm.Rsa, requireAuthentication) }),
- Ecdsa({ requireAuthentication -> SshKey.generateKeystoreNativeKey(SshKey.Algorithm.Ecdsa, requireAuthentication) }),
- Ed25519({ requireAuthentication -> SshKey.generateKeystoreWrappedEd25519Key(requireAuthentication) }),
+ Rsa({ requireAuthentication ->
+ SshKey.generateKeystoreNativeKey(SshKey.Algorithm.Rsa, requireAuthentication)
+ }),
+ Ecdsa({ requireAuthentication ->
+ SshKey.generateKeystoreNativeKey(SshKey.Algorithm.Ecdsa, requireAuthentication)
+ }),
+ Ed25519({ requireAuthentication ->
+ SshKey.generateKeystoreWrappedEd25519Key(requireAuthentication)
+ }),
}
class SshKeyGenActivity : AppCompatActivity() {
@@ -50,7 +56,9 @@ class SshKeyGenActivity : AppCompatActivity() {
MaterialAlertDialogBuilder(this@SshKeyGenActivity).run {
setTitle(R.string.ssh_keygen_existing_title)
setMessage(R.string.ssh_keygen_existing_message)
- setPositiveButton(R.string.ssh_keygen_existing_replace) { _, _ -> lifecycleScope.launch { generate() } }
+ setPositiveButton(R.string.ssh_keygen_existing_replace) { _, _ ->
+ lifecycleScope.launch { generate() }
+ }
setNegativeButton(R.string.ssh_keygen_existing_keep) { _, _ -> finish() }
show()
}
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/sshkeygen/SshKeyImportActivity.kt b/app/src/main/java/dev/msfjarvis/aps/ui/sshkeygen/SshKeyImportActivity.kt
index bf9f6eda..af00e3df 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/sshkeygen/SshKeyImportActivity.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/sshkeygen/SshKeyImportActivity.kt
@@ -26,7 +26,12 @@ class SshKeyImportActivity : AppCompatActivity() {
}
runCatching {
SshKey.import(uri)
- Toast.makeText(this, resources.getString(R.string.ssh_key_success_dialog_title), Toast.LENGTH_LONG).show()
+ Toast.makeText(
+ this,
+ resources.getString(R.string.ssh_key_success_dialog_title),
+ Toast.LENGTH_LONG
+ )
+ .show()
setResult(RESULT_OK)
finish()
}