<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
- <bytecodeTargetLevel target="1.8" />
+ <bytecodeTargetLevel target="11" />
</component>
</project>
\ No newline at end of file
<component name="ProjectDictionaryState">
<dictionary name="MRSa">
<words>
+ <w>acclock</w>
<w>equirectangular</w>
+ <w>liveview</w>
+ <w>mpget</w>
+ <w>mpset</w>
+ <w>ricoh</w>
</words>
</dictionary>
</component>
\ No newline at end of file
<textMaps />
</LinkMapSettings>
</component>
- <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="JDK" project-jdk-type="JavaSDK">
+ <component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="JDK" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="RunConfigurationProducerService">
+ <option name="ignoredProducers">
+ <set>
+ <option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
+ </set>
+ </option>
+ </component>
+</project>
\ No newline at end of file
-package jp.osdn.gokigen.gokigenassets.operation
+package jp.osdn.gokigen.gokigenassets.camera.camerax.operation
import android.util.Log
import android.view.Surface
import jp.osdn.gokigen.gokigenassets.liveview.ILiveViewRefresher
import jp.osdn.gokigen.gokigenassets.liveview.image.CameraLiveViewListenerImpl
import jp.osdn.gokigen.gokigenassets.liveview.storeimage.StoreImage
-import jp.osdn.gokigen.gokigenassets.operation.imagefile.FileControl
+import jp.osdn.gokigen.gokigenassets.utils.imagefile.FileControl
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraControl
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
-package jp.osdn.gokigen.gokigenassets.preview
+package jp.osdn.gokigen.gokigenassets.camera.camerax.preview
import android.os.Bundle
import android.view.LayoutInflater
import androidx.fragment.app.Fragment
import jp.osdn.gokigen.gokigenassets.constants.IApplicationConstantConvert.Companion.ID_LAYOUT_CAMERA_CAPTURE
import jp.osdn.gokigen.gokigenassets.constants.IApplicationConstantConvert.Companion.ID_PREVIEW_VIEW_BUTTON_SHUTTER
-import jp.osdn.gokigen.gokigenassets.operation.ICameraControl
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraControl
class PreviewFragment(private val contentLayoutId: Int = ID_LAYOUT_CAMERA_CAPTURE) : Fragment(contentLayoutId)
{
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.interfaces
+
+
+interface ICameraButtonControl
+{
+ fun pushedButton(code: String?, isLongPress: Boolean): Boolean
+
+ companion object
+ {
+ const val SPECIAL_GREEN_BUTTON = "btn_green"
+ const val FRONT_LEFT = "bjogleft"
+ const val FRONT_RIGHT = "bjogright"
+ const val ADJ_LEFT = "badjleft"
+ const val ADJ_ENTER = "badjok"
+ const val ADJ_RIGHT = "badjright"
+ const val TOGGLE_AEAF_OFF = "baf 0"
+ const val TOGGLE_AEAF_ON = "baf 1"
+ const val LEVER_AEAFL = "bafl"
+ const val LEVER_CAF = "bafc"
+ const val BUTTON_UP = "bup"
+ const val BUTTON_LEFT = "bleft"
+ const val BUTTON_ENTER = "bok"
+ const val BUTTON_RIGHT = "bright"
+ const val BUTTON_DOWN = "bdown"
+ const val BUTTON_FUNCTION_1 = "bdisp"
+ const val BUTTON_FUNCTION_2 = "btrash"
+ const val BUTTON_FUNCTION_3 = "beffect"
+ const val BUTTON_PLUS = "btele"
+ const val BUTTON_MINUS = "bwide"
+ const val BUTTON_PLAYBACK = "bplay"
+ const val KEYLOCK_ON = "uilock on"
+ const val KEYLOCK_OFF = "uilock off"
+ const val LENS_OPEN = "acclock off"
+ const val LENS_RETRACT = "acclock on"
+ const val MUTE_ON = "audio mute on"
+ const val MUTE_OFF = "audio mute off"
+ const val LCD_SLEEP_ON = "lcd sleep on"
+ const val LCD_SLEEP_OFF = "lcd sleep off"
+ const val LED1_ON = "led on 1"
+ const val LED1_OFF = "led off 1"
+ const val BEEP = "audio resplay 0 1 3"
+ const val MODE_REFRESH = "mode refresh"
+ const val SHUTTER = "brl 0"
+ const val SHUTTER_PRESS_AND_HALF_HOLD = "brl 2 1"
+ const val TAKEMODE_M = "bdial M"
+ const val TAKEMODE_TAV = "bdial TAV"
+ const val TAKEMODE_AV = "bdial AV"
+ const val TAKEMODE_TV = "bdial TV"
+ const val TAKEMODE_P = "bdial P"
+ const val TAKEMODE_AUTO = "bdial AUTO"
+ const val TAKEMODE_MY1 = "bdial MY1"
+ const val TAKEMODE_MY2 = "bdial MY2"
+ const val TAKEMODE_MY3 = "bdial MY3"
+ const val TAKEMODE_MOVIE = "bdial MOVIE"
+ }
+}
-package jp.osdn.gokigen.gokigenassets.operation
+package jp.osdn.gokigen.gokigenassets.camera.interfaces
import android.view.View
import androidx.camera.core.CameraSelector
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.interfaces
+
+interface ICameraHardwareStatus
+{
+ fun isAvailableHardwareStatus(): Boolean
+ fun getLensMountStatus(): String?
+ fun getMediaMountStatus(): String?
+
+ fun getMinimumFocalLength(): Float
+ fun getMaximumFocalLength(): Float
+ fun getActualFocalLength(): Float
+
+ fun inquireHardwareInformation(): Map<String, Any?>?
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.interfaces
+
+interface ICameraInformation
+{
+ val isManualFocus: Boolean
+ val isElectricZoomLens: Boolean
+ val isExposureLocked: Boolean
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.interfaces
+
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.playback.IPlaybackControl
+import jp.osdn.gokigen.gokigenassets.liveview.image.ILiveViewListener
+
+interface ICameraInterfaceProvider
+{
+ fun getCameraInterfaceName() : String
+ fun getCameraControl() : ICameraControl
+ fun getCameraConnection(): ICameraConnection
+ fun getFocusingControl(): IFocusingControl
+ fun getZoomLensControl(): IZoomLensControl
+ fun getCaptureControl(): ICaptureControl
+ fun getCameraStatusListHolder(): ICameraStatus
+ fun getHardwareStatus(): ICameraHardwareStatus
+ fun getCameraRunMode(): ICameraRunMode
+ fun getCameraStatusWatcher(): ICameraStatusWatcher
+ fun getLiveViewControl(): ILiveViewController
+ fun getLiveViewListener(): ILiveViewListener
+ fun getCameraInformation(): ICameraInformation
+
+ fun getDisplayInjector(): IDisplayInjector?
+ fun getButtonControl(): ICameraButtonControl?
+
+ fun getPlaybackControl(): IPlaybackControl?
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.interfaces
+
+
+interface ICameraRunMode
+{
+ /** カメラの動作モード変更 */
+ fun changeRunMode(isRecording: Boolean, callback: ICameraRunModeCallback)
+ fun isRecordingMode() : Boolean
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.interfaces
+
+interface ICameraRunModeCallback
+{
+ fun onCompleted(isRecording: Boolean)
+ fun onErrorOccurred(isRecording: Boolean)
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.interfaces
+
+
+/**
+ *
+ */
+interface ICameraStatus
+{
+ fun getStatusList(key: String): List<String?>
+ fun getStatus(key: String): String
+ fun setStatus(key: String, value: String)
+
+ companion object
+ {
+ var BATTERY = "battery"
+ var STATE = "state"
+ var FOCUS_MODE = "focusMode"
+ var AF_MODE = "AFMode"
+
+ var RESOLUTION = "reso"
+ var DRIVE_MODE = "shootMode"
+ var WHITE_BALANCE = "WBMode"
+
+ var AE = "meteringMode"
+
+ var AE_STATUS_MULTI = "multi"
+ var AE_STATUS_ESP = "ESP"
+ var AE_STATUS_SPOT = "spot"
+ var AE_STATUS_PINPOINT = "Spot"
+ var AE_STATUS_CENTER = "center"
+ var AE_STATUS_CENTER2 = "Ctr-Weighted"
+
+ var EFFECT = "effect"
+ var TAKE_MODE = "exposureMode"
+ var IMAGESIZE = "stillSize"
+ var MOVIESIZE = "movieSize"
+
+ var APERATURE = "av"
+ var SHUTTER_SPEED = "tv"
+ var ISO_SENSITIVITY = "sv"
+ var EXPREV = "xv"
+ var FLASH_XV = "flashxv"
+ var SELF_TIMER = "selftimer"
+
+ var TAKE_MODE_MOVIE = "movie"
+ }
+}
\ No newline at end of file
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.interfaces
+
+/**
+ *
+ *
+ */
+interface ICameraStatusUpdateNotify
+{
+ fun updatedTakeMode(mode: String?)
+ fun updatedShutterSpeed(tv: String?)
+ fun updatedAperture(av: String?)
+ fun updatedExposureCompensation(xv: String?)
+ fun updatedMeteringMode(meteringMode: String?)
+ fun updatedWBMode(wbMode: String?)
+ fun updateRemainBattery(percentage: Int)
+ fun updateFocusedStatus(focused: Boolean, focusLocked: Boolean)
+ fun updateIsoSensitivity(sv: String?)
+ fun updateWarning(warning: String?)
+ fun updateStorageStatus(status: String?)
+}
-package jp.osdn.gokigen.gokigenassets.camera.theta.status
+package jp.osdn.gokigen.gokigenassets.camera.interfaces
import jp.osdn.gokigen.gokigenassets.liveview.message.IMessageDrawer
interface ICameraStatusWatcher
{
fun startStatusWatch(indicator : IMessageDrawer?)
+ fun startStatusWatch(notifier: ICameraStatusUpdateNotify)
fun stopStatusWatch()
}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.interfaces
+
+interface ICaptureControl
+{
+ fun doCapture(kind: Int)
+}
\ No newline at end of file
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.interfaces
+
+import jp.osdn.gokigen.gokigenassets.liveview.IIndicatorControl
+import jp.osdn.gokigen.gokigenassets.liveview.focusframe.IAutoFocusFrameDisplay
+
+
+interface IDisplayInjector
+{
+ fun injectDisplay(
+ frameDisplayer: IAutoFocusFrameDisplay,
+ indicator: IIndicatorControl,
+ focusingModeNotify: IFocusingModeNotify
+ )
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.interfaces
+
+import android.view.MotionEvent
+
+interface IFocusingControl
+{
+ fun driveAutoFocus(motionEvent: MotionEvent?): Boolean
+ fun unlockAutoFocus()
+ fun halfPressShutter(isPressed: Boolean)
+}
\ No newline at end of file
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.interfaces
+
+interface IFocusingModeNotify
+{
+ fun changedFocusingMode()
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.interfaces
+
+interface IZoomLensControl
+{
+ fun canZoom(): Boolean
+ fun updateStatus()
+ fun getMaximumFocalLength(): Float
+ fun getMinimumFocalLength(): Float
+ fun getCurrentFocalLength(): Float
+ fun driveZoomLens(targetLength: Float)
+ fun driveZoomLens(isZoomIn: Boolean)
+ fun moveInitialZoomPosition()
+ fun isDrivingZoomLens(): Boolean
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.interfaces.playback
+
+interface ICameraContentListCallback {
+ fun onCompleted(contentList: List<ICameraFileInfo?>?)
+
+ //void onCompleted(List<ICameraContent> contentList);
+ fun onErrorOccurred(e: Exception?)
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.interfaces.playback
+
+import java.util.*
+
+interface ICameraFileInfo
+{
+
+ fun getDatetime(): Date?
+ fun getDirectoryPath(): String?
+ fun getFilename(): String?
+ fun getOriginalFilename(): String?
+
+ fun getAperature(): String?
+ fun getShutterSpeed(): String?
+ fun getIsoSensitivity(): String?
+ fun getExpRev(): String?
+ fun getOrientation(): Int
+ fun getAspectRatio(): String?
+ fun getModel(): String?
+ fun getLatLng(): String?
+ fun getCaptured(): Boolean
+
+ fun updateValues(
+ dateTime: String,
+ av: String,
+ tv: String,
+ sv: String,
+ xv: String,
+ orientation: Int,
+ aspectRatio: String,
+ model: String,
+ LatLng: String,
+ captured: Boolean
+ )
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.interfaces.playback
+
+import java.util.*
+
+interface ICameraFileInfoSetter
+{
+ fun setDate(datetime: Date)
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.interfaces.playback
+
+interface IContentInfoCallback
+{
+ fun onErrorOccurred(e: Exception?)
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.interfaces.playback
+
+interface IDownloadContentCallback
+{
+ fun onCompleted()
+ fun onErrorOccurred(e: Exception?)
+ fun onProgress(data: ByteArray?, length: Int, e: IProgressEvent?)
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.interfaces.playback
+
+import android.graphics.Bitmap
+
+interface IDownloadThumbnailImageCallback
+{
+ fun onCompleted(bitmap: Bitmap?, metadata: HashMap<String?, Any?>?)
+ fun onErrorOccurred(e: Exception?)
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.interfaces.playback
+
+
+/**
+* 画像再生・取得用インタフェース
+*
+*/
+interface IPlaybackControl
+{
+ fun getRawFileSuffix() : String?
+
+ fun downloadContentList(callback: ICameraContentListCallback)
+ fun getContentInfo(path: String?, name: String, callback: IContentInfoCallback)
+
+ fun updateCameraFileInfo(info: ICameraFileInfo?)
+
+ fun downloadContentScreennail(
+ path: String?,
+ name: String,
+ callback: IDownloadThumbnailImageCallback
+ )
+
+ fun downloadContentThumbnail(
+ path: String?,
+ name: String,
+ callback: IDownloadThumbnailImageCallback
+ )
+
+ fun downloadContent(
+ path: String?,
+ name: String,
+ isSmallSize: Boolean,
+ callback: IDownloadContentCallback
+ )
+
+ fun showPictureStarted()
+ fun showPictureFinished()
+
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.interfaces.playback
+
+interface IProgressEvent
+{
+ val progress: Float
+ val isCancellable: Boolean
+
+ fun requestCancellation()
+ interface CancelCallback
+ {
+ fun requestCancellation()
+ }
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.ricohpentax
+
+import android.util.Log
+import android.view.View
+import androidx.camera.core.CameraSelector
+import androidx.fragment.app.FragmentActivity
+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.ILiveViewRefresher
+import jp.osdn.gokigen.gokigenassets.camera.ricohpentax.connection.IUseGR2CommandNotify
+import jp.osdn.gokigen.gokigenassets.camera.ricohpentax.connection.RicohGr2Connection
+import jp.osdn.gokigen.gokigenassets.camera.ricohpentax.liveview.RicohGr2LiveViewControl
+import jp.osdn.gokigen.gokigenassets.camera.ricohpentax.operation.*
+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.liveview.IIndicatorControl
+import jp.osdn.gokigen.gokigenassets.liveview.focusframe.IAutoFocusFrameDisplay
+
+class RicohPentaxCameraControl(context: FragmentActivity, provider: 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 val buttonControl = RicohGr2CameraButtonControl()
+ private val statusChecker = RicohGr2StatusChecker(500)
+ private val playbackControl = RicohGr2PlaybackControl(communicationTimeoutMs)
+ private val hardwareStatus = RicohGr2HardwareStatus()
+ private val runMode = RicohGr2RunMode()
+
+ //private final boolean useGrCommand;
+ 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
+
+
+
+ override fun startLiveView()
+ {
+ TODO("Not yet implemented")
+ }
+
+ override fun stopLiveView()
+ {
+ TODO("Not yet implemented")
+ }
+
+ override fun getConnectionMethod(): String
+ {
+ TODO("Not yet implemented")
+ }
+
+ override fun initialize()
+ {
+ TODO("Not yet implemented")
+ }
+
+ override fun connectToCamera()
+ {
+ TODO("Not yet implemented")
+ }
+
+ override fun startCamera(isPreviewView: Boolean, cameraSelector: CameraSelector)
+ {
+ TODO("Not yet implemented")
+ }
+
+ override fun finishCamera()
+ {
+ TODO("Not yet implemented")
+ }
+
+ override fun changeCaptureMode(mode: String)
+ {
+ TODO("Not yet implemented")
+ }
+
+ override fun setRefresher(refresher: ILiveViewRefresher, imageView: ILiveView)
+ {
+ TODO("Not yet implemented")
+ }
+
+ override fun captureButtonReceiver(id: Int): View.OnClickListener
+ {
+ TODO("Not yet implemented")
+ }
+
+ override fun onClick(v: View?)
+ {
+ TODO("Not yet implemented")
+ }
+
+ override fun changedCaptureMode(captureMode: String)
+ {
+ TODO("Not yet implemented")
+ }
+
+ override fun doShutter()
+ {
+ TODO("Not yet implemented")
+ }
+
+ override fun doShutterOff()
+ {
+ TODO("Not yet implemented")
+ }
+
+ override fun setUseGR2Command(useGR2Command: Boolean, useCameraScreen: Boolean)
+ {
+ this.useGR2Command = useGR2Command
+ this.useCameraScreen = useCameraScreen
+ }
+
+ /**
+ *
+ *
+ */
+ companion object
+ {
+ private val TAG = RicohPentaxCameraControl::class.java.simpleName
+ private const val communicationTimeoutMs = 5000
+ }
+
+ override fun injectDisplay(frameDisplayer: IAutoFocusFrameDisplay, indicator: IIndicatorControl, focusingModeNotify: IFocusingModeNotify)
+ {
+ Log.v(TAG, "injectDisplay()")
+ focusControl = RicohGr2CameraFocusControl(frameDisplayer, indicator)
+ captureControl = RicohGr2CameraCaptureControl(pentaxCaptureAfterAf, frameDisplayer, statusChecker)
+ if (useGR2CommandUpdated)
+ {
+ captureControl?.setUseGR2Command(useGR2Command)
+ focusControl?.setUseGR2Command(useGR2Command)
+ }
+ }
+
+}
\ No newline at end of file
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.ricohpentax.connection
+
+interface IUseGR2CommandNotify
+{
+ fun setUseGR2Command(useGR2Command: Boolean, useCameraScreen: Boolean)
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.ricohpentax.connection
+
+import android.app.Activity
+import android.util.Log
+import androidx.preference.PreferenceManager
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraConnection
+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_CAMERA_NOT_FOUND
+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 {
+
+ companion object
+ {
+ private val TAG = RicohGr2CameraConnectSequence::class.java.simpleName
+ private const val TIMEOUT_MS = 5000
+ }
+ private val httpClient = SimpleHttpClient()
+
+ override fun run() {
+ val areYouThereUrl = "$executeUrl/v1/ping"
+ val grCommandUrl = "$executeUrl/_gr"
+ try {
+ val response: String = httpClient.httpGet(areYouThereUrl, TIMEOUT_MS)
+ Log.v(TAG, "$areYouThereUrl $response")
+ if (response.isNotEmpty())
+ {
+ val preferences = PreferenceManager.getDefaultSharedPreferences(context)
+
+ // 接続時、レンズロックOFF + GR2 コマンド有効/無効の確認
+ run {
+ val postData = "cmd=acclock off"
+ val response0: String? = httpClient.httpPost(grCommandUrl, postData, TIMEOUT_MS)
+ Log.v(TAG, "$grCommandUrl $response0")
+
+ // GR2 専用コマンドを受け付けられるかどうかで、Preference を書き換える
+ val enableGr2Command = response0 != null
+ try
+ {
+ val editor = preferences.edit()
+ editor.putBoolean(ID_PREFERENCE_USE_GR2_SPECIAL_COMMAND, enableGr2Command)
+ editor.apply()
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ val gr2LcdSleep = preferences.getBoolean(ID_PREFERENCE_RICOH_GR2_LCD_SLEEP, false)
+ gr2CommandNotify.setUseGR2Command(enableGr2Command, gr2LcdSleep)
+
+ // 接続時、カメラの画面を消す
+ if ((enableGr2Command)&&(gr2LcdSleep))
+ {
+ val postData0 = "cmd=lcd sleep on"
+ val response1: String? = httpClient.httpPost(grCommandUrl, postData0, TIMEOUT_MS)
+ Log.v(TAG, "$grCommandUrl $response1")
+ }
+ }
+ onConnectNotify()
+ } else {
+ onConnectError(context.getString(ID_STRING_CAMERA_NOT_FOUND))
+ }
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ onConnectError(e.localizedMessage)
+ }
+ }
+
+ private fun onConnectNotify()
+ {
+ try
+ {
+ val thread = Thread { // カメラとの接続確立を通知する
+ cameraStatusReceiver.onStatusNotify(context.getString(ID_STRING_CONNECT_CONNECTED))
+ cameraStatusReceiver.onCameraConnected()
+ Log.v(TAG, "onConnectNotify()")
+ }
+ thread.start()
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ }
+
+ private fun onConnectError(reason: String?)
+ {
+ cameraConnection.alertConnectingFailed(reason)
+ }
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.ricohpentax.connection
+
+import android.app.Activity
+import android.util.Log
+import androidx.preference.PreferenceManager
+import jp.osdn.gokigen.gokigenassets.constants.IApplicationConstantConvert.Companion.ID_PREFERENCE_RICOH_GR2_LCD_SLEEP
+import jp.osdn.gokigen.gokigenassets.utils.communication.SimpleHttpClient
+
+
+class RicohGr2CameraDisconnectSequence(private val activity: Activity, private val powerOff: Boolean, private val executeUrl : String = "http://192.168.0.1") : Runnable
+{
+ companion object
+ {
+ private val TAG = RicohGr2CameraDisconnectSequence::class.java.simpleName
+ private const val TIMEOUT_MS = 5000
+ }
+
+ override fun run()
+ {
+ // カメラをPowerOffして接続を切る
+ try
+ {
+ val preferences = PreferenceManager.getDefaultSharedPreferences(activity)
+ val httpClient = SimpleHttpClient()
+ if (preferences.getBoolean(ID_PREFERENCE_RICOH_GR2_LCD_SLEEP, false))
+ {
+ val screenOnUrl = "$executeUrl/_gr"
+ val postData = "lcd sleep off"
+ val response: String? = httpClient.httpPost(screenOnUrl, postData, TIMEOUT_MS)
+ Log.v(TAG, "$screenOnUrl $response")
+ }
+ if (powerOff)
+ {
+ val cameraPowerOffUrl = "$executeUrl/v1/device/finish"
+ val postData = ""
+ val response: String? = httpClient.httpPost(cameraPowerOffUrl, postData, TIMEOUT_MS)
+ Log.v(TAG, "$cameraPowerOffUrl $response")
+ }
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ }
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.ricohpentax.connection
+
+import android.content.*
+import android.net.ConnectivityManager
+import android.net.wifi.WifiManager
+import android.provider.Settings
+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.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 jp.osdn.gokigen.gokigenassets.constants.ICameraConstantConvert.Companion.ID_STRING_DIALOG_TITLE_CONNECT_FAILED
+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
+{
+ companion object
+ {
+ private val TAG = RicohGr2Connection::class.java.simpleName
+ }
+ private val connectionReceiver: BroadcastReceiver
+
+ //private final ConnectivityManager connectivityManager;
+ private val cameraExecutor: Executor = Executors.newFixedThreadPool(1)
+
+ //private final Handler networkConnectionTimeoutHandler;
+ //private static final int MESSAGE_CONNECTIVITY_TIMEOUT = 1;
+ private var connectionStatus: ICameraConnectionStatus.CameraConnectionStatus = ICameraConnectionStatus.CameraConnectionStatus.UNKNOWN
+
+ /**
+ *
+ *
+ */
+ 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
+ {
+ @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
+ )
+ }
+ }
+ }
+ }
+ } catch (e: Exception) {
+ Log.w(TAG, "onReceiveBroadcastOfConnection() EXCEPTION" + e.message)
+ e.printStackTrace()
+ }
+ }
+
+ /**
+ *
+ *
+ */
+ fun startWatchWifiStatus(context: Context) {
+ Log.v(TAG, "startWatchWifiStatus()")
+ statusReceiver.onStatusNotify("prepare")
+ val filter = IntentFilter()
+ filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION)
+ @Suppress("DEPRECATION")
+ filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION)
+ context.registerReceiver(connectionReceiver, filter)
+ }
+
+ /**
+ *
+ *
+ */
+ fun stopWatchWifiStatus(context: Context) {
+ Log.v(TAG, "stopWatchWifiStatus()")
+ context.unregisterReceiver(connectionReceiver)
+ disconnect(false)
+ }
+
+ /**
+ *
+ *
+ */
+ fun disconnect(powerOff: Boolean) {
+ Log.v(TAG, "disconnect()")
+ disconnectFromCamera(powerOff)
+ connectionStatus = ICameraConnectionStatus.CameraConnectionStatus.DISCONNECTED
+ statusReceiver.onCameraDisconnected()
+ }
+
+ /**
+ *
+ *
+ */
+ fun connect() {
+ Log.v(TAG, "connect()")
+ connectToCamera()
+ }
+
+ /**
+ *
+ *
+ */
+ override fun alertConnectingFailed(message: String?) {
+ Log.v(TAG, "alertConnectingFailed() : $message")
+ if (context != null) {
+ 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() }
+ .setNeutralButton(ID_STRING_DIALOG_BUTTON_NETWORK_SETTINGS
+ ) { dialog, which ->
+ try {
+ // Wifi 設定画面を表示する
+ context.startActivity(Intent(Settings.ACTION_WIFI_SETTINGS))
+ } catch (ex: ActivityNotFoundException) {
+ // Activity が存在しなかった...設定画面が起動できなかった
+ Log.v(TAG, "android.content.ActivityNotFoundException...")
+
+ // この場合は、再試行と等価な動きとする
+ connect()
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
+ }
+ context.runOnUiThread({ builder.show() })
+ }
+ }
+
+ fun getConnectionStatus(): ICameraConnectionStatus.CameraConnectionStatus {
+ Log.v(TAG, "getConnectionStatus()")
+ return connectionStatus
+ }
+
+ /**
+ *
+ *
+ */
+ override fun forceUpdateConnectionStatus(status: ICameraConnectionStatus.CameraConnectionStatus) {
+ Log.v(TAG, "forceUpdateConnectionStatus()")
+ connectionStatus = status
+ }
+
+ /**
+ * カメラとの切断処理
+ */
+ private fun disconnectFromCamera(powerOff: Boolean) {
+ Log.v(TAG, "disconnectFromCamera()")
+ try {
+ cameraExecutor.execute(RicohGr2CameraDisconnectSequence(context, powerOff))
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
+ }
+
+ /**
+ * カメラとの接続処理
+ */
+ private fun connectToCamera() {
+ Log.v(TAG, "connectToCamera()")
+ connectionStatus = ICameraConnectionStatus.CameraConnectionStatus.CONNECTING
+ try {
+ cameraExecutor.execute(
+ RicohGr2CameraConnectSequence(
+ context,
+ statusReceiver,
+ this,
+ gr2CommandNotify
+ )
+ )
+ } catch (e: Exception) {
+ Log.v(TAG, "connectToCamera() EXCEPTION : " + e.message)
+ e.printStackTrace()
+ }
+ }
+
+ init {
+ Log.v(TAG, " RicohGr2Connection()")
+ connectionReceiver = object : BroadcastReceiver() {
+ override fun onReceive(context: Context, intent: Intent)
+ {
+ onReceiveBroadcastOfConnection(context, intent)
+ }
+ }
+ }
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.ricohpentax.liveview
+
+import android.content.Context
+import android.util.Log
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.ILiveViewController
+import jp.osdn.gokigen.gokigenassets.camera.ricohpentax.connection.IUseGR2CommandNotify
+import jp.osdn.gokigen.gokigenassets.liveview.image.CameraLiveViewListenerImpl
+import jp.osdn.gokigen.gokigenassets.utils.communication.SimpleLiveViewSlicer
+
+
+/**
+ *
+ *
+ */
+class RicohGr2LiveViewControl(context: Context, executeUrl : String = "http://192.168.0.1") : ILiveViewController, IUseGR2CommandNotify
+{
+
+ private val liveViewListener = CameraLiveViewListenerImpl(context)
+ private val cameraDisplayUrl = "$executeUrl/v1/display" // カメラの画面をコピーする場合...
+ private val liveViewUrl = "$executeUrl/v1/liveview" // 何も表示しない(ライブビューモード)の場合...
+ //private var cropScale = 1.0f
+ private var whileFetching = false
+ private var useGR2command = false
+ private var useCameraScreen = false
+
+ companion object
+ {
+ private val TAG = RicohGr2LiveViewControl::class.java.simpleName
+ private const val FETCH_ERROR_MAX = 30
+ }
+
+ override fun setUseGR2Command(useGR2cmd: Boolean, useCameraScreen: Boolean) {
+ this.useGR2command = useGR2cmd
+ this.useCameraScreen = useCameraScreen
+ }
+
+/*
+ fun changeLiveViewSize(size: String?) {
+ //
+ }
+*/
+
+ override fun startLiveView() {
+ val isCameraScreen = useGR2command && useCameraScreen
+ Log.v(TAG, "startLiveView()")
+ try {
+ val thread = Thread {
+ try {
+ if (isCameraScreen) {
+ start(cameraDisplayUrl)
+ } else {
+ start(liveViewUrl)
+ }
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
+ }
+ thread.start()
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
+ }
+
+ override fun stopLiveView() {
+ Log.v(TAG, "stopLiveView()")
+ whileFetching = false
+ }
+
+ private fun start(streamUrl: String) {
+ if (whileFetching) {
+ Log.v(TAG, "start() already starting.")
+ }
+ whileFetching = true
+
+ // A thread for retrieving liveview data from server.
+ 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.
+ slicer = SimpleLiveViewSlicer()
+ slicer.open(streamUrl)
+ while (whileFetching) {
+ val payload: SimpleLiveViewSlicer.Payload? = slicer.nextPayloadForMotionJpeg()
+ if (payload == null) {
+ //Log.v(TAG, "Liveview Payload is null.");
+ continuousNullDataReceived++
+ if (continuousNullDataReceived > FETCH_ERROR_MAX) {
+ Log.d(TAG, " FETCH ERROR MAX OVER ")
+ break
+ }
+ continue
+ }
+ val jpegData = payload.getJpegData()
+ if (jpegData != null) {
+ liveViewListener.onUpdateLiveView(jpegData, null)
+ }
+ continuousNullDataReceived = 0
+ }
+ } catch (e: Exception) {
+ e.printStackTrace()
+ } finally {
+ try {
+ slicer?.close()
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
+ //mJpegQueue.clear();
+ if (!whileFetching && continuousNullDataReceived > FETCH_ERROR_MAX) {
+ // 再度ライブビューのスタートをやってみる。
+ whileFetching = false
+ //continuousNullDataReceived = 0;
+ start(streamUrl)
+ }
+ }
+ }
+ thread.start()
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
+ }
+
+/*
+ fun updateDigitalZoom() {}
+*/
+ /**
+ * デジタルズーム倍率の設定値を応答する
+ *
+ */
+/*
+ val digitalZoomScale: Float
+ get() = 1.0f
+*/
+
+ /**
+ * クロップサイズを変更する
+ *
+ */
+/*
+ fun updateMagnifyingLiveViewScale(isChangeScale: Boolean) {
+ //
+ try {
+ val httpClient = SimpleHttpClient()
+ if (isChangeScale) {
+ cropScale = if (cropScale == 1.0f) {
+ 1.25f
+ } else if (cropScale == 1.25f) {
+ 1.68f
+ } else {
+ 1.0f
+ }
+ }
+ val thread = Thread {
+ try {
+ var cropSize = "CROP_SIZE_ORIGINAL"
+ val timeoutMs = 5000
+ val grCmdUrl = "http://192.168.0.1/_gr"
+ var postData: String
+ var result: String?
+ if (isChangeScale) {
+ postData = "mpget=CROP_SHOOTING"
+ result = httpClient.httpPost(grCmdUrl, postData, timeoutMs)
+ if (result == null || result.isEmpty()) {
+ Log.v(TAG, "reply is null.")
+ cropScale = 1.0f
+ } else if (result.contains("SIZE_M")) {
+ cropSize = "CROP_SIZE_S"
+ cropScale = 1.68f
+ } else if (result.contains("SIZE_S")) {
+ cropSize = "CROP_SIZE_ORIGINAL"
+ cropScale = 1.0f
+ } else {
+ cropSize = "CROP_SIZE_M"
+ cropScale = 1.25f
+ }
+ }
+ postData = "mpset=CROP_SHOOTING $cropSize"
+ result = httpClient.httpPost(grCmdUrl, postData, timeoutMs)
+ Log.v(TAG, "RESULT1 : $result")
+ postData = "cmd=mode refresh"
+ result = httpClient.httpPost(grCmdUrl, postData, timeoutMs)
+ Log.v(TAG, "RESULT2 : $result")
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
+ }
+ thread.start()
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
+ }
+*/
+
+ /**
+ * ライブビュー拡大倍率の設定値を応答する
+ *
+ */
+/*
+ val magnifyingLiveViewScale: Float
+ get() = cropScale
+
+ fun getLiveViewListener(): ILiveViewListener {
+ return liveViewListener
+ }
+*/
+
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.ricohpentax.operation
+
+interface IRicohGr2ButtonControl
+{
+ fun pushedButton(code: String, isLongPress: Boolean): Boolean
+
+ companion object
+ {
+ var SPECIAL_GREEN_BUTTON = "btn_green"
+
+ var FRONT_LEFT = "bjogleft"
+ var FRONT_RIGHT = "bjogright"
+ var ADJ_LEFT = "badjleft"
+ var ADJ_ENTER = "badjok"
+ var ADJ_RIGHT = "badjright"
+
+ var TOGGLE_AEAF_OFF = "baf 0"
+ var TOGGLE_AEAF_ON = "baf 1"
+
+ var LEVER_AEAFL = "bafl"
+ var LEVER_CAF = "bafc"
+
+ var BUTTON_UP = "bup"
+ var BUTTON_LEFT = "bleft"
+ var BUTTON_ENTER = "bok"
+ var BUTTON_RIGHT = "bright"
+ var BUTTON_DOWN = "bdown"
+
+ var BUTTON_FUNCTION_1 = "bdisp"
+ var BUTTON_FUNCTION_2 = "btrash"
+ var BUTTON_FUNCTION_3 = "beffect"
+
+ var BUTTON_PLUS = "btele"
+ var BUTTON_MINUS = "bwide"
+ var BUTTON_PLAYBACK = "bplay"
+
+ var KEYLOCK_ON = "uilock on"
+ var KEYLOCK_OFF = "uilock off"
+
+ var LENS_OPEN = "acclock off"
+ var LENS_RETRACT = "acclock on"
+
+ var MUTE_ON = "audio mute on"
+ var MUTE_OFF = "audio mute off"
+
+ var LCD_SLEEP_ON = "lcd sleep on"
+ var LCD_SLEEP_OFF = "lcd sleep off"
+
+ var LED1_ON = "led on 1"
+ var LED1_OFF = "led off 1"
+
+ var BEEP = "audio resplay 0 1 3"
+
+ var MODE_REFRESH = "mode refresh"
+
+ var SHUTTER = "brl 0"
+ var SHUTTER_PRESS_AND_HALF_HOLD = "brl 2 1"
+
+ var TAKEMODE_M = "bdial M"
+ var TAKEMODE_TAV = "bdial TAV"
+ var TAKEMODE_AV = "bdial AV"
+ var TAKEMODE_TV = "bdial TV"
+ var TAKEMODE_P = "bdial P"
+ var TAKEMODE_AUTO = "bdial AUTO"
+ var TAKEMODE_MY1 = "bdial MY1"
+ var TAKEMODE_MY2 = "bdial MY2"
+ var TAKEMODE_MY3 = "bdial MY3"
+ var TAKEMODE_MOVIE = "bdial MOVIE"
+ }
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.ricohpentax.operation
+
+
+interface IRicohGr2CameraStatus
+{
+ fun getStatusList(key: String): List<String?>
+ fun getStatus(key: String): String
+ fun setStatus(key: String, value: String)
+
+ companion object
+ {
+ var BATTERY = "battery"
+ var STATE = "state"
+ var FOCUS_MODE = "focusMode"
+ var AF_MODE = "AFMode"
+
+ var RESOLUTION = "reso"
+ var DRIVE_MODE = "shootMode"
+ var WHITE_BALANCE = "WBMode"
+
+ var AE = "meteringMode"
+
+ var AE_STATUS_MULTI = "multi"
+ var AE_STATUS_ESP = "ESP"
+ var AE_STATUS_SPOT = "spot"
+ var AE_STATUS_PINPOINT = "Spot"
+ var AE_STATUS_CENTER = "center"
+ var AE_STATUS_CENTER2 = "Ctr-Weighted"
+
+ var EFFECT = "effect"
+ var TAKE_MODE = "exposureMode"
+ var IMAGESIZE = "stillSize"
+ var MOVIESIZE = "movieSize"
+
+ var APERATURE = "av"
+ var SHUTTER_SPEED = "tv"
+ var ISO_SENSITIVITY = "sv"
+ var EXPREV = "xv"
+ var FLASH_XV = "flashxv"
+ var SELF_TIMER = "selftimer"
+
+ var TAKE_MODE_MOVIE = "movie"
+ }
+}
\ No newline at end of file
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.ricohpentax.operation
+
+import android.util.Log
+import jp.osdn.gokigen.gokigenassets.camera.ricohpentax.operation.IRicohGr2ButtonControl.Companion.SPECIAL_GREEN_BUTTON
+import jp.osdn.gokigen.gokigenassets.utils.communication.SimpleHttpClient
+
+
+/**
+ *
+ *
+ */
+class RicohGr2CameraButtonControl(executeUrl : String = "http://192.168.0.1") : IRicohGr2ButtonControl
+{
+ private val buttonControlUrl = "$executeUrl/_gr"
+ private val greenButtonUrl = "$executeUrl/v1/params/camera"
+ private val timeoutMs = 6000
+ private val httpClient = SimpleHttpClient()
+
+ companion object
+ {
+ private val TAG: String = RicohGr2CameraButtonControl::class.java.getSimpleName()
+ }
+
+ /**
+ *
+ *
+ */
+ override fun pushedButton(code: String, isLongPress: Boolean): Boolean
+ {
+ return pushButton(code, isLongPress)
+ }
+
+ /**
+ *
+ *
+ */
+ private fun pushButton(keyName: String, isLongPress: Boolean): Boolean
+ {
+ Log.v(TAG, "pushButton()")
+ if (keyName == SPECIAL_GREEN_BUTTON)
+ {
+ // Greenボタンの処理を入れる
+ return processGreenButton(isLongPress)
+ }
+ try
+ {
+ val thread = Thread {
+ try
+ {
+ var cmd = "cmd=$keyName"
+ if (isLongPress) {
+ // ボタン長押しの場合...
+ cmd = "$cmd 1"
+ }
+ val result: String? =
+ httpClient.httpPost(buttonControlUrl, cmd, timeoutMs)
+ if (result == null || result.isEmpty()) {
+ Log.v(TAG, "pushButton() reply is null. $cmd")
+ } else {
+ Log.v(TAG, "pushButton() $cmd result: $result")
+ }
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ }
+ thread.start()
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ return true
+ }
+
+ private fun processGreenButton(isLongPress: Boolean): Boolean {
+ Log.v(TAG, "processGreenButton()")
+ try {
+ val thread = Thread {
+ try {
+ val cmd = ""
+ val result: String? =
+ httpClient.httpPut(greenButtonUrl, cmd, timeoutMs)
+ if (result == null || result.isEmpty()) {
+ Log.v(TAG, "processGreenButton() reply is null.")
+ } else {
+ Log.v(TAG, "processGreenButton() result: $result")
+ }
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
+ }
+ thread.start()
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
+ return true
+ }
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.ricohpentax.operation
+
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraStatus
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICaptureControl
+import jp.osdn.gokigen.gokigenassets.camera.ricohpentax.operation.takepicture.RicohGr2MovieShotControl
+import jp.osdn.gokigen.gokigenassets.camera.ricohpentax.operation.takepicture.RicohGr2SingleShotControl
+import jp.osdn.gokigen.gokigenassets.liveview.focusframe.IAutoFocusFrameDisplay
+
+/**
+ *
+ *
+ */
+class RicohGr2CameraCaptureControl(private val captureAfterAf: Boolean, frameDisplayer: IAutoFocusFrameDisplay, private val cameraStatus: ICameraStatus) : ICaptureControl
+{
+ private val singleShotControl = RicohGr2SingleShotControl(frameDisplayer)
+ private val movieShotControl = RicohGr2MovieShotControl(frameDisplayer)
+ private var useGR2command = false
+
+ fun setUseGR2Command(useGR2command: Boolean)
+ {
+ this.useGR2command = useGR2command
+ }
+
+ /**
+ *
+ *
+ */
+ override fun doCapture(kind: Int)
+ {
+ try
+ {
+ val status = cameraStatus.getStatus(IRicohGr2CameraStatus.TAKE_MODE)
+ if (status.contains(IRicohGr2CameraStatus.TAKE_MODE_MOVIE))
+ {
+ movieShotControl.toggleMovie()
+ }
+ else
+ {
+ singleShotControl.singleShot(useGR2command, captureAfterAf)
+ }
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ }
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.ricohpentax.operation
+
+import android.graphics.PointF
+import android.util.Log
+import android.view.MotionEvent
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.IFocusingControl
+import jp.osdn.gokigen.gokigenassets.camera.ricohpentax.operation.takepicture.RicohGr2AutoFocusControl
+import jp.osdn.gokigen.gokigenassets.liveview.IIndicatorControl
+import jp.osdn.gokigen.gokigenassets.liveview.focusframe.IAutoFocusFrameDisplay
+
+/**
+ *
+ *
+ */
+class RicohGr2CameraFocusControl(private val frameDisplay: IAutoFocusFrameDisplay, indicator: IIndicatorControl) : IFocusingControl
+{
+ private val afControl = RicohGr2AutoFocusControl(frameDisplay, indicator)
+
+ companion object
+ {
+ private val TAG: String = RicohGr2CameraFocusControl::class.java.getSimpleName()
+ }
+
+ fun setUseGR2Command(useGR2command: Boolean)
+ {
+ afControl.setUseGR2Command(useGR2command)
+ }
+
+ /**
+ *
+ *
+ */
+ override fun driveAutoFocus(motionEvent: MotionEvent?): Boolean {
+ Log.v(TAG, "driveAutoFocus()")
+ if ((motionEvent == null)||(motionEvent.action != MotionEvent.ACTION_DOWN))
+ {
+ return false
+ }
+ try
+ {
+ val point: PointF? = frameDisplay.getPointWithEvent(motionEvent)
+ if ((point != null)&&(frameDisplay.isContainsPoint(point)))
+ {
+ afControl.lockAutoFocus(point)
+ }
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ return false
+ }
+
+ /**
+ *
+ *
+ */
+ override fun unlockAutoFocus()
+ {
+ afControl.unlockAutoFocus()
+ }
+
+ override fun halfPressShutter(isPressed: Boolean) {}
+
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.ricohpentax.operation
+
+import android.content.Context
+import androidx.preference.Preference
+import jp.osdn.gokigen.gokigenassets.constants.IApplicationConstantConvert.Companion.ID_DIALOG_EXIT_POWER_OFF
+import jp.osdn.gokigen.gokigenassets.constants.IApplicationConstantConvert.Companion.ID_DIALOG_TITLE_CONFIRMATION
+import jp.osdn.gokigen.gokigenassets.constants.IApplicationConstantConvert.Companion.ID_PREFERENCE_LABEL_EXIT_APPLICATION
+import jp.osdn.gokigen.gokigenassets.scene.IChangeSceneBasic
+import jp.osdn.gokigen.gokigenassets.utils.ConfirmationDialog
+
+class RicohGr2CameraPowerOff(private val context: Context, private val changeScene: IChangeSceneBasic) : Preference.OnPreferenceClickListener, ConfirmationDialog.ConfirmationCallback
+{
+ private var preferenceKey: String? = null
+
+ /**
+ * クラスの準備
+ *
+ */
+ fun prepare() {
+ // 何もしない
+ }
+
+ /**
+ *
+ *
+ * @param preference クリックしたpreference
+ * @return false : ハンドルしない / true : ハンドルした
+ */
+ override fun onPreferenceClick(preference: Preference): Boolean {
+ if (!preference.hasKey()) {
+ return false
+ }
+ preferenceKey = preference.key
+ val isContain = preferenceKey?.contains(ID_PREFERENCE_LABEL_EXIT_APPLICATION)
+ if ((isContain != null)&&(isContain))
+ {
+
+ // 確認ダイアログの生成と表示
+ val dialog: ConfirmationDialog = ConfirmationDialog.newInstance(context)
+ dialog.show(ID_DIALOG_TITLE_CONFIRMATION, ID_DIALOG_EXIT_POWER_OFF, this)
+ return true
+ }
+ return false
+ }
+
+ /**
+ *
+ *
+ */
+ override fun confirm()
+ {
+ val isContain = preferenceKey?.contains(ID_PREFERENCE_LABEL_EXIT_APPLICATION)
+ if ((isContain != null)&&(isContain))
+ {
+ // カメラの電源をOFFにしたうえで、アプリケーションを終了する。
+ changeScene.exitApplication()
+ }
+ }
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.ricohpentax.operation
+
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.IZoomLensControl
+
+/**
+ *
+ *
+ */
+class RicohGr2CameraZoomLensControl : IZoomLensControl
+{
+ /**
+ *
+ *
+ */
+ override fun canZoom(): Boolean
+ {
+ return (false)
+ }
+
+ /**
+ *
+ *
+ */
+ override fun updateStatus() {}
+
+ /**
+ *
+ *
+ */
+ override fun getMaximumFocalLength() : Float
+ {
+ return (0.0f)
+ }
+
+ /**
+ *
+ *
+ */
+ override fun getMinimumFocalLength(): Float
+ {
+ return (0.0f)
+ }
+
+ /**
+ *
+ *
+ */
+ override fun getCurrentFocalLength(): Float
+ {
+ return (0.0f)
+ }
+
+ /**
+ *
+ *
+ */
+ override fun driveZoomLens(targetLength: Float) {}
+
+ /**
+ *
+ *
+ */
+ override fun driveZoomLens(isZoomIn: Boolean) {}
+
+ /**
+ *
+ *
+ */
+ override fun moveInitialZoomPosition() {}
+
+ /**
+ *
+ *
+ */
+ override fun isDrivingZoomLens(): Boolean
+ {
+ return (false)
+ }
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.ricohpentax.operation
+
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraHardwareStatus
+
+
+class RicohGr2HardwareStatus : ICameraHardwareStatus
+{
+ override fun isAvailableHardwareStatus(): Boolean { return false }
+ override fun getLensMountStatus(): String? { return null }
+ override fun getMediaMountStatus(): String? { return null }
+ override fun getMinimumFocalLength(): Float { return 0.0f }
+ override fun getMaximumFocalLength(): Float { return 0.0f }
+ override fun getActualFocalLength(): Float { return 0.0f }
+ override fun inquireHardwareInformation(): Map<String, Any?>? { return null }
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.ricohpentax.operation.takepicture
+
+import android.graphics.PointF
+import android.graphics.RectF
+import android.util.Log
+import jp.osdn.gokigen.gokigenassets.liveview.focusframe.IAutoFocusFrameDisplay
+import jp.osdn.gokigen.gokigenassets.liveview.IIndicatorControl
+import jp.osdn.gokigen.gokigenassets.utils.communication.SimpleHttpClient
+import org.json.JSONObject
+
+/**
+ *
+ *
+ */
+class RicohGr2AutoFocusControl(private val frameDisplayer: IAutoFocusFrameDisplay, private val indicator: IIndicatorControl, executeUrl : String = "http://192.168.0.1")
+{
+ private val autoFocusUrl = "$executeUrl/v1/lens/focus"
+ private val lockAutoFocusUrl = "$executeUrl/v1/lens/focus/lock"
+ private val unlockAutoFocusUrl = "$executeUrl/v1/lens/focus/unlock"
+ private val timeoutMs = 6000
+ private val httpClient = SimpleHttpClient()
+ private var useGR2command = false
+
+ fun setUseGR2Command(useGR2command: Boolean)
+ {
+ this.useGR2command = useGR2command
+ }
+
+ /**
+ *
+ *
+ */
+ fun lockAutoFocus(point: PointF)
+ {
+ Log.v(TAG, "lockAutoFocus() : [" + point.x + ", " + point.y + "]")
+ try {
+ val thread = Thread {
+ val preFocusFrameRect = getPreFocusFrameRect(point)
+ try {
+ showFocusFrame(
+ preFocusFrameRect,
+ IAutoFocusFrameDisplay.FocusFrameStatus.Running,
+ 0.0f
+ )
+
+ //int posX = (int) (Math.round(point.x * 100.0));
+ //int posY = (int) (Math.round(point.y * 100.0));
+ val focusUrl = if (useGR2command) lockAutoFocusUrl else autoFocusUrl
+ val postData =
+ "pos=" + Math.round(point.x * 100.0).toInt() + "," + Math.round(
+ point.y * 100.0
+ ).toInt()
+ Log.v(TAG, "AF ($postData)")
+ val result: String? =
+ httpClient.httpPost(focusUrl, postData, timeoutMs)
+ if (result == null || result.isEmpty()) {
+ Log.v(
+ TAG,
+ "setTouchAFPosition() reply is null."
+ )
+ } else if (findTouchAFPositionResult(result)) {
+ // AF FOCUSED
+ Log.v(
+ TAG,
+ "lockAutoFocus() : FOCUSED"
+ )
+ showFocusFrame(
+ preFocusFrameRect,
+ IAutoFocusFrameDisplay.FocusFrameStatus.Focused,
+ 1.0f
+ ) // いったん1秒だけ表示
+ } else {
+ // AF ERROR
+ Log.v(
+ TAG,
+ "lockAutoFocus() : ERROR"
+ )
+ showFocusFrame(
+ preFocusFrameRect,
+ IAutoFocusFrameDisplay.FocusFrameStatus.Failed,
+ 1.0f
+ )
+ }
+ } catch (e: Exception) {
+ e.printStackTrace()
+ try {
+ showFocusFrame(
+ preFocusFrameRect,
+ IAutoFocusFrameDisplay.FocusFrameStatus.Errored,
+ 1.0f
+ )
+ } catch (ee: Exception) {
+ ee.printStackTrace()
+ }
+ }
+ }
+ thread.start()
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
+ }
+
+ /**
+ *
+ *
+ */
+ fun unlockAutoFocus() {
+ Log.v(TAG, "unlockAutoFocus()")
+ try {
+ val thread = Thread {
+ try {
+ val result: String? = httpClient.httpPost(unlockAutoFocusUrl, "", timeoutMs)
+ if (result == null || result.length < 1) {
+ Log.v(
+ TAG,
+ "cancelTouchAFPosition() reply is null."
+ )
+ }
+ hideFocusFrame()
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
+ }
+ thread.start()
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
+ }
+
+ /**
+ *
+ *
+ */
+ private fun showFocusFrame(rect: RectF, status: IAutoFocusFrameDisplay.FocusFrameStatus, duration: Float)
+ {
+ frameDisplayer.showFocusFrame(rect, status, duration)
+ indicator.onAfLockUpdate(IAutoFocusFrameDisplay.FocusFrameStatus.Focused === status)
+ }
+
+ /**
+ *
+ *
+ */
+ private fun hideFocusFrame() {
+ frameDisplayer.hideFocusFrame()
+ indicator.onAfLockUpdate(false)
+ }
+
+ /**
+ *
+ *
+ */
+ private fun getPreFocusFrameRect(point: PointF): RectF {
+ val imageWidth: Float = frameDisplayer.getContentSizeWidth()
+ val imageHeight: Float = frameDisplayer.getContentSizeHeight()
+
+ // Display a provisional focus frame at the touched point.
+ val focusWidth = 0.125f // 0.125 is rough estimate.
+ var focusHeight = 0.125f
+ focusHeight *= if (imageWidth > imageHeight) {
+ imageWidth / imageHeight
+ } else {
+ imageHeight / imageWidth
+ }
+ return RectF(
+ point.x - focusWidth / 2.0f, point.y - focusHeight / 2.0f,
+ point.x + focusWidth / 2.0f, point.y + focusHeight / 2.0f
+ )
+ }
+
+ companion object {
+ private val TAG = RicohGr2AutoFocusControl::class.java.simpleName
+
+ /**
+ *
+ *
+ */
+ private fun findTouchAFPositionResult(replyString: String): Boolean
+ {
+ var afResult = false
+ try
+ {
+ val resultObject = JSONObject(replyString)
+ val result = resultObject.getString("errMsg")
+ val focused = resultObject.getBoolean("focused")
+ if (result.contains("OK"))
+ {
+ afResult = focused
+ Log.v(TAG, "AF Result : $afResult")
+ }
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ return (afResult)
+ }
+ }
+
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.ricohpentax.operation.takepicture
+
+import android.util.Log
+import jp.osdn.gokigen.gokigenassets.liveview.focusframe.IAutoFocusFrameDisplay
+import jp.osdn.gokigen.gokigenassets.utils.communication.SimpleHttpClient
+
+
+/**
+ *
+ *
+ */
+class RicohGr2MovieShotControl(private val frameDisplayer: IAutoFocusFrameDisplay, executeUrl : String = "http://192.168.0.1")
+{
+ private val shootStartUrl = "$executeUrl/v1/camera/shoot/start"
+ private val shootStopUrl = "$executeUrl/v1/camera/shoot/finish"
+ private val timeoutMs = 6000
+ private val isMovieRecording = false
+ private val httpClient = SimpleHttpClient()
+
+ /**
+ *
+ *
+ */
+ fun toggleMovie()
+ {
+ Log.v(TAG, "toggleMovie()")
+ try
+ {
+ val thread = Thread {
+ try
+ {
+ val postData = ""
+ val result: String? = httpClient.httpPost(if (isMovieRecording) shootStopUrl else shootStartUrl, postData, timeoutMs)
+ if ((result == null)||(result.isEmpty()))
+ {
+ Log.v(TAG, "toggleMovie() reply is null.")
+ }
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ frameDisplayer.hideFocusFrame()
+ }
+ thread.start()
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ }
+
+ companion object
+ {
+ private val TAG: String = RicohGr2MovieShotControl::class.java.getSimpleName()
+ }
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.ricohpentax.operation.takepicture
+
+import android.util.Log
+import jp.osdn.gokigen.gokigenassets.liveview.focusframe.IAutoFocusFrameDisplay
+import jp.osdn.gokigen.gokigenassets.utils.communication.SimpleHttpClient
+
+/**
+ *
+ *
+ *
+ */
+class RicohGr2SingleShotControl(private val frameDisplayer: IAutoFocusFrameDisplay, executeUrl : String = "http://192.168.0.1")
+{
+ private val shootUrl = "$executeUrl/v1/camera/shoot"
+ private val timeoutMs = 6000
+ private val httpClient = SimpleHttpClient()
+
+ /**
+ *
+ *
+ */
+ fun singleShot(isCamera: Boolean, isDriveAutoFocus: Boolean) {
+ Log.v(TAG, "singleShot()")
+ try {
+ val thread = Thread {
+ try
+ {
+ var postData = ""
+ if ((isCamera)&&(isDriveAutoFocus))
+ {
+ // RICOH GR II
+ postData = "af=camera"
+ }
+ else if ((!isCamera)&&(isDriveAutoFocus))
+ {
+ // PENTAX DSLR
+ postData = "af=on"
+ }
+ val result: String? = httpClient.httpPost(shootUrl, postData, timeoutMs)
+ if ((result == null)||(result.isEmpty()))
+ {
+ Log.v(TAG, "singleShot() reply is null.")
+ }
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ frameDisplayer.hideFocusFrame()
+ }
+ thread.start()
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ }
+
+ companion object
+ {
+ private val TAG = RicohGr2SingleShotControl::class.java.simpleName
+ }
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.ricohpentax.status
+
+import android.util.Log
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraStatus
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraStatusUpdateNotify
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraStatusWatcher
+import jp.osdn.gokigen.gokigenassets.liveview.message.IMessageDrawer
+import jp.osdn.gokigen.gokigenassets.utils.communication.SimpleHttpClient
+import java.util.*
+
+
+/**
+ *
+ *
+ */
+class RicohGr2StatusChecker
+/**
+ *
+ *
+ */ internal constructor(private val sleepMs: Int, executeUrl : String = "http://192.168.0.1") : ICameraStatusWatcher, ICameraStatus
+{
+ private val TAG = toString()
+ private val statusCheckUrl = "$executeUrl/v1/props"
+ private val statusSetUrl = "$executeUrl/v1/params/camera"
+ private val grCommandUrl = "$executeUrl/_gr"
+ private val timeoutMs = 5000
+ private var whileFetching = false
+ private var statusHolder: RicohGr2StatusHolder? = null
+ private var useGR2command = false
+ private val httpClient = SimpleHttpClient()
+
+ fun setUseGR2Command(useGR2command: Boolean)
+ {
+ this.useGR2command = useGR2command
+ }
+
+ override fun startStatusWatch(indicator: IMessageDrawer?)
+ {
+ TODO("Not yet implemented")
+ }
+
+ /**
+ *
+ *
+ */
+ override fun startStatusWatch(notifier: ICameraStatusUpdateNotify) {
+ Log.v(TAG, "startStatusWatch()")
+ try {
+ statusHolder = RicohGr2StatusHolder(notifier)
+ val thread = Thread {
+ try {
+ start(statusCheckUrl)
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
+ }
+ thread.start()
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
+ }
+
+ /**
+ *
+ *
+ */
+ override fun stopStatusWatch() {
+ Log.v(TAG, "stoptStatusWatch()")
+ whileFetching = false
+ }
+
+ /**
+ *
+ *
+ */
+ private fun start(watchUrl: String) {
+ if (whileFetching) {
+ Log.v(TAG, "start() already starting.")
+ return
+ }
+ try {
+ whileFetching = true
+ val thread = Thread {
+ Log.d(TAG, "Start status watch.")
+ while (whileFetching) {
+ try {
+ statusHolder!!.updateStatus(httpClient.httpGet(watchUrl, timeoutMs))
+ Thread.sleep(sleepMs.toLong())
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
+ }
+ Log.v(TAG, "STATUS WATCH STOPPED.")
+ }
+ thread.start()
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
+ }
+
+ override fun getStatusList(key: String): List<String> {
+ try {
+ if (statusHolder == null) {
+ return ArrayList()
+ }
+ val listKey = key + "List"
+ return statusHolder!!.getAvailableItemList(listKey)
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
+ return ArrayList()
+ }
+
+ override fun getStatus(key: String): String {
+ try {
+ return if (statusHolder == null) {
+ ""
+ } else statusHolder!!.getItemStatus(key)
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
+ return ""
+ }
+
+ override fun setStatus(key: String, value: String) {
+ val thread = Thread {
+ try {
+ var response: String?
+ var postData = "$key=$value"
+ if (useGR2command && key == "exposureMode") {
+ // 撮影モードを変更するときは、GR専用コマンドを送ることにする。
+ postData = "cmd=" + decideButtonCode(value)
+ response = httpClient.httpPost(grCommandUrl, postData, timeoutMs)
+ Log.v(
+ TAG,
+ "CHANGE MODE : " + postData + " resp. (" + response?.length + "bytes.)"
+ )
+ } else {
+ // 通常の変更コマンド
+ response = httpClient.httpPut(statusSetUrl, postData, timeoutMs)
+ Log.v(
+ TAG,
+ "SET PROPERTY : " + postData + " resp. (" + response?.length + "bytes.)"
+ )
+ }
+ if (useGR2command) {
+ // GR専用コマンドで、画面表示をリフレッシュ
+ response =
+ httpClient.httpPost(grCommandUrl, "cmd=mode refresh", timeoutMs)
+ Log.v(TAG, "refresh resp. (" + response?.length + "bytes.)")
+ }
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
+ }
+ try {
+ thread.start()
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
+ }
+
+ /**
+ * 撮影モードをGRのダイアルコマンドに変更する
+ *
+ */
+ private fun decideButtonCode(exposureMode: String?): String {
+ var buttonCode = "bdial AUTO"
+ if (exposureMode == null) {
+ return buttonCode
+ }
+ when (exposureMode) {
+ "movie" -> buttonCode = "bdial MOVIE"
+ "M" -> buttonCode = "bdial M"
+ "TAV" -> buttonCode = "bdial TAV"
+ "AV" -> buttonCode = "bdial AV"
+ "TV" -> buttonCode = "bdial TV"
+ "P" -> buttonCode = "bdial P"
+ "auto" -> buttonCode = "bdial AUTO"
+ }
+ return buttonCode
+ }
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.ricohpentax.status
+
+import android.util.Log
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraStatusUpdateNotify
+import org.json.JSONObject
+import java.util.*
+
+/**
+ *
+ *
+ */
+internal class RicohGr2StatusHolder(private val notifier: ICameraStatusUpdateNotify)
+{
+ private var latestResultObject: JSONObject? = null
+ private var focused = false
+ private var focusLocked = false
+ private var avStatus = ""
+ private var tvStatus = ""
+ private var xvStatus = ""
+ private var exposureModeStatus = ""
+ private var meteringModeStatus = ""
+ private var wbModeStatus = ""
+ private var batteryStatus = ""
+
+ /**
+ *
+ *
+ */
+ fun getAvailableItemList(key: String): List<String> {
+ val itemList: MutableList<String> = ArrayList()
+ try {
+ val array = latestResultObject!!.getJSONArray(key) ?: return itemList
+ val nofItems = array.length()
+ for (index in 0 until nofItems) {
+ try {
+ itemList.add(array.getString(index))
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
+ }
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
+ return itemList
+ }
+
+ fun getItemStatus(key: String): String {
+ try {
+ return latestResultObject!!.getString(key)
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
+ return ""
+ }
+
+ private fun getStatusString(obj: JSONObject, name: String): String {
+ try {
+ return obj.getString(name)
+ } catch (e: Exception) {
+ //e.printStackTrace();
+ }
+ return ""
+ }
+
+ private fun getBooleanStatus(obj: JSONObject, name: String): Boolean {
+ try {
+ return obj.getBoolean(name)
+ } catch (e: Exception) {
+ //e.printStackTrace();
+ }
+ return false
+ }
+
+ /**
+ *
+ *
+ */
+ fun updateStatus(replyString: String?) {
+ if (replyString == null || replyString.length < 1) {
+ Log.v(TAG, "httpGet() reply is null. ")
+ return
+ }
+ 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")
+ if (result.contains("OK")) {
+ if (avStatus != av) {
+ avStatus = av
+ notifier.updatedAperture(avStatus)
+ }
+ if (tvStatus != tv) {
+ tvStatus = tv
+ notifier.updatedShutterSpeed(tvStatus)
+ }
+ if (xvStatus != xv) {
+ xvStatus = xv
+ notifier.updatedExposureCompensation(xvStatus)
+ }
+ if (exposureModeStatus != exposureMode) {
+ exposureModeStatus = exposureMode
+ notifier.updatedTakeMode(exposureModeStatus)
+ }
+ if (meteringModeStatus != meteringMode) {
+ meteringModeStatus = meteringMode
+ notifier.updatedMeteringMode(meteringModeStatus)
+ }
+ if (wbModeStatus != wbMode) {
+ wbModeStatus = wbMode
+ notifier.updatedWBMode(wbModeStatus)
+ }
+ if (batteryStatus != battery) {
+ batteryStatus = battery
+ notifier.updateRemainBattery(batteryStatus.toInt())
+ }
+ if (focus != focused || focusLock != focusLocked) {
+ focused = focus
+ focusLocked = focusLock
+ notifier.updateFocusedStatus(focused, focusLocked)
+ }
+ }
+ System.gc()
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
+ }
+
+ /**
+ *
+ *
+ */
+ companion object
+ {
+ private val TAG = RicohGr2StatusHolder::class.java.simpleName
+ }
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.ricohpentax.wrapper
+
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraRunMode
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraRunModeCallback
+
+class RicohGr2RunMode : ICameraRunMode
+{
+ private var recordingMode = true
+ override fun changeRunMode(isRecording: Boolean, callback: ICameraRunModeCallback)
+ {
+ // モードレスなので、絶対成功する
+ recordingMode = isRecording
+ callback.onCompleted(isRecording)
+ }
+
+ override fun isRecordingMode(): Boolean
+ {
+ return recordingMode
+ }
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.ricohpentax.wrapper.playback
+
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.playback.ICameraFileInfo
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.playback.ICameraFileInfoSetter
+import java.text.SimpleDateFormat
+import java.util.*
+
+
+class CameraFileInfo(private val path: String, private val name: String) : ICameraFileInfo, ICameraFileInfoSetter
+{
+ private var dateTime : Date? = Date()
+ private var captured = false
+ private var av: String? = null
+ private var sv: String? = null
+ private var tv: String? = null
+ private var xv: String? = null
+ private var orientation = 0
+ private var aspectRatio: String? = null
+ private var cameraModel: String? = null
+ private var latlng: String? = null
+ private val fileSize: Long = 0
+
+ override fun getDatetime(): Date?
+ {
+ return (dateTime)
+ }
+
+ override fun getDirectoryPath(): String
+ {
+ return (path)
+ }
+
+ override fun getFilename(): String
+ {
+ return (name)
+ }
+
+ override fun getOriginalFilename(): String
+ {
+ return (name)
+ }
+
+ override fun getAperature(): String?
+ {
+ return (av)
+ }
+
+ override fun getShutterSpeed(): String?
+ {
+ return (sv)
+ }
+
+ override fun getIsoSensitivity(): String? {
+ TODO("Not yet implemented")
+ }
+
+ override fun getExpRev(): String? {
+ TODO("Not yet implemented")
+ }
+
+ override fun getOrientation(): Int {
+ TODO("Not yet implemented")
+ }
+
+ override fun getAspectRatio(): String? {
+ TODO("Not yet implemented")
+ }
+
+ override fun getModel(): String? {
+ TODO("Not yet implemented")
+ }
+
+ override fun getLatLng(): String? {
+ TODO("Not yet implemented")
+ }
+
+ override fun getCaptured(): Boolean {
+ TODO("Not yet implemented")
+ }
+
+
+ override fun updateValues(
+ dateTime: String,
+ av: String,
+ tv: String,
+ sv: String,
+ xv: String,
+ orientation: Int,
+ aspectRatio: String,
+ model: String,
+ latLng: String,
+ captured: Boolean
+ )
+ {
+ this.av = av
+ this.tv = tv
+ this.sv = sv
+ this.xv = xv
+ this.orientation = orientation
+ this.aspectRatio = aspectRatio
+ cameraModel = model
+ latlng = latLng
+ this.captured = captured
+ try
+ {
+ val df = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.US)
+ this.dateTime = df.parse(dateTime)
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ }
+
+ override fun setDate(datetime: Date)
+ {
+ dateTime = datetime
+ }
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.ricohpentax.wrapper.playback
+
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.playback.IProgressEvent
+
+class ProgressEvent(private val percent: Float, private val callback: CancelCallback?) : IProgressEvent
+{
+ override val progress: Float
+ get() = percent
+ override val isCancellable: Boolean
+ get() = callback != null
+
+ override fun requestCancellation() {
+ callback?.requestCancellation()
+ }
+
+ interface CancelCallback {
+ fun requestCancellation()
+ }
+}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.camera.ricohpentax.wrapper.playback
+
+import android.graphics.Bitmap
+import android.util.Log
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.playback.*
+import jp.osdn.gokigen.gokigenassets.utils.communication.SimpleHttpClient
+import org.json.JSONObject
+import java.util.*
+
+/**
+ *
+ *
+ */
+class RicohGr2PlaybackControl internal constructor(timeoutMSec: Int, executeUrl : String = "http://192.168.0.1") : IPlaybackControl
+{
+ private val TAG = toString()
+ private val getPhotoUrl = "$executeUrl/v1/photos/"
+ private val timeoutValue: Int
+ private val httpClient = SimpleHttpClient()
+
+ override fun getRawFileSuffix() : String
+ {
+ return ".DNG"
+ }
+
+ override fun downloadContentList(callback: ICameraContentListCallback) {
+ val fileList: MutableList<ICameraFileInfo> = ArrayList<ICameraFileInfo>()
+ val imageListUrl = "http://192.168.0.1/v1/photos?limit=3000"
+ val contentList: String?
+ try {
+ contentList = httpClient.httpGet(imageListUrl, timeoutValue)
+ if (contentList == null) {
+ // ぬるぽ発行
+ callback.onErrorOccurred(NullPointerException())
+ return
+ }
+ } catch (e: Exception) {
+ // 例外をそのまま転送
+ callback.onErrorOccurred(e)
+ return
+ }
+ try {
+ val dirsArray = JSONObject(contentList).getJSONArray("dirs")
+ // if (dirsArray != null)
+ run {
+ val size = dirsArray.length()
+ for (index in 0 until size) {
+ val `object` = dirsArray.getJSONObject(index)
+ val dirName = `object`.getString("name")
+ val filesArray = `object`.getJSONArray("files")
+ val nofFiles = filesArray.length()
+ for (fileIndex in 0 until nofFiles) {
+ val fileName = filesArray.getString(fileIndex)
+ fileList.add(CameraFileInfo(dirName, fileName))
+ }
+ }
+ }
+ } catch (e: Exception) {
+ callback.onErrorOccurred(e)
+ return
+ }
+ callback.onCompleted(fileList)
+ }
+
+ override fun updateCameraFileInfo(info: ICameraFileInfo?)
+ {
+ val url = getPhotoUrl + info?.getDirectoryPath().toString() + "/" + info?.getFilename()
+ .toString() + "/info"
+ Log.v(TAG, "updateCameraFileInfo() GET URL : $url")
+ try {
+ val response = httpClient.httpGet(url, timeoutValue)
+ if (response.length < 1)
+ {
+ return
+ }
+ val `object` = JSONObject(response)
+
+ // データを突っ込む
+ val captured = `object`.getBoolean("captured")
+ val av = getJSONString(`object`, "av")
+ val tv = getJSONString(`object`, "tv")
+ val sv = getJSONString(`object`, "sv")
+ val xv = getJSONString(`object`, "xv")
+ val orientation = `object`.getInt("orientation")
+ val aspectRatio = getJSONString(`object`, "aspectRatio")
+ val cameraModel = getJSONString(`object`, "cameraModel")
+ val latLng = getJSONString(`object`, "latlng")
+ val dateTime = `object`.getString("datetime")
+ info?.updateValues(
+ dateTime,
+ av,
+ tv,
+ sv,
+ xv,
+ orientation,
+ aspectRatio,
+ cameraModel,
+ latLng,
+ captured
+ )
+ } catch (e: Throwable) {
+ e.printStackTrace()
+ }
+ }
+
+ private fun getJSONString(`object`: JSONObject, key: String): String {
+ var value = ""
+ try {
+ value = `object`.getString(key)
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
+ return value
+ }
+
+ override fun getContentInfo(path: String?, name: String, callback: IContentInfoCallback) {
+ val url = "$getPhotoUrl$name/info"
+ Log.v(TAG, "getContentInfo() GET URL : $url")
+ try {
+ val response: String = httpClient.httpGet(url, timeoutValue)
+ if (response == null || response.length < 1) {
+ callback.onErrorOccurred(NullPointerException())
+ }
+ } catch (e: Throwable) {
+ e.printStackTrace()
+ }
+ }
+
+
+ override fun downloadContentScreennail(
+ path: String?,
+ name: String,
+ callback: IDownloadThumbnailImageCallback
+ ) {
+ //Log.v(TAG, "downloadContentScreennail() : " + path);
+ val suffix = "?size=view"
+ val url = getPhotoUrl + name + suffix
+ Log.v(TAG, "downloadContentScreennail() GET URL : $url")
+ try {
+ val bmp: Bitmap? = httpClient.httpGetBitmap(url, null, timeoutValue)
+ val map = HashMap<String?, Any?>()
+ map["Orientation"] = 0
+ callback.onCompleted(bmp, map)
+ } catch (e: Throwable) {
+ e.printStackTrace()
+ }
+ }
+
+ override fun downloadContentThumbnail(
+ path: String?,
+ name: String,
+ callback: IDownloadThumbnailImageCallback
+ ) {
+ //Log.v(TAG, "downloadContentThumbnail() : " + path);
+ var suffix = "?size=view"
+ if (name.contains(".JPG")) {
+ suffix = "?size=thumb"
+ }
+ val url = getPhotoUrl + name + suffix
+ Log.v(TAG, "downloadContentThumbnail() GET URL : $url")
+ try {
+ val bmp: Bitmap? = httpClient.httpGetBitmap(url, null, timeoutValue)
+ val map = HashMap<String?, Any?>()
+ map["Orientation"] = 0
+ callback.onCompleted(bmp, map)
+ } catch (e: Throwable) {
+ e.printStackTrace()
+ callback.onErrorOccurred(NullPointerException())
+ }
+ }
+
+ override fun downloadContent(
+ path: String?,
+ name: String,
+ isSmallSize: Boolean,
+ callback: IDownloadContentCallback
+ ) {
+ Log.v(TAG, "downloadContent() : $name")
+ var suffix = "?size=full"
+ if (isSmallSize) {
+ suffix = "?size=view"
+ }
+ val url = getPhotoUrl + name + suffix
+ Log.v(TAG, "downloadContent() GET URL : $url")
+ try {
+ httpClient.httpGetBytes(
+ url,
+ null,
+ timeoutValue,
+ object : SimpleHttpClient.IReceivedMessageCallback {
+ override fun onCompleted() {
+ callback.onCompleted()
+ }
+
+ override fun onErrorOccurred(e: Exception?)
+ {
+ callback.onErrorOccurred(e)
+ }
+
+ override fun onReceive(readBytes: Int, length: Int, size: Int, data: ByteArray?)
+ {
+ val percent =
+ if (length == 0) 0.0f else readBytes.toFloat() / length.toFloat()
+ val event = ProgressEvent(percent, null)
+ callback.onProgress(data, size, event)
+ }
+ })
+ } catch (e: Throwable) {
+ e.printStackTrace()
+ }
+ }
+
+ override fun showPictureStarted() {}
+ override fun showPictureFinished() {}
+
+ companion object {
+ private const val DEFAULT_TIMEOUT = 5000
+ }
+
+ /*****
+ * 操作メモ
+ * 画像の一覧をとる : http://192.168.0.1/v1/photos?limit=3000
+ * 画像の情報をとる : http://192.168.0.1/v1/photos/yyyRICOH/R0000xxx.DNG/info
+ * サムネール画像をとる(JPEG) : http://192.168.0.1/v1/photos/yyyRICOH/R0000xxx.JPG?size=thumb
+ * サムネール画像をとる(DNG) : http://192.168.0.1/v1/photos/yyyRICOH/R0000xxx.DNG?size=view
+ * サムネール画像をとる(MOV) : http://192.168.0.1/v1/photos/yyyRICOH/R0000xxx.MOV?size=view
+ * デバイス表示用画像をとる : http://192.168.0.1/v1/photos/yyyRICOH/R0000xxx.JPG?size=view
+ * 画像(JPEG)をダウンロードする : http://192.168.0.1/v1/photos/yyyRICOH/R0000xxx.JPG?size=full
+ * 画像(DNG)をダウンロードする : http://192.168.0.1/v1/photos/yyyRICOH/R0000xxx.DNG?size=full
+ * 動画をダウンロードする : http://192.168.0.1/v1/photos/yyyRICOH/R0000xxx.MOV?size=full
+ */
+ init {
+ timeoutValue = Math.max(
+ DEFAULT_TIMEOUT,
+ timeoutMSec
+ ) // (timeoutMSec < DEFAULT_TIMEOUT) ? DEFAULT_TIMEOUT : timeoutMSec;
+ }
+}
import jp.osdn.gokigen.gokigenassets.liveview.image.CameraLiveViewListenerImpl
import jp.osdn.gokigen.gokigenassets.liveview.message.IMessageDrawer
import jp.osdn.gokigen.gokigenassets.liveview.storeimage.StoreImage
-import jp.osdn.gokigen.gokigenassets.operation.ICameraControl
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraControl
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, ICameraControl, View.OnClickListener, ICaptureModeReceiver, ICameraShutter
+class ThetaCameraControl(private val context: AppCompatActivity, private val vibrator : IVibrator, statusReceiver : ICameraStatusReceiver) : ILiveViewController,
+ ICameraControl, View.OnClickListener, ICaptureModeReceiver, ICameraShutter
{
private val sessionIdHolder = ThetaSessionHolder()
private val cameraConnection = ThetaCameraConnection(context, statusReceiver, sessionIdHolder, sessionIdHolder, this)
import android.graphics.Color
import android.util.Log
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraStatusUpdateNotify
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraStatusWatcher
import jp.osdn.gokigen.gokigenassets.liveview.message.IMessageDrawer
import jp.osdn.gokigen.gokigenassets.utils.communication.SimpleHttpClient
import org.json.JSONObject
}
}
+ override fun startStatusWatch(notifier: ICameraStatusUpdateNotify)
+ {
+ startStatusWatch(null)
+ }
+
private fun checkStatus0(response: String)
{
try
import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.CAPTURE_ONLY_EXTERNAL_CAMERA_DEFAULT_VALUE
import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.EXTERNAL_STORAGE_LOCATION
import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.EXTERNAL_STORAGE_LOCATION_DEFAULT_VALUE
+import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.GR2_LCD_SLEEP
import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.LABEL_DEBUG_INFO
import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.LABEL_EXIT_APPLICATION
import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.LABEL_WIFI_SETTINGS
import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor.Companion.NUMBER_OF_CACHE_PICTURES_DEFAULT_VALUE
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_LAYOUT_CAMERA_CAPTURE = R.layout.camera_capture
const val ID_LAYOUT_PREFERENCE = R.xml.preference_main
+ const val ID_DIALOG_TITLE_CONFIRMATION = R.string.dialog_title_confirmation
+ const val ID_DIALOG_EXIT_APPLICATION = R.string.dialog_message_exit_application
+ const val ID_DIALOG_EXIT_POWER_OFF = R.string.dialog_message_power_off
+
const val ID_DIALOG_BUTTON_LABEL_POSITIVE = R.string.dialog_positive_execute
const val ID_DIALOG_BUTTON_LABEL_NEGATIVE = R.string.dialog_negative_cancel
const val ID_LABEL_TITLE_CONFIRMATION_FOR_EXPORT_LOG = R.string.dialog_confirm_title_output_log
const val ID_LABEL_MESSAGE_CONFIRMATION_FOR_EXPORT_LOG = R.string.dialog_confirm_message_output_log
-
const val ID_PREFERENCE_LABEL_EXIT_APPLICATION = LABEL_EXIT_APPLICATION
const val ID_PREFERENCE_LABEL_WIFI_SETTINGS = LABEL_WIFI_SETTINGS
const val ID_PREFERENCE_LABEL_DEBUG_INFO = LABEL_DEBUG_INFO
const val ID_PREFERENCE_NUMBER_OF_CACHE_PICTURES = NUMBER_OF_CACHE_PICTURES
const val ID_PREFERENCE_NUMBER_OF_CACHE_PICTURES_DEFAULT_VALUE = NUMBER_OF_CACHE_PICTURES_DEFAULT_VALUE
+ const val ID_PREFERENCE_RICOH_GR2_LCD_SLEEP = GR2_LCD_SLEEP
+ const val ID_PREFERENCE_USE_GR2_SPECIAL_COMMAND = USE_GR2_SPECIAL_COMMAND
+
}
}
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.liveview
+
+interface IIndicatorControl
+{
+ // 撮影状態の記録
+ enum class shootingStatus {
+ Unknown, Starting, Stopping
+ }
+
+ fun onAfLockUpdate(isAfLocked: Boolean)
+ fun onShootingStatusUpdate(status: shootingStatus?)
+ fun onMovieStatusUpdate(status: shootingStatus?)
+ fun onBracketingStatusUpdate(message: String?)
+}
import jp.osdn.gokigen.gokigenassets.constants.IApplicationConstantConvert.Companion.ID_VIEW_FINDER_3
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.operation.ICameraControl
+import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraControl
class LiveImageViewFragment(private val contentLayoutId: Int = ID_LIVE_VIEW_LAYOUT_DEFAULT) : Fragment(contentLayoutId), View.OnClickListener
{
import android.graphics.*
import android.util.DisplayMetrics
import android.util.TypedValue
+import android.view.MotionEvent
-class FocusFrameDrawer(private val context : Context): IFocusFrameDrawer, IFocusFrameControl
+class FocusFrameDrawer(private val context : Context): IFocusFrameDrawer, IAutoFocusFrameDisplay
{
override fun drawFocusFrame(canvas: Canvas)
{
*/
}
- override fun showFocusFrame(rect : RectF, status : IFocusFrameControl.FocusFrameStatus, duration : Float)
+ override fun getContentSizeWidth(): Float {
+ TODO("Not yet implemented")
+ }
+
+ override fun getContentSizeHeight(): Float {
+ TODO("Not yet implemented")
+ }
+
+ override fun getPointWithEvent(event: MotionEvent?): PointF? {
+ TODO("Not yet implemented")
+ }
+
+ override fun isContainsPoint(point: PointF?): Boolean {
+ TODO("Not yet implemented")
+ }
+
+ override fun showFocusFrame(rect : RectF?, status : IAutoFocusFrameDisplay.FocusFrameStatus?, duration : Float)
{
}
private fun convertPointFromImageArea(point: PointF, imageBitmap : Bitmap, imageRotationDegrees : Int): PointF
{
- var viewPointX = point.x
- var viewPointY = point.y
+ val viewPointX = point.x
+ val viewPointY = point.y
/*
val imageSizeWidth: Float
val imageSizeHeight: Float
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.liveview.focusframe
+
+import android.graphics.PointF
+import android.graphics.RectF
+import android.view.MotionEvent
+
+
+interface IAutoFocusFrameDisplay
+{
+ // フォーカスフレームの状態
+ enum class FocusFrameStatus {
+ Running, Focused, Failed, Errored
+ }
+
+ fun getContentSizeWidth(): Float
+ fun getContentSizeHeight(): Float
+
+ fun getPointWithEvent(event: MotionEvent?): PointF?
+ fun isContainsPoint(point: PointF?): Boolean
+
+ fun showFocusFrame(rect: RectF?, status: FocusFrameStatus?, duration: Float)
+ fun hideFocusFrame()
+}
+++ /dev/null
-package jp.osdn.gokigen.gokigenassets.liveview.focusframe
-
-import android.graphics.RectF
-
-interface IFocusFrameControl
-{
- enum class FocusFrameStatus
- {
- Running, Focused, Failed, Errored
- }
-
- fun showFocusFrame(rect : RectF, status : FocusFrameStatus, duration : Float)
- fun hideFocusFrame()
-}
+++ /dev/null
-package jp.osdn.gokigen.gokigenassets.operation.imagefile
-
-
-interface IImageStoreGrant
-{
- fun grantStoreImage()
-}
\ No newline at end of file
import android.content.Intent
import android.net.Uri
-import jp.osdn.gokigen.gokigenassets.operation.imagefile.IImageStoreGrant
+import jp.osdn.gokigen.gokigenassets.utils.imagefile.IImageStoreGrant
interface IScopedStorageAccessPermission
{
-package jp.osdn.gokigen.gokigenassets.operation.imagefile
+package jp.osdn.gokigen.gokigenassets.utils.imagefile
import android.os.Build
import android.util.Log
-package jp.osdn.gokigen.gokigenassets.operation.imagefile
+package jp.osdn.gokigen.gokigenassets.utils.imagefile
import androidx.camera.core.ImageCapture
--- /dev/null
+package jp.osdn.gokigen.gokigenassets.utils.imagefile
+
+
+interface IImageStoreGrant
+{
+ fun grantStoreImage()
+}
\ No newline at end of file
-package jp.osdn.gokigen.gokigenassets.operation.imagefile
+package jp.osdn.gokigen.gokigenassets.utils.imagefile
import android.content.ContentValues
import android.database.DatabaseUtils
-package jp.osdn.gokigen.gokigenassets.operation.imagefile
+package jp.osdn.gokigen.gokigenassets.utils.imagefile
import android.content.ContentValues
import android.os.Environment
-package jp.osdn.gokigen.gokigenassets.operation.imagefile
+package jp.osdn.gokigen.gokigenassets.utils.imagefile
import android.net.Uri
import android.os.Environment
import android.util.Log
import androidx.annotation.RequiresApi
import androidx.appcompat.app.AppCompatActivity
-import jp.osdn.gokigen.gokigenassets.operation.imagefile.IImageStoreGrant
+import jp.osdn.gokigen.gokigenassets.utils.imagefile.IImageStoreGrant
import jp.osdn.gokigen.gokigenassets.preference.PreferenceAccessWrapper
import jp.osdn.gokigen.gokigenassets.utils.IScopedStorageAccessPermission
import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor
const val CAPTURE_ONLY_EXTERNAL_CAMERA = "capture_only_external_camera"
const val CAPTURE_ONLY_EXTERNAL_CAMERA_DEFAULT_VALUE = false
-
// --- SCREEN TRANSACTION LABEL ---
const val LABEL_EXIT_APPLICATION = "exit_application"
const val LABEL_WIFI_SETTINGS = "wifi_settings"
const val THETA_LIVEVIEW_RESOLUTION = "theta_liveview_resolution"
const val THETA_LIVEVIEW_RESOLUTION_DEFAULT_VALUE = "{\"width\": 640, \"height\": 320, \"framerate\": 30}"
+
+ // --- RICOH/PENTAX
+ const val GR2_LCD_SLEEP = "gr2_lcd_sleep"
+ const val USE_GR2_SPECIAL_COMMAND = "use_gr2_command"
+
}
}
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.operation.CameraControl
+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.preview.PreviewFragment
+import jp.osdn.gokigen.gokigenassets.camera.camerax.preview.PreviewFragment
import jp.osdn.gokigen.gokigenassets.scene.IChangeSceneBasic
import jp.osdn.gokigen.gokigenassets.scene.IInformationReceiver
import jp.osdn.gokigen.gokigenassets.scene.IVibrator
<string name="dialog_button_retry">再試行</string>
<string name="dialog_button_network_settings">WiFi設定</string>
+ <string name="dialog_title_confirmation">確認</string>
+ <string name="dialog_message_power_off">カメラの電源を切り、アプリケーションを終了します。</string>
+ <string name="dialog_message_exit">アプリケーションを終了します。</string>
+
</resources>
<string name="dialog_button_retry">Retry</string>
<string name="dialog_button_network_settings">WiFi Settings</string>
+ <string name="dialog_title_confirmation">Confirmation</string>
+ <string name="dialog_message_power_off">Power Off</string>
+ <string name="dialog_message_exit">Exit Application</string>
</resources>
\ No newline at end of file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
- ext.kotlin_version = "1.4.32"
+ ext.kotlin_version = "1.4.31"
repositories {
google()
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:4.1.3'
+ classpath 'com.android.tools.build:gradle:4.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip