diff --git a/controller/app/src/main/java/org/iiab/controller/redesign/LibraryHomeFragment.java b/controller/app/src/main/java/org/iiab/controller/redesign/LibraryHomeFragment.java index e89d8e238..6d942658a 100644 --- a/controller/app/src/main/java/org/iiab/controller/redesign/LibraryHomeFragment.java +++ b/controller/app/src/main/java/org/iiab/controller/redesign/LibraryHomeFragment.java @@ -786,15 +786,14 @@ private void applyState(Card c, int st) { * not a fourth reading here. * *
The card endpoints and the content keys disagree on one name — the Wikipedia card is - * {@code kiwix} and its content type is {@code zim}. That belongs on {@code ContentType} - * as an endpoint field; it is exactly what ADFA-5062 exists to retire, and this adds one - * more instance of it. + * {@code kiwix} and its content type is {@code zim}. That alias now lives on {@code ContentType} + * as an {@code endpoint} field (ADFA-5062), so the lookup is {@code byEndpoint} rather than a + * hand-rolled remap here. */ private boolean contentInFlight(Card c) { if (c == null || c.endpoint == null || passContent == null) return false; - String key = "kiwix".equals(c.endpoint) ? "zim" : c.endpoint; org.iiab.controller.system.domain.ContentType type = - org.iiab.controller.system.domain.ContentType.byKey(key); + org.iiab.controller.system.domain.ContentType.byEndpoint(c.endpoint); return type != null && passContent.isRunning(type); } diff --git a/controller/app/src/main/java/org/iiab/controller/system/domain/ContentType.java b/controller/app/src/main/java/org/iiab/controller/system/domain/ContentType.java index 30f8b0c78..d094cfb2c 100644 --- a/controller/app/src/main/java/org/iiab/controller/system/domain/ContentType.java +++ b/controller/app/src/main/java/org/iiab/controller/system/domain/ContentType.java @@ -40,22 +40,24 @@ public enum ContentType { /** Wikipedia and other ZIM collections, downloaded by the server. */ - ZIM("zim", Operation.ExecutionClass.LIVE), + ZIM("zim", "kiwix", Operation.ExecutionClass.LIVE), /** Gutenberg books, downloaded by the server. */ - BOOKS("books", Operation.ExecutionClass.LIVE), + BOOKS("books", "books", Operation.ExecutionClass.LIVE), /** Kolibri channels, imported by the server. Tens of GB at the top end. */ - COURSES("kolibri", Operation.ExecutionClass.LIVE), + COURSES("kolibri", "kolibri", Operation.ExecutionClass.LIVE), /** Map layers, built by an Ansible runrole under proot. */ - MAPS("maps", Operation.ExecutionClass.STOPPED); + MAPS("maps", "maps", Operation.ExecutionClass.STOPPED); private final String key; + private final String endpoint; private final Operation.ExecutionClass executionClass; - ContentType(String key, Operation.ExecutionClass executionClass) { + ContentType(String key, String endpoint, Operation.ExecutionClass executionClass) { this.key = key; + this.endpoint = endpoint; this.executionClass = executionClass; } @@ -67,6 +69,16 @@ public String key() { return key; } + /** + * The identifier the Home surface uses for this type's platform, which differs from + * {@link #key()} for exactly one type: the Wikipedia card is {@code kiwix} while its + * content key is {@code zim}. Carrying the alias here retires the hand-rolled + * {@code "kiwix" -> "zim"} remap the callers used to keep (ADFA-5062). + */ + public String endpoint() { + return endpoint; + } + public Operation.ExecutionClass executionClass() { return executionClass; } @@ -98,4 +110,20 @@ public static ContentType byKey(String key) { } return null; } + + /** + * @param endpoint a Home-surface platform endpoint (e.g. {@code kiwix}) + * @return the matching type, or {@code null} for an unknown endpoint + */ + public static ContentType byEndpoint(String endpoint) { + if (endpoint == null) { + return null; + } + for (ContentType t : values()) { + if (t.endpoint.equals(endpoint)) { + return t; + } + } + return null; + } }