From 4893422911e8ffd8c983b0f057dea79e4f568562 Mon Sep 17 00:00:00 2001 From: Luis Guzman Date: Fri, 21 Aug 2026 06:37:32 -0600 Subject: [PATCH 1/2] ADFA-4884 fix(maps): FQR delete-list X disarms the map trash tool too Follow-up to ADFA-4884 (not reopening it): closing the delete list via its X left the map's trash tool armed, so tapping a region reopened the list -- the two weren't in lockstep. The X now calls __k2goDisarmDelete (clicks the map's trash toggle off when armed), which routes through the existing onDeleteToolState(false) path; the list also hides directly as a fallback. One file, no new strings. --- .../controller/redesign/FqrController.java | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) 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..3e2734d4f 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); } @@ -769,6 +781,16 @@ private static String human(long bytes) { // ADFA-5025: native pushes the existing region names here so fireExtract can reject a // duplicate name synchronously (see the Next handler). "window.__k2goSetRegions=function(arr){try{window.__k2goRegions=arr||[];}catch(e){}};" + + // ADFA-4884 follow-up: native calls this when our list's X is pressed, to turn the map's + // trash tool OFF too (before, X only closed our list and left the tool armed). Only act when + // it's actually armed (crosshair), then click the same toolbar button the user would — that + // reuses the existing click path, which fires onDeleteToolState(false). + "window.__k2goDisarmDelete=function(){try{" + + "var on=host.map&&host.map.getCanvas&&host.map.getCanvas().style.cursor==='crosshair';" + + "if(!on)return false;" + + "var btn=sr.querySelector('[title=\"Choose region to delete\"]');" + + "if(btn){btn.click();return true;}return false;" + + "}catch(e){return false;}};" + // ADFA-5043: native calls this when the user bails out of the estimate/consent step, to cancel // the FQR selection the same way the name dialog's Cancel does. Buttons have no stable id/class // (same as fireExtract), so match by text. We hid the popup on Next, but a programmatic click From 3ac16ca4271e05fd73f72f3f3f1bd5fc777c85fd Mon Sep 17 00:00:00 2001 From: Luis Guzman Date: Fri, 21 Aug 2026 07:35:45 -0600 Subject: [PATCH 2/2] ADFA-4884 refactor(maps): hoist the trash-tool title to one JS var Code-review nit: the map trash-tool button title was matched in two places (the click listener and __k2goDisarmDelete). Extract it to a single DEL_TITLE var so a future title change is one edit, not two. --- .../java/org/iiab/controller/redesign/FqrController.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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 3e2734d4f..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 @@ -734,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';}}" + @@ -770,7 +773,7 @@ private static String human(long bytes) { "for(var i=0;i