Detect current time zone, locale, and calendar on Android#564
Conversation
04a2669 to
6f7df5d
Compare
Disable force_try
6f7df5d to
b795ad8
Compare
stackotter
left a comment
There was a problem hiding this comment.
Looks great; just going to test things locally before merging
| // added a whole new method that uses up-to-date information. The new method returns | ||
| // TimeZone.UNKNOWN_ZONE_ID on error; the old method returns null on error. | ||
| if (Build.VERSION.SDK_INT >= 36) { | ||
| val id = TimeZone.getIanaID(tz.getID()) |
There was a problem hiding this comment.
I get 'unresolved reference getIanaID' when attempting to compile this code locally 🤔 My SDK version appears to be 35. Is there a way for us to only compile that SDK checking code when the compiling SDK is high enough in the first place? Otherwise we always lock compilation to the highest SDK version that we conditionally support features from
There was a problem hiding this comment.
I don't think so -- Kotlin doesn't have #if (nor does Java). One thing we might be able to do, though this would require swift-bundler support, is:
- Mark a function as
expect - Have an
actualimplementation in another file that always callsgetCanonicalID - Have an
actualimplementation in another file that checks the version number, like I am here - Conditionally compile only one of those two files based on your compile SDK version
(Aside: I'm honestly not 100% sure how expect/actual works in Kotlin. That's just my first idea off the top of my head.)
There was a problem hiding this comment.
Coming back to this now, the Gradle file that sbun generates for me has compileSdk = 36. Shouldn't that mean you need SDK 36 to build it anyways?
There was a problem hiding this comment.
It generates with the latest SDK that you have available (unless the project specifies a compileSDK)
Draft primarily because I still need to figure out how to refer to
Serializablein theimplementslist forAndroidCalendar. I'll also need to come up with a better name forifNotEmpty.