OSDN Git Service

Pentax DSLR機で、AFを動作後シャッターを切る設定ができるよう変更する。(でも、再起動必要...)
[gokigen/Gr2Control.git] / app / src / main / java / net / osdn / gokigen / gr2control / camera / ricohgr2 / wrapper / RicohGr2InterfaceProvider.java
1 package net.osdn.gokigen.gr2control.camera.ricohgr2.wrapper;
2
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;
8
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;
35
36 /**
37  *
38  *
39  */
40 public class RicohGr2InterfaceProvider implements IRicohGr2InterfaceProvider, IDisplayInjector
41 {
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;
53
54     private RicohGr2LiveViewControl liveViewControl;
55     private RicohGr2CameraCaptureControl captureControl;
56     private RicohGr2CameraZoomLensControl zoomControl;
57     private RicohGr2CameraFocusControl focusControl;
58
59     /**
60      *
61      *
62      */
63     public RicohGr2InterfaceProvider(@NonNull Activity context, @NonNull ICameraStatusReceiver provider)
64     {
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);
68
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();
79     }
80
81     public void prepare()
82     {
83         Log.v(TAG, "prepare()");
84     }
85
86     @Override
87     public void injectDisplay(IAutoFocusFrameDisplay frameDisplayer, IIndicatorControl indicator, IFocusingModeNotify focusingModeNotify)
88     {
89         Log.v(TAG, "injectDisplay()");
90         focusControl = new RicohGr2CameraFocusControl(useGrCommand, frameDisplayer, indicator);
91         captureControl = new RicohGr2CameraCaptureControl(useGrCommand, pentaxCaptureAfterAf, frameDisplayer, statusChecker);
92     }
93
94     @Override
95     public ICameraConnection getRicohGr2CameraConnection()
96     {
97         return (gr2Connection);
98     }
99
100     @Override
101     public ILiveViewControl getLiveViewControl()
102     {
103         return (liveViewControl);
104     }
105
106     @Override
107     public ILiveViewListener getLiveViewListener()
108     {
109         if (liveViewControl == null)
110         {
111             return (null);
112         }
113         return (liveViewControl.getLiveViewListener());
114     }
115
116     @Override
117     public IFocusingControl getFocusingControl()
118     {
119         return (focusControl);
120     }
121
122     @Override
123     public ICameraInformation getCameraInformation()
124     {
125         return null;
126     }
127
128     @Override
129     public IZoomLensControl getZoomLensControl()
130     {
131         return (zoomControl);
132     }
133
134     @Override
135     public ICaptureControl getCaptureControl()
136     {
137         return (captureControl);
138     }
139
140     @Override
141     public IDisplayInjector getDisplayInjector() {
142         return (this);
143     }
144
145     @Override
146     public ICameraStatus getCameraStatusListHolder()
147     {
148         return (statusChecker);
149     }
150
151     @Override
152     public ICameraButtonControl getButtonControl()
153     {
154         return (buttonControl);
155     }
156
157     @Override
158     public ICameraStatusWatcher getCameraStatusWatcher() {
159         return (statusChecker);
160     }
161
162     @Override
163     public IPlaybackControl getPlaybackControl()
164     {
165         return (playbackControl);
166     }
167
168     @Override
169     public ICameraHardwareStatus getHardwareStatus()
170     {
171         return (hardwareStatus);
172     }
173
174     @Override
175     public ICameraRunMode getCameraRunMode()
176     {
177         return (runMode);
178     }
179 }