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.ptpip.IPtpIpInterfaceProvider;
30 import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.PtpIpInterfaceProvider;
31 import net.osdn.gokigen.pkremote.camera.vendor.ricoh.wrapper.RicohGr2InterfaceProvider;
32 import net.osdn.gokigen.pkremote.camera.vendor.sony.ISonyInterfaceProvider;
33 import net.osdn.gokigen.pkremote.camera.vendor.sony.wrapper.SonyCameraWrapper;
34 import net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor;
36 import androidx.annotation.NonNull;
37 import androidx.appcompat.app.AppCompatActivity;
38 import androidx.preference.PreferenceManager;
44 public class CameraInterfaceProvider implements IInterfaceProvider
46 private final SonyCameraWrapper sony;
47 private final OlympusInterfaceProvider olympus;
48 private final RicohGr2InterfaceProvider ricohGr2;
49 private final FujiXInterfaceProvider fujiX;
50 private final PanasonicCameraWrapper panasonic;
51 private final PtpIpInterfaceProvider ptpip;
52 private final IInformationReceiver informationReceiver;
53 private final CameraContentsRecognizer cameraContentsRecognizer;
54 private final AppCompatActivity context;
55 //private final CameraStatusListener statusListener;
56 private ICameraConnection.CameraConnectionMethod connectionMethod = ICameraConnection.CameraConnectionMethod.UNKNOWN;
58 public static IInterfaceProvider newInstance(@NonNull AppCompatActivity context, @NonNull ICameraStatusReceiver provider, @NonNull IInformationReceiver informationReceiver)
60 return (new CameraInterfaceProvider(context, provider, informationReceiver));
67 private CameraInterfaceProvider(@NonNull AppCompatActivity context, @NonNull ICameraStatusReceiver provider, @NonNull IInformationReceiver informationReceiver)
69 this.context = context;
70 CameraStatusListener statusListener = new CameraStatusListener();
71 olympus = new OlympusInterfaceProvider(context, provider);
72 ricohGr2 = new RicohGr2InterfaceProvider(context, provider);
73 fujiX = new FujiXInterfaceProvider(context, provider, statusListener, informationReceiver);
74 sony = new SonyCameraWrapper(context, provider, statusListener, informationReceiver);
75 ptpip = new PtpIpInterfaceProvider(context, provider, statusListener, informationReceiver);
76 panasonic = new PanasonicCameraWrapper(context, provider, statusListener, informationReceiver);
77 this.informationReceiver = informationReceiver;
78 this.cameraContentsRecognizer = new CameraContentsRecognizer(context, this);
82 public IOlympusInterfaceProvider getOlympusInterfaceProvider()
88 public ISonyInterfaceProvider getSonyInterface()
94 public IPtpIpInterfaceProvider getPtpIpInterface()
104 public ICameraConnection getCameraConnection()
108 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
109 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
111 return (olympus.getOlyCameraConnection());
113 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
115 return (fujiX.getFujiXCameraConnection());
117 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
119 return (panasonic.getPanasonicCameraConnection());
121 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
123 return (sony.getSonyCameraConnection());
125 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
127 return (ptpip.getPtpIpCameraConnection());
129 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON)
131 return (ptpip.getPtpIpCameraConnection());
133 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
135 return (ricohGr2.getRicohGr2CameraConnection());
146 public ICameraButtonControl getButtonControl()
150 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
151 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
153 return (olympus.getButtonControl());
155 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
157 return (fujiX.getButtonControl());
159 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
161 return (panasonic.getButtonControl());
163 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
165 return (sony.getButtonControl());
167 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
169 return (ptpip.getButtonControl());
171 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON)
173 return (ptpip.getButtonControl());
175 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
177 return (ricohGr2.getButtonControl());
188 public IDisplayInjector getDisplayInjector()
192 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
193 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
195 return (olympus.getDisplayInjector());
197 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
199 return (fujiX.getDisplayInjector());
201 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
203 return (panasonic.getDisplayInjector());
205 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
207 return (sony.getDisplayInjector());
209 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
211 return (ptpip.getDisplayInjector());
213 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON)
215 return (ptpip.getDisplayInjector());
217 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
219 return (ricohGr2.getDisplayInjector());
230 public ILiveViewControl getLiveViewControl()
234 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
235 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
237 return (olympus.getLiveViewControl());
239 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
241 return (fujiX.getLiveViewControl());
243 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
245 return (panasonic.getPanasonicLiveViewControl());
247 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
249 return (sony.getLiveViewControl());
251 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
253 return (ptpip.getLiveViewControl());
255 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON)
257 return (ptpip.getLiveViewControl());
259 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
261 return (ricohGr2.getLiveViewControl());
272 public ILiveViewListener getLiveViewListener()
276 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
277 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
279 return (olympus.getLiveViewListener());
281 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
283 return (fujiX.getLiveViewListener());
285 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
287 return (panasonic.getLiveViewListener());
289 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
291 return (sony.getLiveViewListener());
293 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
295 return (ptpip.getLiveViewListener());
297 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON)
299 return (ptpip.getLiveViewListener());
301 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
303 return (ricohGr2.getLiveViewListener());
314 public IFocusingControl getFocusingControl()
318 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
319 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
321 return (olympus.getFocusingControl());
323 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
325 return (fujiX.getFocusingControl());
327 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
329 return (panasonic.getFocusingControl());
331 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
333 return (sony.getFocusingControl());
335 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
337 return (ptpip.getFocusingControl());
339 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON)
341 return (ptpip.getFocusingControl());
343 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
345 return (ricohGr2.getFocusingControl());
356 public ICameraInformation getCameraInformation()
360 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
361 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
363 return (olympus.getCameraInformation());
365 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
367 return (fujiX.getCameraInformation());
369 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
371 return (panasonic.getCameraInformation());
373 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
375 return (sony.getCameraInformation());
377 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
379 return (ptpip.getCameraInformation());
381 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON)
383 return (ptpip.getCameraInformation());
385 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
387 return (ricohGr2.getCameraInformation());
398 public IZoomLensControl getZoomLensControl()
402 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
403 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
405 return (olympus.getZoomLensControl());
407 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
409 return (fujiX.getZoomLensControl());
411 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
413 return (panasonic.getZoomLensControl());
415 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
417 return (sony.getZoomLensControl());
419 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
421 return (ptpip.getZoomLensControl());
423 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON)
425 return (ptpip.getZoomLensControl());
427 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
429 return (ricohGr2.getZoomLensControl());
440 public ICaptureControl getCaptureControl()
444 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
445 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
447 return (olympus.getCaptureControl());
449 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
451 return (fujiX.getCaptureControl());
453 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
455 return (panasonic.getCaptureControl());
457 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
459 return (sony.getCaptureControl());
461 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
463 return (ptpip.getCaptureControl());
465 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON)
467 return (ptpip.getCaptureControl());
469 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
471 return (ricohGr2.getCaptureControl());
482 public ICameraStatus getCameraStatusListHolder()
486 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
487 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
489 return (olympus.getCameraStatusListHolder());
491 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
493 return (fujiX.getCameraStatusListHolder());
495 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
497 return (panasonic.getCameraStatusListHolder());
499 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
501 return (sony.getCameraStatusListHolder());
503 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
505 return (ptpip.getCameraStatusListHolder());
507 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON)
509 return (ptpip.getCameraStatusListHolder());
511 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
513 return (ricohGr2.getCameraStatusListHolder());
524 public ICameraStatusWatcher getCameraStatusWatcher()
528 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
529 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
531 return (olympus.getCameraStatusWatcher());
533 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
535 return (fujiX.getCameraStatusWatcher());
537 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
539 return (panasonic.getCameraStatusWatcher());
541 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
543 return (sony.getCameraStatusWatcher());
545 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
547 return (ptpip.getCameraStatusWatcher());
549 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON)
551 return (ptpip.getCameraStatusWatcher());
553 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
555 return (ricohGr2.getCameraStatusWatcher());
566 public IPlaybackControl getPlaybackControl()
570 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
571 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
573 return (olympus.getPlaybackControl());
575 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
577 return (fujiX.getPlaybackControl());
579 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
581 return (panasonic.getPlaybackControl());
583 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
585 return (sony.getPlaybackControl());
587 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
589 return (ptpip.getPlaybackControl());
591 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON)
593 return (ptpip.getPlaybackControl());
595 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
597 return (ricohGr2.getPlaybackControl());
608 public ICameraHardwareStatus getHardwareStatus()
612 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
613 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
615 return (olympus.getHardwareStatus());
617 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
619 return (fujiX.getHardwareStatus());
621 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
623 return (panasonic.getHardwareStatus());
625 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
627 return (sony.getHardwareStatus());
629 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
631 return (ptpip.getHardwareStatus());
633 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON)
635 return (ptpip.getHardwareStatus());
637 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
639 return (ricohGr2.getHardwareStatus());
650 public ICameraRunMode getCameraRunMode()
654 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
655 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
657 return (olympus.getCameraRunMode());
659 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
661 return (fujiX.getCameraRunMode());
663 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
665 return (panasonic.getCameraRunMode());
667 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
669 return (sony.getCameraRunMode());
671 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
673 return (ptpip.getCameraRunMode());
675 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON)
677 return (ptpip.getCameraRunMode());
679 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
681 return (ricohGr2.getCameraRunMode());
692 * OPC/GR2/SONY カメラを使用するかどうか
694 * @return OPC / SONY / RICOH (ICameraConnection.CameraConnectionMethod)
696 public ICameraConnection.CameraConnectionMethod getCammeraConnectionMethod()
698 return (getCammeraConnectionMethodImpl());
706 public void resetCameraConnectionMethod()
708 connectionMethod = ICameraConnection.CameraConnectionMethod.UNKNOWN;
716 public IInformationReceiver getInformationReceiver()
718 return (informationReceiver);
722 public ICameraContentsRecognizer getCameraContentsRecognizer()
724 return (cameraContentsRecognizer);
731 private ICameraConnection.CameraConnectionMethod getCammeraConnectionMethodImpl()
733 if (connectionMethod != ICameraConnection.CameraConnectionMethod.UNKNOWN)
735 return (connectionMethod);
737 ICameraConnection.CameraConnectionMethod ret;
740 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
741 String connectionMethod = preferences.getString(IPreferencePropertyAccessor.CONNECTION_METHOD, "RICOH");
742 if (connectionMethod.contains("RICOH"))
744 ret = ICameraConnection.CameraConnectionMethod.RICOH;
746 else if (connectionMethod.contains("FUJI_X"))
748 ret = ICameraConnection.CameraConnectionMethod.FUJI_X;
750 else if (connectionMethod.contains("PANASONIC"))
752 ret = ICameraConnection.CameraConnectionMethod.PANASONIC;
754 else if (connectionMethod.contains("SONY"))
756 ret = ICameraConnection.CameraConnectionMethod.SONY;
758 else if (connectionMethod.contains("CANON"))
760 ret = ICameraConnection.CameraConnectionMethod.CANON;
762 else if (connectionMethod.contains("NIKON"))
764 ret = ICameraConnection.CameraConnectionMethod.NIKON;
766 else // if (connectionMethod.contains("OPC"))
768 ret = ICameraConnection.CameraConnectionMethod.OPC;
771 else if (connectionMethod.contains("SONY"))
773 ret = ICameraConnection.CameraConnectionMethod.SONY;
780 ret = ICameraConnection.CameraConnectionMethod.UNKNOWN;
782 connectionMethod = ret;
783 return (connectionMethod);