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);
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.RICOH)
114 return (ricohGr2.getRicohGr2CameraConnection());
125 public ICameraButtonControl getButtonControl()
129 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
130 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
132 return (olympus.getButtonControl());
134 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
136 return (fujiX.getButtonControl());
138 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
140 return (panasonic.getButtonControl());
142 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
144 return (ricohGr2.getButtonControl());
155 public IDisplayInjector getDisplayInjector()
159 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
160 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
162 return (olympus.getDisplayInjector());
164 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
166 return (fujiX.getDisplayInjector());
168 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
170 return (panasonic.getDisplayInjector());
172 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
174 return (ricohGr2.getDisplayInjector());
185 public ILiveViewControl getLiveViewControl()
189 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
190 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
192 return (olympus.getLiveViewControl());
194 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
196 return (fujiX.getLiveViewControl());
198 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
200 return (panasonic.getPanasonicLiveViewControl());
202 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
204 return (ricohGr2.getLiveViewControl());
215 public ILiveViewListener getLiveViewListener()
219 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
220 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
222 return (olympus.getLiveViewListener());
224 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
226 return (fujiX.getLiveViewListener());
228 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
230 return (panasonic.getLiveViewListener());
232 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
234 return (ricohGr2.getLiveViewListener());
245 public IFocusingControl getFocusingControl()
249 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
250 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
252 return (olympus.getFocusingControl());
254 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
256 return (fujiX.getFocusingControl());
258 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
260 return (panasonic.getFocusingControl());
262 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
264 return (ricohGr2.getFocusingControl());
275 public ICameraInformation getCameraInformation()
279 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
280 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
282 return (olympus.getCameraInformation());
284 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
286 return (fujiX.getCameraInformation());
288 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
290 return (panasonic.getCameraInformation());
292 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
294 return (ricohGr2.getCameraInformation());
305 public IZoomLensControl getZoomLensControl()
309 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
310 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
312 return (olympus.getZoomLensControl());
314 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
316 return (fujiX.getZoomLensControl());
318 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
320 return (panasonic.getZoomLensControl());
322 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
324 return (ricohGr2.getZoomLensControl());
335 public ICaptureControl getCaptureControl()
339 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
340 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
342 return (olympus.getCaptureControl());
344 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
346 return (fujiX.getCaptureControl());
348 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
350 return (panasonic.getCaptureControl());
352 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
354 return (ricohGr2.getCaptureControl());
365 public ICameraStatus getCameraStatusListHolder()
369 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
370 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
372 return (olympus.getCameraStatusListHolder());
374 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
376 return (fujiX.getCameraStatusListHolder());
378 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
380 return (panasonic.getCameraStatusListHolder());
382 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
384 return (ricohGr2.getCameraStatusListHolder());
395 public ICameraStatusWatcher getCameraStatusWatcher()
399 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
400 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
402 return (olympus.getCameraStatusWatcher());
404 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
406 return (fujiX.getCameraStatusWatcher());
408 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
410 return (panasonic.getCameraStatusWatcher());
412 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
414 return (ricohGr2.getCameraStatusWatcher());
425 public IPlaybackControl getPlaybackControl()
429 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
430 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
432 return (olympus.getPlaybackControl());
434 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
436 return (fujiX.getPlaybackControl());
438 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
440 return (panasonic.getPlaybackControl());
442 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
444 return (ricohGr2.getPlaybackControl());
455 public ICameraHardwareStatus getHardwareStatus()
459 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
460 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
462 return (olympus.getHardwareStatus());
464 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
466 return (fujiX.getHardwareStatus());
468 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
470 return (panasonic.getHardwareStatus());
472 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
474 return (ricohGr2.getHardwareStatus());
485 public ICameraRunMode getCameraRunMode()
489 ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
490 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
492 return (olympus.getCameraRunMode());
494 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
496 return (fujiX.getCameraRunMode());
498 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
500 return (panasonic.getCameraRunMode());
502 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
504 return (ricohGr2.getCameraRunMode());
515 * OPC/GR2/SONY カメラを使用するかどうか
517 * @return OPC / SONY / RICOH (ICameraConnection.CameraConnectionMethod)
519 public ICameraConnection.CameraConnectionMethod getCammeraConnectionMethod()
521 return (getCammeraConnectionMethodImpl());
529 public void resetCameraConnectionMethod()
531 connectionMethod = ICameraConnection.CameraConnectionMethod.UNKNOWN;
539 public IInformationReceiver getInformationReceiver()
541 return (informationReceiver);
545 public ICameraContentsRecognizer getCameraContentsRecognizer()
547 return (cameraContentsRecognizer);
554 private ICameraConnection.CameraConnectionMethod getCammeraConnectionMethodImpl()
556 if (connectionMethod != ICameraConnection.CameraConnectionMethod.UNKNOWN)
558 return (connectionMethod);
560 ICameraConnection.CameraConnectionMethod ret;
563 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
564 String connectionMethod = preferences.getString(IPreferencePropertyAccessor.CONNECTION_METHOD, "RICOH");
565 if (connectionMethod.contains("RICOH"))
567 ret = ICameraConnection.CameraConnectionMethod.RICOH;
569 else if (connectionMethod.contains("FUJI_X"))
571 ret = ICameraConnection.CameraConnectionMethod.FUJI_X;
573 else if (connectionMethod.contains("PANASONIC"))
575 ret = ICameraConnection.CameraConnectionMethod.PANASONIC;
577 else // if (connectionMethod.contains("OPC"))
579 ret = ICameraConnection.CameraConnectionMethod.OPC;
582 else if (connectionMethod.contains("SONY"))
584 ret = ICameraConnection.CameraConnectionMethod.SONY;
591 ret = ICameraConnection.CameraConnectionMethod.UNKNOWN;
593 connectionMethod = ret;
594 return (connectionMethod);