Clean up bugs, threading, and build config#8
Merged
Conversation
* Move dictionary search and SQLite reads/writes off the UI thread to
Dispatchers.IO; precompute the favourites set once per result list
rather than running a COUNT query in onBindViewHolder per row.
* Fix MIME typo "plain/text" → "text/plain" on the email favourites
intent so more clients respond.
* Override onNewIntent so a singleTask launch with INITIAL_WORD picks
up subsequent intents.
* Use cursor.use { } for SQLite reads to release on exception, and
drop the eager compileStatement / @synchronized in favour of the
internal SQLiteDatabase locking.
* Drop the per-launch CRC32 of the bundled dictionary; replace with a
data version flag in SharedPreferences and re-extract only when it
bumps.
* Switch dictionary data dir from getExternalFilesDir to filesDir and
remove the obsolete "no SD card" dialog and strings.
* Trim the cleaned word in linkifyDefinition so spans fire onWordClick
with a usable query, and guard linkifySynonyms against missing space.
* Replace the EditText "special:favourites" sentinel with a Mode enum
+ PreviousState in SearchViewModel; toolbar title reflects mode.
* Replace the TextWatcher impl with doAfterTextChanged; drop the
isFavourited / inFavouritesMode callbacks on the adapter.
* Replace the legacy <fragment> tag with FragmentContainerView and
add the preferences fragment programmatically.
* Drop closeFileHandles teardown in the activity — ArcusApplication
owns the dictionary and the OS reclaims handles on process death.
* Move share / email / synonym hardcoded strings into strings.xml.
* Consolidate everything into the com.arcuscomputing.dictionary
package so there is only one root.
* Migrate to plugins {} blocks + libs.versions.toml.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First of several cleanup PRs based on the analysis of the codebase. Net −15 LOC despite adding the version catalog and Mode/state plumbing.
Summary
Real bugs
Dispatchers.IO(search, favourite reads/writes, clear-all).isFavourited()was a SQLiteCOUNT(*)per row inonBindViewHolder— replaced with a singlegetFavouriteKeys()upfront and aSetlookup in the adapter."plain/text"→"text/plain"on the email-favourites intent.onNewIntentnow handlesINITIAL_WORDfor thesingleTaskactivity (previously only the first intent was used).FavouritesDbHelperfixed withcursor.use { }.data_versionflag in SharedPreferences — re-extract only when bumped.linkifyDefinitionnow trims the cleaned word so onWordClick gets a usable query;linkifySynonymsguards against a missing leading space.Code smells
EditText"special:favourites" sentinel replaced with aModeenum +PreviousStateonSearchViewModel; toolbar title now reflects mode.Send mail...,Share word,Shared by Arcus Dictionary,Synonyms:,My Favourites from Arcus Dictionary) moved tostrings.xml.com.arcuscomputing.dictionary— the orphancom.arcuscomputingpackage is gone.@Synchronizeddropped fromFavouritesDbHelper(SQLite handles internal locking); the eagercompileStatementcache went with it.closeFileHandles()teardown removed from the activity —ArcusApplicationowns the dictionary; OS reclaims handles on process death.Modern paradigms
<fragment>tag inactivity_preferences.xmlreplaced withFragmentContainerView; the fragment is added programmatically.apply plugin:form replaced with aplugins {}block.gradle/libs.versions.tomlversion catalog.getExternalFilesDirtofilesDir; removed the now-obsolete "no SD card" dialog and strings.TextWatcherinterface impl replaced withdoAfterTextChanged.Out of scope (deferred to follow-up PRs)
onResume) — left as-is per request.OFFSET_INDEX/TAGCOUNT_INDEXredundant constants) — left as-is per request.ListAdapter+ DiffUtil) — separate PRs.Test plan
./gradlew assembleDebug— passing locally.text/plainfix).🤖 Generated with Claude Code