mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
feat(sdk-android): throwaway sample app for SDK validation
Single-activity Android app that calls Uatu.start() in SampleApplication.onCreate and registers three extractors (app_state, click_count, uptime_millis). MainActivity has a button so click_count exercises non-trivial state.
This commit is contained in:
1 parent
1700160077
commit
8961aadda8
5 files changed
+118
No files matched your search
@@ -0,0 +1,36 @@
|
|||||||
|
plugins {
|
||||||
|
id("com.android.application") version "8.11.0"
|
||||||
|
kotlin("android") version "2.1.21"
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
namespace = "dev.uatu.sample"
|
||||||
|
compileSdk = 35
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
applicationId = "dev.uatu.sample"
|
||||||
|
minSdk = 24
|
||||||
|
targetSdk = 35
|
||||||
|
versionCode = 1
|
||||||
|
versionName = "0.0.1"
|
||||||
|
}
|
||||||
|
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_17
|
||||||
|
targetCompatibility = JavaVersion.VERSION_17
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = "17"
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
debug {
|
||||||
|
isDebuggable = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation(project(":sdk-android"))
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<application
|
||||||
|
android:name=".SampleApplication"
|
||||||
|
android:label="Uatu Sample"
|
||||||
|
android:allowBackup="false">
|
||||||
|
<activity
|
||||||
|
android:name=".MainActivity"
|
||||||
|
android:exported="true">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
</manifest>
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package dev.uatu.sample
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.graphics.Color
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.Gravity
|
||||||
|
import android.widget.Button
|
||||||
|
import android.widget.LinearLayout
|
||||||
|
import android.widget.TextView
|
||||||
|
|
||||||
|
class MainActivity : Activity() {
|
||||||
|
companion object {
|
||||||
|
@Volatile var clickCount: Int = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
private lateinit var label: TextView
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
val layout = LinearLayout(this).apply {
|
||||||
|
orientation = LinearLayout.VERTICAL
|
||||||
|
gravity = Gravity.CENTER
|
||||||
|
setBackgroundColor(Color.parseColor("#FAFAFA"))
|
||||||
|
setPadding(64, 96, 64, 64)
|
||||||
|
}
|
||||||
|
|
||||||
|
label = TextView(this).apply {
|
||||||
|
text = "Clicks: 0"
|
||||||
|
textSize = 28f
|
||||||
|
setTextColor(Color.BLACK)
|
||||||
|
gravity = Gravity.CENTER
|
||||||
|
}
|
||||||
|
layout.addView(label)
|
||||||
|
|
||||||
|
val button = Button(this).apply {
|
||||||
|
text = "Click me"
|
||||||
|
textSize = 18f
|
||||||
|
setOnClickListener {
|
||||||
|
clickCount++
|
||||||
|
label.text = "Clicks: $clickCount"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
layout.addView(button)
|
||||||
|
|
||||||
|
setContentView(layout)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package dev.uatu.sample
|
||||||
|
|
||||||
|
import android.app.Application
|
||||||
|
import dev.uatu.sdk.Uatu
|
||||||
|
|
||||||
|
class SampleApplication : Application() {
|
||||||
|
override fun onCreate() {
|
||||||
|
super.onCreate()
|
||||||
|
Uatu.start(this)
|
||||||
|
Uatu.extract("app_state") { "running" }
|
||||||
|
Uatu.extract("click_count") { MainActivity.clickCount }
|
||||||
|
Uatu.extract("uptime_millis") { System.currentTimeMillis() - startedAt }
|
||||||
|
}
|
||||||
|
|
||||||
|
private val startedAt: Long = System.currentTimeMillis()
|
||||||
|
}
|
||||||
@@ -19,3 +19,5 @@ rootProject.name = "uatu"
|
|||||||
include(":sidecar")
|
include(":sidecar")
|
||||||
include(":sdk-android")
|
include(":sdk-android")
|
||||||
project(":sdk-android").projectDir = file("sdk/android")
|
project(":sdk-android").projectDir = file("sdk/android")
|
||||||
|
include(":sdk-android-sample")
|
||||||
|
project(":sdk-android-sample").projectDir = file("sdk/android/sample")
|
||||||
Reference in new issue
Block a user