From c4cfe727b3b2f9fe6f78773cc9fe433fa399b646 Mon Sep 17 00:00:00 2001 From: geeksville Date: Sat, 15 Feb 2020 14:34:58 -0800 Subject: [PATCH] Begin UI for letting user set name and send texts --- README.md | 7 ++- TODO.md | 6 +- .../geeksville/mesh/MeshUtilApplication.kt | 3 +- .../java/com/geeksville/mesh/ui/MeshApp.kt | 61 +++++++++++++++++++ app/src/main/proto/mesh.options | 2 + app/src/main/proto/mesh.proto | 4 +- .../java/com/geeksville/mesh/ui/UIUnitTest.kt | 18 ++++++ 7 files changed, 94 insertions(+), 7 deletions(-) create mode 100644 app/src/test/java/com/geeksville/mesh/ui/UIUnitTest.kt diff --git a/README.md b/README.md index b211c014..272c982e 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,11 @@ # Meshtastic-Android -This is a tool for using Android with mesh radios. You probably don't want it yet ;-). +This is a tool for using Android with mesh radios. -Questions? kevinh@geeksville.com +This project is currently pre-alpha, but if you have questions please join our chat [![Join the chat at https://gitter.im/Meshtastic/community](https://badges.gitter.im/Meshtastic/community.svg)](https://gitter.im/Meshtastic/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge). + +Soon our first alpha release of will be released here: +[![Download at https://play.google.com/store/apps/details?id=com.geeksville.mesh](https://play.google.com/intl/en_us/badges/static/images/badges/en_badge_web_generic.png)](https://play.google.com/store/apps/details?id=com.geeksville.mesh&referrer=utm_source%3Dappgit%26anid%3Dadmob) ## Analytics setup diff --git a/TODO.md b/TODO.md index 22534777..7f2cb9ee 100644 --- a/TODO.md +++ b/TODO.md @@ -6,6 +6,8 @@ MVP features required for first public alpha * set the radio by using the service * startforegroundservice only if we have a valid radio * if no radio is selected, launch app on the radio select screen +* provide gps location for devices that don't have it +* let user send texts * when we select a new radio, restart the service * show bt scan progress centered and towards the bottom of the screen * get rid of green bar at top @@ -14,6 +16,7 @@ MVP features required for first public alpha * treat macaddrs as the unique id, not the app layer user id * on onStop somehow stop the BT scan (to prevent burning battery) * add alphatest screen at boot +* have the foreground service's notification show a summary of network status, add (individually maskable) notifications for received texts or new positions * prompt user to turnon bluetooth and bind * test bt boot behavior * fix BT device scanning - make a setup screen @@ -32,7 +35,8 @@ MVP features required for first public alpha * test with oldest compatible android in emulator (see below for testing with hardware) * make playstore entry, first public alpha * tell Compose geeks -* tell various vendors & post in forum +* tell various vendors & post in forums +* add play store link with https://developers.google.com/analytics/devguides/collection/android/v4/campaigns#google-play-url-builder and the play icon # Signal alpha release Do this "Signal app compatible" release relatively soon after the alpha release of the android app. diff --git a/app/src/main/java/com/geeksville/mesh/MeshUtilApplication.kt b/app/src/main/java/com/geeksville/mesh/MeshUtilApplication.kt index 7e437e04..304e1d4b 100644 --- a/app/src/main/java/com/geeksville/mesh/MeshUtilApplication.kt +++ b/app/src/main/java/com/geeksville/mesh/MeshUtilApplication.kt @@ -15,8 +15,7 @@ class MeshUtilApplication : GeeksvilleApplication(null, "58e72ccc361883ea502510b // We default to off in the manifest, FIXME turn on only if user approves // leave off when running in the debugger - if (false && !Debug.isDebuggerConnected()) + if (!BuildConfig.DEBUG || !Debug.isDebuggerConnected()) FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(true) - } } \ No newline at end of file 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 84d7e6dd..9dbc2ab3 100644 --- a/app/src/main/java/com/geeksville/mesh/ui/MeshApp.kt +++ b/app/src/main/java/com/geeksville/mesh/ui/MeshApp.kt @@ -4,19 +4,35 @@ import androidx.annotation.DrawableRes import androidx.compose.Composable import androidx.compose.state import androidx.ui.animation.Crossfade +import androidx.ui.core.Clip import androidx.ui.core.Modifier import androidx.ui.core.Text +import androidx.ui.core.TextField import androidx.ui.foundation.VerticalScroller import androidx.ui.foundation.shape.corner.RoundedCornerShape import androidx.ui.graphics.Color +import androidx.ui.input.ImeAction import androidx.ui.layout.* import androidx.ui.material.* import androidx.ui.material.surface.Surface +import androidx.ui.text.TextStyle import androidx.ui.tooling.preview.Preview import androidx.ui.unit.dp +import com.geeksville.android.Logging import com.geeksville.mesh.R +object UILog : Logging + +/// Given a human name, strip out the first letter of the first three words and return that as the initials for +/// that user. +fun getInitials(name: String): String { + val words = name.split(Regex("\\s+")).filter { it.isNotEmpty() }.take(3).map { it.first() } + .joinToString("") + + return words +} + @Composable fun HomeContent() { Column { @@ -36,6 +52,51 @@ fun HomeContent() { Text("Text: ${it.text}") } + val message = state { "text message" } + Surface(color = Color.Yellow) { + Row { + Clip(shape = RoundedCornerShape(15.dp)) { + Padding(padding = 15.dp) { + TextField( + value = message.value, + onValueChange = { message.value = it }, + textStyle = TextStyle( + color = Color.DarkGray + ), + imeAction = ImeAction.Send, + onImeActionPerformed = { + UILog.info("did IME action") + } + ) + } + } + } + } + + val state = state { "fixme bob" } + Surface(color = Color.LightGray) { + Row { + Clip(shape = RoundedCornerShape(15.dp)) { + Padding(padding = 15.dp) { + TextField( + value = state.value, + onValueChange = { state.value = it }, + textStyle = TextStyle( + color = Color.DarkGray + ), + imeAction = ImeAction.Done, + onImeActionPerformed = { + UILog.info("did IME action") + } + ) + } + } + + Text(text = getInitials(state.value)) + } + } + + /* FIXME - doens't work yet - probably because I'm not using release keys // If account is null, then show the signin button, otherwise val context = ambient(ContextAmbient) diff --git a/app/src/main/proto/mesh.options b/app/src/main/proto/mesh.options index 1350a970..2f8fadaf 100644 --- a/app/src/main/proto/mesh.options +++ b/app/src/main/proto/mesh.options @@ -12,6 +12,7 @@ *DeviceState.receive_queue max_count:32 # FIXME, max out based on total SubPacket size And do fragmentation and reassembly (for larger payloads) at the Android layer, not the esp32 layer. +# note: this payload length is ONLY the bytes that are sent inside of the radiohead packet *Data.payload max_size:251 # 128 bit psk key (we don't use 256 bit yet because we want to keep our QR code small) @@ -20,3 +21,4 @@ # MyMessage.name max_size:40 # or fixed_length or fixed_count, or max_count + diff --git a/app/src/main/proto/mesh.proto b/app/src/main/proto/mesh.proto index b63e2006..b55052f4 100644 --- a/app/src/main/proto/mesh.proto +++ b/app/src/main/proto/mesh.proto @@ -295,10 +295,10 @@ message DeviceState { /// We bump up the integer values in this enum to indicate minimum levels of encodings for saved files /// if your file is below the Minimum you should discard it. - Minimum = 11; + Minimum = 12; /// The current value we are using for saved files - Current = 11; + Current = 12; }; /// A version integer used to invalidate old save files when we make incompatible changes diff --git a/app/src/test/java/com/geeksville/mesh/ui/UIUnitTest.kt b/app/src/test/java/com/geeksville/mesh/ui/UIUnitTest.kt new file mode 100644 index 00000000..70e84daf --- /dev/null +++ b/app/src/test/java/com/geeksville/mesh/ui/UIUnitTest.kt @@ -0,0 +1,18 @@ +package com.geeksville.mesh.ui + +import org.junit.Assert +import org.junit.Test + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class UIUnitTest { + @Test + fun initialsGood() { + Assert.assertEquals(getInitials("Kevin Hester"), "KH") + Assert.assertEquals(getInitials(" Kevin Hester Lesser Cat "), "KHL") + Assert.assertEquals(getInitials(" "), "") + } +}