mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 04:58:45 +00:00
Add filter functionality to debug log screen.
This commit is contained in:
committed by
Cody Henthorne
parent
f8b18b6ea9
commit
57454a2661
@@ -52,11 +52,13 @@ editor.session.on("changeScrollLeft", showScrollBar);
|
||||
const Range = ace.require("ace/range").Range;
|
||||
const session = editor.getSession();
|
||||
|
||||
let logLines = ""; // Original logLines
|
||||
let input = ""; // Search query input
|
||||
let markers = []; // IDs of highlighted search markers
|
||||
let matchRanges = []; // Ranges of all search matches
|
||||
let matchCount = 0; // Total number of matches
|
||||
let isCaseSensitive = false;
|
||||
let isFiltered = false;
|
||||
|
||||
// Clear all search markers and match info
|
||||
function clearMarkers() {
|
||||
@@ -139,10 +141,34 @@ function onSearchClose() {
|
||||
|
||||
function onToggleCaseSensitive() {
|
||||
isCaseSensitive = !isCaseSensitive;
|
||||
highlightAllMatches(input);
|
||||
(isFiltered) ? onFilter() : highlightAllMatches(input);
|
||||
}
|
||||
|
||||
function onSearchInput(value) {
|
||||
input = value;
|
||||
}
|
||||
|
||||
function onSearch() {
|
||||
highlightAllMatches(input);
|
||||
}
|
||||
|
||||
function onFilter() {
|
||||
isFiltered = true;
|
||||
editor.getSelection().clearSelection();
|
||||
clearMarkers();
|
||||
const filtered = logLines
|
||||
.split("\n")
|
||||
.filter((line) => {
|
||||
const newLine = isCaseSensitive ? line : line.toLowerCase();
|
||||
return newLine.includes(isCaseSensitive ? input : input.toLowerCase());
|
||||
})
|
||||
.join("\n");
|
||||
|
||||
editor.setValue(filtered, -1);
|
||||
}
|
||||
|
||||
function onFilterClose() {
|
||||
isFiltered = false;
|
||||
editor.setValue(logLines, -1);
|
||||
highlightAllMatches(input);
|
||||
}
|
||||
@@ -47,7 +47,7 @@ object DebugLogsViewer {
|
||||
fun presentLines(webview: WebView, lines: String) {
|
||||
// Set the debug log lines
|
||||
val escaped = JSONObject.quote(lines)
|
||||
webview.evaluateJavascript("editor.insert($escaped);", null)
|
||||
webview.evaluateJavascript("editor.insert($escaped); logLines=$escaped;", null)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@@ -61,10 +61,25 @@ object DebugLogsViewer {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun onSearch(webview: WebView, query: String) {
|
||||
fun onSearchInput(webview: WebView, query: String) {
|
||||
webview.evaluateJavascript("onSearchInput('$query')", null)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun onSearch(webview: WebView) {
|
||||
webview.evaluateJavascript("onSearch()", null)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun onFilter(webview: WebView) {
|
||||
webview.evaluateJavascript("onFilter()", null)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun onFilterClose(webview: WebView) {
|
||||
webview.evaluateJavascript("onFilterClose()", null)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun onSearchUp(webview: WebView) {
|
||||
webview.evaluateJavascript("onSearchUp();", null)
|
||||
@@ -90,10 +105,6 @@ object DebugLogsViewer {
|
||||
webview.evaluateJavascript("onSearchClose();", null)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun onFilter(webview: WebView) {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun onEdit(webview: WebView) {
|
||||
readOnly = !readOnly
|
||||
|
||||
Reference in New Issue
Block a user