OSDN Git Service

Theta用のコードを有効化。(まだ動かしていない。)
authorMRSa <mrsa@myad.jp>
Fri, 24 Jan 2020 16:47:58 +0000 (01:47 +0900)
committerMRSa <mrsa@myad.jp>
Fri, 24 Jan 2020 16:47:58 +0000 (01:47 +0900)
12 files changed:
app/src/main/java/net/osdn/gokigen/a01d/A01dMain.java
app/src/main/java/net/osdn/gokigen/a01d/camera/CameraInterfaceProvider.java
app/src/main/java/net/osdn/gokigen/a01d/camera/ICameraConnection.java
app/src/main/java/net/osdn/gokigen/a01d/camera/IInterfaceProvider.java
app/src/main/java/net/osdn/gokigen/a01d/camera/theta/operation/ThetaSingleShotControl.java [new file with mode: 0644]
app/src/main/java/net/osdn/gokigen/a01d/camera/theta/wrapper/ThetaCaptureControl.java
app/src/main/java/net/osdn/gokigen/a01d/camera/theta/wrapper/ThetaInterfaceProvider.java
app/src/main/java/net/osdn/gokigen/a01d/liveview/LiveViewClickTouchListener.java
app/src/main/java/net/osdn/gokigen/a01d/liveview/LiveViewFragment.java
app/src/main/java/net/osdn/gokigen/a01d/preference/theta/ThetaPreferenceFragment.java
app/src/main/res/values-ja/arrays.xml
app/src/main/res/values/arrays.xml

index 52ce47b..53bca82 100644 (file)
@@ -29,6 +29,7 @@ import net.osdn.gokigen.a01d.preference.panasonic.PanasonicPreferenceFragment;
 import net.osdn.gokigen.a01d.preference.olympuspen.OlympusPreferenceFragment;
 import net.osdn.gokigen.a01d.preference.ricohgr2.RicohGr2PreferenceFragment;
 import net.osdn.gokigen.a01d.preference.sony.SonyPreferenceFragment;
+import net.osdn.gokigen.a01d.preference.theta.ThetaPreferenceFragment;
 
 import androidx.annotation.NonNull;
 import androidx.appcompat.app.ActionBar;
@@ -286,6 +287,18 @@ public class A01dMain extends AppCompatActivity implements ICameraStatusReceiver
                     e.printStackTrace();
                 }
             }
+            else if (method == ICameraConnection.CameraConnectionMethod.THETA)
+            {
+                try
+                {
+                    // THETA の場合は、HTTPコマンド送信ダイアログを表示する
+                    SimpleHttpSendCommandDialog.newInstance("http://192.168.1.1/", null, null).show(getSupportFragmentManager(), "thetaSendCommandDialog");
+                }
+                catch (Exception e)
+                {
+                    e.printStackTrace();
+                }
+            }
             else
             {
                 // OPC カメラの場合...
@@ -337,6 +350,8 @@ public class A01dMain extends AppCompatActivity implements ICameraStatusReceiver
                         preferenceFragment = OlympusPreferenceFragment.newInstance(this, this);
                     } else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X) {
                         preferenceFragment = FujiXPreferenceFragment.newInstance(this, this);
+                    } else if (connectionMethod == ICameraConnection.CameraConnectionMethod.THETA) {
+                        preferenceFragment = ThetaPreferenceFragment.newInstance(this, this);
                     } else //  if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
                     {
                         preferenceFragment = PreferenceFragment.newInstance(this, interfaceProvider, this);
@@ -626,6 +641,10 @@ public class A01dMain extends AppCompatActivity implements ICameraStatusReceiver
         {
             connection = interfaceProvider.getOlympusPenInterface().getOlyCameraConnection();
         }
+        else if  (connectionMethod == ICameraConnection.CameraConnectionMethod.THETA)
+        {
+            connection = interfaceProvider.getThetaInterface().getCameraConnection();
+        }
         else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
         {
             connection = interfaceProvider.getOlympusInterface().getOlyCameraConnection();
index 9bd7e30..edc7860 100644 (file)
@@ -16,6 +16,8 @@ import net.osdn.gokigen.a01d.camera.ricohgr2.IRicohGr2InterfaceProvider;
 import net.osdn.gokigen.a01d.camera.ricohgr2.wrapper.RicohGr2InterfaceProvider;
 import net.osdn.gokigen.a01d.camera.sony.ISonyInterfaceProvider;
 import net.osdn.gokigen.a01d.camera.sony.wrapper.SonyCameraWrapper;
+import net.osdn.gokigen.a01d.camera.theta.IThetaInterfaceProvider;
+import net.osdn.gokigen.a01d.camera.theta.wrapper.ThetaInterfaceProvider;
 import net.osdn.gokigen.a01d.liveview.ICameraStatusUpdateNotify;
 import net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor;
 
@@ -31,6 +33,7 @@ public class CameraInterfaceProvider implements IInterfaceProvider
     private final RicohGr2InterfaceProvider ricohGr2;
     private final FujiXInterfaceProvider fujiX;
     private final PanasonicCameraWrapper panasonic;
+    private final ThetaInterfaceProvider theta;
     private final CameraStatusListener statusListener;
 
     public CameraInterfaceProvider(@NonNull Activity context, @NonNull ICameraStatusReceiver provider)
@@ -43,6 +46,7 @@ public class CameraInterfaceProvider implements IInterfaceProvider
         fujiX = new FujiXInterfaceProvider(context, provider, statusListener);
         panasonic = new PanasonicCameraWrapper(context, provider, statusListener);
         ricohGr2 = new RicohGr2InterfaceProvider(context, provider);
+        theta = new ThetaInterfaceProvider(context, provider, statusListener);
     }
 
     @Override
@@ -100,6 +104,12 @@ public class CameraInterfaceProvider implements IInterfaceProvider
         return (olympusPen);
     }
 
+    @Override
+    public IThetaInterfaceProvider getThetaInterface()
+    {
+        return (theta);
+    }
+
     /**
      *   OPCカメラを使用するかどうか
      *
@@ -132,6 +142,10 @@ public class CameraInterfaceProvider implements IInterfaceProvider
             {
                 ret = ICameraConnection.CameraConnectionMethod.OLYMPUS;
             }
+            else if (connectionMethod.contains("THETA"))
+            {
+                ret = ICameraConnection.CameraConnectionMethod.THETA;
+            }
         }
         catch (Exception e)
         {
index ee02bf1..abf0c25 100644 (file)
@@ -16,6 +16,7 @@ public interface ICameraConnection
         FUJI_X,
         PANASONIC,
         OLYMPUS,
+        THETA,
     }
 
     enum CameraConnectionStatus
index c276dc7..209239a 100644 (file)
@@ -7,6 +7,7 @@ import net.osdn.gokigen.a01d.camera.olympuspen.IOlympusPenInterfaceProvider;
 import net.osdn.gokigen.a01d.camera.panasonic.IPanasonicInterfaceProvider;
 import net.osdn.gokigen.a01d.camera.ricohgr2.IRicohGr2InterfaceProvider;
 import net.osdn.gokigen.a01d.camera.sony.ISonyInterfaceProvider;
+import net.osdn.gokigen.a01d.camera.theta.IThetaInterfaceProvider;
 import net.osdn.gokigen.a01d.liveview.ICameraStatusUpdateNotify;
 
 import androidx.annotation.NonNull;
@@ -26,6 +27,8 @@ public interface IInterfaceProvider
 
     IOlympusPenInterfaceProvider getOlympusPenInterface();
 
+    IThetaInterfaceProvider getThetaInterface();
+
     void setUpdateReceiver(@NonNull ICameraStatusUpdateNotify receiver);
 
     ICameraConnection.CameraConnectionMethod getCammeraConnectionMethod();
diff --git a/app/src/main/java/net/osdn/gokigen/a01d/camera/theta/operation/ThetaSingleShotControl.java b/app/src/main/java/net/osdn/gokigen/a01d/camera/theta/operation/ThetaSingleShotControl.java
new file mode 100644 (file)
index 0000000..12cd19e
--- /dev/null
@@ -0,0 +1,80 @@
+package net.osdn.gokigen.a01d.camera.theta.operation;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.preference.PreferenceManager;
+import android.util.Log;
+
+import androidx.annotation.NonNull;
+
+import net.osdn.gokigen.a01d.camera.theta.wrapper.IThetaSessionIdProvider;
+import net.osdn.gokigen.a01d.camera.utils.SimpleHttpClient;
+import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
+import net.osdn.gokigen.a01d.liveview.IIndicatorControl;
+import net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor;
+
+public class ThetaSingleShotControl
+{
+    private final String TAG = toString();
+    private final IThetaSessionIdProvider sessionIdProvider;
+    private final IAutoFocusFrameDisplay frameDisplayer;
+    private boolean useThetaV21 = false;
+    private int timeoutMs = 6000;
+
+
+    public ThetaSingleShotControl(@NonNull Context context, @NonNull final IThetaSessionIdProvider sessionIdProvider, @NonNull IAutoFocusFrameDisplay frameDisplayer, @NonNull IIndicatorControl indicator)
+    {
+        this.sessionIdProvider = sessionIdProvider;
+        this.frameDisplayer = frameDisplayer;
+        try
+        {
+            SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
+            useThetaV21 = preferences.getBoolean(IPreferencePropertyAccessor.USE_OSC_THETA_V21, false);
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+        Log.v(TAG, "USE THETA WEB API V2.1 (OSC V2) : " + useThetaV21);
+    }
+
+
+    /**
+     *
+     *
+     */
+    public void singleShot()
+    {
+        Log.v(TAG, "singleShot()");
+        try
+        {
+            Thread thread = new Thread(new Runnable()
+            {
+                @Override
+                public void run()
+                {
+                    try
+                    {
+                        String shootUrl = "http://192.168.1.1/osc/commands/execute";
+                        String postData = (useThetaV21) ? "{\"name\":\"camera.takePicture\",\"parameters\":{\"timeout\":0}}" : "{\"name\":\"camera.takePicture\",\"parameters\":{\"sessionId\": \"" + sessionIdProvider.getSessionId() + "\"}}";
+                        String result = SimpleHttpClient.httpPost(shootUrl, postData, timeoutMs);
+                        if ((result == null)||(result.length() < 1))
+                        {
+                            Log.v(TAG, "singleShot() reply is null.");
+                        }
+                    }
+                    catch (Exception e)
+                    {
+                        e.printStackTrace();
+                    }
+                    frameDisplayer.hideFocusFrame();
+                }
+            });
+            thread.start();
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+}
index 267ffde..e11ad86 100644 (file)
@@ -1,4 +1,5 @@
 package net.osdn.gokigen.a01d.camera.theta.wrapper;
+import android.content.Context;
 import android.util.Log;
 
 import androidx.annotation.NonNull;
@@ -8,17 +9,18 @@ import net.osdn.gokigen.a01d.camera.olympuspen.operation.OlympusPenSingleShotCon
 import net.osdn.gokigen.a01d.camera.panasonic.operation.PanasonicCameraCaptureControl;
 import net.osdn.gokigen.a01d.camera.panasonic.operation.takepicture.SingleShotControl;
 import net.osdn.gokigen.a01d.camera.panasonic.wrapper.IPanasonicCamera;
+import net.osdn.gokigen.a01d.camera.theta.operation.ThetaSingleShotControl;
 import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
 import net.osdn.gokigen.a01d.liveview.IIndicatorControl;
 
 public class ThetaCaptureControl implements ICaptureControl
 {
-    private static final String TAG = PanasonicCameraCaptureControl.class.getSimpleName();
-    //private final OlympusPenSingleShotControl singleShotControl;
+    private static final String TAG = ThetaCaptureControl.class.getSimpleName();
+    private final ThetaSingleShotControl singleShotControl;
 
-    public ThetaCaptureControl(@NonNull IAutoFocusFrameDisplay frameDisplayer, @NonNull IIndicatorControl indicator)
+    public ThetaCaptureControl(@NonNull Context context, @NonNull final IThetaSessionIdProvider sessionIdProvider, @NonNull IAutoFocusFrameDisplay frameDisplayer, @NonNull IIndicatorControl indicator)
     {
-        //singleShotControl = new OlympusPenSingleShotControl(frameDisplayer, indicator);
+        singleShotControl = new ThetaSingleShotControl(context, sessionIdProvider, frameDisplayer, indicator);
     }
 
     /**
@@ -31,7 +33,7 @@ public class ThetaCaptureControl implements ICaptureControl
         Log.v(TAG, "doCapture() : " + kind);
         try
         {
-            //singleShotControl.singleShot();
+            singleShotControl.singleShot();
         }
         catch (Exception e)
         {
index d16352b..373b180 100644 (file)
@@ -33,6 +33,7 @@ import net.osdn.gokigen.a01d.liveview.liveviewlistener.ILiveViewListener;
 public class ThetaInterfaceProvider implements IThetaInterfaceProvider, IDisplayInjector, IThetaSessionIdNotifier, IThetaSessionIdProvider
 {
     private final String TAG = toString();
+    private final Activity activity;
     private final ThetaConnection thetaConnection;
     private final ThetaHardwareStatus hardwareStatus;
     private final ThetaRunMode runMode;
@@ -67,7 +68,7 @@ public class ThetaInterfaceProvider implements IThetaInterfaceProvider, IDisplay
             e.printStackTrace();
         }
 */
-        //this.activity = context;
+        this.activity = context;
         //this.provider = provider;
         this.statusListener = statusListener;
         thetaConnection = new ThetaConnection(context, provider, this);
@@ -89,7 +90,7 @@ public class ThetaInterfaceProvider implements IThetaInterfaceProvider, IDisplay
     {
         Log.v(TAG, "injectDisplay()");
         focusControl = new ThetaFocusControl(frameDisplayer);
-        captureControl = new ThetaCaptureControl(frameDisplayer, indicator);
+        captureControl = new ThetaCaptureControl(activity, this, frameDisplayer, indicator);
     }
 
     @Override
index a19a5a9..8d6a5ec 100644 (file)
@@ -97,6 +97,15 @@ class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchLi
             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.OPC)
         {
             this.focusingControl = interfaceProvider.getOlympusInterface().getFocusingControl();
index 6f8674e..2db077e 100644 (file)
@@ -320,6 +320,30 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
                         changeLiveViewScale.setVisibility(View.INVISIBLE);
                     }
                 }
+                else if (connectionMethod == ICameraConnection.CameraConnectionMethod.THETA)
+                {
+                    if (favoriteButton != null)
+                    {
+                        favoriteButton.setVisibility(View.VISIBLE);
+                        favoriteButton.setOnClickListener(onClickTouchListener);
+                    }
+                    if (manualFocus != null)
+                    {
+                        manualFocus.setVisibility(View.INVISIBLE);
+                    }
+                    if (changeLiveViewScale != null)
+                    {
+                        changeLiveViewScale.setVisibility(View.INVISIBLE);
+                    }
+                    if (focusIndicator != null)
+                    {
+                        focusIndicator.setVisibility(View.INVISIBLE);
+                    }
+                    if (propertyButton != null)
+                    {
+                        propertyButton.setOnClickListener(onClickTouchListener);
+                    }
+                }
             }
             if (manualFocus != null)
             {
@@ -381,6 +405,10 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
         {
             interfaceInjector = interfaceProvider.getOlympusPenInterface().getDisplayInjector();
         }
+        else if (connectionMethod == ICameraConnection.CameraConnectionMethod.THETA)
+        {
+            interfaceInjector = interfaceProvider.getThetaInterface().getDisplayInjector();
+        }
         else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
         {
             interfaceInjector = interfaceProvider.getOlympusInterface().getDisplayInjector();
@@ -419,6 +447,12 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
             this.zoomLensControl = interfaceProvider.getOlympusPenInterface().getZoomLensControl();
             this.cameraInformation = interfaceProvider.getOlympusPenInterface().getCameraInformation();
         }
+        else  if (connectionMethod == ICameraConnection.CameraConnectionMethod.THETA)
+        {
+            this.liveViewControl = interfaceProvider.getThetaInterface().getLiveViewControl();
+            this.zoomLensControl = interfaceProvider.getThetaInterface().getZoomLensControl();
+            this.cameraInformation = interfaceProvider.getThetaInterface().getCameraInformation();
+        }
         else //  if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
         {
             this.liveViewControl = interfaceProvider.getOlympusInterface().getLiveViewControl();
@@ -721,6 +755,10 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
             {
                 lvListener = interfaceProvider.getOlympusPenInterface().getLiveViewListener();
             }
+            else if (connectionMethod == ICameraConnection.CameraConnectionMethod.THETA)
+            {
+                lvListener = interfaceProvider.getThetaInterface().getLiveViewListener();
+            }
             else  // if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
             {
                 interfaceProvider.getOlympusLiveViewListener().setOlympusLiveViewListener(liveViewListener);
index f3f855c..4f72bb0 100644 (file)
@@ -124,6 +124,9 @@ public class ThetaPreferenceFragment extends PreferenceFragmentCompat implements
             if (!items.containsKey(IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW)) {
                 editor.putBoolean(IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW, true);
             }
+            if (!items.containsKey(IPreferencePropertyAccessor.USE_OSC_THETA_V21)) {
+                editor.putBoolean(IPreferencePropertyAccessor.USE_OSC_THETA_V21, false);
+            }
             if (!items.containsKey(IPreferencePropertyAccessor.CONNECTION_METHOD)) {
                 editor.putString(IPreferencePropertyAccessor.CONNECTION_METHOD, IPreferencePropertyAccessor.CONNECTION_METHOD_DEFAULT_VALUE);
             }
@@ -158,6 +161,11 @@ public class ThetaPreferenceFragment extends PreferenceFragmentCompat implements
                     Log.v(TAG, " " + key + " , " + value);
                     break;
 
+                case IPreferencePropertyAccessor.USE_OSC_THETA_V21:
+                    value = preferences.getBoolean(key, false);
+                    Log.v(TAG, " " + key + " , " + value);
+                    break;
+
                 default:
                     String strValue = preferences.getString(key, "");
                     setListPreference(key, key, strValue);
@@ -177,7 +185,7 @@ public class ThetaPreferenceFragment extends PreferenceFragmentCompat implements
         try
         {
             //super.onCreate(savedInstanceState);
-            addPreferencesFromResource(R.xml.preferences_olympuspen);
+            addPreferencesFromResource(R.xml.preferences_theta);
 
             ListPreference connectionMethod = findPreference(IPreferencePropertyAccessor.CONNECTION_METHOD);
             connectionMethod.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@@ -313,6 +321,7 @@ public class ThetaPreferenceFragment extends PreferenceFragmentCompat implements
                         // Preferenceの画面に反映させる
                         setBooleanPreference(IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA, IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA, defaultValue);
                         setBooleanPreference(IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW, IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW, defaultValue);
+                        setBooleanPreference(IPreferencePropertyAccessor.USE_OSC_THETA_V21, IPreferencePropertyAccessor.USE_OSC_THETA_V21, false);
                     }
                     catch (Exception e)
                     {
index c2f4f59..321bf8e 100644 (file)
         <item >Olympus Pen/OM-D</item>
         <item >Sony</item>
         <item >Ricoh GR Series / PENTAX</item>
+        <item >Ricoh THETA Series</item>
         <item >Fuji X Series</item>
         <item >Panasonic</item>
     </string-array>
         <item >OLYMPUS</item>
         <item >SONY</item>
         <item >RICOH_GR2</item>
+        <item >THETA</item>
         <item >FUJI_X</item>
         <item >PANASONIC</item>
     </string-array>
index ec56d18..2db0e33 100644 (file)
         <item >Olympus Pen/OM-D</item>
         <item >Sony</item>
         <item >Ricoh GR Series / PENTAX</item>
+        <item >Ricoh THETA Series</item>
         <item >Fuji X Series</item>
         <item >Panasonic</item>
     </string-array>
         <item >OLYMPUS</item>
         <item >SONY</item>
         <item >RICOH_GR2</item>
+        <item >THETA</item>
         <item >FUJI_X</item>
         <item >PANASONIC</item>
     </string-array>