OSDN Git Service

Kodak PIXPRO WPZ2 対応の準備。(LVがまだ)
[gokigen/A01d.git] / app / src / main / java / net / osdn / gokigen / a01d / liveview / LiveViewClickTouchListener.java
index dee5334..fb37502 100644 (file)
@@ -3,6 +3,7 @@ package net.osdn.gokigen.a01d.liveview;
 import android.content.Context;
 import android.content.SharedPreferences;
 import android.util.Log;
+import android.view.KeyEvent;
 import android.view.MotionEvent;
 import android.view.View;
 import android.widget.Toast;
@@ -19,13 +20,14 @@ import net.osdn.gokigen.a01d.camera.olympus.wrapper.property.IOlyCameraProperty;
 import net.osdn.gokigen.a01d.camera.olympus.wrapper.property.IOlyCameraPropertyProvider;
 import net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor;
 
+import androidx.annotation.NonNull;
 import androidx.preference.PreferenceManager;
 
 /**
  *
  *
  */
-class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchListener
+class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchListener, View.OnKeyListener
 {
     private final String TAG = toString();
     private final Context context;
@@ -86,6 +88,51 @@ class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchLi
             this.cameraConnection = interfaceProvider.getPanasonicInterface().getPanasonicCameraConnection();
             this.zoomLensControl = interfaceProvider.getPanasonicInterface().getZoomLensControl();
         }
+        else if (connectionMethod == ICameraConnection.CameraConnectionMethod.OLYMPUS)
+        {
+            this.focusingControl = interfaceProvider.getOlympusPenInterface().getFocusingControl();
+            this.captureControl = interfaceProvider.getOlympusPenInterface().getCaptureControl();
+            this.propertyProvider = interfaceProvider.getOlympusPenInterface().getCameraPropertyProvider();
+            this.cameraInformation = interfaceProvider.getOlympusPenInterface().getCameraInformation();
+            this.cameraConnection = interfaceProvider.getOlympusPenInterface().getOlyCameraConnection();
+            this.zoomLensControl = interfaceProvider.getOlympusPenInterface().getZoomLensControl();
+        }
+        else if (connectionMethod == ICameraConnection.CameraConnectionMethod.THETA)
+        {
+            this.focusingControl = interfaceProvider.getThetaInterface().getFocusingControl();
+            this.captureControl = interfaceProvider.getThetaInterface().getCaptureControl();
+            this.propertyProvider = interfaceProvider.getOlympusInterface().getCameraPropertyProvider();  // 要変更
+            this.cameraInformation = interfaceProvider.getThetaInterface().getCameraInformation();
+            this.cameraConnection = interfaceProvider.getThetaInterface().getCameraConnection();
+            this.zoomLensControl = interfaceProvider.getThetaInterface().getZoomLensControl();
+        }
+        else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
+        {
+            this.focusingControl = interfaceProvider.getCanonInterface().getFocusingControl();
+            this.captureControl = interfaceProvider.getCanonInterface().getCaptureControl();
+            this.propertyProvider = interfaceProvider.getOlympusInterface().getCameraPropertyProvider();  // 要変更
+            this.cameraInformation = interfaceProvider.getCanonInterface().getCameraInformation();
+            this.cameraConnection = interfaceProvider.getCanonInterface().getCameraConnection();
+            this.zoomLensControl = interfaceProvider.getCanonInterface().getZoomLensControl();
+        }
+        else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON)
+        {
+            this.focusingControl = interfaceProvider.getNikonInterface().getFocusingControl();
+            this.captureControl = interfaceProvider.getNikonInterface().getCaptureControl();
+            this.propertyProvider = interfaceProvider.getOlympusInterface().getCameraPropertyProvider();  // 要変更
+            this.cameraInformation = interfaceProvider.getNikonInterface().getCameraInformation();
+            this.cameraConnection = interfaceProvider.getNikonInterface().getCameraConnection();
+            this.zoomLensControl = interfaceProvider.getNikonInterface().getZoomLensControl();
+        }
+        else if (connectionMethod == ICameraConnection.CameraConnectionMethod.KODAK)
+        {
+            this.focusingControl = interfaceProvider.getKodakInterface().getFocusingControl();
+            this.captureControl = interfaceProvider.getKodakInterface().getCaptureControl();
+            this.propertyProvider = interfaceProvider.getOlympusInterface().getCameraPropertyProvider();  // 要変更
+            this.cameraInformation = interfaceProvider.getKodakInterface().getCameraInformation();
+            this.cameraConnection = interfaceProvider.getKodakInterface().getCameraConnection();
+            this.zoomLensControl = interfaceProvider.getKodakInterface().getZoomLensControl();
+        }
         else  // if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
         {
             this.focusingControl = interfaceProvider.getOlympusInterface().getFocusingControl();
@@ -225,13 +272,16 @@ class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchLi
         Log.v(TAG, "pushedShutterButton()");
         try
         {
-            // カメラで撮影する
-            captureControl.doCapture(0);
-
             SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
+
+            if (!preferences.getBoolean(IPreferencePropertyAccessor.CAPTURE_ONLY_LIVE_VIEW, false))
+            {
+                // カメラで撮影する
+                captureControl.doCapture(0);
+            }
             if (preferences.getBoolean(IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW, true))
             {
-                // ã\83©ã\82¤ã\83\96ã\83\93ã\83¥ã\83¼ç\94»å\83\8fã\82\82保管する
+                // ã\83©ã\82¤ã\83\96ã\83\93ã\83¥ã\83¼ç\94»å\83\8fã\82\92保管する
                 statusNotify.takePicture();
             }
         }
@@ -345,4 +395,27 @@ class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchLi
         return ((id == R.id.cameraLiveImageView)&&(focusingControl.driveAutoFocus(motionEvent)));
     }
 
+    /**
+     *   ボタンを押したときの対応
+     *
+     */
+    @Override
+    public boolean onKey(View view, int keyCode, @NonNull KeyEvent keyEvent)
+    {
+        Log.v(TAG, "onKey() : " + keyCode);
+        try
+        {
+            if ((keyEvent.getAction() == KeyEvent.ACTION_DOWN)&&
+                    ((keyCode == KeyEvent.KEYCODE_VOLUME_UP)||(keyCode == KeyEvent.KEYCODE_CAMERA)))
+            {
+                pushedShutterButton();
+                return (true);
+            }
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+        return (false);
+    }
 }