WordPress-Android
WordPress-Android copied to clipboard
Enable non-final resource IDs
Mostly just curious if this will work β Android Studio says it'll speed up build times
To Test:
Regression Notes
-
Potential unintended areas of impact
- TODO
-
What I did to test those areas of impact (or what existing automated tests I relied on)
- TODO
-
What automated tests I added (or what prevented me from doing so)
- TODO
PR Submission Checklist:
- [ ] I have completed the Regression Notes.
- [ ] I have considered adding accessibility improvements for my changes.
- [ ] I have considered if this change warrants user-facing release notes and have added them to
RELEASE-NOTES.txtif necessary.
Testing Checklist (strike-out the not-applying and unnecessary ones):
- [ ] WordPress.com sites and self-hosted Jetpack sites.
- [ ] Portrait and landscape orientations.
- [ ] Light and dark modes.
- [ ] Fonts: Larger, smaller and bold text.
- [ ] High contrast.
- [ ] Talkback.
- [ ] Languages with large words or with letters/accents not frequently used in English.
- [ ] Right-to-left languages. (Even if translation isnβt complete, formatting should still respect the right-to-left layout)
- [ ] Large and small screen sizes. (Tablet and smaller phones)
- [ ] Multi-tasking: Split screen and Pop-up view. (Android 10 or higher)
| 1 Message | |
|---|---|
| :book: | This PR is still a Draft: some checks will be skipped. |
Generated by :no_entry_sign: Danger
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
π² You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
| App Name | WordPress |
|
| Flavor | Jalapeno | |
| Build Type | Debug | |
| Version | pr21179-683099c | |
| Commit | 683099cf45d1bfc900654dd76aa8ff0b87ef152b | |
| Direct Download | wordpress-prototype-build-pr21179-683099c.apk |
π² You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
| App Name | Jetpack |
|
| Flavor | Jalapeno | |
| Build Type | Debug | |
| Version | pr21179-683099c | |
| Commit | 683099cf45d1bfc900654dd76aa8ff0b87ef152b | |
| Direct Download | jetpack-prototype-build-pr21179-683099c.apk |
@jkmassel This PR has been a draft for over a month. Do we need to close it or update it to be ready for review?
@jkmassel This PR has been a draft for over a month. Do we need to close it or update it to be ready for review?
I have no idea if this is how it should be done or even a good idea βΒ I'm hoping @wzieba or @ParaskP7 could weigh in, but I figured I'd ask after the FluxC stuff lands?
π @jkmassel @nbradbury and thanks for the ping!
I have no idea if this is how it should be done or even a good idea.
In terms of keeping up with the standards, this is indeed a good idea. As of AGP 8.0, the default value is true, meaning resource IDs are non-final by default. As such, it is (usually) better to use the default whenever possible.
Mostly just curious if this will work β Android Studio says it'll speed up build times
FYI:
- When set to true (non-final IDs), resource IDs can be dynamically modified at runtime.
- When set to false (final IDs), resource IDs are constants and cannot be changed at runtime.
Performance wise, non-final IDs could actually have a slight performance impact, as the values need to be looked up at runtime rather than being inlined as constants. However, this impact is generally minimal in most applications. Thus, I wouldn't worry too much about that.
PS: This became an AGP default because if has the potential for build time improvements and allowing for more flexible runtime resource loading and manipulation.
NOTE: If you proceed with this change I would recommend the following:
- When updating an
switchstatements withif/else, to do it via AS and via automatic refactoring. Avoid manual refactor, just to be on the safe side. You could command + enter on thatswitchkeyword and selectReplace 'switch' with 'if'. - For updating the
const valintoval, I would recommend against that. Instead, just delete the constant and use the actual resource directly whenever needed, even if that means replacing the constant multiple times here and there,mainandtestsource included. For example:- On this
const val AVATAR_LEFT_OFFSET_DIMEN = R.dimen.margin_small_mediumbit of code. - This
R.dimen.margin_small_mediumcould be already considered as constant. No need to transform that toAVATAR_LEFT_OFFSET_DIMENand reuse this instead, I personally think this is an overkill, and actually, in this case doesn't serve us well. Having it as a non constantvarbreaks the coding guideline (camel-case vs upper-case) but more importantly has the potential for thisvarto be updated down the line, which could result in more problems.
- On this
Hope I helped a bit! π
Btw, this android.nonFinalResIds value change would also need to be update in .mobile-secrets and then this change applied via bundle exec fastlane run configure_apply on this repo.