-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f996835
commit f1170dc
Showing
11 changed files
with
126 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
...src/main/kotlin/io/embrace/android/exampleapp/ui/examples/LogMessageAttachmentsExample.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package io.embrace.android.exampleapp.ui.examples | ||
|
||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.Button | ||
import androidx.compose.material3.Checkbox | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.TextField | ||
import androidx.compose.runtime.Composable | ||
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 io.embrace.android.embracesdk.Embrace | ||
import io.embrace.android.embracesdk.Severity | ||
import io.embrace.android.exampleapp.ui.RadioButtonList | ||
import java.util.UUID | ||
|
||
@Composable | ||
fun LogMessageAttachmentsExample() { | ||
var textValue by remember { mutableStateOf("My log message") } | ||
var severityValue by remember { mutableStateOf(Severity.INFO) } | ||
var includeProps by remember { mutableStateOf(true) } | ||
var hostFileOn3rdPartyServer by remember { mutableStateOf(false) } | ||
|
||
TextField(value = textValue, onValueChange = { | ||
textValue = it | ||
}) | ||
RadioButtonList( | ||
items = Severity.entries, | ||
selectedItem = severityValue | ||
) { | ||
severityValue = it | ||
} | ||
|
||
Row { | ||
Checkbox( | ||
checked = includeProps, | ||
onCheckedChange = { | ||
includeProps = it | ||
} | ||
) | ||
Text("Include properties", Modifier.padding(top = 8.dp)) | ||
} | ||
|
||
Row { | ||
Checkbox( | ||
checked = hostFileOn3rdPartyServer, | ||
onCheckedChange = { | ||
hostFileOn3rdPartyServer = it | ||
} | ||
) | ||
Text("Host files on a 3rd party server (not Embrace)", Modifier.padding(top = 8.dp)) | ||
} | ||
Spacer(Modifier.padding(8.dp)) | ||
Button(onClick = { | ||
val properties = when (includeProps) { | ||
true -> mapOf( | ||
"my_custom_key" to "my_custom_value" | ||
) | ||
else -> null | ||
} | ||
|
||
if (hostFileOn3rdPartyServer) { | ||
Embrace.getInstance().logMessage( | ||
message = textValue, | ||
severity = severityValue, | ||
properties = properties, | ||
attachmentId = UUID.randomUUID().toString(), | ||
attachmentUrl = "https://example.com/my-attachment", | ||
) | ||
} else { | ||
Embrace.getInstance().logMessage( | ||
message = textValue, | ||
severity = severityValue, | ||
properties = properties, | ||
attachment = "Hello, world!".toByteArray(), | ||
) | ||
} | ||
}) { | ||
Text("Send Log") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters