Skip to content

Commit f1101b9

Browse files
Merge pull request #151 from appdevforall/feat/ADFA-4593-tiers-1-2-tooltips
ADFA-4593: three-tier help — tiers 1 & 2 in-APK tooltip mechanism (scaffold)
2 parents 93d72f0 + 35f9315 commit f1101b9

30 files changed

Lines changed: 1068 additions & 1 deletion

‎controller/app/build.gradle‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,3 +393,47 @@ task syncNativeArtifacts {
393393
}
394394

395395
preBuild.dependsOn syncNativeArtifacts
396+
397+
// ---- ADFA-4593: tooltip three-tier help database ------------------------------
398+
// Source of truth is tools/help/i18n (.pot + <lang>.po compiled to assets/help.db).
399+
// Requires Python + polib for validation/compilation; if Python is absent the
400+
// committed help.db is used and checks are skipped (so local builds never break).
401+
def helpI18nDir = file("tools/help/i18n")
402+
def helpDb = file("src/main/assets/help.db")
403+
def helpRequiredLangs = "es,fr,hi,pt,ru"
404+
def helpPython = (System.getProperty("os.name").toLowerCase().contains("win")
405+
? ["py", "python", "python3"] : ["python3", "python"]).find { name ->
406+
try { def p = "${name} --version".execute(); p.waitFor(); p.exitValue() == 0 }
407+
catch (ignored) { false }
408+
}
409+
410+
if (helpPython == null) {
411+
logger.warn("ADFA-4593: Python not found; using committed help.db and skipping tooltip "
412+
+ "translation checks. Install Python + polib for full enforcement (required in CI).")
413+
} else {
414+
tasks.register("validateHelpTranslations", Exec) {
415+
group = "help"
416+
description = "Fail the build if required tooltip translations are missing."
417+
inputs.dir helpI18nDir
418+
workingDir projectDir
419+
def allowMissing = project.hasProperty("helpAllowMissing") ? project.property("helpAllowMissing") : "false"
420+
commandLine helpPython, "tools/help/validate_help.py", "tools/help/i18n",
421+
"--required", helpRequiredLangs, "--allow-missing", allowMissing
422+
}
423+
tasks.register("buildHelpDb", Exec) {
424+
group = "help"
425+
description = "Compile the tooltip help.db from .po sources."
426+
inputs.dir helpI18nDir
427+
outputs.file helpDb
428+
dependsOn "validateHelpTranslations"
429+
workingDir projectDir
430+
commandLine helpPython, "tools/help/build_help_db.py", "tools/help/i18n", helpDb.absolutePath
431+
}
432+
tasks.register("extractHelpPot", Exec) {
433+
group = "help"
434+
description = "Regenerate strings.pot from the English source (run on demand)."
435+
workingDir projectDir
436+
commandLine helpPython, "tools/help/extract_help_pot.py", "tools/help/i18n"
437+
}
438+
tasks.matching { it.name == "preBuild" }.configureEach { dependsOn "buildHelpDb" }
439+
}
32 KB
Binary file not shown.

‎controller/app/src/main/java/org/iiab/controller/MainActivity.java‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
package org.iiab.controller;
1111

1212
import org.iiab.controller.util.AppExecutors;
13+
import org.iiab.controller.help.TooltipCategory;
14+
import org.iiab.controller.help.TooltipTag;
15+
import org.iiab.controller.help.ViewTooltips;
1316

1417
import android.Manifest;
1518
import android.os.Bundle;
@@ -380,6 +383,12 @@ public boolean onTouch(View v, MotionEvent event) {
380383
headerIcon = findViewById(R.id.header_icon);
381384
ImageButton btnShareQr = findViewById(R.id.btn_share_qr);
382385

386+
// ADFA-4593: three-tier help — attach tier-1/2 tooltips (long-press) to native controls.
387+
ViewTooltips.attachLongPress(themeToggle, TooltipCategory.K2GO, TooltipTag.MAIN_THEME_TOGGLE);
388+
ViewTooltips.attachLongPress(btnSettings, TooltipCategory.K2GO, TooltipTag.MAIN_SETTINGS);
389+
ViewTooltips.attachLongPress(btnShareQr, TooltipCategory.K2GO, TooltipTag.MAIN_SHARE_QR);
390+
ViewTooltips.attachLongPress(versionFooter, TooltipCategory.K2GO, TooltipTag.MAIN_VERSION);
391+
383392
// Listeners
384393
themeToggle.setOnClickListener(v -> toggleTheme());
385394
btnSettings.setOnClickListener(v -> startActivity(new Intent(MainActivity.this, SetupActivity.class)));
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* ============================================================================
3+
* Name : HelpLink.java
4+
* Author : AppDevForAll
5+
* Copyright : Copyright (c) 2026 AppDevForAll
6+
* Description : A tier-3 help link (label + relative URI) shown in a tooltip.
7+
* ============================================================================
8+
*/
9+
package org.iiab.controller.help;
10+
11+
/**
12+
* A tier-3 link. {@link #uri} is a relative path resolved against the tier-3
13+
* help server base URL (see ADFA-4594). Kept relative so the serving host/port
14+
* can change without touching the content database.
15+
*/
16+
public final class HelpLink {
17+
18+
public final String label;
19+
public final String uri;
20+
21+
public HelpLink(String label, String uri) {
22+
this.label = label;
23+
this.uri = uri;
24+
}
25+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* ============================================================================
3+
* Name : TooltipCategory.java
4+
* Author : AppDevForAll
5+
* Copyright : Copyright (c) 2026 AppDevForAll
6+
* Description : Tooltip category constants for the K2Go three-tier help system.
7+
* ============================================================================
8+
*/
9+
package org.iiab.controller.help;
10+
11+
/**
12+
* Categories partition the tooltip namespace (mirrors Code On the Go's model,
13+
* where categories are ide/java/kotlin/xml). K2Go starts with a single native
14+
* category; more can be added later without schema changes.
15+
*/
16+
public final class TooltipCategory {
17+
18+
private TooltipCategory() {}
19+
20+
/** Native K2Go UI (tiers 1 & 2 live in the APK). */
21+
public static final String K2GO = "k2go";
22+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* ============================================================================
3+
* Name : TooltipItem.java
4+
* Author : AppDevForAll
5+
* Copyright : Copyright (c) 2026 AppDevForAll
6+
* Description : Immutable value object for one tooltip: tier-1 summary,
7+
* tier-2 detail, and tier-3 links.
8+
* ============================================================================
9+
*/
10+
package org.iiab.controller.help;
11+
12+
import java.util.ArrayList;
13+
import java.util.List;
14+
15+
public final class TooltipItem {
16+
17+
public final String category;
18+
public final String tag;
19+
/** Tier 1: short summary (HTML). */
20+
public final String summary;
21+
/** Tier 2: longer detail (HTML); may be empty. */
22+
public final String detail;
23+
/** Tier 3: links to full help pages; may be empty. */
24+
public final List<HelpLink> links;
25+
26+
public TooltipItem(String category, String tag, String summary, String detail,
27+
List<HelpLink> links) {
28+
this.category = category;
29+
this.tag = tag;
30+
this.summary = summary;
31+
this.detail = detail;
32+
this.links = (links != null) ? links : new ArrayList<HelpLink>();
33+
}
34+
35+
public boolean hasDetail() {
36+
return detail != null && !detail.trim().isEmpty();
37+
}
38+
39+
public boolean hasLinks() {
40+
return links != null && !links.isEmpty();
41+
}
42+
}

0 commit comments

Comments
 (0)