diff options
author | Aditya Wasan <adityawasan55@gmail.com> | 2021-05-22 17:51:02 +0530 |
---|---|---|
committer | Harsh Shandilya <me@msfjarvis.dev> | 2021-05-22 20:05:54 +0530 |
commit | 521f4772d797ca424dcb076359382d7a336b8de7 (patch) | |
tree | 23b610fe90a7fbba2902328b0ab0271fbb9780e2 /app/src | |
parent | d45bb753cfeb5300ac563135b01872a9058ce1ca (diff) |
spotless: fix formatting
Signed-off-by: Aditya Wasan <adityawasan55@gmail.com>
Diffstat (limited to 'app/src')
12 files changed, 61 insertions, 38 deletions
diff --git a/app/src/main/java/dev/msfjarvis/aps/injection/context/ContextModule.kt b/app/src/main/java/dev/msfjarvis/aps/injection/context/ContextModule.kt index cdb0f9f1..6399781e 100644 --- a/app/src/main/java/dev/msfjarvis/aps/injection/context/ContextModule.kt +++ b/app/src/main/java/dev/msfjarvis/aps/injection/context/ContextModule.kt @@ -16,4 +16,4 @@ class ContextModule { fun providesFilesDirPath(@ApplicationContext context: Context): String { return context.filesDir.path } -}
\ No newline at end of file +} diff --git a/app/src/main/java/dev/msfjarvis/aps/injection/context/FilesDirPath.kt b/app/src/main/java/dev/msfjarvis/aps/injection/context/FilesDirPath.kt index 8bced295..ec747bfe 100644 --- a/app/src/main/java/dev/msfjarvis/aps/injection/context/FilesDirPath.kt +++ b/app/src/main/java/dev/msfjarvis/aps/injection/context/FilesDirPath.kt @@ -2,6 +2,4 @@ package dev.msfjarvis.aps.injection.context import javax.inject.Qualifier -@Qualifier -@Retention(AnnotationRetention.RUNTIME) -annotation class FilesDirPath
\ No newline at end of file +@Qualifier @Retention(AnnotationRetention.RUNTIME) annotation class FilesDirPath diff --git a/app/src/main/java/dev/msfjarvis/aps/injection/prefs/GitPreferences.kt b/app/src/main/java/dev/msfjarvis/aps/injection/prefs/GitPreferences.kt index c07bc65e..749eea48 100644 --- a/app/src/main/java/dev/msfjarvis/aps/injection/prefs/GitPreferences.kt +++ b/app/src/main/java/dev/msfjarvis/aps/injection/prefs/GitPreferences.kt @@ -2,6 +2,4 @@ package dev.msfjarvis.aps.injection.prefs import javax.inject.Qualifier -@Qualifier -@Retention(AnnotationRetention.RUNTIME) -annotation class GitPreferences
\ No newline at end of file +@Qualifier @Retention(AnnotationRetention.RUNTIME) annotation class GitPreferences diff --git a/app/src/main/java/dev/msfjarvis/aps/injection/prefs/PreferenceModule.kt b/app/src/main/java/dev/msfjarvis/aps/injection/prefs/PreferenceModule.kt index 41d2a30b..537ee1ad 100644 --- a/app/src/main/java/dev/msfjarvis/aps/injection/prefs/PreferenceModule.kt +++ b/app/src/main/java/dev/msfjarvis/aps/injection/prefs/PreferenceModule.kt @@ -17,7 +17,10 @@ import dev.msfjarvis.aps.BuildConfig @InstallIn(SingletonComponent::class) class PreferenceModule { - private fun provideBaseEncryptedPreferences(context: Context, fileName: String): SharedPreferences { + private fun provideBaseEncryptedPreferences( + context: Context, + fileName: String + ): SharedPreferences { val masterKeyAlias = MasterKey.Builder(context).setKeyScheme(MasterKey.KeyScheme.AES256_GCM).build() return EncryptedSharedPreferences.create( @@ -49,4 +52,4 @@ class PreferenceModule { fun provideProxyPreferences(@ApplicationContext context: Context): SharedPreferences { return provideBaseEncryptedPreferences(context, "http_proxy") } -}
\ No newline at end of file +} diff --git a/app/src/main/java/dev/msfjarvis/aps/injection/prefs/ProxyPreferences.kt b/app/src/main/java/dev/msfjarvis/aps/injection/prefs/ProxyPreferences.kt index c0b43088..786087ad 100644 --- a/app/src/main/java/dev/msfjarvis/aps/injection/prefs/ProxyPreferences.kt +++ b/app/src/main/java/dev/msfjarvis/aps/injection/prefs/ProxyPreferences.kt @@ -2,6 +2,4 @@ package dev.msfjarvis.aps.injection.prefs import javax.inject.Qualifier -@Qualifier -@Retention(AnnotationRetention.RUNTIME) -annotation class ProxyPreferences
\ No newline at end of file +@Qualifier @Retention(AnnotationRetention.RUNTIME) annotation class ProxyPreferences diff --git a/app/src/main/java/dev/msfjarvis/aps/injection/prefs/SettingsPreferences.kt b/app/src/main/java/dev/msfjarvis/aps/injection/prefs/SettingsPreferences.kt index 7bd1f9b9..7bca03c8 100644 --- a/app/src/main/java/dev/msfjarvis/aps/injection/prefs/SettingsPreferences.kt +++ b/app/src/main/java/dev/msfjarvis/aps/injection/prefs/SettingsPreferences.kt @@ -2,6 +2,4 @@ package dev.msfjarvis.aps.injection.prefs import javax.inject.Qualifier -@Qualifier -@Retention(AnnotationRetention.RUNTIME) -annotation class SettingsPreferences
\ No newline at end of file +@Qualifier @Retention(AnnotationRetention.RUNTIME) annotation class SettingsPreferences 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 d2f6ca38..892289af 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 @@ -57,7 +57,6 @@ import dev.msfjarvis.aps.util.extensions.listFilesRecursively import dev.msfjarvis.aps.util.extensions.requestInputFocusOnView import dev.msfjarvis.aps.util.extensions.sharedPrefs import dev.msfjarvis.aps.util.settings.AuthMode -import dev.msfjarvis.aps.util.settings.GitSettings import dev.msfjarvis.aps.util.settings.PreferenceKeys import dev.msfjarvis.aps.util.shortcuts.ShortcutHandler import dev.msfjarvis.aps.util.viewmodel.SearchableRepositoryViewModel 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 a9055408..86b57533 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 @@ -42,11 +42,14 @@ import dev.msfjarvis.aps.util.settings.PreferenceKeys class RepositorySettings(private val activity: FragmentActivity) : SettingsProvider { - private val hiltEntryPoint = EntryPointAccessors.fromApplication(activity.applicationContext, RepositorySettingsEntryPoint::class.java) + private val hiltEntryPoint = + EntryPointAccessors.fromApplication( + activity.applicationContext, + RepositorySettingsEntryPoint::class.java, + ) private val encryptedPreferences = hiltEntryPoint.encryptedPreferences() private val gitSettings = hiltEntryPoint.gitSettings() - private fun <T : FragmentActivity> launchActivity(clazz: Class<T>) { activity.startActivity(Intent(activity, clazz)) } diff --git a/app/src/main/java/dev/msfjarvis/aps/util/git/GitCommandExecutor.kt b/app/src/main/java/dev/msfjarvis/aps/util/git/GitCommandExecutor.kt index 5d507dc8..be0527a2 100644 --- a/app/src/main/java/dev/msfjarvis/aps/util/git/GitCommandExecutor.kt +++ b/app/src/main/java/dev/msfjarvis/aps/util/git/GitCommandExecutor.kt @@ -34,7 +34,11 @@ class GitCommandExecutor( private val operation: GitOperation, ) { - private val hiltEntryPoint = EntryPointAccessors.fromApplication(activity.applicationContext, GitCommandExecutorEntryPoint::class.java) + private val hiltEntryPoint = + EntryPointAccessors.fromApplication( + activity.applicationContext, + GitCommandExecutorEntryPoint::class.java + ) private val gitSettings = hiltEntryPoint.gitSettings() suspend fun execute(): Result<Unit, Throwable> { diff --git a/app/src/main/java/dev/msfjarvis/aps/util/git/operation/GitOperation.kt b/app/src/main/java/dev/msfjarvis/aps/util/git/operation/GitOperation.kt index 5a9da290..9d296353 100644 --- a/app/src/main/java/dev/msfjarvis/aps/util/git/operation/GitOperation.kt +++ b/app/src/main/java/dev/msfjarvis/aps/util/git/operation/GitOperation.kt @@ -16,7 +16,6 @@ import com.github.michaelbull.result.runCatching import com.google.android.material.dialog.MaterialAlertDialogBuilder import dagger.hilt.EntryPoint import dagger.hilt.InstallIn -import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.EntryPointAccessors import dagger.hilt.components.SingletonComponent import dev.msfjarvis.aps.R @@ -31,8 +30,6 @@ import dev.msfjarvis.aps.util.git.sshj.SshKey import dev.msfjarvis.aps.util.git.sshj.SshjSessionFactory import dev.msfjarvis.aps.util.settings.AuthMode import dev.msfjarvis.aps.util.settings.GitSettings -import javax.inject.Inject -import javax.inject.Singleton import kotlin.coroutines.resume import kotlin.coroutines.suspendCoroutine import kotlinx.coroutines.Dispatchers @@ -60,7 +57,11 @@ abstract class GitOperation(protected val callingActivity: FragmentActivity) { abstract val commands: Array<GitCommand<out Any>> private val hostKeyFile = callingActivity.filesDir.resolve(".host_key") private var sshSessionFactory: SshjSessionFactory? = null - private val hiltEntryPoint = EntryPointAccessors.fromApplication(callingActivity.applicationContext, GitOperationEntryPoint::class.java) + private val hiltEntryPoint = + EntryPointAccessors.fromApplication( + callingActivity.applicationContext, + GitOperationEntryPoint::class.java + ) protected val repository = PasswordRepository.getRepository(null)!! protected val git = Git(repository) @@ -229,7 +230,6 @@ abstract class GitOperation(protected val callingActivity: FragmentActivity) { private const val CONNECT_TIMEOUT = 10 } - // Using @EntryPoint seems to be our best option here, changing this to constructor injection would require a larger refactor. @EntryPoint @InstallIn(SingletonComponent::class) interface GitOperationEntryPoint { diff --git a/app/src/main/java/dev/msfjarvis/aps/util/settings/GitSettings.kt b/app/src/main/java/dev/msfjarvis/aps/util/settings/GitSettings.kt index 0d580142..50b6cbfe 100644 --- a/app/src/main/java/dev/msfjarvis/aps/util/settings/GitSettings.kt +++ b/app/src/main/java/dev/msfjarvis/aps/util/settings/GitSettings.kt @@ -52,16 +52,16 @@ enum class AuthMode(val pref: String) { } @Singleton -class GitSettings @Inject constructor( +class GitSettings +@Inject +constructor( @SettingsPreferences private val settings: SharedPreferences, @GitPreferences private val encryptedSettings: SharedPreferences, @ProxyPreferences private val proxySettings: SharedPreferences, @FilesDirPath private val filesDirPath: String, ) { - private val hostKeyPath by lazy(LazyThreadSafetyMode.NONE) { - "$filesDirPath/.host_key" - } + private val hostKeyPath by lazy(LazyThreadSafetyMode.NONE) { "$filesDirPath/.host_key" } var authMode get() = AuthMode.fromString(settings.getString(PreferenceKeys.GIT_REMOTE_AUTH)) private set(value) { @@ -128,7 +128,8 @@ class GitSettings @Inject constructor( sealed class UpdateConnectionSettingsResult { class MissingUsername(val newProtocol: Protocol) : UpdateConnectionSettingsResult() - class AuthModeMismatch(val newProtocol: Protocol, val validModes: List<AuthMode>) : UpdateConnectionSettingsResult() + class AuthModeMismatch(val newProtocol: Protocol, val validModes: List<AuthMode>) : + UpdateConnectionSettingsResult() object Valid : UpdateConnectionSettingsResult() object FailedToParseUrl : UpdateConnectionSettingsResult() } diff --git a/app/src/test/java/dev/msfjarvis/aps/util/settings/MigrationsTest.kt b/app/src/test/java/dev/msfjarvis/aps/util/settings/MigrationsTest.kt index 520d51ac..71f457ec 100644 --- a/app/src/test/java/dev/msfjarvis/aps/util/settings/MigrationsTest.kt +++ b/app/src/test/java/dev/msfjarvis/aps/util/settings/MigrationsTest.kt @@ -59,7 +59,11 @@ class MigrationsTest { putString(PreferenceKeys.GIT_REMOTE_PROTOCOL, Protocol.Ssh.pref) putString(PreferenceKeys.GIT_REMOTE_AUTH, AuthMode.Password.pref) } - runMigrations(filesDir, sharedPrefs, GitSettings(sharedPrefs, encryptedSharedPreferences, proxySharedPreferences, filesDir)) + runMigrations( + filesDir, + sharedPrefs, + GitSettings(sharedPrefs, encryptedSharedPreferences, proxySharedPreferences, filesDir) + ) checkOldKeysAreRemoved() assertEquals( sharedPrefs.getString(PreferenceKeys.GIT_REMOTE_URL), @@ -77,7 +81,11 @@ class MigrationsTest { putString(PreferenceKeys.GIT_REMOTE_PROTOCOL, Protocol.Ssh.pref) putString(PreferenceKeys.GIT_REMOTE_AUTH, AuthMode.SshKey.pref) } - runMigrations(filesDir, sharedPrefs, GitSettings(sharedPrefs, encryptedSharedPreferences, proxySharedPreferences, filesDir)) + runMigrations( + filesDir, + sharedPrefs, + GitSettings(sharedPrefs, encryptedSharedPreferences, proxySharedPreferences, filesDir) + ) checkOldKeysAreRemoved(context) assertEquals( sharedPrefs.getString(PreferenceKeys.GIT_REMOTE_URL), @@ -95,7 +103,11 @@ class MigrationsTest { putString(PreferenceKeys.GIT_REMOTE_PROTOCOL, Protocol.Https.pref) putString(PreferenceKeys.GIT_REMOTE_AUTH, AuthMode.None.pref) } - runMigrations(filesDir, sharedPrefs, GitSettings(sharedPrefs, encryptedSharedPreferences, proxySharedPreferences, filesDir)) + runMigrations( + filesDir, + sharedPrefs, + GitSettings(sharedPrefs, encryptedSharedPreferences, proxySharedPreferences, filesDir) + ) checkOldKeysAreRemoved(context) assertEquals( sharedPrefs.getString(PreferenceKeys.GIT_REMOTE_URL), @@ -106,7 +118,11 @@ class MigrationsTest { @Test fun verifyHiddenFoldersMigrationIfDisabled() { sharedPrefs.edit { clear() } - runMigrations(filesDir, sharedPrefs, GitSettings(sharedPrefs, encryptedSharedPreferences, proxySharedPreferences, filesDir)) + runMigrations( + filesDir, + sharedPrefs, + GitSettings(sharedPrefs, encryptedSharedPreferences, proxySharedPreferences, filesDir) + ) assertEquals(true, sharedPrefs.getBoolean(PreferenceKeys.SHOW_HIDDEN_FOLDERS, true)) assertEquals(false, sharedPrefs.getBoolean(PreferenceKeys.SHOW_HIDDEN_CONTENTS, false)) } @@ -117,7 +133,11 @@ class MigrationsTest { clear() putBoolean(PreferenceKeys.SHOW_HIDDEN_FOLDERS, true) } - runMigrations(filesDir, sharedPrefs, GitSettings(sharedPrefs, encryptedSharedPreferences, proxySharedPreferences, filesDir)) + runMigrations( + filesDir, + sharedPrefs, + GitSettings(sharedPrefs, encryptedSharedPreferences, proxySharedPreferences, filesDir) + ) assertEquals(false, sharedPrefs.getBoolean(PreferenceKeys.SHOW_HIDDEN_FOLDERS, false)) assertEquals(true, sharedPrefs.getBoolean(PreferenceKeys.SHOW_HIDDEN_CONTENTS, false)) } @@ -128,11 +148,12 @@ class MigrationsTest { clear() putBoolean(PreferenceKeys.CLEAR_CLIPBOARD_20X, true) } - runMigrations(filesDir, sharedPrefs, GitSettings(sharedPrefs, encryptedSharedPreferences, proxySharedPreferences, filesDir)) - assertEquals( - true, - sharedPrefs.getBoolean(PreferenceKeys.CLEAR_CLIPBOARD_HISTORY, false) + runMigrations( + filesDir, + sharedPrefs, + GitSettings(sharedPrefs, encryptedSharedPreferences, proxySharedPreferences, filesDir) ) + assertEquals(true, sharedPrefs.getBoolean(PreferenceKeys.CLEAR_CLIPBOARD_HISTORY, false)) assertFalse(sharedPrefs.contains(PreferenceKeys.CLEAR_CLIPBOARD_20X)) } } |