Skip to content

Commit 1619008

Browse files
Merge pull request #573 from appdevforall/feat/K2GO-410-help-topic-routing
K2GO-410 feat(help): route the help viewer by topic (wizard to install, Settings to home)
2 parents 46bf92d + 7de5c06 commit 1619008

6 files changed

Lines changed: 153 additions & 4 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* ============================================================================
3+
* Name : HelpEntry.java
4+
* Author : AppDevForAll
5+
* Copyright : Copyright (c) 2026 AppDevForAll
6+
* Description : K2GO-410. Resolve the bundled manual page for a (topic, language) pair.
7+
* ============================================================================
8+
*/
9+
package org.appdevforall.k2go.help.domain;
10+
11+
/**
12+
* Resolves the bundled manual page for a (topic, language) pair: the two axes of the in-app help
13+
* content. Returns a path relative to {@code assets/help/} (e.g. {@code "app-install.html"}); the
14+
* viewer prefixes the WebViewAssetLoader base.
15+
*
16+
* <p>The manual ships English-only today, so {@code languageTag} is accepted but not yet used. When
17+
* localized manuals are added under {@code assets/help/<lang>/}, map the tag to that subdirectory
18+
* HERE, in one place: the {@link HelpTopic} callers and the viewer do not change. This is the
19+
* app-local (assets) path; the box-served tier-3 route lives in {@link Tier3DocsUrl}.
20+
*/
21+
public final class HelpEntry {
22+
23+
private HelpEntry() {}
24+
25+
/**
26+
* The {@code assets/help/}-relative page for a topic.
27+
*
28+
* @param topic the content axis; null resolves to {@link HelpTopic#HOME}
29+
* @param languageTag the language axis (e.g. from the app locale); reserved for future
30+
* localized manuals, ignored today
31+
*/
32+
public static String assetPath(HelpTopic topic, String languageTag) {
33+
HelpTopic t = (topic != null) ? topic : HelpTopic.HOME;
34+
// TODO(K2GO-410 follow-up): when a localized manual exists under assets/help/<lang>/ for
35+
// languageTag, return that subdir + t.fileName(). Single point of change for the language axis.
36+
return t.fileName();
37+
}
38+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* ============================================================================
3+
* Name : HelpTopic.java
4+
* Author : AppDevForAll
5+
* Copyright : Copyright (c) 2026 AppDevForAll
6+
* Description : K2GO-410. The content axis of the in-app manual: which bundled page to open.
7+
* ============================================================================
8+
*/
9+
package org.appdevforall.k2go.help.domain;
10+
11+
/**
12+
* The content axis of the bundled help manual (K2GO-410): which topic page the in-app viewer opens.
13+
* Each constant names a page file under {@code assets/help/}. Pair it with {@link HelpEntry} to get
14+
* the resolved path. This is the app-local (assets) manual, separate from the box-served tier-3
15+
* route in {@link Tier3DocsUrl}.
16+
*/
17+
public enum HelpTopic {
18+
19+
/** The manual landing page ("Welcome and contents"); the default entry. */
20+
HOME("index.html"),
21+
22+
/** The "Install the app" page: the wizard help target while the user is installing. */
23+
INSTALL("app-install.html");
24+
25+
private final String fileName;
26+
27+
HelpTopic(String fileName) {
28+
this.fileName = fileName;
29+
}
30+
31+
/** The page file name within {@code assets/help/}. */
32+
public String fileName() {
33+
return fileName;
34+
}
35+
36+
/** Resolve a topic by its {@link #name()}; returns {@code fallback} for null or an unknown name. */
37+
public static HelpTopic fromName(String name, HelpTopic fallback) {
38+
if (name != null) {
39+
for (HelpTopic t : values()) {
40+
if (t.name().equals(name)) {
41+
return t;
42+
}
43+
}
44+
}
45+
return fallback;
46+
}
47+
}

‎controller/app/src/main/java/org/appdevforall/k2go/redesign/HelpViewerActivity.java‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
import com.google.android.material.appbar.MaterialToolbar;
3232

3333
import org.appdevforall.k2go.R;
34+
import org.appdevforall.k2go.applang.data.AppLocaleController;
35+
import org.appdevforall.k2go.help.domain.HelpEntry;
36+
import org.appdevforall.k2go.help.domain.HelpTopic;
3437
import org.appdevforall.k2go.config.BoxEndpoints;
3538
import org.appdevforall.k2go.portal.data.PdfViewerCatalog;
3639
import org.appdevforall.k2go.portal.domain.NavigationPolicy;
@@ -61,8 +64,10 @@ public class HelpViewerActivity extends AppCompatActivity {
6164

6265
private static final String TAG = "K2Go-Help";
6366
private static final String APPASSETS_HOST = "appassets.androidplatform.net";
64-
private static final String HELP_ENTRY =
65-
"https://" + APPASSETS_HOST + "/assets/help/index.html";
67+
private static final String APPASSETS_BASE = "https://" + APPASSETS_HOST + "/assets/help/";
68+
69+
/** Intent extra: the {@link HelpTopic} name to open. Absent -> HOME (the manual landing). */
70+
public static final String EXTRA_TOPIC = "k2go_help_topic";
6671

6772
private WebView webView;
6873
// pdf.js builds advertised by the box's /pdfjs/manifest.json (loaded off the main thread);
@@ -158,7 +163,12 @@ public void onReceivedError(WebView view, WebResourceRequest request,
158163
downloadFile(Uri.parse(url), contentDisposition, mimetype);
159164
});
160165

161-
webView.loadUrl(HELP_ENTRY);
166+
// K2GO-410: two axes pick the entry page -- the topic (content) from the caller's extra and
167+
// the app language (resolved centrally). HelpEntry maps them to a bundled page; the language
168+
// axis is a no-op until localized manuals ship. Settings passes no topic -> HOME.
169+
HelpTopic topic = HelpTopic.fromName(getIntent().getStringExtra(EXTRA_TOPIC), HelpTopic.HOME);
170+
String entryUrl = APPASSETS_BASE + HelpEntry.assetPath(topic, AppLocaleController.currentTag());
171+
webView.loadUrl(entryUrl);
162172
}
163173

164174
private void downloadFile(Uri uri, String contentDisposition, String mimetype) {

‎controller/app/src/main/java/org/appdevforall/k2go/redesign/WizardHelpButton.java‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ public static void installOn(Activity activity) {
6161
lp.setMargins(m, Math.round(16 * d), m, m); // top margin clears the status bar
6262
root.addView(b, lp);
6363

64+
// K2GO-410: the wizard help opens the install topic; Settings (no extra) opens HOME.
6465
b.setOnClickListener(v ->
65-
activity.startActivity(new Intent(activity, HelpViewerActivity.class)));
66+
activity.startActivity(new Intent(activity, HelpViewerActivity.class)
67+
.putExtra(HelpViewerActivity.EXTRA_TOPIC,
68+
org.appdevforall.k2go.help.domain.HelpTopic.INSTALL.name())));
6669
}
6770
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package org.appdevforall.k2go.help.domain;
2+
3+
import static org.junit.Assert.assertEquals;
4+
5+
import org.junit.Test;
6+
7+
/** Pure-JVM tests for the (topic, language) -> bundled page resolver (K2GO-410). */
8+
public class HelpEntryTest {
9+
10+
@Test public void resolvesTopicToItsPage() {
11+
assertEquals("index.html", HelpEntry.assetPath(HelpTopic.HOME, "en"));
12+
assertEquals("app-install.html", HelpEntry.assetPath(HelpTopic.INSTALL, "en"));
13+
}
14+
15+
@Test public void languageIsNotUsedYet() {
16+
// Single-language manual today: any tag (including null/empty) resolves to the same page.
17+
String en = HelpEntry.assetPath(HelpTopic.INSTALL, "en");
18+
assertEquals(en, HelpEntry.assetPath(HelpTopic.INSTALL, "es"));
19+
assertEquals(en, HelpEntry.assetPath(HelpTopic.INSTALL, ""));
20+
assertEquals(en, HelpEntry.assetPath(HelpTopic.INSTALL, null));
21+
}
22+
23+
@Test public void nullTopicResolvesToHome() {
24+
assertEquals("index.html", HelpEntry.assetPath(null, "en"));
25+
}
26+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package org.appdevforall.k2go.help.domain;
2+
3+
import static org.junit.Assert.assertEquals;
4+
import static org.junit.Assert.assertSame;
5+
6+
import org.junit.Test;
7+
8+
/** Pure-JVM tests for the help content axis (K2GO-410). */
9+
public class HelpTopicTest {
10+
11+
@Test public void fileNamesMapToBundledPages() {
12+
assertEquals("index.html", HelpTopic.HOME.fileName());
13+
assertEquals("app-install.html", HelpTopic.INSTALL.fileName());
14+
}
15+
16+
@Test public void fromNameParsesKnownConstant() {
17+
assertSame(HelpTopic.INSTALL, HelpTopic.fromName("INSTALL", HelpTopic.HOME));
18+
}
19+
20+
@Test public void fromNameFallsBackForNullOrUnknown() {
21+
assertSame(HelpTopic.HOME, HelpTopic.fromName(null, HelpTopic.HOME));
22+
assertSame(HelpTopic.HOME, HelpTopic.fromName("does-not-exist", HelpTopic.HOME));
23+
assertSame(HelpTopic.INSTALL, HelpTopic.fromName("nope", HelpTopic.INSTALL));
24+
}
25+
}

0 commit comments

Comments
 (0)