app: replace getEncryptedProxyPrefs with injection
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
5e9a91a3b8
commit
7f7c0e7cb1
2 changed files with 3 additions and 6 deletions
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
package dev.msfjarvis.aps.ui.proxy
|
package dev.msfjarvis.aps.ui.proxy
|
||||||
|
|
||||||
|
import android.content.SharedPreferences
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
|
@ -16,9 +17,8 @@ import androidx.core.widget.doOnTextChanged
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import dev.msfjarvis.aps.R
|
import dev.msfjarvis.aps.R
|
||||||
import dev.msfjarvis.aps.databinding.ActivityProxySelectorBinding
|
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.getString
|
||||||
import dev.msfjarvis.aps.util.extensions.unsafeLazy
|
|
||||||
import dev.msfjarvis.aps.util.extensions.viewBinding
|
import dev.msfjarvis.aps.util.extensions.viewBinding
|
||||||
import dev.msfjarvis.aps.util.proxy.ProxyUtils
|
import dev.msfjarvis.aps.util.proxy.ProxyUtils
|
||||||
import dev.msfjarvis.aps.util.settings.GitSettings
|
import dev.msfjarvis.aps.util.settings.GitSettings
|
||||||
|
@ -32,10 +32,10 @@ private val WEB_ADDRESS_REGEX = Patterns.WEB_URL.toRegex()
|
||||||
class ProxySelectorActivity : AppCompatActivity() {
|
class ProxySelectorActivity : AppCompatActivity() {
|
||||||
|
|
||||||
@Inject lateinit var gitSettings: GitSettings
|
@Inject lateinit var gitSettings: GitSettings
|
||||||
|
@ProxyPreferences @Inject lateinit var proxyPrefs: SharedPreferences
|
||||||
@Inject lateinit var proxyUtils: ProxyUtils
|
@Inject lateinit var proxyUtils: ProxyUtils
|
||||||
|
|
||||||
private val binding by viewBinding(ActivityProxySelectorBinding::inflate)
|
private val binding by viewBinding(ActivityProxySelectorBinding::inflate)
|
||||||
private val proxyPrefs by unsafeLazy { applicationContext.getEncryptedProxyPrefs() }
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
|
@ -63,9 +63,6 @@ val Context.clipboard
|
||||||
/** Wrapper for [getEncryptedPrefs] to avoid open-coding the file name at each call site */
|
/** Wrapper for [getEncryptedPrefs] to avoid open-coding the file name at each call site */
|
||||||
fun Context.getEncryptedGitPrefs() = getEncryptedPrefs("git_operation")
|
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] */
|
/** Get an instance of [EncryptedSharedPreferences] with the given [fileName] */
|
||||||
private fun Context.getEncryptedPrefs(fileName: String): SharedPreferences {
|
private fun Context.getEncryptedPrefs(fileName: String): SharedPreferences {
|
||||||
val masterKeyAlias =
|
val masterKeyAlias =
|
||||||
|
|
Loading…
Reference in a new issue