Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #153 from tiki/release/2.1.4
Browse files Browse the repository at this point in the history
Release/2.1.4
  • Loading branch information
ricardobrg authored Apr 21, 2023
2 parents 90812fb + be5fba8 commit 47b4d6e
Show file tree
Hide file tree
Showing 15 changed files with 237 additions and 28 deletions.
32 changes: 20 additions & 12 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
buildscript {
ext.flutterEngine = "1.0.0-1837b5be5f0f1376a1ccf383950e83a80177fb4e"
ext.sdkVersion = "2.1.4"
ext.sdkVersion = "1.0.7"
ext.markwon_version = "4.6.2"
repositories {
mavenCentral()
Expand All @@ -22,8 +22,8 @@ android {
compileSdk 33
defaultConfig {
minSdk 21
versionCode 8
versionName "2.1.3"
versionCode 9
versionName "2.1.4"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down Expand Up @@ -66,7 +66,7 @@ dependencies {

implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.core:core-ktx:1.10.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.8.0'

Expand All @@ -82,22 +82,29 @@ dependencies {
debugEmbed "io.flutter:flutter_embedding_release:$flutterEngine"
releaseEmbed "io.flutter:flutter_embedding_release:$flutterEngine"

debugEmbed "com.mytiki.tiki_sdk_flutter:flutter_release:$sdkVersion"
releaseEmbed "com.mytiki.tiki_sdk_flutter:flutter_release:$sdkVersion"

debugEmbed "io.flutter.plugins.pathprovider:path_provider_android_release:$sdkVersion"
releaseEmbed "io.flutter.plugins.pathprovider:path_provider_android_release:$sdkVersion"
debugEmbed "com.mytiki.tiki_sdk_platform_channel:flutter_release:$sdkVersion"
releaseEmbed "com.mytiki.tiki_sdk_platform_channel:flutter_release:$sdkVersion"

debugEmbed "com.it_nomads.fluttersecurestorage:flutter_secure_storage_release:$sdkVersion"
releaseEmbed "com.it_nomads.fluttersecurestorage:flutter_secure_storage_release:$sdkVersion"

debugEmbed "eu.simonbinder.sqlite3_flutter_libs:sqlite3_flutter_libs_release:$sdkVersion"
releaseEmbed "eu.simonbinder.sqlite3_flutter_libs:sqlite3_flutter_libs_release:$sdkVersion"
}

apply plugin: "org.jetbrains.dokka"
tasks.dokkaHtml.configure {
outputDirectory.set(file("../doc/api"))
dokkaSourceSets {
configureEach {
perPackageOption {
matchingRegex.set(".*core.*")
suppress.set(true)
}

perPackageOption {
matchingRegex.set(".*activities.*")
suppress.set(true)
}
}
}
}

def groovyShell = new GroovyShell()
Expand All @@ -111,6 +118,7 @@ apply plugin: 'maven-publish'
apply plugin: 'signing'

signing {
required { gradle.taskGraph.hasTask("publish") }
def signingKey = System.getenv("PGP_PRIVATE_KEY")
def signingPassword = System.getenv("PGP_PASSPHRASE")
useInMemoryPgpKeys(signingKey, signingPassword)
Expand Down
21 changes: 18 additions & 3 deletions app/src/main/kotlin/com/mytiki/tiki_sdk_android/TikiSdk.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package com.mytiki.tiki_sdk_android
import android.content.Context
import android.content.Intent
import android.content.res.Configuration
import android.os.Bundle
import android.util.Log
import androidx.core.content.ContextCompat.startActivity
import com.mytiki.tiki_sdk_android.TikiSdk.init
Expand Down Expand Up @@ -233,6 +234,7 @@ object TikiSdk {
context: Context,
publishingId: String,
id: String,
dbDir: String? = null,
origin: String? = null,
onComplete: (() -> Unit)?
): Deferred<Unit> {
Expand All @@ -241,7 +243,12 @@ object TikiSdk {
this@TikiSdk.coreChannel = coreChannel
val rspInitJson = coreChannel.invokeMethod(
CoreMethod.BUILD,
ReqInit(publishingId, id, origin ?: context.packageName).toJson()
ReqInit(
publishingId,
id,
dbDir ?: context.applicationInfo.dataDir,
origin ?: context.packageName
).toJson()
).await()
val rspInit = RspInit.fromJson(rspInitJson)
this@TikiSdk.address = rspInit.address
Expand Down Expand Up @@ -277,7 +284,11 @@ object TikiSdk {
guard(ptr, usecases, destinations, {
Log.d("TIKI SDK", "Offer already accepted. PTR: $ptr")
}, {
startActivity(context, Intent(context, OfferFlowActivity::class.java), null)
val bundle = Bundle()
val intent = Intent(context, OfferFlowActivity::class.java)
bundle.putSerializable("theme", theme(context))
intent.putExtras(bundle);
startActivity(context, intent, null)
})
}
}
Expand All @@ -292,7 +303,11 @@ object TikiSdk {
fun settings(context: Context) {
throwIfNotInitialized()
throwIfNoOffers()
startActivity(context, Intent(context, SettingsActivity::class.java), null)
val bundle = Bundle()
val intent = Intent(context, SettingsActivity::class.java)
bundle.putSerializable("theme", theme(context))
intent.putExtras(bundle);
startActivity(context, intent, null)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ import org.json.JSONObject
data class ReqInit(
val publishingId: String,
val id: String,
val dbDir: String,
val origin: String,
) {
fun toJson(): String {
val jsonObject = JSONObject()
jsonObject.put("publishingId", publishingId)
jsonObject.put("id", id)
jsonObject.put("origin", origin)
jsonObject.put("dbDir", dbDir)
return jsonObject.toString()
}
}
3 changes: 2 additions & 1 deletion app/src/main/kotlin/com/mytiki/tiki_sdk_android/ui/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import android.graphics.Color
import androidx.annotation.ColorInt
import com.mytiki.tiki_sdk_android.R
import com.mytiki.tiki_sdk_android.TikiSdk
import java.io.Serializable

/**
* Controls the UI theming for TikiSdk.
*/
class Theme {
class Theme : Serializable {

/**
* Primary text color. Used in default text items.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
package com.mytiki.tiki_sdk_android.ui.activities

import android.graphics.drawable.GradientDrawable
import android.os.Build
import android.os.Bundle
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import com.mytiki.tiki_sdk_android.R
import com.mytiki.tiki_sdk_android.TikiSdk
import com.mytiki.tiki_sdk_android.ui.Theme
import io.noties.markwon.Markwon
import io.noties.markwon.ext.tables.TablePlugin

class LearnMoreActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

val theme = TikiSdk.theme(this)
val theme = if (Build.VERSION.SDK_INT >= 33) {
savedInstanceState!!.getSerializable("theme", Theme::class.java)!!
} else {
savedInstanceState!!.getSerializable("theme") as Theme
}
setContentView(R.layout.learn_more)

val solidBg = GradientDrawable()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.content.pm.PackageManager
import android.graphics.Color
import android.graphics.drawable.GradientDrawable
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS
import android.widget.*
Expand Down Expand Up @@ -51,7 +52,11 @@ class OfferFlowActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
theme = TikiSdk.theme(this)
theme = if (Build.VERSION.SDK_INT >= 33) {
savedInstanceState!!.getSerializable("theme", Theme::class.java)!!
} else {
savedInstanceState!!.getSerializable("theme") as Theme
}
setContentView(R.layout.activity_offer_flow)
initializeBottomSheets()
showOfferPrompt()
Expand Down Expand Up @@ -316,17 +321,26 @@ class OfferFlowActivity : AppCompatActivity() {

private fun showLearnMore() {
val intent = Intent(this, LearnMoreActivity::class.java)
val bundle = Bundle()
bundle.putSerializable("theme", theme)
intent.putExtras(bundle)
startActivity(intent)
}

private fun showTerms() {
val intent = Intent(this, TermsActivity::class.java)
val bundle = Bundle()
bundle.putSerializable("theme", theme)
intent.putExtras(bundle)
termsResult.launch(intent)
}

private fun enableSettingsLink(v: BottomSheetDialog) {
v.findViewById<TextView>(R.id.settings_link)!!.setOnClickListener {
val intent = Intent(this, SettingsActivity::class.java)
val bundle = Bundle()
bundle.putSerializable("theme", theme)
intent.putExtras(bundle)
finish()
startActivity(intent)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.mytiki.tiki_sdk_android.ui.activities
import android.content.Intent
import android.content.pm.PackageManager
import android.graphics.drawable.GradientDrawable
import android.os.Build
import android.os.Bundle
import android.widget.*
import androidx.appcompat.app.AppCompatActivity
Expand Down Expand Up @@ -30,7 +31,11 @@ class SettingsActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.settings)
theme = TikiSdk.theme(this)
theme = if (Build.VERSION.SDK_INT >= 33) {
savedInstanceState!!.getSerializable("theme", Theme::class.java)!!
} else {
savedInstanceState!!.getSerializable("theme") as Theme
}
offer = TikiSdk.offers.values.first()
tikiSdkBtn = findViewById(R.id.tiki_sdk_btn)
setupTradeYourDataTitle()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.mytiki.tiki_sdk_android.ui.activities

import android.content.Intent
import android.graphics.drawable.GradientDrawable
import android.os.Build
import android.os.Bundle
import android.widget.ImageView
import android.widget.RelativeLayout
Expand All @@ -20,7 +21,11 @@ class TermsActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
theme = TikiSdk.theme(this)
theme = if (Build.VERSION.SDK_INT >= 33) {
savedInstanceState!!.getSerializable("theme", Theme::class.java)!!
} else {
savedInstanceState!!.getSerializable("theme") as Theme
}
setContentView(R.layout.terms)

val markwon = Markwon.builder(this)
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ plugins {
id 'com.android.library' version '7.2.2' apply false
id 'org.jetbrains.kotlin.android' version '1.8.10' apply false
id 'maven-publish'
id 'org.jetbrains.dokka' version "1.7.20"
id 'org.jetbrains.dokka' version "1.8.10"
id 'groovy'
}
4 changes: 2 additions & 2 deletions example_app/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ android {
}

dependencies {
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.core:core-ktx:1.10.0'
implementation 'androidx.appcompat:appcompat:1.6.1'

implementation 'com.mytiki:tiki-sdk-android:2.1.0'
implementation 'com.mytiki:tiki-sdk-android:2.1.4'
}
4 changes: 4 additions & 0 deletions example_app/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ pluginManagement {
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
maven{
"local"
url = "../app/build/repo"
}
google()
mavenCentral()
}
Expand Down
2 changes: 2 additions & 0 deletions integration_tests/integration_tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4"
implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.0"))
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.8.0'

testImplementation 'junit:junit:4.13.2'
androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4"
androidTestImplementation 'androidx.test.ext:junit:1.1.4'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class IntegrationTests {
TikiSdk.offer
.id("test_offer")
.ptr("test_offer")
.reward("offerImage")
//.reward("offerImage")
.bullet("Learn how our ads perform ", true)
.bullet("Reach you on other platforms", false)
.bullet("Sold to other companies", false)
Expand All @@ -63,7 +63,7 @@ class IntegrationTests {
.tag(TitleTag.ADVERTISING_DATA)
.description("Trade your IDFA (kind of like a serial # for your phone) for a discount.")
.terms(context, "terms.md")
.duration(365 * 24 * 60 * 60)
.duration(365 * 24 * 60 * 60, TimeUnit.SECONDS)
.add()
.onAccept { _, _ -> print("accepted") }
.onDecline { _, _ -> print("declined") }
Expand Down
Loading

0 comments on commit 47b4d6e

Please sign in to comment.