diff --git a/app/src/main/java/com/geeksville/mesh/ui/Analytics.kt b/app/src/main/java/com/geeksville/mesh/ui/Analytics.kt new file mode 100644 index 00000000..57fedcb3 --- /dev/null +++ b/app/src/main/java/com/geeksville/mesh/ui/Analytics.kt @@ -0,0 +1,19 @@ +package com.geeksville.mesh.ui + +import androidx.compose.Composable +import androidx.compose.onCommit +import com.geeksville.android.GeeksvilleApplication + +/** + * Track compose screen visibility + */ +@Composable +fun analyticsScreen(name: String) { + onCommit(AppStatus.currentScreen) { + GeeksvilleApplication.analytics.sendScreenView(name) + + onDispose { + GeeksvilleApplication.analytics.endScreenView() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/geeksville/mesh/ui/BTScanScreen.kt b/app/src/main/java/com/geeksville/mesh/ui/BTScanScreen.kt index 4f1f3714..b4b67d22 100644 --- a/app/src/main/java/com/geeksville/mesh/ui/BTScanScreen.kt +++ b/app/src/main/java/com/geeksville/mesh/ui/BTScanScreen.kt @@ -65,6 +65,7 @@ fun BTScanScreen() { val bluetoothAdapter = (context.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager?)?.adapter + analyticsScreen(name = "settings") onCommit(AppStatus.currentScreen) { ScanState.debug("BTScan component active") ScanUIState.selectedMacAddr = RadioInterfaceService.getBondedDeviceAddress(context) diff --git a/app/src/main/java/com/geeksville/mesh/ui/Channel.kt b/app/src/main/java/com/geeksville/mesh/ui/Channel.kt index 6219c047..ab4979ec 100644 --- a/app/src/main/java/com/geeksville/mesh/ui/Channel.kt +++ b/app/src/main/java/com/geeksville/mesh/ui/Channel.kt @@ -73,6 +73,8 @@ class AndroidImage(val bitmap: Bitmap) : Image { @Composable fun ChannelContent(channel: Channel = Channel("Default", 7)) { + analyticsScreen(name = "channel") + val typography = MaterialTheme.typography() val context = ContextAmbient.current diff --git a/app/src/main/java/com/geeksville/mesh/ui/MeshApp.kt b/app/src/main/java/com/geeksville/mesh/ui/MeshApp.kt index 3ab6a3ea..71690ddc 100644 --- a/app/src/main/java/com/geeksville/mesh/ui/MeshApp.kt +++ b/app/src/main/java/com/geeksville/mesh/ui/MeshApp.kt @@ -33,6 +33,8 @@ fun getInitials(name: String): String { @Composable fun HomeContent() { + analyticsScreen(name = "settings") + Column { Row { VectorImage( diff --git a/app/src/main/java/com/geeksville/mesh/ui/Messages.kt b/app/src/main/java/com/geeksville/mesh/ui/Messages.kt index f45a4137..1e4b5685 100644 --- a/app/src/main/java/com/geeksville/mesh/ui/Messages.kt +++ b/app/src/main/java/com/geeksville/mesh/ui/Messages.kt @@ -67,6 +67,8 @@ fun MessageCard(msg: TextMessage, modifier: Modifier = Modifier.None) { @Composable fun MessagesContent() { + analyticsScreen(name = "messages") + Column(modifier = LayoutSize.Fill) { val sidePad = 8.dp diff --git a/app/src/main/java/com/geeksville/mesh/ui/Vectors.kt b/app/src/main/java/com/geeksville/mesh/ui/Vectors.kt index 0ad6c10c..22fb0f5d 100644 --- a/app/src/main/java/com/geeksville/mesh/ui/Vectors.kt +++ b/app/src/main/java/com/geeksville/mesh/ui/Vectors.kt @@ -2,25 +2,23 @@ package com.geeksville.mesh.ui import androidx.annotation.DrawableRes import androidx.compose.Composable -import androidx.ui.core.DensityAmbient import androidx.ui.core.Modifier -import androidx.ui.foundation.Clickable +import androidx.ui.foundation.Icon import androidx.ui.graphics.Color import androidx.ui.graphics.vector.DrawVector import androidx.ui.layout.Container import androidx.ui.layout.LayoutSize -import androidx.ui.material.ripple.Ripple +import androidx.ui.material.IconButton import androidx.ui.res.vectorResource -import androidx.ui.unit.dp @Composable fun VectorImageButton(@DrawableRes id: Int, onClick: () -> Unit) { - Ripple(bounded = false) { - Clickable(onClick = onClick) { - VectorImage(id = id /* , modifier = LayoutSize(40.dp, 40.dp) */) - } + //Ripple(bounded = false) { + IconButton(onClick = onClick) { + Icon(vectorResource(id) /* , modifier = LayoutSize(40.dp, 40.dp) */) } + //} } /* fun AppBarIcon(icon: Image, onClick: () -> Unit) { @@ -40,13 +38,13 @@ fun VectorImage( ) { val vector = vectorResource(id) // WithDensity { - Container( - modifier = modifier + LayoutSize( - vector.defaultWidth, - vector.defaultHeight - ) - ) { - DrawVector(vector, tint) - } + Container( + modifier = modifier + LayoutSize( + vector.defaultWidth, + vector.defaultHeight + ) + ) { + DrawVector(vector, tint) + } // } } diff --git a/geeksville-androidlib b/geeksville-androidlib index b9616763..7ac97ad1 160000 --- a/geeksville-androidlib +++ b/geeksville-androidlib @@ -1 +1 @@ -Subproject commit b9616763f34cf5c09d8e0abe49fb79a5844ce27c +Subproject commit 7ac97ad19f4e32007707c390ff4a858ae05afcd1