OSDN Git Service

コマンド送信ダイアログの実装まで。(未確認)
authorMRSa <mrsa@myad.jp>
Wed, 29 Jan 2020 15:17:07 +0000 (00:17 +0900)
committerMRSa <mrsa@myad.jp>
Wed, 29 Jan 2020 15:17:07 +0000 (00:17 +0900)
14 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/ptpip/operation/PtpIpCameraCommandResponse.java [new file with mode: 0644]
app/src/main/java/net/osdn/gokigen/a01d/camera/ptpip/operation/PtpIpCameraCommandSendDialog.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/res/layout-land/ptpip_request_command_layout.xml [new file with mode: 0644]
app/src/main/res/layout/ptpip_request_command_layout.xml [new file with mode: 0644]
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

index 271b23e..7d01a82 100644 (file)
@@ -3,13 +3,10 @@ package net.osdn.gokigen.a01d;
 import android.Manifest;
 import android.content.SharedPreferences;
 import android.content.pm.PackageManager;
-import android.graphics.Color;
-import android.graphics.Typeface;
 import android.os.Bundle;
 import android.util.Log;
 import android.view.KeyEvent;
 import android.view.WindowManager;
-import android.widget.TextView;
 
 import net.osdn.gokigen.a01d.camera.CameraInterfaceProvider;
 import net.osdn.gokigen.a01d.camera.IInterfaceProvider;
@@ -18,6 +15,7 @@ import net.osdn.gokigen.a01d.camera.olympus.cameraproperty.OlyCameraPropertyList
 import net.osdn.gokigen.a01d.camera.ICameraStatusReceiver;
 import net.osdn.gokigen.a01d.camera.ICameraConnection;
 import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.ble.ICameraPowerOn;
+import net.osdn.gokigen.a01d.camera.ptpip.operation.PtpIpCameraCommandSendDialog;
 import net.osdn.gokigen.a01d.camera.utils.SimpleHttpSendCommandDialog;
 import net.osdn.gokigen.a01d.camera.panasonic.operation.PanasonicSendCommandDialog;
 import net.osdn.gokigen.a01d.camera.ricohgr2.operation.RicohGr2SendCommandDialog;
@@ -26,6 +24,7 @@ import net.osdn.gokigen.a01d.liveview.IStatusViewDrawer;
 import net.osdn.gokigen.a01d.liveview.LiveViewFragment;
 import net.osdn.gokigen.a01d.logcat.LogCatFragment;
 import net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor;
+import net.osdn.gokigen.a01d.preference.canon.CanonPreferenceFragment;
 import net.osdn.gokigen.a01d.preference.fujix.FujiXPreferenceFragment;
 import net.osdn.gokigen.a01d.preference.olympus.PreferenceFragment;
 import net.osdn.gokigen.a01d.preference.panasonic.PanasonicPreferenceFragment;
@@ -140,7 +139,7 @@ public class A01dMain extends AppCompatActivity implements ICameraStatusReceiver
     {
         try
         {
-            interfaceProvider = new CameraInterfaceProvider(this, this);
+            interfaceProvider = new CameraInterfaceProvider(this, this, this);
         }
         catch (Exception e)
         {
@@ -302,6 +301,18 @@ public class A01dMain extends AppCompatActivity implements ICameraStatusReceiver
                     e.printStackTrace();
                 }
             }
+            else if (method == ICameraConnection.CameraConnectionMethod.CANON)
+            {
+                try
+                {
+                    // CANON の場合は、PTPIPコマンド送信ダイアログを表示する
+                    PtpIpCameraCommandSendDialog.newInstance(interfaceProvider.getCanonInterface(), true).show(getSupportFragmentManager(), "ptpipSendCommandDialog");
+                }
+                catch (Exception e)
+                {
+                    e.printStackTrace();
+                }
+            }
             else
             {
                 // OPC カメラの場合...
@@ -355,6 +366,8 @@ public class A01dMain extends AppCompatActivity implements ICameraStatusReceiver
                         preferenceFragment = FujiXPreferenceFragment.newInstance(this, this);
                     } else if (connectionMethod == ICameraConnection.CameraConnectionMethod.THETA) {
                         preferenceFragment = ThetaPreferenceFragment.newInstance(this, this);
+                    } else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON) {
+                        preferenceFragment = CanonPreferenceFragment.newInstance(this, this);
                     } else //  if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
                     {
                         preferenceFragment = PreferenceFragment.newInstance(this, interfaceProvider, this);
@@ -648,6 +661,10 @@ public class A01dMain extends AppCompatActivity implements ICameraStatusReceiver
         {
             connection = interfaceProvider.getThetaInterface().getCameraConnection();
         }
+        else if  (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
+        {
+            connection = interfaceProvider.getCanonInterface().getCameraConnection();
+        }
         else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
         {
             connection = interfaceProvider.getOlympusInterface().getOlyCameraConnection();
index edc7860..fbc6ca8 100644 (file)
@@ -3,8 +3,11 @@ package net.osdn.gokigen.a01d.camera;
 import android.app.Activity;
 import android.content.SharedPreferences;
 
+import net.osdn.gokigen.a01d.IInformationReceiver;
+import net.osdn.gokigen.a01d.camera.canon.wrapper.CanonInterfaceProvider;
 import net.osdn.gokigen.a01d.camera.fujix.IFujiXInterfaceProvider;
 import net.osdn.gokigen.a01d.camera.fujix.wrapper.FujiXInterfaceProvider;
+import net.osdn.gokigen.a01d.camera.nikon.wrapper.NikonInterfaceProvider;
 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;
@@ -12,6 +15,7 @@ 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.ptpip.IPtpIpInterfaceProvider;
 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;
@@ -34,9 +38,11 @@ public class CameraInterfaceProvider implements IInterfaceProvider
     private final FujiXInterfaceProvider fujiX;
     private final PanasonicCameraWrapper panasonic;
     private final ThetaInterfaceProvider theta;
+    private final CanonInterfaceProvider canon;
+    private final NikonInterfaceProvider nikon;
     private final CameraStatusListener statusListener;
 
-    public CameraInterfaceProvider(@NonNull Activity context, @NonNull ICameraStatusReceiver provider)
+    public CameraInterfaceProvider(@NonNull Activity context, @NonNull ICameraStatusReceiver provider, @NonNull IInformationReceiver informationReceiver)
     {
         this.context = context;
         this.statusListener = new CameraStatusListener();
@@ -47,6 +53,8 @@ public class CameraInterfaceProvider implements IInterfaceProvider
         panasonic = new PanasonicCameraWrapper(context, provider, statusListener);
         ricohGr2 = new RicohGr2InterfaceProvider(context, provider);
         theta = new ThetaInterfaceProvider(context, provider, statusListener);
+        canon = new CanonInterfaceProvider(context, provider, statusListener, informationReceiver);
+        nikon = new NikonInterfaceProvider(context, provider, statusListener, informationReceiver);
     }
 
     @Override
@@ -99,6 +107,18 @@ public class CameraInterfaceProvider implements IInterfaceProvider
     }
 
     @Override
+    public IPtpIpInterfaceProvider getCanonInterface()
+    {
+        return (canon);
+    }
+
+    @Override
+    public IPtpIpInterfaceProvider getNikonInterface()
+    {
+        return (nikon);
+    }
+
+    @Override
     public IOlympusPenInterfaceProvider getOlympusPenInterface()
     {
         return (olympusPen);
@@ -146,6 +166,10 @@ public class CameraInterfaceProvider implements IInterfaceProvider
             {
                 ret = ICameraConnection.CameraConnectionMethod.THETA;
             }
+            else if (connectionMethod.contains("CANON"))
+            {
+                ret = ICameraConnection.CameraConnectionMethod.CANON;
+            }
         }
         catch (Exception e)
         {
index abf0c25..29e9d7d 100644 (file)
@@ -17,6 +17,7 @@ public interface ICameraConnection
         PANASONIC,
         OLYMPUS,
         THETA,
+        CANON,
     }
 
     enum CameraConnectionStatus
index 209239a..cd45b3a 100644 (file)
@@ -5,6 +5,7 @@ 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.ptpip.IPtpIpInterfaceProvider;
 import net.osdn.gokigen.a01d.camera.ricohgr2.IRicohGr2InterfaceProvider;
 import net.osdn.gokigen.a01d.camera.sony.ISonyInterfaceProvider;
 import net.osdn.gokigen.a01d.camera.theta.IThetaInterfaceProvider;
@@ -24,6 +25,8 @@ public interface IInterfaceProvider
     IRicohGr2InterfaceProvider getRicohGr2Infterface();
     IFujiXInterfaceProvider getFujiXInterface();
     IPanasonicInterfaceProvider getPanasonicInterface();
+    IPtpIpInterfaceProvider getCanonInterface();
+    IPtpIpInterfaceProvider getNikonInterface();
 
     IOlympusPenInterfaceProvider getOlympusPenInterface();
 
diff --git a/app/src/main/java/net/osdn/gokigen/a01d/camera/ptpip/operation/PtpIpCameraCommandResponse.java b/app/src/main/java/net/osdn/gokigen/a01d/camera/ptpip/operation/PtpIpCameraCommandResponse.java
new file mode 100644 (file)
index 0000000..cb21d7b
--- /dev/null
@@ -0,0 +1,96 @@
+package net.osdn.gokigen.a01d.camera.ptpip.operation;
+
+
+import android.app.Activity;
+import android.util.Log;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+
+import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpCommandCallback;
+
+class PtpIpCameraCommandResponse  implements IPtpIpCommandCallback
+{
+    private final String TAG = toString();
+    private final Activity activity;
+    private final TextView field;
+
+    PtpIpCameraCommandResponse(@NonNull Activity activity, @NonNull TextView field)
+    {
+        this.activity = activity;
+        this.field = field;
+    }
+
+    void clear()
+    {
+        try
+        {
+            activity.runOnUiThread(new Runnable() {
+                @Override
+                public void run() {
+                    field.setText("");
+                }
+            });
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    @Override
+    public void onReceiveProgress(int currentBytes, int totalBytes, byte[] body)
+    {
+        Log.v(TAG, " " + currentBytes + "/" + totalBytes);
+    }
+
+    @Override
+    public boolean isReceiveMulti()
+    {
+        return (false);
+    }
+
+    @Override
+    public void receivedMessage(int id, byte[] rx_body)
+    {
+        //Log.v(TAG, "RECEIVE : " + rx_body.length + " bytes.");
+        String message = "[Receive "+ rx_body.length + " bytes.]\n";
+        message = message + dump_bytes(rx_body);
+        final String messageToShow = message;
+        try
+        {
+            activity.runOnUiThread(new Runnable() {
+                @Override
+                public void run() {
+                    field.setText(messageToShow);
+                }
+            });
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     *   デバッグ用:ログにバイト列を出力する
+     *
+     */
+    private String dump_bytes(byte[] data)
+    {
+        int index = 0;
+        StringBuilder message = new StringBuilder();
+        for (byte item : data)
+        {
+            index++;
+            message.append(String.format("%02x ", item));
+            if (index >= 8)
+            {
+                message.append("\n");
+                index = 0;
+            }
+        }
+        message.append("\n");
+        return (message.toString());
+    }
+}
diff --git a/app/src/main/java/net/osdn/gokigen/a01d/camera/ptpip/operation/PtpIpCameraCommandSendDialog.java b/app/src/main/java/net/osdn/gokigen/a01d/camera/ptpip/operation/PtpIpCameraCommandSendDialog.java
new file mode 100644 (file)
index 0000000..bbf3387
--- /dev/null
@@ -0,0 +1,302 @@
+package net.osdn.gokigen.a01d.camera.ptpip.operation;
+
+import android.app.Activity;
+import android.app.Dialog;
+import android.content.DialogInterface;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.Spinner;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AlertDialog;
+import androidx.collection.SparseArrayCompat;
+import androidx.fragment.app.DialogFragment;
+
+import net.osdn.gokigen.a01d.R;
+import net.osdn.gokigen.a01d.camera.ptpip.IPtpIpInterfaceProvider;
+import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpCommandPublisher;
+import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.messages.PtpIpCommandGeneric;
+
+
+public class PtpIpCameraCommandSendDialog  extends DialogFragment
+{
+    private final String TAG = toString();
+    private Dialog myDialog = null;
+    private IPtpIpCommandPublisher commandPublisher = null;
+    private PtpIpCameraCommandResponse responseReceiver = null;
+    private SparseArrayCompat<String> commandNameIndexArray;
+    private boolean isDumpLog = false;
+
+    private int selectedCommandIdPosition = 0;
+    private int selectedBodyLengthPosition = 0;
+
+    public static PtpIpCameraCommandSendDialog newInstance(@NonNull IPtpIpInterfaceProvider interfaceProvider, boolean isDumpLog)
+    {
+        PtpIpCameraCommandSendDialog instance = new PtpIpCameraCommandSendDialog();
+        instance.prepare(interfaceProvider, isDumpLog);
+
+        // パラメータはBundleにまとめておく
+        Bundle arguments = new Bundle();
+        //arguments.putString("method", method);
+        //arguments.putString("message", message);
+        instance.setArguments(arguments);
+
+        return (instance);
+    }
+
+    private void prepare(@NonNull IPtpIpInterfaceProvider interfaceProvider, boolean isDumpLog)
+    {
+        this.commandPublisher = interfaceProvider.getCommandPublisher();
+        this.commandNameIndexArray = new SparseArrayCompat<>();
+        this.isDumpLog = isDumpLog;
+    }
+
+    @Override
+    public @NonNull Dialog onCreateDialog(Bundle savedInstanceState)
+    {
+        final Activity activity = getActivity();
+        final AlertDialog.Builder alertDialog = new AlertDialog.Builder(activity);
+
+        // Get the layout inflater
+        LayoutInflater inflater = activity.getLayoutInflater();
+        final View alertView = inflater.inflate(R.layout.ptpip_request_command_layout, null, false);
+        alertDialog.setView(alertView);
+
+        alertDialog.setIcon(R.drawable.ic_linked_camera_black_24dp);
+        alertDialog.setTitle(getString(R.string.dialog_ptpip_command_title_command));
+        try
+        {
+            final TextView commandResponse = alertView.findViewById(R.id.command_response_value);
+            final EditText edit_command_id = alertView.findViewById(R.id.edit_command_id);
+            final EditText edit_message_body1 = alertView.findViewById(R.id.edit_message_body1);
+            final EditText edit_message_body2 = alertView.findViewById(R.id.edit_message_body2);
+            final EditText edit_message_body3 = alertView.findViewById(R.id.edit_message_body3);
+            final EditText edit_message_body4 = alertView.findViewById(R.id.edit_message_body4);
+            final Spinner selection_command_id = alertView.findViewById(R.id.spinner_selection_command_id);
+            final Spinner selection_message_body_length = alertView.findViewById(R.id.spinner_selection_message_body_length);
+            final Button sendButton = alertView.findViewById(R.id.send_message_button);
+            final Button liveViewButton = alertView.findViewById(R.id.change_to_liveview);
+            final Button playbackButton = alertView.findViewById(R.id.change_to_playback);
+
+            responseReceiver = new PtpIpCameraCommandResponse(activity, commandResponse);
+
+            initializeCommandSelection(activity, selection_command_id, edit_command_id);
+            initializeBodyLengthSelection(activity, selection_message_body_length);
+
+            sendButton.setOnClickListener(new View.OnClickListener()
+            {
+                @Override
+                public void onClick(View v)
+                {
+                    try
+                    {
+                        //Log.v(TAG, "SEND COMMAND");
+                        if (responseReceiver != null)
+                        {
+                            responseReceiver.clear();
+                            int id = parseInt(edit_command_id);
+                            int value1 = parseInt(edit_message_body1);
+                            int value2 = parseInt(edit_message_body2);
+                            int value3 = parseInt(edit_message_body3);
+                            int value4 = parseInt(edit_message_body4);
+
+                            if (selectedBodyLengthPosition == 0)
+                            {
+                                commandPublisher.enqueueCommand(new PtpIpCommandGeneric(responseReceiver, id, isDumpLog, 0, id));
+                            }
+                            else if (selectedBodyLengthPosition == 1)
+                            {
+                                commandPublisher.enqueueCommand(new PtpIpCommandGeneric(responseReceiver, id, isDumpLog, 0, id, 2, value1));
+                            }
+                            else if (selectedBodyLengthPosition == 2)
+                            {
+                                commandPublisher.enqueueCommand(new PtpIpCommandGeneric(responseReceiver, id, isDumpLog, 0, id, 4, value1));
+                            }
+                            else if (selectedBodyLengthPosition == 3)
+                            {
+                                commandPublisher.enqueueCommand(new PtpIpCommandGeneric(responseReceiver, id, isDumpLog, 0, id, 8, value1, value2));
+                            }
+                            else if (selectedBodyLengthPosition == 4)
+                            {
+                                commandPublisher.enqueueCommand(new PtpIpCommandGeneric(responseReceiver, id, isDumpLog, 0, id, 12, value1, value2, value3));
+                            }
+                            else // if (selectedBodyLengthPosition == 5)
+                            {
+                                commandPublisher.enqueueCommand(new PtpIpCommandGeneric(responseReceiver, id, isDumpLog, 0, id, 16, value1, value2, value3, value4));
+                            }
+                        }
+                    }
+                    catch (Exception e)
+                    {
+                        e.printStackTrace();
+                    }
+                }
+            });
+            if ((responseReceiver != null)&&(commandPublisher != null))
+            {
+                //liveViewButton.setOnClickListener(new FujiXCameraModeChangeToLiveView(commandPublisher, responseReceiver));
+                //playbackButton.setOnClickListener(new FujiXCameraModeChangeToPlayback(commandPublisher, responseReceiver));
+            }
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+        alertDialog.setCancelable(true);
+
+        // ボタンを設定する(実行ボタン)
+        alertDialog.setPositiveButton(activity.getString(R.string.dialog_positive_execute),
+                new DialogInterface.OnClickListener() {
+                    public void onClick(DialogInterface dialog, int which)
+                    {
+                        //dialog.dismiss();
+                    }
+                });
+
+        // ボタンを設定する (キャンセルボタン)
+        alertDialog.setNegativeButton(activity.getString(R.string.dialog_negative_cancel),
+                new DialogInterface.OnClickListener() {
+                    public void onClick(DialogInterface dialog, int which) {
+                        dialog.cancel();
+                    }
+                });
+
+        // 確認ダイアログを応答する
+        myDialog = alertDialog.create();
+        return (myDialog);
+    }
+
+    @Override
+    public void onPause()
+    {
+        super.onPause();
+        Log.v(TAG, "AlertDialog::onPause()");
+        if (myDialog != null)
+        {
+            myDialog.cancel();
+        }
+    }
+
+    private int parseInt(EditText area)
+    {
+        try
+        {
+            String value = (area.getText().toString()).toLowerCase();
+            int index =  value.indexOf("x");
+            if (index > 0)
+            {
+                value = value.substring(index + 1);
+            }
+            if (value.length() < 1)
+            {
+                // 未入力のときには0を返す
+                return (0);
+            }
+            //int convertValue = (int)Long.parseLong(value, 16);
+            //Log.v(TAG, String.format(Locale.US, "PARSED VALUE : 0x%08x (%d)", convertValue, convertValue));
+            //return (convertValue);
+            return ((int)Long.parseLong(value, 16));
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            Log.v(TAG, "[" + area.getText().toString() + "]");
+        }
+        return (-1);
+    }
+
+
+    private ArrayAdapter<String> prepareCommandAdapter(@NonNull final Activity activity)
+    {
+        int position = 0;
+        ArrayAdapter<String> adapter = new ArrayAdapter<>(activity, android.R.layout.simple_spinner_item);
+        commandNameIndexArray.clear();
+
+        // せっせとコマンドを入れていく...
+        adapter.add("(Direct Input)");
+        commandNameIndexArray.append(position++, "");
+
+        return (adapter);
+    }
+
+    private void initializeCommandSelection(@NonNull final Activity activity, final Spinner spinner, final EditText commandIdArea)
+    {
+        try
+        {
+            commandIdArea.setText("");
+            ArrayAdapter<String> adapter = prepareCommandAdapter(activity);
+            spinner.setAdapter(adapter);
+            spinner.setSelection(selectedCommandIdPosition);
+            spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
+            {
+                @Override
+                public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
+                {
+                    Log.v(TAG, "onItemSelected : " + position + " (" + id + ")");
+                    try
+                    {
+                        selectedCommandIdPosition = position;
+                        commandIdArea.setText(commandNameIndexArray.get(position, ""));
+                    }
+                    catch (Exception e)
+                    {
+                        e.printStackTrace();
+                    }
+                }
+
+                @Override
+                public void onNothingSelected(AdapterView<?> parent)
+                {
+                    Log.v(TAG, "onNothingSelected");
+                }
+            });
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    private void initializeBodyLengthSelection(final Activity activity, final Spinner spinner)
+    {
+        try
+        {
+            ArrayAdapter<String> adapter = new ArrayAdapter<>(activity, android.R.layout.simple_spinner_item);
+            adapter.add("0");
+            adapter.add("2");
+            adapter.add("4");
+            adapter.add("8");
+            adapter.add("12");
+            adapter.add("16");
+
+            spinner.setAdapter(adapter);
+            spinner.setSelection(selectedBodyLengthPosition);
+            spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
+            {
+                @Override
+                public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
+                {
+                    Log.v(TAG, "onItemSelected : " + position + " (" + id + ")");
+                    selectedBodyLengthPosition = position;
+                }
+
+                @Override
+                public void onNothingSelected(AdapterView<?> parent)
+                {
+                    Log.v(TAG, "onNothingSelected");
+                }
+            });
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+}
index 8d6a5ec..c5addc2 100644 (file)
@@ -106,6 +106,15 @@ class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchLi
             this.cameraConnection = interfaceProvider.getThetaInterface().getCameraConnection();
             this.zoomLensControl = interfaceProvider.getThetaInterface().getZoomLensControl();
         }
+        else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
+        {
+            this.focusingControl = interfaceProvider.getCanonInterface().getFocusingControl();
+            this.captureControl = interfaceProvider.getCanonInterface().getCaptureControl();
+            this.propertyProvider = interfaceProvider.getOlympusInterface().getCameraPropertyProvider();  // 要変更
+            this.cameraInformation = interfaceProvider.getCanonInterface().getCameraInformation();
+            this.cameraConnection = interfaceProvider.getCanonInterface().getCameraConnection();
+            this.zoomLensControl = interfaceProvider.getCanonInterface().getZoomLensControl();
+        }
         else  // if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
         {
             this.focusingControl = interfaceProvider.getOlympusInterface().getFocusingControl();
index 2db077e..abae8fc 100644 (file)
@@ -344,6 +344,30 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
                         propertyButton.setOnClickListener(onClickTouchListener);
                     }
                 }
+                else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
+                {
+                    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)
             {
@@ -409,6 +433,10 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
         {
             interfaceInjector = interfaceProvider.getThetaInterface().getDisplayInjector();
         }
+        else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
+        {
+            interfaceInjector = interfaceProvider.getCanonInterface().getDisplayInjector();
+        }
         else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
         {
             interfaceInjector = interfaceProvider.getOlympusInterface().getDisplayInjector();
@@ -453,6 +481,12 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
             this.zoomLensControl = interfaceProvider.getThetaInterface().getZoomLensControl();
             this.cameraInformation = interfaceProvider.getThetaInterface().getCameraInformation();
         }
+        else  if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
+        {
+            this.liveViewControl = interfaceProvider.getCanonInterface().getLiveViewControl();
+            this.zoomLensControl = interfaceProvider.getCanonInterface().getZoomLensControl();
+            this.cameraInformation = interfaceProvider.getCanonInterface().getCameraInformation();
+        }
         else //  if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
         {
             this.liveViewControl = interfaceProvider.getOlympusInterface().getLiveViewControl();
@@ -759,6 +793,10 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
             {
                 lvListener = interfaceProvider.getThetaInterface().getLiveViewListener();
             }
+            else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
+            {
+                lvListener = interfaceProvider.getCanonInterface().getLiveViewListener();
+            }
             else  // if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
             {
                 interfaceProvider.getOlympusLiveViewListener().setOlympusLiveViewListener(liveViewListener);
diff --git a/app/src/main/res/layout-land/ptpip_request_command_layout.xml b/app/src/main/res/layout-land/ptpip_request_command_layout.xml
new file mode 100644 (file)
index 0000000..5b338f9
--- /dev/null
@@ -0,0 +1,221 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <ScrollView
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content">
+
+        <LinearLayout
+            android:id="@+id/info_edit_data"
+            android:orientation="vertical"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:padding="6dp"
+            >
+
+            <LinearLayout
+                android:id="@+id/mode_change_button_area"
+                android:orientation="horizontal"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:padding="6dp"
+                android:visibility="gone"
+                >
+                <Button
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:tag="button"
+                    android:id="@+id/change_to_liveview"
+                    android:text="@string/dialog_button_liveview"
+                    android:layout_gravity="center"
+                    android:textSize="6pt" />
+
+                <Button
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:tag="button"
+                    android:id="@+id/change_to_playback"
+                    android:text="@string/dialog_button_playback"
+                    android:layout_gravity="center"
+                    android:textSize="6pt" />
+            </LinearLayout>
+
+            <View
+                android:layout_width="fill_parent"
+                android:layout_height="2dp"
+                android:background="@android:color/darker_gray"/>
+
+            <LinearLayout
+                android:id="@+id/command_select_area"
+                android:orientation="horizontal"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:padding="6dp"
+                >
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:id="@+id/command_name"
+                    android:text="@string/dialog_title_command"
+                    android:layout_gravity="start">
+                </TextView>
+
+                <Spinner
+                    android:id="@+id/spinner_selection_command_id"
+                    android:layout_width="fill_parent"
+                    android:layout_height="wrap_content"
+                    android:text="@string/blank"
+                    android:visibility="visible" />
+            </LinearLayout>
+
+            <EditText android:id="@+id/edit_command_id"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:autoLink="all"
+                android:linksClickable="true"
+                android:inputType="text"
+                android:hint="@string/dialog_command_id_hint"
+                />
+
+            <View
+                android:layout_width="fill_parent"
+                android:layout_height="8dp" />
+
+            <View
+                android:layout_width="fill_parent"
+                android:layout_height="1dp"
+                android:background="@android:color/darker_gray"/>
+<!--
+            <LinearLayout
+                android:id="@+id/message_type_area"
+                android:orientation="horizontal"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:padding="6dp"
+                >
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:id="@+id/message_type_name"
+                    android:text="@string/dialog_message_type_name"
+                    android:layout_gravity="start">
+                </TextView>
+
+                <Spinner
+                    android:id="@+id/spinner_selection_message_type"
+                    android:layout_width="fill_parent"
+                    android:layout_height="wrap_content"
+                    android:text="@string/blank"
+                    android:visibility="visible" />
+            </LinearLayout>
+-->
+            <View
+                android:layout_width="fill_parent"
+                android:layout_height="1dp"
+                android:background="@android:color/darker_gray"/>
+
+            <LinearLayout
+                android:id="@+id/body_length_area"
+                android:orientation="horizontal"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:padding="6dp"
+                >
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:id="@+id/body_length_name"
+                    android:text="@string/dialog_title_body_length"
+                    android:layout_gravity="start">
+                </TextView>
+
+                <Spinner
+                    android:id="@+id/spinner_selection_message_body_length"
+                    android:layout_width="fill_parent"
+                    android:layout_height="wrap_content"
+                    android:text="@string/blank"
+                    android:visibility="visible" />
+            </LinearLayout>
+
+            <View
+                android:layout_width="fill_parent"
+                android:layout_height="1dp"
+                android:background="@android:color/darker_gray"/>
+            <View
+                android:layout_width="fill_parent"
+                android:layout_height="6dp" />
+
+            <TextView
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:id="@+id/message_body_name"
+                android:text="@string/dialog_title_message_body"
+                />
+
+            <EditText android:id="@+id/edit_message_body1"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:autoLink="all"
+                android:linksClickable="true"
+                android:inputType="text"
+                android:hint="@string/dialog_message_body1_hint"
+                />
+
+            <EditText android:id="@+id/edit_message_body2"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:autoLink="all"
+                android:linksClickable="true"
+                android:inputType="text"
+                android:hint="@string/dialog_message_body2_hint"
+                />
+
+            <EditText android:id="@+id/edit_message_body3"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:autoLink="all"
+                android:linksClickable="true"
+                android:inputType="text"
+                android:hint="@string/dialog_message_body3_hint"
+                />
+
+            <EditText android:id="@+id/edit_message_body4"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:autoLink="all"
+                android:linksClickable="true"
+                android:inputType="text"
+                android:hint="@string/dialog_message_body4_hint"
+                />
+
+            <Button
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:tag="button"
+                android:id="@+id/send_message_button"
+                android:text="@string/dialog_send_message"
+                android:layout_gravity="center"
+                android:textSize="6pt" />
+
+            <View
+                android:layout_width="fill_parent"
+                android:layout_height="2dp"
+                android:background="@android:color/darker_gray"/>
+
+            <TextView
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:id="@+id/command_response_value"
+                android:text="@string/blank"
+                />
+
+            <View
+                android:layout_width="fill_parent"
+                android:layout_height="2dp"
+                android:background="@android:color/darker_gray"/>
+
+        </LinearLayout>
+    </ScrollView>
+</LinearLayout>
diff --git a/app/src/main/res/layout/ptpip_request_command_layout.xml b/app/src/main/res/layout/ptpip_request_command_layout.xml
new file mode 100644 (file)
index 0000000..5b338f9
--- /dev/null
@@ -0,0 +1,221 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <ScrollView
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content">
+
+        <LinearLayout
+            android:id="@+id/info_edit_data"
+            android:orientation="vertical"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:padding="6dp"
+            >
+
+            <LinearLayout
+                android:id="@+id/mode_change_button_area"
+                android:orientation="horizontal"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:padding="6dp"
+                android:visibility="gone"
+                >
+                <Button
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:tag="button"
+                    android:id="@+id/change_to_liveview"
+                    android:text="@string/dialog_button_liveview"
+                    android:layout_gravity="center"
+                    android:textSize="6pt" />
+
+                <Button
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:tag="button"
+                    android:id="@+id/change_to_playback"
+                    android:text="@string/dialog_button_playback"
+                    android:layout_gravity="center"
+                    android:textSize="6pt" />
+            </LinearLayout>
+
+            <View
+                android:layout_width="fill_parent"
+                android:layout_height="2dp"
+                android:background="@android:color/darker_gray"/>
+
+            <LinearLayout
+                android:id="@+id/command_select_area"
+                android:orientation="horizontal"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:padding="6dp"
+                >
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:id="@+id/command_name"
+                    android:text="@string/dialog_title_command"
+                    android:layout_gravity="start">
+                </TextView>
+
+                <Spinner
+                    android:id="@+id/spinner_selection_command_id"
+                    android:layout_width="fill_parent"
+                    android:layout_height="wrap_content"
+                    android:text="@string/blank"
+                    android:visibility="visible" />
+            </LinearLayout>
+
+            <EditText android:id="@+id/edit_command_id"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:autoLink="all"
+                android:linksClickable="true"
+                android:inputType="text"
+                android:hint="@string/dialog_command_id_hint"
+                />
+
+            <View
+                android:layout_width="fill_parent"
+                android:layout_height="8dp" />
+
+            <View
+                android:layout_width="fill_parent"
+                android:layout_height="1dp"
+                android:background="@android:color/darker_gray"/>
+<!--
+            <LinearLayout
+                android:id="@+id/message_type_area"
+                android:orientation="horizontal"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:padding="6dp"
+                >
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:id="@+id/message_type_name"
+                    android:text="@string/dialog_message_type_name"
+                    android:layout_gravity="start">
+                </TextView>
+
+                <Spinner
+                    android:id="@+id/spinner_selection_message_type"
+                    android:layout_width="fill_parent"
+                    android:layout_height="wrap_content"
+                    android:text="@string/blank"
+                    android:visibility="visible" />
+            </LinearLayout>
+-->
+            <View
+                android:layout_width="fill_parent"
+                android:layout_height="1dp"
+                android:background="@android:color/darker_gray"/>
+
+            <LinearLayout
+                android:id="@+id/body_length_area"
+                android:orientation="horizontal"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:padding="6dp"
+                >
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:id="@+id/body_length_name"
+                    android:text="@string/dialog_title_body_length"
+                    android:layout_gravity="start">
+                </TextView>
+
+                <Spinner
+                    android:id="@+id/spinner_selection_message_body_length"
+                    android:layout_width="fill_parent"
+                    android:layout_height="wrap_content"
+                    android:text="@string/blank"
+                    android:visibility="visible" />
+            </LinearLayout>
+
+            <View
+                android:layout_width="fill_parent"
+                android:layout_height="1dp"
+                android:background="@android:color/darker_gray"/>
+            <View
+                android:layout_width="fill_parent"
+                android:layout_height="6dp" />
+
+            <TextView
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:id="@+id/message_body_name"
+                android:text="@string/dialog_title_message_body"
+                />
+
+            <EditText android:id="@+id/edit_message_body1"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:autoLink="all"
+                android:linksClickable="true"
+                android:inputType="text"
+                android:hint="@string/dialog_message_body1_hint"
+                />
+
+            <EditText android:id="@+id/edit_message_body2"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:autoLink="all"
+                android:linksClickable="true"
+                android:inputType="text"
+                android:hint="@string/dialog_message_body2_hint"
+                />
+
+            <EditText android:id="@+id/edit_message_body3"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:autoLink="all"
+                android:linksClickable="true"
+                android:inputType="text"
+                android:hint="@string/dialog_message_body3_hint"
+                />
+
+            <EditText android:id="@+id/edit_message_body4"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:autoLink="all"
+                android:linksClickable="true"
+                android:inputType="text"
+                android:hint="@string/dialog_message_body4_hint"
+                />
+
+            <Button
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:tag="button"
+                android:id="@+id/send_message_button"
+                android:text="@string/dialog_send_message"
+                android:layout_gravity="center"
+                android:textSize="6pt" />
+
+            <View
+                android:layout_width="fill_parent"
+                android:layout_height="2dp"
+                android:background="@android:color/darker_gray"/>
+
+            <TextView
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:id="@+id/command_response_value"
+                android:text="@string/blank"
+                />
+
+            <View
+                android:layout_width="fill_parent"
+                android:layout_height="2dp"
+                android:background="@android:color/darker_gray"/>
+
+        </LinearLayout>
+    </ScrollView>
+</LinearLayout>
index 321bf8e..4f8deff 100644 (file)
         <item >Ricoh THETA Series</item>
         <item >Fuji X Series</item>
         <item >Panasonic</item>
+        <item >Canon</item>
     </string-array>
 
     <string-array name="connection_method_value">
         <item >THETA</item>
         <item >FUJI_X</item>
         <item >PANASONIC</item>
+        <item >CANON</item>
     </string-array>
 
 
index b4cf48c..dc7a19d 100644 (file)
     <string name="dialog_ricoh_command_title_command">メッセージ送信(RICOH)</string>
     <string name="dialog_panasonic_command_title_command">メッセージ送信(Panasonic)</string>
     <string name="dialog_fujix_command_title_command">メッセージ送信(FUJI)</string>
+    <string name="dialog_ptpip_command_title_command">メッセージ送信(PTP/IP)</string>
     <string name="dialog_title_command">コマンド</string>
     <string name="dialog_command_id_hint">0x####</string>
     <string name="dialog_message_type_name">メッセージ種別</string>
     <string name="dialog_title_body_length">ボディ長</string>
     <string name="dialog_message_body1_hint">0x########</string>
     <string name="dialog_message_body2_hint">0x########</string>
+    <string name="dialog_message_body3_hint">0x########</string>
+    <string name="dialog_message_body4_hint">0x########</string>
     <string name="dialog_title_message_body">メッセージボディ</string>
     <string name="dialog_send_message">送信</string>
     <string name="dialog_button_liveview">ライブビュー</string>
index 2db0e33..3f172c5 100644 (file)
         <item >Ricoh THETA Series</item>
         <item >Fuji X Series</item>
         <item >Panasonic</item>
+        <item >Canon</item>
     </string-array>
 
     <string-array name="connection_method_value">
         <item >THETA</item>
         <item >FUJI_X</item>
         <item >PANASONIC</item>
+        <item >CANON</item>
     </string-array>
 
     <string-array name="gr2_display_mode">
index 7860a99..a5cb427 100644 (file)
     <string name="dialog_ricoh_command_title_command">Send Message(RICOH)</string>
     <string name="dialog_panasonic_command_title_command">Send Message(Panasonic)</string>
     <string name="dialog_fujix_command_title_command">Send Message(FUJI)</string>
+    <string name="dialog_ptpip_command_title_command">Send Message(PTP/IP)</string>
     <string name="dialog_title_command">Command</string>
     <string name="dialog_command_id_hint">0x####</string>
     <string name="dialog_message_type_name">Message Type</string>
     <string name="dialog_title_body_length">Body Length</string>
     <string name="dialog_message_body1_hint">0x########</string>
     <string name="dialog_message_body2_hint">0x########</string>
+    <string name="dialog_message_body3_hint">0x########</string>
+    <string name="dialog_message_body4_hint">0x########</string>
     <string name="dialog_title_message_body">Message Body</string>
     <string name="dialog_send_message">Send</string>
     <string name="dialog_button_liveview">to LiveView</string>