From 10d65379720becbc55b9f0a8a86b3e0402b1f702 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Wed, 24 Mar 2021 14:28:11 +0800 Subject: [PATCH 1/3] Disable the "set default channel" button if already on the default channel --- app/src/main/java/com/geeksville/mesh/model/Channel.kt | 4 ++++ app/src/main/java/com/geeksville/mesh/ui/ChannelFragment.kt | 4 ++-- app/src/main/res/values/strings.xml | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/geeksville/mesh/model/Channel.kt b/app/src/main/java/com/geeksville/mesh/model/Channel.kt index 06855b66a..b07c383f4 100644 --- a/app/src/main/java/com/geeksville/mesh/model/Channel.kt +++ b/app/src/main/java/com/geeksville/mesh/model/Channel.kt @@ -78,6 +78,10 @@ data class Channel( return "#${name}-${suffix}" } + + override fun equals(o: Any?): Boolean = (o is Channel) + && psk.toByteArray() contentEquals o.psk.toByteArray() + && name == o.name } fun xorHash(b: ByteArray) = b.fold(0, { acc, x -> acc xor (x.toInt() and 0xff) }) \ No newline at end of file diff --git a/app/src/main/java/com/geeksville/mesh/ui/ChannelFragment.kt b/app/src/main/java/com/geeksville/mesh/ui/ChannelFragment.kt index a8f5457b1..8caa6b9d6 100644 --- a/app/src/main/java/com/geeksville/mesh/ui/ChannelFragment.kt +++ b/app/src/main/java/com/geeksville/mesh/ui/ChannelFragment.kt @@ -85,7 +85,7 @@ class ChannelFragment : ScreenFragment("Channel"), Logging { // Only let buttons work if we are connected to the radio binding.shareButton.isEnabled = connected - binding.resetButton.isEnabled = connected + binding.resetButton.isEnabled = connected && Channel.defaultChannel != channel binding.editableCheckbox.isChecked = false // start locked if (channel != null) { @@ -185,7 +185,7 @@ class ChannelFragment : ScreenFragment("Channel"), Logging { .setNeutralButton(R.string.cancel) { _, _ -> setGUIfromModel() // throw away any edits } - .setPositiveButton(getString(R.string.accept)) { _, _ -> + .setPositiveButton(R.string.apply) { _, _ -> debug("Switching back to default channel") installSettings(Channel.defaultChannel.settings) } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c91839d96..8e2d4774d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -101,4 +101,5 @@ Reset Are you sure you want to change to the default channel? Reset to defaults + Apply From 2b4b063ca7687cff6135e5451df21c7232c6b558 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Wed, 24 Mar 2021 15:19:26 +0800 Subject: [PATCH 2/3] fix problem noticed by @havealoha, device region not fetched the first time app is run --- .../com/geeksville/mesh/service/MeshService.kt | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/geeksville/mesh/service/MeshService.kt b/app/src/main/java/com/geeksville/mesh/service/MeshService.kt index 9a0d41a98..5f8a075d1 100644 --- a/app/src/main/java/com/geeksville/mesh/service/MeshService.kt +++ b/app/src/main/java/com/geeksville/mesh/service/MeshService.kt @@ -428,7 +428,7 @@ class MeshService : Service(), Logging { private var radioConfig: RadioConfigProtos.RadioConfig? = null - private var channels = arrayOf() + private var channels = fixupChannelList(listOf()).toTypedArray() /// True after we've done our initial node db init @Volatile @@ -781,6 +781,7 @@ class MeshService : Service(), Logging { val mi = myNodeInfo if (mi != null) { val ch = a.getChannelResponse + // add new entries if needed channels[ch.index] = ch debug("Admin: Received channel ${ch.index}") if (ch.index + 1 < mi.maxChannels) { @@ -1314,14 +1315,14 @@ class MeshService : Service(), Logging { /// scan the channel list and make sure it has one PRIMARY channel and is maxChannels long private fun fixupChannelList(lIn: List): List { - val mi = myNodeInfo + val maxChannels = + myNodeInfo?.maxChannels ?: 8 // If we don't have my node info, assume 8 channels var l = lIn - if (mi != null) - while (l.size < mi.maxChannels) { - val b = ChannelProtos.Channel.newBuilder() - b.index = l.size - l += b.build() - } + while (l.size < maxChannels) { + val b = ChannelProtos.Channel.newBuilder() + b.index = l.size + l += b.build() + } return l } From 868ed3f88c43ad69c0d10b5426e9ba5b4a615afa Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Wed, 24 Mar 2021 15:20:27 +0800 Subject: [PATCH 3/3] 1.2.14 --- app/build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 4704ea736..29a6baa4e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -36,9 +36,9 @@ android { defaultConfig { applicationId "com.geeksville.mesh" minSdkVersion 21 // The oldest emulator image I have tried is 22 (though 21 probably works) - targetSdkVersion 30 - versionCode 20213 // format is Mmmss (where M is 1+the numeric major number - versionName "1.2.13" + targetSdkVersion 29 // 30 can't work until an explicit location permissions dialog is added + versionCode 20214 // format is Mmmss (where M is 1+the numeric major number + versionName "1.2.14" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" // per https://developer.android.com/studio/write/vector-asset-studio