mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
feat: add demo mode for testing and review purposes
- Activates by tapping "None (disable)" 7 times. - Displays a confirmation message when `Demo Mode` is enabled. - Simulates a connection to a Meshtastic device and allows the app to function without requiring real hardware.
This commit is contained in:
parent
16e91c0ebf
commit
ffb402acde
4 changed files with 36 additions and 17 deletions
|
|
@ -290,6 +290,9 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
|
|||
.show()
|
||||
}
|
||||
|
||||
private var tapCount = 0
|
||||
private var lastTapTime: Long = 0
|
||||
|
||||
private fun addDeviceButton(device: BTScanModel.DeviceListEntry, enabled: Boolean) {
|
||||
val b = RadioButton(requireActivity())
|
||||
b.text = device.name
|
||||
|
|
@ -299,6 +302,19 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
|
|||
binding.deviceRadioGroup.addView(b)
|
||||
|
||||
b.setOnClickListener {
|
||||
if (device.fullAddress == "n") {
|
||||
val currentTapTime = System.currentTimeMillis()
|
||||
if (currentTapTime - lastTapTime > TAP_THRESHOLD) {
|
||||
tapCount = 0
|
||||
}
|
||||
lastTapTime = currentTapTime
|
||||
tapCount++
|
||||
|
||||
if (tapCount >= TAP_TRIGGER) {
|
||||
model.showSnackbar("Demo Mode enabled")
|
||||
scanModel.showMockInterface()
|
||||
}
|
||||
}
|
||||
if (!device.bonded) // If user just clicked on us, try to bond
|
||||
binding.scanStatusText.setText(R.string.starting_pairing)
|
||||
b.isChecked = scanModel.onSelected(device)
|
||||
|
|
@ -354,7 +370,7 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
|
|||
// If we are running on an emulator, always leave this message showing so we can test the worst case layout
|
||||
val curRadio = scanModel.selectedAddress
|
||||
|
||||
if (curRadio != null && !scanModel.isMockInterfaceAddressValid) {
|
||||
if (curRadio != null && curRadio != "m") {
|
||||
binding.warningNotPaired.visibility = View.GONE
|
||||
} else if (bluetoothViewModel.enabled.value == true) {
|
||||
binding.warningNotPaired.visibility = View.VISIBLE
|
||||
|
|
@ -449,6 +465,9 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
|
|||
|
||||
companion object {
|
||||
const val SCAN_PERIOD: Long = 10000 // Stops scanning after 10 seconds
|
||||
private const val TAP_TRIGGER: Int = 7
|
||||
private const val TAP_THRESHOLD: Long = 500 // max 500 ms between taps
|
||||
|
||||
}
|
||||
|
||||
private fun Editable.isIPAddress(): Boolean {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue