Repository navigation
build: upgrade toolchain and libraries, target API 36 - #98
Conversation
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.
There was a problem hiding this comment.
🔵 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
left a comment
There was a problem hiding this comment.
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()) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
It looks like the original switch/case had no default case? So I think that makes the one on the right better? 🤔
There was a problem hiding this comment.
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
What
Upgrade the build toolchain and libraries, and target API 36.
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:
R.idvalues non-final and stops merging libraryRattributes into the appR. The threeonOptionsItemSelectedswitches become if/else, andApplicationuses Calligraphy's ownR.attr.fontPath.android:tintbecomesapp:tint.DownloadReceiverregisters as exported, because DownloadManager sends its broadcasts from another app.NetworkManagerregisters as not exported.BaseActivity.applySystemBarInsetspads the toolbar and content for edge-to-edge.DownloadReceiveris now exported, so other apps can send itACTION_NOTIFICATION_CLICKED, which opensFavouritesActivity. That was already possible before Android 14.Evidence
./gradlew buildpasses. On an API 36 emulator,DictionaryAndroidUnitTestpasses 12 of 12 andNZSLDictionaryTestpasses 5 of 5. Five tests inFavouritesRepositoryTestandFavouritesActivityTestfail, 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.