mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-02-15 02:02:40 -05:00
disable sleep prefs for non-ESP32 devices
This commit is contained in:
@@ -123,10 +123,9 @@ class UIViewModel @Inject constructor(
|
||||
|
||||
var positionBroadcastSecs: Int?
|
||||
get() {
|
||||
_deviceConfig.value?.position?.let {
|
||||
if (it.positionBroadcastSecs > 0) return it.positionBroadcastSecs
|
||||
_deviceConfig.value?.position?.positionBroadcastSecs?.let {
|
||||
// These default values are borrowed from the device code.
|
||||
return 15 * 60
|
||||
return if (it > 0) it else 15 * 60 // default 900 sec
|
||||
}
|
||||
return null
|
||||
}
|
||||
@@ -140,7 +139,13 @@ class UIViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
var lsSleepSecs: Int?
|
||||
get() = _deviceConfig.value?.power?.lsSecs
|
||||
get() {
|
||||
_deviceConfig.value?.power?.lsSecs?.let {
|
||||
// These default values are borrowed from the device code.
|
||||
return if (it > 0) return it else 5 * 60 // default 300 sec
|
||||
}
|
||||
return null
|
||||
}
|
||||
set(value) {
|
||||
val config = _deviceConfig.value
|
||||
if (value != null && config != null) {
|
||||
@@ -179,6 +184,9 @@ class UIViewModel @Inject constructor(
|
||||
meshService?.region = value.number
|
||||
}
|
||||
|
||||
// We consider hasWifi = ESP32
|
||||
var isESP32: Boolean = _deviceConfig.value?.hasWifi() == true
|
||||
|
||||
/// hardware info about our local device (can be null)
|
||||
private val _myNodeInfo = MutableLiveData<MyNodeInfo?>()
|
||||
val myNodeInfo: LiveData<MyNodeInfo?> get() = _myNodeInfo
|
||||
|
||||
@@ -43,8 +43,8 @@ class AdvancedSettingsFragment : ScreenFragment("Advanced Settings"), Logging {
|
||||
binding.lsSleepEditText.setText(model.lsSleepSecs.toString())
|
||||
binding.positionBroadcastPeriodView.isEnabled = !model.gpsDisabled
|
||||
binding.positionBroadcastSwitch.isChecked = !model.gpsDisabled
|
||||
binding.lsSleepView.isEnabled = model.isPowerSaving ?: false
|
||||
binding.lsSleepSwitch.isChecked = model.isPowerSaving ?: false
|
||||
binding.lsSleepView.isEnabled = model.isPowerSaving ?: false && model.isESP32
|
||||
binding.lsSleepSwitch.isChecked = model.isPowerSaving ?: false && model.isESP32
|
||||
}
|
||||
|
||||
model.connectionState.observe(viewLifecycleOwner) { connectionState ->
|
||||
@@ -52,7 +52,7 @@ class AdvancedSettingsFragment : ScreenFragment("Advanced Settings"), Logging {
|
||||
binding.positionBroadcastPeriodView.isEnabled = connected && !model.gpsDisabled
|
||||
binding.lsSleepView.isEnabled = connected && model.isPowerSaving ?: false
|
||||
binding.positionBroadcastSwitch.isEnabled = connected
|
||||
binding.lsSleepSwitch.isEnabled = connected
|
||||
binding.lsSleepSwitch.isEnabled = connected && model.isESP32
|
||||
binding.shutdownButton.isEnabled = connected
|
||||
binding.rebootButton.isEnabled = connected
|
||||
}
|
||||
@@ -89,7 +89,6 @@ class AdvancedSettingsFragment : ScreenFragment("Advanced Settings"), Logging {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO - disable all sleep settings for non-ESP32 devices
|
||||
binding.lsSleepEditText.on(EditorInfo.IME_ACTION_DONE) {
|
||||
val str = binding.lsSleepEditText.text.toString()
|
||||
val n = str.toIntOrNull()
|
||||
|
||||
Reference in New Issue
Block a user