1 package net.osdn.gokigen.pkremote.camera;
3 import android.content.SharedPreferences;
5 import net.osdn.gokigen.pkremote.IInformationReceiver;
6 import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraButtonControl;
7 import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraConnection;
8 import net.osdn.gokigen.pkremote.camera.interfaces.liveview.ILiveViewListener;
9 import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraContentsRecognizer;
10 import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraHardwareStatus;
11 import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraInformation;
12 import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraRunMode;
13 import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraStatus;
14 import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraStatusReceiver;
15 import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraStatusWatcher;
16 import net.osdn.gokigen.pkremote.camera.interfaces.control.ICaptureControl;
17 import net.osdn.gokigen.pkremote.camera.interfaces.liveview.IDisplayInjector;
18 import net.osdn.gokigen.pkremote.camera.interfaces.control.IFocusingControl;
19 import net.osdn.gokigen.pkremote.camera.interfaces.IInterfaceProvider;
20 import net.osdn.gokigen.pkremote.camera.interfaces.liveview.ILiveViewControl;
21 import net.osdn.gokigen.pkremote.camera.interfaces.playback.IPlaybackControl;
22 import net.osdn.gokigen.pkremote.camera.interfaces.control.IZoomLensControl;
23 import net.osdn.gokigen.pkremote.camera.playback.CameraContentsRecognizer;
24 import net.osdn.gokigen.pkremote.camera.utils.CameraStatusListener;
25 import net.osdn.gokigen.pkremote.camera.vendor.fujix.wrapper.FujiXInterfaceProvider;
26 import net.osdn.gokigen.pkremote.camera.vendor.olympus.IOlympusInterfaceProvider;
27 import net.osdn.gokigen.pkremote.camera.vendor.olympus.wrapper.OlympusInterfaceProvider;
28 import net.osdn.gokigen.pkremote.camera.vendor.panasonic.wrapper.PanasonicCameraWrapper;
29 import net.osdn.gokigen.pkremote.camera.vendor.ricoh.wrapper.RicohGr2InterfaceProvider;
30 import net.osdn.gokigen.pkremote.camera.vendor.sony.ISonyInterfaceProvider;
31 import net.osdn.gokigen.pkremote.camera.vendor.sony.wrapper.SonyCameraWrapper;
32 import net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor;
33 import net.osdn.gokigen.pkremote.preference.panasonic.PanasonicPreferenceFragment;
35 import androidx.annotation.NonNull;
36 import androidx.appcompat.app.AppCompatActivity;
37 import androidx.preference.PreferenceManager;
43 public class CameraInterfaceProvider implements IInterfaceProvider
45 private final SonyCameraWrapper sony;
46 private final OlympusInterfaceProvider olympus;
47 private final RicohGr2InterfaceProvider ricohGr2;
48 private final FujiXInterfaceProvider fujiX;
49 private final PanasonicCameraWrapper panasonic;
50 private final IInformationReceiver informationReceiver;
51 private final CameraContentsRecognizer cameraContentsRecognizer;
52 private final AppCompatActivity context;
53 //private final CameraStatusListener statusListener;
54 private ICameraConnection.CameraConnectionMethod connectionMethod = ICameraConnection.CameraConnectionMethod.UNKNOWN;
56 public static IInterfaceProvider newInstance(@NonNull AppCompatActivity context, @NonNull ICameraStatusReceiver provider, @NonNull IInformationReceiver informationReceiver)
58 return (new CameraInterfaceProvider(context, provider, informationReceiver));
65 private CameraInterfaceProvider(@NonNull AppCompatActivity context, @NonNull ICameraStatusReceiver provider, @NonNull IInformationReceiver informationReceiver)
67 this.context = context;
68 CameraStatusListener statusListener = new CameraStatusListener();
69 olympus = new OlympusInterfaceProvider(context, provider);
70 ricohGr2 = new RicohGr2InterfaceProvider(context, provider);
71 fujiX = new FujiXInterfaceProvider(context, provider, statusListener, informationReceiver);
72 sony = new SonyCameraWrapper(context, provider, statusListener, informationReceiver);
73 panasonic = new PanasonicCameraWrapper(context, provider, statusListener);
74 this.informationReceiver = informationReceiver;
75 this.cameraContentsRecognizer = new CameraContentsRecognizer(context, this);
79 public IOlympusInterfaceProvider getOlympusInterfaceProvider()
85 public ISonyInterfaceProvider getSonyInterface()
95 public ICameraConnection getCameraConnection()
99 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
100 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
102 return (olympus.getOlyCameraConnection());
104 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
106 return (fujiX.getFujiXCameraConnection());
108 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
110 return (panasonic.getPanasonicCameraConnection());
112 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
114 return (sony.getSonyCameraConnection());
116 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
118 return (ricohGr2.getRicohGr2CameraConnection());
129 public ICameraButtonControl getButtonControl()
133 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
134 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
136 return (olympus.getButtonControl());
138 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
140 return (fujiX.getButtonControl());
142 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
144 return (panasonic.getButtonControl());
146 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
148 return (sony.getButtonControl());
150 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
152 return (ricohGr2.getButtonControl());
163 public IDisplayInjector getDisplayInjector()
167 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
168 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
170 return (olympus.getDisplayInjector());
172 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
174 return (fujiX.getDisplayInjector());
176 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
178 return (panasonic.getDisplayInjector());
180 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
182 return (sony.getDisplayInjector());
184 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
186 return (ricohGr2.getDisplayInjector());
197 public ILiveViewControl getLiveViewControl()
201 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
202 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
204 return (olympus.getLiveViewControl());
206 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
208 return (fujiX.getLiveViewControl());
210 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
212 return (panasonic.getPanasonicLiveViewControl());
214 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
216 return (sony.getLiveViewControl());
218 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
220 return (ricohGr2.getLiveViewControl());
231 public ILiveViewListener getLiveViewListener()
235 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
236 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
238 return (olympus.getLiveViewListener());
240 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
242 return (fujiX.getLiveViewListener());
244 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
246 return (panasonic.getLiveViewListener());
248 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
250 return (sony.getLiveViewListener());
252 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
254 return (ricohGr2.getLiveViewListener());
265 public IFocusingControl getFocusingControl()
269 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
270 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
272 return (olympus.getFocusingControl());
274 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
276 return (fujiX.getFocusingControl());
278 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
280 return (panasonic.getFocusingControl());
282 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
284 return (sony.getFocusingControl());
286 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
288 return (ricohGr2.getFocusingControl());
299 public ICameraInformation getCameraInformation()
303 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
304 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
306 return (olympus.getCameraInformation());
308 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
310 return (fujiX.getCameraInformation());
312 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
314 return (panasonic.getCameraInformation());
316 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
318 return (sony.getCameraInformation());
320 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
322 return (ricohGr2.getCameraInformation());
333 public IZoomLensControl getZoomLensControl()
337 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
338 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
340 return (olympus.getZoomLensControl());
342 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
344 return (fujiX.getZoomLensControl());
346 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
348 return (panasonic.getZoomLensControl());
350 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
352 return (sony.getZoomLensControl());
354 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
356 return (ricohGr2.getZoomLensControl());
367 public ICaptureControl getCaptureControl()
371 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
372 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
374 return (olympus.getCaptureControl());
376 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
378 return (fujiX.getCaptureControl());
380 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
382 return (panasonic.getCaptureControl());
384 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
386 return (sony.getCaptureControl());
388 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
390 return (ricohGr2.getCaptureControl());
401 public ICameraStatus getCameraStatusListHolder()
405 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
406 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
408 return (olympus.getCameraStatusListHolder());
410 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
412 return (fujiX.getCameraStatusListHolder());
414 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
416 return (panasonic.getCameraStatusListHolder());
418 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
420 return (sony.getCameraStatusListHolder());
422 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
424 return (ricohGr2.getCameraStatusListHolder());
435 public ICameraStatusWatcher getCameraStatusWatcher()
439 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
440 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
442 return (olympus.getCameraStatusWatcher());
444 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
446 return (fujiX.getCameraStatusWatcher());
448 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
450 return (panasonic.getCameraStatusWatcher());
452 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
454 return (sony.getCameraStatusWatcher());
456 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
458 return (ricohGr2.getCameraStatusWatcher());
469 public IPlaybackControl getPlaybackControl()
473 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
474 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
476 return (olympus.getPlaybackControl());
478 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
480 return (fujiX.getPlaybackControl());
482 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
484 return (panasonic.getPlaybackControl());
486 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
488 return (sony.getPlaybackControl());
490 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
492 return (ricohGr2.getPlaybackControl());
503 public ICameraHardwareStatus getHardwareStatus()
507 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
508 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
510 return (olympus.getHardwareStatus());
512 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
514 return (fujiX.getHardwareStatus());
516 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
518 return (panasonic.getHardwareStatus());
520 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
522 return (sony.getHardwareStatus());
524 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
526 return (ricohGr2.getHardwareStatus());
537 public ICameraRunMode getCameraRunMode()
541 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
542 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
544 return (olympus.getCameraRunMode());
546 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
548 return (fujiX.getCameraRunMode());
550 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
552 return (panasonic.getCameraRunMode());
554 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
556 return (sony.getCameraRunMode());
558 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
560 return (ricohGr2.getCameraRunMode());
571 * OPC/GR2/SONY カメラを使用するかどうか
573 * @return OPC / SONY / RICOH (ICameraConnection.CameraConnectionMethod)
575 public ICameraConnection.CameraConnectionMethod getCammeraConnectionMethod()
577 return (getCammeraConnectionMethodImpl());
585 public void resetCameraConnectionMethod()
587 connectionMethod = ICameraConnection.CameraConnectionMethod.UNKNOWN;
595 public IInformationReceiver getInformationReceiver()
597 return (informationReceiver);
601 public ICameraContentsRecognizer getCameraContentsRecognizer()
603 return (cameraContentsRecognizer);
610 private ICameraConnection.CameraConnectionMethod getCammeraConnectionMethodImpl()
612 if (connectionMethod != ICameraConnection.CameraConnectionMethod.UNKNOWN)
614 return (connectionMethod);
616 ICameraConnection.CameraConnectionMethod ret;
619 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
620 String connectionMethod = preferences.getString(IPreferencePropertyAccessor.CONNECTION_METHOD, "RICOH");
621 if (connectionMethod.contains("RICOH"))
623 ret = ICameraConnection.CameraConnectionMethod.RICOH;
625 else if (connectionMethod.contains("FUJI_X"))
627 ret = ICameraConnection.CameraConnectionMethod.FUJI_X;
629 else if (connectionMethod.contains("PANASONIC"))
631 ret = ICameraConnection.CameraConnectionMethod.PANASONIC;
633 else if (connectionMethod.contains("SONY"))
635 ret = ICameraConnection.CameraConnectionMethod.SONY;
637 else // if (connectionMethod.contains("OPC"))
639 ret = ICameraConnection.CameraConnectionMethod.OPC;
642 else if (connectionMethod.contains("SONY"))
644 ret = ICameraConnection.CameraConnectionMethod.SONY;
651 ret = ICameraConnection.CameraConnectionMethod.UNKNOWN;
653 connectionMethod = ret;
654 return (connectionMethod);