OSDN Git Service

いったんコミット。
authorMRSa <mrsa@myad.jp>
Fri, 3 Jan 2020 15:30:50 +0000 (00:30 +0900)
committerMRSa <mrsa@myad.jp>
Fri, 3 Jan 2020 15:30:50 +0000 (00:30 +0900)
44 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/IInterfaceProvider.java
app/src/main/java/net/osdn/gokigen/a01d/camera/fujix/wrapper/connection/FujiXCameraConnectSequence.java
app/src/main/java/net/osdn/gokigen/a01d/camera/fujix/wrapper/connection/FujiXCameraConnectSequenceForPlayback.java
app/src/main/java/net/osdn/gokigen/a01d/camera/fujix/wrapper/connection/FujiXCameraConnectSequenceForRead.java
app/src/main/java/net/osdn/gokigen/a01d/camera/fujix/wrapper/connection/FujiXConnection.java
app/src/main/java/net/osdn/gokigen/a01d/camera/olympus/wrapper/connection/OlyCameraConnection.java
app/src/main/java/net/osdn/gokigen/a01d/camera/olympuspen/IOlympusPenInterfaceProvider.java
app/src/main/java/net/osdn/gokigen/a01d/camera/olympuspen/operation/OlympusPenAutoFocusControl.java [new file with mode: 0644]
app/src/main/java/net/osdn/gokigen/a01d/camera/olympuspen/operation/OlympusPenSingleShotControl.java [new file with mode: 0644]
app/src/main/java/net/osdn/gokigen/a01d/camera/olympuspen/wrapper/OlympusPenCameraInformation.java [new file with mode: 0644]
app/src/main/java/net/osdn/gokigen/a01d/camera/olympuspen/wrapper/OlympusPenCameraStatusWatcher.java [new file with mode: 0644]
app/src/main/java/net/osdn/gokigen/a01d/camera/olympuspen/wrapper/OlympusPenCaptureControl.java [new file with mode: 0644]
app/src/main/java/net/osdn/gokigen/a01d/camera/olympuspen/wrapper/OlympusPenFocusControl.java [new file with mode: 0644]
app/src/main/java/net/osdn/gokigen/a01d/camera/olympuspen/wrapper/OlympusPenInterfaceProvider.java
app/src/main/java/net/osdn/gokigen/a01d/camera/olympuspen/wrapper/OlympusPenLiveViewControl.java [new file with mode: 0644]
app/src/main/java/net/osdn/gokigen/a01d/camera/olympuspen/wrapper/OlympusPenRunMode.java
app/src/main/java/net/osdn/gokigen/a01d/camera/olympuspen/wrapper/OlympusPenZoomLensControl.java [new file with mode: 0644]
app/src/main/java/net/osdn/gokigen/a01d/camera/olympuspen/wrapper/connection/OlympusPenCameraConnectSequence.java
app/src/main/java/net/osdn/gokigen/a01d/camera/olympuspen/wrapper/connection/OlympusPenConnection.java
app/src/main/java/net/osdn/gokigen/a01d/camera/panasonic/wrapper/connection/PanasonicCameraConnection.java
app/src/main/java/net/osdn/gokigen/a01d/camera/ricohgr2/wrapper/connection/RicohGr2Connection.java
app/src/main/java/net/osdn/gokigen/a01d/camera/sony/wrapper/connection/SonyCameraConnection.java
app/src/main/java/net/osdn/gokigen/a01d/camera/utils/SimpleLogDumper.java [new file with mode: 0644]
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/IPreferencePropertyAccessor.java
app/src/main/java/net/osdn/gokigen/a01d/preference/fujix/FujiXPreferenceFragment.java
app/src/main/java/net/osdn/gokigen/a01d/preference/olympus/PreferenceFragment.java
app/src/main/java/net/osdn/gokigen/a01d/preference/olympuspen/OlympusPreferenceFragment.java
app/src/main/java/net/osdn/gokigen/a01d/preference/panasonic/PanasonicPreferenceFragment.java
app/src/main/java/net/osdn/gokigen/a01d/preference/ricohgr2/RicohGr2PreferenceFragment.java
app/src/main/java/net/osdn/gokigen/a01d/preference/sony/SonyPreferenceFragment.java
app/src/main/res/values-ja/arrays.xml
app/src/main/res/values-ja/strings.xml
app/src/main/res/values/arrays.xml
app/src/main/res/values/strings.xml
app/src/main/res/xml/preferences.xml
app/src/main/res/xml/preferences_fuji_x.xml
app/src/main/res/xml/preferences_olympuspen.xml
app/src/main/res/xml/preferences_panasonic.xml
app/src/main/res/xml/preferences_ricoh_gr2.xml
app/src/main/res/xml/preferences_sony.xml

index 35f8ec1..e905ac6 100644 (file)
@@ -267,6 +267,19 @@ public class A01dMain extends AppCompatActivity implements ICameraStatusReceiver
                     e.printStackTrace();
                 }
             }
+            else if (method == ICameraConnection.CameraConnectionMethod.OLYMPUS)
+            {
+                try
+                {
+                    // Olympus Penの場合は、コマンド送信ダイアログを表示する
+                    //FujiXCameraCommandSendDialog.newInstance(interfaceProvider.getFujiXInterface()).show(getSupportFragmentManager(), "sendCommandDialog");
+
+                }
+                catch (Exception e)
+                {
+                    e.printStackTrace();
+                }
+            }
             else
             {
                 // OPC カメラの場合...
@@ -603,6 +616,10 @@ public class A01dMain extends AppCompatActivity implements ICameraStatusReceiver
         {
             connection = interfaceProvider.getFujiXInterface().getFujiXCameraConnection();
         }
+        else if  (connectionMethod == ICameraConnection.CameraConnectionMethod.OLYMPUS)
+        {
+            connection = interfaceProvider.getOlympusPenInterface().getOlyCameraConnection();
+        }
         else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
         {
             connection = interfaceProvider.getOlympusInterface().getOlyCameraConnection();
index 174c293..836ba36 100644 (file)
@@ -8,6 +8,8 @@ import net.osdn.gokigen.a01d.camera.fujix.wrapper.FujiXInterfaceProvider;
 import net.osdn.gokigen.a01d.camera.olympus.wrapper.IOlympusLiveViewListener;
 import net.osdn.gokigen.a01d.camera.olympus.IOlympusInterfaceProvider;
 import net.osdn.gokigen.a01d.camera.olympus.wrapper.OlympusInterfaceProvider;
+import net.osdn.gokigen.a01d.camera.olympuspen.IOlympusPenInterfaceProvider;
+import net.osdn.gokigen.a01d.camera.olympuspen.wrapper.OlympusPenInterfaceProvider;
 import net.osdn.gokigen.a01d.camera.panasonic.IPanasonicInterfaceProvider;
 import net.osdn.gokigen.a01d.camera.panasonic.wrapper.PanasonicCameraWrapper;
 import net.osdn.gokigen.a01d.camera.ricohgr2.IRicohGr2InterfaceProvider;
@@ -24,6 +26,7 @@ public class CameraInterfaceProvider implements IInterfaceProvider
 {
     private final Activity context;
     private final OlympusInterfaceProvider olympus;
+    private final OlympusPenInterfaceProvider olympusPen;
     private final SonyCameraWrapper sony;
     private final RicohGr2InterfaceProvider ricohGr2;
     private final FujiXInterfaceProvider fujiX;
@@ -35,6 +38,7 @@ public class CameraInterfaceProvider implements IInterfaceProvider
         this.context = context;
         this.statusListener = new CameraStatusListener();
         olympus = new OlympusInterfaceProvider(context, provider);
+        olympusPen = new OlympusPenInterfaceProvider(context, provider);
         sony = new SonyCameraWrapper(context, provider, statusListener);
         fujiX = new FujiXInterfaceProvider(context, provider, statusListener);
         panasonic = new PanasonicCameraWrapper(context, provider, statusListener);
@@ -90,6 +94,12 @@ public class CameraInterfaceProvider implements IInterfaceProvider
         return (panasonic);
     }
 
+    @Override
+    public IOlympusPenInterfaceProvider getOlympusPenInterface()
+    {
+        return (olympusPen);
+    }
+
     /**
      *   OPCカメラを使用するかどうか
      *
index fb5eed8..c276dc7 100644 (file)
@@ -3,6 +3,7 @@ package net.osdn.gokigen.a01d.camera;
 import net.osdn.gokigen.a01d.camera.fujix.IFujiXInterfaceProvider;
 import net.osdn.gokigen.a01d.camera.olympus.wrapper.IOlympusLiveViewListener;
 import net.osdn.gokigen.a01d.camera.olympus.IOlympusInterfaceProvider;
+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;
@@ -23,6 +24,8 @@ public interface IInterfaceProvider
     IFujiXInterfaceProvider getFujiXInterface();
     IPanasonicInterfaceProvider getPanasonicInterface();
 
+    IOlympusPenInterfaceProvider getOlympusPenInterface();
+
     void setUpdateReceiver(@NonNull ICameraStatusUpdateNotify receiver);
 
     ICameraConnection.CameraConnectionMethod getCammeraConnectionMethod();
index a4ceb9e..756541d 100644 (file)
@@ -70,7 +70,7 @@ public class FujiXCameraConnectSequence implements Runnable, IFujiXCommandCallba
                 if (!interfaceProvider.getCommandCommunication().connect())
                 {
                     // 接続失敗...
-                    onConnectError(context.getString(R.string.dialog_title_connect_failed));
+                    onConnectError(context.getString(R.string.dialog_title_connect_failed_fuji));
                     return;
                 }
             }
index cffcce3..413a009 100644 (file)
@@ -76,9 +76,9 @@ public class FujiXCameraConnectSequenceForPlayback implements Runnable, IFujiXCo
                     // 接続失敗...
                     if (cameraStatusReceiver != null)
                     {
-                        cameraStatusReceiver.onStatusNotify(context.getString(R.string.dialog_title_connect_failed));
+                        cameraStatusReceiver.onStatusNotify(context.getString(R.string.dialog_title_connect_failed_fuji));
                     }
-                    onConnectError(context.getString(R.string.dialog_title_connect_failed));
+                    onConnectError(context.getString(R.string.dialog_title_connect_failed_fuji));
                     return;
                 }
             }
@@ -98,7 +98,7 @@ public class FujiXCameraConnectSequenceForPlayback implements Runnable, IFujiXCo
             e.printStackTrace();
             if (cameraStatusReceiver != null)
             {
-                cameraStatusReceiver.onStatusNotify(context.getString(R.string.dialog_title_connect_failed));
+                cameraStatusReceiver.onStatusNotify(context.getString(R.string.dialog_title_connect_failed_fuji));
             }
             onConnectError(e.getLocalizedMessage());
         }
@@ -136,7 +136,7 @@ public class FujiXCameraConnectSequenceForPlayback implements Runnable, IFujiXCo
                 }
                 else
                 {
-                    onConnectError(context.getString(R.string.connect_error_message));
+                    onConnectError(context.getString(R.string.connect_error_message_fuji));
                 }
                 break;
 
@@ -234,7 +234,8 @@ public class FujiXCameraConnectSequenceForPlayback implements Runnable, IFujiXCo
                 {
                     cameraStatusReceiver.onStatusNotify(context.getString(R.string.connect_connecting9));
                 }
-                commandIssuer.enqueueCommand(new ChangeToPlayback2nd(this));
+                //commandIssuer.enqueueCommand(new ChangeToPlayback2nd(this));
+                commandIssuer.enqueueCommand(new StatusRequestMessage(this));
                 break;
 
             case SEQ_CHANGE_TO_PLAYBACK_2ND:
index bdbc574..5a04364 100644 (file)
@@ -69,7 +69,7 @@ public class FujiXCameraConnectSequenceForRead implements Runnable, IFujiXComman
                 if (!interfaceProvider.getCommandCommunication().connect())
                 {
                     // 接続失敗...
-                    onConnectError(context.getString(R.string.dialog_title_connect_failed));
+                    onConnectError(context.getString(R.string.dialog_title_connect_failed_fuji));
                     return;
                 }
             }
index 47b66d4..822a7cc 100644 (file)
@@ -140,7 +140,7 @@ public class FujiXConnection implements ICameraConnection
     {
         Log.v(TAG, "alertConnectingFailed() : " + message);
         final AlertDialog.Builder builder = new AlertDialog.Builder(context)
-                .setTitle(context.getString(R.string.dialog_title_connect_failed))
+                .setTitle(context.getString(R.string.dialog_title_connect_failed_fuji))
                 .setMessage(message)
                 .setPositiveButton(context.getString(R.string.dialog_title_button_retry), new DialogInterface.OnClickListener() {
                     @Override
index 064ce99..803a4cb 100644 (file)
@@ -258,7 +258,7 @@ public class OlyCameraConnection implements ICameraConnection, OLYCameraConnecti
     public void alertConnectingFailed(String message)
     {
         final AlertDialog.Builder builder = new AlertDialog.Builder(context)
-                .setTitle(context.getString(R.string.dialog_title_connect_failed))
+                .setTitle(context.getString(R.string.dialog_title_connect_failed_opc))
                 .setMessage(message)
                 .setPositiveButton(context.getString(R.string.dialog_title_button_retry), new DialogInterface.OnClickListener() {
                     @Override
index fa603c3..fce0d87 100644 (file)
@@ -11,6 +11,7 @@ import net.osdn.gokigen.a01d.camera.ILiveViewControl;
 import net.osdn.gokigen.a01d.camera.IZoomLensControl;
 import net.osdn.gokigen.a01d.camera.olympus.wrapper.ICameraHardwareStatus;
 import net.osdn.gokigen.a01d.camera.olympus.wrapper.ICameraRunMode;
+import net.osdn.gokigen.a01d.camera.olympus.wrapper.property.IOlyCameraPropertyProvider;
 import net.osdn.gokigen.a01d.liveview.liveviewlistener.ILiveViewListener;
 
 /**
@@ -26,6 +27,7 @@ public interface IOlympusPenInterfaceProvider
     IZoomLensControl getZoomLensControl();
     ICaptureControl getCaptureControl();
     IDisplayInjector getDisplayInjector();
+    IOlyCameraPropertyProvider getCameraPropertyProvider();
 
     ICameraStatus getCameraStatusListHolder();
     ICameraStatusWatcher getCameraStatusWatcher();
diff --git a/app/src/main/java/net/osdn/gokigen/a01d/camera/olympuspen/operation/OlympusPenAutoFocusControl.java b/app/src/main/java/net/osdn/gokigen/a01d/camera/olympuspen/operation/OlympusPenAutoFocusControl.java
new file mode 100644 (file)
index 0000000..c503ae2
--- /dev/null
@@ -0,0 +1,284 @@
+package net.osdn.gokigen.a01d.camera.olympuspen.operation;
+
+import android.graphics.PointF;
+import android.graphics.RectF;
+import android.util.Log;
+
+import androidx.annotation.NonNull;
+
+import net.osdn.gokigen.a01d.camera.panasonic.operation.takepicture.PanasonicAutoFocusControl;
+import net.osdn.gokigen.a01d.camera.panasonic.wrapper.IPanasonicCamera;
+import net.osdn.gokigen.a01d.camera.utils.SimpleHttpClient;
+import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
+import net.osdn.gokigen.a01d.liveview.IIndicatorControl;
+
+import org.json.JSONArray;
+import org.json.JSONObject;
+
+public class OlympusPenAutoFocusControl
+{
+    private static final String TAG = PanasonicAutoFocusControl.class.getSimpleName();
+    private static final int TIMEOUT_MS = 3000;
+    private final IIndicatorControl indicator;
+    private final IAutoFocusFrameDisplay frameDisplayer;
+    //private IPanasonicCamera camera = null;
+
+    /**
+     *
+     *
+     */
+    public OlympusPenAutoFocusControl(@NonNull final IAutoFocusFrameDisplay frameDisplayer, final IIndicatorControl indicator)
+    {
+        this.frameDisplayer = frameDisplayer;
+        this.indicator = indicator;
+    }
+
+    /**
+     *
+     *
+     */
+    public void setCamera(@NonNull IPanasonicCamera panasonicCamera)
+    {
+        //this.camera = panasonicCamera;
+    }
+
+    /**
+     *
+     *
+     */
+    public void lockAutoFocus(@NonNull final PointF point)
+    {
+        Log.v(TAG, "lockAutoFocus() : [" + point.x + ", " + point.y + "]");
+/*
+        if (camera == null)
+        {
+            Log.v(TAG, "ISonyCameraApi is null...");
+            return;
+        }
+*/
+        try
+        {
+            Thread thread = new Thread(new Runnable()
+            {
+                @Override
+                public void run()
+                {
+                    RectF preFocusFrameRect = getPreFocusFrameRect(point);
+                    try
+                    {
+                        showFocusFrame(preFocusFrameRect, IAutoFocusFrameDisplay.FocusFrameStatus.Running, 0.0);
+
+                        int posX = (int) (Math.floor(point.x * 1000.0));
+                        int posY = (int) (Math.floor(point.y * 1000.0));
+                        Log.v(TAG, "AF (" + posX + ", " + posY + ")");
+/*
+                        //String reply = SimpleHttpClient.httpGet(camera.getCmdUrl() + "cam.cgi?mode=camctrl&type=touch&value=" + posX + "/" + posY + "&value2=on", TIMEOUT_MS);
+
+                        if (!reply.contains("ok"))
+                        {
+                            Log.v(TAG, "setTouchAFPosition() reply is null.");
+                        }
+*/
+/*
+                        if (findTouchAFPositionResult(resultsObj))
+                        {
+                            // AF FOCUSED
+                            Log.v(TAG, "lockAutoFocus() : FOCUSED");
+                            showFocusFrame(preFocusFrameRect, IAutoFocusFrameDisplay.FocusFrameStatus.Focused, 0.0);
+                        }
+                        else
+                        {
+                            // AF ERROR
+                            Log.v(TAG, "lockAutoFocus() : ERROR");
+                            showFocusFrame(preFocusFrameRect, IAutoFocusFrameDisplay.FocusFrameStatus.Failed, 1.0);
+                        }
+*/
+                        showFocusFrame(preFocusFrameRect, IAutoFocusFrameDisplay.FocusFrameStatus.Errored, 1.0);
+                    }
+                    catch (Exception e)
+                    {
+                        e.printStackTrace();
+                        try
+                        {
+                            showFocusFrame(preFocusFrameRect, IAutoFocusFrameDisplay.FocusFrameStatus.Errored, 1.0);
+                        }
+                        catch (Exception ee)
+                        {
+                            ee.printStackTrace();
+                        }
+                    }
+                }
+            });
+            thread.start();
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     *   シャッター半押し処理
+     *
+     */
+    public void halfPressShutter(final boolean isPressed)
+    {
+        Log.v(TAG, "halfPressShutter() : " + isPressed);
+/*
+        if (camera == null)
+        {
+            Log.v(TAG, "IPanasonicCamera is null...");
+            return;
+        }
+*/
+        try
+        {
+            Thread thread = new Thread(new Runnable()
+            {
+                @Override
+                public void run()
+                {
+                    try
+                    {
+                        String status = (isPressed) ? "on" : "off";
+/*
+                        String reply = SimpleHttpClient.httpGet(camera.getCmdUrl() + "cam.cgi?mode=camctrl&type=touch&value=500/500&value2=" + status, TIMEOUT_MS);
+                        if (!reply.contains("ok"))
+                        {
+                            Log.v(TAG, "CENTER FOCUS (" + status + ") FAIL...");
+                        }
+                        else
+                        {
+                            indicator.onAfLockUpdate(isPressed);
+                        }
+*/
+                    }
+                    catch (Exception e)
+                    {
+                        e.printStackTrace();
+                    }
+                }
+            });
+            thread.start();
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     *
+     *
+     */
+    public void unlockAutoFocus()
+    {
+        Log.v(TAG, "unlockAutoFocus()");
+/*
+        if (camera == null)
+        {
+            Log.v(TAG, "IPanasonicCamera is null...");
+            return;
+        }
+*/
+        try
+        {
+            Thread thread = new Thread(new Runnable()
+            {
+                @Override
+                public void run()
+                {
+                    try
+                    {
+/*
+                        String reply = SimpleHttpClient.httpGet(camera.getCmdUrl() + "cam.cgi?mode=camctrl&type=touch&value=500/500&value2=off", TIMEOUT_MS);
+                        if (!reply.contains("ok"))
+                        {
+                            Log.v(TAG, "CENTER FOCUS (UNLOCK) FAIL...");
+                        }
+*/
+                        hideFocusFrame();
+                    }
+                    catch (Exception e)
+                    {
+                        e.printStackTrace();
+                    }
+                }
+            });
+            thread.start();
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     *
+     *
+     */
+    private void showFocusFrame(RectF rect, IAutoFocusFrameDisplay.FocusFrameStatus status, double duration)
+    {
+        frameDisplayer.showFocusFrame(rect, status, duration);
+        indicator.onAfLockUpdate(IAutoFocusFrameDisplay.FocusFrameStatus.Focused == status);
+    }
+
+    /**
+     *
+     *
+     */
+    private void hideFocusFrame()
+    {
+        frameDisplayer.hideFocusFrame();
+        indicator.onAfLockUpdate(false);
+    }
+
+    /**
+     *
+     *
+     */
+    private RectF getPreFocusFrameRect(@NonNull PointF point)
+    {
+        float imageWidth =  frameDisplayer.getContentSizeWidth();
+        float imageHeight =  frameDisplayer.getContentSizeHeight();
+
+        // Display a provisional focus frame at the touched point.
+        float focusWidth = 0.125f;  // 0.125 is rough estimate.
+        float focusHeight = 0.125f;
+        if (imageWidth > imageHeight)
+        {
+            focusHeight *= (imageWidth / imageHeight);
+        }
+        else
+        {
+            focusHeight *= (imageHeight / imageWidth);
+        }
+        return (new RectF(point.x - focusWidth / 2.0f, point.y - focusHeight / 2.0f,
+                point.x + focusWidth / 2.0f, point.y + focusHeight / 2.0f));
+    }
+
+    /**
+     *
+     *
+     */
+    private static boolean findTouchAFPositionResult(JSONObject replyJson)
+    {
+        boolean afResult = false;
+        try
+        {
+            int indexOfTouchAFPositionResult = 1;
+            JSONArray resultsObj = replyJson.getJSONArray("result");
+            if (!resultsObj.isNull(indexOfTouchAFPositionResult))
+            {
+                JSONObject touchAFPositionResultObj = resultsObj.getJSONObject(indexOfTouchAFPositionResult);
+                afResult = touchAFPositionResultObj.getBoolean("AFResult");
+                Log.v(TAG, "AF Result : " + afResult);
+            }
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+        return (afResult);
+    }
+}
diff --git a/app/src/main/java/net/osdn/gokigen/a01d/camera/olympuspen/operation/OlympusPenSingleShotControl.java b/app/src/main/java/net/osdn/gokigen/a01d/camera/olympuspen/operation/OlympusPenSingleShotControl.java
new file mode 100644 (file)
index 0000000..21ab868
--- /dev/null
@@ -0,0 +1,81 @@
+package net.osdn.gokigen.a01d.camera.olympuspen.operation;
+
+import android.util.Log;
+
+import androidx.annotation.NonNull;
+
+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.utils.SimpleHttpClient;
+import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
+import net.osdn.gokigen.a01d.liveview.IIndicatorControl;
+
+public class OlympusPenSingleShotControl
+{
+    private static final String TAG = SingleShotControl.class.getSimpleName();
+    private static final int TIMEOUT_MS = 3000;
+    private final IAutoFocusFrameDisplay frameDisplayer;
+    private final IIndicatorControl indicator;
+    private IPanasonicCamera camera = null;
+
+    /**
+     *
+     *
+     */
+    public OlympusPenSingleShotControl(@NonNull IAutoFocusFrameDisplay frameDisplayer, @NonNull IIndicatorControl indicator)
+    {
+        this.frameDisplayer = frameDisplayer;
+        this.indicator = indicator;
+    }
+
+    /**
+     *
+     *
+     */
+    public void setCamera(@NonNull IPanasonicCamera panasonicCamera)
+    {
+        this.camera = panasonicCamera;
+    }
+
+    /**
+     *
+     *
+     */
+    public void singleShot()
+    {
+        Log.v(TAG, "singleShot()");
+        if (camera == null)
+        {
+            Log.v(TAG, "IPanasonicCamera is null...");
+            return;
+        }
+        try
+        {
+            Thread thread = new Thread(new Runnable()
+            {
+                @Override
+                public void run()
+                {
+                    try
+                    {
+                        String reply = SimpleHttpClient.httpGet(camera.getCmdUrl() + "cam.cgi?mode=camcmd&value=capture", TIMEOUT_MS);
+                        if (!reply.contains("ok"))
+                        {
+                            Log.v(TAG, "Capture Failure... : " + reply);
+                        }
+                    }
+                    catch (Exception e)
+                    {
+                        e.printStackTrace();
+                    }
+                    frameDisplayer.hideFocusFrame();
+                }
+            });
+            thread.start();
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+}
diff --git a/app/src/main/java/net/osdn/gokigen/a01d/camera/olympuspen/wrapper/OlympusPenCameraInformation.java b/app/src/main/java/net/osdn/gokigen/a01d/camera/olympuspen/wrapper/OlympusPenCameraInformation.java
new file mode 100644 (file)
index 0000000..6dcb559
--- /dev/null
@@ -0,0 +1,79 @@
+package net.osdn.gokigen.a01d.camera.olympuspen.wrapper;
+
+import net.osdn.gokigen.a01d.camera.ICameraInformation;
+import net.osdn.gokigen.a01d.camera.olympus.wrapper.property.IOlyCameraPropertyProvider;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class OlympusPenCameraInformation implements ICameraInformation, IOlyCameraPropertyProvider
+{
+    OlympusPenCameraInformation()
+    {
+
+    }
+
+    @Override
+    public boolean isManualFocus()
+    {
+        return false;
+    }
+
+    @Override
+    public boolean isElectricZoomLens()
+    {
+        return false;
+    }
+
+    @Override
+    public boolean isExposureLocked()
+    {
+        return false;
+    }
+
+    @Override
+    public Set<String> getCameraPropertyNames() {
+        return null;
+    }
+
+    @Override
+    public String getCameraPropertyValue(String name) {
+        return null;
+    }
+
+    @Override
+    public Map<String, String> getCameraPropertyValues(Set<String> names) {
+        return null;
+    }
+
+    @Override
+    public String getCameraPropertyTitle(String name) {
+        return null;
+    }
+
+    @Override
+    public List<String> getCameraPropertyValueList(String name) {
+        return null;
+    }
+
+    @Override
+    public String getCameraPropertyValueTitle(String propertyValue) {
+        return null;
+    }
+
+    @Override
+    public void setCameraPropertyValue(String name, String value) {
+
+    }
+
+    @Override
+    public void setCameraPropertyValues(Map<String, String> values) {
+
+    }
+
+    @Override
+    public boolean canSetCameraProperty(String name) {
+        return false;
+    }
+}
diff --git a/app/src/main/java/net/osdn/gokigen/a01d/camera/olympuspen/wrapper/OlympusPenCameraStatusWatcher.java b/app/src/main/java/net/osdn/gokigen/a01d/camera/olympuspen/wrapper/OlympusPenCameraStatusWatcher.java
new file mode 100644 (file)
index 0000000..e22860b
--- /dev/null
@@ -0,0 +1,43 @@
+package net.osdn.gokigen.a01d.camera.olympuspen.wrapper;
+
+import androidx.annotation.NonNull;
+
+import net.osdn.gokigen.a01d.camera.ICameraStatus;
+import net.osdn.gokigen.a01d.camera.ICameraStatusWatcher;
+import net.osdn.gokigen.a01d.liveview.ICameraStatusUpdateNotify;
+
+import java.util.List;
+
+public class OlympusPenCameraStatusWatcher implements ICameraStatusWatcher, ICameraStatus
+{
+    OlympusPenCameraStatusWatcher()
+    {
+
+    }
+
+
+    @Override
+    public void startStatusWatch(@NonNull ICameraStatusUpdateNotify notifier) {
+
+    }
+
+    @Override
+    public void stopStatusWatch() {
+
+    }
+
+    @Override
+    public List<String> getStatusList(String key) {
+        return null;
+    }
+
+    @Override
+    public String getStatus(String key) {
+        return null;
+    }
+
+    @Override
+    public void setStatus(String key, String value) {
+
+    }
+}
diff --git a/app/src/main/java/net/osdn/gokigen/a01d/camera/olympuspen/wrapper/OlympusPenCaptureControl.java b/app/src/main/java/net/osdn/gokigen/a01d/camera/olympuspen/wrapper/OlympusPenCaptureControl.java
new file mode 100644 (file)
index 0000000..7a5e961
--- /dev/null
@@ -0,0 +1,48 @@
+package net.osdn.gokigen.a01d.camera.olympuspen.wrapper;
+
+import android.util.Log;
+
+import androidx.annotation.NonNull;
+
+import net.osdn.gokigen.a01d.camera.ICaptureControl;
+import net.osdn.gokigen.a01d.camera.olympuspen.operation.OlympusPenSingleShotControl;
+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.liveview.IAutoFocusFrameDisplay;
+import net.osdn.gokigen.a01d.liveview.IIndicatorControl;
+
+public class OlympusPenCaptureControl  implements ICaptureControl
+{
+    private static final String TAG = PanasonicCameraCaptureControl.class.getSimpleName();
+    private final OlympusPenSingleShotControl singleShotControl;
+
+    public OlympusPenCaptureControl(@NonNull IAutoFocusFrameDisplay frameDisplayer, @NonNull IIndicatorControl indicator)
+    {
+        singleShotControl = new OlympusPenSingleShotControl(frameDisplayer, indicator);
+    }
+
+    public void setCamera(@NonNull IPanasonicCamera panasonicCamera)
+    {
+        singleShotControl.setCamera(panasonicCamera);
+    }
+
+    /**
+     *   撮影する
+     *
+     */
+    @Override
+    public void doCapture(int kind)
+    {
+        Log.v(TAG, "doCapture() : " + kind);
+        try
+        {
+            singleShotControl.singleShot();
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+}
diff --git a/app/src/main/java/net/osdn/gokigen/a01d/camera/olympuspen/wrapper/OlympusPenFocusControl.java b/app/src/main/java/net/osdn/gokigen/a01d/camera/olympuspen/wrapper/OlympusPenFocusControl.java
new file mode 100644 (file)
index 0000000..09a984f
--- /dev/null
@@ -0,0 +1,83 @@
+package net.osdn.gokigen.a01d.camera.olympuspen.wrapper;
+
+import android.graphics.PointF;
+import android.util.Log;
+import android.view.MotionEvent;
+
+import androidx.annotation.NonNull;
+
+import net.osdn.gokigen.a01d.camera.IFocusingControl;
+import net.osdn.gokigen.a01d.camera.olympuspen.operation.OlympusPenAutoFocusControl;
+import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
+import net.osdn.gokigen.a01d.liveview.IIndicatorControl;
+
+public class OlympusPenFocusControl implements IFocusingControl
+{
+    private final String TAG = toString();
+    private final OlympusPenAutoFocusControl afControl;
+    private final IAutoFocusFrameDisplay frameDisplay;
+
+    public OlympusPenFocusControl(@NonNull final IAutoFocusFrameDisplay frameDisplayer, @NonNull final IIndicatorControl indicator)
+    {
+        this.frameDisplay = frameDisplayer;
+        afControl = new OlympusPenAutoFocusControl(frameDisplayer, indicator);
+    }
+
+    @Override
+    public boolean driveAutoFocus(final MotionEvent motionEvent)
+    {
+        Log.v(TAG, "driveAutoFocus()");
+        if (motionEvent.getAction() != MotionEvent.ACTION_DOWN)
+        {
+            return (false);
+        }
+        try
+        {
+            PointF point = frameDisplay.getPointWithEvent(motionEvent);
+            if (frameDisplay.isContainsPoint(point))
+            {
+               afControl.lockAutoFocus(point);
+            }
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+        return (false);
+    }
+
+    @Override
+    public void unlockAutoFocus()
+    {
+        Log.v(TAG, "unlockAutoFocus()");
+        try
+        {
+            afControl.unlockAutoFocus();
+            frameDisplay.hideFocusFrame();
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    @Override
+    public void halfPressShutter(boolean isPressed)
+    {
+        Log.v(TAG, "halfPressShutter() " + isPressed);
+        try
+        {
+            afControl.halfPressShutter(isPressed);
+            if (!isPressed)
+            {
+                // フォーカスを外す
+                frameDisplay.hideFocusFrame();
+                afControl.unlockAutoFocus();
+            }
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+}
index 0266d75..4339adb 100644 (file)
@@ -1,11 +1,9 @@
 package net.osdn.gokigen.a01d.camera.olympuspen.wrapper;
 
 import android.app.Activity;
-import android.content.SharedPreferences;
 import android.util.Log;
 
 import androidx.annotation.NonNull;
-import androidx.preference.PreferenceManager;
 
 import net.osdn.gokigen.a01d.camera.ICameraConnection;
 import net.osdn.gokigen.a01d.camera.ICameraInformation;
@@ -20,13 +18,13 @@ import net.osdn.gokigen.a01d.camera.ILiveViewControl;
 import net.osdn.gokigen.a01d.camera.IZoomLensControl;
 import net.osdn.gokigen.a01d.camera.olympus.wrapper.ICameraHardwareStatus;
 import net.osdn.gokigen.a01d.camera.olympus.wrapper.ICameraRunMode;
+import net.osdn.gokigen.a01d.camera.olympus.wrapper.property.IOlyCameraPropertyProvider;
 import net.osdn.gokigen.a01d.camera.olympuspen.IOlympusPenInterfaceProvider;
 import net.osdn.gokigen.a01d.camera.olympuspen.wrapper.connection.OlympusPenConnection;
 import net.osdn.gokigen.a01d.camera.olympuspen.wrapper.hardware.OlympusPenHardwareStatus;
 import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
 import net.osdn.gokigen.a01d.liveview.IIndicatorControl;
 import net.osdn.gokigen.a01d.liveview.liveviewlistener.ILiveViewListener;
-import net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor;
 
 /**
  *
@@ -38,6 +36,12 @@ public class OlympusPenInterfaceProvider implements IOlympusPenInterfaceProvider
     private final OlympusPenConnection olympusPenConnection;
     private final OlympusPenHardwareStatus hardwareStatus;
     private final OlympusPenRunMode runMode;
+    private final OlympusPenLiveViewControl liveViewControl;
+    private final OlympusPenZoomLensControl zoomLensControl;
+    private final OlympusPenCameraInformation cameraInformation;
+    private final OlympusPenCameraStatusWatcher statusWatcher;
+    private  OlympusPenFocusControl focusControl = null;
+    private  OlympusPenCaptureControl captureControl = null;
 
     /**
      *
@@ -66,6 +70,10 @@ public class OlympusPenInterfaceProvider implements IOlympusPenInterfaceProvider
         olympusPenConnection = new OlympusPenConnection(context, provider);
         hardwareStatus = new OlympusPenHardwareStatus();
         runMode = new OlympusPenRunMode();
+        liveViewControl = new OlympusPenLiveViewControl();
+        zoomLensControl = new OlympusPenZoomLensControl();
+        cameraInformation = new OlympusPenCameraInformation();
+        statusWatcher = new OlympusPenCameraStatusWatcher();
     }
 
     public void prepare()
@@ -77,6 +85,8 @@ public class OlympusPenInterfaceProvider implements IOlympusPenInterfaceProvider
     public void injectDisplay(IAutoFocusFrameDisplay frameDisplayer, IIndicatorControl indicator, IFocusingModeNotify focusingModeNotify)
     {
         Log.v(TAG, "injectDisplay()");
+        focusControl = new OlympusPenFocusControl(frameDisplayer, indicator);
+        captureControl = new OlympusPenCaptureControl(frameDisplayer, indicator);
     }
 
     @Override
@@ -88,37 +98,37 @@ public class OlympusPenInterfaceProvider implements IOlympusPenInterfaceProvider
     @Override
     public ILiveViewControl getLiveViewControl()
     {
-        return (null);
+        return (liveViewControl);
     }
 
     @Override
     public ILiveViewListener getLiveViewListener()
     {
-        return (null);
+        return (liveViewControl.getLiveViewListener());
     }
 
     @Override
     public IFocusingControl getFocusingControl()
     {
-        return (null);
+        return (focusControl);
     }
 
     @Override
     public ICameraInformation getCameraInformation()
     {
-        return (null);
+        return (cameraInformation);
     }
 
     @Override
     public IZoomLensControl getZoomLensControl()
     {
-        return (null);
+        return (zoomLensControl);
     }
 
     @Override
     public ICaptureControl getCaptureControl()
     {
-        return (null);
+        return (captureControl);
     }
 
     @Override
@@ -127,14 +137,20 @@ public class OlympusPenInterfaceProvider implements IOlympusPenInterfaceProvider
     }
 
     @Override
+    public IOlyCameraPropertyProvider getCameraPropertyProvider()
+    {
+        return (cameraInformation);
+    }
+
+    @Override
     public ICameraStatus getCameraStatusListHolder()
     {
-        return (null);
+        return (statusWatcher);
     }
 
     @Override
     public ICameraStatusWatcher getCameraStatusWatcher() {
-        return (null);
+        return (statusWatcher);
     }
 
     @Override
diff --git a/app/src/main/java/net/osdn/gokigen/a01d/camera/olympuspen/wrapper/OlympusPenLiveViewControl.java b/app/src/main/java/net/osdn/gokigen/a01d/camera/olympuspen/wrapper/OlympusPenLiveViewControl.java
new file mode 100644 (file)
index 0000000..4d5e1c4
--- /dev/null
@@ -0,0 +1,345 @@
+package net.osdn.gokigen.a01d.camera.olympuspen.wrapper;
+
+import android.util.Log;
+
+import androidx.annotation.NonNull;
+
+import net.osdn.gokigen.a01d.camera.ILiveViewControl;
+import net.osdn.gokigen.a01d.camera.utils.SimpleHttpClient;
+import net.osdn.gokigen.a01d.liveview.liveviewlistener.CameraLiveViewListenerImpl;
+import net.osdn.gokigen.a01d.liveview.liveviewlistener.ILiveViewListener;
+
+import java.io.ByteArrayOutputStream;
+import java.net.DatagramPacket;
+import java.net.DatagramSocket;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+public class OlympusPenLiveViewControl implements ILiveViewControl
+{
+    private final String TAG = toString();
+    private final CameraLiveViewListenerImpl liveViewListener;
+    private DatagramSocket receiveSocket = null;
+    private boolean whileStreamReceive = false;
+
+    private static final int TIMEOUT_MAX = 3;
+    private static final int RECEIVE_BUFFER_SIZE = 1024 * 1024 * 4;
+    private static final int TIMEOUT_MS = 1500;
+    private static final int LIVEVIEW_PORT = 49152;
+
+    private final String COMMUNICATION_URL = "http://192.168.0.10/";
+    private final String LIVEVIEW_START_REQUEST = "exec_takemisc.cgi?com=startliveview&port=49152";
+    private final String LIVEVIEW_STOP_REQUEST = "exec_takemisc.cgi?com=stopliveview";
+
+    private Map<String, String> headerMap;
+    private ByteArrayOutputStream receivedByteStream;
+
+    OlympusPenLiveViewControl()
+    {
+        liveViewListener = new CameraLiveViewListenerImpl();
+
+        headerMap = new HashMap<>();
+        headerMap.put("User-Agent", "OlympusCameraKit"); // "OI.Share"
+        headerMap.put("X-Protocol", "OlympusCameraKit"); // "OI.Share"
+
+        receivedByteStream = new ByteArrayOutputStream(RECEIVE_BUFFER_SIZE);
+    }
+
+    @Override
+    public void changeLiveViewSize(String size)
+    {
+
+    }
+
+    @Override
+    public void startLiveView()
+    {
+        Log.v(TAG, "startLiveView()");
+        try
+        {
+            Thread thread = new Thread(new Runnable()
+            {
+                @Override
+                public void run()
+                {
+                    try
+                    {
+                        startReceiveStream();
+                        if (!whileStreamReceive)
+                        {
+                            Log.v(TAG, "CANNOT OPEN : UDP RECEIVE SOCKET");
+                            return;
+                        }
+                        String requestUrl = COMMUNICATION_URL + LIVEVIEW_START_REQUEST;
+                        String reply = SimpleHttpClient.httpGetWithHeader(requestUrl, headerMap, null, TIMEOUT_MS);
+                        Log.v(TAG, "   ----- START LIVEVIEW ----- : " + requestUrl + " " + reply);
+                    }
+                    catch (Exception e)
+                    {
+                        e.printStackTrace();
+                    }
+                }
+            });
+            thread.start();
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    @Override
+    public void stopLiveView()
+    {
+        Log.v(TAG, "stopLiveView()");
+        try
+        {
+            Thread thread = new Thread(new Runnable()
+            {
+                @Override
+                public void run()
+                {
+                    try
+                    {
+                        String requestUrl = COMMUNICATION_URL + LIVEVIEW_STOP_REQUEST;
+                        String reply = SimpleHttpClient.httpGetWithHeader(requestUrl, headerMap, null, TIMEOUT_MS);
+                        Log.v(TAG, "stopLiveview() is issued.  " + reply);
+
+                        //  ライブビューウォッチャーを止める
+                        whileStreamReceive = false;
+                        closeReceiveSocket();
+                    }
+                    catch (Exception e)
+                    {
+                        e.printStackTrace();
+                    }
+                }
+            });
+            thread.start();
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    @Override
+    public void updateDigitalZoom()
+    {
+
+    }
+
+    @Override
+    public void updateMagnifyingLiveViewScale(boolean isChangeScale)
+    {
+
+    }
+
+    @Override
+    public float getMagnifyingLiveViewScale()
+    {
+        return (1.0f);
+    }
+
+    @Override
+    public float getDigitalZoomScale()
+    {
+        return (1.0f);
+    }
+
+    private void startReceiveStream()
+    {
+        if (whileStreamReceive)
+        {
+            Log.v(TAG, "startReceiveStream() : already starting.");
+            return;
+        }
+
+        // ソケットをあける (UDP)
+        try
+        {
+            receiveSocket = new DatagramSocket(LIVEVIEW_PORT);
+            whileStreamReceive = true;
+            receivedByteStream.flush();
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            whileStreamReceive = false;
+            receiveSocket = null;
+        }
+
+        // 受信スレッドを動かす
+        Thread thread = new Thread(new Runnable() {
+            @Override
+            public void run() {
+                receiverThread();
+            }
+        });
+        try
+        {
+            thread.start();
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    private void checkReceiveImage(@NonNull DatagramPacket packet)
+    {
+        try
+        {
+            int dataLength = packet.getLength();
+            byte[] receivedData = packet.getData();
+            if (receivedData == null)
+            {
+                // 受信データが取れなかったのでいったん終了する
+                Log.v(TAG, "RECEIVED DATA IS NULL...");
+                return;
+            }
+
+            int position = 12;
+            int extensionLength = 0;
+            boolean isFinished = false;
+            if (receivedData[0] == (byte) 0x90)
+            {
+                // 先頭パケット (RTPヘッダは 12bytes + 拡張ヘッダ...)
+                //extensionLength = (receivedData[14]);
+                //extensionLength = (extensionLength * 256) + (receivedData[15]);
+                extensionLength = 16;
+                extensionLength = checkJpegStartPosition(receivedData, extensionLength) - position;
+
+            }
+            else if (receivedData[1] == (byte) 0xe0)
+            {
+                // 末尾パケット (RTPヘッダは 12bytes)
+                isFinished = true;
+            }
+            //Log.v(TAG, "RECEIVED PACKET : " + dataLength + " [" + isFinished + "] ext : " + extensionLength);
+
+            int offset = position + extensionLength;
+            receivedByteStream.write(receivedData, (position + extensionLength), (dataLength - offset));
+            if (isFinished)
+            {
+                byte[] dataArray = receivedByteStream.toByteArray();
+/*
+                {
+                    byte[] start = Arrays.copyOfRange(dataArray, 0, 32);
+                    byte[] end = Arrays.copyOfRange(dataArray, (dataArray.length - 32), dataArray.length);
+                    dump_bytes(" ST ", start);
+                    dump_bytes(" ED ", end);
+                }
+*/
+                liveViewListener.onUpdateLiveView(Arrays.copyOf(dataArray, dataArray.length), null);
+                receivedByteStream.flush();
+                //System.gc();
+            }
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    private int checkJpegStartPosition(byte[] bytes, int offset)
+    {
+        try
+        {
+            int position = offset;
+            int maxLength = bytes.length - 1;
+            while (position < maxLength)
+            {
+                if (bytes[position] == (byte) 0xff)
+                {
+                    if (bytes[position + 1] == (byte) 0xd8)
+                    {
+                        return (position);
+                    }
+                }
+                position++;
+            }
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+        return (0);
+    }
+
+    private void receiverThread()
+    {
+        int exceptionCount = 0;
+        byte[] buffer = new byte[RECEIVE_BUFFER_SIZE];
+        while (whileStreamReceive)
+        {
+            try
+            {
+                DatagramPacket receive_packet = new DatagramPacket(buffer, buffer.length);
+                if (receiveSocket != null)
+                {
+                    receiveSocket.setSoTimeout(TIMEOUT_MS);
+                    receiveSocket.receive(receive_packet);
+                    checkReceiveImage(receive_packet);
+                    exceptionCount = 0;
+                }
+                else
+                {
+                    Log.v(TAG, "receiveSocket is NULL...");
+                }
+            }
+            catch (Exception e)
+            {
+                exceptionCount++;
+                e.printStackTrace();
+                if (exceptionCount > TIMEOUT_MAX)
+                {
+                    try
+                    {
+                        //  ライブビューの送信が来なくなった... それも回数が超えた...
+                        Log.v(TAG, "LV : RETRY REQUEST");
+                        exceptionCount = 0;
+/*
+                        String reply = SimpleHttpClient.httpGet(camera.getCmdUrl() + LIVEVIEW_START_REQUEST, TIMEOUT_MS);
+                        if (!reply.contains("ok"))
+                        {
+                            Log.v(TAG, "LV : RETRY COMMAND FAIL...");
+                        }
+*/
+                    }
+                    catch (Exception ee)
+                    {
+                        ee.printStackTrace();
+                    }
+                }
+            }
+        }
+        closeReceiveSocket();
+        Log.v(TAG, "  ----- startReceiveStream() : Finished.");
+        System.gc();
+    }
+
+    public ILiveViewListener getLiveViewListener()
+    {
+        return (liveViewListener);
+    }
+
+    private void closeReceiveSocket()
+    {
+        Log.v(TAG, "closeReceiveSocket()");
+        try
+        {
+            if (receiveSocket != null)
+            {
+                Log.v(TAG, "  ----- SOCKET CLOSE -----  ");
+                receiveSocket.close();
+                receiveSocket = null;
+            }
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+}
index 4d0274f..a76b569 100644 (file)
@@ -11,6 +11,7 @@ import java.util.Map;
 public class OlympusPenRunMode implements ICameraRunMode
 {
     private final String TAG = this.toString();
+    private boolean runMode = false;
 
     @Override
     public void changeRunMode(final boolean isRecording)
@@ -18,6 +19,7 @@ public class OlympusPenRunMode implements ICameraRunMode
         final int TIMEOUT_MS = 5000;
         try
         {
+            Log.v(TAG, " changeRunMode : " + isRecording);
             final Thread thread = new Thread(new Runnable()
             {
                 @Override
@@ -28,7 +30,7 @@ public class OlympusPenRunMode implements ICameraRunMode
                     headerMap.put("User-Agent", "OlympusCameraKit"); // "OI.Share"
                     headerMap.put("X-Protocol", "OlympusCameraKit"); // "OI.Share"
 
-                    String playModeUrl = "http://192.168.0.10/switch_cameramode.cgi";
+                    String playModeUrl = "http://192.168.0.10/switch_cammode.cgi";
                     if (isRecording)
                     {
                         playModeUrl = playModeUrl + "?mode=rec";
@@ -39,6 +41,17 @@ public class OlympusPenRunMode implements ICameraRunMode
                     }
                     String response = SimpleHttpClient.httpGetWithHeader(playModeUrl, headerMap, null, TIMEOUT_MS);
                     Log.v(TAG, " " + playModeUrl + " " + response);
+                    try
+                    {
+                        if (response.contains("ok"))
+                        {
+                            runMode = isRecording;
+                        }
+                    }
+                    catch (Exception e)
+                    {
+                        e.printStackTrace();
+                    }
                 }
             });
             thread.start();
@@ -52,6 +65,6 @@ public class OlympusPenRunMode implements ICameraRunMode
     @Override
     public boolean isRecordingMode()
     {
-        return (true);
+        return (runMode);
     }
 }
diff --git a/app/src/main/java/net/osdn/gokigen/a01d/camera/olympuspen/wrapper/OlympusPenZoomLensControl.java b/app/src/main/java/net/osdn/gokigen/a01d/camera/olympuspen/wrapper/OlympusPenZoomLensControl.java
new file mode 100644 (file)
index 0000000..50ee3cb
--- /dev/null
@@ -0,0 +1,135 @@
+package net.osdn.gokigen.a01d.camera.olympuspen.wrapper;
+
+import android.util.Log;
+
+import androidx.annotation.NonNull;
+
+import net.osdn.gokigen.a01d.camera.IZoomLensControl;
+import net.osdn.gokigen.a01d.camera.panasonic.wrapper.IPanasonicCamera;
+import net.osdn.gokigen.a01d.camera.utils.SimpleHttpClient;
+
+public class OlympusPenZoomLensControl  implements IZoomLensControl
+{
+    private final String TAG = toString();
+    private IPanasonicCamera camera = null;
+    private boolean isZooming = false;
+    private static final int TIMEOUT_MS = 3000;
+
+    OlympusPenZoomLensControl()
+    {
+        Log.v(TAG, "OlympusPenZoomLensControl()");
+    }
+
+    public void setCamera(@NonNull IPanasonicCamera panasonicCamera)
+    {
+        camera = panasonicCamera;
+    }
+
+    @Override
+    public boolean canZoom() {
+        Log.v(TAG, "canZoom()");
+        return (true);
+    }
+
+    @Override
+    public void updateStatus()
+    {
+        Log.v(TAG, "updateStatus()");
+    }
+
+    @Override
+    public float getMaximumFocalLength()
+    {
+        Log.v(TAG, "getMaximumFocalLength()");
+        return (0);
+    }
+
+    @Override
+    public float getMinimumFocalLength()
+    {
+        Log.v(TAG, "getMinimumFocalLength()");
+        return (0);
+    }
+
+    @Override
+    public float getCurrentFocalLength()
+    {
+        Log.v(TAG, "getCurrentFocalLength()");
+        return (0);
+    }
+
+    @Override
+    public void driveZoomLens(float targetLength)
+    {
+        Log.v(TAG, "driveZoomLens() : " + targetLength);
+    }
+
+    @Override
+    public void moveInitialZoomPosition()
+    {
+        Log.v(TAG, "moveInitialZoomPosition()");
+    }
+
+    @Override
+    public boolean isDrivingZoomLens()
+    {
+        Log.v(TAG, "isDrivingZoomLens()");
+        return (isZooming);
+    }
+
+    /**
+     *
+     *
+     */
+    @Override
+    public void driveZoomLens(boolean isZoomIn)
+    {
+        Log.v(TAG, "driveZoomLens() : " + isZoomIn);
+        if (camera == null)
+        {
+            Log.v(TAG, "IPanasonicCameraApi is null...");
+            return;
+        }
+        try
+        {
+            String command;
+            if (isZooming)
+            {
+                command = "cam.cgi?mode=camcmd&value=zoomstop";
+            }
+            else
+            {
+                command = (isZoomIn) ? "cam.cgi?mode=camcmd&value=tele-normal" : "cam.cgi?mode=camcmd&value=wide-normal";
+            }
+            final String direction = command;
+            Thread thread = new Thread(new Runnable()
+            {
+                @Override
+                public void run()
+                {
+                    try
+                    {
+                        String reply = SimpleHttpClient.httpGet(camera.getCmdUrl() + direction, TIMEOUT_MS);
+                        if (reply.contains("ok"))
+                        {
+                            isZooming = !isZooming;
+                        }
+                        else
+                        {
+                            Log.v(TAG, "driveZoomLens() reply is failure.");
+                        }
+                    }
+                    catch (Exception e)
+                    {
+                        e.printStackTrace();
+                    }
+                }
+            });
+            thread.start();
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+}
index 019356d..8aadd20 100644 (file)
@@ -34,6 +34,7 @@ class OlympusPenCameraConnectSequence implements Runnable
         final String camInfoUrl = "http://192.168.0.10/get_caminfo.cgi";
         final String getCommandListUrl = "http://192.168.0.10/get_commandlist.cgi";
         final String getConnectModeUrl = "http://192.168.0.10/get_connectmode.cgi";
+        final String switchCameraModeUrl = "http://192.168.0.10/switch_cammode.cgi";
 
         final int TIMEOUT_MS = 5000;
         try
@@ -52,6 +53,11 @@ class OlympusPenCameraConnectSequence implements Runnable
                 String response3 = SimpleHttpClient.httpGetWithHeader(camInfoUrl, headerMap, null, TIMEOUT_MS);
                 Log.v(TAG, " " + camInfoUrl + " " + response3);
 
+                // 撮影モードに切り替え。
+                String lvUrl = switchCameraModeUrl + "?mode=rec" + "&lvqty=" + getLiveViewQuality();
+                String response4 = SimpleHttpClient.httpGetWithHeader(lvUrl, headerMap, null, TIMEOUT_MS);
+                Log.v(TAG, " " + lvUrl + " " + response4);
+
                 onConnectNotify();
             }
             else
@@ -66,6 +72,12 @@ class OlympusPenCameraConnectSequence implements Runnable
         }
     }
 
+    private String getLiveViewQuality()
+    {
+        //  ※ LV解像度をここで取得する
+        return ("0640x0480");
+    }
+
     private void onConnectNotify()
     {
         try
index a952e2e..5fa373c 100644 (file)
@@ -174,7 +174,7 @@ public class OlympusPenConnection implements ICameraConnection
     {
         Log.v(TAG, "alertConnectingFailed() : " + message);
         final AlertDialog.Builder builder = new AlertDialog.Builder(context)
-                .setTitle(context.getString(R.string.dialog_title_connect_failed))
+                .setTitle(context.getString(R.string.dialog_title_connect_failed_olympus))
                 .setMessage(message)
                 .setPositiveButton(context.getString(R.string.dialog_title_button_retry), new DialogInterface.OnClickListener() {
                     @Override
index 1876c0a..6bfb560 100644 (file)
@@ -187,7 +187,7 @@ public class PanasonicCameraConnection implements ICameraConnection
     {
         Log.v(TAG, "alertConnectingFailed() : " + message);
         final AlertDialog.Builder builder = new AlertDialog.Builder(context)
-                .setTitle(context.getString(R.string.dialog_title_connect_failed))
+                .setTitle(context.getString(R.string.dialog_title_connect_failed_panasonic))
                 .setMessage(message)
                 .setPositiveButton(context.getString(R.string.dialog_title_button_retry), new DialogInterface.OnClickListener() {
                     @Override
index b6ee7c7..0760e0f 100644 (file)
@@ -174,7 +174,7 @@ public class RicohGr2Connection implements ICameraConnection
     {
         Log.v(TAG, "alertConnectingFailed() : " + message);
         final AlertDialog.Builder builder = new AlertDialog.Builder(context)
-                .setTitle(context.getString(R.string.dialog_title_connect_failed))
+                .setTitle(context.getString(R.string.dialog_title_connect_failed_ricoh))
                 .setMessage(message)
                 .setPositiveButton(context.getString(R.string.dialog_title_button_retry), new DialogInterface.OnClickListener() {
                     @Override
index 5df4aac..69cc892 100644 (file)
@@ -187,7 +187,7 @@ public class SonyCameraConnection implements ICameraConnection
     {
         Log.v(TAG, "alertConnectingFailed() : " + message);
         final AlertDialog.Builder builder = new AlertDialog.Builder(context)
-                .setTitle(context.getString(R.string.dialog_title_connect_failed))
+                .setTitle(context.getString(R.string.dialog_title_connect_failed_sony))
                 .setMessage(message)
                 .setPositiveButton(context.getString(R.string.dialog_title_button_retry), new DialogInterface.OnClickListener() {
                     @Override
diff --git a/app/src/main/java/net/osdn/gokigen/a01d/camera/utils/SimpleLogDumper.java b/app/src/main/java/net/osdn/gokigen/a01d/camera/utils/SimpleLogDumper.java
new file mode 100644 (file)
index 0000000..35184fe
--- /dev/null
@@ -0,0 +1,78 @@
+package net.osdn.gokigen.a01d.camera.utils;
+
+import android.app.Activity;
+import android.os.Environment;
+import android.util.Log;
+
+import androidx.annotation.NonNull;
+
+import net.osdn.gokigen.a01d.R;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Locale;
+
+public class SimpleLogDumper
+{
+    private static final String TAG = SimpleLogDumper.class.getSimpleName();
+
+    /**
+     *   デバッグ用:ログにバイト列を出力する
+     *
+     */
+    public static void dump_bytes(String header, byte[] data)
+    {
+        if (data == null)
+        {
+            Log.v(TAG, "DATA IS NULL");
+            return;
+        }
+        if (data.length > 8192)
+        {
+            Log.v(TAG, " --- DUMP DATA IS TOO LONG... " + data.length + " bytes.");
+            return;
+        }
+
+        int index = 0;
+        StringBuffer message;
+        message = new StringBuffer();
+        for (byte item : data)
+        {
+            index++;
+            message.append(String.format("%02x ", item));
+            if (index >= 16)
+            {
+                Log.v(TAG, header + " " + message);
+                index = 0;
+                message = new StringBuffer();
+            }
+        }
+        if (index != 0)
+        {
+            Log.v(TAG, header + " " + message);
+        }
+        System.gc();
+    }
+
+    public static void binaryOutputToFile(@NonNull Activity activity, String fileNamePrefix, byte[] rx_body)
+    {
+        try
+        {
+            Calendar calendar = Calendar.getInstance();
+            String extendName = new SimpleDateFormat("yyyyMMdd-HHmmss", Locale.getDefault()).format(calendar.getTime());
+            final String directoryPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).getPath() + "/" + activity.getString(R.string.app_name2) + "/";
+            String outputFileName = fileNamePrefix + "_" + extendName + ".bin";
+            String filepath = new File(directoryPath.toLowerCase(), outputFileName.toLowerCase()).getPath();
+            FileOutputStream outputStream = new FileOutputStream(filepath);
+            outputStream.write(rx_body, 0, rx_body.length);
+            outputStream.flush();
+            outputStream.close();
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+}
index 1d888da..a19a5a9 100644 (file)
@@ -88,6 +88,15 @@ 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.OPC)
         {
             this.focusingControl = interfaceProvider.getOlympusInterface().getFocusingControl();
index 1c57c3a..00237b9 100644 (file)
@@ -295,6 +295,32 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
                         propertyButton.setOnClickListener(onClickTouchListener);
                     }
                 }
+                else if (connectionMethod == ICameraConnection.CameraConnectionMethod.OLYMPUS)
+                {
+                    /*
+                    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.VISIBLE);
+                    }
+                    if (propertyButton != null)
+                    {
+                        propertyButton.setOnClickListener(onClickTouchListener);
+                    }
+                    */
+                }
             }
             if (manualFocus != null)
             {
@@ -352,6 +378,10 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
         {
             interfaceInjector = interfaceProvider.getPanasonicInterface().getDisplayInjector();
         }
+        else if (connectionMethod == ICameraConnection.CameraConnectionMethod.OLYMPUS)
+        {
+            interfaceInjector = interfaceProvider.getOlympusPenInterface().getDisplayInjector();
+        }
         else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
         {
             interfaceInjector = interfaceProvider.getOlympusInterface().getDisplayInjector();
@@ -384,6 +414,12 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
             this.zoomLensControl = interfaceProvider.getPanasonicInterface().getZoomLensControl();
             this.cameraInformation = interfaceProvider.getPanasonicInterface().getCameraInformation();
         }
+        else  if (connectionMethod == ICameraConnection.CameraConnectionMethod.OLYMPUS)
+        {
+            this.liveViewControl = interfaceProvider.getOlympusPenInterface().getLiveViewControl();
+            this.zoomLensControl = interfaceProvider.getOlympusPenInterface().getZoomLensControl();
+            this.cameraInformation = interfaceProvider.getOlympusPenInterface().getCameraInformation();
+        }
         else //  if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
         {
             this.liveViewControl = interfaceProvider.getOlympusInterface().getLiveViewControl();
@@ -682,6 +718,10 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
             {
                 lvListener = interfaceProvider.getPanasonicInterface().getLiveViewListener();
             }
+            else if (connectionMethod == ICameraConnection.CameraConnectionMethod.OLYMPUS)
+            {
+                lvListener = interfaceProvider.getOlympusPenInterface().getLiveViewListener();
+            }
             else  // if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
             {
                 interfaceProvider.getOlympusLiveViewListener().setOlympusLiveViewListener(liveViewListener);
index 204924b..a82b0a8 100644 (file)
@@ -12,6 +12,8 @@ public interface IPreferencePropertyAccessor
     String AUTO_CONNECT_TO_CAMERA = "auto_connect_to_camera";
     String BLE_POWER_ON = "ble_power_on";
 
+    String WIFI_SETTINGS = "wifi_settings";
+
     String TAKE_MODE =  "take_mode";
     String TAKE_MODE_DEFAULT_VALUE =  "P";
 
index e67a6ee..4043c13 100644 (file)
@@ -1,8 +1,10 @@
 package net.osdn.gokigen.a01d.preference.fujix;
 
 import android.content.Context;
+import android.content.Intent;
 import android.content.SharedPreferences;
 import android.os.Bundle;
+import android.provider.Settings;
 import android.util.Log;
 
 import net.osdn.gokigen.a01d.IChangeScene;
@@ -22,13 +24,16 @@ import androidx.preference.Preference;
 import androidx.preference.PreferenceFragmentCompat;
 import androidx.preference.PreferenceManager;
 
+import static net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor.WIFI_SETTINGS;
+
 /**
  *
  *
  */
-public class FujiXPreferenceFragment  extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener
+public class FujiXPreferenceFragment  extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener, Preference.OnPreferenceClickListener
 {
     private final String TAG = toString();
+    private AppCompatActivity context = null;
     private SharedPreferences preferences = null;
     private CameraPowerOffFujiX powerOffController = null;
     private LogCatViewer logCatViewer = null;
@@ -64,6 +69,8 @@ public class FujiXPreferenceFragment  extends PreferenceFragmentCompat implement
 
             logCatViewer = new LogCatViewer(changeScene);
             logCatViewer.prepare();
+
+            this.context = context;
         }
         catch (Exception e)
         {
@@ -206,7 +213,8 @@ public class FujiXPreferenceFragment  extends PreferenceFragmentCompat implement
 
             findPreference("exit_application").setOnPreferenceClickListener(powerOffController);
             findPreference("debug_info").setOnPreferenceClickListener(logCatViewer);
-    }
+            findPreference(WIFI_SETTINGS).setOnPreferenceClickListener(this);
+        }
         catch (Exception e)
         {
             e.printStackTrace();
@@ -337,4 +345,27 @@ public class FujiXPreferenceFragment  extends PreferenceFragmentCompat implement
         }
     }
 
+    @Override
+    public boolean onPreferenceClick(Preference preference)
+    {
+        try
+        {
+            String preferenceKey = preference.getKey();
+            if (preferenceKey.contains(WIFI_SETTINGS))
+            {
+                // Wifi 設定画面を表示する
+                Log.v(TAG, " onPreferenceClick : " + preferenceKey);
+                if (context != null)
+                {
+                    context.startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
+                }
+            }
+            return (true);
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+        return (false);
+    }
 }
index 94c4e86..d6d37ac 100644 (file)
@@ -3,8 +3,10 @@ package net.osdn.gokigen.a01d.preference.olympus;
 
 import android.app.ProgressDialog;
 import android.content.Context;
+import android.content.Intent;
 import android.content.SharedPreferences;
 import android.os.Bundle;
+import android.provider.Settings;
 import android.util.Log;
 
 import net.osdn.gokigen.a01d.IChangeScene;
@@ -33,14 +35,17 @@ import androidx.preference.PreferenceFragmentCompat;
 import androidx.preference.PreferenceManager;
 import jp.co.olympus.camerakit.OLYCamera;
 
+import static net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor.WIFI_SETTINGS;
+
 
 /**
  *   SettingFragment
  *
  */
-public class PreferenceFragment extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener, PreferenceSynchronizer.IPropertySynchronizeCallback
+public class PreferenceFragment extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener, PreferenceSynchronizer.IPropertySynchronizeCallback, Preference.OnPreferenceClickListener
 {
     private final String TAG = toString();
+    private AppCompatActivity context = null;
     private IOlyCameraPropertyProvider propertyInterface = null;
     private ICameraHardwareStatus hardwareStatusInterface = null;
     private ICameraRunMode changeRunModeExecutor = null;
@@ -83,6 +88,8 @@ public class PreferenceFragment extends PreferenceFragmentCompat implements Shar
         powerOnSelector.prepare();
         logCatViewer = new LogCatViewer(changeScene);
         logCatViewer.prepare();
+
+        this.context = context;
     }
 
     /**
@@ -179,6 +186,7 @@ public class PreferenceFragment extends PreferenceFragmentCompat implements Shar
         //super.onCreate(savedInstanceState);
         addPreferencesFromResource(R.xml.preferences);
 
+        try
         {
             final HashMap<String, String> sizeTable = new HashMap<>();
             sizeTable.put("QVGA", "(320x240)");
@@ -237,10 +245,16 @@ public class PreferenceFragment extends PreferenceFragmentCompat implements Shar
                 }
             });
             connectionMethod.setSummary(connectionMethod.getValue() + " ");
+
+            findPreference("exit_application").setOnPreferenceClickListener(powerOffController);
+            findPreference("olympus_air_bt").setOnPreferenceClickListener(powerOnSelector);
+            findPreference("debug_info").setOnPreferenceClickListener(logCatViewer);
+            findPreference(WIFI_SETTINGS).setOnPreferenceClickListener(this);
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
         }
-        findPreference("exit_application").setOnPreferenceClickListener(powerOffController);
-        findPreference("olympus_air_bt").setOnPreferenceClickListener(powerOnSelector);
-        findPreference("debug_info").setOnPreferenceClickListener(logCatViewer);
     }
 
     /**
@@ -531,4 +545,27 @@ public class PreferenceFragment extends PreferenceFragmentCompat implements Shar
         });
     }
 
+    @Override
+    public boolean onPreferenceClick(Preference preference)
+    {
+        try
+        {
+            String preferenceKey = preference.getKey();
+            if (preferenceKey.contains(WIFI_SETTINGS))
+            {
+                // Wifi 設定画面を表示する
+                Log.v(TAG, " onPreferenceClick : " + preferenceKey);
+                if (context != null)
+                {
+                    context.startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
+                }
+            }
+            return (true);
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+        return (false);
+    }
 }
index 5000d34..aaf4bf7 100644 (file)
@@ -1,8 +1,10 @@
 package net.osdn.gokigen.a01d.preference.olympuspen;
 
 import android.content.Context;
+import android.content.Intent;
 import android.content.SharedPreferences;
 import android.os.Bundle;
+import android.provider.Settings;
 import android.util.Log;
 
 import androidx.annotation.NonNull;
@@ -22,13 +24,16 @@ import net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor;
 
 import java.util.Map;
 
+import static net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor.WIFI_SETTINGS;
+
 /**
  *
  *
  */
-public class OlympusPreferenceFragment extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener
+public class OlympusPreferenceFragment extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener, Preference.OnPreferenceClickListener
 {
     private final String TAG = toString();
+    private AppCompatActivity context = null;
     private SharedPreferences preferences = null;
     private OlympusPenCameraPowerOff powerOffController = null;
     private LogCatViewer logCatViewer = null;
@@ -68,6 +73,8 @@ public class OlympusPreferenceFragment extends PreferenceFragmentCompat implemen
 
             //cameraApiListViewer = new PanasonicCameraApiListViewer(changeScene);
             //cameraApiListViewer.prepare();
+
+            this.context = context;
         }
         catch (Exception e)
         {
@@ -186,6 +193,7 @@ public class OlympusPreferenceFragment extends PreferenceFragmentCompat implemen
             findPreference("exit_application").setOnPreferenceClickListener(powerOffController);
             findPreference("debug_info").setOnPreferenceClickListener(logCatViewer);
             //findPreference("panasonic_api_list").setOnPreferenceClickListener(cameraApiListViewer);
+            findPreference(WIFI_SETTINGS).setOnPreferenceClickListener(this);
         }
         catch (Exception e)
         {
@@ -316,4 +324,28 @@ public class OlympusPreferenceFragment extends PreferenceFragmentCompat implemen
         }
     }
 
+    @Override
+    public boolean onPreferenceClick(Preference preference)
+    {
+        try
+        {
+            String preferenceKey = preference.getKey();
+            if (preferenceKey.contains(WIFI_SETTINGS))
+            {
+                // Wifi 設定画面を表示する
+                Log.v(TAG, " onPreferenceClick : " + preferenceKey);
+                if (context != null)
+                {
+                    context.startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
+                }
+            }
+            return (true);
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+        return (false);
+    }
+
 }
index caba594..45038be 100644 (file)
@@ -1,8 +1,10 @@
 package net.osdn.gokigen.a01d.preference.panasonic;
 
 import android.content.Context;
+import android.content.Intent;
 import android.content.SharedPreferences;
 import android.os.Bundle;
+import android.provider.Settings;
 import android.util.Log;
 
 import net.osdn.gokigen.a01d.IChangeScene;
@@ -22,13 +24,16 @@ import androidx.preference.Preference;
 import androidx.preference.PreferenceFragmentCompat;
 import androidx.preference.PreferenceManager;
 
+import static net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor.WIFI_SETTINGS;
+
 /**
  *
  *
  */
-public class PanasonicPreferenceFragment  extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener
+public class PanasonicPreferenceFragment  extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener, Preference.OnPreferenceClickListener
 {
     private final String TAG = toString();
+    private AppCompatActivity context = null;
     private SharedPreferences preferences = null;
     private CameraPowerOffPanasonic powerOffController = null;
     private LogCatViewer logCatViewer = null;
@@ -68,6 +73,8 @@ public class PanasonicPreferenceFragment  extends PreferenceFragmentCompat imple
 
             //cameraApiListViewer = new PanasonicCameraApiListViewer(changeScene);
             //cameraApiListViewer.prepare();
+
+            this.context = context;
         }
         catch (Exception e)
         {
@@ -186,6 +193,7 @@ public class PanasonicPreferenceFragment  extends PreferenceFragmentCompat imple
             findPreference("exit_application").setOnPreferenceClickListener(powerOffController);
             findPreference("debug_info").setOnPreferenceClickListener(logCatViewer);
             //findPreference("panasonic_api_list").setOnPreferenceClickListener(cameraApiListViewer);
+            findPreference(WIFI_SETTINGS).setOnPreferenceClickListener(this);
         }
         catch (Exception e)
         {
@@ -316,4 +324,29 @@ public class PanasonicPreferenceFragment  extends PreferenceFragmentCompat imple
         }
     }
 
+
+    @Override
+    public boolean onPreferenceClick(Preference preference)
+    {
+        try
+        {
+            String preferenceKey = preference.getKey();
+            if (preferenceKey.contains(WIFI_SETTINGS))
+            {
+                // Wifi 設定画面を表示する
+                Log.v(TAG, " onPreferenceClick : " + preferenceKey);
+                if (context != null)
+                {
+                    context.startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
+                }
+            }
+            return (true);
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+        return (false);
+    }
+
 }
index cce969b..bfedf38 100644 (file)
@@ -2,8 +2,10 @@ package net.osdn.gokigen.a01d.preference.ricohgr2;
 
 
 import android.content.Context;
+import android.content.Intent;
 import android.content.SharedPreferences;
 import android.os.Bundle;
+import android.provider.Settings;
 import android.util.Log;
 
 import net.osdn.gokigen.a01d.IChangeScene;
@@ -23,9 +25,12 @@ import androidx.preference.Preference;
 import androidx.preference.PreferenceFragmentCompat;
 import androidx.preference.PreferenceManager;
 
-public class RicohGr2PreferenceFragment  extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener
+import static net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor.WIFI_SETTINGS;
+
+public class RicohGr2PreferenceFragment  extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener, Preference.OnPreferenceClickListener
 {
     private final String TAG = toString();
+    private AppCompatActivity context = null;
     private SharedPreferences preferences = null;
     private CameraPowerOffRicohGr2 powerOffController = null;
     private LogCatViewer logCatViewer = null;
@@ -61,6 +66,8 @@ public class RicohGr2PreferenceFragment  extends PreferenceFragmentCompat implem
 
             logCatViewer = new LogCatViewer(changeScene);
             logCatViewer.prepare();
+
+            this.context = context;
         }
         catch (Exception e)
         {
@@ -215,6 +222,7 @@ public class RicohGr2PreferenceFragment  extends PreferenceFragmentCompat implem
 
             findPreference("exit_application").setOnPreferenceClickListener(powerOffController);
             findPreference("debug_info").setOnPreferenceClickListener(logCatViewer);
+            findPreference(WIFI_SETTINGS).setOnPreferenceClickListener(this);
         }
         catch (Exception e)
         {
@@ -347,4 +355,29 @@ public class RicohGr2PreferenceFragment  extends PreferenceFragmentCompat implem
             });
         }
     }
+
+
+    @Override
+    public boolean onPreferenceClick(Preference preference)
+    {
+        try
+        {
+            String preferenceKey = preference.getKey();
+            if (preferenceKey.contains(WIFI_SETTINGS))
+            {
+                // Wifi 設定画面を表示する
+                Log.v(TAG, " onPreferenceClick : " + preferenceKey);
+                if (context != null)
+                {
+                    context.startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
+                }
+            }
+            return (true);
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+        return (false);
+    }
 }
index 7322cf1..425f026 100644 (file)
@@ -1,8 +1,10 @@
 package net.osdn.gokigen.a01d.preference.sony;
 
 import android.content.Context;
+import android.content.Intent;
 import android.content.SharedPreferences;
 import android.os.Bundle;
+import android.provider.Settings;
 import android.util.Log;
 
 import net.osdn.gokigen.a01d.IChangeScene;
@@ -23,13 +25,16 @@ import androidx.preference.Preference;
 import androidx.preference.PreferenceFragmentCompat;
 import androidx.preference.PreferenceManager;
 
+import static net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor.WIFI_SETTINGS;
+
 /**
  *
  *
  */
-public class SonyPreferenceFragment  extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener
+public class SonyPreferenceFragment  extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener, Preference.OnPreferenceClickListener
 {
     private final String TAG = toString();
+    private AppCompatActivity context = null;
     private SharedPreferences preferences = null;
     private CameraPowerOffSony powerOffController = null;
     private LogCatViewer logCatViewer = null;
@@ -70,6 +75,8 @@ public class SonyPreferenceFragment  extends PreferenceFragmentCompat implements
 
             cameraApiListViewer = new SonyCameraApiListViewer(changeScene);
             cameraApiListViewer.prepare();
+
+            this.context = context;
         }
         catch (Exception e)
         {
@@ -188,6 +195,7 @@ public class SonyPreferenceFragment  extends PreferenceFragmentCompat implements
             findPreference("exit_application").setOnPreferenceClickListener(powerOffController);
             findPreference("debug_info").setOnPreferenceClickListener(logCatViewer);
             findPreference("sony_api_list").setOnPreferenceClickListener(cameraApiListViewer);
+            findPreference(WIFI_SETTINGS).setOnPreferenceClickListener(this);
         }
         catch (Exception e)
         {
@@ -318,4 +326,27 @@ public class SonyPreferenceFragment  extends PreferenceFragmentCompat implements
         }
     }
 
+    @Override
+    public boolean onPreferenceClick(Preference preference)
+    {
+        try
+        {
+            String preferenceKey = preference.getKey();
+            if (preferenceKey.contains(WIFI_SETTINGS))
+            {
+                // Wifi 設定画面を表示する
+                Log.v(TAG, " onPreferenceClick : " + preferenceKey);
+                if (context != null)
+                {
+                    context.startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
+                }
+            }
+            return (true);
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+        return (false);
+    }
 }
index 83bd31e..c2f4f59 100644 (file)
 
     <string-array name="connection_method">
         <item >OPC (Olympus Air)</item>
+        <item >Olympus Pen/OM-D</item>
         <item >Sony</item>
-        <item>Ricoh GR Series / PENTAX</item>
+        <item >Ricoh GR Series / PENTAX</item>
         <item >Fuji X Series</item>
         <item >Panasonic</item>
-        <item >Olympus Pen/OM-D</item>
     </string-array>
 
     <string-array name="connection_method_value">
         <item >OPC</item>
+        <item >OLYMPUS</item>
         <item >SONY</item>
         <item >RICOH_GR2</item>
         <item >FUJI_X</item>
         <item >PANASONIC</item>
-        <item >OLYMPUS</item>
     </string-array>
 
 
index b5259aa..737abf8 100644 (file)
@@ -70,6 +70,9 @@
     <string name="pref_instruction_manual">操作説明</string>
     <string name="pref_privacy_policy">プライバシーポリシー</string>
 
+    <string name="pref_wifi_settings">WiFi設定</string>
+    <string name="pref_summary_wifi_settings"> </string>
+
     <string name="information"> </string>
     <string name="favorite">お気に入り</string>
     <string name="preferences">設定</string>
     <string name="dialog_start_load_property_title">カメラプロパティ設定中</string>
     <string name="dialog_title_button_network_settings">WiFi設定</string>
     <string name="dialog_title_button_retry">再試行</string>
-    <string name="dialog_title_connect_failed">接続失敗</string>
+    <string name="dialog_title_connect_failed_ricoh">接続失敗(RICOH)</string>
+    <string name="dialog_title_connect_failed_opc">接続失敗(OPC)</string>
+    <string name="dialog_title_connect_failed_olympus">接続失敗(Olympus)</string>
+    <string name="dialog_title_connect_failed_panasonic">接続失敗(PANASONIC)</string>
+    <string name="dialog_title_connect_failed_sony">接続失敗(SONY)</string>
+    <string name="dialog_title_connect_failed_fuji">接続失敗(FUJI)</string>
     <string name="fatal_cannot_use_camera">Olympus Camera Kitが動作しないモードのため、カメラのリセットが必要です。電源ボタンを8秒以上長押しして、カメラをリセットしてください。</string>
     <string name="network_connection_timeout">接続タイムアウト</string>
     <string name="restored_my_props">設定を展開しました。 : </string>
     <string name="connect_connecting11">接続中&#8230;(11/12)</string>
     <string name="connect_connecting12">接続中&#8230;(12/12)</string>
     <string name="connect_connect_finished">カメラと接続</string>
-    <string name="connect_error_message">接続失敗</string>
+
+    <string name="connect_error_message_olympus">接続失敗 (OLYMPUS)</string>
+    <string name="connect_error_message_fuji">接続失敗 (FUJI)</string>
 
 </resources>
index be9df74..ec56d18 100644 (file)
 
     <string-array name="connection_method">
         <item >OPC (Olympus Air)</item>
+        <item >Olympus Pen/OM-D</item>
         <item >Sony</item>
-        <item>Ricoh GR Series / PENTAX</item>
+        <item >Ricoh GR Series / PENTAX</item>
         <item >Fuji X Series</item>
         <item >Panasonic</item>
-        <item >Olympus Pen/OM-D</item>
     </string-array>
 
     <string-array name="connection_method_value">
         <item >OPC</item>
+        <item >OLYMPUS</item>
         <item >SONY</item>
         <item >RICOH_GR2</item>
         <item >FUJI_X</item>
         <item >PANASONIC</item>
-        <item >OLYMPUS</item>
     </string-array>
 
     <string-array name="gr2_display_mode">
index 6f3a545..cdd2903 100644 (file)
     <string name="pref_instruction_manual">A01d Instructions</string>
     <string name="pref_privacy_policy">Privacy Policy</string>
 
+    <string name="pref_wifi_settings">WIFI Settings</string>
+    <string name="pref_summary_wifi_settings"> </string>
+
     <string name="information"> </string>
     <string name="favorite">Favorite</string>
     <string name="preferences">Preferences</string>
     <string name="grid">Grid</string>
 
     <string name="network_connection_timeout">Connection time out</string>
-    <string name="dialog_title_connect_failed">Connect failed</string>
+    <string name="dialog_title_connect_failed_ricoh">Connect failed (RICOH)</string>
+    <string name="dialog_title_connect_failed_opc">Connect failed (OPC)</string>
+    <string name="dialog_title_connect_failed_olympus">Connect failed (Olympus)</string>
+    <string name="dialog_title_connect_failed_panasonic">Connect failed (PANASONIC)</string>
+    <string name="dialog_title_connect_failed_sony">Connect failed (SONY)</string>
+    <string name="dialog_title_connect_failed_fuji">Connect failed (FUJI)</string>
     <string name="dialog_title_button_retry">Retry</string>
     <string name="dialog_title_button_network_settings">WiFi Settings</string>
 
     <string name="connect_connecting11">Connecting&#8230;(11/12)</string>
     <string name="connect_connecting12">Connecting&#8230;(12/12)</string>
     <string name="connect_connect_finished">Connect Finished.</string>
-    <string name="connect_error_message">CONNECTION ERROR</string>
+
+    <string name="connect_error_message_olympus">CONNECTION ERROR (OLYMPUS)</string>
+    <string name="connect_error_message_fuji">CONNECTION ERROR (FUJI)</string>
+
 </resources>
index 7b23ed5..f68d92e 100644 (file)
             android:key="connection_method"
             android:defaultValue="OPC"/>
 
+        <PreferenceScreen
+            android:key="wifi_settings"
+            android:title="@string/pref_wifi_settings"
+            android:summary="@string/pref_summary_wifi_settings" />
+
     </PreferenceCategory>
 
     <PreferenceCategory
index bc8ce82..8c3fc4c 100644 (file)
             android:key="connection_method"
             android:defaultValue="OPC"/>
 
+        <PreferenceScreen
+            android:key="wifi_settings"
+            android:title="@string/pref_wifi_settings"
+            android:summary="@string/pref_summary_wifi_settings" />
+
     </PreferenceCategory>
 
     <PreferenceCategory
index 7f3aee6..ffdcb6a 100644 (file)
             android:key="connection_method"
             android:defaultValue="OPC"/>
 
+        <PreferenceScreen
+            android:key="wifi_settings"
+            android:title="@string/pref_wifi_settings"
+            android:summary="@string/pref_summary_wifi_settings" />
+
     </PreferenceCategory>
 
     <PreferenceCategory
index a807ebd..08ae615 100644 (file)
             android:key="connection_method"
             android:defaultValue="OPC"/>
 
+        <PreferenceScreen
+            android:key="wifi_settings"
+            android:title="@string/pref_wifi_settings"
+            android:summary="@string/pref_summary_wifi_settings" />
+
     </PreferenceCategory>
 
     <PreferenceCategory
index a0e0a87..5c9e186 100644 (file)
             android:key="connection_method"
             android:defaultValue="OPC"/>
 
+        <PreferenceScreen
+            android:key="wifi_settings"
+            android:title="@string/pref_wifi_settings"
+            android:summary="@string/pref_summary_wifi_settings" />
+
     </PreferenceCategory>
 
     <PreferenceCategory
index bdaaf13..bcf6050 100644 (file)
             android:key="connection_method"
             android:defaultValue="OPC"/>
 
+        <PreferenceScreen
+            android:key="wifi_settings"
+            android:title="@string/pref_wifi_settings"
+            android:summary="@string/pref_summary_wifi_settings" />
+
     </PreferenceCategory>
 
     <PreferenceCategory