Skip to content

refactor: extract widget storage behind WidgetRepository interface.#21065

Open
Giyutomioka-SS wants to merge 1 commit into
ankidroid:mainfrom
Giyutomioka-SS:refactor/MetaDB
Open

refactor: extract widget storage behind WidgetRepository interface.#21065
Giyutomioka-SS wants to merge 1 commit into
ankidroid:mainfrom
Giyutomioka-SS:refactor/MetaDB

Conversation

@Giyutomioka-SS
Copy link
Copy Markdown
Contributor

@Giyutomioka-SS Giyutomioka-SS commented May 17, 2026

Note

Assisted-by Claude Opus 4.7
Research & architecture analysis

Decouples WidgetStatus from MetaDB by introducing a WidgetRepository interface.
MetaDbWidgetRepository delegates to the existing MetaDB methods, so there’s no behavior change.

Fixes

Approach

  • Added a WidgetRepository interface for the 3 widget-related MetaDB methods
  • Added MetaDbWidgetRepository as a delegating implementation with constructor-injected context.
  • Initialized it in AnkiDroidApp.onCreate() before ChangeManager.subscribe()
  • Replaced direct MetaDB usage in WidgetStatus.kt with the interface and removed context from fetchSmall() / fetchDue()

How Has This Been Tested?

Local build, test compilation passes.

Checklist

Please, go through these checks before submitting the PR.

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

Copy link
Copy Markdown
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cheers

Comment thread AnkiDroid/src/main/java/com/ichi2/widget/WidgetRepository.kt Outdated
Comment thread AnkiDroid/src/main/java/com/ichi2/anki/AnkiDroidApp.kt Outdated
Comment thread AnkiDroid/src/main/java/com/ichi2/widget/WidgetStatus.kt Outdated
Comment thread AnkiDroid/src/main/java/com/ichi2/widget/WidgetStatus.kt Outdated
Copy link
Copy Markdown
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nitpick, rest looks good

Comment thread AnkiDroid/src/main/java/com/ichi2/anki/AnkiDroidApp.kt Outdated
@david-allison david-allison added Needs Second Approval Has one approval, one more approval to merge and removed Needs Review labels May 17, 2026
Copy link
Copy Markdown
Contributor

@DoomsCoder DoomsCoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Second Approval Has one approval, one more approval to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants