kryptco / krypton-android

DEPRECATED Krypton turns your Android device into a U2F Authenticator: strong, unphishable 2FA.
https://krypt.co
Other
203 stars 50 forks source link

Instant camera setup/teardown on visibility hint #59

Closed kennylevinsen closed 7 years ago

kennylevinsen commented 7 years ago

Move all setup/teardown work to a separate thread, using a threadpool with a single thread to synchronize start/stop operations. This frees up the UI thread, making the UI more fluid.

The result is that there is no UI glitching when the camera is enabled/disabled, and it is therefore managed instantly on visibility hints.

kennylevinsen commented 7 years ago

There's some minor restructuring in there (camera setup grouped together, Camera.PreviewCallback implementation moved to the PairScanner), I killed a preview.requestLayout(); that seemed unnecessary, and I removed a line of code taken from an Android example that was there for pre-3.0 compatibility, which I'm pretty sure isn't supported anyway.

If that was in fact necessary, I'll re-add it. Likewise, if you dislike the refactoring, please don't hesitate to say so. There's nothing wrong with disagreeing on coding style, and it is your project. :)

As a side-note: Consider changing language level to Java 8. With the amount of Runnables in there, you're going to love lambda expressions.

kcking commented 7 years ago

Thanks Kenny! I'll test this out this weekend.