1 package net.osdn.gokigen.gr2control.camera.ricohgr2.wrapper;
3 import android.app.Activity;
4 import android.content.SharedPreferences;
5 import android.support.annotation.NonNull;
6 import android.support.v7.preference.PreferenceManager;
7 import android.util.Log;
9 import net.osdn.gokigen.gr2control.camera.ICameraButtonControl;
10 import net.osdn.gokigen.gr2control.camera.ICameraConnection;
11 import net.osdn.gokigen.gr2control.camera.ICameraHardwareStatus;
12 import net.osdn.gokigen.gr2control.camera.ICameraInformation;
13 import net.osdn.gokigen.gr2control.camera.ICameraStatus;
14 import net.osdn.gokigen.gr2control.camera.ICameraStatusReceiver;
15 import net.osdn.gokigen.gr2control.camera.ICameraStatusWatcher;
16 import net.osdn.gokigen.gr2control.camera.ICaptureControl;
17 import net.osdn.gokigen.gr2control.camera.IDisplayInjector;
18 import net.osdn.gokigen.gr2control.camera.IFocusingControl;
19 import net.osdn.gokigen.gr2control.camera.IFocusingModeNotify;
20 import net.osdn.gokigen.gr2control.camera.ILiveViewControl;
21 import net.osdn.gokigen.gr2control.camera.ICameraRunMode;
22 import net.osdn.gokigen.gr2control.camera.playback.IPlaybackControl;
23 import net.osdn.gokigen.gr2control.camera.IZoomLensControl;
24 import net.osdn.gokigen.gr2control.camera.ricohgr2.IRicohGr2InterfaceProvider;
25 import net.osdn.gokigen.gr2control.camera.ricohgr2.operation.RicohGr2CameraButtonControl;
26 import net.osdn.gokigen.gr2control.camera.ricohgr2.operation.RicohGr2CameraCaptureControl;
27 import net.osdn.gokigen.gr2control.camera.ricohgr2.operation.RicohGr2CameraFocusControl;
28 import net.osdn.gokigen.gr2control.camera.ricohgr2.operation.RicohGr2CameraZoomLensControl;
29 import net.osdn.gokigen.gr2control.camera.ricohgr2.operation.RicohGr2HardwareStatus;
30 import net.osdn.gokigen.gr2control.camera.ricohgr2.wrapper.connection.RicohGr2Connection;
31 import net.osdn.gokigen.gr2control.liveview.IAutoFocusFrameDisplay;
32 import net.osdn.gokigen.gr2control.liveview.IIndicatorControl;
33 import net.osdn.gokigen.gr2control.liveview.liveviewlistener.ILiveViewListener;
34 import net.osdn.gokigen.gr2control.preference.IPreferencePropertyAccessor;
40 public class RicohGr2InterfaceProvider implements IRicohGr2InterfaceProvider, IDisplayInjector
42 private final String TAG = toString();
43 //private final Activity activity;
44 //private final ICameraStatusReceiver provider;
45 private final RicohGr2Connection gr2Connection;
46 private final RicohGr2CameraButtonControl buttonControl;
47 private final RicohGr2StatusChecker statusChecker;
48 private final RicohGr2PlaybackControl playbackControl;
49 private final RicohGr2HardwareStatus hardwareStatus;
50 private final RicohGr2RunMode runMode;
51 private final boolean useGrCommand;
52 private final boolean pentaxCaptureAfterAf;
54 private RicohGr2LiveViewControl liveViewControl;
55 private RicohGr2CameraCaptureControl captureControl;
56 private RicohGr2CameraZoomLensControl zoomControl;
57 private RicohGr2CameraFocusControl focusControl;
63 public RicohGr2InterfaceProvider(@NonNull Activity context, @NonNull ICameraStatusReceiver provider)
65 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
66 useGrCommand = preferences.getBoolean(IPreferencePropertyAccessor.USE_GR2_SPECIAL_COMMAND, true);
67 pentaxCaptureAfterAf = preferences.getBoolean(IPreferencePropertyAccessor.PENTAX_CAPTURE_AFTER_AF, false);
69 //this.activity = context;
70 //this.provider = provider;
71 gr2Connection = new RicohGr2Connection(context, provider);
72 liveViewControl = new RicohGr2LiveViewControl(useGrCommand);
73 zoomControl = new RicohGr2CameraZoomLensControl();
74 buttonControl = new RicohGr2CameraButtonControl();
75 statusChecker = new RicohGr2StatusChecker(500, useGrCommand);
76 playbackControl = new RicohGr2PlaybackControl();
77 hardwareStatus = new RicohGr2HardwareStatus();
78 runMode = new RicohGr2RunMode();
83 Log.v(TAG, "prepare()");
87 public void injectDisplay(IAutoFocusFrameDisplay frameDisplayer, IIndicatorControl indicator, IFocusingModeNotify focusingModeNotify)
89 Log.v(TAG, "injectDisplay()");
90 focusControl = new RicohGr2CameraFocusControl(useGrCommand, frameDisplayer, indicator);
91 captureControl = new RicohGr2CameraCaptureControl(useGrCommand, pentaxCaptureAfterAf, frameDisplayer, statusChecker);
95 public ICameraConnection getRicohGr2CameraConnection()
97 return (gr2Connection);
101 public ILiveViewControl getLiveViewControl()
103 return (liveViewControl);
107 public ILiveViewListener getLiveViewListener()
109 if (liveViewControl == null)
113 return (liveViewControl.getLiveViewListener());
117 public IFocusingControl getFocusingControl()
119 return (focusControl);
123 public ICameraInformation getCameraInformation()
129 public IZoomLensControl getZoomLensControl()
131 return (zoomControl);
135 public ICaptureControl getCaptureControl()
137 return (captureControl);
141 public IDisplayInjector getDisplayInjector() {
146 public ICameraStatus getCameraStatusListHolder()
148 return (statusChecker);
152 public ICameraButtonControl getButtonControl()
154 return (buttonControl);
158 public ICameraStatusWatcher getCameraStatusWatcher() {
159 return (statusChecker);
163 public IPlaybackControl getPlaybackControl()
165 return (playbackControl);
169 public ICameraHardwareStatus getHardwareStatus()
171 return (hardwareStatus);
175 public ICameraRunMode getCameraRunMode()