Skip to content

Refactor and modernise app architecture#5

Merged
baz8080 merged 1 commit intomasterfrom
baz8080/refactor-and-modernise
May 4, 2026
Merged

Refactor and modernise app architecture#5
baz8080 merged 1 commit intomasterfrom
baz8080/refactor-and-modernise

Conversation

@baz8080
Copy link
Copy Markdown
Owner

@baz8080 baz8080 commented May 4, 2026

Summary

  • Menu: Deleted IArcusMenu/ArcusMenu (interface with single implementation, tightly coupled to Activity); replaced with standard XML menu resource and inline handlers
  • Constants: Deleted DictionaryConstants bag-of-constants; replaced part-of-speech data with a PartOfSpeech enum, moved remaining constants to their natural homes
  • Dead code removed: ArcusDictionaryMockObjects, ArcusFavouritesActivity, unused Pattern field, onActivityResult (was unreachable), onConfigurationChanged, doWarningNoOp
  • Preferences: Migrated EditPreferencesActivity from deprecated PreferenceActivity to PreferenceFragmentCompat; removed dead useAutoCorrect preference key
  • Initialisation: Made DataFileManager self-contained (stores context at construction); ArcusDictionary.ensureLoaded() no longer needs a context param; ArcusApplication.dictionary is now a by lazy instance property
  • Database: Added SortOrder enum to FavouritesDbHelper (closes SQL injection vector from raw sort strings); fixed isFavourite to use SELECT COUNT(*) instead of SELECT *
  • View layer bug: WordModel.type changed from var to val; removed mutation of the model inside getView()
  • Adapter decoupling: QuickResultListAdapter no longer references ArcusSearchActivity; communicates via a Callbacks interface
  • RecyclerView: Replaced ListView and hand-rolled ListAdapter (12 boilerplate methods) with RecyclerView.Adapter + ViewHolder
  • Coroutines: Replaced Thread/Handler/Runnable/SearchHandler with lifecycleScope + coroutines
  • Back navigation: Replaced deprecated onKeyDown with OnBackPressedCallback
  • ViewModel: Added SearchViewModel for sortMethod and previousWord state

Test plan

  • Search works with debounce (type, verify results appear after pause)
  • Exact match appears at top of results
  • Favourites mode: star/unstar words, sort alpha/date, clear all, email
  • Back from favourites returns to previous search
  • Double-back from search shows exit warning then exits
  • Settings screen opens and preferences persist
  • TTS speaks selected word
  • Share sends word + definition
  • App loads correctly on first install (data file extraction)

🤖 Generated with Claude Code

- Replace IArcusMenu/ArcusMenu with XML menu resource
- Replace DictionaryConstants bag with PartOfSpeech enum and co-located constants
- Delete ArcusDictionaryMockObjects, ArcusFavouritesActivity, dead code throughout
- Migrate EditPreferencesActivity from deprecated PreferenceActivity to PreferenceFragmentCompat
- Make DataFileManager self-contained; remove context threading through ArcusDictionary
- Move ArcusApplication.dictionary to lazy instance property
- Add SortOrder enum to FavouritesDbHelper; fix isFavourite to use COUNT(*)
- Fix WordModel.type mutation in view layer; make type a val
- Decouple QuickResultListAdapter from ArcusSearchActivity via Callbacks interface
- Migrate ListView to RecyclerView with ViewHolder pattern
- Replace Thread/Handler/Runnable with coroutines (lifecycleScope)
- Replace onKeyDown back handling with OnBackPressedCallback
- Add SearchViewModel for sortMethod and previousWord state
- Remove dead onActivityResult, onConfigurationChanged, unused Pattern field

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@baz8080 baz8080 merged commit fb9b544 into master May 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant