diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/core/di/modules/TestNetworkModule.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/core/di/modules/TestNetworkModule.kt index ba0281c1f..d1640df1e 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/core/di/modules/TestNetworkModule.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/core/di/modules/TestNetworkModule.kt @@ -28,7 +28,7 @@ import org.kiwix.sharedFunctions.MOCK_BASE_URL @Module(includes = [NetworkModule::class]) class TestNetworkModule { - fun provideKiwixService(okHttpClient: OkHttpClient?): KiwixService = + fun provideKiwixService(okHttpClient: OkHttpClient): KiwixService = KiwixService.ServiceCreator.newHacklistService( okHttpClient, MOCK_BASE_URL diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/di/modules/NetworkModule.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/di/modules/NetworkModule.kt index 073c78285..606419215 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/di/modules/NetworkModule.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/di/modules/NetworkModule.kt @@ -32,6 +32,11 @@ import org.kiwix.kiwixmobile.core.data.remote.UserAgentInterceptor import java.util.concurrent.TimeUnit.SECONDS import javax.inject.Singleton +private const val CONNECTION_TIMEOUT = 10L +private const val READ_TIMEOUT = 60L +private const val USER_AGENT = "kiwix-android-version:${BuildConfig.VERSION_CODE}" +private const val KIWIX_DOWNLOAD_URL = "http://mirror.download.kiwix.org/" + @Module class NetworkModule { @Provides @Singleton fun provideOkHttpClient(): OkHttpClient { @@ -41,20 +46,13 @@ class NetworkModule { .addNetworkInterceptor(HttpLoggingInterceptor().apply { level = if (BuildConfig.DEBUG) BASIC else NONE }) - .addNetworkInterceptor(UserAgentInterceptor(userAgent)) + .addNetworkInterceptor(UserAgentInterceptor(USER_AGENT)) .build() } - @Provides @Singleton fun provideKiwixService(okHttpClient: OkHttpClient?): KiwixService = + @Provides @Singleton fun provideKiwixService(okHttpClient: OkHttpClient): KiwixService = ServiceCreator.newHacklistService(okHttpClient, KIWIX_DOWNLOAD_URL) @Provides @Singleton fun provideConnectivityManager(context: Context): ConnectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager - - companion object { - private const val CONNECTION_TIMEOUT = 10L - private const val READ_TIMEOUT = 60L - private const val userAgent = "kiwix-android-version:${BuildConfig.VERSION_CODE}" - private const val KIWIX_DOWNLOAD_URL = "http://mirror.download.kiwix.org/" - } }