[+] Add option to stop logging
This commit is contained in:
@@ -25,6 +25,8 @@ class MainActivity : AppCompatActivity()
|
|||||||
lateinit var binding: ActivityMainBinding
|
lateinit var binding: ActivityMainBinding
|
||||||
lateinit var influx: InfluxDBClientKotlin
|
lateinit var influx: InfluxDBClientKotlin
|
||||||
|
|
||||||
|
var log = true
|
||||||
|
|
||||||
val enableBluetoothRequest = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
|
val enableBluetoothRequest = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
|
||||||
if (it.resultCode != RESULT_OK) ensureBluetooth()
|
if (it.resultCode != RESULT_OK) ensureBluetooth()
|
||||||
}
|
}
|
||||||
@@ -109,6 +111,10 @@ class MainActivity : AppCompatActivity()
|
|||||||
act<ActivityScan>()
|
act<ActivityScan>()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
R.id.action_stop_logging -> {
|
||||||
|
log = false
|
||||||
|
true
|
||||||
|
}
|
||||||
else -> super.onOptionsItemSelected(item)
|
else -> super.onOptionsItemSelected(item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -143,6 +149,7 @@ class MainActivity : AppCompatActivity()
|
|||||||
|
|
||||||
@SuppressLint("NotifyDataSetChanged")
|
@SuppressLint("NotifyDataSetChanged")
|
||||||
fun addRecord(t: Any) {
|
fun addRecord(t: Any) {
|
||||||
|
if (!log) return
|
||||||
while (records.size > 20) records.remove(0)
|
while (records.size > 20) records.remove(0)
|
||||||
records.add(t)
|
records.add(t)
|
||||||
runOnUiThread { binding.content.recycler.adapter?.notifyDataSetChanged() }
|
runOnUiThread { binding.content.recycler.adapter?.notifyDataSetChanged() }
|
||||||
|
|||||||
@@ -12,4 +12,9 @@
|
|||||||
android:orderInCategory="100"
|
android:orderInCategory="100"
|
||||||
android:title="@string/action_scan"
|
android:title="@string/action_scan"
|
||||||
app:showAsAction="never" />
|
app:showAsAction="never" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_stop_logging"
|
||||||
|
android:orderInCategory="100"
|
||||||
|
android:title="@string/action_stop_logging"
|
||||||
|
app:showAsAction="never" />
|
||||||
</menu>
|
</menu>
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
<string name="app_name">WearSync</string>
|
<string name="app_name">WearSync</string>
|
||||||
<string name="action_settings">Settings</string>
|
<string name="action_settings">Settings</string>
|
||||||
<string name="action_scan">Scan for Devices</string>
|
<string name="action_scan">Scan for Devices</string>
|
||||||
|
<string name="action_stop_logging">Stop Logging on Display</string>
|
||||||
|
|
||||||
<!-- Preference Titles -->
|
<!-- Preference Titles -->
|
||||||
<string name="pref_influx_head">InfluxDB Settings</string>
|
<string name="pref_influx_head">InfluxDB Settings</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user