Correctly handle supported image formats on Android APIs < 23#622
Correctly handle supported image formats on Android APIs < 23#622axxel merged 3 commits intozxing-cpp:masterfrom
Conversation
e19a7c8 to
5dd9c8a
Compare
|
Just to make I understand the situation regarding the explicit mode: Everything in a kotlin class is public unless specified private, right? So if there is no |
|
Yes, unfortunately Kotlin visibility is implicitly Explicit API mode helps prevent two errors:
Note: Kotlin also has
Take the following example from public fun read(bitmap: Bitmap, cropRect: Rect = Rect(), rotation: Int = 0): Result? {
return read(bitmap, options, cropRect, rotation)
}I could also write the function in a single-expression format. Without Explicit API mode I could omit the return type: public fun read(bitmap: Bitmap, cropRect: Rect = Rect(), rotation: Int = 0) = read(bitmap, options, cropRect, rotation)Explicit API mode prevents that: public fun read(bitmap: Bitmap, cropRect: Rect = Rect(), rotation: Int = 0): Result? = read(bitmap, options, cropRect, rotation) |
|
As you can possibly infer from my choice of words in my last comment, I'm not a fan of 'unnecessary' verbosity but I'm also not particularly emotional about the Kotlin code base in general and you clearly have more knowledge and experience here... Thanks for taking the time to engage in the discussion. |
The library declares minSdk 21, but
BarcodeReaderaccesses ImageFormat constants that were added in API 23. This PR guards the access to these constants with a version check.Also, the explicit API mode was enabled for the Kotlin compiler. This flag instructs the compiler to enforce visibility modifiers and return types be explicitly specified (if they would be public by default).