Modernize Architecture and Implement Settings Export/Import - #146
Modernize Architecture and Implement Settings Export/Import#146RajnishKMehta wants to merge 48 commits into
Conversation
- Upgrade Gradle to 9.6.0 and AGP to 9.2.1. - Set target and compile SDK to 37. - Enable Kotlin support and configure Java 21 compatibility. - Remove legacy support-v13 and modernize dependencies. - Update test configuration to modern AndroidX Test methodology. - Add MigrationVerification.kt to set foundation for Kotlin development.
- Update checkout to v6 and setup-java to v5 (JDK 21). - Use gradle/actions/setup-gradle@v4 for efficient caching. - Add pull_request trigger to verify builds on every PR. - Update upload-artifact to v6 with 60 days retention. - Target Ubuntu runner for faster build times.
Update CI workflow to trigger on all branches for pull requests.
- Use buildscript classpath for AGP 9.2.1 and Kotlin 2.3.10. - Leverage AGP 9.0+ built-in Kotlin support (removed explicit plugin apply). - Fix SDK property to compileSdk 37. - Use optimized proguard-android-optimize.txt. - Use stable v4 GitHub Actions for CI. - Fix dummy Kotlin class to avoid direct Activity instantiation. - Verified successful local build and unit tests.
- Split CI into release.yml (push to main) and debug.yml (PRs). - Configure debug build type with applicationIdSuffix ".debug". - Implement dynamic versionCode using GITHUB_RUN_NUMBER in CI. - Set versionNameSuffix for debug builds to include run number. - Ensure 60-day artifact retention. - Refine app/build.gradle for AGP 9.x compatibility.
Updated versionNameSuffix handling for debug build type and enabled resource shrinking for release build.
- Implemented comprehensive Proguard rules in app/proguard-rules.pro to ensure stability with minification. - Updated app/build.gradle.kts to use GITHUB_RUN_NUMBER for versionCode on CI. - Maintained existing minification and resource shrinking settings. - Verified successful local release build.
- Overhaul app/proguard-rules.pro to prevent aggressive shrinking of essential classes (IME, AndroidX, libraries). - Increase Gradle JVM heap size in gradle.properties to resolve CI 'GC thrashing' failure. - Strictly maintain project state as requested.
Set versionCode to a fixed value of 23 and disabled minification for release builds.
Added steps to generate and sign a release APK with a temporary keystore.
Removed signing configuration for the release build type.
- Corrected AndroidManifest.xml structure: moved <uses-library> inside <application> and removed deprecated 'package' attribute. - Fixed Release APK installation by signing release builds with the debug key and disabling minification. - Resolved API 34+ lint error in CodeBoardIME.java by using ContextCompat.registerReceiver with RECEIVER_NOT_EXPORTED flag. - Reverted unwanted changes to versionCode. - Verified successful local builds for both debug and release.
- Implemented Settings export and import functionality in Kotlin (SettingsManager.kt) using JSON format with .codeboard extension. - Integrated Export/Import into SettingsFragment.java using modern ActivityResultLauncher and SAF. - Fixed Release APK installation by signing the release build with the debug key and disabling minification for stability. - Corrected AndroidManifest.xml structure (moved <uses-library> inside <application>). - Resolved API 34+ lint error for broadcast receiver registration in CodeBoardIME.java. - Reverted unwanted dynamic versioning changes.
- Refactored Settings export/import to handle invalid JSON and I/O errors gracefully. - Replaced hardcoded strings with resource-based strings in `app/src/main/res/values/backup_strings.xml`. - Updated `SettingsFragment.java` to display error reasons using `Toast.LENGTH_LONG`. - Improved `SettingsManager.kt` with better error reporting and resource management (try-with-resources equivalent). - Fixed XML entity error in `preferences.xml`. - Maintained previously implemented hybrid API 37 modernization and installation fixes.
- Implemented robust error handling in `SettingsManager.kt` by catching `Throwable` to prevent crashes during malformed JSON imports. - Added file extension validation in `SettingsFragment.java` to restrict imports to `.codeboard` or `.json` files. - Added a 512KB file size limit to prevent memory issues with non-settings files. - Moved all UI strings and the default export filename to `app/src/main/res/values/backup_strings.xml`. - Updated error reporting to use `Toast.LENGTH_LONG` with specific failure reasons. - Maintained previously established hybrid API 37 modernization and installation fixes.
Change JSON output formatting to remove indentation.
- Implemented strict Settings validation in `SettingsValidator.kt` to verify JSON syntax and recognized setting keys. - Restricted file imports to `.codeboard` or `.json` extensions and specific MIME types (`application/x-codeboard`, `application/octet-stream`). - Added 512KB file size limit check in `SettingsFragment.java` using ContentResolver query. - Enhanced error handling in `SettingsManager.kt` by catching `Throwable` to prevent crashes on any malformed input. - Moved all UI messages and the default filename to `backup_strings.xml`. - Updated all error toasts to use `Toast.LENGTH_LONG` for better readability. - Cleaned up JSON export by removing indentation for consistency.
…rror handling - Added SettingsValidator.kt to verify JSON syntax and ensure the file contains valid CodeBoard settings keys. - Implemented file size validation (max 512KB) in SettingsFragment.java before processing. - Restricted export MIME type to application/x-codeboard and import to application/octet-stream and application/x-codeboard. - Added file extension validation (.codeboard or .json) during import. - Wrapped all import/export logic in broad catch blocks to prevent any potential crashes. - Replaced all hardcoded strings with values from backup_strings.xml. - Ensured all error messages are displayed with Toast.LENGTH_LONG. - Refined SettingsManager.kt for better resource management and key validation.
- Deleted SettingsValidator.kt and removed specific key validation to allow any valid JSON field mapping. - Removed file extension (.codeboard/.json) restrictions from the import process. - Refined SettingsManager.kt to use simple JSON syntax validation and handle malformed input gracefully. - Maintained 512KB file size limit for security. - Updated SettingsFragment.java to support all file types while maintaining specific MIME type hints for the system picker. - Ensured all UI strings remain externalized in backup_strings.xml. - Maintained Toast.LENGTH_LONG for error reporting.
Removed file extensions from export and import settings titles.
Update release signing configuration to use release key if available, fallback to debug key.
Updated release build configuration to enable minification and resource shrinking.
|
Namaste! Here is a PR after almost a year. 😄 First of all, thank you so much for creating CodeBoard. I don't have a laptop or PC, only an Android phone, so this keyboard has been a huge part of my learning journey (I'm still learning 😊). I started coding on my phone, and CodeBoard made that much easier. I probably use the Select All, Copy, Paste, and Cut features hundreds of times every day. What's even more special is that every change in this PR was made using CodeBoard itself, entirely on my Android phone. I used AI to help generate and speed up parts of the code, but I reviewed the changes, made adjustments, tested them, and handled the development workflow on my phone. CodeBoard was my primary development tool throughout the whole process. I really appreciate the work you've put into this project. Thanks again for building such a useful keyboard. I hope this PR is helpful! By the way, I'm curious about one thing: why is CodeBoard only available on the Play Store? Have you ever considered publishing it on GitHub Releases or F-Droid as well? |
|
One more thing 🙂 If you're interested in publishing CodeBoard on GitHub Releases, I'd be happy to help set up the automation for it. I've already added a GitHub Actions workflow that builds a debug APK for every PR to verify that the project still builds successfully: If you'd like, I can also help set up a release workflow that automatically builds and uploads signed APKs to GitHub Releases whenever a new version is tagged. Play Store publishing can also be automated through CI/CD. I haven't implemented that part myself yet, but I'd be happy to work on it as well. I can also help with publishing the app on F-Droid. I've already gone through the process for my own app, DhwaniControl, and my merge request is here: Of course, only if you're interested. I'd be happy to contribute. 🙂 |
46899ff to
83a10e2
Compare
This Pull Request modernized the legacy Java codebase and introduces a new Settings Backup & Restore feature.
Key Changes:
build.gradle,settings.gradle) to Kotlin DSL (.kts) and upgraded Gradle to 9.6.0 with AGP 9.2.1.CodeBoardIME.javato useContextCompatwith explicit export flags for API 34+ compliance.AndroidManifest.xmlstructure and ensuring proper signing.Close #123
Closes #92