--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera
+
+import android.view.View
+import androidx.camera.core.CameraSelector
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraControl
+import jp.osdn.gokigen.gokigenassets.liveview.ILiveView
+import jp.osdn.gokigen.gokigenassets.liveview.ILiveViewRefresher
+
+class DummyCameraControl() : ICameraControl, View.OnClickListener
+{
+ override fun getConnectionMethod(): String
+ {
+ return ("NONE")
+ }
+ override fun initialize() { }
+ override fun connectToCamera() { }
+ override fun startCamera(isPreviewView: Boolean, cameraSelector: CameraSelector) { }
+ override fun finishCamera() { }
+ override fun changeCaptureMode(mode: String) { }
+ override fun setRefresher(refresher: ILiveViewRefresher, imageView: ILiveView) { }
+ override fun captureButtonReceiver(id: Int): View.OnClickListener
+ {
+ return (this)
+ }
+ override fun onClick(v: View?) { }
+}
\ No newline at end of file
interface ICameraStatusWatcher
{
- fun startStatusWatch(indicator : IMessageDrawer?)
- fun startStatusWatch(notifier: ICameraStatusUpdateNotify)
+ fun startStatusWatch(indicator : IMessageDrawer?, notifier: ICameraStatusUpdateNotify?)
fun stopStatusWatch()
}
import android.util.Log
import android.view.View
+import androidx.appcompat.app.AppCompatActivity
import androidx.camera.core.CameraSelector
import androidx.fragment.app.FragmentActivity
import jp.osdn.gokigen.gokigenassets.camera.interfaces.*
import jp.osdn.gokigen.gokigenassets.camera.ricohpentax.status.RicohGr2StatusChecker
import jp.osdn.gokigen.gokigenassets.camera.ricohpentax.wrapper.RicohGr2RunMode
import jp.osdn.gokigen.gokigenassets.camera.ricohpentax.wrapper.playback.RicohGr2PlaybackControl
+import jp.osdn.gokigen.gokigenassets.camera.theta.ThetaCameraControl
+import jp.osdn.gokigen.gokigenassets.camera.theta.operation.ThetaMovieRecordingControl
+import jp.osdn.gokigen.gokigenassets.camera.theta.operation.ThetaSingleShotControl
+import jp.osdn.gokigen.gokigenassets.constants.IApplicationConstantConvert
import jp.osdn.gokigen.gokigenassets.liveview.IIndicatorControl
import jp.osdn.gokigen.gokigenassets.liveview.focusframe.IAutoFocusFrameDisplay
+import jp.osdn.gokigen.gokigenassets.liveview.image.CameraLiveViewListenerImpl
+import jp.osdn.gokigen.gokigenassets.scene.IVibrator
-class RicohPentaxCameraControl(context: FragmentActivity, provider: ICameraStatusReceiver) : ILiveViewController, ICameraControl, View.OnClickListener,
+class RicohPentaxCameraControl(private val context: AppCompatActivity, private val vibrator : IVibrator, statusReceiver : ICameraStatusReceiver) : ILiveViewController, ICameraControl, View.OnClickListener,
ICaptureModeReceiver, ICameraShutter, IDisplayInjector, IUseGR2CommandNotify
{
//private final Activity activity;
//private final ICameraStatusReceiver provider;
- private val gr2Connection = RicohGr2Connection(context, provider, this)
+ private var liveViewListener = CameraLiveViewListenerImpl(context)
+ private val gr2Connection = RicohGr2Connection(context, statusReceiver, this)
private val buttonControl = RicohGr2CameraButtonControl()
private val statusChecker = RicohGr2StatusChecker(500)
private val playbackControl = RicohGr2PlaybackControl(communicationTimeoutMs)
private val pentaxCaptureAfterAf: Boolean = false
private val liveViewControl = RicohGr2LiveViewControl(context)
private var captureControl: RicohGr2CameraCaptureControl? = null
- private val zoomControl = RicohGr2CameraZoomLensControl()
private var focusControl: RicohGr2CameraFocusControl? = null
private var useGR2Command = false
private var useGR2CommandUpdated = false
private var useCameraScreen = false
+ private var isStatusWatch = false
+ private var cameraPositionId = 0
-
+ private val zoomControl = RicohGr2CameraZoomLensControl()
override fun startLiveView()
{
- TODO("Not yet implemented")
+ Log.v(TAG, " startLiveView() ")
+ try
+ {
+ if (!isStatusWatch)
+ {
+ statusChecker.startStatusWatch(null, null)
+ isStatusWatch = true
+ }
+ liveViewControl.startLiveView()
+ }
+ catch (e : Exception)
+ {
+ e.printStackTrace()
+ }
}
override fun stopLiveView()
{
- TODO("Not yet implemented")
+ try
+ {
+ liveViewControl.stopLiveView()
+ }
+ catch (e : Exception)
+ {
+ e.printStackTrace()
+ }
}
override fun getConnectionMethod(): String
{
- TODO("Not yet implemented")
+ return ("PENTAX")
}
override fun initialize()
{
- TODO("Not yet implemented")
+ // TODO("Not yet implemented")
}
override fun connectToCamera()
{
- TODO("Not yet implemented")
+ Log.v(TAG, " connectToCamera() : PENTAX ")
+ try
+ {
+ gr2Connection.connect()
+ }
+ catch (e : Exception)
+ {
+ e.printStackTrace()
+ }
}
override fun startCamera(isPreviewView: Boolean, cameraSelector: CameraSelector)
{
- TODO("Not yet implemented")
+ try
+ {
+ if (gr2Connection.getConnectionStatus() != ICameraConnectionStatus.CameraConnectionStatus.CONNECTED)
+ {
+ gr2Connection.startWatchWifiStatus(context)
+ }
+ else
+ {
+ gr2Connection.connect()
+ }
+ }
+ catch (e : Exception)
+ {
+ e.printStackTrace()
+ }
}
override fun finishCamera()
{
- TODO("Not yet implemented")
- }
-
- override fun changeCaptureMode(mode: String)
- {
- TODO("Not yet implemented")
+ try
+ {
+ if (isStatusWatch)
+ {
+ statusChecker.stopStatusWatch()
+ isStatusWatch = false
+ }
+ gr2Connection.disconnect(false)
+ gr2Connection.stopWatchWifiStatus(context)
+ }
+ catch (e : Exception)
+ {
+ e.printStackTrace()
+ }
}
override fun setRefresher(refresher: ILiveViewRefresher, imageView: ILiveView)
{
- TODO("Not yet implemented")
+ try
+ {
+ liveViewListener.setRefresher(refresher)
+ imageView.setImageProvider(liveViewListener)
+ }
+ catch (e : Exception)
+ {
+ e.printStackTrace()
+ }
}
override fun captureButtonReceiver(id: Int): View.OnClickListener
{
- TODO("Not yet implemented")
+ cameraPositionId = id
+ return (this)
}
override fun onClick(v: View?)
{
+ if (v == null)
+ {
+ return
+ }
+ when (v.id)
+ {
+ IApplicationConstantConvert.ID_BUTTON_SHUTTER -> { doShutter() }
+ else -> { }
+ }
+ }
+
+ override fun changeCaptureMode(mode: String)
+ {
TODO("Not yet implemented")
}
override fun doShutter()
{
- TODO("Not yet implemented")
+ try
+ {
+ Log.v(TAG, " doShutter()")
+ captureControl?.doCapture(0)
+ }
+ catch (e : Exception)
+ {
+ e.printStackTrace()
+ }
}
override fun doShutterOff()
{
- TODO("Not yet implemented")
+ try
+ {
+ Log.v(TAG, " doShutterOff()")
+ captureControl?.doCapture(0)
+ }
+ catch (e : Exception)
+ {
+ e.printStackTrace()
+ }
}
override fun setUseGR2Command(useGR2Command: Boolean, useCameraScreen: Boolean)
this.useGR2command = useGR2command
}
- override fun startStatusWatch(indicator: IMessageDrawer?)
+ override fun startStatusWatch(indicator : IMessageDrawer?, notifier: ICameraStatusUpdateNotify?)
{
- TODO("Not yet implemented")
- }
-
- /**
- *
- *
- */
- override fun startStatusWatch(notifier: ICameraStatusUpdateNotify) {
Log.v(TAG, "startStatusWatch()")
try {
statusHolder = RicohGr2StatusHolder(notifier)
*
*
*/
-internal class RicohGr2StatusHolder(private val notifier: ICameraStatusUpdateNotify)
+class RicohGr2StatusHolder(private val notifier: ICameraStatusUpdateNotify?)
{
private var latestResultObject: JSONObject? = null
private var focused = false
return ""
}
- private fun getStatusString(obj: JSONObject, name: String): String {
+ private fun getStatusString(obj: JSONObject?, name: String): String {
try {
+ if (obj == null)
+ {
+ return ""
+ }
return obj.getString(name)
} catch (e: Exception) {
//e.printStackTrace();
return ""
}
- private fun getBooleanStatus(obj: JSONObject, name: String): Boolean {
+ private fun getBooleanStatus(obj: JSONObject?, name: String): Boolean {
try {
+ if (obj == null)
+ {
+ return false
+ }
return obj.getBoolean(name)
} catch (e: Exception) {
//e.printStackTrace();
}
try {
latestResultObject = JSONObject(replyString)
- val result = getStatusString(latestResultObject!!, "errMsg")
- val av = getStatusString(latestResultObject!!, "av")
- val tv = getStatusString(latestResultObject!!, "tv")
- val xv = getStatusString(latestResultObject!!, "xv")
- val exposureMode = getStatusString(latestResultObject!!, "exposureMode")
- val meteringMode = getStatusString(latestResultObject!!, "meteringMode")
- val wbMode = getStatusString(latestResultObject!!, "WBMode")
- val battery = getStatusString(latestResultObject!!, "battery")
- val focus = getBooleanStatus(latestResultObject!!, "focused")
- val focusLock = getBooleanStatus(latestResultObject!!, "focusLocked")
+ val result = getStatusString(latestResultObject, "errMsg")
+ val av = getStatusString(latestResultObject, "av")
+ val tv = getStatusString(latestResultObject, "tv")
+ val xv = getStatusString(latestResultObject, "xv")
+ val exposureMode = getStatusString(latestResultObject, "exposureMode")
+ val meteringMode = getStatusString(latestResultObject, "meteringMode")
+ val wbMode = getStatusString(latestResultObject, "WBMode")
+ val battery = getStatusString(latestResultObject, "battery")
+ val focus = getBooleanStatus(latestResultObject, "focused")
+ val focusLock = getBooleanStatus(latestResultObject, "focusLocked")
if (result.contains("OK")) {
if (avStatus != av) {
avStatus = av
- notifier.updatedAperture(avStatus)
+ notifier?.updatedAperture(avStatus)
}
if (tvStatus != tv) {
tvStatus = tv
- notifier.updatedShutterSpeed(tvStatus)
+ notifier?.updatedShutterSpeed(tvStatus)
}
if (xvStatus != xv) {
xvStatus = xv
- notifier.updatedExposureCompensation(xvStatus)
+ notifier?.updatedExposureCompensation(xvStatus)
}
if (exposureModeStatus != exposureMode) {
exposureModeStatus = exposureMode
- notifier.updatedTakeMode(exposureModeStatus)
+ notifier?.updatedTakeMode(exposureModeStatus)
}
if (meteringModeStatus != meteringMode) {
meteringModeStatus = meteringMode
- notifier.updatedMeteringMode(meteringModeStatus)
+ notifier?.updatedMeteringMode(meteringModeStatus)
}
if (wbModeStatus != wbMode) {
wbModeStatus = wbMode
- notifier.updatedWBMode(wbModeStatus)
+ notifier?.updatedWBMode(wbModeStatus)
}
if (batteryStatus != battery) {
batteryStatus = battery
- notifier.updateRemainBattery(batteryStatus.toInt())
+ notifier?.updateRemainBattery(batteryStatus.toInt())
}
if (focus != focused || focusLock != focusLocked) {
focused = focus
focusLocked = focusLock
- notifier.updateFocusedStatus(focused, focusLocked)
+ notifier?.updateFocusedStatus(focused, focusLocked)
}
}
System.gc()
{
if (!isStatusWatch)
{
- statusWatcher.startStatusWatch(indicator)
+ statusWatcher.startStatusWatch(indicator, null)
isStatusWatch = true
}
liveViewControl.setSessionIdProvider(sessionIdHolder)
private var showInformation: IMessageDrawer? = null
- override fun startStatusWatch(indicator : IMessageDrawer?)
+ override fun startStatusWatch(indicator : IMessageDrawer?, notifier: ICameraStatusUpdateNotify?)
{
if (whileFetching)
{
}
}
- override fun startStatusWatch(notifier: ICameraStatusUpdateNotify)
- {
- startStatusWatch(null)
- }
-
private fun checkStatus0(response: String)
{
try
import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.LABEL_WIFI_SETTINGS
import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.NUMBER_OF_CACHE_PICTURES
import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.NUMBER_OF_CACHE_PICTURES_DEFAULT_VALUE
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CONNECTION_METHOD
import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_SAVE_LOCAL_LOCATION
import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_SAVE_LOCAL_LOCATION_DEFAULT_VALUE
import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.USE_GR2_SPECIAL_COMMAND
const val ID_VIEW_FINDER_3 = R.id.liveViewFinder3
const val ID_VIEW_UPPER_AREA = R.id.liveview_upper_area
const val ID_VIEW_LOWER_AREA = R.id.liveview_lower_area
+ const val ID_VIEW_AREA_0 = R.id.panelLayout0
+ const val ID_VIEW_AREA_1 = R.id.panelLayout1
+ const val ID_VIEW_AREA_2 = R.id.panelLayout2
+ const val ID_VIEW_AREA_3 = R.id.panelLayout3
const val ID_CACHE_SEEKBAR_0 = R.id.liveview_cache_seekbar0
const val ID_CACHE_SEEKBAR_1 = R.id.liveview_cache_seekbar1
const val ID_PREFERENCE_RICOH_GR2_LCD_SLEEP = GR2_LCD_SLEEP
const val ID_PREFERENCE_USE_GR2_SPECIAL_COMMAND = USE_GR2_SPECIAL_COMMAND
+ const val ID_PREFERENCE_LABEL_SELECT_CAMERA_CONNECTION_METHOD = PREFERENCE_CONNECTION_METHOD
+
}
}
import android.view.View
import android.view.ViewGroup
import android.widget.ImageButton
+import android.widget.LinearLayout
import android.widget.SeekBar
import androidx.fragment.app.Fragment
import androidx.preference.PreferenceManager
import jp.osdn.gokigen.gokigenassets.constants.IApplicationConstantConvert.Companion.ID_VIEW_LOWER_AREA
import jp.osdn.gokigen.gokigenassets.constants.IApplicationConstantConvert.Companion.ID_VIEW_UPPER_AREA
import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraControl
+import jp.osdn.gokigen.gokigenassets.constants.IApplicationConstantConvert.Companion.ID_VIEW_AREA_0
+import jp.osdn.gokigen.gokigenassets.constants.IApplicationConstantConvert.Companion.ID_VIEW_AREA_1
+import jp.osdn.gokigen.gokigenassets.constants.IApplicationConstantConvert.Companion.ID_VIEW_AREA_2
+import jp.osdn.gokigen.gokigenassets.constants.IApplicationConstantConvert.Companion.ID_VIEW_AREA_3
class LiveImageViewFragment(private val contentLayoutId: Int = ID_LIVE_VIEW_LAYOUT_DEFAULT) : Fragment(contentLayoutId), View.OnClickListener
{
this.isCameraControl3 = isCameraControl3
this.cameraControl3 = cameraControl3
+ updateCameraLayout()
}
- override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View
+ private fun updateCameraLayout()
{
- if (::liveviewView.isInitialized)
- {
- return (liveviewView)
- }
- liveviewView = inflater.inflate(contentLayoutId, null, false)
- liveviewView.findViewById<ImageButton>(ID_BUTTON_SHUTTER)?.setOnClickListener(this)
-
- try
+ if (!::liveviewView.isInitialized)
{
- val preferences : SharedPreferences = PreferenceManager.getDefaultSharedPreferences(activity)
- this.isCacheImage = preferences.getBoolean(ID_PREFERENCE_CACHE_LIVE_VIEW_PICTURES, false)
+ // まだ Viewができていないときには何もしない
+ return
}
- catch (e : Exception)
- {
- e.printStackTrace()
- }
-
try
{
+ Log.v(TAG, "updateCameraLayout()")
if (::cameraControl0.isInitialized)
{
+ val area0 = liveviewView.findViewById<LinearLayout>(ID_VIEW_AREA_0)
val imageCache0 = liveviewView.findViewById<SeekBar>(ID_CACHE_SEEKBAR_0)
imageCache0.visibility = View.GONE
imageCache0.visibility = View.VISIBLE
imageCache0.setOnSeekBarChangeListener(imageView0)
}
+ area0.visibility = View.VISIBLE
}
else
{
imageView0.visibility = View.GONE
+ area0.visibility = View.GONE
}
}
if (::cameraControl1.isInitialized)
{
+ val area1 = liveviewView.findViewById<LinearLayout>(ID_VIEW_AREA_1)
val imageCache1 = liveviewView.findViewById<SeekBar>(ID_CACHE_SEEKBAR_1)
imageCache1.visibility = View.GONE
imageCache1.visibility = View.VISIBLE
imageCache1.setOnSeekBarChangeListener(imageView1)
}
+ area1.visibility = View.VISIBLE
}
else
{
imageView1.visibility = View.GONE
+ area1.visibility = View.GONE
}
}
if (::cameraControl2.isInitialized)
{
+ val area2 = liveviewView.findViewById<LinearLayout>(ID_VIEW_AREA_2)
val imageCache2 = liveviewView.findViewById<SeekBar>(ID_CACHE_SEEKBAR_2)
imageCache2.visibility = View.GONE
imageCache2.visibility = View.VISIBLE
imageCache2.setOnSeekBarChangeListener(imageView2)
}
+ area2.visibility = View.VISIBLE
}
else
{
imageView2.visibility = View.GONE
+ area2.visibility = View.GONE
}
}
if (::cameraControl3.isInitialized)
{
+ val area3 = liveviewView.findViewById<LinearLayout>(ID_VIEW_AREA_3)
val imageCache3 = liveviewView.findViewById<SeekBar>(ID_CACHE_SEEKBAR_3)
imageCache3.visibility = View.GONE
imageCache3.visibility = View.VISIBLE
imageCache3.setOnSeekBarChangeListener(imageView3)
}
+ area3.visibility = View.VISIBLE
}
else
{
imageView3.visibility = View.GONE
+ area3.visibility = View.GONE
}
}
if ((!isCameraControl0)&&(!isCameraControl1))
val area = liveviewView.findViewById<LiveImageView>(ID_VIEW_LOWER_AREA)
area.visibility = View.GONE
}
+ liveviewView.postInvalidate()
+ }
+ catch (e : Exception)
+ {
+ e.printStackTrace()
+ }
+ }
+
+ override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View
+ {
+ if (::liveviewView.isInitialized)
+ {
+ return (liveviewView)
+ }
+ liveviewView = inflater.inflate(contentLayoutId, null, false)
+ liveviewView.findViewById<ImageButton>(ID_BUTTON_SHUTTER)?.setOnClickListener(this)
+
+ try
+ {
+ val preferences : SharedPreferences = PreferenceManager.getDefaultSharedPreferences(activity)
+ this.isCacheImage = preferences.getBoolean(ID_PREFERENCE_CACHE_LIVE_VIEW_PICTURES, false)
}
catch (e : Exception)
{
e.printStackTrace()
}
+ updateCameraLayout()
return (liveviewView)
}
import jp.osdn.gokigen.gokigenassets.constants.IApplicationConstantConvert.Companion.ID_LAYOUT_PREFERENCE
import jp.osdn.gokigen.gokigenassets.constants.IApplicationConstantConvert.Companion.ID_PREFERENCE_LABEL_DEBUG_INFO
import jp.osdn.gokigen.gokigenassets.constants.IApplicationConstantConvert.Companion.ID_PREFERENCE_LABEL_EXIT_APPLICATION
+import jp.osdn.gokigen.gokigenassets.constants.IApplicationConstantConvert.Companion.ID_PREFERENCE_LABEL_SELECT_CAMERA_CONNECTION_METHOD
import jp.osdn.gokigen.gokigenassets.constants.IApplicationConstantConvert.Companion.ID_PREFERENCE_LABEL_WIFI_SETTINGS
class MainPreferenceFragment : PreferenceFragmentCompat()
prepareClickListener(ID_PREFERENCE_LABEL_EXIT_APPLICATION)
prepareClickListener(ID_PREFERENCE_LABEL_WIFI_SETTINGS)
prepareClickListener(ID_PREFERENCE_LABEL_DEBUG_INFO)
+ prepareClickListener(ID_PREFERENCE_LABEL_SELECT_CAMERA_CONNECTION_METHOD)
}
private fun prepareChangeListener(context: Context)
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"
+ const val PREFERENCE_CAMERA_METHOD_1 = "camera_method1"
+ const val PREFERENCE_CAMERA_METHOD_1_DEFAULT_VALUE = "camerax"
+
+ const val PREFERENCE_CAMERA_METHOD_2 = "camera_method2"
+ const val PREFERENCE_CAMERA_METHOD_2_DEFAULT_VALUE = "camerax"
+
+ const val PREFERENCE_CAMERA_METHOD_3 = "camera_method3"
+ const val PREFERENCE_CAMERA_METHOD_3_DEFAULT_VALUE = "camerax"
+
+ const val PREFERENCE_CAMERA_METHOD_4 = "camera_method4"
+ const val PREFERENCE_CAMERA_METHOD_4_DEFAULT_VALUE = "camerax"
+
}
}
import androidx.preference.PreferenceManager
import jp.osdn.gokigen.gokigenassets.preference.IActionReceiver
import jp.osdn.gokigen.gokigenassets.scene.IChangeSceneBasic
+import jp.osdn.gokigen.mangle.scene.IChangeScene
-class PreferenceChanger(private val activity : AppCompatActivity, private val changeSceneBasic : IChangeSceneBasic) : SharedPreferences.OnSharedPreferenceChangeListener, Preference.OnPreferenceClickListener, IActionReceiver
+class PreferenceChanger(private val activity : AppCompatActivity, private val changeSceneBasic : IChangeSceneBasic, private val changeScene : IChangeScene) : SharedPreferences.OnSharedPreferenceChangeListener, Preference.OnPreferenceClickListener, IActionReceiver
{
private var preferences : SharedPreferences = PreferenceManager.getDefaultSharedPreferences(activity)
)
IPreferencePropertyAccessor.LABEL_EXIT_APPLICATION -> changeSceneBasic.exitApplication()
IPreferencePropertyAccessor.LABEL_DEBUG_INFO -> changeSceneBasic.changeToDebugInformation()
+ IPreferencePropertyAccessor.PREFERENCE_CONNECTION_METHOD -> changeScene.selectConnectionMethod()
else -> { Log.v(TAG, " onPreferenceClick() : " + preference?.key); ret = false; }
}
return (ret)
{
editor.putString(IPreferencePropertyAccessor.THETA_LIVEVIEW_RESOLUTION, IPreferencePropertyAccessor.THETA_LIVEVIEW_RESOLUTION_DEFAULT_VALUE)
}
+ if (!items.containsKey(IPreferencePropertyAccessor.PREFERENCE_CAMERA_METHOD_1))
+ {
+ editor.putString(IPreferencePropertyAccessor.PREFERENCE_CAMERA_METHOD_1, IPreferencePropertyAccessor.PREFERENCE_CAMERA_METHOD_1_DEFAULT_VALUE)
+ }
+ if (!items.containsKey(IPreferencePropertyAccessor.PREFERENCE_CAMERA_METHOD_2))
+ {
+ editor.putString(IPreferencePropertyAccessor.PREFERENCE_CAMERA_METHOD_2, IPreferencePropertyAccessor.PREFERENCE_CAMERA_METHOD_2_DEFAULT_VALUE)
+ }
+ if (!items.containsKey(IPreferencePropertyAccessor.PREFERENCE_CAMERA_METHOD_3))
+ {
+ editor.putString(IPreferencePropertyAccessor.PREFERENCE_CAMERA_METHOD_3, IPreferencePropertyAccessor.PREFERENCE_CAMERA_METHOD_3_DEFAULT_VALUE)
+ }
+ if (!items.containsKey(IPreferencePropertyAccessor.PREFERENCE_CAMERA_METHOD_4))
+ {
+ editor.putString(IPreferencePropertyAccessor.PREFERENCE_CAMERA_METHOD_4, IPreferencePropertyAccessor.PREFERENCE_CAMERA_METHOD_4_DEFAULT_VALUE)
+ }
editor.apply()
}
catch (e : Exception)
--- /dev/null
+package jp.osdn.gokigen.mangle.preference
+
+import androidx.fragment.app.DialogFragment
+
+class SelectCameraConnectionMethodDialog() : DialogFragment()
+{
+
+
+
+}
\ No newline at end of file
fun changeToLiveView()
fun connectToCamera()
fun changeToConfiguration()
+ fun selectConnectionMethod()
//fun changeToDebugInformation()
//fun exitApplication()
}
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.preference.MainPreferenceFragment
import jp.osdn.gokigen.gokigenassets.preference.PreferenceAccessWrapper
import jp.osdn.gokigen.gokigenassets.camera.camerax.preview.PreviewFragment
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraControl
import jp.osdn.gokigen.gokigenassets.scene.IChangeSceneBasic
import jp.osdn.gokigen.gokigenassets.scene.IInformationReceiver
import jp.osdn.gokigen.gokigenassets.scene.IVibrator
import jp.osdn.gokigen.gokigenassets.utils.logcat.LogCatFragment
import jp.osdn.gokigen.mangle.R
import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_METHOD_1
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_METHOD_2
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_METHOD_3
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.PREFERENCE_CAMERA_METHOD_4
import jp.osdn.gokigen.mangle.preference.PreferenceChanger
import jp.osdn.gokigen.mangle.preference.PreferenceValueInitializer
-
class SceneChanger(private val activity: AppCompatActivity, private val informationNotify: IInformationReceiver, vibrator : IVibrator, statusReceiver : ICameraStatusReceiver) : IChangeScene, IChangeSceneBasic
{
- private val cameraControl0: CameraControl
- private val cameraControl1: CameraControl
- private val cameraControl2 = ThetaCameraControl(activity, vibrator, statusReceiver)
+ private var cameraXisCreated = false
+ private lateinit var cameraControl: ICameraControl
+ private val cameraControl1: ICameraControl
+ private val cameraControl2: ICameraControl
+ private val cameraControl3: ICameraControl
+ private val cameraControl4: ICameraControl
- private val preferenceChanger = PreferenceChanger(activity, this)
+ private val preferenceChanger = PreferenceChanger(activity, this, this)
private lateinit var liveviewFragment : LiveImageViewFragment
private lateinit var previewFragment : PreviewFragment
private lateinit var logCatFragment : LogCatFragment
init
{
Log.v(TAG, " SceneChanger is created. ")
- cameraControl0 = CameraControl(activity)
- cameraControl0.initialize()
- cameraControl1 = CameraControl(activity)
- cameraControl1.initialize()
+ 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.initialize()
cameraControl2.initialize()
- cameraControl2.connectToCamera()
+ cameraControl3.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(cameraControl0)
+ previewFragment = PreviewFragment.newInstance(cameraControl)
}
setDefaultFragment(previewFragment)
- cameraControl0.startCamera()
+ cameraControl.startCamera()
val msg = activity.getString(R.string.app_name) + " : " + " camerax"
informationNotify.updateMessage(msg, isBold = false, isColor = true, color = Color.LTGRAY)
{
if (!::liveviewFragment.isInitialized)
{
+ val isEnableCamera1 = cameraControl1.getConnectionMethod() != "NONE"
+ val isEnableCamera2 = cameraControl2.getConnectionMethod() != "NONE"
+ val isEnableCamera3 = cameraControl3.getConnectionMethod() != "NONE"
+ val isEnableCamera4 = cameraControl4.getConnectionMethod() != "NONE"
+
liveviewFragment = LiveImageViewFragment.newInstance()
- liveviewFragment.setCameraControl(true, cameraControl1,true, cameraControl1,true, cameraControl1,true, cameraControl2)
+ liveviewFragment.setCameraControl(isEnableCamera1, cameraControl1, isEnableCamera2, cameraControl2, isEnableCamera3, cameraControl3, isEnableCamera4, cameraControl4)
}
setDefaultFragment(liveviewFragment)
- cameraControl0.startCamera(
+ cameraControl1.startCamera(
isPreviewView = false,
cameraSelector = CameraSelector.DEFAULT_FRONT_CAMERA
)
- cameraControl1.startCamera(
+ cameraControl2.startCamera(
isPreviewView = false,
cameraSelector = CameraSelector.DEFAULT_BACK_CAMERA
)
- cameraControl2.startCamera(
+ cameraControl3.startCamera(
+ isPreviewView = false,
+ cameraSelector = CameraSelector.DEFAULT_BACK_CAMERA
+ )
+ cameraControl4.startCamera(
isPreviewView = false,
cameraSelector = CameraSelector.DEFAULT_BACK_CAMERA
)
{
if (!::liveviewFragment.isInitialized)
{
+ val isEnableCamera1 = cameraControl1.getConnectionMethod() != "NONE"
+ val isEnableCamera2 = cameraControl2.getConnectionMethod() != "NONE"
+ val isEnableCamera3 = cameraControl3.getConnectionMethod() != "NONE"
+ val isEnableCamera4 = cameraControl4.getConnectionMethod() != "NONE"
liveviewFragment = LiveImageViewFragment.newInstance()
- liveviewFragment.setCameraControl(true, cameraControl0,true, cameraControl0,true, cameraControl1,true, cameraControl1)
+ liveviewFragment.setCameraControl(
+ isEnableCamera1, cameraControl1,
+ isEnableCamera2, cameraControl2,
+ isEnableCamera3, cameraControl3,
+ isEnableCamera4, cameraControl4
+ )
}
changeFragment(liveviewFragment)
}
)
}
+ override fun selectConnectionMethod()
+ {
+ try
+ {
+ Log.v(TAG, " selectConnectionMethod ")
+
+ }
+ catch (e : Exception)
+ {
+ e.printStackTrace()
+ }
+ }
+
private fun changeFragment(fragment: Fragment)
{
val transaction : FragmentTransaction = activity.supportFragmentManager.beginTransaction()
fun finish()
{
- cameraControl0.finishCamera()
cameraControl1.finishCamera()
cameraControl2.finishCamera()
+ cameraControl3.finishCamera()
+ cameraControl4.finishCamera()
}
companion object
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <View
+ android:layout_width="fill_parent"
+ android:layout_height="1dp"
+ android:background="@android:color/darker_gray"/>
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+ <TextView
+ android:id="@+id/label_connection_method1"
+ android:layout_width="0dp"
+ android:layout_height="fill_parent"
+ android:layout_weight="1"
+ android:adjustViewBounds = "true"
+ android:scaleType="fitCenter"
+ android:layout_gravity="center_horizontal"
+ android:gravity="center"
+ android:textSize="9pt"
+ android:text="@string/label_connection_method1"
+ >
+ </TextView>
+ <Spinner
+ android:id="@+id/connection_method1"
+ android:layout_gravity="start"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:padding="6dp"
+ android:textSize="9pt"
+ />
+
+ </LinearLayout>
+
+ <View
+ android:layout_width="fill_parent"
+ android:layout_height="1dp"
+ android:background="@android:color/darker_gray"/>
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+ <TextView
+ android:id="@+id/label_connection_method2"
+ android:layout_width="0dp"
+ android:layout_height="fill_parent"
+ android:layout_weight="1"
+ android:adjustViewBounds = "true"
+ android:scaleType="fitCenter"
+ android:layout_gravity="center_horizontal"
+ android:gravity="center"
+ android:textSize="9pt"
+ android:text="@string/label_connection_method2"
+ >
+ </TextView>
+ <Spinner
+ android:id="@+id/connection_method2"
+ android:layout_gravity="start"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:padding="6dp"
+ android:textSize="9pt"
+ />
+
+ </LinearLayout>
+
+ <View
+ android:layout_width="fill_parent"
+ android:layout_height="1dp"
+ android:background="@android:color/darker_gray"/>
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+ <TextView
+ android:id="@+id/label_connection_method3"
+ android:layout_width="0dp"
+ android:layout_height="fill_parent"
+ android:layout_weight="1"
+ android:adjustViewBounds = "true"
+ android:scaleType="fitCenter"
+ android:layout_gravity="center_horizontal"
+ android:gravity="center"
+ android:textSize="9pt"
+ android:text="@string/label_connection_method3"
+ >
+ </TextView>
+ <Spinner
+ android:id="@+id/connection_method3"
+ android:layout_gravity="start"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:padding="6dp"
+ android:textSize="9pt"
+ />
+ </LinearLayout>
+
+ <View
+ android:layout_width="fill_parent"
+ android:layout_height="1dp"
+ android:background="@android:color/darker_gray"/>
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+ <TextView
+ android:id="@+id/label_connection_method4"
+ android:layout_width="0dp"
+ android:layout_height="fill_parent"
+ android:layout_weight="1"
+ android:adjustViewBounds = "true"
+ android:scaleType="fitCenter"
+ android:layout_gravity="center_horizontal"
+ android:gravity="center"
+ android:textSize="9pt"
+ android:text="@string/label_connection_method4"
+ >
+ </TextView>
+ <Spinner
+ android:id="@+id/connection_method4"
+ android:layout_gravity="start"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:padding="6dp"
+ android:textSize="9pt"
+ />
+ </LinearLayout>
+
+ <View
+ android:layout_width="fill_parent"
+ android:layout_height="1dp"
+ android:background="@android:color/darker_gray"/>
+
+</LinearLayout>
\ No newline at end of file
<string name="pref_number_of_cache_pictures">ライブビュー画像の遅延最大数</string>
<string name="pref_summary_number_of_cache_pictures">ライブビューを遅らせる画像の最大枚数を指定します。(初期値:500、再起動後に有効)</string>
+ <string name="pref_connection_method">接続方式設定</string>
+ <string name="pref_summary_connection_method">接続するカメラを設定します。</string>
+
+ <string name="label_connection_method1">カメラ 1</string>
+ <string name="label_connection_method2">カメラ 2</string>
+ <string name="label_connection_method3">カメラ 3</string>
+ <string name="label_connection_method4">カメラ 4</string>
+
<string name="connect_start">開始</string>
<string name="connect_check_wifi">WIFI確認中</string>
<string name="connect_connect">接続</string>
<string name="pref_number_of_cache_pictures">Max number of cache pictures</string>
<string name="pref_summary_number_of_cache_pictures">Set number of cache pictures. (Default:500, enables after restart.)</string>
+ <string name="pref_connection_method">Camera Connection Method</string>
+ <string name="pref_summary_connection_method"> </string>
+
+ <string name="label_connection_method1">CAMERA 1</string>
+ <string name="label_connection_method2">CAMERA 2</string>
+ <string name="label_connection_method3">CAMERA 3</string>
+ <string name="label_connection_method4">CAMERA 4</string>
<string name="connect_start">start</string>
<string name="connect_check_wifi">check WIFI</string>
android:key="capture_both_camera_and_live_view"
android:title="@string/pref_capture_both_camera_and_live_view"
android:summary="@string/pref_summary_capture_both_live_view"/>
+
+ <PreferenceScreen
+ android:key="connection_method"
+ android:title="@string/pref_connection_method"
+ android:summary="@string/pref_summary_connection_method" />
+
<!--
<SwitchPreferenceCompat
android:key="capture_only_live_view"