OSDN Git Service

次バージョンのための拡張を開始。
[gokigen/PKRemote.git] / app / src / main / java / net / osdn / gokigen / pkremote / camera / vendor / olympuspen / wrapper / OlympusPenInterfaceProvider.java
1 package net.osdn.gokigen.pkremote.camera.vendor.olympuspen.wrapper;
2
3 import android.app.Activity;
4 import android.content.SharedPreferences;
5
6 import android.util.Log;
7
8 import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraButtonControl;
9 import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraConnection;
10 import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraRunMode;
11 import net.osdn.gokigen.pkremote.camera.interfaces.control.ICaptureControl;
12 import net.osdn.gokigen.pkremote.camera.interfaces.control.IFocusingControl;
13 import net.osdn.gokigen.pkremote.camera.interfaces.control.IFocusingModeNotify;
14 import net.osdn.gokigen.pkremote.camera.interfaces.control.IZoomLensControl;
15 import net.osdn.gokigen.pkremote.camera.interfaces.liveview.IAutoFocusFrameDisplay;
16 import net.osdn.gokigen.pkremote.camera.interfaces.liveview.IDisplayInjector;
17 import net.osdn.gokigen.pkremote.camera.interfaces.liveview.IIndicatorControl;
18 import net.osdn.gokigen.pkremote.camera.interfaces.liveview.ILiveViewControl;
19 import net.osdn.gokigen.pkremote.camera.interfaces.liveview.ILiveViewListener;
20 import net.osdn.gokigen.pkremote.camera.interfaces.playback.IPlaybackControl;
21 import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraHardwareStatus;
22 import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraInformation;
23 import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraStatus;
24 import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraStatusReceiver;
25 import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraStatusWatcher;
26 import net.osdn.gokigen.pkremote.camera.vendor.olympuspen.IOlympusPenInterfaceProvider;
27 import net.osdn.gokigen.pkremote.camera.vendor.olympuspen.wrapper.connection.OlympusPenConnection;
28 import net.osdn.gokigen.pkremote.camera.vendor.olympuspen.wrapper.hardware.OlympusPenButtonControl;
29 import net.osdn.gokigen.pkremote.camera.vendor.olympuspen.wrapper.hardware.OlympusPenHardwareStatus;
30 import net.osdn.gokigen.pkremote.camera.vendor.olympuspen.wrapper.playback.OlympusPenPlaybackControl;
31 import net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor;
32
33 import androidx.annotation.NonNull;
34 import androidx.preference.PreferenceManager;
35
36 /**
37  *
38  *
39  */
40 public class OlympusPenInterfaceProvider implements IOlympusPenInterfaceProvider, IDisplayInjector
41 {
42     private final String TAG = toString();
43     //private final Activity activity;
44     //private final ICameraStatusReceiver provider;
45     private final OlympusPenConnection olympusPenConnection;
46     private final OlympusPenButtonControl buttonControl;
47     private final OlympusPenPlaybackControl playbackControl;
48     private final OlympusPenHardwareStatus hardwareStatus;
49     private final OlympusPenRunMode runMode;
50
51     /**
52      *
53      *
54      */
55     public OlympusPenInterfaceProvider(@NonNull Activity context, @NonNull ICameraStatusReceiver provider)
56     {
57         SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
58         //useGrCommand = preferences.getBoolean(IPreferencePropertyAccessor.USE_GR2_SPECIAL_COMMAND, true);
59         //pentaxCaptureAfterAf = preferences.getBoolean(IPreferencePropertyAccessor.PENTAX_CAPTURE_AFTER_AF, false);
60         int communicationTimeoutMs = 10000;  // デフォルトは 10000ms とする
61         try
62         {
63             communicationTimeoutMs = Integer.parseInt(preferences.getString(IPreferencePropertyAccessor.RICOH_GET_PICS_LIST_TIMEOUT, IPreferencePropertyAccessor.RICOH_GET_PICS_LIST_TIMEOUT_DEFAULT_VALUE)) * 1000;
64             if (communicationTimeoutMs < 3000)
65             {
66                 communicationTimeoutMs = 3000;  // 最小値は 3000msとする。
67             }
68         }
69         catch (Exception e)
70         {
71             e.printStackTrace();
72         }
73         int maxCount = 3000;  // デフォルトは 3000枚 とする
74         try
75         {
76             maxCount = Integer.parseInt(preferences.getString(IPreferencePropertyAccessor.RICOH_GET_PICS_LIST_MAX_COUNT, IPreferencePropertyAccessor.RICOH_GET_PICS_LIST_MAX_COUNT_DEFAULT_VALUE));
77             if (maxCount < 300)
78             {
79                 maxCount = 300;  // 最小値は 300枚とする。
80             }
81         }
82         catch (Exception e)
83         {
84             e.printStackTrace();
85         }
86
87         //this.activity = context;
88         //this.provider = provider;
89         olympusPenConnection = new OlympusPenConnection(context, provider);
90         //liveViewControl = new RicohGr2LiveViewControl(useGrCommand);
91         //zoomControl = new RicohGr2CameraZoomLensControl();
92         buttonControl = new OlympusPenButtonControl();
93         //statusChecker = new RicohGr2StatusChecker(500, useGrCommand);
94         playbackControl = new OlympusPenPlaybackControl(communicationTimeoutMs);
95         hardwareStatus = new OlympusPenHardwareStatus();
96         runMode = new OlympusPenRunMode();
97     }
98
99     public void prepare()
100     {
101         Log.v(TAG, "prepare()");
102     }
103
104     @Override
105     public void injectDisplay(IAutoFocusFrameDisplay frameDisplayer, IIndicatorControl indicator, IFocusingModeNotify focusingModeNotify)
106     {
107         Log.v(TAG, "injectDisplay()");
108         //focusControl = new RicohGr2CameraFocusControl(useGrCommand, frameDisplayer, indicator);
109         //captureControl = new RicohGr2CameraCaptureControl(useGrCommand, pentaxCaptureAfterAf, frameDisplayer, statusChecker);
110     }
111
112     @Override
113     public ICameraConnection getOlyCameraConnection()
114     {
115         return (olympusPenConnection);
116     }
117
118     @Override
119     public ILiveViewControl getLiveViewControl()
120     {
121         return (null);
122     }
123
124     @Override
125     public ILiveViewListener getLiveViewListener()
126     {
127         return (null);
128     }
129
130     @Override
131     public IFocusingControl getFocusingControl()
132     {
133         return (null);
134     }
135
136     @Override
137     public ICameraInformation getCameraInformation()
138     {
139         return (null);
140     }
141
142     @Override
143     public IZoomLensControl getZoomLensControl()
144     {
145         return (null);
146     }
147
148     @Override
149     public ICaptureControl getCaptureControl()
150     {
151         return (null);
152     }
153
154     @Override
155     public IDisplayInjector getDisplayInjector() {
156         return (this);
157     }
158
159     @Override
160     public ICameraStatus getCameraStatusListHolder()
161     {
162         return (null);
163     }
164
165     @Override
166     public ICameraButtonControl getButtonControl()
167     {
168         return (buttonControl);
169     }
170
171     @Override
172     public ICameraStatusWatcher getCameraStatusWatcher() {
173         return (null);
174     }
175
176     @Override
177     public IPlaybackControl getPlaybackControl()
178     {
179         return (playbackControl);
180     }
181
182     @Override
183     public ICameraHardwareStatus getHardwareStatus()
184     {
185         return (hardwareStatus);
186     }
187
188     @Override
189     public ICameraRunMode getCameraRunMode()
190     {
191         return (runMode);
192     }
193 }