aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2023-07-09 16:48:34 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2023-07-09 16:48:34 +0530
commit6f3f7e4b4c6a7eb8efe4e7a2cb3fea8d7ef1bb5d (patch)
tree3557f667c51ff362442978da01da53981edad01b
parent378ce98cd029a4e054ca2e5914a560f3ac706771 (diff)
refactor: adopt Kotlin 1.9's `data object`s
-rw-r--r--app/src/main/java/app/passwordstore/util/auth/BiometricAuthenticator.kt6
-rw-r--r--app/src/main/java/app/passwordstore/util/git/ErrorMessages.kt8
-rw-r--r--app/src/main/java/app/passwordstore/util/settings/GitSettings.kt4
-rw-r--r--crypto-common/src/main/kotlin/app/passwordstore/crypto/errors/CryptoException.kt12
4 files changed, 15 insertions, 15 deletions
diff --git a/app/src/main/java/app/passwordstore/util/auth/BiometricAuthenticator.kt b/app/src/main/java/app/passwordstore/util/auth/BiometricAuthenticator.kt
index ddc52ff2..4b91bee6 100644
--- a/app/src/main/java/app/passwordstore/util/auth/BiometricAuthenticator.kt
+++ b/app/src/main/java/app/passwordstore/util/auth/BiometricAuthenticator.kt
@@ -37,13 +37,13 @@ object BiometricAuthenticator {
* An incorrect biometric was entered, but the prompt UI is offering the option to retry the
* operation.
*/
- object Retry : Result()
+ data object Retry : Result()
/** The biometric hardware is unavailable or disabled on a software or hardware level. */
- object HardwareUnavailableOrDisabled : Result()
+ data object HardwareUnavailableOrDisabled : Result()
/** The prompt was dismissed. */
- object Cancelled : Result()
+ data object Cancelled : Result()
}
fun canAuthenticate(activity: FragmentActivity): Boolean {
diff --git a/app/src/main/java/app/passwordstore/util/git/ErrorMessages.kt b/app/src/main/java/app/passwordstore/util/git/ErrorMessages.kt
index 41ed8e9a..8ce0125b 100644
--- a/app/src/main/java/app/passwordstore/util/git/ErrorMessages.kt
+++ b/app/src/main/java/app/passwordstore/util/git/ErrorMessages.kt
@@ -28,17 +28,17 @@ sealed class GitException(@StringRes res: Int, vararg fmt: String) :
/** Encapsulates possible errors from a [org.eclipse.jgit.api.PullCommand]. */
sealed class PullException(@StringRes res: Int, vararg fmt: String) : GitException(res, *fmt) {
- object PullRebaseFailed : PullException(R.string.git_pull_rebase_fail_error)
+ data object PullRebaseFailed : PullException(R.string.git_pull_rebase_fail_error)
- object PullMergeFailed : PullException(R.string.git_pull_merge_fail_error)
+ data object PullMergeFailed : PullException(R.string.git_pull_merge_fail_error)
}
/** Encapsulates possible errors from a [org.eclipse.jgit.api.PushCommand]. */
sealed class PushException(@StringRes res: Int, vararg fmt: String) : GitException(res, *fmt) {
- object NonFastForward : PushException(R.string.git_push_nff_error)
+ data object NonFastForward : PushException(R.string.git_push_nff_error)
- object RemoteRejected : PushException(R.string.git_push_other_error)
+ data object RemoteRejected : PushException(R.string.git_push_other_error)
class Generic(message: String) : PushException(R.string.git_push_generic_error, message)
}
diff --git a/app/src/main/java/app/passwordstore/util/settings/GitSettings.kt b/app/src/main/java/app/passwordstore/util/settings/GitSettings.kt
index e01e6317..b7422c99 100644
--- a/app/src/main/java/app/passwordstore/util/settings/GitSettings.kt
+++ b/app/src/main/java/app/passwordstore/util/settings/GitSettings.kt
@@ -135,9 +135,9 @@ constructor(
class AuthModeMismatch(val newProtocol: Protocol, val validModes: List<AuthMode>) :
UpdateConnectionSettingsResult()
- object Valid : UpdateConnectionSettingsResult()
+ data object Valid : UpdateConnectionSettingsResult()
- object FailedToParseUrl : UpdateConnectionSettingsResult()
+ data object FailedToParseUrl : UpdateConnectionSettingsResult()
}
fun updateConnectionSettingsIfValid(
diff --git a/crypto-common/src/main/kotlin/app/passwordstore/crypto/errors/CryptoException.kt b/crypto-common/src/main/kotlin/app/passwordstore/crypto/errors/CryptoException.kt
index 551a051e..eb64541e 100644
--- a/crypto-common/src/main/kotlin/app/passwordstore/crypto/errors/CryptoException.kt
+++ b/crypto-common/src/main/kotlin/app/passwordstore/crypto/errors/CryptoException.kt
@@ -9,21 +9,21 @@ public sealed class CryptoException(message: String? = null, cause: Throwable? =
public sealed class KeyManagerException(message: String? = null) : CryptoException(message)
/** Store contains no keys. */
-public object NoKeysAvailableException : KeyManagerException("No keys were found")
+public data object NoKeysAvailableException : KeyManagerException("No keys were found")
/** Key directory does not exist or cannot be accessed. */
-public object KeyDirectoryUnavailableException :
+public data object KeyDirectoryUnavailableException :
KeyManagerException("Key directory does not exist")
/** Failed to delete given key. */
-public object KeyDeletionFailedException : KeyManagerException("Couldn't delete the key file")
+public data object KeyDeletionFailedException : KeyManagerException("Couldn't delete the key file")
/** Failed to parse the key as a known type. */
-public object InvalidKeyException :
+public data object InvalidKeyException :
KeyManagerException("Given key cannot be parsed as a known key type")
/** Key failed the [app.passwordstore.crypto.KeyUtils.isKeyUsable] test. */
-public object UnusableKeyException :
+public data object UnusableKeyException :
KeyManagerException("Given key is not usable for encryption - is it using AEAD?")
/** No key matching `keyId` could be found. */
@@ -42,7 +42,7 @@ public sealed class CryptoHandlerException(message: String? = null, cause: Throw
public class IncorrectPassphraseException(cause: Throwable) : CryptoHandlerException(null, cause)
/** No keys were passed to the encrypt/decrypt operation. */
-public object NoKeysProvidedException : CryptoHandlerException(null, null)
+public data object NoKeysProvidedException : CryptoHandlerException(null, null)
/** An unexpected error that cannot be mapped to a known type. */
public class UnknownError(cause: Throwable) : CryptoHandlerException(null, cause)