feat: add copy article as markdown patch for Volkskrant and Gelderlander #54

Merged
midas merged 9 commits from feat/copy-article-markdown into dev 2026-10-10 18:19:16 +02:00
Owner

Refs #52

Samenvatting

Voegt de patch Copy article as Markdown toe voor zowel de Volkskrant (be.persgroep.android.news.mobilevk) als De Gelderlander (com.mecom.gelderlander.nl).
Bij het delen van een artikel wordt een keuzemenu getoond:

  • Kopiëren als Markdown (klembord met Toast-notificatie)
  • Delen als Markdown (Android share sheet met Markdown-tekst)
  • Link delen (de standaard fallback van de app)

Met runtime toggle in Midas Instellingen: copy_article_markdown (categorie Inhoud).


Huidige status & openstaande punten voor Claude

1. de Volkskrant (be.persgroep.android.news.mobilevk)

  • Bytecode hook:
    • Inladen: ArticleDtoMapper.invoke(ArticleDto): Article -> roept VolkskrantArticleExporter.onArticleLoaded(Article) aan.
    • Delen: IntentNavigatorImpl.share(Activity, ShareEvent.ViewData) -> roept VolkskrantArticleExporter.onShare(Activity, ShareEvent.ViewData) aan.
  • Geobserveerd probleem bij praktijktest:
    • De gebruiker testte een artikel over het Openbaar Ministerie in Brazilië, maar de gekopieerde Markdown ging over een ander artikel (indiase autoriteiten).
    • Mogelijke oorzaken:
      1. findArticle probeert het artikel te matchen via shareViewData.getShareMessage().invoke(activity.getResources()). Mogelijk gooit dit een fout of retourneert het iets waar de URL/ID niet in zit, waardoor hij terugviel op lastArticle (het laatst geparseerde artikel in de feed).
      2. Artikelen worden mogelijk niet (of niet allemaal) via ArticleDtoMapper.invoke ingeladen als ze uit een lokale cache (Room / offline storage) komen.
      3. Een alternatief en wellicht veel robuuster hook point voor Volkskrant is ArticleViewModel:
        • ArticleViewModel.updateArticleToolbar(Article) (of ArticleToolbarExtKt.toToolbarModel(Article)) heeft direct het actieve Article van het scherm.
        • Of in ArticleViewModel.onArticleUpdate(Article) / checkMarketingTemplateAndRenderArticle(Article).

2. De Gelderlander (com.mecom.gelderlander.nl)

  • Bytecode hook:
    • Inladen: ArticleDetailResponse.<init>(List, Presentation, Metadata) -> roept GelderlanderArticleExporter.onArticleLoaded(ArticleDetailResponse).
    • Delen: ha2.h(Context, j20) -> roept GelderlanderArticleExporter.onShare(Context, Object) aan.
  • Geobserveerd probleem:
    • In eerdere tests leek de deelknop niets te doen (mogelijk ontbrak het artikel in de cache of faalde context-resolutie).
    • We hebben zojuist onShare(Context, Object) toegevoegd zodat j20 (waar metadata.title en metadata.url op zitten) wordt meegegeven aan findArticle via reflectie (j20.getMetadata().getUrl()).
    • Dit moet nog geverifieerd worden op het apparaat.

Relevante bronbestanden:

  • extensions/extension/src/main/java/nl/midasvo/extension/markdown/HtmlToMarkdown.java
  • extensions/extension/src/main/java/nl/midasvo/extension/markdown/MidasShareHelper.java
  • extensions/extension/src/main/java/nl/midasvo/extension/volkskrant/VolkskrantArticleExporter.java
  • extensions/extension/src/main/java/nl/midasvo/extension/gelderlander/GelderlanderArticleExporter.java
  • patches/src/main/kotlin/nl/midasvo/patches/volkskrant/markdown/CopyArticleMarkdownPatch.kt
  • patches/src/main/kotlin/nl/midasvo/patches/gelderlander/markdown/CopyArticleMarkdownPatch.kt
Refs #52 ## Samenvatting Voegt de patch **Copy article as Markdown** toe voor zowel **de Volkskrant** (`be.persgroep.android.news.mobilevk`) als **De Gelderlander** (`com.mecom.gelderlander.nl`). Bij het delen van een artikel wordt een keuzemenu getoond: - **Kopiëren als Markdown** (klembord met Toast-notificatie) - **Delen als Markdown** (Android share sheet met Markdown-tekst) - **Link delen** (de standaard fallback van de app) Met runtime toggle in Midas Instellingen: `copy_article_markdown` (categorie Inhoud). --- ## Huidige status & openstaande punten voor Claude ### 1. de Volkskrant (`be.persgroep.android.news.mobilevk`) - **Bytecode hook:** - Inladen: `ArticleDtoMapper.invoke(ArticleDto): Article` -> roept `VolkskrantArticleExporter.onArticleLoaded(Article)` aan. - Delen: `IntentNavigatorImpl.share(Activity, ShareEvent.ViewData)` -> roept `VolkskrantArticleExporter.onShare(Activity, ShareEvent.ViewData)` aan. - **Geobserveerd probleem bij praktijktest:** - De gebruiker testte een artikel over het Openbaar Ministerie in Brazilië, maar de gekopieerde Markdown ging over een ander artikel (indiase autoriteiten). - Mogelijke oorzaken: 1. `findArticle` probeert het artikel te matchen via `shareViewData.getShareMessage().invoke(activity.getResources())`. Mogelijk gooit dit een fout of retourneert het iets waar de URL/ID niet in zit, waardoor hij terugviel op `lastArticle` (het laatst geparseerde artikel in de feed). 2. Artikelen worden mogelijk niet (of niet allemaal) via `ArticleDtoMapper.invoke` ingeladen als ze uit een lokale cache (Room / offline storage) komen. 3. Een alternatief en wellicht veel robuuster hook point voor Volkskrant is **`ArticleViewModel`**: - `ArticleViewModel.updateArticleToolbar(Article)` (of `ArticleToolbarExtKt.toToolbarModel(Article)`) heeft direct het actieve `Article` van het scherm. - Of in `ArticleViewModel.onArticleUpdate(Article)` / `checkMarketingTemplateAndRenderArticle(Article)`. ### 2. De Gelderlander (`com.mecom.gelderlander.nl`) - **Bytecode hook:** - Inladen: `ArticleDetailResponse.<init>(List, Presentation, Metadata)` -> roept `GelderlanderArticleExporter.onArticleLoaded(ArticleDetailResponse)`. - Delen: `ha2.h(Context, j20)` -> roept `GelderlanderArticleExporter.onShare(Context, Object)` aan. - **Geobserveerd probleem:** - In eerdere tests leek de deelknop niets te doen (mogelijk ontbrak het artikel in de cache of faalde context-resolutie). - We hebben zojuist `onShare(Context, Object)` toegevoegd zodat `j20` (waar `metadata.title` en `metadata.url` op zitten) wordt meegegeven aan `findArticle` via reflectie (`j20.getMetadata().getUrl()`). - Dit moet nog geverifieerd worden op het apparaat. ### Relevante bronbestanden: - `extensions/extension/src/main/java/nl/midasvo/extension/markdown/HtmlToMarkdown.java` - `extensions/extension/src/main/java/nl/midasvo/extension/markdown/MidasShareHelper.java` - `extensions/extension/src/main/java/nl/midasvo/extension/volkskrant/VolkskrantArticleExporter.java` - `extensions/extension/src/main/java/nl/midasvo/extension/gelderlander/GelderlanderArticleExporter.java` - `patches/src/main/kotlin/nl/midasvo/patches/volkskrant/markdown/CopyArticleMarkdownPatch.kt` - `patches/src/main/kotlin/nl/midasvo/patches/gelderlander/markdown/CopyArticleMarkdownPatch.kt`
feat: add copy article as markdown patch for Volkskrant and Gelderlander
All checks were successful
CI / Build (pull_request) Successful in 3m25s
636369168c
Implements an option to copy or share articles formatted in Markdown
for both de Volkskrant and De Gelderlander (DPG news apps).

Refs #52
Co-Authored-By: Antigravity <antigravity@google.com>
fix: share the on-screen article as Markdown in de Volkskrant and De Gelderlander
All checks were successful
CI / Build (pull_request) Successful in 3m7s
0cea6296f2
De Volkskrant: take the article from the ArticleViewModel whose toolbar
share was clicked (onToolbarAction -> getCurrentArticle) instead of the
last article ArticleDtoMapper produced, which was often a pager neighbour
or prefetch. IntentNavigatorImpl.share only takes over when that click is
pending and the share message contains the article url, so podcast, live
blog and other shares keep the original chooser.

De Gelderlander: the Kubus models keep their class names but R8 renames
their getters (getMetadata() is b()), so every stub call failed at
runtime. The share hook now passes the title and share text that ha2.h
already built, the article is found by url, and the models are read via
KubusModels (getters by return type or by property name from the data
class toString). The stubs are reduced to class shells.

Both: the injected branch was inverted (a handled share also ran the
original chooser, an unhandled one did nothing). The dialog now requires
an Activity; the ViewDataString stub no longer declares invoke(Object),
which does not exist in the app.

Refs #52

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
feat: add a Markdown button to the de Volkskrant article toolbar
All checks were successful
CI / Build (pull_request) Successful in 2m58s
69a5ed328f
Instead of taking over the share button, the article toolbar gets its own
icon (the Markdown mark, CC0) that copies the article as Markdown with one
tap. A shared resource patch adds res/drawable/midas_markdown.xml; the
extension adds a ToolbarAction subclass to the list built in
ArticleToolbarDelegateImpl.createToolbarArticleContent (the app renders any
ToolbarAction from its drawable resource id), and ArticleViewModel
.onToolbarAction consumes the click with getCurrentArticle(), before the
app's own dispatch that doesn't know the action. The share button keeps its
original behaviour.

Refs #52

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drawn in the toolbar style of the apps (1dp round strokes, 24x24) instead of the filled Markdown mark, which looked heavier and smaller than the other icons.

Refs #52

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
feat: add a Markdown button to the De Gelderlander article toolbar
All checks were successful
CI / Build (pull_request) Successful in 2m59s
69f10eccfd
The toolbar view model (obfuscated p40 in 9.21.1, matched by its strings)
hands its state to the extension before publishing it. The extension copies
the share menu item (found by its share_icon drawable) with the Markdown
icon and a new content description string, and gives it a Proxy of the
interaction interface. The click handler consumes that interaction first
and copies the view model's active article, looked up by url in the
ArticleDetailResponse cache. The share button gets its original behaviour
back, and the share dialog in MidasShareHelper is gone.

Refs #52

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fix: include the header picture in De Gelderlander's Markdown
Some checks failed
CI / Build (pull_request) Has been cancelled
9dc6ea3db3
The header picture is not a top-level PictureComponent but the media of a MediaTopComponent or MediaOverlayComponent (which also holds the title); GroupComponents wrap further content. The component list is flattened before rendering, reading wrapper properties by name via KubusModels.value.

Refs #52

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
chore: document the Gelderlander header picture in the Markdown notes
All checks were successful
CI / Build (pull_request) Successful in 2m53s
2c60543ae5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
feat: show videos as a thumbnail linking to the video in the Markdown export
All checks were successful
CI / Build (pull_request) Successful in 3m7s
1aa6ac6b60
Articles only carry a video id. A shared, unnamed patch hooks the
VideoProduction constructors of DPG's video SDK (in both apps) and the
extension caches each video's title, poster, share url and duration. A video
whose metadata the SDK has loaded is copied as [![Video: title](poster)](url)
with its duration; any other video as a link to the article. Nothing extra
is requested. de Volkskrant: VideoBlocks and header video media; De
Gelderlander: VideoProductionComponents.

Refs #52

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merge remote-tracking branch 'origin/dev' into claude/morphe-markdown-copy-patch-665b62
All checks were successful
CI / Build (pull_request) Successful in 3m18s
9aad7d1e27
# Conflicts:
#	docs/apps/gelderlander.md
Sign in to join this conversation.
No description provided.