Before this, the previously scanned code was _always_ ignored for
bulk scans to avoid scanning the same code twice. But this isn't
always desirable, and the setting to ignore duplicates should have
an effect to give the user control over this behaviour.
`WifiConnector.parse()` still returned a `WifiNetworkSuggestion`
on Android Q but `WifiConnector.addNetwork()` is now expecting a
`WifiNetworkSuggestion.Builder` :8
Anyway, this code wasn't very good to start with. Having the exact
same check in two different places with the exact same meaning is
bad. This bug is a good example of that ;)
So now, `WifiConnector.addNetwork()` checks what type of object it
got and does the right thing with it.
Thanks to @JacobKochems who found this bug and made me aware of it.
Because WifiManager.getNetworkSuggestions() is only available from
Android R (API level 30) on. So added network suggestions cannot be
queried on Android Q (API level 29) which will be important to allow
removing them individually.
Because the current expression leads to an infinite loop for some
inputs. For example, this string was reported to make the app crash:
com.taobao.arthas.boot.ProcessUtils.findJavaHome(ProcessUtils.java:222)
The problem seems to be somehow related to case insensitivity as the
expression works when insensitivity is removed. Also, the infinite
loop only occurs on an Android device - not in unit tests.
Anyway, the current expression was too complex anyway, and this
simpler one should be good enough.
To allow small codes to be small on screen.
This makes it easier to use a generated barcode in place of a small
printed barcode. There are scanners out there that expect a barcode
to be of a certain (small) size.
We should only prefer read-only properties over of functions if the
underlying algorithm…
* does not throw
* is cheap to calculate (or cached on the first run)
* returns the same result over invocations if the object state
hasn't changed
See:
https://kotlinlang.org/docs/coding-conventions.html#functions-vs-properties
But `ZXing.encodeAs*` may throw and may also not be that cheap to
calculate. So functions are a better fit here.
Also, because these functions will always return the same result,
it makes sense to cache their outputs.