feat: add the Midas Settings extension and screen #49

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

Part of #16.

Feature description

Add an in-app settings screen, Midas Settings, to the patched apps. Users can switch individual patch behaviours on and off at runtime, without patching again. The patches stay as they are in Morphe Manager: including a patch adds its hook, and its Midas Settings toggle decides at runtime whether the hook acts.

Which roadmap issues get a toggle is noted in a "Midas Settings" section in each issue. Some things deliberately have no toggle and are always on when their patch is included: ads, tracking SDKs, the forced update and the ad SDK init.

The name must not suggest the screen comes from Morphe (NOTICE §7e, AGENTS.md). "Midas Settings" is fine; "Morphe settings" is not.

Research summary

  • Morphe's own settings framework (YouTube, Reddit) is only partly reusable:
    • the storage core is published as app.morphe:morphe-extensions-library (Setting, BooleanSetting, SharedPreferences morphe_prefs);
    • the UI (AbstractPreferenceFragment, theme utilities, widgets) and the Kotlin settings DSL are not published.
    • Reusing it would also force the extension to be named shared and would carry NOTICE obligations.
    • Decision: write our own small implementation.
  • Neither app ships usable androidx.preference (no PreferenceFragmentCompat). In De Gelderlander, AppCompat and Fragment are obfuscated. So build the screen on framework classes only: android.app.Activity with plain views (Switch, LinearLayout, ScrollView), or the framework's deprecated android.preference.PreferenceFragment.
  • Morphe adds no Activities to the manifest because that breaks root (mount) installs. Our users install the patched XAPK normally, so adding an Activity through a manifest resource patch is fine. Mention the limitation in the docs.

Design

Extension module

  • Copy extensions/extension back from the morphe-patches-template (see AGENTS.md). Use our own package nl.midasvo.extension.

Storage

  • MidasSettings, with SharedPreferences file midas_settings.
  • A typed BooleanSetting(key, defaultValue, restartRequired).
  • An in-memory cache, so hooks can read toggles cheaply on hot paths such as feed filters.

Which toggles exist

The screen must only show toggles for patches that were actually included.

  • Option A (preferred): a shared, unnamed patch-side helper, e.g. midasSettingsPatch, collects toggle definitions from the named patches (key, Dutch title and summary, default, category, restart flag). In finalize, it writes them to res/raw/midas_settings.json. The Activity renders that file.
  • Option B: inject the definitions into an extension method with bytecode.

Screen

nl.midasvo.extension.settings.MidasSettingsActivity:

  • title "Midas Settings";
  • categories, e.g. "Advertenties en promotie", "Pop-ups en meldingen", "Inhoud", "Privacy";
  • a switch row per toggle, with a summary;
  • a "requires restart" hint plus a restart button when such a toggle changed;
  • a footer with the patches version and the repo link.

Strings are Dutch; both apps are Dutch-only.

Manifest

  • A resource patch adds the Activity: exported=false, theme @style/AppTheme (exists in both apps).
  • The screen follows the system dark mode (uiMode), not the app's in-app dark-mode override. That is acceptable for a first version.

Context

  • Hooks need a Context to read settings. Take the application Context lazily from the first hook that has one, or hook Application.onCreate:
    • de Volkskrant: nl.persgroep.edition.application.MainApplication.onCreate;
    • De Gelderlander: com.kubusapp.MainApplication, which already has a static instance accessor.

Build

  • The CI build and release workflows must keep working with an extension module, which needs GitHub Packages (GPR_USER/GPR_KEY).
  • Check that patches-list.json generation still works.

Delivery

Build this together with the first toggle and one entry point, as one vertical slice:

  1. this issue;
  2. #50;
  3. the Volkskrant part of #35 (review prompts) as the first toggle.

The Gelderlander entry point (#51) follows with its first toggle.

Done when

  • Extension module builds; the .mpp contains it.
  • Toggle definitions are only generated for included patches.
  • Build passes; patches apply on 7.52.0 (and 9.21.1 once #51 lands).
  • Device check (after asking):
    • the screen opens from the app's settings;
    • the toggle is stored and survives a restart;
    • the first toggled hook follows it.
  • A "Midas Settings" section in AGENTS.md: how a patch adds a toggle, naming of keys, and default rules.
  • docs/apps/*.md describe the entry points.
Part of #16. ## Feature description Add an in-app settings screen, **Midas Settings**, to the patched apps. Users can switch individual patch behaviours on and off at runtime, without patching again. The patches stay as they are in Morphe Manager: including a patch adds its hook, and its Midas Settings toggle decides at runtime whether the hook acts. Which roadmap issues get a toggle is noted in a "Midas Settings" section in each issue. Some things deliberately have no toggle and are always on when their patch is included: ads, tracking SDKs, the forced update and the ad SDK init. The name must not suggest the screen comes from Morphe (NOTICE §7e, AGENTS.md). "Midas Settings" is fine; "Morphe settings" is not. ## Research summary - Morphe's own settings framework (YouTube, Reddit) is only partly reusable: - the storage core is published as `app.morphe:morphe-extensions-library` (`Setting`, `BooleanSetting`, SharedPreferences `morphe_prefs`); - the UI (`AbstractPreferenceFragment`, theme utilities, widgets) and the Kotlin settings DSL are not published. - Reusing it would also force the extension to be named `shared` and would carry NOTICE obligations. - **Decision: write our own small implementation.** - Neither app ships usable `androidx.preference` (no `PreferenceFragmentCompat`). In De Gelderlander, AppCompat and Fragment are obfuscated. So build the screen on framework classes only: `android.app.Activity` with plain views (`Switch`, `LinearLayout`, `ScrollView`), or the framework's deprecated `android.preference.PreferenceFragment`. - Morphe adds no Activities to the manifest because that breaks root (mount) installs. Our users install the patched XAPK normally, so adding an Activity through a manifest resource patch is fine. Mention the limitation in the docs. ## Design ### Extension module - Copy `extensions/extension` back from the morphe-patches-template (see AGENTS.md). Use our own package `nl.midasvo.extension`. ### Storage - `MidasSettings`, with SharedPreferences file `midas_settings`. - A typed `BooleanSetting(key, defaultValue, restartRequired)`. - An in-memory cache, so hooks can read toggles cheaply on hot paths such as feed filters. ### Which toggles exist The screen must only show toggles for patches that were actually included. - **Option A (preferred):** a shared, unnamed patch-side helper, e.g. `midasSettingsPatch`, collects toggle definitions from the named patches (`key`, Dutch title and summary, default, category, restart flag). In `finalize`, it writes them to `res/raw/midas_settings.json`. The Activity renders that file. - **Option B:** inject the definitions into an extension method with bytecode. ### Screen `nl.midasvo.extension.settings.MidasSettingsActivity`: - title "Midas Settings"; - categories, e.g. "Advertenties en promotie", "Pop-ups en meldingen", "Inhoud", "Privacy"; - a switch row per toggle, with a summary; - a "requires restart" hint plus a restart button when such a toggle changed; - a footer with the patches version and the repo link. Strings are Dutch; both apps are Dutch-only. ### Manifest - A resource patch adds the Activity: `exported=false`, theme `@style/AppTheme` (exists in both apps). - The screen follows the system dark mode (`uiMode`), not the app's in-app dark-mode override. That is acceptable for a first version. ### Context - Hooks need a Context to read settings. Take the application Context lazily from the first hook that has one, or hook `Application.onCreate`: - de Volkskrant: `nl.persgroep.edition.application.MainApplication.onCreate`; - De Gelderlander: `com.kubusapp.MainApplication`, which already has a static instance accessor. ### Build - The CI build and release workflows must keep working with an extension module, which needs GitHub Packages (`GPR_USER`/`GPR_KEY`). - Check that `patches-list.json` generation still works. ## Delivery Build this together with the first toggle and one entry point, as one vertical slice: 1. this issue; 2. #50; 3. the Volkskrant part of #35 (review prompts) as the first toggle. The Gelderlander entry point (#51) follows with its first toggle. ## Done when - [ ] Extension module builds; the `.mpp` contains it. - [ ] Toggle definitions are only generated for included patches. - [ ] Build passes; patches apply on 7.52.0 (and 9.21.1 once #51 lands). - [ ] Device check (after asking): - [ ] the screen opens from the app's settings; - [ ] the toggle is stored and survives a restart; - [ ] the first toggled hook follows it. - [ ] A "Midas Settings" section in AGENTS.md: how a patch adds a toggle, naming of keys, and default rules. - [ ] `docs/apps/*.md` describe the entry points.
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:26 +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#49
No description provided.