kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
Merge remote-tracking branch 'root/master' into dev
commit
1ba8e4e1f6
|
@ -74,15 +74,3 @@ data class Channel(
|
|||
return barcodeEncoder.createBitmap(bitMatrix)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* a nice readable description of modem configs
|
||||
*/
|
||||
fun MeshProtos.ChannelSettings.ModemConfig.toHumanString(): String = when (this) {
|
||||
MeshProtos.ChannelSettings.ModemConfig.Bw125Cr45Sf128 -> "Medium range (but fast)"
|
||||
MeshProtos.ChannelSettings.ModemConfig.Bw500Cr45Sf128 -> "Short range (but fast)"
|
||||
MeshProtos.ChannelSettings.ModemConfig.Bw31_25Cr48Sf512 -> "Long range (but slower)"
|
||||
MeshProtos.ChannelSettings.ModemConfig.Bw125Cr48Sf4096 -> "Very long range (but slow)"
|
||||
else -> this.toString()
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package com.geeksville.mesh.model
|
||||
|
||||
import com.geeksville.mesh.MeshProtos
|
||||
import com.geeksville.mesh.R
|
||||
|
||||
enum class ChannelOption(val modemConfig: MeshProtos.ChannelSettings.ModemConfig, val configRes: Int) {
|
||||
SHORT(MeshProtos.ChannelSettings.ModemConfig.Bw125Cr45Sf128, R.string.modem_config_short),
|
||||
MEDIUM(MeshProtos.ChannelSettings.ModemConfig.Bw500Cr45Sf128, R.string.modem_config_medium),
|
||||
LONG(MeshProtos.ChannelSettings.ModemConfig.Bw31_25Cr48Sf512, R.string.modem_config_long),
|
||||
VERY_LONG(MeshProtos.ChannelSettings.ModemConfig.Bw125Cr48Sf4096, R.string.modem_config_very_long)
|
||||
}
|
|
@ -17,9 +17,12 @@ import com.geeksville.analytics.DataPair
|
|||
import com.geeksville.android.GeeksvilleApplication
|
||||
import com.geeksville.android.Logging
|
||||
import com.geeksville.android.hideKeyboard
|
||||
import com.geeksville.mesh.MeshProtos
|
||||
import com.geeksville.mesh.R
|
||||
import com.geeksville.mesh.model.Channel
|
||||
import com.geeksville.mesh.model.ChannelOption
|
||||
import com.geeksville.mesh.model.UIViewModel
|
||||
import com.geeksville.mesh.model.toHumanRes
|
||||
import com.geeksville.mesh.service.MeshService
|
||||
import com.geeksville.util.Exceptions
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
|
@ -59,7 +62,7 @@ class ChannelFragment : ScreenFragment("Channel"), Logging {
|
|||
private fun onEditingChanged() {
|
||||
val isEditing = editableCheckbox.isChecked
|
||||
|
||||
channelOptions.isEnabled = false // Not yet ready
|
||||
channelOptions.isEnabled = isEditing
|
||||
shareButton.isEnabled = !isEditing
|
||||
channelNameView.isEnabled = isEditing
|
||||
if (isEditing) // Dim the (stale) QR code while editing...
|
||||
|
@ -91,11 +94,12 @@ class ChannelFragment : ScreenFragment("Channel"), Logging {
|
|||
}
|
||||
|
||||
onEditingChanged() // we just locked the gui
|
||||
|
||||
val modemConfigs = ChannelOption.values()
|
||||
val modemConfigList = modemConfigs.map { getString(it.configRes) }
|
||||
val adapter = ArrayAdapter(
|
||||
requireContext(),
|
||||
R.layout.dropdown_menu_popup_item,
|
||||
arrayOf("Item 1", "Item 2", "Item 3", "Item 4")
|
||||
modemConfigList
|
||||
)
|
||||
|
||||
filled_exposed_dropdown.setAdapter(adapter)
|
||||
|
@ -163,6 +167,8 @@ class ChannelFragment : ScreenFragment("Channel"), Logging {
|
|||
newSettings.psk = ByteString.copyFrom(Channel.channelDefaultKey)
|
||||
}
|
||||
|
||||
val selectedChannelOptionString = filled_exposed_dropdown.editableText.toString()
|
||||
newSettings.modemConfig = getModemConfig(selectedChannelOptionString)
|
||||
// Try to change the radio, if it fails, tell the user why and throw away their redits
|
||||
try {
|
||||
model.setChannel(newSettings.build())
|
||||
|
@ -200,4 +206,13 @@ class ChannelFragment : ScreenFragment("Channel"), Logging {
|
|||
setGUIfromModel()
|
||||
})
|
||||
}
|
||||
|
||||
private fun getModemConfig(selectedChannelOptionString: String): MeshProtos.ChannelSettings.ModemConfig {
|
||||
for (item in ChannelOption.values()) {
|
||||
if (getString(item.configRes) == selectedChannelOptionString)
|
||||
return item.modemConfig
|
||||
}
|
||||
|
||||
return MeshProtos.ChannelSettings.ModemConfig.UNRECOGNIZED
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,4 +64,8 @@
|
|||
<string name="pairing_failed_try_again">Le jumelage a échoué, veuillez sélectionner à nouveau</string>
|
||||
<string name="location_disabled">L\'accès à la position est désactivé, ne peut pas fournir de position au mesh.</string>
|
||||
<string name="update_to">Mise à jour vers %s</string>
|
||||
<string name="modem_config_short">Courte distance (rapide)</string>
|
||||
<string name="modem_config_medium">Moyenne distance (rapide)</string>
|
||||
<string name="modem_config_long">Longue distance (plus lent)</string>
|
||||
<string name="modem_config_very_long">Très longue distance (lent)</string>
|
||||
</resources>
|
|
@ -63,4 +63,9 @@
|
|||
<string name="app_too_old">Application too old</string>
|
||||
<string name="must_update">You must update this application on the Google Play store (or Github). It is too old to talk to this radio.</string>
|
||||
<string name="none">None (disable)</string>
|
||||
<string name="modem_config_short">Short range (but fast)</string>
|
||||
<string name="modem_config_medium">Medium range (but fast)</string>
|
||||
<string name="modem_config_long">Long range (but slower)</string>
|
||||
<string name="modem_config_very_long">Very long range (but slow)</string>
|
||||
<string name="modem_config_unrecognized">UNRECOGNIZED</string>
|
||||
</resources>
|
||||
|
|
Ładowanie…
Reference in New Issue