diff --git a/buildSrc/src/main/java/Dependencies.kt b/buildSrc/src/main/java/Dependencies.kt
index bd0279263..ae05b6769 100644
--- a/buildSrc/src/main/java/Dependencies.kt
+++ b/buildSrc/src/main/java/Dependencies.kt
@@ -13,7 +13,7 @@ object LibsVersion {
const val JUNIT = "4.13.2"
const val ASM = "9.2"
const val SQLITE = "2.1.0"
- const val SENTRY = "5.1.2"
+ const val SENTRY = "5.5.0"
}
object Libs {
diff --git a/examples/android-room/src/main/AndroidManifest.xml b/examples/android-room/src/main/AndroidManifest.xml
index 2a76f2318..e68bd17bf 100644
--- a/examples/android-room/src/main/AndroidManifest.xml
+++ b/examples/android-room/src/main/AndroidManifest.xml
@@ -16,6 +16,10 @@
android:name=".ui.EditActivity"
android:theme="@style/Theme.AppCompat.NoActionBar" />
+
+
diff --git a/examples/android-room/src/main/java/io/sentry/android/roomsample/SampleApp.kt b/examples/android-room/src/main/java/io/sentry/android/roomsample/SampleApp.kt
index 27420ca7f..e49451e85 100644
--- a/examples/android-room/src/main/java/io/sentry/android/roomsample/SampleApp.kt
+++ b/examples/android-room/src/main/java/io/sentry/android/roomsample/SampleApp.kt
@@ -1,14 +1,25 @@
package io.sentry.android.roomsample
import android.app.Application
+import android.content.Context
+import android.content.SharedPreferences
import androidx.room.Room
import io.sentry.android.roomsample.data.TracksDatabase
+import io.sentry.android.roomsample.util.DEFAULT_LYRICS
+import java.io.File
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.GlobalScope
+import kotlinx.coroutines.flow.collect
+import kotlinx.coroutines.launch
class SampleApp : Application() {
companion object {
lateinit var database: TracksDatabase
private set
+
+ lateinit var analytics: SharedPreferences
+ private set
}
override fun onCreate() {
@@ -17,5 +28,23 @@ class SampleApp : Application() {
.createFromAsset("tracks.db")
.fallbackToDestructiveMigration()
.build()
+
+ analytics = getSharedPreferences("analytics", Context.MODE_PRIVATE)
+
+ GlobalScope.launch(Dispatchers.IO) {
+ database.tracksDao().all()
+ .collect { tracks ->
+ tracks.forEachIndexed { index, track ->
+ // add lyrics for every 2nd track
+ if (index % 2 == 0) {
+ val dir = File("$filesDir${File.separatorChar}lyrics")
+ dir.mkdirs()
+
+ val file = File(dir, "${track.id}.txt")
+ file.writeText(DEFAULT_LYRICS)
+ }
+ }
+ }
+ }
}
}
diff --git a/examples/android-room/src/main/java/io/sentry/android/roomsample/ui/EditActivity.kt b/examples/android-room/src/main/java/io/sentry/android/roomsample/ui/EditActivity.kt
index 4e1983df7..70c86930b 100644
--- a/examples/android-room/src/main/java/io/sentry/android/roomsample/ui/EditActivity.kt
+++ b/examples/android-room/src/main/java/io/sentry/android/roomsample/ui/EditActivity.kt
@@ -56,8 +56,14 @@ class EditActivity : ComponentActivity() {
} else {
if (originalTrack == null) {
addNewTrack(name, composer, duration.toLong(), unitPrice.toFloat())
+
+ val createCount = SampleApp.analytics.getInt("create_count", 0) + 1
+ SampleApp.analytics.edit().putInt("create_count", createCount).apply()
} else {
originalTrack.update(name, composer, duration.toLong(), unitPrice.toFloat())
+
+ val editCount = SampleApp.analytics.getInt("edit_count", 0) + 1
+ SampleApp.analytics.edit().putInt("edit_count", editCount).apply()
}
transaction.finish(SpanStatus.OK)
finish()
diff --git a/examples/android-room/src/main/java/io/sentry/android/roomsample/ui/LyricsActivity.kt b/examples/android-room/src/main/java/io/sentry/android/roomsample/ui/LyricsActivity.kt
new file mode 100644
index 000000000..f2f2ce82a
--- /dev/null
+++ b/examples/android-room/src/main/java/io/sentry/android/roomsample/ui/LyricsActivity.kt
@@ -0,0 +1,62 @@
+package io.sentry.android.roomsample.ui
+
+import android.annotation.SuppressLint
+import android.os.Bundle
+import android.widget.EditText
+import androidx.activity.ComponentActivity
+import androidx.appcompat.widget.Toolbar
+import io.sentry.Sentry
+import io.sentry.SpanStatus
+import io.sentry.android.roomsample.R
+import io.sentry.android.roomsample.data.Track
+import java.io.File
+
+@SuppressLint("SetTextI18n")
+class LyricsActivity : ComponentActivity() {
+ private lateinit var file: File
+ private lateinit var lyricsInput: EditText
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_lyrics)
+
+ val transaction = Sentry.startTransaction(
+ "Track Interaction",
+ "ui.action.lyrics",
+ true
+ )
+
+ lyricsInput = findViewById(R.id.lyrics)
+ val toolbar = findViewById(R.id.toolbar)
+
+ val track: Track = intent.getSerializableExtra(TRACK_EXTRA_KEY) as Track
+ toolbar.title = "Lyrics for ${track.name}"
+
+ val dir = File("$filesDir${File.separatorChar}lyrics")
+ dir.mkdirs()
+
+ file = File(dir, "${track.id}.txt")
+ if (file.exists()) {
+ lyricsInput.setText(file.readText())
+ }
+ transaction.finish(SpanStatus.OK)
+ }
+
+ override fun onBackPressed() {
+ val transaction = Sentry.getSpan() ?: Sentry.startTransaction(
+ "Track Interaction",
+ "ui.action.lyrics_finish",
+ true
+ )
+ if (!file.exists()) {
+ file.createNewFile()
+ }
+ file.writeText(lyricsInput.text.toString())
+ transaction.finish(SpanStatus.OK)
+ super.onBackPressed()
+ }
+
+ companion object {
+ const val TRACK_EXTRA_KEY = "LyricsActivity.Track"
+ }
+}
diff --git a/examples/android-room/src/main/java/io/sentry/android/roomsample/ui/MainActivity.kt b/examples/android-room/src/main/java/io/sentry/android/roomsample/ui/MainActivity.kt
index f489d1a1d..7f852baaa 100644
--- a/examples/android-room/src/main/java/io/sentry/android/roomsample/ui/MainActivity.kt
+++ b/examples/android-room/src/main/java/io/sentry/android/roomsample/ui/MainActivity.kt
@@ -1,15 +1,7 @@
package io.sentry.android.roomsample.ui
-import android.annotation.SuppressLint
-import android.content.Context
import android.content.Intent
import android.os.Bundle
-import android.util.AttributeSet
-import android.view.LayoutInflater
-import android.view.View
-import android.view.ViewGroup
-import android.widget.LinearLayout
-import android.widget.TextView
import androidx.activity.ComponentActivity
import androidx.appcompat.widget.Toolbar
import androidx.lifecycle.lifecycleScope
@@ -19,9 +11,8 @@ import io.sentry.Sentry
import io.sentry.SpanStatus
import io.sentry.android.roomsample.R
import io.sentry.android.roomsample.SampleApp
-import io.sentry.android.roomsample.data.Track
+import io.sentry.android.roomsample.ui.list.TrackAdapter
import kotlinx.coroutines.flow.collect
-import kotlinx.coroutines.runBlocking
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
@@ -55,77 +46,3 @@ class MainActivity : ComponentActivity() {
}
}
}
-
-class TrackRow(
- context: Context,
- attrs: AttributeSet
-) : LinearLayout(context, attrs) {
-
- val deleteButton: View get() = findViewById(R.id.delete_track)
- val editButton: View get() = findViewById(R.id.edit_track)
-
- @SuppressLint("SetTextI18n")
- fun populate(track: Track) {
- val mins = (track.millis / 1000) / 60
- val secs = (track.millis / 1000) % 60
-
- findViewById(R.id.track_name).text = track.name
- findViewById(R.id.track_duration).text = "${mins}m ${secs}s"
- findViewById(R.id.band_name).text = track.composer
- }
-}
-
-class TrackAdapter : RecyclerView.Adapter() {
-
- private var data: List