OSDN Git Service

BLE接続を行うための準備を追加。
authorMRSa <mrsa@myad.jp>
Sat, 16 Dec 2017 15:33:37 +0000 (00:33 +0900)
committerMRSa <mrsa@myad.jp>
Sat, 16 Dec 2017 15:33:37 +0000 (00:33 +0900)
app/src/main/java/net/osdn/gokigen/a01d/A01dMain.java
app/src/main/java/net/osdn/gokigen/a01d/camera/olympus/IOlympusInterfaceProvider.java
app/src/main/java/net/osdn/gokigen/a01d/camera/olympus/wrapper/OlympusInterfaceProvider.java
app/src/main/java/net/osdn/gokigen/a01d/camera/olympus/wrapper/connection/ble/ICameraPowerOn.java [new file with mode: 0644]
app/src/main/java/net/osdn/gokigen/a01d/camera/olympus/wrapper/connection/ble/PowerOnCamera.java
app/src/main/res/layout-land/column_save_bt.xml [new file with mode: 0644]
app/src/main/res/layout-land/fragmant_camera_property.xml
app/src/main/res/layout/column_save_bt.xml [new file with mode: 0644]
app/src/main/res/layout/fragmant_camera_property.xml
app/src/main/res/values-ja/strings.xml
app/src/main/res/values/strings.xml

index 9671ffe..3c12077 100644 (file)
@@ -20,6 +20,7 @@ import net.osdn.gokigen.a01d.camera.olympus.cameraproperty.OlyCameraPropertyList
 import net.osdn.gokigen.a01d.camera.olympus.wrapper.OlympusInterfaceProvider;
 import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.ICameraStatusReceiver;
 import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.IOlyCameraConnection;
+import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.ble.ICameraPowerOn;
 import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.ble.PowerOnCamera;
 import net.osdn.gokigen.a01d.liveview.IStatusViewDrawer;
 import net.osdn.gokigen.a01d.liveview.LiveViewFragment;
@@ -30,7 +31,7 @@ import net.osdn.gokigen.a01d.preference.PreferenceFragment;
  *   A01d ;
  *
  */
-public class A01dMain extends AppCompatActivity implements ICameraStatusReceiver, IChangeScene, PowerOnCamera.PowerOnCameraCallback
+public class A01dMain extends AppCompatActivity implements ICameraStatusReceiver, IChangeScene, ICameraPowerOn.PowerOnCameraCallback
 {
     private final String TAG = toString();
     private IOlympusInterfaceProvider interfaceProvider = null;
@@ -134,9 +135,8 @@ public class A01dMain extends AppCompatActivity implements ICameraStatusReceiver
             // BLEでカメラの電源をONにする設定だった時
             try
             {
-                // カメラの電源ONクラスを呼び出しておく
-                PowerOnCamera powerOnCamera = new PowerOnCamera(this);
-                powerOnCamera.wakeup();
+                // カメラの電源ONクラスを呼び出しておく (電源ONができたら、コールバックをもらう)
+                interfaceProvider.getCameraPowerOn().wakeup(this);
             }
             catch (Exception e)
             {
index 4448ee1..3d0e15c 100644 (file)
@@ -7,6 +7,7 @@ import net.osdn.gokigen.a01d.camera.olympus.wrapper.ICameraHardwareStatus;
 import net.osdn.gokigen.a01d.camera.olympus.wrapper.ICameraInformation;
 import net.osdn.gokigen.a01d.camera.olympus.wrapper.ICameraRunMode;
 import net.osdn.gokigen.a01d.camera.olympus.wrapper.ILiveViewControl;
+import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.ble.ICameraPowerOn;
 import net.osdn.gokigen.a01d.camera.olympus.wrapper.property.IOlyCameraPropertyProvider;
 import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.IOlyCameraConnection;
 
@@ -15,6 +16,7 @@ import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.IOlyCameraConnect
  */
 public interface IOlympusInterfaceProvider
 {
+    ICameraPowerOn getCameraPowerOn();
     IOlyCameraConnection getOlyCameraConnection();
     ICameraHardwareStatus getHardwareStatus();
     IOlyCameraPropertyProvider getCameraPropertyProvider();
index 007e881..b907249 100644 (file)
@@ -10,6 +10,8 @@ import net.osdn.gokigen.a01d.camera.olympus.operation.IZoomLensControl;
 import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.ICameraStatusReceiver;
 import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.IOlyCameraConnection;
 import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.OlyCameraConnection;
+import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.ble.ICameraPowerOn;
+import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.ble.PowerOnCamera;
 import net.osdn.gokigen.a01d.camera.olympus.wrapper.property.IOlyCameraPropertyProvider;
 import net.osdn.gokigen.a01d.camera.olympus.wrapper.property.OlyCameraPropertyProxy;
 import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
@@ -28,6 +30,7 @@ public class OlympusInterfaceProvider implements IOlympusInterfaceProvider, IOly
     private final OlyCameraHardwareStatus hardwareStatus;
     private final OLYCameraPropertyListenerImpl propertyListener;
     private final OlyCameraZoomLensControl zoomLensControl;
+    private final ICameraPowerOn cameraPowerOn;
     private OlyCameraFocusControl focusControl = null;
     private OlyCameraCaptureControl captureControl = null;
 
@@ -39,6 +42,7 @@ public class OlympusInterfaceProvider implements IOlympusInterfaceProvider, IOly
         this.hardwareStatus = new OlyCameraHardwareStatus(this.wrapper.getOLYCamera());
         this.propertyListener = new OLYCameraPropertyListenerImpl(this.wrapper.getOLYCamera());
         this.zoomLensControl = new OlyCameraZoomLensControl(context, this.wrapper.getOLYCamera());
+        this.cameraPowerOn = new PowerOnCamera(this.wrapper.getOLYCamera());
     }
 
     @Override
@@ -50,6 +54,12 @@ public class OlympusInterfaceProvider implements IOlympusInterfaceProvider, IOly
     }
 
     @Override
+    public ICameraPowerOn getCameraPowerOn()
+    {
+        return (cameraPowerOn);
+    }
+
+    @Override
     public IOlyCameraConnection getOlyCameraConnection()
     {
         return (connection);
diff --git a/app/src/main/java/net/osdn/gokigen/a01d/camera/olympus/wrapper/connection/ble/ICameraPowerOn.java b/app/src/main/java/net/osdn/gokigen/a01d/camera/olympus/wrapper/connection/ble/ICameraPowerOn.java
new file mode 100644 (file)
index 0000000..7f6639f
--- /dev/null
@@ -0,0 +1,14 @@
+package net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.ble;
+
+
+public interface ICameraPowerOn
+{
+    // カメラ起動指示
+    void wakeup(PowerOnCameraCallback callback);
+
+    // 実行終了時のコールバックのインタフェース
+    interface PowerOnCameraCallback
+    {
+        void wakeupExecuted(boolean isExecute);
+    }
+}
index f83a7f2..0e7a171 100644 (file)
@@ -1,40 +1,92 @@
 package net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.ble;
 
 
+import android.bluetooth.BluetoothDevice;
+import android.content.Context;
 import android.util.Log;
 
+import jp.co.olympus.camerakit.OACentralConfiguration;
+import jp.co.olympus.camerakit.OLYCamera;
+
 /**
  *   BLE経由でカメラの電源を入れるクラス
  *
  */
-public class PowerOnCamera
+public class PowerOnCamera implements ICameraPowerOn
 {
     private final String TAG = toString();
-    private final PowerOnCameraCallback callback;
+    private final OLYCamera camera;
+    private String btName;
+    private String btCode;
 
-    public PowerOnCamera(PowerOnCameraCallback callback)
+    /**
+     *
+     */
+    public PowerOnCamera(OLYCamera camera)
     {
         Log.v(TAG, "PowerOnCamera()");
-
-        this.callback = callback;
+        this.camera = camera;
     }
 
-    public void wakeup()
+    public void wakeup(PowerOnCameraCallback callback)
     {
+        boolean isWakeup = true;
         Log.v(TAG, "PowerOnCamera::wakeup()");
 
-
+        btName = "";
+        btCode = "";
+        try
+        {
+            OACentralConfiguration oa_central = OACentralConfiguration.load();
+            btName = oa_central.getBleName();
+            btCode = oa_central.getBleCode();
+            Log.v(TAG, "Bluetooth BtName : '" + btName + "' btCode : '" + btCode + "' ");
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+/*
+        try
+        {
+            BluetoothDevice btDevice = null;
+            camera.setBluetoothDevice(btDevice);
+            camera.setBluetoothPassword(btCode);
+            camera.wakeup();
+            isWakeup = true;
+        }
+        catch (Exception e)
+        {
+            // 例外受信
+            e.printStackTrace();
+            isWakeup = false;
+        }
+*/
         // 今は暫定で返しちゃう
-        callback.wakeupExecuted(true);
+        callback.wakeupExecuted(isWakeup);
     }
 
-    /**
-     *   実行終了時のコールバックのインタフェース
-     *
-     */
-    public interface PowerOnCameraCallback
-    {
-        void wakeupExecuted(boolean isExecute);
+
+
+/*
+private BluetoothAdapter.LeScanCallback mLeScanCallback = new BluetoothAdapter.LeScanCallback(){
+    @Override
+    public void onLeScan(final BluetoothDevice device, int rssi, byte[] scanRecord){
+        if (btName.equals(device.getName())){
+            btAdapter.stopLeScan(this);
+            btDevice = device;
+            try {
+                camera.setBluetoothDevice(btDevice);
+                camera.setBluetoothPassword(btCode);
+                camera.wakeup();
+                camera.connect(OLYCamera.ConnectionType.BluetoothLE);
+            } catch (OLYCameraKitException e) {
+                Log.w(TAG, "To connect to the camera is failed: " + e.getMessage());
+            }
+        }
     }
+};
+*/
+
 
 }
diff --git a/app/src/main/res/layout-land/column_save_bt.xml b/app/src/main/res/layout-land/column_save_bt.xml
new file mode 100644 (file)
index 0000000..9dd153b
--- /dev/null
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:orientation="horizontal"
+    >
+    <TextView
+        android:layout_width="0px"
+        android:layout_height="0px"
+      />
+    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:textSize="5pt"
+        android:tag="id"
+        />
+    <Button xmlns:android="http://schemas.android.com/apk/res/android"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:tag="button"
+        android:text="@string/save_props"
+        />
+    <EditText xmlns:android="http://schemas.android.com/apk/res/android"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:hint="@string/hint_save_bt_name"
+        android:textSize="8pt"
+        android:tag="bt_name"
+        />
+    <EditText xmlns:android="http://schemas.android.com/apk/res/android"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:hint="@string/hint_save_bt_passcode"
+        android:inputType="textPassword"
+        android:password="true"
+        android:textSize="8pt"
+        android:tag="bt_passcode"
+        />
+    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:textSize="4pt"
+        android:tag="info"
+        />
+</LinearLayout>
index 57b3b01..d36dbb9 100644 (file)
@@ -21,6 +21,7 @@
             android:layout_weight="1"
             android:gravity="start"
             android:clickable="true"
+            android:focusable="true"
             android:text="@string/blank"
             android:textColor="@color/background_dark"
             android:textSize="14sp" />
@@ -42,6 +43,7 @@
             android:layout_gravity="end"
             android:visibility="invisible"
             android:clickable="true"
+            android:focusable="true"
             android:scaleType="center"
             android:contentDescription="@string/configuration"
             android:src="@drawable/ic_save_black_24dp" />
@@ -55,6 +57,7 @@
             android:layout_gravity="end"
             android:visibility="invisible"
             android:clickable="true"
+            android:focusable="true"
             android:scaleType="center"
             android:contentDescription="@string/configuration"
             android:src="@drawable/ic_refresh_black_24dp" />
@@ -68,6 +71,7 @@
             android:layout_gravity="end"
             android:visibility="visible"
             android:clickable="true"
+            android:focusable="true"
             android:scaleType="center"
             android:contentDescription="@string/restore"
             android:src="@drawable/ic_restore_page_black_24dp" />
diff --git a/app/src/main/res/layout/column_save_bt.xml b/app/src/main/res/layout/column_save_bt.xml
new file mode 100644 (file)
index 0000000..9dd153b
--- /dev/null
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:orientation="horizontal"
+    >
+    <TextView
+        android:layout_width="0px"
+        android:layout_height="0px"
+      />
+    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:textSize="5pt"
+        android:tag="id"
+        />
+    <Button xmlns:android="http://schemas.android.com/apk/res/android"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:tag="button"
+        android:text="@string/save_props"
+        />
+    <EditText xmlns:android="http://schemas.android.com/apk/res/android"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:hint="@string/hint_save_bt_name"
+        android:textSize="8pt"
+        android:tag="bt_name"
+        />
+    <EditText xmlns:android="http://schemas.android.com/apk/res/android"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:hint="@string/hint_save_bt_passcode"
+        android:inputType="textPassword"
+        android:password="true"
+        android:textSize="8pt"
+        android:tag="bt_passcode"
+        />
+    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:textSize="4pt"
+        android:tag="info"
+        />
+</LinearLayout>
index 8a5ddc4..9184f43 100644 (file)
@@ -21,6 +21,7 @@
             android:layout_weight="1"
             android:gravity="start"
             android:clickable="true"
+            android:focusable="true"
             android:text="@string/blank"
             android:textColor="@color/background_dark"
             android:textSize="14sp" />
@@ -42,6 +43,7 @@
             android:layout_gravity="end"
             android:visibility="invisible"
             android:clickable="true"
+            android:focusable="true"
             android:scaleType="center"
             android:contentDescription="@string/configuration"
             android:src="@drawable/ic_save_black_24dp" />
@@ -55,6 +57,7 @@
             android:layout_gravity="end"
             android:visibility="invisible"
             android:clickable="true"
+            android:focusable="true"
             android:scaleType="center"
             android:contentDescription="@string/configuration"
             android:src="@drawable/ic_refresh_black_24dp" />
@@ -68,6 +71,7 @@
             android:layout_gravity="end"
             android:visibility="visible"
             android:clickable="true"
+            android:focusable="true"
             android:scaleType="center"
             android:contentDescription="@string/restore"
             android:src="@drawable/ic_restore_page_black_24dp" />
index 6f81d9d..df0cbef 100644 (file)
     <string name="hint_save_props">ラベル</string>
     <string name="saved_my_props">設定を保存しました。 : </string>
 
+
+    <string name="hint_save_bt_name">名前</string>
+    <string name="hint_save_bt_passcode">パスコード</string>
+
     <string name="auto_save_props">(自動保存)</string>
     <string name="title_tab_title_load">設定反映</string>
     <string name="title_tab_title_save">設定保存</string>
index 109ecc6..f84c440 100644 (file)
     <string name="title_tab_title_save">Save</string>
     <string name="title_my_settings">Favorite Camera Properties</string>
 
+    <string name="hint_save_bt_name">Name</string>
+    <string name="hint_save_bt_passcode">Passcode</string>
+
+
     <string name="connect_start">start</string>
     <string name="connect_check_wifi">check WIFI</string>
     <string name="connect_connect">connecting</string>