Skip to content

build: upgrade toolchain and libraries, target API 36 - #98

Merged
joshmcarthur merged 3 commits into
mainfrom
modernise-dependencies
Nov 5, 2026
Merged

joshmcarthur merged 3 commits into
mainfrom
modernise-dependencies

Conversation

@joshmcarthur

Copy link
Copy Markdown
Contributor

What

Upgrade the build toolchain and libraries, and target API 36.

  • Gradle 6.9.4 to 9.8.2, AGP 4.2.2 to 9.5.0, JDK 17
  • Material 1.1.0 to 1.14.0, androidx.test 1.7.0, Espresso 3.7.0
  • compileSdk 36, targetSdk 36, minSdk 14 to 23 (drops Android 4.0 to 5.1)
  • Handle the Android 14 to 16 behaviour changes: receiver export flags, edge-to-edge insets
  • The Favourites screen now uses a Toolbar instead of a window action bar

Why

The old toolchain cannot build against a current SDK. Google Play requires targetSdk 36 for updates. Material 1.14.0 needs minSdk 23 and compileSdk 35 or later, so minSdk moves with it.

Calligraphy3 and ViewPump are kept. Both are the latest versions, and they still apply the Montserrat fonts on API 36.

How

Three commits, each builds on its own:

  1. Toolchain. AGP 9 makes R.id values non-final and stops merging library R attributes into the app R. The three onOptionsItemSelected switches become if/else, and Application uses Calligraphy's own R.attr.fontPath.
  2. Libraries and minSdk 23. Jetifier is removed. android:tint becomes app:tint.
  3. targetSdk 36. DownloadReceiver registers as exported, because DownloadManager sends its broadcasts from another app. NetworkManager registers as not exported. BaseActivity.applySystemBarInsets pads the toolbar and content for edge-to-edge.

DownloadReceiver is now exported, so other apps can send it ACTION_NOTIFICATION_CLICKED, which opens FavouritesActivity. That was already possible before Android 14.

Evidence

./gradlew build passes. On an API 36 emulator, DictionaryAndroidUnitTest passes 12 of 12 and NZSLDictionaryTest passes 5 of 5. Five tests in FavouritesRepositoryTest and FavouritesActivityTest fail, and they fail the same way on the first commit. A real download completed and refreshed the favourites list through the exported receiver. The main, word and favourites screens lay out correctly under the system bars.

Not checked: offline video playback, and screenshots against a real API 33 device.

The Play Store requires targeting API 36, and the old toolchain
(Gradle 6.9.4, AGP 4.2.2, jcenter) cannot get there. This commit only
moves the toolchain; compileSdk, targetSdk and minSdk are unchanged.

- Gradle wrapper 9.8.2 (AGP 9.5 needs 9.6 or later)
- Replace jcenter() with mavenCentral()
- Move the package name into the app `namespace`
- Merge the duplicate dependencies blocks
- Use proguard-android-optimize.txt, as AGP 9 requires (minify is off,
  so release behaviour is unchanged)
- CI: JDK 17, checkout@v4, setup-java@v4

AGP 9 makes R.id values non-final and stops merging library R
attributes into the app R class. The android.nonFinalResIds flag is
ignored in AGP 9, so:
- Convert the three onOptionsItemSelected switches to if/else
- Reference Calligraphy's fontPath through its own R class

Behaviour is unchanged.
Material 1.14.0 needs minSdk 23 and compileSdk 35 or later, so those
move with it. targetSdk stays at 33; compileSdk only changes which
APIs the code compiles against. This drops Android 4.0 to 5.1 devices.

- Material 1.1.0 -> 1.14.0
- androidx.test 1.7.0, ext:junit 1.3.0, Espresso 3.7.0
- compileSdk 36, minSdk 23
- Remove android.enableJetifier; checkJetifier found nothing that needs it
- Use app:tint in the download button layout (new lint error)

Calligraphy and ViewPump still apply Montserrat on API 36, so no
ViewPumpAppCompatDelegate is needed. On an API 36 emulator,
DictionaryAndroidUnitTest and NZSLDictionaryTest pass. Five tests in
FavouritesRepositoryTest and FavouritesActivityTest fail the same way
on the previous commit; they are not caused by this change.
The Play Store requires targetSdk 36. Raising it turns on three
behaviour changes that the app has to handle.

- Runtime receivers: Android 14 requires an exported flag.
  DownloadReceiver is RECEIVER_EXPORTED because DownloadManager sends
  its broadcasts from another app. NetworkManager is
  RECEIVER_NOT_EXPORTED because only the system sends its broadcasts.
- Edge-to-edge: Android 15+ always draws behind the system bars.
  BaseActivity.applySystemBarInsets pads the toolbar below the status
  bar and keeps content clear of the navigation bar, display cutout
  and keyboard. NZSLDictionary and the toolbar screens use it.
- Favourites screen: it used a window action bar, which edge-to-edge
  draws under the status bar. It now has a Toolbar and the default
  AppTheme. The title and menu items are unchanged.
- Remove the unused WindowedAppTheme styles.
- Use the namespace = assignment syntax in app/build.gradle.

DownloadReceiver is now exported, so other apps can send it
ACTION_NOTIFICATION_CLICKED, which opens FavouritesActivity. That was
already possible before Android 14.

Checked on an API 36 emulator: the main, word and favourites screens
lay out correctly, and a real download completes and refreshes the
list. The test results match the previous commit: the same five tests
in FavouritesRepositoryTest and FavouritesActivityTest fail.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Reported validation covers only API 36, leaving older-device inset behavior, keyboard interactions, and offline video playback unverified after the SDK and edge-to-edge migration.

No open issues 🎉

What changed in this PR

Modernizes the Android dictionary app’s build and dependencies for API 36, with receiver registration and layout updates for newer Android behavior.

Changes:

  • Upgrades Gradle, Android Gradle Plugin, libraries, and CI Java; targets API 36 and raises minimum support to API 23.
  • Adds explicit broadcast receiver export flags and shared system-bar, cutout, and keyboard inset handling.
  • Moves Favourites to a Toolbar and adapts resource references and menu handling for the updated toolchain.
File Description
gradlew.bat Refreshes the Windows Gradle launcher.
gradlew Refreshes the POSIX Gradle launcher.
gradle/​wrapper/​gradle-wrapper.properties Selects Gradle 9.8.2 and updates wrapper settings.
gradle.properties Removes Jetifier.
build.gradle Upgrades AGP and replaces JCenter with Maven Central.
app/​src/​main/​res/​values/​styles.xml Removes obsolete window action-bar styles.
app/​src/​main/​res/​layout/​activity_favourites.xml Adds the Favourites Toolbar.
app/​src/​main/​res/​layout/​activity_favourites__download_button.xml Uses AppCompat image tinting.
app/​src/​main/​java/​com/​hewgill/​android/​nzsldict/​NZSLDictionary.java Applies insets and supports non-final resource IDs in menu handling.
app/​src/​main/​java/​com/​hewgill/​android/​nzsldict/​NetworkManager.java Registers the connectivity receiver as not exported.
app/​src/​main/​java/​com/​hewgill/​android/​nzsldict/​FavouritesActivity.java Initializes the Toolbar and updates menu handling.
app/​src/​main/​java/​com/​hewgill/​android/​nzsldict/​DownloadReceiver.java Registers the download receiver as exported.
app/​src/​main/​java/​com/​hewgill/​android/​nzsldict/​BaseActivity.java Adds shared inset handling and updates menu dispatch.
app/​src/​main/​java/​com/​hewgill/​android/​nzsldict/​Application.java References Calligraphy’s font attribute directly.
app/​src/​main/​AndroidManifest.xml Removes the package declaration and Favourites theme override.
app/​build.gradle Sets the namespace and SDK levels; consolidates and upgrades dependencies.
.github/​workflows/​android.yml Updates workflow actions and switches CI to JDK 17.

Review effort: Balanced

@jonholdsworth jonholdsworth left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Lot of changes, but they seem sensible in light of the context document.
Nothing too systemic, most of it seems front end.
And it builds! 🙂


@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {

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.

question: is this just a style thing...?

it's been years since I've written Java, but if this was working previously I'm not seeing a change to suggest why this is needed beyond style?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It looks like the original switch/case had no default case? So I think that makes the one on the right better? 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

R.id values used to be final, and are not final anymore, so without this we run into compiler issues since the expressions are dynamic

@joshmcarthur
joshmcarthur merged commit 7695f4c into main Nov 5, 2026
2 checks passed
@joshmcarthur
joshmcarthur deleted the modernise-dependencies branch November 5, 2026 04:17
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.

5 participants