Skip to content

Commit 32a72a6

Browse files
committed
feat: Integrate Example App
1 parent 91af29a commit 32a72a6

File tree

11 files changed

+180
-36
lines changed

11 files changed

+180
-36
lines changed

build.gradle

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,24 @@ repositories {
6161

6262
dependencies {
6363
implementation 'androidx.annotation:annotation:1.5.0'
64-
api 'com.rokt:roktsdk:4.8.1'
64+
api 'com.rokt:roktsdk:4.9.0'
6565

6666
testImplementation files('libs/java-json.jar')
6767
testImplementation 'com.squareup.assertj:assertj-android:1.2.0'
6868
testImplementation ("io.mockk:mockk:1.13.4")
6969
}
70+
71+
allprojects {
72+
group = 'com.mparticle'
73+
repositories {
74+
mavenLocal()
75+
google()
76+
mavenCentral()
77+
}
78+
79+
tasks.withType(Javadoc) {
80+
options.addStringOption('Xdoclint:none', '-quiet')
81+
}
82+
83+
apply plugin: 'org.jlleitschuh.gradle.ktlint'
84+
}

example/.gitignore

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,33 @@
1-
/build
1+
# Built application files
2+
*.apk
3+
*.ap_
4+
5+
# Files for the ART/Dalvik VM
6+
*.dex
7+
8+
# Java class files
9+
*.class
10+
11+
# Generated files
12+
bin/
13+
gen/
14+
out/
15+
16+
# Gradle files
17+
.gradle/
18+
build/
19+
20+
# Local configuration file (sdk path, etc)
21+
local.properties
22+
23+
24+
# IntelliJ
25+
*.iml
26+
.idea/workspace.xml
27+
.idea/tasks.xml
28+
.idea/gradle.xml
29+
.idea/assetWizardSettings.xml
30+
.idea/dictionaries
31+
.idea/libraries
32+
.idea/caches
33+
.idea/

example/build.gradle

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55

66
android {
77
namespace 'com.mparticle.rokt.example'
8-
compileSdk 33
8+
compileSdk 34
99

1010
defaultConfig {
1111
applicationId "com.mparticle.rokt.example"
@@ -34,10 +34,23 @@ android {
3434

3535
dependencies {
3636

37-
implementation 'androidx.core:core-ktx:1.16.0'
38-
implementation 'androidx.appcompat:appcompat:1.7.0'
37+
implementation 'androidx.core:core-ktx:1.13.0'
38+
implementation 'androidx.appcompat:appcompat:1.6.0'
39+
implementation project(":")
3940
implementation 'com.google.android.material:material:1.12.0'
41+
implementation 'androidx.activity:activity:1.6.0'
42+
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
4043
testImplementation 'junit:junit:4.13.2'
4144
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
4245
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
46+
}
47+
48+
configurations.all {
49+
resolutionStrategy {
50+
eachDependency {
51+
if (requested.group == "androidx.lifecycle" && requested.name == "lifecycle-livedata-core") {
52+
useVersion("2.5.1")
53+
}
54+
}
55+
}
4356
}

example/src/androidTest/java/com/mparticle/rokt/example/ExampleInstrumentedTest.kt

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3-
3+
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
44
<application
55
android:allowBackup="true"
66
android:icon="@mipmap/ic_launcher"
77
android:label="@string/app_name"
88
android:roundIcon="@mipmap/ic_launcher_round"
9+
android:networkSecurityConfig="@xml/network_security_config"
10+
android:name=".MainApplication"
911
android:supportsRtl="true"
10-
android:theme="@style/Theme.Androidroktkit" />
12+
android:theme="@style/Theme.Androidroktkit">
13+
<activity
14+
android:name=".MainActivity"
15+
android:exported="true"
16+
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar">
17+
<intent-filter>
18+
<action android:name="android.intent.action.MAIN" />
19+
<category android:name="android.intent.category.LAUNCHER" />
20+
</intent-filter>
21+
</activity>
22+
</application>
1123

1224
</manifest>
Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,46 @@
11
package com.mparticle.rokt.example
22

33
import android.os.Bundle
4+
import android.util.Log
5+
import android.widget.Button
46
import androidx.activity.enableEdgeToEdge
57
import androidx.appcompat.app.AppCompatActivity
68
import androidx.core.view.ViewCompat
79
import androidx.core.view.WindowInsetsCompat
10+
import java.lang.ref.WeakReference
811

912
class MainActivity : AppCompatActivity() {
1013
override fun onCreate(savedInstanceState: Bundle?) {
1114
super.onCreate(savedInstanceState)
1215
enableEdgeToEdge()
1316
setContentView(R.layout.activity_main)
17+
val attributes = mapOf(
18+
Pair("lastname", "Smith"),
19+
Pair("mobile", "1112223333"),
20+
Pair("country", "USA"),
21+
Pair("noFunctional", "true"),
22+
Pair("email", "testEmail_${System.currentTimeMillis()}@example.com"),
23+
Pair("sandbox", "true")
24+
)
1425
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
1526
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
1627
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
1728
insets
1829
}
30+
val roktKit = (this.application as MainApplication).kit
31+
findViewById<Button>(R.id.executeButton).setOnClickListener {
32+
Log.d("ExampleActivity", "Button clicked")
33+
roktKit.execute(
34+
"mauitest",
35+
attributes,
36+
Runnable { },
37+
Runnable { },
38+
Runnable { },
39+
Runnable { },
40+
mutableMapOf("Location1" to WeakReference(findViewById(R.id.roktEmbeddedView))),
41+
null,
42+
null
43+
)
44+
}
1945
}
20-
}
46+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,14 @@
11
package com.mparticle.rokt.example
22

3+
import android.app.Application
4+
import com.mparticle.kits.RoktKit
5+
6+
class MainApplication : Application() {
7+
val kit = RoktKit()
8+
override fun onCreate() {
9+
super.onCreate()
10+
// Initialize any libraries or SDKs here
11+
val settings = mapOf("accountId" to "2754655826098840951")
12+
kit.onKitCreate(settings, this)
13+
}
14+
}

example/src/main/res/layout/activity_main.xml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,52 @@
77
android:layout_height="match_parent"
88
tools:context=".MainActivity">
99

10+
<ImageView
11+
android:id="@+id/logoImage"
12+
android:layout_width="wrap_content"
13+
android:layout_height="wrap_content"
14+
android:layout_marginTop="64dp"
15+
android:src="@drawable/ic_rokt_logo"
16+
app:layout_constraintEnd_toEndOf="parent"
17+
app:layout_constraintStart_toStartOf="parent"
18+
app:layout_constraintTop_toTopOf="parent" />
19+
20+
<TextView
21+
android:id="@+id/textView"
22+
android:layout_width="wrap_content"
23+
android:layout_height="wrap_content"
24+
android:layout_marginStart="16dp"
25+
android:layout_marginTop="64dp"
26+
android:layout_marginEnd="16dp"
27+
app:flow_horizontalAlign="center"
28+
android:text="Seize the Transaction Moment"
29+
android:textSize="24sp"
30+
android:textStyle="bold"
31+
app:layout_constraintEnd_toEndOf="parent"
32+
app:layout_constraintStart_toStartOf="parent"
33+
app:layout_constraintTop_toBottomOf="@+id/logoImage" />
34+
35+
<com.mparticle.rokt.RoktEmbeddedView
36+
android:id="@+id/roktEmbeddedView"
37+
android:layout_width="wrap_content"
38+
android:layout_height="wrap_content"
39+
android:layout_marginStart="16dp"
40+
android:layout_marginTop="64dp"
41+
android:layout_marginEnd="16dp"
42+
app:layout_constraintEnd_toEndOf="parent"
43+
app:layout_constraintStart_toStartOf="parent"
44+
app:layout_constraintTop_toBottomOf="@+id/textView" />
45+
46+
<Button
47+
android:id="@+id/executeButton"
48+
android:layout_width="wrap_content"
49+
android:layout_height="wrap_content"
50+
android:paddingStart="32dp"
51+
android:paddingEnd="32dp"
52+
android:text="Show"
53+
app:layout_constraintBottom_toBottomOf="parent"
54+
app:layout_constraintEnd_toEndOf="parent"
55+
app:layout_constraintStart_toStartOf="parent"
56+
app:layout_constraintTop_toBottomOf="@+id/roktEmbeddedView" />
57+
1058
</androidx.constraintlayout.widget.ConstraintLayout>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<network-security-config>
3+
<base-config cleartextTrafficPermitted="true">
4+
<trust-anchors>
5+
<!-- Trust user added CAs in the Example app -->
6+
<certificates src="user" />
7+
<certificates src="system" />
8+
</trust-anchors>
9+
</base-config>
10+
</network-security-config>
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
package com.mparticle.rokt.example
22

3+
import org.junit.Assert.assertEquals
34
import org.junit.Test
45

5-
import org.junit.Assert.*
6-
76
/**
87
* Example local unit test, which will execute on the development machine (host).
98
*
@@ -14,4 +13,4 @@ class ExampleUnitTest {
1413
fun addition_isCorrect() {
1514
assertEquals(4, 2 + 2)
1615
}
17-
}
16+
}

0 commit comments

Comments
 (0)