-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMainActivity.kt
More file actions
234 lines (222 loc) · 9.21 KB
/
Copy pathMainActivity.kt
File metadata and controls
234 lines (222 loc) · 9.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
package com.example.androidobservability
import android.content.Intent
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.activity.viewModels
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Button
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.example.androidobservability.ui.theme.AndroidObservabilityTheme
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val viewModel: ViewModel by viewModels()
enableEdgeToEdge()
setContent {
AndroidObservabilityTheme {
Scaffold(
modifier = Modifier
.fillMaxSize()
.imePadding()
) { innerPadding ->
var customLogText by remember { mutableStateOf("") }
var customSpanText by remember { mutableStateOf("") }
var customContextKey by remember { mutableStateOf("") }
Column(
modifier = Modifier
.fillMaxSize()
.padding(innerPadding)
.verticalScroll(rememberScrollState())
.padding(16.dp)
) {
Text(
text = "Hello Telemetry",
modifier = Modifier.padding(bottom = 16.dp)
)
Button(
onClick = {
this@MainActivity.startActivity(
Intent(
this@MainActivity,
SecondaryActivity::class.java
)
)
}
) {
Text("Go to Secondary Activity")
}
Button(
onClick = {
this@MainActivity.startActivity(
Intent(
this@MainActivity,
CreditCardActivity::class.java
)
)
}
) {
Text("Open Credit Card (XML)")
}
Button(
onClick = {
this@MainActivity.startActivity(
Intent(
this@MainActivity,
com.smoothie.SmoothieListActivity::class.java
)
)
}
) {
Text("Open Fruta (XML)")
}
Button(
onClick = {
viewModel.triggerHttpRequests()
}
) {
Text("Trigger HTTP Request")
}
Button(
onClick = {
viewModel.triggerMetric()
}
) {
Text("Trigger Metric")
}
Button(
onClick = {
viewModel.triggerHistogramMetric()
}
) {
Text("Trigger Histogram Metric")
}
Button(
onClick = {
viewModel.triggerCountMetric()
}
) {
Text("Trigger Count Metric")
}
Button(
onClick = {
viewModel.triggerIncrementalMetric()
}
) {
Text("Trigger Incremental Metric")
}
Button(
onClick = {
viewModel.triggerUpDownCounterMetric()
}
) {
Text("Trigger UpDownCounter Metric")
}
Button(
onClick = {
viewModel.triggerError()
}
) {
Text("Trigger Error")
}
Button(
onClick = {
viewModel.triggerLog()
}
) {
Text("Trigger Log")
}
Button(
onClick = {
viewModel.startForegroundService()
}
) {
Text("Start Foreground Service")
}
Button(
onClick = {
viewModel.startBackgroundService()
}
) {
Text("Start Background Service")
}
Button(
onClick = {
viewModel.triggerNestedSpans()
}
) {
Text("Trigger Nested Spans")
}
Button(
onClick = {
viewModel.triggerCrash()
}
) {
Text("Trigger Crash")
}
OutlinedTextField(
value = customLogText,
onValueChange = { customLogText = it },
label = { Text("Log Message") },
modifier = Modifier.padding(8.dp)
)
Button(
onClick = {
viewModel.triggerCustomLog(customLogText)
},
modifier = Modifier.padding(8.dp)
) {
Text("Send custom log")
}
Spacer(modifier = Modifier.height(16.dp))
OutlinedTextField(
value = customSpanText,
onValueChange = { customSpanText = it },
label = { Text("Span Name") },
modifier = Modifier.padding(8.dp)
)
Button(
onClick = {
viewModel.triggerCustomSpan(customSpanText)
},
modifier = Modifier.padding(8.dp)
) {
Text("Send custom span")
}
Spacer(modifier = Modifier.height(16.dp))
OutlinedTextField(
value = customContextKey,
onValueChange = { customContextKey = it },
label = { Text("LD context key") },
modifier = Modifier.padding(8.dp)
)
Button(
onClick = {
viewModel.identifyLDContext(customContextKey)
},
modifier = Modifier.padding(8.dp)
) {
Text("Identify LD Context")
}
}
}
}
}
}
}