feat(volkskrant): open Midas Settings from the settings menu #50

Closed
opened 2026-10-10 12:43:21 +02:00 by midas · 1 comment
Owner

Part of #16. Depends on #49.

Feature description

Add a row Midas Settings to de Volkskrant's own settings menu that opens MidasSettingsActivity (#49).

Findings (7.52.0, unobfuscated)

The menu is bundled, not server-driven

  • Its rows come from res/raw/service_menu.json.
    • ServiceMenuDataSourceImpl.getServiceMenu reads it with openRawResource.
    • It is parsed into nl.persgroep.edition.domain.data.settings.data.ServiceMenu, then ServiceMenuSection(title, showHeader, items), then ServiceMenuItem(title, subtitle, type, url, extra, submenu).
  • A JSON row looks like {"title","subtitle","type","url","accessory"}.
  • An unknown type becomes ServiceMenuItemType.UNKNOWN, which maps to SettingItemType.Other (SettingsMenuMapperKt.mapToSettingItemType).
  • The filters in SettingsMenuMapper only touch LOG_IN, PROFILE/LOG_OUT, DARKMODE, DEVELOPER_MENU and READ_STATE, so they don't remove such a row.

Click path

  1. SettingsMenuViewModel.onSettingItemClicked(SettingsItem) emits NavigationEvent.Url(url, title) for Other rows with a url.
  2. MainActivity handles that event in private void navigateToUrl(NavHostController, String url, String title). It tries DeeplinkDestinationConverter.toDeeplink(Uri), and otherwise opens the in-app WebView.

Approach

  1. Resource patch. Append a row to service_menu.json, at the end of an appropriate section or as a new section:
    {"title":"Midas Settings","subtitle":"Patch-instellingen","type":"midasSettings","url":"midas-settings://open","accessory":"push"}
    
  2. Bytecode hook. At index 0 of MainActivity.navigateToUrl(Landroidx/navigation/NavHostController;Ljava/lang/String;Ljava/lang/String;)V, call MidasSettings.handleUrl(Activity, String): boolean and return-void when it returns true. The Activity is p0; mind register aliasing.
  3. Fallback, if DPG moves the JSON or serves the menu from a server: append a ServiceMenuSection at the start of SettingsMenuMapper.invoke(ServiceMenu, UserSession) (anchors "Debug menu is activated for: ", "Current user email: ").

Risks

  • If the hook misses, the custom-scheme URL opens a WebView with an error. The fingerprint must fail loudly (method, not methodOrNull).
  • The JSON edit should parse and insert, not do a string replace, so it survives formatting changes.

Not this

The app's hidden developer menu (DebugDeveloperScreen, gated by SettingsMenuMapper.isDeveloperMenuEnabled) can switch backend environments and feature toggles. Don't expose it.

Done when

  • Build passes; patch applied on 7.52.0.
  • Device check (after asking): the row appears in Instellingen and opens Midas Settings; back returns to the menu.
  • Documented in docs/apps/volkskrant.md.
Part of #16. Depends on #49. ## Feature description Add a row **Midas Settings** to de Volkskrant's own settings menu that opens `MidasSettingsActivity` (#49). ## Findings (7.52.0, unobfuscated) ### The menu is bundled, not server-driven - Its rows come from `res/raw/service_menu.json`. - `ServiceMenuDataSourceImpl.getServiceMenu` reads it with `openRawResource`. - It is parsed into `nl.persgroep.edition.domain.data.settings.data.ServiceMenu`, then `ServiceMenuSection(title, showHeader, items)`, then `ServiceMenuItem(title, subtitle, type, url, extra, submenu)`. - A JSON row looks like `{"title","subtitle","type","url","accessory"}`. - An unknown `type` becomes `ServiceMenuItemType.UNKNOWN`, which maps to `SettingItemType.Other` (`SettingsMenuMapperKt.mapToSettingItemType`). - The filters in `SettingsMenuMapper` only touch LOG_IN, PROFILE/LOG_OUT, DARKMODE, DEVELOPER_MENU and READ_STATE, so they don't remove such a row. ### Click path 1. `SettingsMenuViewModel.onSettingItemClicked(SettingsItem)` emits `NavigationEvent.Url(url, title)` for `Other` rows with a url. 2. `MainActivity` handles that event in `private void navigateToUrl(NavHostController, String url, String title)`. It tries `DeeplinkDestinationConverter.toDeeplink(Uri)`, and otherwise opens the in-app WebView. ## Approach 1. **Resource patch.** Append a row to `service_menu.json`, at the end of an appropriate section or as a new section: ```json {"title":"Midas Settings","subtitle":"Patch-instellingen","type":"midasSettings","url":"midas-settings://open","accessory":"push"} ``` 2. **Bytecode hook.** At index 0 of `MainActivity.navigateToUrl(Landroidx/navigation/NavHostController;Ljava/lang/String;Ljava/lang/String;)V`, call `MidasSettings.handleUrl(Activity, String): boolean` and `return-void` when it returns true. The Activity is `p0`; mind register aliasing. 3. **Fallback**, if DPG moves the JSON or serves the menu from a server: append a `ServiceMenuSection` at the start of `SettingsMenuMapper.invoke(ServiceMenu, UserSession)` (anchors "Debug menu is activated for: ", "Current user email: "). ## Risks - If the hook misses, the custom-scheme URL opens a WebView with an error. The fingerprint must fail loudly (`method`, not `methodOrNull`). - The JSON edit should parse and insert, not do a string replace, so it survives formatting changes. ## Not this The app's hidden developer menu (`DebugDeveloperScreen`, gated by `SettingsMenuMapper.isDeveloperMenuEnabled`) can switch backend environments and feature toggles. Don't expose it. ## Done when - [ ] Build passes; patch applied on 7.52.0. - [ ] Device check (after asking): the row appears in Instellingen and opens Midas Settings; back returns to the menu. - [ ] Documented in `docs/apps/volkskrant.md`.
Author
Owner

Done in 8126fee (pre-release v1.6.0-dev.1). Device-tested on de Volkskrant 7.52.0: the Midas Settings row in Instellingen opens the screen, back returns to the menu, toggle persists.

Done in 8126fee (pre-release v1.6.0-dev.1). Device-tested on de Volkskrant 7.52.0: the Midas Settings row in Instellingen opens the screen, back returns to the menu, toggle persists.
midas closed this issue 2026-10-10 13:19:27 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
midas/midas-patches#50
No description provided.