diff --git a/controller/app/src/main/java/org/iiab/controller/redesign/FqrController.java b/controller/app/src/main/java/org/iiab/controller/redesign/FqrController.java index 99308ab6a..9fea237ca 100644 --- a/controller/app/src/main/java/org/iiab/controller/redesign/FqrController.java +++ b/controller/app/src/main/java/org/iiab/controller/redesign/FqrController.java @@ -180,8 +180,9 @@ public void onExtractRequested(String name, String box) { /** The map's trash tool was toggled; {@code on} is its REAL state (read from the map cursor, not a * parallel flip that could desync/invert). Open the list when it turns on, close it when off. A - * second press dismisses the list (feels native); closing via the sheet's X doesn't change the - * tool, so the next deactivate correctly leaves it closed. */ + * second press dismisses the list (feels native); the sheet's X goes the other way — it disarms + * the tool (see closeDeleteSheetAndTool), which routes back here with on=false, so the two stay + * in lockstep. */ @JavascriptInterface public void onDeleteToolState(boolean on) { if (!active) return; @@ -513,7 +514,7 @@ private void buildDeleteSheet() { int closePad = dp(6); close.setPadding(closePad, closePad, closePad, closePad); close.setContentDescription(activity.getString(R.string.k2go_cancel)); - close.setOnClickListener(v -> hideDeleteSheet()); + close.setOnClickListener(v -> closeDeleteSheetAndTool()); header.addView(close, new LinearLayout.LayoutParams(dp(36), dp(36))); sheet.addView(header); @@ -655,6 +656,17 @@ private void hideDeleteSheet() { deleteSheet = null; searchField = null; listContainer = null; highlight = null; } + /** ADFA-4884 follow-up: closing the list via its X now also disarms the map's trash tool, so the + * tool and the list stay in lockstep (before, X hid the list but left the tool armed, so tapping + * a region reopened it). We ask the map to toggle its tool off — that fires onDeleteToolState(false), + * which hides the list — and also hide here directly so the list still closes if the JS can't reach + * the tool. deleteToolOn is cleared so native state matches even in that fallback. */ + private void closeDeleteSheetAndTool() { + webView.evaluateJavascript("window.__k2goDisarmDelete&&window.__k2goDisarmDelete();", null); + deleteToolOn = false; + hideDeleteSheet(); + } + // ---- helpers ----------------------------------------------------------------------------- /** Padded, transparent container for MaterialAlertDialog setView (the dialog paints the surface). */ private LinearLayout dialogContent(int pad) { return dialogContent(pad, pad); } @@ -722,6 +734,9 @@ private static String human(long bytes) { "if(window.__k2goFqr)return;window.__k2goFqr=true;" + "var host=document.querySelector('maps-black');if(!host||!host.shadowRoot){console.log('K2Go-FQR no shadow');return;}" + "var sr=host.shadowRoot;" + + // ADFA-4884: the map's trash-tool button, matched by its title in one place (the click + // listener reads it; __k2goDisarmDelete finds it to toggle off). + "var DEL_TITLE='Choose region to delete';" + "var EX=/tile-extract\\.py\\s+extract\\s+([a-z0-9_]{1,34})\\s+(-?[\\d.]+,-?[\\d.]+,-?[\\d.]+,-?[\\d.]+)/;" + "var DE=/tile-extract\\.py\\s+delete\\s+([a-z0-9_]{1,34})/;" + "function hidePop(pre){var p=pre.closest?pre.closest('.maplibregl-popup'):null;if(p){p.style.display='none';}}" + @@ -758,7 +773,7 @@ private static String human(long bytes) { "for(var i=0;i