dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
- implementation 'androidx.core:core-ktx:1.3.2'
- implementation 'androidx.appcompat:appcompat:1.2.0'
+ implementation 'androidx.core:core-ktx:1.5.0'
+ implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.preference:preference-ktx:1.1.1'
implementation 'com.google.android.material:material:1.3.0'
//androidTestImplementation 'androidx.test.ext:junit:1.1.2'
//androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
- def camerax_version = "1.1.0-alpha04"
+ def camerax_version = "1.1.0-alpha05"
implementation "androidx.camera:camera-camera2:$camerax_version"
implementation "androidx.camera:camera-lifecycle:$camerax_version"
- implementation "androidx.camera:camera-view:1.0.0-alpha24"
+ implementation "androidx.camera:camera-view:1.0.0-alpha25"
implementation "androidx.datastore:datastore-preferences:1.0.0-beta01"
}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera
+
+class CameraPreference(private val method : String, private val sequence : String = "0", private val option1 : String = "", private val option2 : String = "", private val option3 : String = "", private val option4 : String = "", private val option5 : String = "") : ICameraPreferenceProvider
+{
+ override fun getCameraMethod(): String
+ {
+ return (method)
+ }
+
+ override fun getConnectionSequence(): String
+ {
+ return (sequence)
+ }
+
+ override fun getCameraOption1(): String
+ {
+ return (option1)
+ }
+
+ override fun getCameraOption2(): String
+ {
+ return (option2)
+ }
+
+ override fun getCameraOption3(): String
+ {
+ return (option3)
+ }
+
+ override fun getCameraOption4(): String
+ {
+ return (option4)
+ }
+
+ override fun getCameraOption5(): String
+ {
+ return (option5)
+ }
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera
+
+interface ICameraPreferenceProvider
+{
+ fun getCameraMethod() : String
+ fun getConnectionSequence() : String
+
+ fun getCameraOption1() : String
+ fun getCameraOption2() : String
+ fun getCameraOption3() : String
+ fun getCameraOption4() : String
+ fun getCameraOption5() : String
+}
import androidx.camera.core.Preview
import androidx.camera.lifecycle.ProcessCameraProvider
import androidx.core.content.ContextCompat
+import jp.osdn.gokigen.gokigenassets.camera.ICameraPreferenceProvider
import jp.osdn.gokigen.gokigenassets.constants.IApplicationConstantConvert.Companion.ID_CAMERA_X_PREVIEW_LAYOUT
import jp.osdn.gokigen.gokigenassets.liveview.ILiveView
import jp.osdn.gokigen.gokigenassets.liveview.ILiveViewRefresher
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
-class CameraControl(private val activity : AppCompatActivity) : ICameraControl
+class CameraControl(private val activity : AppCompatActivity, private val preference: ICameraPreferenceProvider) : ICameraControl
{
private lateinit var cameraExecutor: ExecutorService
private lateinit var liveViewListener : CameraLiveViewListenerImpl
import androidx.appcompat.app.AppCompatActivity
import androidx.camera.core.CameraSelector
import androidx.fragment.app.FragmentActivity
+import jp.osdn.gokigen.gokigenassets.camera.ICameraPreferenceProvider
import jp.osdn.gokigen.gokigenassets.camera.interfaces.*
import jp.osdn.gokigen.gokigenassets.camera.theta.status.ICaptureModeReceiver
import jp.osdn.gokigen.gokigenassets.liveview.ILiveView
import jp.osdn.gokigen.gokigenassets.liveview.image.CameraLiveViewListenerImpl
import jp.osdn.gokigen.gokigenassets.scene.IVibrator
-class RicohPentaxCameraControl(private val context: AppCompatActivity, private val vibrator : IVibrator, statusReceiver : ICameraStatusReceiver) : ILiveViewController, ICameraControl, View.OnClickListener,
+class RicohPentaxCameraControl(private val context: AppCompatActivity, private val vibrator : IVibrator, private val preference: ICameraPreferenceProvider, statusReceiver : ICameraStatusReceiver) : ILiveViewController, ICameraControl, View.OnClickListener,
ICaptureModeReceiver, ICameraShutter, IDisplayInjector, IUseGR2CommandNotify
{
//private final Activity activity;
//private final ICameraStatusReceiver provider;
private var liveViewListener = CameraLiveViewListenerImpl(context)
- private val gr2Connection = RicohGr2Connection(context, statusReceiver, this)
+ private val gr2Connection = RicohGr2Connection(context, statusReceiver, this, this)
private val buttonControl = RicohGr2CameraButtonControl()
private val statusChecker = RicohGr2StatusChecker(500)
private val playbackControl = RicohGr2PlaybackControl(communicationTimeoutMs)
override fun stopLiveView()
{
+ Log.v(TAG, " stopLiveView() ")
try
{
liveViewControl.stopLiveView()
+ if (isStatusWatch)
+ {
+ statusChecker.stopStatusWatch()
+ isStatusWatch = false
+ }
}
catch (e : Exception)
{
override fun changeCaptureMode(mode: String)
{
- TODO("Not yet implemented")
+ //TODO("Not yet implemented")
}
override fun changedCaptureMode(captureMode: String)
{
- TODO("Not yet implemented")
+ //TODO("Not yet implemented")
}
override fun doShutter()
import android.util.Log
import androidx.preference.PreferenceManager
import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraConnection
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraConnectionStatus
import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraStatusReceiver
import jp.osdn.gokigen.gokigenassets.constants.IApplicationConstantConvert.Companion.ID_PREFERENCE_RICOH_GR2_LCD_SLEEP
import jp.osdn.gokigen.gokigenassets.constants.IApplicationConstantConvert.Companion.ID_PREFERENCE_USE_GR2_SPECIAL_COMMAND
import jp.osdn.gokigen.gokigenassets.constants.ICameraConstantConvert.Companion.ID_STRING_CONNECT_CONNECTED
import jp.osdn.gokigen.gokigenassets.utils.communication.SimpleHttpClient
-class RicohGr2CameraConnectSequence(private val context: Activity, private val cameraStatusReceiver: ICameraStatusReceiver, private val cameraConnection: ICameraConnection, private val gr2CommandNotify: IUseGR2CommandNotify, private val executeUrl : String = "http://192.168.1.1") : Runnable {
+class RicohGr2CameraConnectSequence(private val context: Activity, private val cameraStatusReceiver: ICameraStatusReceiver, private val cameraConnection: ICameraConnection, private val gr2CommandNotify: IUseGR2CommandNotify, private val executeUrl : String = "http://192.168.0.1") : Runnable {
companion object
{
cameraStatusReceiver.onStatusNotify(context.getString(ID_STRING_CONNECT_CONNECTED))
cameraStatusReceiver.onCameraConnected()
Log.v(TAG, "onConnectNotify()")
+ cameraConnection.forceUpdateConnectionStatus(ICameraConnectionStatus.CameraConnectionStatus.CONNECTED)
}
thread.start()
}
import android.util.Log
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.FragmentActivity
-import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraConnection
-import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraConnectionStatus
-import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraStatusReceiver
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.*
import jp.osdn.gokigen.gokigenassets.constants.ICameraConstantConvert.Companion.ID_STRING_CONNECT_CHECK_WIFI
import jp.osdn.gokigen.gokigenassets.constants.ICameraConstantConvert.Companion.ID_STRING_DIALOG_BUTTON_NETWORK_SETTINGS
import jp.osdn.gokigen.gokigenassets.constants.ICameraConstantConvert.Companion.ID_STRING_DIALOG_BUTTON_RETRY
import java.util.concurrent.Executor
import java.util.concurrent.Executors
-
/**
*
*
*/
-class RicohGr2Connection(private val context: FragmentActivity, private val statusReceiver: ICameraStatusReceiver, private val gr2CommandNotify: IUseGR2CommandNotify) : ICameraConnection
+class RicohGr2Connection(private val context: FragmentActivity, private val statusReceiver: ICameraStatusReceiver, private val liveViewControl: ILiveViewController, private val gr2CommandNotify: IUseGR2CommandNotify) : ICameraConnection
{
companion object
{
private fun onReceiveBroadcastOfConnection(context: Context, intent: Intent) {
statusReceiver.onStatusNotify(context.getString(ID_STRING_CONNECT_CHECK_WIFI))
Log.v(TAG, context.getString(ID_STRING_CONNECT_CHECK_WIFI))
- val action = intent.action
- if (action == null) {
- Log.v(TAG, "intent.getAction() : null")
- return
- }
try
{
+ val action = intent.action
+ if (action == null)
+ {
+ Log.v(TAG, "intent.getAction() : null")
+ return
+ }
+
@Suppress("DEPRECATION")
if (action == ConnectivityManager.CONNECTIVITY_ACTION)
{
Log.v(TAG, "onReceiveBroadcastOfConnection() : CONNECTIVITY_ACTION")
val wifiManager = context.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager
- if (wifiManager != null) {
- val info = wifiManager.connectionInfo
- if (wifiManager.isWifiEnabled && info != null) {
- if (info.networkId == -1) {
- Log.v(TAG, "Network ID is -1, there is no currently connected network.")
- } else {
- Log.v(TAG, "Network ID is " + info.networkId)
- }
- // 自動接続が指示されていた場合は、カメラとの接続処理を行う
- connectToCamera()
- } else {
- if (info == null) {
- Log.v(TAG, "NETWORK INFO IS NULL.")
- } else {
- Log.v(
- TAG,
- "isWifiEnabled : " + wifiManager.isWifiEnabled + " NetworkId : " + info.networkId
- )
- }
+ val info = wifiManager.connectionInfo
+ if (wifiManager.isWifiEnabled && info != null)
+ {
+ Log.v(TAG, "Network ID is " + info.networkId)
+ // 自動接続が指示されていた場合は、カメラとの接続処理を行う
+ connectToCamera()
+ }
+ else
+ {
+ if (info == null)
+ {
+ Log.v(TAG, "NETWORK INFO IS NULL.")
+ }
+ else
+ {
+ Log.v(TAG, "isWifiEnabled : " + wifiManager.isWifiEnabled + " NetworkId : " + info.networkId)
}
}
}
- } catch (e: Exception) {
+ }
+ catch (e: Exception)
+ {
Log.w(TAG, "onReceiveBroadcastOfConnection() EXCEPTION" + e.message)
e.printStackTrace()
}
*
*
*/
- override fun alertConnectingFailed(message: String?) {
+ override fun alertConnectingFailed(message: String?)
+ {
Log.v(TAG, "alertConnectingFailed() : $message")
- if (context != null) {
+ try
+ {
val builder: AlertDialog.Builder = AlertDialog.Builder(context)
.setTitle(context.getString(ID_STRING_DIALOG_TITLE_CONNECT_FAILED))
.setMessage(message)
.setPositiveButton(
context.getString(ID_STRING_DIALOG_BUTTON_RETRY)
- ) { dialog, which -> connect() }
+ ) { _, _ -> connect() }
.setNeutralButton(ID_STRING_DIALOG_BUTTON_NETWORK_SETTINGS
- ) { dialog, which ->
+ ) { _, _ ->
try {
// Wifi 設定画面を表示する
context.startActivity(Intent(Settings.ACTION_WIFI_SETTINGS))
e.printStackTrace()
}
}
- context.runOnUiThread({ builder.show() })
+ context.runOnUiThread { builder.show() }
+ }
+ catch (e : Exception)
+ {
+ e.printStackTrace()
}
}
*
*
*/
- override fun forceUpdateConnectionStatus(status: ICameraConnectionStatus.CameraConnectionStatus) {
+ override fun forceUpdateConnectionStatus(status: ICameraConnectionStatus.CameraConnectionStatus)
+ {
Log.v(TAG, "forceUpdateConnectionStatus()")
connectionStatus = status
+ if (status == ICameraConnectionStatus.CameraConnectionStatus.CONNECTED)
+ {
+ liveViewControl.startLiveView()
+ }
+ else if (status == ICameraConnectionStatus.CameraConnectionStatus.DISCONNECTED)
+ {
+ liveViewControl.stopLiveView()
+ }
+
+
}
/**
private const val FETCH_ERROR_MAX = 30
}
- override fun setUseGR2Command(useGR2cmd: Boolean, useCameraScreen: Boolean) {
- this.useGR2command = useGR2cmd
+ override fun setUseGR2Command(useGR2Command: Boolean, useCameraScreen: Boolean)
+ {
+ this.useGR2command = useGR2Command
this.useCameraScreen = useCameraScreen
}
-/*
- fun changeLiveViewSize(size: String?) {
- //
- }
-*/
-
- override fun startLiveView() {
+ override fun startLiveView()
+ {
val isCameraScreen = useGR2command && useCameraScreen
- Log.v(TAG, "startLiveView()")
- try {
+ Log.v(TAG, "startLiveView() : $isCameraScreen ($useGR2command)")
+ try
+ {
val thread = Thread {
- try {
- if (isCameraScreen) {
+ try
+ {
+ if (isCameraScreen)
+ {
start(cameraDisplayUrl)
- } else {
+ }
+ else
+ {
start(liveViewUrl)
}
- } catch (e: Exception) {
+ }
+ catch (e: Exception)
+ {
e.printStackTrace()
}
}
thread.start()
- } catch (e: Exception) {
+ }
+ catch (e: Exception)
+ {
e.printStackTrace()
}
}
- override fun stopLiveView() {
+ override fun stopLiveView()
+ {
Log.v(TAG, "stopLiveView()")
whileFetching = false
}
- private fun start(streamUrl: String) {
- if (whileFetching) {
+ private fun start(streamUrl: String)
+ {
+ 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
var continuousNullDataReceived = 0
- try {
- // Create Slicer to open the stream and parse it.
+ try
+ {
slicer = SimpleLiveViewSlicer()
slicer.open(streamUrl)
- while (whileFetching) {
+ while (whileFetching)
+ {
val payload: SimpleLiveViewSlicer.Payload? = slicer.nextPayloadForMotionJpeg()
- if (payload == null) {
- //Log.v(TAG, "Liveview Payload is null.");
+ if (payload == null)
+ {
+ Log.v(TAG, "Liveview Payload is null.")
continuousNullDataReceived++
- if (continuousNullDataReceived > FETCH_ERROR_MAX) {
+ if (continuousNullDataReceived > FETCH_ERROR_MAX)
+ {
Log.d(TAG, " FETCH ERROR MAX OVER ")
break
}
continue
}
val jpegData = payload.getJpegData()
- if (jpegData != null) {
+ if (jpegData != null)
+ {
liveViewListener.onUpdateLiveView(jpegData, null)
}
+ else
+ {
+ Log.v(TAG, " jpegData is NULL...")
+ }
continuousNullDataReceived = 0
}
- } catch (e: Exception) {
+ }
+ catch (e: Exception)
+ {
e.printStackTrace()
- } finally {
- try {
+ }
+ finally
+ {
+ try
+ {
slicer?.close()
- } catch (e: Exception) {
+ }
+ catch (e: Exception)
+ {
e.printStackTrace()
}
- //mJpegQueue.clear();
- if (!whileFetching && continuousNullDataReceived > FETCH_ERROR_MAX) {
+ if (!whileFetching && continuousNullDataReceived > FETCH_ERROR_MAX)
+ {
// 再度ライブビューのスタートをやってみる。
whileFetching = false
- //continuousNullDataReceived = 0;
start(streamUrl)
}
}
}
thread.start()
- } catch (e: Exception) {
+ }
+ catch (e: Exception)
+ {
e.printStackTrace()
}
}
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.camera.core.CameraSelector
+import jp.osdn.gokigen.gokigenassets.camera.ICameraPreferenceProvider
import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraConnectionStatus
import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraStatusReceiver
import jp.osdn.gokigen.gokigenassets.camera.interfaces.ILiveViewController
import jp.osdn.gokigen.gokigenassets.preference.PreferenceAccessWrapper
import jp.osdn.gokigen.gokigenassets.scene.IVibrator
-class ThetaCameraControl(private val context: AppCompatActivity, private val vibrator : IVibrator, statusReceiver : ICameraStatusReceiver) : ILiveViewController,
+class ThetaCameraControl(private val context: AppCompatActivity, private val vibrator : IVibrator, private val preference: ICameraPreferenceProvider, statusReceiver : ICameraStatusReceiver) : ILiveViewController,
ICameraControl, View.OnClickListener, ICaptureModeReceiver, ICameraShutter
{
private val sessionIdHolder = ThetaSessionHolder()
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.constants
+
+interface ICameraConnectionMethods
+{
+ companion object
+ {
+ // --- CONNECTION METHOD
+ const val PREFERENCE_CAMERA_METHOD_NONE = "none"
+ const val PREFERENCE_CAMERA_METHOD_CAMERAX = "camerax"
+ const val PREFERENCE_CAMERA_METHOD_THETA = "THETA"
+ const val PREFERENCE_CAMERA_METHOD_PENTAX = "RICOH"
+ }
+}
{
try
{
- //Log.v(TAG, "onUpdateLiveView()")
insertCache(data, 0)
isImageReceived = true
refresh()
}
}
- @SuppressLint("UnsafeExperimentalUsageError")
+ @SuppressLint("UnsafeExperimentalUsageError", "UnsafeOptInUsageError")
override fun analyze(imageProxy: ImageProxy)
{
try
mHttpConn?.connect()
if (mHttpConn?.responseCode == HttpURLConnection.HTTP_OK)
{
+ Log.v(TAG, " LIVEVIEW REQUEST ACCEPTED : ${mHttpConn?.responseCode}")
mInputStream = mHttpConn?.inputStream
}
+ else
+ {
+ Log.v(TAG, " LIVEVIEW REQUEST RESPONSE NG : ${mHttpConn?.responseCode}")
+ }
}
catch (e: Exception)
{
// --- RICOH/PENTAX
const val GR2_LCD_SLEEP = "gr2_lcd_sleep"
const val USE_GR2_SPECIAL_COMMAND = "use_gr2_command"
-
- // --- CONNECTION METHOD
- const val PREFERENCE_CAMERA_METHOD_NONE = "none"
const val PREFERENCE_CONNECTION_METHOD = "connection_method"
// --- CAMERA 1 PREFERENCES
{
editor.putString(IPreferencePropertyAccessor.THETA_LIVEVIEW_RESOLUTION, IPreferencePropertyAccessor.THETA_LIVEVIEW_RESOLUTION_DEFAULT_VALUE)
}
+
+ ///// CAMERA METHOD /////
if (!items.containsKey(IPreferencePropertyAccessor.PREFERENCE_CAMERA_METHOD_1))
{
editor.putString(IPreferencePropertyAccessor.PREFERENCE_CAMERA_METHOD_1, IPreferencePropertyAccessor.PREFERENCE_CAMERA_METHOD_1_DEFAULT_VALUE)
{
editor.putString(IPreferencePropertyAccessor.PREFERENCE_CAMERA_METHOD_4, IPreferencePropertyAccessor.PREFERENCE_CAMERA_METHOD_4_DEFAULT_VALUE)
}
+
+ ///// CONNECTION SEQUENCE /////
if (!items.containsKey(IPreferencePropertyAccessor.PREFERENCE_CAMERA_SEQUENCE_1))
{
editor.putString(IPreferencePropertyAccessor.PREFERENCE_CAMERA_SEQUENCE_1, IPreferencePropertyAccessor.PREFERENCE_CAMERA_SEQUENCE_1_DEFAULT_VALUE)
editor.putString(IPreferencePropertyAccessor.PREFERENCE_CAMERA_SEQUENCE_4, IPreferencePropertyAccessor.PREFERENCE_CAMERA_SEQUENCE_4_DEFAULT_VALUE)
}
+ ////////// CAMERA 1 //////////
if (!items.containsKey(IPreferencePropertyAccessor.PREFERENCE_CAMERA_OPTION1_1))
{
editor.putString(IPreferencePropertyAccessor.PREFERENCE_CAMERA_OPTION1_1, IPreferencePropertyAccessor.PREFERENCE_CAMERA_OPTION1_1_DEFAULT_VALUE)
editor.putString(IPreferencePropertyAccessor.PREFERENCE_CAMERA_OPTION5_1, IPreferencePropertyAccessor.PREFERENCE_CAMERA_OPTION5_1_DEFAULT_VALUE)
}
+ ////////// CAMERA 2 //////////
if (!items.containsKey(IPreferencePropertyAccessor.PREFERENCE_CAMERA_OPTION1_2))
{
editor.putString(IPreferencePropertyAccessor.PREFERENCE_CAMERA_OPTION1_2, IPreferencePropertyAccessor.PREFERENCE_CAMERA_OPTION1_2_DEFAULT_VALUE)
editor.putString(IPreferencePropertyAccessor.PREFERENCE_CAMERA_OPTION5_2, IPreferencePropertyAccessor.PREFERENCE_CAMERA_OPTION5_2_DEFAULT_VALUE)
}
+ ////////// CAMERA 3 //////////
if (!items.containsKey(IPreferencePropertyAccessor.PREFERENCE_CAMERA_OPTION1_3))
{
editor.putString(IPreferencePropertyAccessor.PREFERENCE_CAMERA_OPTION1_3, IPreferencePropertyAccessor.PREFERENCE_CAMERA_OPTION1_3_DEFAULT_VALUE)
editor.putString(IPreferencePropertyAccessor.PREFERENCE_CAMERA_OPTION5_3, IPreferencePropertyAccessor.PREFERENCE_CAMERA_OPTION5_3_DEFAULT_VALUE)
}
+ ////////// CAMERA 4 //////////
if (!items.containsKey(IPreferencePropertyAccessor.PREFERENCE_CAMERA_OPTION1_4))
{
editor.putString(IPreferencePropertyAccessor.PREFERENCE_CAMERA_OPTION1_4, IPreferencePropertyAccessor.PREFERENCE_CAMERA_OPTION1_4_DEFAULT_VALUE)
--- /dev/null
+package jp.osdn.gokigen.mangle.scene
+
+import androidx.appcompat.app.AppCompatActivity
+import jp.osdn.gokigen.gokigenassets.camera.CameraPreference
+import jp.osdn.gokigen.gokigenassets.camera.DummyCameraControl
+import jp.osdn.gokigen.gokigenassets.camera.ICameraPreferenceProvider
+import jp.osdn.gokigen.gokigenassets.camera.camerax.operation.CameraControl
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraControl
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraStatusReceiver
+import jp.osdn.gokigen.gokigenassets.camera.ricohpentax.RicohPentaxCameraControl
+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_NONE
+import jp.osdn.gokigen.gokigenassets.constants.ICameraConnectionMethods.Companion.PREFERENCE_CAMERA_METHOD_PENTAX
+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
+import jp.osdn.gokigen.gokigenassets.scene.IVibrator
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_METHOD_1
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_METHOD_1_DEFAULT_VALUE
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_METHOD_2
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_METHOD_2_DEFAULT_VALUE
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_METHOD_3
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_METHOD_3_DEFAULT_VALUE
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_METHOD_4
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_METHOD_4_DEFAULT_VALUE
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION1_1
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION1_1_DEFAULT_VALUE
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION1_2
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION1_2_DEFAULT_VALUE
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION1_3
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION1_3_DEFAULT_VALUE
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION1_4
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION1_4_DEFAULT_VALUE
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION2_1
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION2_1_DEFAULT_VALUE
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION2_2
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION2_2_DEFAULT_VALUE
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION2_3
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION2_3_DEFAULT_VALUE
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION2_4
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION2_4_DEFAULT_VALUE
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION3_1
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION3_1_DEFAULT_VALUE
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION3_2
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION3_2_DEFAULT_VALUE
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION3_3
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION3_3_DEFAULT_VALUE
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION3_4
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION3_4_DEFAULT_VALUE
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION4_1
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION4_1_DEFAULT_VALUE
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION4_2
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION4_2_DEFAULT_VALUE
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION4_3
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION4_3_DEFAULT_VALUE
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION4_4
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION4_4_DEFAULT_VALUE
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION5_1
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION5_1_DEFAULT_VALUE
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION5_2
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION5_2_DEFAULT_VALUE
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION5_3
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION5_3_DEFAULT_VALUE
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION5_4
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_OPTION5_4_DEFAULT_VALUE
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_SEQUENCE_1
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_SEQUENCE_1_DEFAULT_VALUE
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_SEQUENCE_2
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_SEQUENCE_2_DEFAULT_VALUE
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_SEQUENCE_3
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_SEQUENCE_3_DEFAULT_VALUE
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_SEQUENCE_4
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_SEQUENCE_4_DEFAULT_VALUE
+
+class CameraProvider(private val activity: AppCompatActivity, private val informationNotify: IInformationReceiver, private val vibrator : IVibrator, private val statusReceiver : ICameraStatusReceiver)
+{
+ private var cameraXisCreated = false
+ private lateinit var cameraXControl: ICameraControl
+
+ fun decideCameraControl(preferenceKey : String) : ICameraControl
+ {
+ try
+ {
+ val wrapper = PreferenceAccessWrapper(activity)
+ val cameraPreference = when (preferenceKey) {
+ PREFERENCE_CAMERA_METHOD_1 -> setupCameraPreference1(wrapper)
+ PREFERENCE_CAMERA_METHOD_2 -> setupCameraPreference2(wrapper)
+ PREFERENCE_CAMERA_METHOD_3 -> setupCameraPreference3(wrapper)
+ PREFERENCE_CAMERA_METHOD_4 -> setupCameraPreference4(wrapper)
+ else -> setupCameraPreference0()
+ }
+ return (when (cameraPreference.getCameraMethod()) {
+ PREFERENCE_CAMERA_METHOD_NONE -> DummyCameraControl()
+ PREFERENCE_CAMERA_METHOD_CAMERAX -> prepareCameraXControl(cameraPreference)
+ PREFERENCE_CAMERA_METHOD_THETA -> prepareThetaCameraControl(cameraPreference)
+ PREFERENCE_CAMERA_METHOD_PENTAX -> preparePentaxCameraControl(cameraPreference)
+ else -> DummyCameraControl()
+ })
+ }
+ catch (e : Exception)
+ {
+ e.printStackTrace()
+ }
+ return (DummyCameraControl())
+ }
+
+ fun getCameraXControl() : ICameraControl
+ {
+ try
+ {
+ return (prepareCameraXControl(setupCameraPreference0()))
+ }
+ catch (e : Exception)
+ {
+ e.printStackTrace()
+ }
+ return (DummyCameraControl())
+ }
+
+ private fun setupCameraPreference0() : ICameraPreferenceProvider
+ {
+ return (CameraPreference(PREFERENCE_CAMERA_METHOD_NONE))
+ }
+
+ private fun setupCameraPreference1(wrapper : PreferenceAccessWrapper) : ICameraPreferenceProvider
+ {
+ val method = wrapper.getString(PREFERENCE_CAMERA_METHOD_1, PREFERENCE_CAMERA_METHOD_1_DEFAULT_VALUE)
+ val sequence = wrapper.getString(PREFERENCE_CAMERA_SEQUENCE_1, PREFERENCE_CAMERA_SEQUENCE_1_DEFAULT_VALUE)
+ val option1 = wrapper.getString(PREFERENCE_CAMERA_OPTION1_1, PREFERENCE_CAMERA_OPTION1_1_DEFAULT_VALUE)
+ val option2 = wrapper.getString(PREFERENCE_CAMERA_OPTION2_1, PREFERENCE_CAMERA_OPTION2_1_DEFAULT_VALUE)
+ val option3 = wrapper.getString(PREFERENCE_CAMERA_OPTION3_1, PREFERENCE_CAMERA_OPTION3_1_DEFAULT_VALUE)
+ val option4 = wrapper.getString(PREFERENCE_CAMERA_OPTION4_1, PREFERENCE_CAMERA_OPTION4_1_DEFAULT_VALUE)
+ val option5 = wrapper.getString(PREFERENCE_CAMERA_OPTION5_1, PREFERENCE_CAMERA_OPTION5_1_DEFAULT_VALUE)
+
+ return (CameraPreference(method, sequence, option1, option2, option3, option4, option5))
+ }
+
+ private fun setupCameraPreference2(wrapper : PreferenceAccessWrapper) : ICameraPreferenceProvider
+ {
+ val method = wrapper.getString(PREFERENCE_CAMERA_METHOD_2, PREFERENCE_CAMERA_METHOD_2_DEFAULT_VALUE)
+ val sequence = wrapper.getString(PREFERENCE_CAMERA_SEQUENCE_2, PREFERENCE_CAMERA_SEQUENCE_2_DEFAULT_VALUE)
+ val option1 = wrapper.getString(PREFERENCE_CAMERA_OPTION1_2, PREFERENCE_CAMERA_OPTION1_2_DEFAULT_VALUE)
+ val option2 = wrapper.getString(PREFERENCE_CAMERA_OPTION2_2, PREFERENCE_CAMERA_OPTION2_2_DEFAULT_VALUE)
+ val option3 = wrapper.getString(PREFERENCE_CAMERA_OPTION3_2, PREFERENCE_CAMERA_OPTION3_2_DEFAULT_VALUE)
+ val option4 = wrapper.getString(PREFERENCE_CAMERA_OPTION4_2, PREFERENCE_CAMERA_OPTION4_2_DEFAULT_VALUE)
+ val option5 = wrapper.getString(PREFERENCE_CAMERA_OPTION5_2, PREFERENCE_CAMERA_OPTION5_2_DEFAULT_VALUE)
+
+ return (CameraPreference(method, sequence, option1, option2, option3, option4, option5))
+ }
+
+ private fun setupCameraPreference3(wrapper : PreferenceAccessWrapper) : ICameraPreferenceProvider
+ {
+ val method = wrapper.getString(PREFERENCE_CAMERA_METHOD_3, PREFERENCE_CAMERA_METHOD_3_DEFAULT_VALUE)
+ val sequence = wrapper.getString(PREFERENCE_CAMERA_SEQUENCE_3, PREFERENCE_CAMERA_SEQUENCE_3_DEFAULT_VALUE)
+ val option1 = wrapper.getString(PREFERENCE_CAMERA_OPTION1_3, PREFERENCE_CAMERA_OPTION1_3_DEFAULT_VALUE)
+ val option2 = wrapper.getString(PREFERENCE_CAMERA_OPTION2_3, PREFERENCE_CAMERA_OPTION2_3_DEFAULT_VALUE)
+ val option3 = wrapper.getString(PREFERENCE_CAMERA_OPTION3_3, PREFERENCE_CAMERA_OPTION3_3_DEFAULT_VALUE)
+ val option4 = wrapper.getString(PREFERENCE_CAMERA_OPTION4_3, PREFERENCE_CAMERA_OPTION4_3_DEFAULT_VALUE)
+ val option5 = wrapper.getString(PREFERENCE_CAMERA_OPTION5_3, PREFERENCE_CAMERA_OPTION5_3_DEFAULT_VALUE)
+
+ return (CameraPreference(method, sequence, option1, option2, option3, option4, option5))
+ }
+
+ private fun setupCameraPreference4(wrapper : PreferenceAccessWrapper) : ICameraPreferenceProvider
+ {
+ val method = wrapper.getString(PREFERENCE_CAMERA_METHOD_4, PREFERENCE_CAMERA_METHOD_4_DEFAULT_VALUE)
+ val sequence = wrapper.getString(PREFERENCE_CAMERA_SEQUENCE_4, PREFERENCE_CAMERA_SEQUENCE_4_DEFAULT_VALUE)
+ val option1 = wrapper.getString(PREFERENCE_CAMERA_OPTION1_4, PREFERENCE_CAMERA_OPTION1_4_DEFAULT_VALUE)
+ val option2 = wrapper.getString(PREFERENCE_CAMERA_OPTION2_4, PREFERENCE_CAMERA_OPTION2_4_DEFAULT_VALUE)
+ val option3 = wrapper.getString(PREFERENCE_CAMERA_OPTION3_4, PREFERENCE_CAMERA_OPTION3_4_DEFAULT_VALUE)
+ val option4 = wrapper.getString(PREFERENCE_CAMERA_OPTION4_4, PREFERENCE_CAMERA_OPTION4_4_DEFAULT_VALUE)
+ val option5 = wrapper.getString(PREFERENCE_CAMERA_OPTION5_4, PREFERENCE_CAMERA_OPTION5_4_DEFAULT_VALUE)
+
+ return (CameraPreference(method, sequence, option1, option2, option3, option4, option5))
+ }
+
+ private fun prepareThetaCameraControl(cameraPreference : ICameraPreferenceProvider) : ICameraControl
+ {
+ return (ThetaCameraControl(activity, vibrator, cameraPreference, statusReceiver))
+ }
+
+ private fun preparePentaxCameraControl(cameraPreference : ICameraPreferenceProvider) : ICameraControl
+ {
+ return (RicohPentaxCameraControl(activity, vibrator, cameraPreference, statusReceiver))
+ }
+
+ private fun prepareCameraXControl(cameraPreference : ICameraPreferenceProvider): ICameraControl
+ {
+ if ((cameraXisCreated)&&(::cameraXControl.isInitialized))
+ {
+ return (cameraXControl)
+ }
+ cameraXControl = CameraControl(activity, cameraPreference)
+ cameraXisCreated = true
+ return (cameraXControl)
+ }
+}
\ No newline at end of file
import androidx.camera.core.CameraSelector
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentTransaction
-import jp.osdn.gokigen.gokigenassets.camera.DummyCameraControl
import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraStatusReceiver
-import jp.osdn.gokigen.gokigenassets.camera.theta.ThetaCameraControl
import jp.osdn.gokigen.gokigenassets.liveview.LiveImageViewFragment
-import jp.osdn.gokigen.gokigenassets.camera.camerax.operation.CameraControl
import jp.osdn.gokigen.gokigenassets.preference.MainPreferenceFragment
import jp.osdn.gokigen.gokigenassets.preference.PreferenceAccessWrapper
import jp.osdn.gokigen.gokigenassets.camera.camerax.preview.PreviewFragment
class SceneChanger(private val activity: AppCompatActivity, private val informationNotify: IInformationReceiver, vibrator : IVibrator, statusReceiver : ICameraStatusReceiver) : IChangeScene, IChangeSceneBasic
{
- private var cameraXisCreated = false
- private lateinit var cameraControl: ICameraControl
+ private val cameraProvider = CameraProvider(activity, informationNotify, vibrator, statusReceiver)
+
+ private val cameraControl0 = cameraProvider.getCameraXControl()
private val cameraControl1: ICameraControl
private val cameraControl2: ICameraControl
private val cameraControl3: ICameraControl
{
Log.v(TAG, " SceneChanger is created. ")
- cameraControl1 = DummyCameraControl() //decideCameraControl(PREFERENCE_CAMERA_METHOD_1, activity, vibrator, statusReceiver)
- cameraControl2 = decideCameraControl(PREFERENCE_CAMERA_METHOD_2, activity, vibrator, statusReceiver)
- cameraControl3 = decideCameraControl(PREFERENCE_CAMERA_METHOD_3, activity, vibrator, statusReceiver)
- cameraControl4 = DummyCameraControl() //decideCameraControl(PREFERENCE_CAMERA_METHOD_4, activity, vibrator, statusReceiver)
+ cameraControl1 = cameraProvider.decideCameraControl(PREFERENCE_CAMERA_METHOD_1)
+ cameraControl2 = cameraProvider.decideCameraControl(PREFERENCE_CAMERA_METHOD_2)
+ cameraControl3 = cameraProvider.decideCameraControl(PREFERENCE_CAMERA_METHOD_3)
+ cameraControl4 = cameraProvider.decideCameraControl(PREFERENCE_CAMERA_METHOD_4)
cameraControl1.initialize()
cameraControl2.initialize()
cameraControl4.initialize()
}
- private fun decideCameraControl(preferenceKey : String, activity: AppCompatActivity, vibrator : IVibrator, statusReceiver : ICameraStatusReceiver) : ICameraControl
- {
- try
- {
- if ((cameraXisCreated)&&(::cameraControl.isInitialized))
- {
- return (cameraControl)
- }
- cameraControl = CameraControl(activity)
- cameraXisCreated = true
- return (cameraControl)
- }
- catch (e : Exception)
- {
- e.printStackTrace()
- }
- return (DummyCameraControl())
- }
-
-
private fun initializeFragmentForPreview()
{
- if (!::cameraControl.isInitialized)
- {
- cameraControl = CameraControl(activity)
- cameraXisCreated = true
- }
if (!::previewFragment.isInitialized)
{
- previewFragment = PreviewFragment.newInstance(cameraControl)
+ previewFragment = PreviewFragment.newInstance(cameraControl0)
}
setDefaultFragment(previewFragment)
- cameraControl.startCamera()
+ cameraControl0.startCamera()
val msg = activity.getString(R.string.app_name) + " : " + " camerax"
informationNotify.updateMessage(msg, isBold = false, isColor = true, color = Color.LTGRAY)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
- ext.kotlin_version = "1.5.0"
+ ext.kotlin_version = "1.5.10"
repositories {
google()
jcenter()