kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
change stress test to a checkbox and only show for debug builds
rodzic
1bff87977e
commit
2736a01d4b
|
@ -929,12 +929,9 @@ class MainActivity : AppCompatActivity(), Logging,
|
|||
val handler: Handler by lazy {
|
||||
Handler(mainLooper)
|
||||
}
|
||||
// Keeps track of pings status so we update the menu properly.
|
||||
var pingRunning: Boolean = false
|
||||
|
||||
override fun onPrepareOptionsMenu(menu: Menu): Boolean {
|
||||
menu.findItem(R.id.start_ping).setVisible(!pingRunning)
|
||||
menu.findItem(R.id.stop_ping).setVisible(pingRunning)
|
||||
menu.findItem(R.id.stress_test).isVisible = BuildConfig.DEBUG // only show stress test for debug builds (for now)
|
||||
return super.onPrepareOptionsMenu(menu)
|
||||
}
|
||||
|
||||
|
@ -960,7 +957,7 @@ class MainActivity : AppCompatActivity(), Logging,
|
|||
fragmentTransaction.commit()
|
||||
return true
|
||||
}
|
||||
R.id.start_ping -> {
|
||||
R.id.stress_test -> {
|
||||
fun postPing() {
|
||||
// Send ping message and arrange delayed recursion.
|
||||
debug("Sending ping")
|
||||
|
@ -975,14 +972,11 @@ class MainActivity : AppCompatActivity(), Logging,
|
|||
)
|
||||
}
|
||||
postPing()
|
||||
pingRunning = true
|
||||
invalidateOptionsMenu()
|
||||
return true
|
||||
}
|
||||
R.id.stop_ping -> {
|
||||
handler.removeCallbacksAndMessages(null)
|
||||
pingRunning = false
|
||||
invalidateOptionsMenu()
|
||||
item.isChecked = !item.isChecked // toggle ping test
|
||||
if(item.isChecked)
|
||||
postPing()
|
||||
else
|
||||
handler.removeCallbacksAndMessages(null)
|
||||
return true
|
||||
}
|
||||
else -> super.onOptionsItemSelected(item)
|
||||
|
|
|
@ -11,6 +11,11 @@
|
|||
android:id="@+id/debug"
|
||||
android:title="@string/debug_panel"
|
||||
app:showAsAction="withText" />
|
||||
<item
|
||||
android:id="@+id/stress_test"
|
||||
android:checkable="true"
|
||||
android:checked="false"
|
||||
android:title="Protocol stress test" />
|
||||
<item
|
||||
android:id="@+id/about"
|
||||
android:title="@string/about"
|
||||
|
|
Ładowanie…
Reference in New Issue