--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="deploymentTargetDropDown">
+ <runningDeviceTargetSelectedWithDropDown>
+ <Target>
+ <type value="RUNNING_DEVICE_TARGET" />
+ <deviceKey>
+ <Key>
+ <type value="SERIAL_NUMBER" />
+ <value value="3e50111c1220" />
+ </Key>
+ </deviceKey>
+ </Target>
+ </runningDeviceTargetSelectedWithDropDown>
+ <timeTargetWasSelectedWithDropDown value="2022-02-20T14:51:00.404275800Z" />
+ </component>
+</project>
\ No newline at end of file
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.liveview
+
+import android.content.Context
+import android.view.OrientationEventListener
+
+class CameraOrientationEventReceiver(context: Context): OrientationEventListener(context)
+{
+ private var orientation : Int = -1
+
+ override fun onOrientationChanged(p0: Int)
+ {
+ orientation = p0
+ }
+
+ fun isPositionIsClockWise() : Boolean
+ {
+ return (orientation <= 180)
+ }
+}
import java.util.*
import kotlin.math.min
-class LiveImageView : View, ILiveView, ILiveViewRefresher, IShowGridFrame, OnSeekBarChangeListener, IFocusingModeNotify, IFocusFrameDrawer, IAutoFocusFrameDisplay, ICachePositionProvider
+class LiveImageView : View, ILiveView, ILiveViewRefresher, IShowGridFrame, OnSeekBarChangeListener, IFocusingModeNotify, IFocusFrameDrawer, IAutoFocusFrameDisplay, ICachePositionProvider, IImageRotation
{
companion object
{
private val TAG = LiveImageView::class.java.simpleName
}
+ private lateinit var orientationEventListener : CameraOrientationEventReceiver
private var sliderPosition : Float = 0.0f
private var imageRotationDegrees : Int = 0
private var showGrid : Boolean = false
informationDrawer = InformationDrawer(this)
indicatorControl = IndicatorControl()
imageBitmap = BitmapFactory.decodeResource(context.resources, ID_DRAWABLE_BACKGROUND_IMAGE)
+ orientationEventListener = CameraOrientationEventReceiver(context)
+ orientationEventListener.enable()
}
fun injectDisplay(cameraControl: ICameraControl)
val config = context.resources.configuration
if (config.orientation == Configuration.ORIENTATION_LANDSCAPE)
{
- addDegrees = 90
+ addDegrees = if (orientationEventListener.isPositionIsClockWise()) { 90 } else { 270 }
}
}
catch (e: Exception)
}
return PointF(imagePointX, imagePointY)
}
-
}