OSDN Git Service

Kodak PIXPRO WPZ2 対応の準備。(LVがまだ)
[gokigen/A01d.git] / app / src / main / java / net / osdn / gokigen / a01d / liveview / LiveViewClickTouchListener.java
index 5fd361f..fb37502 100644 (file)
@@ -2,8 +2,8 @@ package net.osdn.gokigen.a01d.liveview;
 
 import android.content.Context;
 import android.content.SharedPreferences;
-import android.support.v7.preference.PreferenceManager;
 import android.util.Log;
+import android.view.KeyEvent;
 import android.view.MotionEvent;
 import android.view.View;
 import android.widget.Toast;
@@ -18,13 +18,16 @@ import net.osdn.gokigen.a01d.camera.ICameraConnection;
 import net.osdn.gokigen.a01d.camera.IZoomLensControl;
 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.olympus.IPreferencePropertyAccessor;
+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;
@@ -37,10 +40,10 @@ class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchLi
     private final IOlyCameraPropertyProvider propertyProvider;
     private final ICameraInformation cameraInformation;
     private final ICameraConnection cameraConnection;
-    private final IFavoriteSettingDialogKicker dialogKicker;
+    private final IDialogKicker dialogKicker;
     private final IZoomLensControl zoomLensControl;
 
-    LiveViewClickTouchListener(Context context, ILiveImageStatusNotify imageStatusNotify, IStatusViewDrawer statusView, IChangeScene changeScene, IInterfaceProvider interfaceProvider, IFavoriteSettingDialogKicker dialogKicker)
+    LiveViewClickTouchListener(Context context, ILiveImageStatusNotify imageStatusNotify, IStatusViewDrawer statusView, IChangeScene changeScene, IInterfaceProvider interfaceProvider, IDialogKicker dialogKicker)
     {
         this.context = context;
         this.statusNotify = imageStatusNotify;
@@ -48,16 +51,17 @@ class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchLi
         this.changeScene = changeScene;
         this.interfaceProvider = interfaceProvider;
 
-        if (interfaceProvider.useOlympusCamera())
+        ICameraConnection.CameraConnectionMethod connectionMethod = interfaceProvider.getCammeraConnectionMethod();
+        if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
         {
-            this.focusingControl = interfaceProvider.getOlympusInterface().getFocusingControl();
-            this.captureControl = interfaceProvider.getOlympusInterface().getCaptureControl();
-            this.propertyProvider = interfaceProvider.getOlympusInterface().getCameraPropertyProvider();
-            this.cameraInformation = interfaceProvider.getOlympusInterface().getCameraInformation();
-            this.cameraConnection = interfaceProvider.getOlympusInterface().getOlyCameraConnection();
-            this.zoomLensControl = interfaceProvider.getOlympusInterface().getZoomLensControl();
+            this.focusingControl = interfaceProvider.getRicohGr2Infterface().getFocusingControl();
+            this.captureControl = interfaceProvider.getRicohGr2Infterface().getCaptureControl();
+            this.propertyProvider = interfaceProvider.getOlympusInterface().getCameraPropertyProvider();  // 要変更
+            this.cameraInformation = interfaceProvider.getRicohGr2Infterface().getCameraInformation();
+            this.cameraConnection = interfaceProvider.getRicohGr2Infterface().getRicohGr2CameraConnection();
+            this.zoomLensControl = interfaceProvider.getRicohGr2Infterface().getZoomLensControl();
         }
-        else
+        else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
         {
             this.focusingControl = interfaceProvider.getSonyInterface().getFocusingControl();
             this.captureControl = interfaceProvider.getSonyInterface().getCaptureControl();
@@ -66,6 +70,79 @@ class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchLi
             this.cameraConnection = interfaceProvider.getSonyInterface().getSonyCameraConnection();
             this.zoomLensControl = interfaceProvider.getSonyInterface().getZoomLensControl();
         }
+        else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
+        {
+            this.focusingControl = interfaceProvider.getFujiXInterface().getFocusingControl();
+            this.captureControl = interfaceProvider.getFujiXInterface().getCaptureControl();
+            this.cameraInformation = interfaceProvider.getFujiXInterface().getCameraInformation();
+            this.propertyProvider = interfaceProvider.getOlympusInterface().getCameraPropertyProvider();  // 要変更
+            this.cameraConnection = interfaceProvider.getFujiXInterface().getFujiXCameraConnection();
+            this.zoomLensControl = interfaceProvider.getFujiXInterface().getZoomLensControl();
+        }
+        else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
+        {
+            this.focusingControl = interfaceProvider.getPanasonicInterface().getFocusingControl();
+            this.captureControl = interfaceProvider.getPanasonicInterface().getCaptureControl();
+            this.propertyProvider = interfaceProvider.getOlympusInterface().getCameraPropertyProvider();  // 要変更
+            this.cameraInformation = interfaceProvider.getPanasonicInterface().getCameraInformation();
+            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();
+            this.captureControl = interfaceProvider.getOlympusInterface().getCaptureControl();
+            this.propertyProvider = interfaceProvider.getOlympusInterface().getCameraPropertyProvider();
+            this.cameraInformation = interfaceProvider.getOlympusInterface().getCameraInformation();
+            this.cameraConnection = interfaceProvider.getOlympusInterface().getOlyCameraConnection();
+            this.zoomLensControl = interfaceProvider.getOlympusInterface().getZoomLensControl();
+        }
+
         this.dialogKicker = dialogKicker;
     }
 
@@ -132,6 +209,11 @@ class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchLi
                     actionZoomout();
                     break;
 
+                case R.id.focus_indicator:
+                    // フォーカスインジケータをクリックした
+                    actionFocusButton();
+                    break;
+
                 default:
                     Log.v(TAG, "onClick() : " + id);
                     break;
@@ -190,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();
             }
         }
@@ -235,6 +320,28 @@ class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchLi
     }
 
     /**
+     *   フォーカスボタンが押されたとき...
+     *
+     */
+    private void actionFocusButton()
+    {
+        try
+        {
+            // シャッターを半押しする
+            if (focusingControl != null)
+            {
+                boolean isHalfPress = !statusViewDrawer.isFocusLocked();
+                focusingControl.halfPressShutter(isHalfPress);
+                Log.v(TAG, " actionFocusButton() : isHalfPress " + isHalfPress);
+            }
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    /**
      *   お気に入り設定ダイアログの表示
      *
      */
@@ -243,7 +350,16 @@ class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchLi
         Log.v(TAG, "showFavoriteDialog()");
         try
         {
-            if (!interfaceProvider.useOlympusCamera())
+            if (interfaceProvider.getCammeraConnectionMethod() == ICameraConnection.CameraConnectionMethod.FUJI_X)
+            {
+                // FUJI X Seriesの場合は、カメラ状態を表示するダイアログを表示する
+                if (cameraConnection.getConnectionStatus() == ICameraConnection.CameraConnectionStatus.CONNECTED)
+                {
+                    dialogKicker.showCameraStatusDialog();
+                }
+                return;
+            }
+            else if (interfaceProvider.getCammeraConnectionMethod() != ICameraConnection.CameraConnectionMethod.OPC)
             {
                 // OPCカメラでない場合には、「OPCカメラのみ有効です」表示をして画面遷移させない
                 Toast.makeText(context, context.getText(R.string.only_opc_feature), Toast.LENGTH_SHORT).show();
@@ -279,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);
+    }
 }