sforkowany z mirror/meshtastic-android
Formatting
rodzic
757c3867f2
commit
2f7ce57015
|
@ -52,7 +52,6 @@ import com.google.android.gms.common.ConnectionResult
|
|||
import com.google.android.gms.common.GoogleApiAvailability
|
||||
import com.google.android.gms.tasks.Task
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.google.android.material.tabs.TabLayoutMediator
|
||||
import com.google.protobuf.InvalidProtocolBufferException
|
||||
import com.vorlonsoft.android.rate.AppRate
|
||||
|
|
|
@ -17,5 +17,6 @@ enum class ChannelOption(val modemConfig: MeshProtos.ChannelSettings.ModemConfig
|
|||
}
|
||||
return null
|
||||
}
|
||||
val defaultMinBroadcastPeriod = VERY_LONG.minBroadcastPeriodSecs
|
||||
}
|
||||
}
|
|
@ -20,7 +20,6 @@ class AdvancedSettingsFragment : ScreenFragment("Advanced Settings"), Logging {
|
|||
private val MAX_INT_DEVICE = 0xFFFFFFFF
|
||||
private var _binding: AdvancedSettingsBinding? = null
|
||||
|
||||
// This property is only valid between onCreateView and onDestroyView.
|
||||
private val binding get() = _binding!!
|
||||
|
||||
private val model: UIViewModel by activityViewModels()
|
||||
|
@ -52,17 +51,19 @@ class AdvancedSettingsFragment : ScreenFragment("Advanced Settings"), Logging {
|
|||
val n = textEdit.text.toString().toIntOrNull()
|
||||
val minBroadcastPeriodSecs =
|
||||
ChannelOption.fromConfig(model.radioConfig.value?.channelSettings?.modemConfig)?.minBroadcastPeriodSecs
|
||||
?: 9000
|
||||
info("edit broadcast $n min $minBroadcastPeriodSecs")
|
||||
?: ChannelOption.defaultMinBroadcastPeriod
|
||||
|
||||
if (n != null && n < MAX_INT_DEVICE && (n == 0 || n >= minBroadcastPeriodSecs)) {
|
||||
model.positionBroadcastSecs = n
|
||||
} else {
|
||||
// restore the value in the edit field
|
||||
textEdit.setText(model.positionBroadcastSecs.toString())
|
||||
val errorText = when {
|
||||
(n == null || n < 0 || n >= MAX_INT_DEVICE) -> "Bad value: ${textEdit.text.toString()}"
|
||||
else -> getString(R.string.broadcast_period_too_small).format(minBroadcastPeriodSecs)
|
||||
}
|
||||
val errorText =
|
||||
if (n == null || n < 0 || n >= MAX_INT_DEVICE)
|
||||
"Bad value: ${textEdit.text.toString()}"
|
||||
else
|
||||
getString(R.string.broadcast_period_too_small).format(minBroadcastPeriodSecs)
|
||||
|
||||
Snackbar.make(requireView(), errorText, Snackbar.LENGTH_LONG).show()
|
||||
}
|
||||
requireActivity().hideKeyboard()
|
||||
|
|
|
@ -34,7 +34,6 @@ import com.geeksville.mesh.R
|
|||
import com.geeksville.mesh.android.bluetoothManager
|
||||
import com.geeksville.mesh.android.usbManager
|
||||
import com.geeksville.mesh.databinding.SettingsFragmentBinding
|
||||
import com.geeksville.mesh.model.ChannelOption
|
||||
import com.geeksville.mesh.model.UIViewModel
|
||||
import com.geeksville.mesh.service.BluetoothInterface
|
||||
import com.geeksville.mesh.service.MeshService
|
||||
|
@ -49,7 +48,6 @@ import com.google.android.gms.location.LocationRequest
|
|||
import com.google.android.gms.location.LocationServices
|
||||
import com.google.android.gms.location.LocationSettingsRequest
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
|
Ładowanie…
Reference in New Issue