feat: hide advertorials in Kubus feeds #191

Closed
midas wants to merge 0 commits from feat/167-kubus-advertorials into dev
Owner

Closes #167

New Kubus patch Hide advertorials (toggle hide_advertorials, "Verberg advertorials", default on, category Ads / "Advertenties en promotie"). It removes advertorials from the home and section feeds.

Builds on #189 (fix/kubus-9.24.1), which is merged into this branch. Merge #189 first; after that this diff only shows the advertorials change.

How advertorials are flagged

  • An advertorial is not a block type of its own. It is an ArticleItem inside an ordinary feed block, with isAdvertorial() true, meaning articleType equals ADVERTORIAL (ignoring case).
  • ArticleItem keeps its class name and isAdvertorial() in every version:
    • up to 9.23.x: com.popular.core.model.data.ArticleItem (Tubantia 9.22.0 decompile; the 9.21.1 dex has the same strings)
    • from 9.24.1 on: com.kubusapp.feature.sections.model.ArticleItem, a kotlinx.serialization class (9.24.1 decompile and dex)
  • The blocks that hold articles are renamed from 9.24.1 on (pu2 CarouselTeaser, bp5 DossierTeaser, fb2 BreakingNewsTeaser, jhb/omj Mini-/VideoCarouselTeaser, ...).

Design

  • In the extension, KubusAdvertorials.strip is the last rule of the existing shared feed teaser filter (KubusContentFilters.filterFeedTeasers). It reads the toggle with isActive(). There is no new smali: the patch only depends on midasSettingsPatch and feedTeaserFilterPatch and registers the toggle.
  • Blocks are not recognised by type. The rule reads every instance field of a block (declared fields, so 9.21.1's private fields too) and finds articles with KubusModels.typeName == ArticleItem.
  • To tell if an article is an advertorial it calls the app's own isAdvertorial(). If that method is ever missing, it falls back to articleType read by name through toString().
  • What happens to each block:
    • Article lists: advertorials are removed. This happens in place, so the raw and defaulted copies (b/e) both change. An immutable list is replaced by a filtered copy in every field that holds it.
    • Advertorial primary article: it is replaced, in all its fields (a/f), by the first editorial item of the block's lists, and that item leaves the list. A mixed row keeps its editorial items.
    • The block is dropped when an advertorial primary has no replacement, or when nothing editorial is left (an emptied carousel). The existing divider cleanup then applies.
  • A block without advertorials is never touched. A block whose fields cannot be read or written is kept, because ContentFilter catches the failure. The hook itself still has its never-throw wrapper.

Verification

Check Result
gradlew buildAndroid (incl. extension contract check) pass
gradlew :extensions:extension:testDebugUnitTest pass (14 new tests in KubusAdvertorialsTest)
check-patches.sh Tubantia 9.24.1 XAPK exit 0, 20/20 Applied incl. Hide advertorials
check-patches.sh AD 9.24.1 XAPK exit 0, 20/20 Applied incl. Hide advertorials
check-patches.sh Tubantia 9.21.1 XAPK exit 0, 20/20 Applied incl. Hide advertorials

The tests cover:

  • named (9.21.1-style, private fields) and renamed (public fields a/b/e/f) blocks
  • the articleType fallback
  • a row left empty, together with its divider
  • a mixed row
  • primary promotion into both copies
  • a primary with no replacement
  • an immutable list
  • toggle off
  • a throwing block and a throwing teaser list

Not device-tested. It is not verified that the feeds carry advertorials right now, or how a promoted primary looks in each block type.

Edition

Edition has no comparable feed flag. Checked in de Volkskrant 7.53.1: ADVERTORIAL is a StyleVariantDto value of the article page only (ArticleStyle.Advertorial, ArticleType.Advertorial, AdvertorialHeader, footer). Apart from Hilt wiring, nothing outside nl.persgroep.edition.article mentions it. Edition is not changed in this PR.

🤖 Generated with Claude Code

Closes #167 New Kubus patch **Hide advertorials** (toggle `hide_advertorials`, "Verberg advertorials", default on, category Ads / "Advertenties en promotie"). It removes advertorials from the home and section feeds. Builds on #189 (`fix/kubus-9.24.1`), which is merged into this branch. Merge #189 first; after that this diff only shows the advertorials change. ## How advertorials are flagged - An advertorial is not a block type of its own. It is an `ArticleItem` inside an ordinary feed block, with `isAdvertorial()` true, meaning `articleType` equals `ADVERTORIAL` (ignoring case). - `ArticleItem` keeps its class name and `isAdvertorial()` in every version: - up to 9.23.x: `com.popular.core.model.data.ArticleItem` (Tubantia 9.22.0 decompile; the 9.21.1 dex has the same strings) - from 9.24.1 on: `com.kubusapp.feature.sections.model.ArticleItem`, a kotlinx.serialization class (9.24.1 decompile and dex) - The blocks that hold articles are renamed from 9.24.1 on (`pu2` CarouselTeaser, `bp5` DossierTeaser, `fb2` BreakingNewsTeaser, `jhb`/`omj` Mini-/VideoCarouselTeaser, ...). ## Design - In the extension, `KubusAdvertorials.strip` is the last rule of the existing shared feed teaser filter (`KubusContentFilters.filterFeedTeasers`). It reads the toggle with `isActive()`. There is no new smali: the patch only depends on `midasSettingsPatch` and `feedTeaserFilterPatch` and registers the toggle. - Blocks are not recognised by type. The rule reads every instance field of a block (declared fields, so 9.21.1's private fields too) and finds articles with `KubusModels.typeName` == `ArticleItem`. - To tell if an article is an advertorial it calls the app's own `isAdvertorial()`. If that method is ever missing, it falls back to `articleType` read by name through `toString()`. - What happens to each block: - Article lists: advertorials are removed. This happens in place, so the raw and defaulted copies (`b`/`e`) both change. An immutable list is replaced by a filtered copy in every field that holds it. - Advertorial primary article: it is replaced, in all its fields (`a`/`f`), by the first editorial item of the block's lists, and that item leaves the list. A mixed row keeps its editorial items. - The block is dropped when an advertorial primary has no replacement, or when nothing editorial is left (an emptied carousel). The existing divider cleanup then applies. - A block without advertorials is never touched. A block whose fields cannot be read or written is kept, because `ContentFilter` catches the failure. The hook itself still has its never-throw wrapper. ## Verification | Check | Result | | --- | --- | | `gradlew buildAndroid` (incl. extension contract check) | pass | | `gradlew :extensions:extension:testDebugUnitTest` | pass (14 new tests in `KubusAdvertorialsTest`) | | `check-patches.sh` Tubantia 9.24.1 XAPK | exit 0, 20/20 Applied incl. Hide advertorials | | `check-patches.sh` AD 9.24.1 XAPK | exit 0, 20/20 Applied incl. Hide advertorials | | `check-patches.sh` Tubantia 9.21.1 XAPK | exit 0, 20/20 Applied incl. Hide advertorials | The tests cover: - named (9.21.1-style, private fields) and renamed (public fields `a`/`b`/`e`/`f`) blocks - the `articleType` fallback - a row left empty, together with its divider - a mixed row - primary promotion into both copies - a primary with no replacement - an immutable list - toggle off - a throwing block and a throwing teaser list **Not device-tested.** It is not verified that the feeds carry advertorials right now, or how a promoted primary looks in each block type. ## Edition Edition has no comparable feed flag. Checked in de Volkskrant 7.53.1: `ADVERTORIAL` is a `StyleVariantDto` value of the article page only (`ArticleStyle.Advertorial`, `ArticleType.Advertorial`, `AdvertorialHeader`, footer). Apart from Hilt wiring, nothing outside `nl.persgroep.edition.article` mentions it. Edition is not changed in this PR. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Kubus 9.24.1 moved its network models from Moshi to kotlinx.serialization:
com.kubus.module.network.model is gone and R8 renames the models (SectionResponse,
AdvertisementPack, ArticleDetailResponse, ShareButtons.Properties, ArticleComponent).
Every patch that named one failed, and so did every patch depending on the two
content filter hooks.

- Patches find a model by its data class toString() literal, which is the same in
  9.21.1-9.24.1, and hook every constructor that builds the object (the first List
  parameter, as 9.24.1 adds a leading int "seen" mask).
- The extension recognises models by KubusModels.typeName (class name, else the
  start of toString()) instead of instanceof on the stubs; Properties and Metadata
  are found by the model type of their value.
- Midas Settings: the profile menu models moved to
  com.kubusapp.feature.domain.data.settings.api.model (reflection in the extension,
  getSections matched by class simple name); the url row opener navigates with
  AppRoute; DeepLinkRouterActivity moved and forwards from onCreate/onNewIntent.
- Copy as Markdown: the toolbar click handler is a function reference bound to
  the view model; the state is built in the view model again.
- Disable tracking: TrackingStarterInitializer no longer casts to FirebaseAnalytics.

Closes #185, #184, #183, #182, #178, #177

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
bump: declare Kubus 9.24.1 as tested
All checks were successful
CI / Build (pull_request) Successful in 1m55s
CI / Patch check (pull_request) Successful in 2m49s
715ad8a8bd
Checked with check-patches.sh on Tubantia, AD, PZC, BN DeStem, Brabants Dagblad and
De Stentor 9.24.1. Eindhovens Dagblad and De Gelderlander are still on 9.23.3 on
APKPure, so 9.24.1 is untested for them.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
New patch Hide advertorials (toggle hide_advertorials, default on): the
shared Kubus feed teaser filter removes ArticleItems whose isAdvertorial()
is true from every teaser block. Advertorials leave article lists, an
advertorial primary article is replaced by the first editorial list item,
and a block with nothing editorial left is dropped. Blocks are read field
by field, so this works on the named Moshi models (9.21.1-9.23.x) and the
renamed kotlinx.serialization models (9.24.1).

Closes #167

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
chore: evidence labels in the advertorials notes
All checks were successful
CI / Build (pull_request) Successful in 1m10s
CI / Patch check (pull_request) Successful in 2m18s
22593fd0ed
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
midas closed this pull request 2026-11-17 15:33:59 +01:00
Author
Owner

Merged into dev through the integration PR #195 (same commits), released as v1.11.0-dev.10.

Merged into dev through the integration PR #195 (same commits), released as v1.11.0-dev.10.
All checks were successful
CI / Build (pull_request) Successful in 1m10s
Required
Details
CI / Patch check (pull_request) Successful in 2m18s

Pull request closed

Sign in to join this conversation.
No description provided.