• R/O
  • HTTP
  • SSH
  • HTTPS

A01d: Commit

OPC(Olympus Air)用望遠鏡アプリ。


Commit MetaInfo

Révision904bd53f088f58cf5faafc91352f2821fbcea5c7 (tree)
l'heure2018-06-11 23:49:28
AuteurMRSa <mrsa@myad...>
CommiterMRSa

Message de Log

SONYカメラの撮影機能を追加。

Change Summary

Modification

--- a/app/src/main/java/net/osdn/gokigen/a01d/A01dMain.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/A01dMain.java
@@ -130,15 +130,19 @@ public class A01dMain extends AppCompatActivity implements ICameraStatusReceiver
130130 {
131131 if (isBlePowerOn())
132132 {
133- // BLEでカメラの電源をONにする設定だった時
134- try
135- {
136- // カメラの電源ONクラスを呼び出しておく (電源ONができたら、コールバックをもらう)
137- interfaceProvider.getOlympusInterface().getCameraPowerOn().wakeup(this);
138- }
139- catch (Exception e)
133+ // BLEでPower ONは、OPCのみ対応
134+ if (interfaceProvider.useOlympusCamera())
140135 {
141- e.printStackTrace();
136+ // BLEでカメラの電源をONにする設定だった時
137+ try
138+ {
139+ // カメラの電源ONクラスを呼び出しておく (電源ONができたら、コールバックをもらう)
140+ interfaceProvider.getOlympusInterface().getCameraPowerOn().wakeup(this);
141+ }
142+ catch (Exception e)
143+ {
144+ e.printStackTrace();
145+ }
142146 }
143147 }
144148 else if (isAutoConnectCamera())
@@ -177,7 +181,7 @@ public class A01dMain extends AppCompatActivity implements ICameraStatusReceiver
177181 super.onPause();
178182 try
179183 {
180- ICameraConnection connection = interfaceProvider.getOlympusInterface().getOlyCameraConnection();
184+ ICameraConnection connection = getCameraConnection();
181185 if (connection != null)
182186 {
183187 connection.stopWatchWifiStatus(this);
@@ -198,27 +202,31 @@ public class A01dMain extends AppCompatActivity implements ICameraStatusReceiver
198202 {
199203 try
200204 {
205+ ICameraConnection connection = getCameraConnection();
201206 if (!useOlympusCamera())
202207 {
203208 // OPCカメラでない場合には、「OPCカメラのみ有効です」表示をして画面遷移させない
204209 Toast.makeText(getApplicationContext(), getText(R.string.only_opc_feature), Toast.LENGTH_SHORT).show();
205- return;
206210 }
207- ICameraConnection connection = interfaceProvider.getOlympusInterface().getOlyCameraConnection();
208- if (connection != null) {
209- ICameraConnection.CameraConnectionStatus status = connection.getConnectionStatus();
210- if (status == ICameraConnection.CameraConnectionStatus.CONNECTED)
211+ else
212+ {
213+ // OPC カメラの場合...
214+ if (connection != null)
211215 {
212- if (propertyListFragment == null)
216+ ICameraConnection.CameraConnectionStatus status = connection.getConnectionStatus();
217+ if (status == ICameraConnection.CameraConnectionStatus.CONNECTED)
213218 {
214- propertyListFragment = new OlyCameraPropertyListFragment();
219+ if (propertyListFragment == null)
220+ {
221+ propertyListFragment = new OlyCameraPropertyListFragment();
222+ }
223+ propertyListFragment.setInterface(this, interfaceProvider.getOlympusInterface().getCameraPropertyProvider());
224+ FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
225+ transaction.replace(R.id.fragment1, propertyListFragment);
226+ // backstackに追加
227+ transaction.addToBackStack(null);
228+ transaction.commit();
215229 }
216- propertyListFragment.setInterface(this, interfaceProvider.getOlympusInterface().getCameraPropertyProvider());
217- FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
218- transaction.replace(R.id.fragment1, propertyListFragment);
219- // backstackに追加
220- transaction.addToBackStack(null);
221- transaction.commit();
222230 }
223231 }
224232 }
@@ -241,7 +249,7 @@ public class A01dMain extends AppCompatActivity implements ICameraStatusReceiver
241249 {
242250 preferenceFragment = new PreferenceFragment();
243251 }
244- preferenceFragment.setInterface(this, interfaceProvider.getOlympusInterface(), this);
252+ preferenceFragment.setInterface(this, interfaceProvider, this);
245253 FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
246254 transaction.replace(R.id.fragment1, preferenceFragment);
247255 // backstackに追加
@@ -285,7 +293,7 @@ public class A01dMain extends AppCompatActivity implements ICameraStatusReceiver
285293 }
286294 try
287295 {
288- ICameraConnection connection = (useOlympusCamera()) ? interfaceProvider.getOlympusInterface().getOlyCameraConnection() : interfaceProvider.getSonyInterface().getSonyCameraConnection();
296+ ICameraConnection connection = getCameraConnection();
289297 if (connection != null)
290298 {
291299 ICameraConnection.CameraConnectionStatus status = connection.getConnectionStatus();
@@ -314,7 +322,7 @@ public class A01dMain extends AppCompatActivity implements ICameraStatusReceiver
314322 Log.v(TAG, "exitApplication()");
315323 try
316324 {
317- ICameraConnection connection = interfaceProvider.getOlympusInterface().getOlyCameraConnection();
325+ ICameraConnection connection = getCameraConnection();
318326 if (connection != null)
319327 {
320328 connection.disconnect(true);
@@ -340,7 +348,7 @@ public class A01dMain extends AppCompatActivity implements ICameraStatusReceiver
340348 if (statusViewDrawer != null)
341349 {
342350 statusViewDrawer.updateStatusView(message);
343- ICameraConnection connection = interfaceProvider.getOlympusInterface().getOlyCameraConnection();
351+ ICameraConnection connection = getCameraConnection();
344352 if (connection != null)
345353 {
346354 statusViewDrawer.updateConnectionStatus(connection.getConnectionStatus());
@@ -362,16 +370,9 @@ public class A01dMain extends AppCompatActivity implements ICameraStatusReceiver
362370 {
363371 Log.v(TAG, "onCameraConnected()");
364372
365- try {
366- ICameraConnection connection;
367- if (interfaceProvider.useOlympusCamera())
368- {
369- connection = interfaceProvider.getOlympusInterface().getOlyCameraConnection();
370- } else
371- {
372- connection = interfaceProvider.getSonyInterface().getSonyCameraConnection();
373- }
374-
373+ try
374+ {
375+ ICameraConnection connection = getCameraConnection();
375376 if (connection != null)
376377 {
377378 // クラス構造をミスった...のでこんなところで、無理やりステータスを更新する
@@ -417,7 +418,7 @@ public class A01dMain extends AppCompatActivity implements ICameraStatusReceiver
417418 try
418419 {
419420 e.printStackTrace();
420- ICameraConnection connection = interfaceProvider.getOlympusInterface().getOlyCameraConnection();
421+ ICameraConnection connection = getCameraConnection();
421422 if (connection != null)
422423 {
423424 connection.alertConnectingFailed(message + " " + e.getLocalizedMessage());
@@ -502,6 +503,24 @@ public class A01dMain extends AppCompatActivity implements ICameraStatusReceiver
502503 }
503504
504505 /**
506+ *
507+ *
508+ *
509+ */
510+ private ICameraConnection getCameraConnection()
511+ {
512+ ICameraConnection connection;
513+ if (interfaceProvider.useOlympusCamera())
514+ {
515+ connection = interfaceProvider.getOlympusInterface().getOlyCameraConnection();
516+ } else
517+ {
518+ connection = interfaceProvider.getSonyInterface().getSonyCameraConnection();
519+ }
520+ return (connection);
521+ }
522+
523+ /**
505524 * カメラへのBLE接続指示が完了したとき
506525 *
507526 * @param isExecuted true : BLEで起動した, false : 起動していない、その他
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/CameraInterfaceProvider.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/CameraInterfaceProvider.java
@@ -33,12 +33,6 @@ public class CameraInterfaceProvider implements IInterfaceProvider
3333 }
3434
3535 @Override
36- public IDisplayInjector getOlympusDisplayInjector()
37- {
38- return (olympus);
39- }
40-
41- @Override
4236 public IOlympusLiveViewListener getOlympusLiveViewListener()
4337 {
4438 return (olympus.getLiveViewListener());
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/olympus/wrapper/ICameraInformation.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/ICameraInformation.java
@@ -1,4 +1,4 @@
1-package net.osdn.gokigen.a01d.camera.olympus.wrapper;
1+package net.osdn.gokigen.a01d.camera;
22
33
44 public interface ICameraInformation
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/olympus/operation/ICaptureControl.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/ICaptureControl.java
@@ -1,4 +1,4 @@
1-package net.osdn.gokigen.a01d.camera.olympus.operation;
1+package net.osdn.gokigen.a01d.camera;
22
33 /**
44 * 撮影用のインタフェース
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/olympus/operation/IFocusingControl.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/IFocusingControl.java
@@ -1,4 +1,4 @@
1-package net.osdn.gokigen.a01d.camera.olympus.operation;
1+package net.osdn.gokigen.a01d.camera;
22
33 import android.view.MotionEvent;
44
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/IInterfaceProvider.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/IInterfaceProvider.java
@@ -11,7 +11,6 @@ import net.osdn.gokigen.a01d.camera.sony.ISonyInterfaceProvider;
1111 public interface IInterfaceProvider
1212 {
1313 IOlympusInterfaceProvider getOlympusInterface();
14- IDisplayInjector getOlympusDisplayInjector();
1514 IOlympusLiveViewListener getOlympusLiveViewListener();
1615
1716 ISonyInterfaceProvider getSonyInterface();
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/olympus/operation/IZoomLensControl.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/IZoomLensControl.java
@@ -1,4 +1,4 @@
1-package net.osdn.gokigen.a01d.camera.olympus.operation;
1+package net.osdn.gokigen.a01d.camera;
22
33 /**
44 * ズームレンズの状態
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/olympus/IOlympusInterfaceProvider.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/olympus/IOlympusInterfaceProvider.java
@@ -1,16 +1,17 @@
11 package net.osdn.gokigen.a01d.camera.olympus;
22
3-import net.osdn.gokigen.a01d.camera.olympus.operation.ICaptureControl;
4-import net.osdn.gokigen.a01d.camera.olympus.operation.IFocusingControl;
5-import net.osdn.gokigen.a01d.camera.olympus.operation.IZoomLensControl;
3+import net.osdn.gokigen.a01d.camera.ICaptureControl;
4+import net.osdn.gokigen.a01d.camera.IFocusingControl;
5+import net.osdn.gokigen.a01d.camera.IZoomLensControl;
66 import net.osdn.gokigen.a01d.camera.olympus.wrapper.ICameraHardwareStatus;
7-import net.osdn.gokigen.a01d.camera.olympus.wrapper.ICameraInformation;
7+import net.osdn.gokigen.a01d.camera.ICameraInformation;
88 import net.osdn.gokigen.a01d.camera.olympus.wrapper.ICameraRunMode;
99 import net.osdn.gokigen.a01d.camera.ILiveViewControl;
1010 import net.osdn.gokigen.a01d.camera.olympus.wrapper.IOlympusLiveViewListener;
1111 import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.ble.ICameraPowerOn;
1212 import net.osdn.gokigen.a01d.camera.olympus.wrapper.property.IOlyCameraPropertyProvider;
1313 import net.osdn.gokigen.a01d.camera.ICameraConnection;
14+import net.osdn.gokigen.a01d.camera.sony.wrapper.IDisplayInjector;
1415
1516 /**
1617 *
@@ -27,6 +28,7 @@ public interface IOlympusInterfaceProvider
2728 IFocusingControl getFocusingControl();
2829 ICaptureControl getCaptureControl();
2930 ICameraInformation getCameraInformation();
31+ IDisplayInjector getDisplayInjector();
3032
3133 IOlympusLiveViewListener getLiveViewListener();
3234 }
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/olympus/operation/takepicture/AutoFocusControl.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/olympus/operation/takepicture/OlympusAutoFocusControl.java
@@ -19,7 +19,7 @@ import jp.co.olympus.camerakit.OLYCameraKitException;
1919 * 3. unlockAutoFocus() で AF-Unlock を実行
2020 *
2121 */
22-public class AutoFocusControl implements OLYCamera.TakePictureCallback
22+public class OlympusAutoFocusControl implements OLYCamera.TakePictureCallback
2323 {
2424 private final OLYCamera camera;
2525 private final IIndicatorControl indicator;
@@ -31,7 +31,7 @@ public class AutoFocusControl implements OLYCamera.TakePictureCallback
3131 * コンストラクタ
3232 *
3333 */
34- public AutoFocusControl(OLYCamera camera, IAutoFocusFrameDisplay frameDisplayer, IIndicatorControl indicator)
34+ public OlympusAutoFocusControl(OLYCamera camera, IAutoFocusFrameDisplay frameDisplayer, IIndicatorControl indicator)
3535 {
3636 this.camera = camera;
3737 this.frameDisplayer = frameDisplayer;
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/olympus/wrapper/OLYCameraPropertyListenerImpl.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/olympus/wrapper/OLYCameraPropertyListenerImpl.java
@@ -2,8 +2,8 @@ package net.osdn.gokigen.a01d.camera.olympus.wrapper;
22
33 import android.util.Log;
44
5+import net.osdn.gokigen.a01d.camera.ICameraInformation;
56 import net.osdn.gokigen.a01d.camera.olympus.wrapper.property.IOlyCameraProperty;
6-import net.osdn.gokigen.a01d.liveview.IStatusViewDrawer;
77
88 import jp.co.olympus.camerakit.OLYCamera;
99 import jp.co.olympus.camerakit.OLYCameraPropertyListener;
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/olympus/wrapper/OlyCameraCaptureControl.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/olympus/wrapper/OlyCameraCaptureControl.java
@@ -2,7 +2,7 @@ package net.osdn.gokigen.a01d.camera.olympus.wrapper;
22
33 import android.util.Log;
44
5-import net.osdn.gokigen.a01d.camera.olympus.operation.ICaptureControl;
5+import net.osdn.gokigen.a01d.camera.ICaptureControl;
66 import net.osdn.gokigen.a01d.camera.olympus.operation.takepicture.SingleShotControl;
77 import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
88 import net.osdn.gokigen.a01d.liveview.IIndicatorControl;
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/olympus/wrapper/OlyCameraFocusControl.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/olympus/wrapper/OlyCameraFocusControl.java
@@ -1,12 +1,10 @@
11 package net.osdn.gokigen.a01d.camera.olympus.wrapper;
22
33 import android.graphics.PointF;
4-import android.util.Log;
54 import android.view.MotionEvent;
65
7-import net.osdn.gokigen.a01d.camera.olympus.operation.IFocusingControl;
8-import net.osdn.gokigen.a01d.camera.olympus.operation.takepicture.AutoFocusControl;
9-import net.osdn.gokigen.a01d.camera.olympus.wrapper.property.IOlyCameraPropertyProvider;
6+import net.osdn.gokigen.a01d.camera.IFocusingControl;
7+import net.osdn.gokigen.a01d.camera.olympus.operation.takepicture.OlympusAutoFocusControl;
108 import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
119 import net.osdn.gokigen.a01d.liveview.IIndicatorControl;
1210
@@ -17,13 +15,13 @@ import net.osdn.gokigen.a01d.liveview.IIndicatorControl;
1715 public class OlyCameraFocusControl implements IFocusingControl
1816 {
1917 private final String TAG = toString();
20- private final AutoFocusControl afControl;
18+ private final OlympusAutoFocusControl afControl;
2119 private final IAutoFocusFrameDisplay frameDisplay;
2220
2321 public OlyCameraFocusControl(OlyCameraWrapper wrapper, IAutoFocusFrameDisplay frameDisplayer, IIndicatorControl indicator)
2422 {
2523 this.frameDisplay = frameDisplayer;
26- afControl = new AutoFocusControl(wrapper.getOLYCamera(), frameDisplayer, indicator);
24+ afControl = new OlympusAutoFocusControl(wrapper.getOLYCamera(), frameDisplayer, indicator);
2725 }
2826
2927 @Override
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/olympus/wrapper/OlyCameraZoomLensControl.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/olympus/wrapper/OlyCameraZoomLensControl.java
@@ -5,7 +5,7 @@ import android.content.SharedPreferences;
55 import android.support.v7.preference.PreferenceManager;
66 import android.util.Log;
77
8-import net.osdn.gokigen.a01d.camera.olympus.operation.IZoomLensControl;
8+import net.osdn.gokigen.a01d.camera.IZoomLensControl;
99 import net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor;
1010
1111 import jp.co.olympus.camerakit.OLYCamera;
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/olympus/wrapper/OlympusInterfaceProvider.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/olympus/wrapper/OlympusInterfaceProvider.java
@@ -2,12 +2,13 @@ package net.osdn.gokigen.a01d.camera.olympus.wrapper;
22
33 import android.app.Activity;
44
5+import net.osdn.gokigen.a01d.camera.ICameraInformation;
56 import net.osdn.gokigen.a01d.camera.ILiveViewControl;
67 import net.osdn.gokigen.a01d.camera.sony.wrapper.IDisplayInjector;
78 import net.osdn.gokigen.a01d.camera.olympus.IOlympusInterfaceProvider;
8-import net.osdn.gokigen.a01d.camera.olympus.operation.ICaptureControl;
9-import net.osdn.gokigen.a01d.camera.olympus.operation.IFocusingControl;
10-import net.osdn.gokigen.a01d.camera.olympus.operation.IZoomLensControl;
9+import net.osdn.gokigen.a01d.camera.ICaptureControl;
10+import net.osdn.gokigen.a01d.camera.IFocusingControl;
11+import net.osdn.gokigen.a01d.camera.IZoomLensControl;
1112 import net.osdn.gokigen.a01d.camera.ICameraStatusReceiver;
1213 import net.osdn.gokigen.a01d.camera.ICameraConnection;
1314 import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.OlyCameraConnection;
@@ -118,4 +119,11 @@ public class OlympusInterfaceProvider implements IOlympusInterfaceProvider, IDis
118119 {
119120 return (wrapper);
120121 }
122+
123+ @Override
124+ public IDisplayInjector getDisplayInjector()
125+ {
126+ return (this);
127+ }
128+
121129 }
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/ISonyInterfaceProvider.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/ISonyInterfaceProvider.java
@@ -1,7 +1,12 @@
11 package net.osdn.gokigen.a01d.camera.sony;
22
33 import net.osdn.gokigen.a01d.camera.ICameraConnection;
4+import net.osdn.gokigen.a01d.camera.ICameraInformation;
5+import net.osdn.gokigen.a01d.camera.ICaptureControl;
6+import net.osdn.gokigen.a01d.camera.IFocusingControl;
47 import net.osdn.gokigen.a01d.camera.ILiveViewControl;
8+import net.osdn.gokigen.a01d.camera.IZoomLensControl;
9+import net.osdn.gokigen.a01d.camera.sony.wrapper.IDisplayInjector;
510 import net.osdn.gokigen.a01d.liveview.liveviewlistener.ILiveViewListener;
611
712 public interface ISonyInterfaceProvider
@@ -9,5 +14,10 @@ public interface ISonyInterfaceProvider
914 ICameraConnection getSonyCameraConnection();
1015 ILiveViewControl getSonyLiveViewControl();
1116 ILiveViewListener getSonyLiveViewListener();
17+ IFocusingControl getFocusingControl();
18+ ICameraInformation getCameraInformation();
19+ IZoomLensControl getZoomLensControl();
20+ ICaptureControl getCaptureControl();
21+ IDisplayInjector getDisplayInjector();
1222
1323 }
--- /dev/null
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/operation/SonyCameraCaptureControl.java
@@ -0,0 +1,44 @@
1+package net.osdn.gokigen.a01d.camera.sony.operation;
2+
3+import android.support.annotation.NonNull;
4+import android.util.Log;
5+
6+import net.osdn.gokigen.a01d.camera.ICaptureControl;
7+import net.osdn.gokigen.a01d.camera.sony.operation.takepicture.SingleShotControl;
8+import net.osdn.gokigen.a01d.camera.sony.wrapper.ISonyCameraApi;
9+import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
10+import net.osdn.gokigen.a01d.liveview.IIndicatorControl;
11+
12+public class SonyCameraCaptureControl implements ICaptureControl
13+{
14+ private static final String TAG = SonyCameraCaptureControl.class.getSimpleName();
15+ private final SingleShotControl singleShotControl;
16+
17+ public SonyCameraCaptureControl(@NonNull IAutoFocusFrameDisplay frameDisplayer, @NonNull IIndicatorControl indicator)
18+ {
19+ singleShotControl = new SingleShotControl(frameDisplayer, indicator);
20+ }
21+
22+ public void setCameraApi(@NonNull ISonyCameraApi sonyCameraApi)
23+ {
24+ singleShotControl.setCameraApi(sonyCameraApi);
25+ }
26+
27+ /**
28+ * 撮影する
29+ *
30+ */
31+ @Override
32+ public void doCapture(int kind)
33+ {
34+ Log.v(TAG, "doCapture() : " + kind);
35+ try
36+ {
37+ singleShotControl.singleShot();
38+ }
39+ catch (Exception e)
40+ {
41+ e.printStackTrace();
42+ }
43+ }
44+}
--- /dev/null
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/operation/SonyCameraFocusControl.java
@@ -0,0 +1,69 @@
1+package net.osdn.gokigen.a01d.camera.sony.operation;
2+
3+import android.graphics.PointF;
4+import android.support.annotation.NonNull;
5+import android.util.Log;
6+import android.view.MotionEvent;
7+
8+import net.osdn.gokigen.a01d.camera.IFocusingControl;
9+import net.osdn.gokigen.a01d.camera.olympus.operation.takepicture.OlympusAutoFocusControl;
10+import net.osdn.gokigen.a01d.camera.sony.operation.takepicture.SonyAutoFocusControl;
11+import net.osdn.gokigen.a01d.camera.sony.wrapper.ISonyCameraApi;
12+import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
13+import net.osdn.gokigen.a01d.liveview.IIndicatorControl;
14+
15+public class SonyCameraFocusControl implements IFocusingControl
16+{
17+ private final String TAG = toString();
18+ private final SonyAutoFocusControl afControl;
19+ private final IAutoFocusFrameDisplay frameDisplay;
20+
21+ public SonyCameraFocusControl(@NonNull final IAutoFocusFrameDisplay frameDisplayer, @NonNull final IIndicatorControl indicator)
22+ {
23+ this.frameDisplay = frameDisplayer;
24+ afControl = new SonyAutoFocusControl(frameDisplayer, indicator);
25+ }
26+
27+ public void setCameraApi(@NonNull ISonyCameraApi sonyCameraApi)
28+ {
29+ afControl.setCameraApi(sonyCameraApi);
30+ }
31+
32+ @Override
33+ public boolean driveAutoFocus(final MotionEvent motionEvent)
34+ {
35+ Log.v(TAG, "driveAutoFocus()");
36+ if (motionEvent.getAction() != MotionEvent.ACTION_DOWN)
37+ {
38+ return (false);
39+ }
40+ try
41+ {
42+ PointF point = frameDisplay.getPointWithEvent(motionEvent);
43+ if (frameDisplay.isContainsPoint(point))
44+ {
45+ afControl.lockAutoFocus(point);
46+ }
47+ }
48+ catch (Exception e)
49+ {
50+ e.printStackTrace();
51+ }
52+ return (false);
53+ }
54+
55+ @Override
56+ public void unlockAutoFocus()
57+ {
58+ Log.v(TAG, "unlockAutoFocus()");
59+ try
60+ {
61+ afControl.unlockAutoFocus();
62+ frameDisplay.hideFocusFrame();
63+ }
64+ catch (Exception e)
65+ {
66+ e.printStackTrace();
67+ }
68+ }
69+}
--- /dev/null
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/operation/SonyCameraZoomLensControl.java
@@ -0,0 +1,67 @@
1+package net.osdn.gokigen.a01d.camera.sony.operation;
2+
3+import android.util.Log;
4+
5+import net.osdn.gokigen.a01d.camera.IZoomLensControl;
6+
7+public class SonyCameraZoomLensControl implements IZoomLensControl
8+{
9+ private final String TAG = toString();
10+
11+ public SonyCameraZoomLensControl()
12+ {
13+ Log.v(TAG, "SonyCameraZoomLensControl()");
14+ }
15+
16+ @Override
17+ public boolean canZoom() {
18+ Log.v(TAG, "canZoom()");
19+ return false;
20+ }
21+
22+ @Override
23+ public void updateStatus()
24+ {
25+ Log.v(TAG, "updateStatus()");
26+ }
27+
28+ @Override
29+ public float getMaximumFocalLength()
30+ {
31+ Log.v(TAG, "getMaximumFocalLength()");
32+ return (0);
33+ }
34+
35+ @Override
36+ public float getMinimumFocalLength()
37+ {
38+ Log.v(TAG, "getMinimumFocalLength()");
39+ return (0);
40+ }
41+
42+ @Override
43+ public float getCurrentFocalLength()
44+ {
45+ Log.v(TAG, "getCurrentFocalLength()");
46+ return 0;
47+ }
48+
49+ @Override
50+ public void driveZoomLens(float targetLength)
51+ {
52+ Log.v(TAG, "driveZoomLens() : " + targetLength);
53+ }
54+
55+ @Override
56+ public void moveInitialZoomPosition()
57+ {
58+ Log.v(TAG, "moveInitialZoomPosition()");
59+ }
60+
61+ @Override
62+ public boolean isDrivingZoomLens()
63+ {
64+ Log.v(TAG, "isDrivingZoomLens()");
65+ return (false);
66+ }
67+}
--- /dev/null
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/operation/takepicture/SingleShotControl.java
@@ -0,0 +1,81 @@
1+package net.osdn.gokigen.a01d.camera.sony.operation.takepicture;
2+
3+import android.graphics.RectF;
4+import android.support.annotation.NonNull;
5+import android.util.Log;
6+
7+import net.osdn.gokigen.a01d.camera.sony.wrapper.ISonyCameraApi;
8+import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
9+import net.osdn.gokigen.a01d.liveview.IIndicatorControl;
10+
11+import org.json.JSONObject;
12+
13+public class SingleShotControl
14+{
15+ private static final String TAG = SingleShotControl.class.getSimpleName();
16+ private final IAutoFocusFrameDisplay frameDisplayer;
17+ private final IIndicatorControl indicator;
18+ private ISonyCameraApi cameraApi = null;
19+
20+ /**
21+ *
22+ *
23+ */
24+ public SingleShotControl(@NonNull IAutoFocusFrameDisplay frameDisplayer, @NonNull IIndicatorControl indicator)
25+ {
26+ this.frameDisplayer = frameDisplayer;
27+ this.indicator = indicator;
28+ }
29+
30+ /**
31+ *
32+ *
33+ */
34+ public void setCameraApi(@NonNull ISonyCameraApi sonyCameraApi)
35+ {
36+ this.cameraApi = sonyCameraApi;
37+ }
38+
39+ /**
40+ *
41+ *
42+ */
43+ public void singleShot()
44+ {
45+ Log.v(TAG, "singleShot()");
46+ if (cameraApi == null)
47+ {
48+ Log.v(TAG, "ISonyCameraApi is null...");
49+ return;
50+ }
51+ try
52+ {
53+ Thread thread = new Thread(new Runnable()
54+ {
55+ @Override
56+ public void run()
57+ {
58+ try
59+ {
60+ //JSONObject resultsObj = cameraApi.awaitTakePicture();
61+ JSONObject resultsObj = cameraApi.actTakePicture();
62+ if (resultsObj == null)
63+ {
64+ Log.v(TAG, "setTouchAFPosition() reply is null.");
65+ }
66+ }
67+ catch (Exception e)
68+ {
69+ e.printStackTrace();
70+ }
71+ frameDisplayer.hideFocusFrame();
72+ }
73+ });
74+ thread.start();
75+ }
76+ catch (Exception e)
77+ {
78+ e.printStackTrace();
79+ }
80+ }
81+}
--- /dev/null
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/operation/takepicture/SonyAutoFocusControl.java
@@ -0,0 +1,224 @@
1+package net.osdn.gokigen.a01d.camera.sony.operation.takepicture;
2+
3+import android.graphics.PointF;
4+import android.graphics.RectF;
5+import android.support.annotation.NonNull;
6+import android.util.Log;
7+
8+import net.osdn.gokigen.a01d.camera.sony.wrapper.ISonyCameraApi;
9+import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
10+import net.osdn.gokigen.a01d.liveview.IIndicatorControl;
11+
12+import org.json.JSONArray;
13+import org.json.JSONObject;
14+
15+
16+/**
17+ *
18+ *
19+ */
20+public class SonyAutoFocusControl
21+{
22+ private static final String TAG = SonyAutoFocusControl.class.getSimpleName();
23+ private final IIndicatorControl indicator;
24+ private final IAutoFocusFrameDisplay frameDisplayer;
25+ private ISonyCameraApi cameraApi = null;
26+
27+ /**
28+ *
29+ *
30+ */
31+ public SonyAutoFocusControl(@NonNull final IAutoFocusFrameDisplay frameDisplayer, final IIndicatorControl indicator)
32+ {
33+ this.frameDisplayer = frameDisplayer;
34+ this.indicator = indicator;
35+ }
36+
37+ /**
38+ *
39+ *
40+ */
41+ public void setCameraApi(@NonNull ISonyCameraApi sonyCameraApi)
42+ {
43+ this.cameraApi = sonyCameraApi;
44+ }
45+
46+ /**
47+ *
48+ *
49+ */
50+ public void lockAutoFocus(@NonNull final PointF point)
51+ {
52+ Log.v(TAG, "lockAutoFocus() : [" + point.x + ", " + point.y + "]");
53+ if (cameraApi == null)
54+ {
55+ Log.v(TAG, "ISonyCameraApi is null...");
56+ return;
57+ }
58+ try
59+ {
60+ Thread thread = new Thread(new Runnable()
61+ {
62+ @Override
63+ public void run()
64+ {
65+ RectF preFocusFrameRect = getPreFocusFrameRect(point);
66+ try
67+ {
68+ showFocusFrame(preFocusFrameRect, IAutoFocusFrameDisplay.FocusFrameStatus.Running, 0.0);
69+
70+ Log.v(TAG, "AF (" + point.x + ", " + point.y + ")");
71+ JSONObject resultsObj = cameraApi.setTouchAFPosition(point.x, point.y);
72+ if (resultsObj == null)
73+ {
74+ Log.v(TAG, "setTouchAFPosition() reply is null.");
75+ }
76+ if (findTouchAFPositionResult(resultsObj))
77+ {
78+ // AF FOCUSED
79+ Log.v(TAG, "lockAutoFocus() : FOCUSED");
80+ showFocusFrame(preFocusFrameRect, IAutoFocusFrameDisplay.FocusFrameStatus.Focused, 0.0);
81+ }
82+ else
83+ {
84+ // AF ERROR
85+ Log.v(TAG, "lockAutoFocus() : ERROR");
86+ showFocusFrame(preFocusFrameRect, IAutoFocusFrameDisplay.FocusFrameStatus.Failed, 1.0);
87+ }
88+ }
89+ catch (Exception e)
90+ {
91+ e.printStackTrace();
92+ try
93+ {
94+ showFocusFrame(preFocusFrameRect, IAutoFocusFrameDisplay.FocusFrameStatus.Errored, 1.0);
95+ }
96+ catch (Exception ee)
97+ {
98+ ee.printStackTrace();
99+ }
100+ }
101+ }
102+ });
103+ thread.start();
104+ }
105+ catch (Exception e)
106+ {
107+ e.printStackTrace();
108+ }
109+ }
110+
111+ /**
112+ *
113+ *
114+ */
115+ public void unlockAutoFocus()
116+ {
117+ Log.v(TAG, "unlockAutoFocus()");
118+ if (cameraApi == null)
119+ {
120+ Log.v(TAG, "ISonyCameraApi is null...");
121+ return;
122+ }
123+ try
124+ {
125+ Thread thread = new Thread(new Runnable()
126+ {
127+ @Override
128+ public void run()
129+ {
130+ try
131+ {
132+ JSONObject resultsObj = cameraApi.cancelTouchAFPosition();
133+ if (resultsObj == null)
134+ {
135+ Log.v(TAG, "cancelTouchAFPosition() reply is null.");
136+ }
137+ hideFocusFrame();
138+ }
139+ catch (Exception e)
140+ {
141+ e.printStackTrace();
142+ }
143+ }
144+ });
145+ thread.start();
146+ }
147+ catch (Exception e)
148+ {
149+ e.printStackTrace();
150+ }
151+ }
152+
153+ /**
154+ *
155+ *
156+ */
157+ private void showFocusFrame(RectF rect, IAutoFocusFrameDisplay.FocusFrameStatus status, double duration)
158+ {
159+ frameDisplayer.showFocusFrame(rect, status, duration);
160+ indicator.onAfLockUpdate(IAutoFocusFrameDisplay.FocusFrameStatus.Focused == status);
161+ }
162+
163+ /**
164+ *
165+ *
166+ */
167+ private void hideFocusFrame()
168+ {
169+ frameDisplayer.hideFocusFrame();
170+ indicator.onAfLockUpdate(false);
171+ }
172+
173+ /**
174+ *
175+ *
176+ */
177+ private RectF getPreFocusFrameRect(@NonNull PointF point)
178+ {
179+ float imageWidth = 1.0f;
180+ float imageHeight = 1.0f;
181+ imageWidth = frameDisplayer.getContentSizeWidth();
182+ imageHeight = frameDisplayer.getContentSizeHeight();
183+
184+ // Display a provisional focus frame at the touched point.
185+ float focusWidth = 0.125f; // 0.125 is rough estimate.
186+ float focusHeight = 0.125f;
187+ if (imageWidth > imageHeight)
188+ {
189+ focusHeight *= (imageWidth / imageHeight);
190+ }
191+ else
192+ {
193+ focusHeight *= (imageHeight / imageWidth);
194+ }
195+ return (new RectF(point.x - focusWidth / 2.0f, point.y - focusHeight / 2.0f,
196+ point.x + focusWidth / 2.0f, point.y + focusHeight / 2.0f));
197+ }
198+
199+ /**
200+ *
201+ *
202+ */
203+ private static boolean findTouchAFPositionResult(JSONObject replyJson)
204+ {
205+ boolean afResult = false;
206+ try
207+ {
208+ int indexOfTouchAFPositionResult = 1;
209+ JSONArray resultsObj = replyJson.getJSONArray("result");
210+ if (!resultsObj.isNull(indexOfTouchAFPositionResult))
211+ {
212+ JSONObject touchAFPositionResultObj = resultsObj.getJSONObject(indexOfTouchAFPositionResult);
213+ afResult = touchAFPositionResultObj.getBoolean("AFResult");
214+ Log.v(TAG, "AF Result : " + afResult);
215+ }
216+ }
217+ catch (Exception e)
218+ {
219+ e.printStackTrace();
220+ }
221+ return (afResult);
222+ }
223+
224+}
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/wrapper/ISonyCameraApi.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/wrapper/ISonyCameraApi.java
@@ -15,11 +15,16 @@ public interface ISonyCameraApi
1515 JSONObject getAvailableShootMode();
1616 JSONObject getSupportedShootMode();
1717
18+ JSONObject setTouchAFPosition(double Xpos, double Ypos);
19+ JSONObject getTouchAFPosition();
20+ JSONObject cancelTouchAFPosition();
21+
1822 JSONObject startLiveview();
1923 JSONObject stopLiveview();
2024
2125 JSONObject startRecMode();
2226 JSONObject actTakePicture();
27+ JSONObject awaitTakePicture();
2328
2429 JSONObject startMovieRec();
2530 JSONObject stopMovieRec();
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/wrapper/SonyCameraApi.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/wrapper/SonyCameraApi.java
@@ -164,6 +164,49 @@ class SonyCameraApi implements ISonyCameraApi
164164 }
165165
166166 @Override
167+ public JSONObject setTouchAFPosition(double Xpos, double Ypos)
168+ {
169+ try
170+ {
171+ Log.v(TAG, "setTouchAFPosition (" + Xpos + ", " + Ypos + ")");
172+ return (communicateJSON("camera", "setTouchAFPosition", new JSONArray().put(Xpos).put(Ypos), "1.0", -1));
173+ }
174+ catch (Exception e)
175+ {
176+ e.printStackTrace();
177+ }
178+ return (new JSONObject());
179+ }
180+
181+ @Override
182+ public JSONObject getTouchAFPosition()
183+ {
184+ try
185+ {
186+ return (communicateJSON("camera", "getTouchAFPosition", new JSONArray(), "1.0", -1));
187+ }
188+ catch (Exception e)
189+ {
190+ e.printStackTrace();
191+ }
192+ return (new JSONObject());
193+ }
194+
195+ @Override
196+ public JSONObject cancelTouchAFPosition()
197+ {
198+ try
199+ {
200+ return (communicateJSON("camera", "cancelTouchAFPosition", new JSONArray(), "1.0", -1));
201+ }
202+ catch (Exception e)
203+ {
204+ e.printStackTrace();
205+ }
206+ return (new JSONObject());
207+ }
208+
209+ @Override
167210 public JSONObject startLiveview()
168211 {
169212 try {
@@ -211,6 +254,20 @@ class SonyCameraApi implements ISonyCameraApi
211254 }
212255
213256 @Override
257+ public JSONObject awaitTakePicture()
258+ {
259+ try
260+ {
261+ return (communicateJSON("camera", "awaitTakePicture", new JSONArray(), "1.0", -1));
262+ }
263+ catch (Exception e)
264+ {
265+ e.printStackTrace();
266+ }
267+ return (new JSONObject());
268+ }
269+
270+ @Override
214271 public JSONObject startMovieRec()
215272 {
216273 try {
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/wrapper/SonyCameraWrapper.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/wrapper/SonyCameraWrapper.java
@@ -6,25 +6,35 @@ import android.support.annotation.Nullable;
66 import android.util.Log;
77
88 import net.osdn.gokigen.a01d.camera.ICameraConnection;
9+import net.osdn.gokigen.a01d.camera.ICameraInformation;
910 import net.osdn.gokigen.a01d.camera.ICameraStatusReceiver;
11+import net.osdn.gokigen.a01d.camera.ICaptureControl;
12+import net.osdn.gokigen.a01d.camera.IFocusingControl;
1013 import net.osdn.gokigen.a01d.camera.ILiveViewControl;
14+import net.osdn.gokigen.a01d.camera.IZoomLensControl;
15+import net.osdn.gokigen.a01d.camera.olympus.wrapper.IFocusingModeNotify;
1116 import net.osdn.gokigen.a01d.camera.sony.ISonyInterfaceProvider;
17+import net.osdn.gokigen.a01d.camera.sony.operation.SonyCameraCaptureControl;
18+import net.osdn.gokigen.a01d.camera.sony.operation.SonyCameraFocusControl;
1219 import net.osdn.gokigen.a01d.camera.sony.wrapper.connection.SonyCameraConnection;
1320 import net.osdn.gokigen.a01d.camera.sony.wrapper.eventlistener.CameraEventObserver;
1421 import net.osdn.gokigen.a01d.camera.sony.wrapper.eventlistener.ICameraChangeListener;
1522 import net.osdn.gokigen.a01d.camera.sony.wrapper.eventlistener.ICameraEventObserver;
1623 import net.osdn.gokigen.a01d.camera.sony.wrapper.eventlistener.ICameraStatusHolder;
24+import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
25+import net.osdn.gokigen.a01d.liveview.IIndicatorControl;
1726 import net.osdn.gokigen.a01d.liveview.liveviewlistener.ILiveViewListener;
1827
19-public class SonyCameraWrapper implements ISonyCameraHolder, ISonyInterfaceProvider
28+public class SonyCameraWrapper implements ISonyCameraHolder, ISonyInterfaceProvider, IDisplayInjector
2029 {
2130 private final String TAG = toString();
2231 private final Activity context;
2332 private final ICameraStatusReceiver provider;
2433 private ISonyCamera sonyCamera = null;
25- private ISonyCameraApi sonyCameraApi = null;
2634 private ICameraEventObserver eventObserver = null;
2735 private SonyLiveViewControl liveViewControl = null;
36+ private SonyCameraFocusControl focusControl = null;
37+ private SonyCameraCaptureControl captureControl = null;
2838
2939 public SonyCameraWrapper(final Activity context, final ICameraStatusReceiver statusReceiver)
3040 {
@@ -36,9 +46,12 @@ public class SonyCameraWrapper implements ISonyCameraHolder, ISonyInterfaceProvi
3646 public void prepare()
3747 {
3848 Log.v(TAG, " prepare : " + sonyCamera.getFriendlyName() + " " + sonyCamera.getModelName());
39- sonyCameraApi = SonyCameraApi.newInstance(sonyCamera);
49+ ISonyCameraApi sonyCameraApi = SonyCameraApi.newInstance(sonyCamera);
4050 eventObserver = CameraEventObserver.newInstance(context, sonyCameraApi);
4151 liveViewControl = new SonyLiveViewControl(sonyCameraApi);
52+
53+ focusControl.setCameraApi(sonyCameraApi);
54+ captureControl.setCameraApi(sonyCameraApi);
4255 }
4356
4457 @Override
@@ -66,6 +79,7 @@ public class SonyCameraWrapper implements ISonyCameraHolder, ISonyInterfaceProvi
6679 @Override
6780 public void detectedCamera(@NonNull ISonyCamera camera)
6881 {
82+ Log.v(TAG, "detectedCamera()");
6983 sonyCamera = camera;
7084 }
7185
@@ -86,4 +100,43 @@ public class SonyCameraWrapper implements ISonyCameraHolder, ISonyInterfaceProvi
86100 {
87101 return (liveViewControl.getSonyLiveViewListener());
88102 }
103+
104+ @Override
105+ public IFocusingControl getFocusingControl()
106+ {
107+ return (focusControl);
108+ }
109+
110+ @Override
111+ public ICameraInformation getCameraInformation()
112+ {
113+ return null;
114+ }
115+
116+ @Override
117+ public IZoomLensControl getZoomLensControl()
118+ {
119+ return null;
120+ }
121+
122+ @Override
123+ public ICaptureControl getCaptureControl()
124+ {
125+ return (captureControl);
126+ }
127+
128+ @Override
129+ public IDisplayInjector getDisplayInjector()
130+ {
131+ return (this);
132+ }
133+
134+ @Override
135+ public void injectDisplay(@NonNull IAutoFocusFrameDisplay frameDisplayer, @NonNull IIndicatorControl indicator, @NonNull IFocusingModeNotify focusingModeNotify)
136+ {
137+ Log.v(TAG, "injectDisplay()");
138+
139+ focusControl = new SonyCameraFocusControl(frameDisplayer, indicator);
140+ captureControl = new SonyCameraCaptureControl(frameDisplayer, indicator);
141+ }
89142 }
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/wrapper/SonyLiveViewControl.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/wrapper/SonyLiveViewControl.java
@@ -92,7 +92,11 @@ public class SonyLiveViewControl implements ILiveViewControl
9292 {
9393 try
9494 {
95- cameraApi.stopLiveview();
95+ JSONObject resultsObj = cameraApi.stopLiveview();
96+ if (resultsObj == null)
97+ {
98+ Log.v(TAG, "stopLiveview() reply is null.");
99+ }
96100 }
97101 catch (Exception e)
98102 {
@@ -169,12 +173,12 @@ public class SonyLiveViewControl implements ILiveViewControl
169173 final SimpleLiveviewSlicer.Payload payload = slicer.nextPayload();
170174 if (payload == null)
171175 {
172- Log.v(TAG, "Liveview Payload is null.");
176+ //Log.v(TAG, "Liveview Payload is null.");
173177 continuousNullDataReceived++;
174178 if (continuousNullDataReceived > FETCH_ERROR_MAX)
175179 {
176180 Log.d(TAG, " FETCH ERROR MAX OVER ");
177- //break;
181+ break;
178182 }
179183 continue;
180184 }
@@ -205,11 +209,11 @@ public class SonyLiveViewControl implements ILiveViewControl
205209 e.printStackTrace();
206210 }
207211 //mJpegQueue.clear();
208- whileFetching = false;
209- if (continuousNullDataReceived > FETCH_ERROR_MAX)
212+ if ((!whileFetching)&&(continuousNullDataReceived > FETCH_ERROR_MAX))
210213 {
211214 // 再度ライブビューのスタートをやってみる。
212- continuousNullDataReceived = 0;
215+ whileFetching = false;
216+ //continuousNullDataReceived = 0;
213217 start(streamUrl);
214218 }
215219 }
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/wrapper/connection/SonyCameraConnectSequence.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/wrapper/connection/SonyCameraConnectSequence.java
@@ -33,7 +33,7 @@ public class SonyCameraConnectSequence implements Runnable, SonySsdpClient.ISear
3333 this.cameraConnection = cameraConnection;
3434 this.cameraStatusReceiver = statusReceiver;
3535 this.cameraHolder = cameraHolder;
36- client = new SonySsdpClient(context, this, statusReceiver, -1);
36+ client = new SonySsdpClient(context, this, statusReceiver, 1);
3737 }
3838
3939 @Override
--- a/app/src/main/java/net/osdn/gokigen/a01d/liveview/LiveViewClickTouchListener.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/liveview/LiveViewClickTouchListener.java
@@ -11,10 +11,9 @@ import android.widget.Toast;
1111 import net.osdn.gokigen.a01d.IChangeScene;
1212 import net.osdn.gokigen.a01d.R;
1313 import net.osdn.gokigen.a01d.camera.IInterfaceProvider;
14-import net.osdn.gokigen.a01d.camera.olympus.IOlympusInterfaceProvider;
15-import net.osdn.gokigen.a01d.camera.olympus.operation.ICaptureControl;
16-import net.osdn.gokigen.a01d.camera.olympus.operation.IFocusingControl;
17-import net.osdn.gokigen.a01d.camera.olympus.wrapper.ICameraInformation;
14+import net.osdn.gokigen.a01d.camera.ICaptureControl;
15+import net.osdn.gokigen.a01d.camera.IFocusingControl;
16+import net.osdn.gokigen.a01d.camera.ICameraInformation;
1817 import net.osdn.gokigen.a01d.camera.ICameraConnection;
1918 import net.osdn.gokigen.a01d.camera.olympus.wrapper.property.IOlyCameraProperty;
2019 import net.osdn.gokigen.a01d.camera.olympus.wrapper.property.IOlyCameraPropertyProvider;
@@ -46,11 +45,23 @@ class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchLi
4645 this.statusViewDrawer = statusView;
4746 this.changeScene = changeScene;
4847 this.interfaceProvider = interfaceProvider;
49- this.focusingControl = interfaceProvider.getOlympusInterface().getFocusingControl();
50- this.captureControl = interfaceProvider.getOlympusInterface().getCaptureControl();
51- this.propertyProvider = interfaceProvider.getOlympusInterface().getCameraPropertyProvider();
52- this.cameraInformation = interfaceProvider.getOlympusInterface().getCameraInformation();
53- this.cameraConnection = interfaceProvider.getOlympusInterface().getOlyCameraConnection();
48+
49+ if (interfaceProvider.useOlympusCamera())
50+ {
51+ this.focusingControl = interfaceProvider.getOlympusInterface().getFocusingControl();
52+ this.captureControl = interfaceProvider.getOlympusInterface().getCaptureControl();
53+ this.propertyProvider = interfaceProvider.getOlympusInterface().getCameraPropertyProvider();
54+ this.cameraInformation = interfaceProvider.getOlympusInterface().getCameraInformation();
55+ this.cameraConnection = interfaceProvider.getOlympusInterface().getOlyCameraConnection();
56+ }
57+ else
58+ {
59+ this.focusingControl = interfaceProvider.getSonyInterface().getFocusingControl();
60+ this.captureControl = interfaceProvider.getSonyInterface().getCaptureControl();
61+ this.propertyProvider = interfaceProvider.getOlympusInterface().getCameraPropertyProvider(); // 要変更
62+ this.cameraInformation = interfaceProvider.getSonyInterface().getCameraInformation();
63+ this.cameraConnection = interfaceProvider.getSonyInterface().getSonyCameraConnection();
64+ }
5465 this.dialogKicker = dialogKicker;
5566 }
5667
@@ -209,6 +220,11 @@ class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchLi
209220 public boolean onTouch(View view, MotionEvent motionEvent)
210221 {
211222 int id = view.getId();
223+ if (focusingControl == null)
224+ {
225+ Log.v(TAG, "focusingControl is NULL.");
226+ return (false);
227+ }
212228 //Log.v(TAG, "onTouch() : " + id + " (" + motionEvent.getX() + "," + motionEvent.getY() + ")");
213229 return ((id == R.id.cameraLiveImageView)&&(focusingControl.driveAutoFocus(motionEvent)));
214230 }
--- a/app/src/main/java/net/osdn/gokigen/a01d/liveview/LiveViewFragment.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/liveview/LiveViewFragment.java
@@ -23,8 +23,8 @@ import net.osdn.gokigen.a01d.camera.IInterfaceProvider;
2323 import net.osdn.gokigen.a01d.camera.sony.wrapper.IDisplayInjector;
2424 import net.osdn.gokigen.a01d.camera.olympus.myolycameraprops.LoadSaveCameraProperties;
2525 import net.osdn.gokigen.a01d.camera.olympus.myolycameraprops.LoadSaveMyCameraPropertyDialog;
26-import net.osdn.gokigen.a01d.camera.olympus.operation.IZoomLensControl;
27-import net.osdn.gokigen.a01d.camera.olympus.wrapper.ICameraInformation;
26+import net.osdn.gokigen.a01d.camera.IZoomLensControl;
27+import net.osdn.gokigen.a01d.camera.ICameraInformation;
2828 import net.osdn.gokigen.a01d.camera.olympus.wrapper.IFocusingModeNotify;
2929 import net.osdn.gokigen.a01d.camera.ILiveViewControl;
3030 import net.osdn.gokigen.a01d.camera.ICameraConnection;
@@ -70,7 +70,7 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
7070 public static LiveViewFragment newInstance(IChangeScene sceneSelector, @NonNull IInterfaceProvider provider)
7171 {
7272 LiveViewFragment instance = new LiveViewFragment();
73- instance.prepare(sceneSelector, provider, provider.getOlympusDisplayInjector());
73+ instance.prepare(sceneSelector, provider);
7474
7575 // パラメータはBundleにまとめておく
7676 Bundle arguments = new Bundle();
@@ -134,6 +134,10 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
134134 {
135135 interfaceInjector.injectDisplay(imageView, imageView, this);
136136 }
137+ else
138+ {
139+ Log.v(TAG, "interfaceInjector is NULL...");
140+ }
137141 if (onClickTouchListener == null)
138142 {
139143 onClickTouchListener = new LiveViewClickTouchListener(this.getContext(), imageView, this, changeScene, interfaceProvider, this);
@@ -182,9 +186,19 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
182186 /**
183187 *
184188 */
185- private void prepare(IChangeScene sceneSelector, IInterfaceProvider interfaceProvider, IDisplayInjector interfaceInjector)
189+ private void prepare(IChangeScene sceneSelector, IInterfaceProvider interfaceProvider)
186190 {
187191 Log.v(TAG, "prepare()");
192+
193+ IDisplayInjector interfaceInjector;
194+ if (interfaceProvider.useOlympusCamera())
195+ {
196+ interfaceInjector = interfaceProvider.getOlympusInterface().getDisplayInjector();
197+ }
198+ else
199+ {
200+ interfaceInjector = interfaceProvider.getSonyInterface().getDisplayInjector();
201+ }
188202 this.changeScene = sceneSelector;
189203 this.interfaceProvider = interfaceProvider;
190204 this.interfaceInjector = interfaceInjector;
@@ -198,12 +212,11 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
198212 else
199213 {
200214 this.liveViewControl = interfaceProvider.getSonyInterface().getSonyLiveViewControl();
201- this.zoomLensControl = interfaceProvider.getOlympusInterface().getZoomLensControl(); // 要変更
202- this.cameraInformation = interfaceProvider.getOlympusInterface().getCameraInformation(); // 要変更
215+ this.zoomLensControl = interfaceProvider.getSonyInterface().getZoomLensControl();
216+ this.cameraInformation = interfaceProvider.getSonyInterface().getCameraInformation();
203217 }
204218 }
205219
206-
207220 /**
208221 * カメラとの接続状態の更新
209222 *
@@ -457,7 +470,7 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
457470 else
458471 {
459472 // ダミー
460- prepare(changeScene, interfaceProvider, interfaceInjector);
473+ prepare(changeScene, interfaceProvider);
461474 }
462475 }
463476 try
--- a/app/src/main/java/net/osdn/gokigen/a01d/preference/PreferenceFragment.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/preference/PreferenceFragment.java
@@ -15,6 +15,7 @@ import android.util.Log;
1515
1616 import net.osdn.gokigen.a01d.IChangeScene;
1717 import net.osdn.gokigen.a01d.R;
18+import net.osdn.gokigen.a01d.camera.IInterfaceProvider;
1819 import net.osdn.gokigen.a01d.camera.olympus.wrapper.ICameraHardwareStatus;
1920 import net.osdn.gokigen.a01d.camera.olympus.wrapper.ICameraRunMode;
2021 import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.ble.OlyCameraPowerOnSelector;
@@ -52,12 +53,12 @@ public class PreferenceFragment extends PreferenceFragmentCompat implements Shar
5253 *
5354 *
5455 */
55- public void setInterface(AppCompatActivity context, IOlympusInterfaceProvider factory, IChangeScene changeScene)
56+ public void setInterface(AppCompatActivity context, IInterfaceProvider factory, IChangeScene changeScene)
5657 {
5758 Log.v(TAG, "setInterface()");
58- this.propertyInterface = factory.getCameraPropertyProvider();
59- this.changeRunModeExecutor = factory.getCameraRunMode();
60- hardwareStatusInterface = factory.getHardwareStatus();
59+ this.propertyInterface = factory.getOlympusInterface().getCameraPropertyProvider();
60+ this.changeRunModeExecutor = factory.getOlympusInterface().getCameraRunMode();
61+ hardwareStatusInterface = factory.getOlympusInterface().getHardwareStatus();
6162 powerOffController = new CameraPowerOff(context, changeScene);
6263 powerOffController.prepare();
6364 powerOnSelector = new OlyCameraPowerOnSelector(context);
Afficher sur ancien navigateur de dépôt.