OSDN Git Service

接続方式の切り替えロジックを入れてみる。
authorMRSa <mrsa@myad.jp>
Thu, 7 Jan 2021 14:53:11 +0000 (23:53 +0900)
committerMRSa <mrsa@myad.jp>
Thu, 7 Jan 2021 14:53:11 +0000 (23:53 +0900)
15 files changed:
wear/src/main/java/jp/sfjp/gokigen/a01c/ICameraController.java [moved from wear/src/main/java/jp/sfjp/gokigen/a01c/olycamerawrapper/IOlyCameraCoordinator.java with 77% similarity]
wear/src/main/java/jp/sfjp/gokigen/a01c/IChangeScene.java
wear/src/main/java/jp/sfjp/gokigen/a01c/MainActivity.java
wear/src/main/java/jp/sfjp/gokigen/a01c/liveview/CameraLiveImageView.java
wear/src/main/java/jp/sfjp/gokigen/a01c/liveview/CameraLiveViewListenerImpl.java
wear/src/main/java/jp/sfjp/gokigen/a01c/liveview/CameraLiveViewOnTouchListener.java [moved from wear/src/main/java/jp/sfjp/gokigen/a01c/liveview/OlyCameraLiveViewOnTouchListener.java with 95% similarity]
wear/src/main/java/jp/sfjp/gokigen/a01c/liveview/IImageDataReceiver.java [new file with mode: 0644]
wear/src/main/java/jp/sfjp/gokigen/a01c/olycamerawrapper/OlyCameraCoordinator.java
wear/src/main/java/jp/sfjp/gokigen/a01c/olycamerawrapper/dispatcher/FeatureDispatcher.java
wear/src/main/java/jp/sfjp/gokigen/a01c/preference/IPreferenceCameraPropertyAccessor.java
wear/src/main/java/jp/sfjp/gokigen/a01c/preference/PreferenceAccessWrapper.kt
wear/src/main/java/jp/sfjp/gokigen/a01c/preference/PreferenceInitializer.kt [new file with mode: 0644]
wear/src/main/java/jp/sfjp/gokigen/a01c/thetacamerawrapper/ThetaCameraController.kt [new file with mode: 0644]
wear/src/main/res/drawable/kamakura.jpg [new file with mode: 0644]
wear/src/main/res/values-ja/strings.xml

@@ -1,10 +1,13 @@
-package jp.sfjp.gokigen.a01c.olycamerawrapper;
+package jp.sfjp.gokigen.a01c;
 
 import android.view.MotionEvent;
 
-import jp.co.olympus.camerakit.OLYCameraLiveViewListener;
-import jp.co.olympus.camerakit.OLYCameraStatusListener;
-import jp.sfjp.gokigen.a01c.ICameraConnection;
+import androidx.annotation.NonNull;
+
+import jp.sfjp.gokigen.a01c.liveview.CameraLiveViewListenerImpl;
+import jp.sfjp.gokigen.a01c.olycamerawrapper.ICameraRunMode;
+import jp.sfjp.gokigen.a01c.olycamerawrapper.ILevelGauge;
+import jp.sfjp.gokigen.a01c.olycamerawrapper.IZoomLensHolder;
 import jp.sfjp.gokigen.a01c.olycamerawrapper.property.ILoadSaveCameraProperties;
 import jp.sfjp.gokigen.a01c.olycamerawrapper.property.IOlyCameraPropertyProvider;
 import jp.sfjp.gokigen.a01c.olycamerawrapper.property.ICameraPropertyLoadSaveOperations;
@@ -13,11 +16,11 @@ import jp.sfjp.gokigen.a01c.olycamerawrapper.property.ICameraPropertyLoadSaveOpe
  *
  *
  */
-public interface IOlyCameraCoordinator
+public interface ICameraController
 {
     /** ライブビュー関係 **/
+    void setLiveViewListener(@NonNull CameraLiveViewListenerImpl listener);
     void changeLiveViewSize(String size);
-    void setLiveViewListener(OLYCameraLiveViewListener listener);
     void startLiveView();
     void stopLiveView();
 
@@ -53,14 +56,14 @@ public interface IOlyCameraCoordinator
     boolean isAFLock();
     boolean isAELock();
 
-    /** カメラの状態変化リスナの設定 **/
-    void setCameraStatusListener(OLYCameraStatusListener listener);
+    ///** カメラの状態変化リスナの設定 **/
+    //void setCameraStatusListener(OLYCameraStatusListener listener);
 
     /** カメラ状態の表示をすべて更新する **/
     void updateStatusAll();
 
-    /** カメラの状態サマリ(のテキスト情報)を取得する **/
-    String getCameraStatusSummary(ICameraStatusSummary decoder);
+    ///** カメラの状態サマリ(のテキスト情報)を取得する **/
+    //String getCameraStatusSummary(ICameraStatusSummary decoder);
 
     // カメラプロパティアクセスインタフェース
     IOlyCameraPropertyProvider getCameraPropertyProvider();
index db46f8a..6ddd41b 100644 (file)
@@ -7,6 +7,6 @@ public interface IChangeScene
 {
     void exitApplication();
     boolean showConnectionStatus();
-    boolean checkConnectionFeature(int id);
+    boolean checkConnectionFeature(int id, int btnId);
     boolean touchedPosition(float posX, float posY);
 }
index 8514efc..1006d9c 100644 (file)
@@ -26,10 +26,11 @@ import jp.sfjp.gokigen.a01c.liveview.dialog.IDialogDismissedNotifier;
 import jp.sfjp.gokigen.a01c.olycamerawrapper.dispatcher.FeatureDispatcher;
 import jp.sfjp.gokigen.a01c.liveview.ICameraStatusReceiver;
 import jp.sfjp.gokigen.a01c.liveview.IMessageDrawer;
-import jp.sfjp.gokigen.a01c.liveview.OlyCameraLiveViewOnTouchListener;
-import jp.sfjp.gokigen.a01c.olycamerawrapper.IOlyCameraCoordinator;
+import jp.sfjp.gokigen.a01c.liveview.CameraLiveViewOnTouchListener;
 import jp.sfjp.gokigen.a01c.olycamerawrapper.OlyCameraCoordinator;
 import jp.sfjp.gokigen.a01c.preference.IPreferenceCameraPropertyAccessor;
+import jp.sfjp.gokigen.a01c.preference.PreferenceAccessWrapper;
+import jp.sfjp.gokigen.a01c.thetacamerawrapper.ThetaCameraController;
 
 /**
  *   メインのActivity
@@ -41,11 +42,14 @@ public class MainActivity extends AppCompatActivity implements  IChangeScene, IS
     static final int REQUEST_NEED_PERMISSIONS = 1010;
     //static final int COMMAND_MY_PROPERTY = 0x00000100;
 
+    private PreferenceAccessWrapper preferences = null;
     private PowerManager powerManager = null;
     private CameraLiveImageView liveView = null;
-    private IOlyCameraCoordinator coordinator = null;
+    private ICameraController currentCoordinator = null;
+    private ICameraController olyAirCoordinator = null;
+    private ICameraController thetaCoordinator = null;
     private IMessageDrawer messageDrawer = null;
-    private OlyCameraLiveViewOnTouchListener listener = null;
+    private CameraLiveViewOnTouchListener listener = null;
     private FavoriteSettingSelectionDialog selectionDialog = null;
     private Vibrator vibrator = null;
     private boolean cameraDisconnectedHappened = false;
@@ -237,7 +241,7 @@ public class MainActivity extends AppCompatActivity implements  IChangeScene, IS
             }
             liveView.setOnTouchListener(listener);
             messageDrawer = liveView.getMessageDrawer();
-            messageDrawer.setLevelGauge(coordinator.getLevelGauge());
+            messageDrawer.setLevelGauge(currentCoordinator.getLevelGauge());
         }
         catch (Exception e)
         {
@@ -253,7 +257,7 @@ public class MainActivity extends AppCompatActivity implements  IChangeScene, IS
     {
         try
         {
-            if (coordinator != null)
+            if (currentCoordinator != null)
             {
                 int resId;
                 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
@@ -343,14 +347,19 @@ public class MainActivity extends AppCompatActivity implements  IChangeScene, IS
     {
         try
         {
-            if (liveView == null) {
+            preferences = new PreferenceAccessWrapper(this);
+            preferences.initialize();
+            String connectionMethod = preferences.getString(IPreferenceCameraPropertyAccessor.CONNECTION_METHOD, IPreferenceCameraPropertyAccessor.CONNECTION_METHOD_DEFAULT_VALUE);
+            if (liveView == null)
+            {
                 liveView = findViewById(R.id.liveview);
             }
-            coordinator = null;
-            coordinator = new OlyCameraCoordinator(this, liveView, this, this);
-            coordinator.setLiveViewListener(new CameraLiveViewListenerImpl(liveView));
-            listener = new OlyCameraLiveViewOnTouchListener(this, new FeatureDispatcher(this, this, coordinator, liveView), this);
-            selectionDialog = new FavoriteSettingSelectionDialog(this, coordinator.getCameraPropertyLoadSaveOperations(), this);
+            olyAirCoordinator = new OlyCameraCoordinator(this, liveView, this, this);
+            thetaCoordinator = new ThetaCameraController(this, liveView, this, this);
+            currentCoordinator = olyAirCoordinator; // (connectionMethod.contains(IPreferenceCameraPropertyAccessor.CONNECTION_METHOD_THETA)) ? thetaCoordinator : olyAirCoordinator;
+            currentCoordinator.setLiveViewListener(new CameraLiveViewListenerImpl(liveView));
+            listener = new CameraLiveViewOnTouchListener(this, new FeatureDispatcher(this, this, currentCoordinator, preferences, liveView), this);
+            selectionDialog = new FavoriteSettingSelectionDialog(this, currentCoordinator.getCameraPropertyLoadSaveOperations(), this);
             connectToCamera();
         }
         catch (Exception e)
@@ -370,7 +379,7 @@ public class MainActivity extends AppCompatActivity implements  IChangeScene, IS
             @Override
             public void run()
             {
-                coordinator.getConnectionInterface().connect();
+                currentCoordinator.getConnectionInterface().connect();
             }
         });
         try
@@ -411,7 +420,7 @@ public class MainActivity extends AppCompatActivity implements  IChangeScene, IS
             }
 
             // ライブビューを停止させる
-            coordinator.stopLiveView();
+            currentCoordinator.stopLiveView();
 
             //  パラメータを確認し、カメラの電源を切る
             if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(IPreferenceCameraPropertyAccessor.EXIT_APPLICATION_WITH_DISCONNECT, true))
@@ -419,7 +428,7 @@ public class MainActivity extends AppCompatActivity implements  IChangeScene, IS
                 Log.v(TAG, "Shutdown camera...");
 
                 // カメラの電源をOFFにする
-                coordinator.getConnectionInterface().disconnect(true);
+                currentCoordinator.getConnectionInterface().disconnect(true);
             }
             //finish();
             //finishAndRemoveTask();
@@ -435,7 +444,7 @@ public class MainActivity extends AppCompatActivity implements  IChangeScene, IS
      *   接続機能を確認する
      */
     @Override
-    public boolean checkConnectionFeature(int id)
+    public boolean checkConnectionFeature(int id, int btnId)
     {
         boolean ret = false;
         if (id == 0)
@@ -443,6 +452,11 @@ public class MainActivity extends AppCompatActivity implements  IChangeScene, IS
             // Wifi 設定画面を開く
             ret = launchWifiSettingScreen();
         }
+        else if (id == 1)
+        {
+            // 接続の変更を確認する
+            changeConnectionMethod();
+        }
         return (ret);
     }
 
@@ -501,11 +515,11 @@ public class MainActivity extends AppCompatActivity implements  IChangeScene, IS
         try
         {
             // ライブビューの開始 & タッチ/ボタンの操作を可能にする
-            coordinator.startLiveView();
-            coordinator.setRecViewMode(false);
+            currentCoordinator.startLiveView();
+            currentCoordinator.setRecViewMode(false);
             listener.setEnableOperation(operation.ENABLE);
             setMessage(IShowInformation.AREA_C, Color.WHITE, "");
-            coordinator.updateStatusAll();
+            currentCoordinator.updateStatusAll();
         }
         catch (Exception e)
         {
@@ -815,4 +829,67 @@ public class MainActivity extends AppCompatActivity implements  IChangeScene, IS
             e.printStackTrace();
         }
     }
+
+    private void updateConnectionMethod(String parameter, ICameraController method)
+    {
+        try
+        {
+            currentCoordinator = method;
+            preferences.putString(IPreferenceCameraPropertyAccessor.CONNECTION_METHOD, parameter);
+            vibrate(IShowInformation.VIBRATE_PATTERN_SHORT_DOUBLE);
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     *   接続方式を変更するか確認する
+     *
+     */
+    private void changeConnectionMethod()
+    {
+        final AppCompatActivity activity = this;
+        runOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                try
+                {
+                    int titleId = R.string.change_title_from_opc_to_theta;
+                    int messageId = R.string.change_message_from_opc_to_theta;
+                    boolean method = false;
+                    String connectionMethod = preferences.getString(IPreferenceCameraPropertyAccessor.CONNECTION_METHOD, IPreferenceCameraPropertyAccessor.CONNECTION_METHOD_DEFAULT_VALUE);
+                    if (connectionMethod.contains(IPreferenceCameraPropertyAccessor.CONNECTION_METHOD_THETA))
+                    {
+                        titleId = R.string.change_title_from_theta_to_opc;
+                        messageId = R.string.change_message_from_theta_to_opc;
+                        method = true;
+                    }
+                    final boolean isTheta = method;
+                    ConfirmationDialog confirmation = new ConfirmationDialog(activity);
+                    confirmation.show(titleId, messageId, new ConfirmationDialog.Callback() {
+                        @Override
+                        public void confirm() {
+                            Log.v(TAG, " --- CONFIRMED! --- (theta:" + isTheta + ")");
+                            if (isTheta)
+                            {
+                                // 接続方式を OPC に切り替える
+                                updateConnectionMethod(IPreferenceCameraPropertyAccessor.CONNECTION_METHOD_OPC, olyAirCoordinator);
+                            }
+                            else
+                            {
+                                // 接続方式を Theta に切り替える
+                                updateConnectionMethod(IPreferenceCameraPropertyAccessor.CONNECTION_METHOD_THETA, olyAirCoordinator);  // thetaCoordinator
+                            }
+                        }
+                    });
+                }
+                catch (Exception e)
+                {
+                    e.printStackTrace();
+                }
+            }
+        });
+    }
 }
index 1676e76..16d3f93 100644 (file)
@@ -41,7 +41,7 @@ import jp.sfjp.gokigen.a01c.preference.PreferenceAccessWrapper;
  *    (OLYMPUS の ImageCaptureSample をカスタマイズ)
  *
  */
-public class CameraLiveImageView extends View implements CameraLiveViewListenerImpl.IImageDataReceiver, IAutoFocusFrameDisplay, ILiveImageStatusNotify, IDialogController
+public class CameraLiveImageView extends View implements IImageDataReceiver, IAutoFocusFrameDisplay, ILiveImageStatusNotify, IDialogController
 {
     private final String TAG = toString();
 
index 33dca7d..fad67de 100644 (file)
@@ -2,6 +2,8 @@ package jp.sfjp.gokigen.a01c.liveview;
 
 import android.util.Log;
 
+import androidx.annotation.NonNull;
+
 import java.util.Map;
 
 import jp.co.olympus.camerakit.OLYCamera;
@@ -12,19 +14,17 @@ import jp.co.olympus.camerakit.OLYCameraLiveViewListener;
  *  (LiveViewFragment用)
  *
  */
-public class CameraLiveViewListenerImpl implements OLYCameraLiveViewListener
+public class CameraLiveViewListenerImpl implements OLYCameraLiveViewListener, IImageDataReceiver
 {
-    private final String TAG = toString();
     private final IImageDataReceiver imageView;
 
     /**
      * コンストラクタ
      */
-    public CameraLiveViewListenerImpl(IImageDataReceiver target)
+    public CameraLiveViewListenerImpl(@NonNull IImageDataReceiver target)
     {
-        Log.v(TAG, "CameraLiveViewListenerImpl is created. ; " + target.toString());
+        Log.v(toString(), "CameraLiveViewListenerImpl is created. : " + target.toString());
         this.imageView = target;
-        //
     }
 
     /**
@@ -34,18 +34,18 @@ public class CameraLiveViewListenerImpl implements OLYCameraLiveViewListener
     @Override
     public void onUpdateLiveView(OLYCamera camera, byte[] data, Map<String, Object> metadata)
     {
-        //Log.v(TAG, "onUpdateLiveView()");
         if (imageView != null)
         {
             imageView.setImageData(data, metadata);
         }
     }
 
-    /**
-     *   CameraLiveImageView
-     */
-    interface IImageDataReceiver
+    @Override
+    public void setImageData(byte[] data, Map<String, Object> metadata)
     {
-        void setImageData(byte[] data, Map<String, Object> metadata);
+        if (imageView != null)
+        {
+            imageView.setImageData(data, metadata);
+        }
     }
 }
@@ -17,7 +17,7 @@ import jp.sfjp.gokigen.a01c.ICameraFeatureDispatcher;
  *   画面がタッチ・クリックされた時の処理分岐
  *
  */
-public class OlyCameraLiveViewOnTouchListener  implements View.OnClickListener, View.OnTouchListener, View.OnLongClickListener
+public class CameraLiveViewOnTouchListener implements View.OnClickListener, View.OnTouchListener, View.OnLongClickListener
 {
     private final String TAG = toString();
 
@@ -30,7 +30,7 @@ public class OlyCameraLiveViewOnTouchListener  implements View.OnClickListener,
      *   コンストラクタの整理
      *
      */
-    public OlyCameraLiveViewOnTouchListener(Context context, ICameraFeatureDispatcher dispatcher, IChangeScene changeScene)
+    public CameraLiveViewOnTouchListener(Context context, ICameraFeatureDispatcher dispatcher, IChangeScene changeScene)
     {
         this.dispatcher = dispatcher;
         this.changeScene = changeScene;
@@ -51,7 +51,7 @@ public class OlyCameraLiveViewOnTouchListener  implements View.OnClickListener,
             Log.v(TAG, "onClick() : prohibit operation");
             if (operationMode == IShowInformation.operation.ONLY_CONNECT)
             {
-                changeScene.checkConnectionFeature(0);
+                changeScene.checkConnectionFeature(0, id);
             }
             return;
         }
@@ -84,7 +84,7 @@ public class OlyCameraLiveViewOnTouchListener  implements View.OnClickListener,
         {
             // 操作禁止の指示がされていた場合は何もしない
             Log.v(TAG, "onLongClick() : prohibit operation");
-            return  ((operationMode == IShowInformation.operation.ONLY_CONNECT)&&(changeScene.checkConnectionFeature(1)));
+            return  ((operationMode == IShowInformation.operation.ONLY_CONNECT)&&(changeScene.checkConnectionFeature(1, id)));
         }
         try
         {
diff --git a/wear/src/main/java/jp/sfjp/gokigen/a01c/liveview/IImageDataReceiver.java b/wear/src/main/java/jp/sfjp/gokigen/a01c/liveview/IImageDataReceiver.java
new file mode 100644 (file)
index 0000000..92e5b87
--- /dev/null
@@ -0,0 +1,8 @@
+package jp.sfjp.gokigen.a01c.liveview;
+
+import java.util.Map;
+
+public interface IImageDataReceiver
+{
+    void setImageData(byte[] data, Map<String, Object> metadata);
+}
index bfce1a0..fe31486 100644 (file)
@@ -7,15 +7,17 @@ import android.util.Log;
 import android.view.MotionEvent;
 import android.widget.Toast;
 
+import androidx.annotation.NonNull;
 import androidx.preference.PreferenceManager;
 
 import jp.co.olympus.camerakit.OLYCamera;
-import jp.co.olympus.camerakit.OLYCameraLiveViewListener;
-import jp.co.olympus.camerakit.OLYCameraStatusListener;
 
+import jp.co.olympus.camerakit.OLYCameraLiveViewListener;
 import jp.sfjp.gokigen.a01c.ICameraConnection;
+import jp.sfjp.gokigen.a01c.ICameraController;
 import jp.sfjp.gokigen.a01c.IShowInformation;
 import jp.sfjp.gokigen.a01c.R;
+import jp.sfjp.gokigen.a01c.liveview.CameraLiveViewListenerImpl;
 import jp.sfjp.gokigen.a01c.liveview.IAutoFocusFrameDisplay;
 import jp.sfjp.gokigen.a01c.liveview.ICameraStatusReceiver;
 import jp.sfjp.gokigen.a01c.olycamerawrapper.indicator.CameraStatusDisplay;
@@ -48,7 +50,7 @@ import jp.sfjp.gokigen.a01c.preference.IPreferenceCameraPropertyAccessor;
  *    o. CameraInteractionCoordinator.ICameraCallback でカメラとの接続状態を通知する
  *
  */
-public class OlyCameraCoordinator implements IOlyCameraCoordinator, IIndicatorControl, ICameraRunMode, IOLYCameraObjectProvider
+public class OlyCameraCoordinator implements ICameraController, IIndicatorControl, ICameraRunMode, IOLYCameraObjectProvider
 {
     private final String TAG = toString();
     private final IAutoFocusFrameDisplay focusFrameDisplay;
@@ -104,10 +106,8 @@ public class OlyCameraCoordinator implements IOlyCameraCoordinator, IIndicatorCo
         zoomLensHolder = new ZoomLensHolder(camera);
     }
 
-    /**
-     * ライブビューの設定
-     */
-    public void setLiveViewListener(OLYCameraLiveViewListener listener)
+    @Override
+    public void setLiveViewListener(@NonNull CameraLiveViewListenerImpl listener)
     {
         Log.v(TAG, "setLiveViewListener()");
         try
@@ -392,6 +392,7 @@ public class OlyCameraCoordinator implements IOlyCameraCoordinator, IIndicatorCo
         return (propertyProxy.isExposureLocked());
     }
 
+/*
     @Override
     public void setCameraStatusListener(OLYCameraStatusListener listener)
     {
@@ -403,6 +404,7 @@ public class OlyCameraCoordinator implements IOlyCameraCoordinator, IIndicatorCo
     {
         return (decoder.getCameraStatusMessage(camera, ""));
     }
+*/
 
     /**
      *   ステータス表示をすべて更新する
index a9ebc30..1cb7deb 100644 (file)
@@ -11,7 +11,7 @@ import jp.sfjp.gokigen.a01c.ICameraFeatureDispatcher;
 import jp.sfjp.gokigen.a01c.IShowInformation;
 import jp.sfjp.gokigen.a01c.R;
 import jp.sfjp.gokigen.a01c.liveview.ILiveImageStatusNotify;
-import jp.sfjp.gokigen.a01c.olycamerawrapper.IOlyCameraCoordinator;
+import jp.sfjp.gokigen.a01c.ICameraController;
 import jp.sfjp.gokigen.a01c.olycamerawrapper.IZoomLensHolder;
 import jp.sfjp.gokigen.a01c.olycamerawrapper.property.IOlyCameraProperty;
 import jp.sfjp.gokigen.a01c.olycamerawrapper.property.IOlyCameraPropertyProvider;
@@ -29,17 +29,17 @@ public class FeatureDispatcher implements ICameraFeatureDispatcher
 
     private final AppCompatActivity activity;
     private final IShowInformation statusDrawer;
-    private final IOlyCameraCoordinator camera;
+    private final ICameraController camera;
     private final ILiveImageStatusNotify liveImageView;
     private final PreferenceAccessWrapper preferences;
 
-    public FeatureDispatcher(@NonNull AppCompatActivity context, @NonNull IShowInformation statusDrawer, @NonNull IOlyCameraCoordinator camera, ILiveImageStatusNotify liveImageView)
+    public FeatureDispatcher(@NonNull AppCompatActivity context, @NonNull IShowInformation statusDrawer, @NonNull ICameraController camera, @NonNull PreferenceAccessWrapper preferenceAccessWrapper, @NonNull ILiveImageStatusNotify liveImageView)
     {
         this.activity = context;
         this.statusDrawer = statusDrawer;
         this.camera = camera;
         this.liveImageView = liveImageView;
-        this.preferences = new PreferenceAccessWrapper(context);
+        this.preferences = preferenceAccessWrapper;
     }
 
     /**
@@ -937,13 +937,6 @@ public class FeatureDispatcher implements ICameraFeatureDispatcher
         try
         {
             Log.v(TAG, " --- showSettingsScreen() ---");
-            ConfirmationDialog confirmation = new ConfirmationDialog(activity);
-            confirmation.show(R.string.change_title_from_opc_to_theta, R.string.change_message_from_opc_to_theta, new ConfirmationDialog.Callback() {
-                @Override
-                public void confirm() {
-                    Log.v(TAG, " --- CONFIRMED! --- ");
-                }
-            });
         }
         catch (Exception e)
         {
index 5c3a61b..e2cf284 100644 (file)
@@ -7,6 +7,11 @@ package jp.sfjp.gokigen.a01c.preference;
  */
 public interface IPreferenceCameraPropertyAccessor
 {
+    String CONNECTION_METHOD = "connection_method";
+    String CONNECTION_METHOD_OPC = "OPC";
+    String CONNECTION_METHOD_THETA = "THETA";
+    String CONNECTION_METHOD_DEFAULT_VALUE = CONNECTION_METHOD_OPC;
+
     String FRAME_GRID = "frame_grid";
     String FRAME_GRID_DEFAULT_VALUE = "0";
 
index fe6ec63..22e1842 100644 (file)
@@ -5,10 +5,22 @@ import android.content.SharedPreferences
 import androidx.preference.PreferenceDataStore
 import androidx.preference.PreferenceManager
 
-class PreferenceAccessWrapper(context : Context) : PreferenceDataStore()
+class PreferenceAccessWrapper(private val context : Context) : PreferenceDataStore()
 {
     private val preferences = PreferenceManager.getDefaultSharedPreferences(context)
 
+    fun initialize()
+    {
+        try
+        {
+            PreferenceInitializer().initializePreferences(context)
+        }
+        catch (e : Exception)
+        {
+            e.printStackTrace()
+        }
+    }
+
     override fun getString(key : String, defaultValue : String?) : String
     {
         try
diff --git a/wear/src/main/java/jp/sfjp/gokigen/a01c/preference/PreferenceInitializer.kt b/wear/src/main/java/jp/sfjp/gokigen/a01c/preference/PreferenceInitializer.kt
new file mode 100644 (file)
index 0000000..3967b84
--- /dev/null
@@ -0,0 +1,42 @@
+package jp.sfjp.gokigen.a01c.preference
+
+import android.content.Context
+import android.content.SharedPreferences
+import androidx.preference.PreferenceManager
+
+class PreferenceInitializer
+{
+    fun initializePreferences(context : Context)
+    {
+        try
+        {
+            initializeApplicationPreferences(context)
+        }
+        catch (e : Exception)
+        {
+            e.printStackTrace()
+        }
+    }
+
+    private fun initializeApplicationPreferences(context : Context)
+    {
+        try
+        {
+            val preferences = PreferenceManager.getDefaultSharedPreferences(context) ?: return
+            val items : Map<String, *> = preferences.all
+            val editor : SharedPreferences.Editor = preferences.edit()
+            if (!items.containsKey(IPreferenceCameraPropertyAccessor.CONNECTION_METHOD))
+            {
+                editor.putString(
+                        IPreferenceCameraPropertyAccessor.CONNECTION_METHOD,
+                        IPreferenceCameraPropertyAccessor.CONNECTION_METHOD_DEFAULT_VALUE
+                )
+            }
+            editor.apply()
+        }
+        catch (e : Exception)
+        {
+            e.printStackTrace()
+        }
+    }
+}
diff --git a/wear/src/main/java/jp/sfjp/gokigen/a01c/thetacamerawrapper/ThetaCameraController.kt b/wear/src/main/java/jp/sfjp/gokigen/a01c/thetacamerawrapper/ThetaCameraController.kt
new file mode 100644 (file)
index 0000000..1a8c2de
--- /dev/null
@@ -0,0 +1,127 @@
+package jp.sfjp.gokigen.a01c.thetacamerawrapper
+
+import android.util.Log
+import android.view.MotionEvent
+import androidx.appcompat.app.AppCompatActivity
+import jp.sfjp.gokigen.a01c.ICameraConnection
+import jp.sfjp.gokigen.a01c.ICameraController
+import jp.sfjp.gokigen.a01c.IShowInformation
+import jp.sfjp.gokigen.a01c.liveview.CameraLiveViewListenerImpl
+import jp.sfjp.gokigen.a01c.liveview.IAutoFocusFrameDisplay
+import jp.sfjp.gokigen.a01c.liveview.ICameraStatusReceiver
+import jp.sfjp.gokigen.a01c.olycamerawrapper.ICameraRunMode
+import jp.sfjp.gokigen.a01c.olycamerawrapper.ILevelGauge
+import jp.sfjp.gokigen.a01c.olycamerawrapper.IZoomLensHolder
+import jp.sfjp.gokigen.a01c.olycamerawrapper.property.ICameraPropertyLoadSaveOperations
+import jp.sfjp.gokigen.a01c.olycamerawrapper.property.ILoadSaveCameraProperties
+import jp.sfjp.gokigen.a01c.olycamerawrapper.property.IOlyCameraPropertyProvider
+
+class ThetaCameraController(val context : AppCompatActivity, val focusFrameDisplay : IAutoFocusFrameDisplay, val showInformation : IShowInformation, val receiver : ICameraStatusReceiver) : ICameraController
+{
+    private lateinit var listener : CameraLiveViewListenerImpl
+
+    override fun setLiveViewListener(listener: CameraLiveViewListenerImpl)
+    {
+        this.listener = listener
+    }
+
+    override fun changeLiveViewSize(size: String?)
+    {
+        // ログだけ残す
+        Log.v(toString(), " changeLiveViewSize: $size")
+    }
+
+    override fun startLiveView() {
+        TODO("Not yet implemented")
+    }
+
+    override fun stopLiveView() {
+        TODO("Not yet implemented")
+    }
+
+    override fun updateTakeMode() {
+        TODO("Not yet implemented")
+    }
+
+    override fun driveAutoFocus(event: MotionEvent?): Boolean {
+        TODO("Not yet implemented")
+    }
+
+    override fun unlockAutoFocus() {
+        TODO("Not yet implemented")
+    }
+
+    override fun isContainsAutoFocusPoint(event: MotionEvent?): Boolean {
+        TODO("Not yet implemented")
+    }
+
+    override fun singleShot() {
+        TODO("Not yet implemented")
+    }
+
+    override fun movieControl() {
+        TODO("Not yet implemented")
+    }
+
+    override fun bracketingShot(bracketingStyle: Int, bracketingCount: Int, durationSeconds: Int) {
+        TODO("Not yet implemented")
+    }
+
+    override fun setRecViewMode(isRecViewMode: Boolean) {
+        TODO("Not yet implemented")
+    }
+
+    override fun toggleAutoExposure() {
+        TODO("Not yet implemented")
+    }
+
+    override fun toggleManualFocus() {
+        TODO("Not yet implemented")
+    }
+
+    override fun isManualFocus(): Boolean {
+        TODO("Not yet implemented")
+    }
+
+    override fun isAFLock(): Boolean {
+        TODO("Not yet implemented")
+    }
+
+    override fun isAELock(): Boolean {
+        TODO("Not yet implemented")
+    }
+
+    override fun updateStatusAll() {
+        TODO("Not yet implemented")
+    }
+
+    override fun getCameraPropertyProvider(): IOlyCameraPropertyProvider {
+        TODO("Not yet implemented")
+    }
+
+    override fun getCameraPropertyLoadSaveOperations(): ICameraPropertyLoadSaveOperations {
+        TODO("Not yet implemented")
+    }
+
+    override fun getLoadSaveCameraProperties(): ILoadSaveCameraProperties {
+        TODO("Not yet implemented")
+    }
+
+    override fun getChangeRunModeExecutor(): ICameraRunMode {
+        TODO("Not yet implemented")
+    }
+
+    override fun getConnectionInterface(): ICameraConnection {
+        TODO("Not yet implemented")
+    }
+
+    override fun getZoomLensHolder(): IZoomLensHolder {
+        TODO("Not yet implemented")
+    }
+
+    override fun getLevelGauge(): ILevelGauge {
+        TODO("Not yet implemented")
+    }
+
+
+}
\ No newline at end of file
diff --git a/wear/src/main/res/drawable/kamakura.jpg b/wear/src/main/res/drawable/kamakura.jpg
new file mode 100644 (file)
index 0000000..c55c5a2
Binary files /dev/null and b/wear/src/main/res/drawable/kamakura.jpg differ
index bab8452..664ef12 100644 (file)
     <string name="pref_cat_info">カメラ情報</string>
     <string name="pref_camerakit_version">Camera kit Version</string>
 
-    <string name="change_title_from_opc_to_theta">Change To Theta</string>
-    <string name="change_message_from_opc_to_theta">Change To Theta, OK?</string>
+    <string name="change_title_from_opc_to_theta">THETAと接続</string>
+    <string name="change_message_from_opc_to_theta">接続方式をTHETAにしますか?</string>
 
-    <string name="change_title_from_theta_to_opc">Change To OPC</string>
-    <string name="change_message_from_theta_to_opc">Change To OPC, OK?</string>
+    <string name="change_title_from_theta_to_opc">OPCに接続</string>
+    <string name="change_message_from_theta_to_opc">接続方式をOPCにしますか?</string>
 
 </resources>