mirror of
https://github.com/SimpleMobileTools/Simple-Camera.git
synced 2025-02-16 19:30:40 +01:00
make mOrientation a local variable
This commit is contained in:
parent
824ad221df
commit
3bfde4d4a3
@ -66,7 +66,7 @@ class PhotoProcessor(val activity: MainActivity, val uri: Uri?, val currCameraId
|
||||
var image = BitmapFactory.decodeByteArray(data, 0, data.size)
|
||||
val exif = ExifInterface(photoFile.toString())
|
||||
|
||||
val deviceRot = MainActivity.mOrientation.compensateDeviceRotation(currCameraId)
|
||||
val deviceRot = MainActivity.mLastHandledOrientation.compensateDeviceRotation(currCameraId)
|
||||
val previewRot = activity.getPreviewRotation(currCameraId)
|
||||
val imageRot = when (exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED)) {
|
||||
ExifInterface.ORIENTATION_ROTATE_90 -> 90
|
||||
|
@ -587,7 +587,7 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
|
||||
}
|
||||
|
||||
private fun getVideoRotation(): Int {
|
||||
val deviceRot = MainActivity.mOrientation.compensateDeviceRotation(mCurrCameraId)
|
||||
val deviceRot = MainActivity.mLastHandledOrientation.compensateDeviceRotation(mCurrCameraId)
|
||||
val previewRot = mActivity.getPreviewRotation(mCurrCameraId)
|
||||
return (deviceRot + previewRot) % 360
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ import java.util.*
|
||||
|
||||
class MainActivity : SimpleActivity(), SensorEventListener, PreviewListener, PhotoProcessor.MediaSavedListener {
|
||||
companion object {
|
||||
|
||||
private val CAMERA_STORAGE_PERMISSION = 1
|
||||
private val RECORD_AUDIO_PERMISSION = 2
|
||||
private val FADE_DELAY = 5000
|
||||
@ -53,8 +52,7 @@ class MainActivity : SimpleActivity(), SensorEventListener, PreviewListener, Pho
|
||||
private var mIsHardwareShutterHandled = false
|
||||
private var mCurrVideoRecTimer = 0
|
||||
private var mCurrCameraId = 0
|
||||
private var mLastHandledOrientation = 0
|
||||
var mOrientation = 0
|
||||
var mLastHandledOrientation = 0
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@ -488,18 +486,18 @@ class MainActivity : SimpleActivity(), SensorEventListener, PreviewListener, Pho
|
||||
}
|
||||
|
||||
override fun onSensorChanged(event: SensorEvent) {
|
||||
if (event.values[0] < 6.5 && event.values[0] > -6.5) {
|
||||
mOrientation = ORIENT_PORTRAIT
|
||||
val orientation = if (event.values[0] < 6.5 && event.values[0] > -6.5) {
|
||||
ORIENT_PORTRAIT
|
||||
} else {
|
||||
if (event.values[0] > 0) {
|
||||
mOrientation = ORIENT_LANDSCAPE_LEFT
|
||||
ORIENT_LANDSCAPE_LEFT
|
||||
} else {
|
||||
mOrientation = ORIENT_LANDSCAPE_RIGHT
|
||||
ORIENT_LANDSCAPE_RIGHT
|
||||
}
|
||||
}
|
||||
|
||||
if (mOrientation != mLastHandledOrientation) {
|
||||
val degrees = when (mOrientation) {
|
||||
if (orientation != mLastHandledOrientation) {
|
||||
val degrees = when (orientation) {
|
||||
ORIENT_LANDSCAPE_LEFT -> 90
|
||||
ORIENT_LANDSCAPE_RIGHT -> -90
|
||||
else -> 0
|
||||
@ -507,7 +505,7 @@ class MainActivity : SimpleActivity(), SensorEventListener, PreviewListener, Pho
|
||||
|
||||
mPreview!!.deviceOrientationChanged()
|
||||
animateViews(degrees)
|
||||
mLastHandledOrientation = mOrientation
|
||||
mLastHandledOrientation = orientation
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user