diff options
| author | Harsh Shandilya <me@msfjarvis.dev> | 2022-06-09 13:51:29 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-09 13:51:29 +0530 |
| commit | 426fc924fba28ec898681ad7f7010456554f061e (patch) | |
| tree | 195eac25c605a89f4e239578d685928a64675ee0 /app/src/main/java/dev/msfjarvis/aps/ui | |
| parent | f968b21bf665975e17ad9b03bcff652000e96ec4 (diff) | |
| download | HardenedPass-426fc924fba28ec898681ad7f7010456554f061e.tar.gz HardenedPass-426fc924fba28ec898681ad7f7010456554f061e.zip | |
Upgrade ktfmt (#1942)
* build-logic: upgrade ktfmt
* all: reformat
Diffstat (limited to 'app/src/main/java/dev/msfjarvis/aps/ui')
10 files changed, 41 insertions, 25 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 4a40a5e0..b5052049 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 @@ -195,7 +195,8 @@ class AutofillDecryptActivity : AppCompatActivity() { return null } .onSuccess { result -> - return when (val resultCode = + return when ( + val resultCode = result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR) ) { OpenPgpApi.RESULT_CODE_SUCCESS -> { 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 b0dfa6ec..89f1a733 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 @@ -204,7 +204,8 @@ class AutofillFilterView : AppCompatActivity() { } // 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) || + if ( + (list.isEmpty() && rvPasswordSwitcher.nextView.id == rvPasswordEmpty.id) || (list.isNotEmpty() && rvPasswordSwitcher.nextView.id == rvPassword.id) ) { rvPasswordSwitcher.showNext() 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 113c3bb6..b1f11dfa 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 @@ -274,7 +274,8 @@ class PasswordCreationActivity : BasePgpActivity(), OpenPgpServiceConnection.OnB // Allow the user to quickly switch between storing the username as the filename or // in the encrypted extras. This only makes sense if the directory structure is // FileBased. - if (suggestedName == null && + if ( + suggestedName == null && AutofillPreferences.directoryStructure(this@PasswordCreationActivity) == DirectoryStructure.FileBased ) { @@ -418,9 +419,8 @@ class PasswordCreationActivity : BasePgpActivity(), OpenPgpServiceConnection.OnB GpgIdentifier.fromString(line) ?: run { // The line being empty means this is most likely an empty `.gpg-id` - // file - // we created. Skip the validation so we can make the user add a real - // ID. + // file we created. Skip the validation so we can make the user add a + // real ID. if (line.isEmpty()) return@run if (line.removePrefix("0x").matches("[a-fA-F0-9]{8}".toRegex())) { snackbar(message = resources.getString(R.string.short_key_ids_unsupported)) @@ -488,7 +488,8 @@ 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)) && + if ( + (!editing || (editing && suggestedName != file.nameWithoutExtension)) && file.exists() ) { snackbar(message = getString(R.string.password_creation_duplicate_error)) @@ -535,7 +536,8 @@ class PasswordCreationActivity : BasePgpActivity(), OpenPgpServiceConnection.OnB returnIntent.putExtra(RETURN_EXTRA_USERNAME, username) } - if (directoryInputLayout.isVisible && + if ( + directoryInputLayout.isVisible && directoryInputLayout.isEnabled && oldFileName != null ) { diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/crypto/PasswordCreationActivityV2.kt b/app/src/main/java/dev/msfjarvis/aps/ui/crypto/PasswordCreationActivityV2.kt index b435b6e7..5792c892 100644 --- a/app/src/main/java/dev/msfjarvis/aps/ui/crypto/PasswordCreationActivityV2.kt +++ b/app/src/main/java/dev/msfjarvis/aps/ui/crypto/PasswordCreationActivityV2.kt @@ -204,7 +204,8 @@ class PasswordCreationActivityV2 : BasePgpActivity() { // Allow the user to quickly switch between storing the username as the filename or // in the encrypted extras. This only makes sense if the directory structure is // FileBased. - if (suggestedName == null && + if ( + suggestedName == null && AutofillPreferences.directoryStructure(this@PasswordCreationActivityV2) == DirectoryStructure.FileBased ) { @@ -368,8 +369,8 @@ class PasswordCreationActivityV2 : BasePgpActivity() { // 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 @@ -407,7 +408,8 @@ class PasswordCreationActivityV2 : BasePgpActivity() { returnIntent.putExtra(RETURN_EXTRA_USERNAME, username) } - if (directoryInputLayout.isVisible && + if ( + directoryInputLayout.isVisible && directoryInputLayout.isEnabled && oldFileName != null ) { 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 54fd2892..cae55ba1 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 @@ -65,7 +65,8 @@ class SelectFolderFragment : Fragment(R.layout.password_recycler_view) { if (item.type == PasswordItem.TYPE_CATEGORY) { model.navigateTo(item.file, listMode = ListMode.DirectoriesOnly) (requireActivity() as AppCompatActivity) - .supportActionBar?.setDisplayHomeAsUpEnabled(true) + .supportActionBar + ?.setDisplayHomeAsUpEnabled(true) } } } 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 e44e3e3c..614d9a52 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 @@ -152,7 +152,8 @@ 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 + if ( + cause is SSHException && cause.disconnectReason == DisconnectReason.AUTH_CANCELLED_BY_USER ) return true cause = cause.cause @@ -170,11 +171,13 @@ abstract class BaseGitActivity : ContinuationContainerActivity() { // exceptions. // Also, SSHJ's UserAuthException about exhausting available authentication methods hides // more useful exceptions. - 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"))) { + 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 = rootCause.cause ?: break } return rootCause 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 e713a54e..93f104fb 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 @@ -140,7 +140,8 @@ class GitServerConfigActivity : BaseGitActivity() { .show(supportFragmentManager, "SSH_SCHEME_WARNING") return@setOnClickListener } - when (val updateResult = + when ( + val updateResult = gitSettings.updateConnectionSettingsIfValid( newAuthMode = newAuthMode, newUrl = binding.serverUrl.text.toString().trim(), @@ -230,7 +231,8 @@ 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() && + if ( + localDir.exists() && localDirFiles.isNotEmpty() && !(localDirFiles.size == 1 && localDirFiles[0].name == ".git") ) { 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 117d1d49..c70f0b5a 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 @@ -303,7 +303,8 @@ class PasswordFragment : Fragment(R.layout.password_recycler_view) { listener = object : OnFragmentInteractionListener { override fun onFragmentInteraction(item: PasswordItem) { - if (settings.getString(PreferenceKeys.SORT_ORDER) == + if ( + settings.getString(PreferenceKeys.SORT_ORDER) == PasswordSortOrder.RECENTLY_USED.name ) { // save the time when password was used 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 84bef7bb..0ee42896 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 @@ -182,7 +182,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 || + if ( + (keyCode == KeyEvent.KEYCODE_SEARCH || keyCode == KeyEvent.KEYCODE_F && event.isCtrlPressed) && !searchItem.isActionViewExpanded ) { searchItem.expandActionView() @@ -353,7 +354,8 @@ class PasswordStore : BaseGitActivity() { if (localDir != null && settings.getBoolean(PreferenceKeys.REPOSITORY_INITIALIZED, false)) { logcat { "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() 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 63abdf7c..dec0c135 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 @@ -127,7 +127,8 @@ class SshKeyGenActivity : AppCompatActivity() { this@SshKeyGenActivity, R.string.biometric_prompt_title_ssh_keygen ) { result -> - // Do not cancel on failed attempts as these are handled by the authenticator UI. + // Do not cancel on failed attempts as these are handled by the + // authenticator UI. if (result !is Result.Retry) cont.resume(result) } } |
