From 09024fbc616c82a68939c90480c403b7b0ba5756 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Tue, 1 Apr 2025 18:50:08 -0400 Subject: [PATCH] Performance: Avoids creating OkHttp proxies directly on the OnCreate --- amethyst/src/main/java/com/vitorpamplona/amethyst/Amethyst.kt | 3 --- .../vitorpamplona/amethyst/service/okhttp/HttpClientManager.kt | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/Amethyst.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/Amethyst.kt index 6ba9f86e7..ca1385522 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/Amethyst.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/Amethyst.kt @@ -39,7 +39,6 @@ import coil3.disk.DiskCache import coil3.memory.MemoryCache import com.vitorpamplona.amethyst.service.location.LocationState import com.vitorpamplona.amethyst.service.notifications.PokeyReceiver -import com.vitorpamplona.amethyst.service.okhttp.HttpClientManager import com.vitorpamplona.amethyst.service.okhttp.OkHttpWebSocket import com.vitorpamplona.amethyst.service.playback.diskCache.VideoCache import com.vitorpamplona.amethyst.ui.MainActivity @@ -109,8 +108,6 @@ class Amethyst : Application() { instance = this - HttpClientManager.setDefaultUserAgent("Amethyst/${BuildConfig.VERSION_NAME}") - if (BuildConfig.DEBUG || BuildConfig.BUILD_TYPE == "benchmark") { StrictMode.setThreadPolicy( ThreadPolicy diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/okhttp/HttpClientManager.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/okhttp/HttpClientManager.kt index 2cb3ee404..9be9f002f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/okhttp/HttpClientManager.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/okhttp/HttpClientManager.kt @@ -22,6 +22,7 @@ package com.vitorpamplona.amethyst.service.okhttp import android.R.attr.port import android.util.Log +import com.vitorpamplona.amethyst.BuildConfig import com.vitorpamplona.quartz.nip17Dm.files.encryption.NostrCipher import okhttp3.OkHttpClient import java.net.InetSocketAddress @@ -44,7 +45,7 @@ object HttpClientManager { private var defaultTimeout = DEFAULT_TIMEOUT_ON_WIFI private var defaultHttpClient: OkHttpClient? = null private var defaultHttpClientWithoutProxy: OkHttpClient? = null - private var userAgent: String = "Amethyst" + private var userAgent: String = "Amethyst/${BuildConfig.VERSION_NAME}" private var currentProxy: Proxy? = DEFAULT_TOR_PROXY