Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3cf93c21 authored by Jonathan Klee's avatar Jonathan Klee
Browse files

Merge branch '3099-update-ua' into 'main'

Update UA dynamically

See merge request !556
parents 3d2536cd a3472100
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ stages:
before_script:
  - export GRADLE_USER_HOME=$(pwd)/.gradle
  - chmod +x ./gradlew
  - echo user_agent=$USER_AGENT > local.properties

cache:
  key: ${CI_PROJECT_ID}
+9 −0
Original line number Diff line number Diff line
@@ -111,6 +111,7 @@ android {

        buildConfigField "String", "BUILD_ID", "\"${getGitHash() + "." + getDate()}\""
        buildConfigField("String", "SENTRY_DSN", "\"${getSentryDsn()}\"")
        buildConfigField "String", "USER_AGENT", "\"${retrieveKey("user_agent", "Dalvik/2.1.0 (Linux; U; Android %s)")}\""

        def parentalControlPkgName = "foundation.e.parentalcontrol"

@@ -331,3 +332,11 @@ dependencies {
    // JSoup
    implementation(libs.jsoup)
}

def retrieveKey(String keyName, String defaultValue) {
    Properties properties = new Properties()
    properties.load(project.rootProject.file('local.properties').newDataInputStream())

    return properties.getProperty(keyName, defaultValue)
}
+4 −2
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@

package foundation.e.apps.di.network

import android.annotation.SuppressLint
import android.os.Build
import dagger.Module
import dagger.Provides
@@ -36,8 +37,9 @@ class InterceptorModule {
    companion object {
        private const val HEADER_USER_AGENT = "User-Agent"
        private const val HEADER_ACCEPT_LANGUAGE = "Accept-Language"
        val HEADER_USER_AGENT_VALUE =
            "Dalvik/2.1.0 (Linux; U; Android ${Build.VERSION.RELEASE};)"

        @SuppressLint("StringFormatTrivial")
        val HEADER_USER_AGENT_VALUE = String.format(BuildConfig.USER_AGENT, Build.VERSION.RELEASE)
    }

    @Singleton