kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
feat:add extra filters, including own address (#2183)
rodzic
931d3320e2
commit
03ae071548
|
|
@ -35,11 +35,13 @@ import kotlinx.coroutines.flow.combine
|
|||
import kotlinx.coroutines.flow.stateIn
|
||||
import kotlinx.coroutines.launch
|
||||
import java.text.DateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
import javax.inject.Inject
|
||||
import com.geeksville.mesh.Portnums.PortNum
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import com.geeksville.mesh.repository.datastore.RadioConfigRepository
|
||||
|
||||
data class SearchMatch(
|
||||
val logIndex: Int,
|
||||
|
|
@ -155,6 +157,7 @@ class LogFilterManager {
|
|||
@HiltViewModel
|
||||
class DebugViewModel @Inject constructor(
|
||||
private val meshLogRepository: MeshLogRepository,
|
||||
private val radioConfigRepository: RadioConfigRepository,
|
||||
) : ViewModel(), Logging {
|
||||
|
||||
val meshLog: StateFlow<ImmutableList<UiMeshLog>> = meshLogRepository.getAllLogs()
|
||||
|
|
@ -275,10 +278,19 @@ class DebugViewModel @Inject constructor(
|
|||
private val TIME_FORMAT = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM)
|
||||
}
|
||||
|
||||
val presetFilters = arrayOf(
|
||||
// "!xxxxxxxx", // Dynamically determine the address of the connected node (i.e., messages to us).
|
||||
"!ffffffff", // broadcast
|
||||
) + PortNum.entries.map { it.name } // all apps
|
||||
val presetFilters: List<String>
|
||||
get() = buildList {
|
||||
// Our address if available
|
||||
radioConfigRepository.myNodeInfo.value?.myNodeNum?.let { add("!%08x".format(it)) }
|
||||
// broadcast
|
||||
add("!ffffffff")
|
||||
// decoded
|
||||
add("decoded")
|
||||
// today (locale-dependent short date format)
|
||||
add(DateFormat.getDateInstance(DateFormat.SHORT).format(Date()))
|
||||
// Each app name
|
||||
addAll(PortNum.entries.map { it.name })
|
||||
}
|
||||
|
||||
fun setSelectedLogId(id: String?) { _selectedLogId.value = id }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ internal fun DebugScreen(
|
|||
DebugSearchStateviewModelDefaults(
|
||||
searchState = searchState,
|
||||
filterTexts = filterTexts,
|
||||
presetFilters = viewModel.presetFilters.asList(),
|
||||
presetFilters = viewModel.presetFilters,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@
|
|||
<string name="debug_logs_export">Export Logs</string>
|
||||
<string name="debug_last_messages">500 last messages</string>
|
||||
<string name="debug_filters">Filters</string>
|
||||
<string name="debug_active_filters">Active filters</string>
|
||||
<string name="debug_active_filters">Active filters (Match any)</string>
|
||||
<string name="debug_default_search">Search in logs...</string>
|
||||
<string name="debug_clear">Clear Logs</string>
|
||||
<string name="clear">Clear</string>
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue