diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..4b45f2c --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,32 @@ +name: Run Tests + +on: + push: + branches: + - main + pull_request: + +# prevent concurrent builds from running at the same time +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + name: Test Kotlin SDK for TelemetryDeck + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Configure JDK + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '17' + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Run test + run: ./gradlew lib:test \ No newline at end of file diff --git a/.gitignore b/.gitignore index 8512d29..734bf56 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,8 @@ /.idea/workspace.xml /.idea/navEditor.xml /.idea/assetWizardSettings.xml +/.idea/androidTestResultsUserPreferences.xml +/.idea/deploymentTargetSelector.xml .DS_Store /build /captures diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..b86273d --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..9c6ca34 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml index 9a55c2d..d4b7acc 100644 --- a/.idea/kotlinc.xml +++ b/.idea/kotlinc.xml @@ -1,6 +1,6 @@ - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..f988785 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index 40c6ee7..7e39cd5 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,12 @@ -# KotlinClient +# Kotlin SDK for TelemetryDeck This package allows you to send signals to [TelemetryDeck](https://telemetrydeck.com) from your Android applications. Sign up for a free account at [telemetrydeck.com](https://telemetrydeck.com) ## Installation -The TelemetryDeck is distributed using [jitpack](https://jitpack.io/), so you'll need to add the jitpack dependency to your `settings.gradle` file: +### Dependencies -```groovy -dependencyResolutionManagement { - repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) - repositories { - google() - mavenCentral() - maven { url 'https://jitpack.io' } // <-- add this line - } -} -``` - -After that is done, add the following to your `build.gradle` file, under `dependencies`: +The Kotlin SDK for TelemetryDeck is available from Maven Central and can be used as a dependency directly in `build.gradle` file: ```groovy dependencies { @@ -33,7 +22,7 @@ If needed, update your `gradle.settings` to reference Kotlin version compatible id "org.jetbrains.kotlin.android" version "1.9.25" apply false ``` -## Permission for internet access +### Permission for internet access Sending signals requires access to the internet so the following permission should be added to the app's `AndroidManifest.xml` @@ -41,15 +30,17 @@ Sending signals requires access to the internet so the following permission shou ``` +## Getting Started + ### Using the application manifest -The TelemetryManager can be initialized automatically by adding the application key to the `application` section of the app's `AndroidManifest.xml`: +A quick way to start is by adding your App ID to the `application` section of the app's `AndroidManifest.xml`: ```xml ... - + ``` @@ -58,24 +49,24 @@ Replace `XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX` with your TelemetryDeck App ID. In addition, the following optional properties are supported: -- `com.telemetrydeck.sdk.showDebugLogs` -- `com.telemetrydeck.sdk.apiBaseURL` -- `com.telemetrydeck.sdk.sendNewSessionBeganSignal` -- `com.telemetrydeck.sdk.sessionID` -- `com.telemetrydeck.sdk.testMode` -- `com.telemetrydeck.sdk.defaultUser` +- `com.telemetrydeck.showDebugLogs` +- `com.telemetrydeck.apiBaseURL` +- `com.telemetrydeck.sendNewSessionBeganSignal` +- `com.telemetrydeck.sessionID` +- `com.telemetrydeck.testMode` +- `com.telemetrydeck.defaultUser` -### Programatic Usage +### Programmatic Usage -For greater control you can instead manually start the TelemetryManager client +For greater control you can set up and configure `TelemetryDeck` using the provided builder: ```kotlin -val builder = TelemetryManager.Builder() +val builder = TelemetryDeck.Builder() .appID("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX") .showDebugLogs(true) .defaultUser("Person") -TelemetryManager.start(application, builder) +TelemetryDeck.start(application, builder) ``` ## Sending Signals @@ -83,29 +74,71 @@ TelemetryManager.start(application, builder) To send a signal immediately ```kotlin -TelemetryManager.send("appLaunchedRegularly") +TelemetryDeck.send("appLaunchedRegularly") ``` -To enqueue a signal to be sent by TelemetryManager at a later time +To enqueue a signal to be sent by TelemetryDeck at a later time ```kotlin -TelemetryManager.queue("appLaunchedRegularly") +TelemetryDeck.signal("appLaunchedRegularly") ``` +### Environment Parameters + +By default, Kotlin SDK for TelemetryDeck will include the following environment parameters for each outgoing signal + + +| Signal name | Provider | +|------------------------------------------------|--------------------------------| +| `TelemetryDeck.Session.started` | `SessionAppProvider` | +| `TelemetryDeck.AppInfo.buildNumber` | `EnvironmentParameterProvider` | +| `TelemetryDeck.AppInfo.version` | `EnvironmentParameterProvider` | +| `TelemetryDeck.AppInfo.versionAndBuildNumber` | `EnvironmentParameterProvider` | +| `TelemetryDeck.Device.architecture` | `EnvironmentParameterProvider` | +| `TelemetryDeck.Device.modelName` | `EnvironmentParameterProvider` | +| `TelemetryDeck.Device.operatingSystem` | `EnvironmentParameterProvider` | +| `TelemetryDeck.Device.platform` | `EnvironmentParameterProvider` | +| `TelemetryDeck.Device.systemMajorMinorVersion` | `EnvironmentParameterProvider` | +| `TelemetryDeck.Device.systemMajorVersion` | `EnvironmentParameterProvider` | +| `TelemetryDeck.Device.systemVersion` | `EnvironmentParameterProvider` | +| `TelemetryDeck.Device.orientation` | `PlatformContextProvider` | +| `TelemetryDeck.Device.screenDensity` | `PlatformContextProvider` | +| `TelemetryDeck.Device.screenResolutionHeight` | `PlatformContextProvider` | +| `TelemetryDeck.Device.screenResolutionWidth` | `PlatformContextProvider` | +| `TelemetryDeck.Device.brand` | `EnvironmentParameterProvider` | +| `TelemetryDeck.Device.timeZone` | `PlatformContextProvider` | +| `TelemetryDeck.AppInfo.buildNumber` | `EnvironmentParameterProvider` | +| `TelemetryDeck.AppInfo.version` | `EnvironmentParameterProvider` | +| `TelemetryDeck.AppInfo.versionAndBuildNumber` | `EnvironmentParameterProvider` | +| `TelemetryDeck.SDK.name` | `EnvironmentParameterProvider` | +| `TelemetryDeck.SDK.version` | `EnvironmentParameterProvider` | +| `TelemetryDeck.SDK.nameAndVersion` | `EnvironmentParameterProvider` | +| `TelemetryDeck.SDK.buildType` | `EnvironmentParameterProvider` | +| `TelemetryDeck.RunContext.locale` | `PlatformContextProvider` | +| `TelemetryDeck.RunContext.targetEnvironment` | `PlatformContextProvider` | +| `TelemetryDeck.RunContext.isSideLoaded` | `PlatformContextProvider` | +| `TelemetryDeck.RunContext.sourceMarketplace` | `PlatformContextProvider` | + + +See [Custom Telemetry](#custom-telemetry) on how to implement your own parameter enrichment. + ## Custom Telemetry -Another way to send signals is to register a custom `TelemetryProvider` . A provider maintains a reference to the TelemetryManager in order to queue or send signals. +Another way to send signals is to register a custom `TelemetryDeckProvider`. +A provider uses the TelemetryDeck client in order to queue or send signals based on environment or other triggers. + -To create a provider, implement the `TelemetryProvider` interface: +To create a provider, implement the `TelemetryDeckProvider` interface: ```kotlin -class CustomProvider: TelemetryProvider { - override fun register(ctx: Application?, manager: TelemetryManager) { +class CustomProvider: TelemetryDeckProvider { + override fun register(ctx: Application?, client: TelemetryDeckClient) { // configure and start the provider + // you may retain a WeakReference to client } override fun stop() { - // deactivate the provider + // deactivate the provider, perform cleanup work } } ``` @@ -114,18 +147,20 @@ Setup and start the provider during the `register` method. Tips: -- Do not retain a strong reference to the application context or the TelemetryManager. -- You can use `WeakReference` if you need to be able to call the TelemetryManager at a later time. +- Do not retain a strong reference to the application context or TelemetryDeckClient instance. +- You can use `WeakReference` if you need to be able to call the TelemetryDeck at a later time. -To use your custom provider, register it using the `TelemetryManager.Builder` : +To use your custom provider, register it by calling `addProvider` using the `TelemetryDeck.Builder` : ```kotlin -val builder = TelemetryManager.Builder() - .appID("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX") - .addProvider(CustomProvider()) +val builder = TelemetryDeck.Builder() + // ... + .addProvider(CustomProvider()) // <-- Your custom provider ``` -When a signal is received by TelemetryManager, it can be enriched with platform and environment specific information. TelemetryManager calls the `enrich` method allowing every registered provider to add additional payload to a signal. +Every time the SDK is about to send signals to our servers, the `enrich` method of every provider will be invoked to give you the opportunity to append additional parameters. + +In the implementation of your custom `TelemetryDeckProvider`, you can override the `enrich` method: ```kotlin override fun enrich( @@ -133,35 +168,123 @@ override fun enrich( clientUser: String?, additionalPayload: Map ): Map { + // retrieve the payload of signal val signalPayload = additionalPayload.toMutableMap() + // add additional attributes of your choice val today = LocalDateTime.now().dayOfWeek if (today == DayOfWeek.MONDAY) { signalPayload["isMonday"] = "yes" } + // return the enriched payload return signalPayload } ``` -TelemetryManager also makes use of providers in order to provide lifecycle and environment integration out of the box. Feel free to examine how they work and inspire your own implementations. You can also completely disable or override the default providers with your own. +We use providers internally to provide lifecycle and environment integration out of the box. +Feel free to examine how they work and inspire your own implementations. -- `SessionProvider` - Monitors the app lifecycle in order to broadcast the NewSessionBegan signal. This provider is tasked with resetting the sessionID when `sendNewSessionBeganSignal` is enabled. -- `AppLifecycleTelemetryProvider` - Emits signals for application and activity lifecycle events. -- `EnvironmentMetadataProvider` - Adds environment and device information to outgoing Signals. This provider overrides the `enrich` method in order to append additional metdata for all signals before sending them. +You can also completely disable or override the default providers with your own. + +- `SessionAppProvider` - Emits signals for application and activity lifecycle events. This provider is tasked with resetting the sessionID when `sendNewSessionBeganSignal` is enabled. +- `SessionActivityProvider` - Emits signals for application and activity lifecycle events. This provider is not enabled by default. +- `EnvironmentParameterProvider` - Adds environment and device information to outgoing Signals. This provider overrides the `enrich` method in order to append additional metadata for all signals before sending them. +- `PlatformContextProvider` - Adds environment and device information which may change over time like the current timezone and screen metrics. ```kotlin // Append a custom provider -val builder = TelemetryManager.Builder() - .appID("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX") +val builder = TelemetryDeck.Builder() + // ... .addProvider(CustomProvider()) // Replace all default providers -val builder = TelemetryManager.Builder() - .appID("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX") +val builder = TelemetryDeck.Builder() + // ... .providers(listOf(CustomProvider(), AnotherProvider())) ``` +## Custom Logging + +By default, TelemetryDeck SDK uses a simple `println` to output internal diagnostic messages when `showDebugLogs` is set to `true` in configuration. + +If your platform has custom logging needs, you can adopt the `DebugLogger` interface and provide it to the `TelemetryDeck` builder: + +```kotlin +val builder = TelemetryDeck.Builder() + // ... + .logger(CustomLogger()) +``` + +Please note that the logger implementation should be thread safe as it may be invoked in different queues and contexts. + + + ## Requirements - Android API 21 or later - Kotlin 1.9.25 or later + + +## Migrating providers to 3.0+ + +If you had Kotlin SDK for TelemetryDeck added to your app, you will notice that `TelemetryManager` and related classes have been deprecated. +You can read more about the motivation behind these changes [here](https://telemetrydeck.com/docs/articles/grand-rename/). + +To upgrade, please perform the following changes depending on how you use TelemetryDeck SDK. + +### If you're using the application manifest + +* Adapt the manifest of your app and rename all keys from `com.telemetrydeck.sdk.*` to `com.telemetrydeck.*` for example: + +Before: +```xml + +``` + +After: +```xml + +``` + +* In your app sourcecode, rename all uses of `TelemetryManager` to `TelemetryDeck`. +* If you were using `send()` to send signals, no further changes are needed! +* If you were using `queue()` to send signals, you will need to rename the method to `TelemetryDeck.signal()`. + +### Programmatic Usage + +* In your app sourcecode, rename all uses of `TelemetryManager` to `TelemetryDeck`. +* If you were using `send()` to send signals, no further changes are needed! +* If you were using `queue()` to send signals, you will need to rename the method to `TelemetryDeck.signal()`. +* If you had a custom provider configuration, please replace the corresponding providers as follows: + +| Provider (old name) | Provider (new, 3.0+) | +|---------------------------------|-----------------------------------------------------------| +| `AppLifecycleTelemetryProvider` | `SessionAppProvider`, `SessionActivityProvider` | +| `SessionProvider` | `SessionAppProvider` | +| `EnvironmentMetadataProvider` | `EnvironmentParameterProvider`, `PlatformContextProvider` | + + + +> [!TIP] +> You can rename all deprecated classes in your project using the Code Cleanup function in IntelliJ/Android Studio. + + +> [!WARNING] +> Do not mix usage of `TelemetryManager` and `TelemetryDeck`. Once you're ready to migrate, adapt all uses at the same time. + + +### Custom Telemetry + + +Your custom providers must replace `TelemetryProvider` with `TelemetryDeckProvider`. + +To adopt the new interface: + +* Adapt the signature of the `register` method to `register(ctx: Application?, client: TelemetryDeckSignalProcessor)` + +The `TelemetryDeckSignalProcessor` interface offers a subset of the `TelemetryDeck` client API which gives you access to: + +* To access the logger, use can use `client.debugLogger` +* To access the signal cache, use `client.signalCache` + + diff --git a/app/.gitignore b/app/.gitignore deleted file mode 100644 index 42afabf..0000000 --- a/app/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle deleted file mode 100644 index ecde9ae..0000000 --- a/app/build.gradle +++ /dev/null @@ -1,50 +0,0 @@ -plugins { - id 'com.android.application' - id 'kotlin-android' -} - -android { - compileSdk 31 - - defaultConfig { - applicationId "com.telemetrydeck.sdk.app" - minSdk 21 - targetSdk 31 - versionCode 1 - versionName "1.0" - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - kotlinOptions { - jvmTarget = '1.8' - } - buildFeatures { - viewBinding true - } - namespace 'com.telemetrydeck.sdk.app' -} - -dependencies { - - implementation 'androidx.core:core-ktx:1.7.0' - implementation 'androidx.appcompat:appcompat:1.3.1' - implementation 'com.google.android.material:material:1.4.0' - implementation 'androidx.constraintlayout:constraintlayout:2.1.1' - implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5' - implementation 'androidx.navigation:navigation-ui-ktx:2.3.5' - implementation project(':lib') - testImplementation 'junit:junit:4.+' - androidTestImplementation 'androidx.test.ext:junit:1.1.3' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' -} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro deleted file mode 100644 index 481bb43..0000000 --- a/app/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/app/src/androidTest/java/com/telemetrydeck/sdk/app/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/telemetrydeck/sdk/app/ExampleInstrumentedTest.kt deleted file mode 100644 index aec64f1..0000000 --- a/app/src/androidTest/java/com/telemetrydeck/sdk/app/ExampleInstrumentedTest.kt +++ /dev/null @@ -1,24 +0,0 @@ -package com.telemetrydeck.sdk.app - -import androidx.test.platform.app.InstrumentationRegistry -import androidx.test.ext.junit.runners.AndroidJUnit4 - -import org.junit.Test -import org.junit.runner.RunWith - -import org.junit.Assert.* - -/** - * Instrumented test, which will execute on an Android device. - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -@RunWith(AndroidJUnit4::class) -class ExampleInstrumentedTest { - @Test - fun useAppContext() { - // Context of the app under test. - val appContext = InstrumentationRegistry.getInstrumentation().targetContext - assertEquals("com.telemetrydeck.sdk.app", appContext.packageName) - } -} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml deleted file mode 100644 index 56212e0..0000000 --- a/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/java/com/telemetrydeck/sdk/app/FirstFragment.kt b/app/src/main/java/com/telemetrydeck/sdk/app/FirstFragment.kt deleted file mode 100644 index d7f919f..0000000 --- a/app/src/main/java/com/telemetrydeck/sdk/app/FirstFragment.kt +++ /dev/null @@ -1,50 +0,0 @@ -package com.telemetrydeck.sdk.app - -import android.os.Bundle -import androidx.fragment.app.Fragment -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import androidx.lifecycle.lifecycleScope -import androidx.navigation.fragment.findNavController -import com.telemetrydeck.sdk.TelemetryManager -import com.telemetrydeck.sdk.app.databinding.FragmentFirstBinding -import kotlinx.coroutines.launch - -/** - * A simple [Fragment] subclass as the default destination in the navigation. - */ -class FirstFragment : Fragment() { - - private var _binding: FragmentFirstBinding? = null - - // This property is only valid between onCreateView and - // onDestroyView. - private val binding get() = _binding!! - - override fun onCreateView( - inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? - ): View? { - - _binding = FragmentFirstBinding.inflate(inflater, container, false) - return binding.root - - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - - binding.buttonFirst.setOnClickListener { - lifecycleScope.launch { - TelemetryManager.send("firstButtonPressed") - } - findNavController().navigate(R.id.action_FirstFragment_to_SecondFragment) - } - } - - override fun onDestroyView() { - super.onDestroyView() - _binding = null - } -} \ No newline at end of file diff --git a/app/src/main/java/com/telemetrydeck/sdk/app/MainActivity.kt b/app/src/main/java/com/telemetrydeck/sdk/app/MainActivity.kt deleted file mode 100644 index 115af9a..0000000 --- a/app/src/main/java/com/telemetrydeck/sdk/app/MainActivity.kt +++ /dev/null @@ -1,67 +0,0 @@ -package com.telemetrydeck.sdk.app - -import android.os.Bundle -import android.view.Menu -import android.view.MenuItem -import androidx.appcompat.app.AppCompatActivity -import androidx.navigation.findNavController -import androidx.navigation.ui.AppBarConfiguration -import androidx.navigation.ui.navigateUp -import androidx.navigation.ui.setupActionBarWithNavController -import com.google.android.material.snackbar.Snackbar -import com.telemetrydeck.sdk.TelemetryManager -import com.telemetrydeck.sdk.app.databinding.ActivityMainBinding - -class MainActivity : AppCompatActivity() { - - private lateinit var appBarConfiguration: AppBarConfiguration - private lateinit var binding: ActivityMainBinding - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - - TelemetryManager.newDefaultUser("It's me :)") -// val builder = TelemetryManager.Builder() -// .appID("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX") -// .showDebugLogs(true) -// .defaultUser("Person Name") -// -// TelemetryManager.start(application, builder) - - binding = ActivityMainBinding.inflate(layoutInflater) - setContentView(binding.root) - - setSupportActionBar(binding.toolbar) - - val navController = findNavController(R.id.nav_host_fragment_content_main) - appBarConfiguration = AppBarConfiguration(navController.graph) - setupActionBarWithNavController(navController, appBarConfiguration) - - binding.fab.setOnClickListener { view -> - Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) - .setAction("Action", null).show() - } - } - - override fun onCreateOptionsMenu(menu: Menu): Boolean { - // Inflate the menu; this adds items to the action bar if it is present. - menuInflater.inflate(R.menu.menu_main, menu) - return true - } - - override fun onOptionsItemSelected(item: MenuItem): Boolean { - // Handle action bar item clicks here. The action bar will - // automatically handle clicks on the Home/Up button, so long - // as you specify a parent activity in AndroidManifest.xml. - return when (item.itemId) { - R.id.action_settings -> true - else -> super.onOptionsItemSelected(item) - } - } - - override fun onSupportNavigateUp(): Boolean { - val navController = findNavController(R.id.nav_host_fragment_content_main) - return navController.navigateUp(appBarConfiguration) - || super.onSupportNavigateUp() - } -} \ No newline at end of file diff --git a/app/src/main/java/com/telemetrydeck/sdk/app/SecondFragment.kt b/app/src/main/java/com/telemetrydeck/sdk/app/SecondFragment.kt deleted file mode 100644 index 7dd6d9d..0000000 --- a/app/src/main/java/com/telemetrydeck/sdk/app/SecondFragment.kt +++ /dev/null @@ -1,50 +0,0 @@ -package com.telemetrydeck.sdk.app - -import android.os.Bundle -import androidx.fragment.app.Fragment -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import androidx.lifecycle.lifecycleScope -import androidx.navigation.fragment.findNavController -import com.telemetrydeck.sdk.TelemetryManager -import com.telemetrydeck.sdk.app.databinding.FragmentSecondBinding -import kotlinx.coroutines.launch - -/** - * A simple [Fragment] subclass as the second destination in the navigation. - */ -class SecondFragment : Fragment() { - - private var _binding: FragmentSecondBinding? = null - - // This property is only valid between onCreateView and - // onDestroyView. - private val binding get() = _binding!! - - override fun onCreateView( - inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? - ): View? { - - _binding = FragmentSecondBinding.inflate(inflater, container, false) - return binding.root - - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - TelemetryManager.stop() - binding.buttonSecond.setOnClickListener { - lifecycleScope.launch { - TelemetryManager.send("secondButtonPressed") - } - findNavController().navigate(R.id.action_SecondFragment_to_FirstFragment) - } - } - - override fun onDestroyView() { - super.onDestroyView() - _binding = null - } -} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml deleted file mode 100644 index 2b068d1..0000000 --- a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml deleted file mode 100644 index 07d5da9..0000000 --- a/app/src/main/res/drawable/ic_launcher_background.xml +++ /dev/null @@ -1,170 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml deleted file mode 100644 index 4999565..0000000 --- a/app/src/main/res/layout/activity_main.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/content_main.xml b/app/src/main/res/layout/content_main.xml deleted file mode 100644 index 4f68632..0000000 --- a/app/src/main/res/layout/content_main.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_first.xml b/app/src/main/res/layout/fragment_first.xml deleted file mode 100644 index fb44a3d..0000000 --- a/app/src/main/res/layout/fragment_first.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - -