From 7f7c0e7cb1c63ea62d8385a3df2373a52aa0eb8f Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Sun, 30 May 2021 11:28:46 +0530 Subject: app: replace getEncryptedProxyPrefs with injection Signed-off-by: Harsh Shandilya --- .../main/java/dev/msfjarvis/aps/ui/proxy/ProxySelectorActivity.kt | 6 +++--- .../java/dev/msfjarvis/aps/util/extensions/AndroidExtensions.kt | 3 --- 2 files changed, 3 insertions(+), 6 deletions(-) (limited to 'app') 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 90aea7ae..b69267cf 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 @@ -5,6 +5,7 @@ package dev.msfjarvis.aps.ui.proxy +import android.content.SharedPreferences import android.os.Bundle import android.os.Handler import android.os.Looper @@ -16,9 +17,8 @@ import androidx.core.widget.doOnTextChanged import dagger.hilt.android.AndroidEntryPoint import dev.msfjarvis.aps.R import dev.msfjarvis.aps.databinding.ActivityProxySelectorBinding -import dev.msfjarvis.aps.util.extensions.getEncryptedProxyPrefs +import dev.msfjarvis.aps.injection.prefs.ProxyPreferences import dev.msfjarvis.aps.util.extensions.getString -import dev.msfjarvis.aps.util.extensions.unsafeLazy import dev.msfjarvis.aps.util.extensions.viewBinding import dev.msfjarvis.aps.util.proxy.ProxyUtils import dev.msfjarvis.aps.util.settings.GitSettings @@ -32,10 +32,10 @@ private val WEB_ADDRESS_REGEX = Patterns.WEB_URL.toRegex() class ProxySelectorActivity : AppCompatActivity() { @Inject lateinit var gitSettings: GitSettings + @ProxyPreferences @Inject lateinit var proxyPrefs: SharedPreferences @Inject lateinit var proxyUtils: ProxyUtils private val binding by viewBinding(ActivityProxySelectorBinding::inflate) - private val proxyPrefs by unsafeLazy { applicationContext.getEncryptedProxyPrefs() } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) diff --git a/app/src/main/java/dev/msfjarvis/aps/util/extensions/AndroidExtensions.kt b/app/src/main/java/dev/msfjarvis/aps/util/extensions/AndroidExtensions.kt index 29554127..ae175433 100644 --- a/app/src/main/java/dev/msfjarvis/aps/util/extensions/AndroidExtensions.kt +++ b/app/src/main/java/dev/msfjarvis/aps/util/extensions/AndroidExtensions.kt @@ -63,9 +63,6 @@ val Context.clipboard /** Wrapper for [getEncryptedPrefs] to avoid open-coding the file name at each call site */ fun Context.getEncryptedGitPrefs() = getEncryptedPrefs("git_operation") -/** Wrapper for [getEncryptedPrefs] to get the encrypted preference set for the HTTP proxy. */ -fun Context.getEncryptedProxyPrefs() = getEncryptedPrefs("http_proxy") - /** Get an instance of [EncryptedSharedPreferences] with the given [fileName] */ private fun Context.getEncryptedPrefs(fileName: String): SharedPreferences { val masterKeyAlias = -- cgit v1.2.3