Skip to content

Commit

Permalink
Merge pull request #3 from Optable/send-osdk-version
Browse files Browse the repository at this point in the history
Auto-send osdk SDK version query param to edge.
  • Loading branch information
bmilekic authored Sep 23, 2020
2 parents ee62e1d + 3f9f53b commit c3f6b97
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 8 deletions.
15 changes: 12 additions & 3 deletions DemoApp/DemoAppKotlin/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
plugins {
id("de.nanogiants.android-versioning") version "2.4.0"
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
Expand All @@ -10,8 +14,11 @@ android {
applicationId "co.optable.androidsdkdemo"
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"

versionCode versioning.getVersionCode()
versionName versioning.getVersionName(false)
archivesBaseName = "optable-android-sdk-demo-kotlin"

multiDexEnabled true

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand All @@ -23,10 +30,12 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = '1.8'
}
Expand All @@ -53,5 +62,5 @@ dependencies {
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

implementation 'com.google.android.gms:play-services-ads:19.3.0'
implementation 'com.github.Optable:optable-android-sdk:master-SNAPSHOT'
implementation "com.github.Optable:optable-android-sdk:" + versioning.getVersionName(false)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
10 changes: 8 additions & 2 deletions android_sdk/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
plugins {
id("de.nanogiants.android-versioning") version "2.4.0"
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
Expand All @@ -9,8 +13,10 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"

versionCode versioning.getVersionCode()
versionName versioning.getVersionName(false)
archivesBaseName = "optable-android-sdk"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
Expand Down
12 changes: 11 additions & 1 deletion android_sdk/src/main/java/co/optable/android_sdk/core/Client.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,17 @@ class Client(private val config: Config, private val context: Context) {

private class RequestInterceptor(private val userAgent: String, private val storage: LocalStorage): Interceptor {
override fun intercept(chain: Interceptor.Chain): Response {
var newRequest = chain.request().newBuilder().addHeader("User-Agent", userAgent)
var oldRequest = chain.request()
var newURL = oldRequest.url.newBuilder()
.addQueryParameter("osdk",
"android-" +
BuildConfig.VERSION_NAME + "-" +
BuildConfig.VERSION_CODE.toString()
).build()
var newRequest = oldRequest.newBuilder()
.url(newURL)
.addHeader("User-Agent", userAgent)

val pass = storage.getPassport()
if (pass != null) {
newRequest = newRequest.addHeader("X-Optable-Visitor", pass)
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip

0 comments on commit c3f6b97

Please sign in to comment.