Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ class MvtPerformanceTest {

// Test the capital of Cameroon because it's dense
println("Test Yaoundé")
for(x in 17430 until 17437) {
for(y in 16029 until 16034) {
for(x in 17430/2 until 17437/2) {
for(y in 16029/2 until 16034/2) {
downloadAndParseTile(x, y, gridState)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class ManifestClient(val applicationContext: Context) {
private var retrofit : Retrofit? = null

private val okHttpClient = OkHttpClient.Builder()
.addInterceptor(UserAgentInterceptor())
.addInterceptor { chain ->
val response = chain.proceed(chain.request())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ interface PhotonSearchProvider {
}
}
private val logging = OkHttpClient.Builder()
.addInterceptor(UserAgentInterceptor())
.addInterceptor(loggingInterceptor)
.callTimeout(5, TimeUnit.SECONDS)
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ abstract class TileClient(val applicationContext: Context) {

protected val okHttpClient = OkHttpClient.Builder()
.cache(myCache)
.addInterceptor(UserAgentInterceptor())
.addInterceptor { chain ->

// Get the request from the chain.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.scottishtecharmy.soundscape.network

import okhttp3.Interceptor
import okhttp3.Response
import org.scottishtecharmy.soundscape.BuildConfig

class UserAgentInterceptor : Interceptor {
override fun intercept(chain: Interceptor.Chain): Response {
val request = chain.request().newBuilder()
.header("User-Agent", USER_AGENT)
.build()
return chain.proceed(request)
}

companion object {
val USER_AGENT: String = buildString {
append("Soundscape/${BuildConfig.VERSION_NAME}")
if (BuildConfig.BUILD_TYPE == "releaseTest") {
append(" (unit tests)")
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import okhttp3.OkHttpClient
import org.scottishtecharmy.soundscape.network.UserAgentInterceptor
import okhttp3.ResponseBody
import org.scottishtecharmy.soundscape.geojsonparser.geojson.FeatureCollection
import org.scottishtecharmy.soundscape.network.IDownloadService
Expand Down Expand Up @@ -82,6 +83,7 @@ class OfflineDownloader {
init {
// We want a long timeout here to allow for network caching to happen behind the scenes
val okHttpClient = OkHttpClient.Builder()
.addInterceptor(UserAgentInterceptor())
.connectTimeout(3, TimeUnit.MINUTES)
.readTimeout(3, TimeUnit.MINUTES)
.build()
Expand Down