Skip to content

Commit

Permalink
Merge pull request #267 from geeksville/dev1.2
Browse files Browse the repository at this point in the history
1.2.14
  • Loading branch information
geeksville authored Mar 24, 2021
2 parents b44a104 + 0425f82 commit 9e5172d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/com/geeksville/mesh/model/Channel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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) })
17 changes: 9 additions & 8 deletions app/src/main/java/com/geeksville/mesh/service/MeshService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ class MeshService : Service(), Logging {

private var radioConfig: RadioConfigProtos.RadioConfig? = null

private var channels = arrayOf<ChannelProtos.Channel>()
private var channels = fixupChannelList(listOf()).toTypedArray()

/// True after we've done our initial node db init
@Volatile
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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<ChannelProtos.Channel>): List<ChannelProtos.Channel> {
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
}

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/geeksville/mesh/ui/ChannelFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,5 @@
<string name="reset">Reset</string>
<string name="are_you_shure_change_default">Are you sure you want to change to the default channel?</string>
<string name="reset_to_defaults">Reset to defaults</string>
<string name="apply">Apply</string>
</resources>

0 comments on commit 9e5172d

Please sign in to comment.