Closed dlevache-pro closed 5 years ago
Thanks for reporting that. I will take a look at it.
The same bug appears in Samsung Galaxy S5. The last thing required to fix in order to have perfect camera view 📸 :)
Update: Since the android does not recreating Activity when switching landscape modes, it has to be done manually. I fixed this issue by manual detecting Display orientation. When landscape <-> reversed_landscape change is detected the following code is called:
runOnUiThread {
fotoapparat.stop()
fotoapparat.start()
}
Hey @marekfoltyn, I'm running into this same issue when going from landscape -> reverse landscape. How are you going about manually detecting display orientation?
Hi @ijwhelan, if you're targeting API 17+ then the following fix should work - Include this file in your project - ReverseOrientationObserver.kt
Then, in your onCreate() add the following code -
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
reverseOrientationObserver = ReverseOrientationObserver(this) {
fotoapparat.stop()
fotoapparat.start()
}
}
And in onDestroy() add -
reverseOrientationObserver?.quit()
reverseOrientationObserver = null
@dmitry-zaitsev Could this be added to the sample app in this repo if I raise a PR?
Hi @rdsarna Your link does not work. Could you fix it please? I also encountered this problem. Thanks in advance!
@balazsbanto Sorry about that, fixed now.
When the screen orientation is not locked, the system does not create a new activity when the device is turned upside down (from portrait to reverse portrait or from landscape to reverse landscape, with no intermediate orientation). In both these cases, the camera view displays images in the wrong orientation.
With an intermediate orientation (portrait during the landscape to reverse landscape switch), there is no problem.
What are you trying to achieve or the steps to reproduce?
Using the code from the sample:
What was the result you received?
The camera view is rendered upside down.
What did you expect?
Video preview is rendered in the correct orientation
Context: