import jp.osdn.gokigen.gokigenassets.constants.ICameraConnectionMethods.Companion.PREFERENCE_CAMERA_METHOD_CAMERAX
import jp.osdn.gokigen.gokigenassets.constants.ICameraConnectionMethods.Companion.PREFERENCE_CAMERA_METHOD_PANASONIC
import jp.osdn.gokigen.gokigenassets.constants.ICameraConnectionMethods.Companion.PREFERENCE_CAMERA_METHOD_PENTAX
+import jp.osdn.gokigen.gokigenassets.constants.ICameraConnectionMethods.Companion.PREFERENCE_CAMERA_METHOD_SONY
import jp.osdn.gokigen.gokigenassets.constants.ICameraConnectionMethods.Companion.PREFERENCE_CAMERA_METHOD_THETA
import jp.osdn.gokigen.gokigenassets.liveview.*
import jp.osdn.gokigen.gokigenassets.liveview.focusframe.IAutoFocusFrameDisplay
PREFERENCE_CAMERA_METHOD_PENTAX -> true
PREFERENCE_CAMERA_METHOD_THETA -> true
PREFERENCE_CAMERA_METHOD_PANASONIC -> true
+ PREFERENCE_CAMERA_METHOD_SONY -> true
else -> false
}
}
-package jp.osdn.gokigen.gokigenassets.camera.panasonic.status
+package jp.osdn.gokigen.gokigenassets.camera.interfaces
interface ICameraStatusHolder
{
import android.content.Context
import android.util.Log
-import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraStatus
-import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICardSlotSelectionReceiver
-import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICardSlotSelector
-import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraChangeListener
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.*
import jp.osdn.gokigen.gokigenassets.camera.panasonic.IPanasonicCamera
import jp.osdn.gokigen.gokigenassets.utils.communication.SimpleHttpClient
-class CameraStatusHolder(private val context: Context, private val remote: IPanasonicCamera, private val cardSlotSelector: ICardSlotSelector) : ICardSlotSelectionReceiver, ICameraStatusHolder
+class CameraStatusHolder(private val context: Context, private val remote: IPanasonicCamera, private val cardSlotSelector: ICardSlotSelector) : ICardSlotSelectionReceiver,
+ ICameraStatusHolder
{
private var listener: ICameraChangeListener? = null
private var currentSd = "sd1"
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.sony
+
+import android.util.Log
+import android.view.KeyEvent
+import android.view.View
+import androidx.appcompat.app.AppCompatActivity
+import jp.osdn.gokigen.gokigenassets.camera.ICameraPreferenceProvider
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.*
+import jp.osdn.gokigen.gokigenassets.constants.IApplicationConstantConvert
+import jp.osdn.gokigen.gokigenassets.liveview.ICachePositionProvider
+import jp.osdn.gokigen.gokigenassets.liveview.IIndicatorControl
+import jp.osdn.gokigen.gokigenassets.liveview.ILiveView
+import jp.osdn.gokigen.gokigenassets.liveview.ILiveViewRefresher
+import jp.osdn.gokigen.gokigenassets.liveview.focusframe.IAutoFocusFrameDisplay
+import jp.osdn.gokigen.gokigenassets.liveview.image.CameraLiveViewListenerImpl
+import jp.osdn.gokigen.gokigenassets.liveview.storeimage.StoreImage
+import jp.osdn.gokigen.gokigenassets.preference.PreferenceAccessWrapper
+import jp.osdn.gokigen.gokigenassets.scene.IInformationReceiver
+import jp.osdn.gokigen.gokigenassets.scene.IVibrator
+import jp.osdn.gokigen.gokigenassets.camera.sony.liveview.SonyLiveViewControl
+import jp.osdn.gokigen.gokigenassets.camera.sony.operation.SonyCameraCaptureControl
+import jp.osdn.gokigen.gokigenassets.camera.sony.operation.SonyCameraFocusControl
+import jp.osdn.gokigen.gokigenassets.camera.sony.operation.SonyCameraZoomLensControl
+import jp.osdn.gokigen.gokigenassets.camera.sony.wrapper.ISonyCameraApi
+import jp.osdn.gokigen.gokigenassets.camera.sony.wrapper.ISonyCameraHolder
+import jp.osdn.gokigen.gokigenassets.camera.sony.wrapper.connection.SonyCameraConnection
+import jp.osdn.gokigen.gokigenassets.camera.sony.wrapper.eventlistener.SonyCameraEventObserver
+import jp.osdn.gokigen.gokigenassets.camera.sony.wrapper.ISonyCamera
+import jp.osdn.gokigen.gokigenassets.camera.sony.wrapper.SonyCameraApi
+import jp.osdn.gokigen.gokigenassets.camera.sony.wrapper.eventlistener.ISonyCameraEventObserver
+import jp.osdn.gokigen.gokigenassets.camera.sony.wrapper.eventlistener.SonyStatus
+import org.json.JSONObject
+import kotlin.collections.ArrayList
+
+
+class SonyCameraControl(private val context: AppCompatActivity, private val vibrator : IVibrator, private val informationNotify : IInformationReceiver, private val preference: ICameraPreferenceProvider, provider: ICameraStatusReceiver) : ISonyCameraHolder,
+ IDisplayInjector, ICameraControl, View.OnClickListener, View.OnLongClickListener, ICameraShutter, IKeyDown
+{
+ private val sonyCameraStatus = SonyStatus(JSONObject())
+ private val liveViewListener = CameraLiveViewListenerImpl(context, informationNotify)
+ private val cameraConnection = SonyCameraConnection(context, provider, this)
+ private val storeImage = StoreImage(context, liveViewListener)
+
+ private lateinit var cachePositionProvider : ICachePositionProvider
+ private lateinit var sonyCamera: ISonyCamera
+ private lateinit var sonyCameraApi: ISonyCameraApi
+ private lateinit var eventObserver: ISonyCameraEventObserver
+ private lateinit var liveViewControl: SonyLiveViewControl
+ private lateinit var focusControl: SonyCameraFocusControl
+ private lateinit var captureControl: SonyCameraCaptureControl
+
+ private val zoomControl = SonyCameraZoomLensControl()
+ private var isStatusWatch = false
+ private var cameraPositionId = 0
+
+ companion object
+ {
+ private val TAG = SonyCameraControl::class.java.simpleName
+ }
+
+ override fun prepare()
+ {
+ if (::sonyCamera.isInitialized)
+ {
+ Log.v(TAG, " prepare : ${sonyCamera.getFriendlyName()} ${sonyCamera.getModelName()}")
+ try
+ {
+ sonyCameraApi = SonyCameraApi(sonyCamera)
+ eventObserver = SonyCameraEventObserver.newInstance(context, sonyCameraApi, sonyCameraStatus)
+ liveViewControl = SonyLiveViewControl(context, informationNotify, liveViewListener, sonyCameraApi)
+ zoomControl.setCameraApi(sonyCameraApi)
+ if (::focusControl.isInitialized)
+ {
+ focusControl.setCameraApi(sonyCameraApi)
+ }
+ if (::captureControl.isInitialized)
+ {
+ captureControl.setCameraApi(sonyCameraApi)
+ }
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ }
+ else
+ {
+ Log.w(TAG, " ISonyCamera is not initialized...")
+ }
+ }
+
+ override fun startRecMode()
+ {
+ try
+ {
+ val apiCommands: List<String> = getApiCommands()
+ val index = apiCommands.indexOf("startRecMode")
+ if (index > 0)
+ {
+ // startRecMode発行
+ Log.v(TAG, "----- THIS CAMERA NEEDS COMMAND 'startRecMode'.")
+ sonyCameraApi.startRecMode()
+ }
+ }
+ catch (e: java.lang.Exception)
+ {
+ e.printStackTrace()
+ }
+ }
+
+ override fun startEventWatch()
+ {
+ try
+ {
+ if (::eventObserver.isInitialized)
+ {
+ eventObserver.setEventListener(sonyCameraStatus)
+ eventObserver.activate()
+ eventObserver.start()
+ }
+ while (true)
+ {
+ val holder = eventObserver.getCameraStatusHolder()
+ if (holder?.getLiveviewStatus() == true)
+ {
+ break
+ }
+ try
+ {
+ Thread.sleep(1500)
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ }
+ if (::liveViewControl.isInitialized)
+ {
+ liveViewControl.startLiveView(false)
+ }
+
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ }
+
+ override fun detectedCamera(camera: ISonyCamera)
+ {
+ Log.v(TAG, "detectedCamera()")
+ sonyCamera = camera
+ }
+
+ override fun getConnectionMethod(): String
+ {
+ return ("SONY")
+ }
+
+ override fun initialize()
+ {
+ Log.v(TAG, " --- initialize()")
+ // TODO("Not yet implemented")
+ }
+
+ override fun connectToCamera()
+ {
+ Log.v(TAG, " connectToCamera() : PANASONIC ")
+ try
+ {
+ cameraConnection.connect()
+ }
+ catch (e : Exception)
+ {
+ e.printStackTrace()
+ }
+ }
+
+ override fun startCamera(isPreviewView: Boolean, cameraSequence: Int)
+ {
+ try
+ {
+ if (cameraConnection.getConnectionStatus() != ICameraConnectionStatus.CameraConnectionStatus.CONNECTED)
+ {
+ cameraConnection.startWatchWifiStatus(context)
+ }
+ else
+ {
+ cameraConnection.connect()
+ }
+ }
+ catch (e : Exception)
+ {
+ e.printStackTrace()
+ }
+ }
+
+ override fun finishCamera()
+ {
+ try
+ {
+ if (isStatusWatch)
+ {
+ if (::eventObserver.isInitialized)
+ {
+ eventObserver.stop()
+ }
+ isStatusWatch = false
+ if (::liveViewControl.isInitialized)
+ {
+ liveViewControl.stopLiveView()
+ }
+ }
+ cameraConnection.disconnect(false)
+ cameraConnection.stopWatchWifiStatus(context)
+ }
+ catch (e : Exception)
+ {
+ e.printStackTrace()
+ }
+ }
+
+ override fun changeCaptureMode(mode: String)
+ {
+ Log.v(TAG, " --- changeCaptureMode(mode: $mode)")
+ // TODO("Not yet implemented")
+ }
+
+ override fun needRotateImage(): Boolean
+ {
+ return (false)
+ }
+
+ override fun setRefresher(id: Int, refresher: ILiveViewRefresher, imageView: ILiveView, cachePosition : ICachePositionProvider)
+ {
+ try
+ {
+ liveViewListener.setRefresher(refresher)
+ imageView.setImageProvider(liveViewListener)
+ cachePositionProvider = cachePosition
+ }
+ catch (e : Exception)
+ {
+ e.printStackTrace()
+ }
+ }
+
+ override fun captureButtonReceiver(id: Int): View.OnClickListener
+ {
+ cameraPositionId = id
+ return (this)
+ }
+
+ override fun onLongClickReceiver(id: Int): View.OnLongClickListener
+ {
+ cameraPositionId = id
+ return (this)
+ }
+
+ override fun keyDownReceiver(id: Int): IKeyDown
+ {
+ cameraPositionId = id
+ return (this)
+ }
+
+ override fun getFocusingControl(id: Int): IFocusingControl
+ {
+ cameraPositionId = id
+ return (focusControl)
+ }
+
+ override fun getDisplayInjector(): IDisplayInjector
+ {
+ return (this)
+ }
+
+ override fun injectDisplay(frameDisplayer: IAutoFocusFrameDisplay, indicator: IIndicatorControl, focusingModeNotify: IFocusingModeNotify)
+ {
+ Log.v(TAG, "injectDisplay()")
+ focusControl = SonyCameraFocusControl(frameDisplayer, indicator)
+ captureControl = SonyCameraCaptureControl(frameDisplayer, indicator)
+ }
+/*
+ override fun startLiveView(isCameraScreen: Boolean)
+ {
+ Log.v(TAG, " startLiveView($isCameraScreen) ")
+ try
+ {
+ if (!isStatusWatch)
+ {
+ if (::eventObserver.isInitialized)
+ {
+ eventObserver.activate()
+ eventObserver.start()
+ val holder = eventObserver.getCameraStatusHolder()
+ holder?.getLiveviewStatus()
+ isStatusWatch = true
+ }
+ }
+ liveViewControl.startLiveView()
+ }
+ catch (e : Exception)
+ {
+ e.printStackTrace()
+ }
+ }
+
+ override fun stopLiveView()
+ {
+ Log.v(TAG, " stopLiveView() ")
+ try
+ {
+ liveViewControl.stopLiveView()
+ if (isStatusWatch)
+ {
+ if (::eventObserver.isInitialized)
+ {
+ eventObserver.stop()
+ isStatusWatch = false
+ }
+ }
+ }
+ catch (e : Exception)
+ {
+ e.printStackTrace()
+ }
+ }
+*/
+
+ override fun onClick(v: View?)
+ {
+ if (v == null)
+ {
+ return
+ }
+ when (v.id)
+ {
+ IApplicationConstantConvert.ID_BUTTON_SHUTTER -> { doShutter() }
+ else -> { }
+ }
+ }
+
+ override fun doShutter()
+ {
+ try
+ {
+ Log.v(TAG, " doShutter()")
+ val isNotDriveShutter = captureImageLiveView()
+ if (isNotDriveShutter)
+ {
+ // シャッターを駆動させない(けど、バイブレーションで通知する)
+ vibrator.vibrate(IVibrator.VibratePattern.SIMPLE_SHORT)
+ return
+ }
+ if (::captureControl.isInitialized)
+ {
+ captureControl.doCapture(0)
+ }
+ }
+ catch (e : Exception)
+ {
+ e.printStackTrace()
+ }
+ }
+
+ override fun doShutterOff()
+ {
+ try
+ {
+ Log.v(TAG, " doShutterOff()")
+ if (::captureControl.isInitialized)
+ {
+ captureControl.doCapture(0)
+ }
+ }
+ catch (e : Exception)
+ {
+ e.printStackTrace()
+ }
+ }
+
+ override fun handleKeyDown(keyCode: Int, event: KeyEvent): Boolean
+ {
+ if ((event.action == KeyEvent.ACTION_DOWN)&&((keyCode == KeyEvent.KEYCODE_VOLUME_UP)||(keyCode == KeyEvent.KEYCODE_CAMERA)))
+ {
+ doShutter()
+ return (true)
+ }
+ return (false)
+ }
+
+ private fun captureImageLiveView() : Boolean
+ {
+ try
+ {
+ // preferenceから設定を取得する
+ val captureBothCamera = PreferenceAccessWrapper(context).getBoolean(
+ IApplicationConstantConvert.ID_PREFERENCE_CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW, IApplicationConstantConvert.ID_PREFERENCE_CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW_DEFAULT_VALUE)
+ val notUseShutter = PreferenceAccessWrapper(context).getBoolean(
+ IApplicationConstantConvert.ID_PREFERENCE_CAPTURE_ONLY_LIVEVIEW_IMAGE, IApplicationConstantConvert.ID_PREFERENCE_CAPTURE_ONLY_LIVEVIEW_IMAGE_DEFAULT_VALUE)
+ if ((captureBothCamera)&&(liveViewListener.isImageReceived()))
+ {
+ // ライブビュー画像を保管する場合...
+ val thread = Thread { storeImage.doStore(cameraPositionId, false, cachePositionProvider.getCachePosition()) }
+ try
+ {
+ thread.start()
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ }
+ return (notUseShutter)
+ }
+ catch (e : Exception)
+ {
+ e.printStackTrace()
+ }
+ return (false)
+ }
+
+ private fun getApiCommands(): List<String>
+ {
+ try
+ {
+ var apiList = sonyCameraApi.getAvailableApiList()?.getString("result")
+ apiList = apiList?.replace("[", "")?.replace("]", "")?.replace("\"", "")
+ val apiListSplit = apiList?.split(",".toRegex())?.toTypedArray()
+ return (apiListSplit?.toList() ?: ArrayList())
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ return (ArrayList())
+ }
+
+ override fun onLongClick(v: View?): Boolean
+ {
+ return (false)
+ }
+
+ override fun setNeighborCameraControl(camera0: ICameraControl?, camera1: ICameraControl?, camera2: ICameraControl?, camera3: ICameraControl?) { }
+ override fun getCameraStatus(): ICameraStatus
+ {
+ return (sonyCameraStatus)
+ }
+}
import org.json.JSONObject
import jp.osdn.gokigen.gokigenassets.liveview.image.CameraLiveViewListenerImpl
import jp.osdn.gokigen.gokigenassets.camera.sony.wrapper.ISonyCameraApi
+import jp.osdn.gokigen.gokigenassets.liveview.image.IImageDataReceiver
import jp.osdn.gokigen.gokigenassets.scene.IInformationReceiver
import jp.osdn.gokigen.gokigenassets.utils.communication.SimpleLiveViewSlicer
import org.json.JSONArray
import java.lang.Exception
-class SonyLiveViewControl(private val context: Context, private val informationReceiver: IInformationReceiver, private val cameraApi: ISonyCameraApi) : ILiveViewController
+class SonyLiveViewControl(context: Context, private val informationReceiver: IInformationReceiver, private val imageDataReceiver: IImageDataReceiver, private val cameraApi: ISonyCameraApi) : ILiveViewController
{
- private val liveViewListener = CameraLiveViewListenerImpl(context, informationReceiver)
private var whileFetching = false
override fun startLiveView(isCameraScreen: Boolean)
}
}
- fun changeLiveViewSize(size: String?) { }
- fun updateDigitalZoom() {}
- fun updateMagnifyingLiveViewScale(isChangeScale: Boolean) {}
- fun getMagnifyingLiveViewScale(): Float { return (1.0f) }
- fun getDigitalZoomScale(): Float { return (1.0f) }
-
fun start(streamUrl: String?): Boolean
{
- if (streamUrl == null) {
+ if (streamUrl == null)
+ {
Log.e(TAG, "start() streamUrl is null.")
return false
}
- if (whileFetching) {
+ if (whileFetching)
+ {
Log.v(TAG, "start() already starting.")
}
whileFetching = true
// A thread for retrieving liveview data from server.
- try {
+ try
+ {
val thread = Thread {
Log.d(TAG, "Starting retrieving streaming data from server.")
var slicer: SimpleLiveViewSlicer? = null
val jpegData = payload.getJpegData()
if (jpegData != null)
{
- liveViewListener.onUpdateLiveView(jpegData, null)
+ imageDataReceiver.onUpdateLiveView(jpegData, null)
}
continuousNullDataReceived = 0
}
{
e.printStackTrace()
}
- return true
+ return (true)
}
companion object
class SonyCameraFocusControl(private val frameDisplay: IAutoFocusFrameDisplay, indicator: IIndicatorControl) : IFocusingControl
{
private val afControl = AutoFocusControl(frameDisplay, indicator)
+
fun setCameraApi(sonyCameraApi: ISonyCameraApi)
{
afControl.setCameraApi(sonyCameraApi)
import jp.osdn.gokigen.gokigenassets.liveview.focusframe.IAutoFocusFrameDisplay.FocusFrameStatus
import java.lang.Exception
-
class AutoFocusControl(private val frameDisplayer: IAutoFocusFrameDisplay, private val indicator: IIndicatorControl)
{
private lateinit var cameraApi: ISonyCameraApi
val posY = point.y * 100.0
Log.v(TAG, "AF ($posX, $posY)")
val resultsObj = cameraApi.setTouchAFPosition(posX, posY)
- if (resultsObj == null)
- {
- Log.v(TAG, "setTouchAFPosition() reply is null.")
- }
- if (findTouchAFPositionResult(resultsObj))
+ if (resultsObj != null)
{
- // AF FOCUSED
- Log.v(TAG, "lockAutoFocus() : FOCUSED")
- showFocusFrame(preFocusFrameRect, FocusFrameStatus.Focused, 0.0)
+ if (findTouchAFPositionResult(resultsObj))
+ {
+ // AF FOCUSED
+ Log.v(TAG, "lockAutoFocus() : FOCUSED")
+ showFocusFrame(preFocusFrameRect, FocusFrameStatus.Focused, 0.0)
+ }
+ else
+ {
+ // AF ERROR
+ Log.v(TAG, "lockAutoFocus() : ERROR")
+ showFocusFrame(preFocusFrameRect, FocusFrameStatus.Failed, 1.0)
+ }
}
else
{
- // AF ERROR
- Log.v(TAG, "lockAutoFocus() : ERROR")
- showFocusFrame(preFocusFrameRect, FocusFrameStatus.Failed, 1.0)
+ Log.v(TAG, "setTouchAFPosition() reply is null.")
}
}
catch (e: Exception)
*
*
*/
+ private fun findTouchAFPositionResult(replyJson: JSONObject): Boolean
+ {
+ var afResult = false
+ try
+ {
+ val indexOfTouchAFPositionResult = 1
+ val resultsObj = replyJson.getJSONArray("result")
+ if (!resultsObj.isNull(indexOfTouchAFPositionResult))
+ {
+ val touchAFPositionResultObj = resultsObj.getJSONObject(indexOfTouchAFPositionResult)
+ afResult = touchAFPositionResultObj.getBoolean("AFResult")
+ Log.v(TAG, "AF Result : $afResult")
+ }
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ return afResult
+ }
+
+ /**
+ *
+ *
+ */
private fun getPreFocusFrameRect(point: PointF): RectF
{
val imageWidth = frameDisplayer.getContentSizeWidth()
companion object
{
private val TAG = AutoFocusControl::class.java.simpleName
- private fun findTouchAFPositionResult(replyJson: JSONObject?): Boolean
- {
- var afResult = false
- try
- {
- val indexOfTouchAFPositionResult = 1
- val resultsObj = replyJson!!.getJSONArray("result")
- if (!resultsObj.isNull(indexOfTouchAFPositionResult))
- {
- val touchAFPositionResultObj = resultsObj.getJSONObject(indexOfTouchAFPositionResult)
- afResult = touchAFPositionResultObj.getBoolean("AFResult")
- Log.v(TAG, "AF Result : $afResult")
- }
- }
- catch (e: Exception)
- {
- e.printStackTrace()
- }
- return afResult
- }
}
}
import jp.osdn.gokigen.gokigenassets.liveview.focusframe.IAutoFocusFrameDisplay
import java.lang.Exception
-
class SingleShotControl(private val frameDisplayer: IAutoFocusFrameDisplay, private val indicator: IIndicatorControl)
{
private lateinit var cameraApi: ISonyCameraApi
package jp.osdn.gokigen.gokigenassets.camera.sony.wrapper
-import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraChangeListener
-
interface ISonyCameraHolder
{
fun detectedCamera(camera: ISonyCamera)
fun prepare()
fun startRecMode()
- fun startPlaybackMode()
- fun startEventWatch(listener: ICameraChangeListener?)
+ fun startEventWatch()
}
import jp.osdn.gokigen.gokigenassets.utils.communication.SimpleHttpClient
import java.lang.Exception
-private class SonyCameraApi(private val sonyCamera: ISonyCamera) : ISonyCameraApi
+class SonyCameraApi(private val sonyCamera: ISonyCamera) : ISonyCameraApi
{
private var requestId = 1
private val httpClient = SimpleHttpClient()
return JSONObject()
}
- override fun isErrorReply(replyJson: JSONObject?): Boolean {
+ override fun isErrorReply(replyJson: JSONObject?): Boolean
+ {
return replyJson != null && replyJson.has("error")
}
- companion object {
+ companion object
+ {
private val TAG = SonyCameraApi::class.java.simpleName
private const val FULL_LOG = true
- fun newInstance(target: ISonyCamera): ISonyCameraApi
- {
- return SonyCameraApi(target)
- }
}
}
import jp.osdn.gokigen.gokigenassets.camera.sony.wrapper.ISonyCameraHolder
import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraConnection
import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraStatusReceiver
-import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraChangeListener
import jp.osdn.gokigen.gokigenassets.constants.ICameraConstantConvert.Companion.ID_STRING_CONNECT_CAMERA_FOUND
import jp.osdn.gokigen.gokigenassets.constants.ICameraConstantConvert.Companion.ID_STRING_CONNECT_CONNECTED
import jp.osdn.gokigen.gokigenassets.constants.ICameraConstantConvert.Companion.ID_STRING_CONNECT_START
class SonyCameraConnectSequence(private val context: AppCompatActivity,
private val cameraStatusReceiver: ICameraStatusReceiver,
private val cameraConnection: ICameraConnection?,
- private val cameraHolder: ISonyCameraHolder,
- private val listener: ICameraChangeListener) : Runnable, SonySsdpClient.ISearchResultCallback
+ private val cameraHolder: ISonyCameraHolder) : Runnable, SonySsdpClient.ISearchResultCallback
{
+ private var client = SonySsdpClient(context, this, cameraStatusReceiver, 1)
+
companion object
{
private val TAG = SonyCameraConnectSequence::class.java.simpleName
}
- private var client: SonySsdpClient? = null
-
- init
- {
- Log.v(TAG, "SonyCameraConnectSequence")
- client = SonySsdpClient(context, this, cameraStatusReceiver, 1)
- }
-
override fun run()
{
Log.v(TAG, "search()")
try
{
cameraStatusReceiver.onStatusNotify(context.getString(ID_STRING_CONNECT_START))
- client?.search()
+ client.search()
}
catch (e: Exception)
{
try
{
cameraHolder.prepare()
- cameraHolder.startPlaybackMode()
- //cameraHolder.startRecMode();
- //cameraHolder.startEventWatch(listener);
+ cameraHolder.startRecMode()
+ cameraHolder.startEventWatch()
}
catch (e: Exception)
{
}
}
+/*
private fun waitForAMoment(mills: Long)
{
if (mills > 0)
}
}
}
+*/
override fun onErrorFinished(reason: String?)
{
import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraConnectionStatus.CameraConnectionStatus
import android.net.ConnectivityManager
import android.net.wifi.WifiManager
-import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraChangeListener
import jp.osdn.gokigen.gokigenassets.camera.sony.wrapper.ISonyCameraHolder
import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraStatusReceiver
-
import android.content.*
import android.provider.Settings
import android.util.Log
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
-
import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraConnection
-import jp.osdn.gokigen.gokigenassets.camera.interfaces.ILiveViewController
import jp.osdn.gokigen.gokigenassets.constants.ICameraConstantConvert
import java.lang.Exception
import java.util.concurrent.Executor
import java.util.concurrent.Executors
-
-class SonyCameraConnection(private val context: AppCompatActivity, private val statusReceiver: ICameraStatusReceiver, private val liveViewControl: ILiveViewController, private val cameraHolder: ISonyCameraHolder, private val listener: ICameraChangeListener) : ICameraConnection
+class SonyCameraConnection(private val context: AppCompatActivity, private val statusReceiver: ICameraStatusReceiver, private val cameraHolder: ISonyCameraHolder) : ICameraConnection
{
companion object
{
connectionStatus = CameraConnectionStatus.CONNECTING
try
{
- cameraExecutor.execute(SonyCameraConnectSequence(context, statusReceiver, this, cameraHolder, listener))
+ cameraExecutor.execute(SonyCameraConnectSequence(context, statusReceiver, this, cameraHolder))
}
catch (e: Exception)
{
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.sony.wrapper.eventlistener
+
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraChangeListener
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraStatusHolder
+
+interface ISonyCameraEventObserver
+{
+ fun activate()
+ fun start(): Boolean
+ fun stop()
+ fun release()
+
+ fun setEventListener(listener: ICameraChangeListener)
+ fun clearEventListener()
+
+ fun getCameraStatusHolder(): ICameraStatusHolder?
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.sony.wrapper.eventlistener
+
+import org.json.JSONObject
+
+interface ISonyStatusReceiver
+{
+ fun updateStatus(jsonObject: JSONObject)
+}
\ No newline at end of file
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.sony.wrapper.eventlistener
+
+import android.os.Handler
+import android.util.Log
+import org.json.JSONObject
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraChangeListener
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraStatusHolder
+import java.lang.Exception
+import java.util.*
+import kotlin.collections.ArrayList
+
+
+class ReplyJsonParser(private val uiHandler: Handler) : ICameraStatusHolder
+{
+ private var cameraStatus = ""
+ private var listener: ICameraChangeListener? = null
+ private var currentLiveviewStatus = false
+ private var currentShootMode = ""
+ private var currentAvailableShootModes: List<String?> = Collections.unmodifiableList(ArrayList<String>())
+ private var currentZoomPosition = 0
+ private var currentStorageId = ""
+ private var currentFocusStatus = ""
+
+ fun parse(replyJson: JSONObject)
+ {
+ try
+ {
+ // AvailableApis
+ val availableApis = findAvailableApiList(replyJson)
+ if (availableApis.isNotEmpty())
+ {
+ uiHandler.post { listener?.onApiListModified(availableApis) }
+ }
+
+ // CameraStatus
+ val cameraStatus = findCameraStatus(replyJson) ?: ""
+ Log.d(TAG, "getEvent cameraStatus: $cameraStatus")
+ if (cameraStatus != this.cameraStatus)
+ {
+ this.cameraStatus = cameraStatus
+ uiHandler.post { listener?.onCameraStatusChanged(cameraStatus) }
+ }
+
+ // LiveviewStatus
+ val liveviewStatus = findLiveviewStatus(replyJson) ?: false
+ Log.d(TAG, "getEvent liveviewStatus: $liveviewStatus")
+ if (liveviewStatus != currentLiveviewStatus)
+ {
+ currentLiveviewStatus = liveviewStatus
+ uiHandler.post { listener?.onLiveviewStatusChanged(liveviewStatus) }
+ }
+
+ // ShootMode
+ val shootMode = findShootMode(replyJson) ?: ""
+ Log.d(TAG, "getEvent shootMode: $shootMode")
+ if (shootMode != currentShootMode)
+ {
+ currentShootMode = shootMode
+
+ // Available Shoot Modes
+ val shootModes = findAvailableShootModes(replyJson)
+ currentAvailableShootModes = Collections.unmodifiableList(shootModes)
+ uiHandler.post { listener?.onShootModeChanged(shootMode) }
+ }
+
+ // zoomPosition
+ val zoomPosition = findZoomInformation(replyJson)
+ Log.d(TAG, "getEvent zoomPosition: $zoomPosition")
+ if (zoomPosition != -1)
+ {
+ currentZoomPosition = zoomPosition
+ uiHandler.post { listener?.onZoomPositionChanged(zoomPosition) }
+ }
+
+ // storageId
+ val storageId = findStorageId(replyJson) ?: ""
+ Log.d(TAG, "getEvent storageId:$storageId")
+ if (storageId != currentStorageId)
+ {
+ currentStorageId = storageId
+ uiHandler.post { listener?.onStorageIdChanged(storageId) }
+ }
+
+ // focusStatus (v1.1)
+ val focusStatus = findFocusStatus(replyJson) ?: ""
+ Log.d(TAG, "getEvent focusStatus:$focusStatus")
+ if (focusStatus != currentFocusStatus)
+ {
+ currentFocusStatus = focusStatus
+ uiHandler.post { listener?.onFocusStatusChanged(focusStatus) }
+ }
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ }
+
+ private fun findAvailableApiList(replyJson: JSONObject): List<String?>
+ {
+ val availableApis: MutableList<String?> = ArrayList()
+ val indexOfAvailableApiList = 0
+ try
+ {
+ val resultsObj = replyJson.getJSONArray("result")
+ if (!resultsObj.isNull(indexOfAvailableApiList))
+ {
+ val availableApiListObj = resultsObj.getJSONObject(indexOfAvailableApiList)
+ val type = availableApiListObj.getString("type")
+ if ("availableApiList" == type)
+ {
+ val apiArray = availableApiListObj.getJSONArray("names")
+ for (i in 0 until apiArray.length())
+ {
+ availableApis.add(apiArray.getString(i))
+ }
+ }
+ else
+ {
+ Log.w(TAG, "Event reply: Illegal Index (0: AvailableApiList) $type")
+ }
+ }
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ return (availableApis)
+ }
+
+ private fun findCameraStatus(replyJson: JSONObject): String
+ {
+ var cameraStatus = ""
+ val indexOfCameraStatus = 1
+ try
+ {
+ val resultsObj = replyJson.getJSONArray("result")
+ if (!resultsObj.isNull(indexOfCameraStatus))
+ {
+ val cameraStatusObj = resultsObj.getJSONObject(indexOfCameraStatus)
+ val type = cameraStatusObj.getString("type")
+ if ("cameraStatus" == type)
+ {
+ cameraStatus = cameraStatusObj.getString("cameraStatus")
+ }
+ else
+ {
+ Log.w(TAG, "Event reply: Illegal Index (1: CameraStatus) $type")
+ }
+ }
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ return (cameraStatus)
+ }
+
+ private fun findLiveviewStatus(replyJson: JSONObject): Boolean
+ {
+ var liveviewStatus = false
+ try
+ {
+ val indexOfLiveviewStatus = 3
+ val resultsObj = replyJson.getJSONArray("result")
+ if (!resultsObj.isNull(indexOfLiveviewStatus))
+ {
+ val liveviewStatusObj = resultsObj.getJSONObject(indexOfLiveviewStatus)
+ val type = liveviewStatusObj.getString("type")
+ if ("liveviewStatus" == type)
+ {
+ liveviewStatus = liveviewStatusObj.getBoolean("liveviewStatus")
+ }
+ else
+ {
+ Log.w(TAG, "Event reply: Illegal Index (3: LiveviewStatus) $type")
+ }
+ }
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ return (liveviewStatus)
+ }
+
+ private fun findShootMode(replyJson: JSONObject): String
+ {
+ var shootMode = ""
+ try
+ {
+ val indexOfShootMode = 21
+ val resultsObj = replyJson.getJSONArray("result")
+ if (!resultsObj.isNull(indexOfShootMode))
+ {
+ val shootModeObj = resultsObj.getJSONObject(indexOfShootMode)
+ val type = shootModeObj.getString("type")
+ if ("shootMode" == type)
+ {
+ shootMode = shootModeObj.getString("currentShootMode")
+ }
+ else
+ {
+ Log.w(TAG, "Event reply: Illegal Index (21: ShootMode) $type")
+ }
+ }
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ return (shootMode)
+ }
+
+ private fun findAvailableShootModes(replyJson: JSONObject): List<String>
+ {
+ val shootModes: MutableList<String> = ArrayList()
+ try
+ {
+ val indexOfShootMode = 21
+ val resultsObj = replyJson.getJSONArray("result")
+ if (!resultsObj.isNull(indexOfShootMode))
+ {
+ val shootModesObj = resultsObj.getJSONObject(indexOfShootMode)
+ val type = shootModesObj.getString("type")
+ if ("shootMode" == type)
+ {
+ val shootModesArray = shootModesObj.getJSONArray("shootModeCandidates")
+ for (i in 0 until shootModesArray.length())
+ {
+ shootModes.add(shootModesArray.getString(i))
+ }
+ }
+ else
+ {
+ Log.w(TAG, "Event reply: Illegal Index (21: ShootMode) $type")
+ }
+ }
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ return (shootModes)
+ }
+
+ private fun findZoomInformation(replyJson: JSONObject): Int
+ {
+ var zoomPosition = -1
+ try
+ {
+ val indexOfZoomInformation = 2
+ val resultsObj = replyJson.getJSONArray("result")
+ if (!resultsObj.isNull(indexOfZoomInformation))
+ {
+ val zoomInformationObj = resultsObj.getJSONObject(indexOfZoomInformation)
+ val type = zoomInformationObj.getString("type")
+ if ("zoomInformation" == type)
+ {
+ zoomPosition = zoomInformationObj.getInt("zoomPosition")
+ }
+ else
+ {
+ Log.w(TAG, "Event reply: Illegal Index (2: zoomInformation) $type")
+ }
+ }
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ return (zoomPosition)
+ }
+
+ private fun findStorageId(replyJson: JSONObject): String
+ {
+ var storageId = ""
+ try
+ {
+ val indexOfStorageInformation = 10
+ val resultsObj = replyJson.getJSONArray("result")
+ if (!resultsObj.isNull(indexOfStorageInformation))
+ {
+ val storageInformationArray = resultsObj.getJSONArray(indexOfStorageInformation)
+ if (!storageInformationArray.isNull(0))
+ {
+ val storageInformationObj = storageInformationArray.getJSONObject(0)
+ val type = storageInformationObj.getString("type")
+ if ("storageInformation" == type)
+ {
+ storageId = storageInformationObj.getString("storageID")
+ }
+ else
+ {
+ Log.w(TAG, "Event reply: Illegal Index (11: storageInformation) $type")
+ }
+ }
+ }
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ return (storageId)
+ }
+
+ private fun findFocusStatus(replyJson: JSONObject): String
+ {
+ var focusStatus = ""
+ try
+ {
+ val indexOfFocusStatus = 35
+ val resultsObj = replyJson.getJSONArray("result")
+ if (!resultsObj.isNull(indexOfFocusStatus))
+ {
+ val focusStatusObj = resultsObj.getJSONObject(indexOfFocusStatus)
+ val type = focusStatusObj.getString("type")
+ if ("focusStatus" == type)
+ {
+ focusStatus = focusStatusObj.getString("focusStatus")
+ }
+ else
+ {
+ Log.w(TAG, "Event reply: Illegal Index (21: ShootMode) $type")
+ }
+ }
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ return (focusStatus)
+ }
+
+ fun setEventChangeListener(listener: ICameraChangeListener?)
+ {
+ this.listener = listener
+ }
+
+ fun clearEventChangeListener()
+ {
+ listener = null
+ }
+
+ fun catchResponseError()
+ {
+ uiHandler.post { listener?.onResponseError() }
+ }
+
+ override fun getCameraStatus(): String
+ {
+ return cameraStatus
+ }
+
+ override fun getLiveviewStatus(): Boolean
+ {
+ return currentLiveviewStatus
+ }
+
+ override fun getShootMode(): String
+ {
+ return currentShootMode
+ }
+
+ override fun getAvailableShootModes(): List<String?>
+ {
+ return currentAvailableShootModes
+ }
+
+ override fun getZoomPosition(): Int
+ {
+ return currentZoomPosition
+ }
+
+ override fun getStorageId(): String
+ {
+ return currentStorageId
+ }
+
+ companion object
+ {
+ private val TAG = ReplyJsonParser::class.java.simpleName
+ }
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.sony.wrapper.eventlistener
+
+import android.content.Context
+import android.os.Handler
+import android.util.Log
+import org.json.JSONObject
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraStatusHolder
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraChangeListener
+import jp.osdn.gokigen.gokigenassets.camera.sony.wrapper.ISonyCameraApi
+import java.lang.Exception
+import java.lang.Thread.sleep
+
+
+class SonyCameraEventObserver(context: Context, private val remoteApi: ISonyCameraApi, private val sonyStatus: ISonyStatusReceiver) : ISonyCameraEventObserver
+{
+ private val replyParser = ReplyJsonParser(Handler(context.mainLooper))
+ private var isEventMonitoring = false
+ private var isActive = false
+ private var eventVersion = "1.1" // 初期値を "1.0" から "1.1" に更新
+
+ override fun start(): Boolean
+ {
+ if (!isActive)
+ {
+ Log.w(TAG, "start() observer is not active.")
+ return (false)
+ }
+ if (isEventMonitoring)
+ {
+ Log.w(TAG, "start() already starting.")
+ return (false)
+ }
+ isEventMonitoring = true
+ try
+ {
+ val thread = Thread {
+ Log.d(TAG, "start() exec.")
+ var firstCall = true
+ MONITORLOOP@ while (isEventMonitoring)
+ {
+ val longPolling = !firstCall
+ try
+ {
+ val replyJson = remoteApi.getEvent(eventVersion, longPolling) ?: JSONObject()
+ val errorCode = findErrorCode(replyJson)
+ Log.d(TAG, "getEvent errorCode: $errorCode")
+ when (errorCode)
+ {
+ 0 -> { }
+ 1, 12 -> {
+ if (eventVersion == "1.1")
+ {
+ // "1.1" でエラーが発生した時には "1.0" にダウングレードして再実行
+ eventVersion = "1.0"
+ continue@MONITORLOOP
+ }
+ replyParser.catchResponseError()
+ break@MONITORLOOP // "1.0" でもエラーが発生した場合は、モニタ終了
+ }
+ 2 -> { continue@MONITORLOOP } // タイムアウト、即時再実行
+ 40402 -> {
+ // 5秒待ち後、再実行
+ try
+ {
+ sleep(5000)
+ }
+ catch (e: InterruptedException)
+ {
+ // do nothing.
+ }
+ continue@MONITORLOOP
+ }
+ else -> {
+ // その他の応答、、エラー終了
+ Log.w(TAG, "SimpleCameraEventObserver: Unexpected error: $errorCode")
+ replyParser.catchResponseError()
+ break@MONITORLOOP // モニタ終了
+ }
+ }
+ replyParser.parse(replyJson)
+ sonyStatus.updateStatus(replyJson)
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ firstCall = false
+ } // MONITORLOOP end.
+ isEventMonitoring = false
+ }
+ thread.start()
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ return (true)
+ }
+
+ override fun stop()
+ {
+ isEventMonitoring = false
+ }
+
+ override fun release()
+ {
+ isEventMonitoring = false
+ isActive = false
+ }
+
+ override fun setEventListener(listener: ICameraChangeListener)
+ {
+ try
+ {
+ replyParser.setEventChangeListener(listener)
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ }
+
+ override fun clearEventListener()
+ {
+ try
+ {
+ replyParser.clearEventChangeListener()
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ }
+
+ override fun getCameraStatusHolder(): ICameraStatusHolder
+ {
+ return replyParser
+ }
+
+ override fun activate()
+ {
+ isActive = true
+ }
+
+ private fun findErrorCode(replyJson: JSONObject?): Int
+ {
+ var code = 0 // 0 means no error.
+ try
+ {
+ if (replyJson?.has("error") == true)
+ {
+ val errorObj = replyJson.getJSONArray("error")
+ code = errorObj.getInt(0)
+ }
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ code = -1
+ }
+ return (code)
+ }
+
+ companion object
+ {
+ private val TAG = SonyCameraEventObserver::class.java.simpleName
+
+ fun newInstance(context: Context, apiClient: ISonyCameraApi, sonyStatus: ISonyStatusReceiver): ISonyCameraEventObserver
+ {
+ return SonyCameraEventObserver(context, apiClient, sonyStatus)
+ }
+ }
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.sony.wrapper.eventlistener
+
+import android.graphics.Color
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.*
+import jp.osdn.gokigen.gokigenassets.liveview.message.IMessageDrawer
+import org.json.JSONObject
+
+class SonyStatus(jsonObject : JSONObject) : ICameraStatusUpdateNotify, ICameraStatusWatcher, ICameraStatus, ICameraChangeListener, ISonyStatusReceiver
+{
+ private var jsonObject : JSONObject
+ init
+ {
+ this.jsonObject = jsonObject
+ }
+
+ override fun updatedTakeMode(mode: String?) { }
+
+ override fun updatedShutterSpeed(tv: String?) { }
+
+ override fun updatedAperture(av: String?) { }
+
+ override fun updatedExposureCompensation(xv: String?) { }
+
+ override fun updatedMeteringMode(meteringMode: String?) { }
+
+ override fun updatedWBMode(wbMode: String?) {}
+
+ override fun updateRemainBattery(percentage: Int) {}
+
+ override fun updateFocusedStatus(focused: Boolean, focusLocked: Boolean) {}
+
+ override fun updateIsoSensitivity(sv: String?) {}
+
+ override fun updateWarning(warning: String?) {}
+
+ override fun updateStorageStatus(status: String?) {}
+
+ override fun startStatusWatch(indicator: IMessageDrawer?, notifier: ICameraStatusUpdateNotify?) { }
+
+ override fun stopStatusWatch() { }
+
+ override fun setStatus(key: String, value: String) { }
+
+ override fun getStatusList(key: String): List<String?>
+ {
+ return (ArrayList())
+ }
+
+ override fun getStatus(key: String): String
+ {
+ return ("")
+ }
+
+ override fun getStatusColor(key: String): Int
+ {
+ return (Color.WHITE)
+ }
+
+ override fun onApiListModified(apis: List<String?>?) {
+ //TODO("Not yet implemented")
+ }
+
+ override fun onCameraStatusChanged(status: String?) {
+ //TODO("Not yet implemented")
+ }
+
+ override fun onLiveviewStatusChanged(status: Boolean) {
+ //TODO("Not yet implemented")
+ }
+
+ override fun onShootModeChanged(shootMode: String?) {
+ //TODO("Not yet implemented")
+ }
+
+ override fun onZoomPositionChanged(zoomPosition: Int) {
+ //TODO("Not yet implemented")
+ }
+
+ override fun onStorageIdChanged(storageId: String?) {
+ //TODO("Not yet implemented")
+ }
+
+ override fun onFocusStatusChanged(focusStatus: String?) {
+ //TODO("Not yet implemented")
+ }
+
+ override fun onResponseError() {
+ //TODO("Not yet implemented")
+ }
+
+ override fun updateStatus(jsonObject: JSONObject)
+ {
+ this.jsonObject = jsonObject
+ }
+
+}
const val PREFERENCE_CAMERA_METHOD_THETA = "THETA"
const val PREFERENCE_CAMERA_METHOD_PENTAX = "RICOH"
const val PREFERENCE_CAMERA_METHOD_PANASONIC = "PANASONIC"
+ const val PREFERENCE_CAMERA_METHOD_SONY = "SONY"
}
}
import jp.osdn.gokigen.gokigenassets.constants.ICameraConnectionMethods.Companion.PREFERENCE_CAMERA_METHOD_NONE
import jp.osdn.gokigen.gokigenassets.constants.ICameraConnectionMethods.Companion.PREFERENCE_CAMERA_METHOD_PANASONIC
import jp.osdn.gokigen.gokigenassets.constants.ICameraConnectionMethods.Companion.PREFERENCE_CAMERA_METHOD_PENTAX
+import jp.osdn.gokigen.gokigenassets.constants.ICameraConnectionMethods.Companion.PREFERENCE_CAMERA_METHOD_SONY
import jp.osdn.gokigen.gokigenassets.constants.ICameraConnectionMethods.Companion.PREFERENCE_CAMERA_METHOD_THETA
class MainPreferenceFragment : PreferenceFragmentCompat(), IPreferenceViewUpdater
PREFERENCE_CAMERA_METHOD_THETA -> updatePreferenceItemVisibility(true, sequenceKey, option1Key, option2Key, option3Key, option4Key, option5Key)
PREFERENCE_CAMERA_METHOD_PENTAX -> updatePreferenceItemVisibility(true, sequenceKey, option1Key, option2Key, option3Key, option4Key, option5Key)
PREFERENCE_CAMERA_METHOD_PANASONIC -> updatePreferenceItemVisibility(true, sequenceKey, option1Key, option2Key, option3Key, option4Key, option5Key)
+ PREFERENCE_CAMERA_METHOD_SONY -> updatePreferenceItemVisibility(true, sequenceKey, option1Key, option2Key, option3Key, option4Key, option5Key)
else -> updatePreferenceItemVisibility(false, sequenceKey, option1Key, option2Key, option3Key, option4Key, option5Key)
}
}
import jp.osdn.gokigen.gokigenassets.camera.interfaces.*
import jp.osdn.gokigen.gokigenassets.camera.panasonic.wrapper.PanasonicCameraControl
import jp.osdn.gokigen.gokigenassets.camera.ricohpentax.RicohPentaxCameraControl
+import jp.osdn.gokigen.gokigenassets.camera.sony.SonyCameraControl
import jp.osdn.gokigen.gokigenassets.camera.theta.ThetaCameraControl
import jp.osdn.gokigen.gokigenassets.constants.ICameraConnectionMethods.Companion.PREFERENCE_CAMERA_METHOD_CAMERAX
import jp.osdn.gokigen.gokigenassets.constants.ICameraConnectionMethods.Companion.PREFERENCE_CAMERA_METHOD_CONSOLE
import jp.osdn.gokigen.gokigenassets.constants.ICameraConnectionMethods.Companion.PREFERENCE_CAMERA_METHOD_NONE
import jp.osdn.gokigen.gokigenassets.constants.ICameraConnectionMethods.Companion.PREFERENCE_CAMERA_METHOD_PANASONIC
import jp.osdn.gokigen.gokigenassets.constants.ICameraConnectionMethods.Companion.PREFERENCE_CAMERA_METHOD_PENTAX
+import jp.osdn.gokigen.gokigenassets.constants.ICameraConnectionMethods.Companion.PREFERENCE_CAMERA_METHOD_SONY
import jp.osdn.gokigen.gokigenassets.constants.ICameraConnectionMethods.Companion.PREFERENCE_CAMERA_METHOD_THETA
import jp.osdn.gokigen.gokigenassets.preference.PreferenceAccessWrapper
import jp.osdn.gokigen.gokigenassets.scene.IInformationReceiver
PREFERENCE_CAMERA_METHOD_THETA -> prepareThetaCameraControl(cameraPreference)
PREFERENCE_CAMERA_METHOD_PENTAX -> preparePentaxCameraControl(cameraPreference)
PREFERENCE_CAMERA_METHOD_PANASONIC -> preparePanasonicCameraControl(cameraPreference)
+ PREFERENCE_CAMERA_METHOD_SONY -> prepareSonyCameraControl(cameraPreference)
else -> DummyCameraControl()
})
}
return (PanasonicCameraControl(activity, vibrator, informationNotify, cameraPreference, statusReceiver))
}
+ private fun prepareSonyCameraControl(cameraPreference : ICameraPreferenceProvider) : ICameraControl
+ {
+ return (SonyCameraControl(activity, vibrator, informationNotify, cameraPreference, statusReceiver))
+ }
+
private fun prepareConsolePanelControl(cameraPreference : ICameraPreferenceProvider) : ICameraControl
{
return (ConsolePanelControl(activity, vibrator, informationNotify, cameraPreference))
<item>Ricoh GR / PENTAX</item>
<item>Ricoh Theta(OSC)</item>
<item>Panasonic (MFT)</item>
+ <item>Sony</item>
<!--
<item>OPC(Olympus Air)</item>
<item>Olympus(OM-D/PEN)</item>
<item>KODAK PIXPRO</item>
<item>Fuji X Series</item>
- <item>Sony</item>
<item>Canon</item>
<item>Nikon</item>
-->
<item>RICOH</item>
<item>THETA</item>
<item>PANASONIC</item>
+ <item>SONY</item>
<!--
<item>OPC</item>
<item>OLYMPUS</item>
<item>PIXPRO</item>
<item>FUJI_X</item>
- <item>SONY</item>
<item>CANON</item>
<item>NIKON</item>
-->
<item>Ricoh GR / PENTAX</item>
<item>Ricoh Theta(OSC)</item>
<item>Panasonic (MFT)</item>
-<!--
- <item>OPC(Olympus Air)</item>
- <item>Olympus(OM-D/PEN)</item>
- <item>KODAK PIXPRO</item>
- <item>Fuji X Series</item>
<item>Sony</item>
- <item>Canon</item>
- <item>Nikon</item>
--->
+
+ <!--
+ <item>OPC(Olympus Air)</item>
+ <item>Olympus(OM-D/PEN)</item>
+ <item>KODAK PIXPRO</item>
+ <item>Fuji X Series</item>
+ <item>Canon</item>
+ <item>Nikon</item>
+ -->
</string-array>
<string-array name="connection_method_value">
<item>RICOH</item>
<item>THETA</item>
<item>PANASONIC</item>
-<!--
- <item>OPC</item>
- <item>OLYMPUS</item>
- <item>PIXPRO</item>
- <item>FUJI_X</item>
<item>SONY</item>
- <item>CANON</item>
- <item>NIKON</item>
--->
+
+ <!--
+ <item>OPC</item>
+ <item>OLYMPUS</item>
+ <item>PIXPRO</item>
+ <item>FUJI_X</item>
+ <item>CANON</item>
+ <item>NIKON</item>
+ -->
</string-array>
<string-array name="connection_sequence">