fix: buttons rotation (#41)

* fix: buttons rotation

* fix: add back shutter rotation

---------

Co-authored-by: Naveen Singh <36371707+naveensingh@users.noreply.github.com>
Co-authored-by: Naveen Singh <snaveen935@gmail.com>
This commit is contained in:
Michał Korczak
2025-05-28 14:53:10 +02:00
committed by GitHub
parent 78972ded0b
commit 7cba7db64d

View File

@@ -646,15 +646,27 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
private fun animateViews(degrees: Int) = binding.apply {
val views = arrayOf(
toggleCamera,
layoutTop.toggleTimer,
layoutTop.toggleFlash,
layoutTop.changeResolution,
shutter,
layoutTop.settings,
lastPhotoVideoPreview
lastPhotoVideoPreview,
layoutTimer.timerOff,
layoutTimer.timer3s,
layoutTimer.timer5s,
layoutTimer.timer10S,
layoutFlash.flashOff,
layoutFlash.flashAuto,
layoutFlash.flashOn,
layoutFlash.flashAlwaysOn
)
for (view in views) {
rotate(view, degrees)
}
mediaSizeToggleGroup?.children?.forEach { child ->
rotate(child, degrees)
}
}
private fun rotate(view: View, degrees: Int) =
@@ -834,8 +846,15 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
onSelect.invoke(index, selectedResolution.buttonViewId != clickedViewId)
}
val currentDegrees = when (mLastHandledOrientation) {
ORIENT_LANDSCAPE_LEFT -> 90
ORIENT_LANDSCAPE_RIGHT -> -90
else -> 0
}
resolutions.forEach {
val button = createButton(it, onItemClick)
button.rotation = currentDegrees.toFloat()
mediaSizeToggleGroup.addView(button)
}