Skip to content

refactor: extract widget storage behind WidgetRepository interface.#21065

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

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

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

Copy link
Copy Markdown
Contributor

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

@david-allison david-allison left a comment

Copy link
Copy Markdown
Member

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

@david-allison david-allison left a comment

Copy link
Copy Markdown
Member

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

@DoomsCoder DoomsCoder left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 🚀

@criticalAY criticalAY added the Needs Author Reply Waiting for a reply from the original author label May 24, 2026
@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Hello 👋, this PR has had no activity for more than 2 weeks and needs a reply from the author. If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 7 days until this gets closed automatically

@github-actions github-actions Bot added the Stale label Jun 7, 2026
@github-actions github-actions Bot closed this Jun 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Has Conflicts Needs Author Reply Waiting for a reply from the original author Needs Second Approval Has one approval, one more approval to merge Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants