Skip to content

Commit 7ef1b56

Browse files
authored
Add manual initialization Reaper example (#200)
1 parent b7e3b74 commit 7ef1b56

33 files changed

+419
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Manually initializing Reaper
2+
3+
By default Reaper is initialized automatically as shown in the
4+
`reaper/sample/app` example. However if finer control over
5+
initialization is required then Reaper can be manually initialized
6+
instead. This is demonstrated in this sample app.
7+
8+
Two changes are required compared to `reaper/sample/app`.
9+
1. Update [AndroidManifest.xml](./src/main/AndroidManifest.xml) to remove
10+
`com.emergetools.reaper.ReaperInitializer` from `androidx.startup.InitializationProvider`.
11+
2. Update [MainActivity.kt](./src/main/kotlin/com/emergetools/reaper/sample/manuallyInitialized/MainActivity.kt) to call `Reaper.init(context)`.
12+
13+
For more detail see
14+
[Disable automatic initialization](https://docs.emergetools.com/docs/reaper-setup-android#disable-automatic-initialization)
15+
and
16+
[Manual initialization](https://docs.emergetools.com/docs/reaper-setup-android#manual-initialization).
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
plugins {
2+
alias(libs.plugins.android.application)
3+
alias(libs.plugins.kotlin.android)
4+
alias(libs.plugins.kotlin.serialization)
5+
alias(libs.plugins.buildconfig)
6+
id("com.emergetools.android")
7+
}
8+
9+
emerge {
10+
apiToken.set(System.getenv("EMERGE_API_TOKEN"))
11+
12+
vcs {
13+
gitHub {
14+
repoName.set("emerge-android")
15+
repoOwner.set("EmergeTools")
16+
}
17+
}
18+
19+
reaper {
20+
enabled.set(true)
21+
publishableApiKey.set(System.getenv("EMERGE_REAPER_API_KEY")?:"<key>")
22+
}
23+
}
24+
25+
android {
26+
namespace = "com.emergetools.reaper.sample.manuallyInitialized"
27+
compileSdk = 34
28+
29+
defaultConfig {
30+
applicationId = "com.emergetools.reaper.sample.manuallyInitialized"
31+
minSdk = 21
32+
targetSdk = 33
33+
versionCode = 1
34+
versionName = "1.0"
35+
36+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
37+
vectorDrawables {
38+
useSupportLibrary = true
39+
}
40+
}
41+
42+
buildTypes {
43+
release {
44+
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
45+
isMinifyEnabled = true
46+
}
47+
debug {
48+
applicationIdSuffix = ".debug"
49+
}
50+
}
51+
52+
compileOptions {
53+
sourceCompatibility = JavaVersion.VERSION_17
54+
targetCompatibility = JavaVersion.VERSION_17
55+
}
56+
57+
kotlinOptions {
58+
jvmTarget = JavaVersion.VERSION_17.toString()
59+
}
60+
61+
buildFeatures {
62+
compose = true
63+
}
64+
65+
composeOptions {
66+
kotlinCompilerExtensionVersion = libs.versions.compose.compiler.extension.get()
67+
}
68+
}
69+
70+
buildConfig {
71+
className("ReaperConfig")
72+
packageName("com.emergetools.reaper.sample.manuallyInitialized")
73+
}
74+
75+
dependencies {
76+
implementation(libs.androidx.activity)
77+
implementation(libs.androidx.activity.compose)
78+
implementation(libs.androidx.navigation.compose)
79+
implementation(libs.androidx.navigation.ui.ktx)
80+
implementation(libs.kotlinx.serialization)
81+
82+
implementation(platform(libs.compose.bom))
83+
implementation(libs.compose.ui)
84+
implementation(libs.compose.ui.tooling)
85+
implementation(libs.compose.ui.tooling.preview)
86+
implementation(libs.compose.material)
87+
implementation(libs.androidx.test.core.ktx)
88+
89+
// Reaper SDK
90+
implementation(libs.androidx.startup.runtime)
91+
implementation(projects.reaper.reaper)
92+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#-keep class com.emergetools.reaper.Reaper
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools">
4+
5+
<application
6+
android:name="android.app.Application"
7+
android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name"
9+
android:roundIcon="@mipmap/ic_launcher_round"
10+
android:supportsRtl="true"
11+
android:theme="@style/Theme.Sample">
12+
13+
<activity
14+
android:name="com.emergetools.reaper.sample.manuallyInitialized.MainActivity"
15+
android:exported="true">
16+
<intent-filter>
17+
<action android:name="android.intent.action.MAIN" />
18+
19+
<category android:name="android.intent.category.DEFAULT" />
20+
<category android:name="android.intent.category.LAUNCHER" />
21+
</intent-filter>
22+
</activity>
23+
<activity android:name="androidx.activity.ComponentActivity" />
24+
25+
<provider
26+
android:name="androidx.startup.InitializationProvider"
27+
android:authorities="${applicationId}.androidx-startup"
28+
android:exported="false"
29+
tools:node="merge">
30+
<meta-data android:name="com.emergetools.reaper.ReaperInitializer"
31+
tools:node="remove" />
32+
</provider>
33+
</application>
34+
35+
</manifest>
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.emergetools.reaper.sample.manuallyInitialized
2+
3+
import android.os.Bundle
4+
import androidx.activity.ComponentActivity
5+
import androidx.activity.compose.setContent
6+
import androidx.compose.material3.Button
7+
import androidx.compose.material3.Text
8+
import com.emergetools.reaper.Reaper
9+
10+
class MainActivity : ComponentActivity() {
11+
12+
override fun onCreate(savedInstanceState: Bundle?) {
13+
super.onCreate(savedInstanceState)
14+
setContent {
15+
Button(onClick = { onClick() }) {
16+
Text("Initialize Reaper")
17+
}
18+
}
19+
}
20+
21+
private fun onClick() {
22+
Reaper.init(this)
23+
}
24+
}
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:height="108dp"
4+
android:width="108dp"
5+
android:viewportHeight="108"
6+
android:viewportWidth="108">
7+
<path
8+
android:fillColor="#3DDC84"
9+
android:pathData="M0,0h108v108h-108z" />
10+
<path
11+
android:fillColor="#00000000"
12+
android:pathData="M9,0L9,108"
13+
android:strokeColor="#33FFFFFF"
14+
android:strokeWidth="0.8" />
15+
<path
16+
android:fillColor="#00000000"
17+
android:pathData="M19,0L19,108"
18+
android:strokeColor="#33FFFFFF"
19+
android:strokeWidth="0.8" />
20+
<path
21+
android:fillColor="#00000000"
22+
android:pathData="M29,0L29,108"
23+
android:strokeColor="#33FFFFFF"
24+
android:strokeWidth="0.8" />
25+
<path
26+
android:fillColor="#00000000"
27+
android:pathData="M39,0L39,108"
28+
android:strokeColor="#33FFFFFF"
29+
android:strokeWidth="0.8" />
30+
<path
31+
android:fillColor="#00000000"
32+
android:pathData="M49,0L49,108"
33+
android:strokeColor="#33FFFFFF"
34+
android:strokeWidth="0.8" />
35+
<path
36+
android:fillColor="#00000000"
37+
android:pathData="M59,0L59,108"
38+
android:strokeColor="#33FFFFFF"
39+
android:strokeWidth="0.8" />
40+
<path
41+
android:fillColor="#00000000"
42+
android:pathData="M69,0L69,108"
43+
android:strokeColor="#33FFFFFF"
44+
android:strokeWidth="0.8" />
45+
<path
46+
android:fillColor="#00000000"
47+
android:pathData="M79,0L79,108"
48+
android:strokeColor="#33FFFFFF"
49+
android:strokeWidth="0.8" />
50+
<path
51+
android:fillColor="#00000000"
52+
android:pathData="M89,0L89,108"
53+
android:strokeColor="#33FFFFFF"
54+
android:strokeWidth="0.8" />
55+
<path
56+
android:fillColor="#00000000"
57+
android:pathData="M99,0L99,108"
58+
android:strokeColor="#33FFFFFF"
59+
android:strokeWidth="0.8" />
60+
<path
61+
android:fillColor="#00000000"
62+
android:pathData="M0,9L108,9"
63+
android:strokeColor="#33FFFFFF"
64+
android:strokeWidth="0.8" />
65+
<path
66+
android:fillColor="#00000000"
67+
android:pathData="M0,19L108,19"
68+
android:strokeColor="#33FFFFFF"
69+
android:strokeWidth="0.8" />
70+
<path
71+
android:fillColor="#00000000"
72+
android:pathData="M0,29L108,29"
73+
android:strokeColor="#33FFFFFF"
74+
android:strokeWidth="0.8" />
75+
<path
76+
android:fillColor="#00000000"
77+
android:pathData="M0,39L108,39"
78+
android:strokeColor="#33FFFFFF"
79+
android:strokeWidth="0.8" />
80+
<path
81+
android:fillColor="#00000000"
82+
android:pathData="M0,49L108,49"
83+
android:strokeColor="#33FFFFFF"
84+
android:strokeWidth="0.8" />
85+
<path
86+
android:fillColor="#00000000"
87+
android:pathData="M0,59L108,59"
88+
android:strokeColor="#33FFFFFF"
89+
android:strokeWidth="0.8" />
90+
<path
91+
android:fillColor="#00000000"
92+
android:pathData="M0,69L108,69"
93+
android:strokeColor="#33FFFFFF"
94+
android:strokeWidth="0.8" />
95+
<path
96+
android:fillColor="#00000000"
97+
android:pathData="M0,79L108,79"
98+
android:strokeColor="#33FFFFFF"
99+
android:strokeWidth="0.8" />
100+
<path
101+
android:fillColor="#00000000"
102+
android:pathData="M0,89L108,89"
103+
android:strokeColor="#33FFFFFF"
104+
android:strokeWidth="0.8" />
105+
<path
106+
android:fillColor="#00000000"
107+
android:pathData="M0,99L108,99"
108+
android:strokeColor="#33FFFFFF"
109+
android:strokeWidth="0.8" />
110+
<path
111+
android:fillColor="#00000000"
112+
android:pathData="M19,29L89,29"
113+
android:strokeColor="#33FFFFFF"
114+
android:strokeWidth="0.8" />
115+
<path
116+
android:fillColor="#00000000"
117+
android:pathData="M19,39L89,39"
118+
android:strokeColor="#33FFFFFF"
119+
android:strokeWidth="0.8" />
120+
<path
121+
android:fillColor="#00000000"
122+
android:pathData="M19,49L89,49"
123+
android:strokeColor="#33FFFFFF"
124+
android:strokeWidth="0.8" />
125+
<path
126+
android:fillColor="#00000000"
127+
android:pathData="M19,59L89,59"
128+
android:strokeColor="#33FFFFFF"
129+
android:strokeWidth="0.8" />
130+
<path
131+
android:fillColor="#00000000"
132+
android:pathData="M19,69L89,69"
133+
android:strokeColor="#33FFFFFF"
134+
android:strokeWidth="0.8" />
135+
<path
136+
android:fillColor="#00000000"
137+
android:pathData="M19,79L89,79"
138+
android:strokeColor="#33FFFFFF"
139+
android:strokeWidth="0.8" />
140+
<path
141+
android:fillColor="#00000000"
142+
android:pathData="M29,19L29,89"
143+
android:strokeColor="#33FFFFFF"
144+
android:strokeWidth="0.8" />
145+
<path
146+
android:fillColor="#00000000"
147+
android:pathData="M39,19L39,89"
148+
android:strokeColor="#33FFFFFF"
149+
android:strokeWidth="0.8" />
150+
<path
151+
android:fillColor="#00000000"
152+
android:pathData="M49,19L49,89"
153+
android:strokeColor="#33FFFFFF"
154+
android:strokeWidth="0.8" />
155+
<path
156+
android:fillColor="#00000000"
157+
android:pathData="M59,19L59,89"
158+
android:strokeColor="#33FFFFFF"
159+
android:strokeWidth="0.8" />
160+
<path
161+
android:fillColor="#00000000"
162+
android:pathData="M69,19L69,89"
163+
android:strokeColor="#33FFFFFF"
164+
android:strokeWidth="0.8" />
165+
<path
166+
android:fillColor="#00000000"
167+
android:pathData="M79,19L79,89"
168+
android:strokeColor="#33FFFFFF"
169+
android:strokeWidth="0.8" />
170+
</vector>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:aapt="http://schemas.android.com/aapt"
3+
android:width="108dp"
4+
android:height="108dp"
5+
android:viewportWidth="108"
6+
android:viewportHeight="108">
7+
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
8+
<aapt:attr name="android:fillColor">
9+
<gradient
10+
android:startY="49.59793"
11+
android:startX="42.9492"
12+
android:endY="92.4963"
13+
android:endX="85.84757"
14+
android:type="linear">
15+
<item
16+
android:color="#44000000"
17+
android:offset="0.0" />
18+
<item
19+
android:color="#00000000"
20+
android:offset="1.0" />
21+
</gradient>
22+
</aapt:attr>
23+
</path>
24+
<path
25+
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
26+
android:fillColor="#FFFFFF"
27+
android:fillType="nonZero"
28+
android:strokeWidth="1"
29+
android:strokeColor="#00000000" />
30+
</vector>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
3+
<background android:drawable="@color/ic_launcher_background"/>
4+
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
5+
</adaptive-icon>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
3+
<background android:drawable="@color/ic_launcher_background"/>
4+
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
5+
</adaptive-icon>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<resources>
2+
<string name="app_name">Reaper sample</string>
3+
<string name="sample_title">Testtitel</string>
4+
<string name="sample_subtitle">Test-Untertitel</string>
5+
</resources>

0 commit comments

Comments
 (0)