Skip to content

Commit

Permalink
Updating the User-Agent string to a new format.
Browse files Browse the repository at this point in the history
Upping versionCode to 78
  • Loading branch information
Dima-Android committed Jun 20, 2024
1 parent 5510710 commit 99bf4c5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
package org.zotero.android.api

import android.os.Build
import okhttp3.Interceptor
import okhttp3.Interceptor.Chain
import okhttp3.Response
import org.zotero.android.architecture.logging.DeviceInfoProvider
import org.zotero.android.sync.SchemaController
import javax.inject.Inject

class ClientInfoNetworkInterceptor @Inject constructor(
private val schemaController: SchemaController
) : Interceptor {
private val userAgentString =
"zotero" +
"android/${Build.VERSION.SDK_INT} " +
"(${Build.MANUFACTURER} ${Build.DEVICE})"

override fun intercept(chain: Chain): Response {
val request = chain.request()
val clientInfoRequest = request.newBuilder()
.header("X-Zotero-Client", "Android")
.header("User-Agent", userAgentString)
.header("User-Agent", DeviceInfoProvider.userAgentString)
.header("Zotero-API-Version", 3.toString())
.header("Zotero-Schema-Version", schemaController.version.toString())
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,7 @@ object DeviceInfoProvider {
return "Android "+ Build.VERSION.SDK_INT
}

val userAgentString: String get() {
return "Zotero/${BuildConfig.VERSION_NAME} (Android ${Build.VERSION.SDK_INT})"
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.zotero.android.screens.share.backgroundprocessor

import android.content.Context
import android.os.Build
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.cancel
import kotlinx.coroutines.launch
Expand All @@ -14,6 +13,7 @@ import org.zotero.android.api.NoAuthenticationApi
import org.zotero.android.api.SyncApi
import org.zotero.android.api.network.CustomResult
import org.zotero.android.api.network.safeApiCall
import org.zotero.android.architecture.logging.DeviceInfoProvider
import org.zotero.android.backgrounduploader.BackgroundUpload
import org.zotero.android.database.DbWrapper
import org.zotero.android.database.requests.MarkAttachmentUploadedDbRequest
Expand Down Expand Up @@ -149,9 +149,7 @@ class BackgroundUploadProcessor @Inject constructor(
// headersWithExtra["Content-Type"] = contentType
headersWithExtra["Zotero-API-Version"] = 3.toString()
headersWithExtra["Zotero-Schema-Version"] = schemaController.version.toString()
headersWithExtra["User-Agent"] = "zotero" +
"android/${Build.VERSION.SDK_INT} " +
"(${Build.MANUFACTURER} ${Build.DEVICE})"
headersWithExtra["User-Agent"] = DeviceInfoProvider.userAgentString
return headersWithExtra

}
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/BuildConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ object BuildConfig {
const val compileSdkVersion = 34
const val targetSdk = 33

val versionCode = 77 // Must be updated on every build
val versionCode = 78 // Must be updated on every build
val version = Version(
major = 1,
minor = 0,
Expand Down

0 comments on commit 99bf4c5

Please sign in to comment.