OSDN Git Service

最新SDKに更新。
[gokigen/A01d.git] / app / src / main / java / net / osdn / gokigen / a01d / camera / ricohgr2 / wrapper / RicohGr2InterfaceProvider.java
1 package net.osdn.gokigen.a01d.camera.ricohgr2.wrapper;
2
3 import android.app.Activity;
4 import android.content.SharedPreferences;
5 import android.preference.PreferenceManager;
6 import android.util.Log;
7
8 import net.osdn.gokigen.a01d.camera.ICameraConnection;
9 import net.osdn.gokigen.a01d.camera.ICameraInformation;
10 import net.osdn.gokigen.a01d.camera.ICameraStatusReceiver;
11 import net.osdn.gokigen.a01d.camera.ICaptureControl;
12 import net.osdn.gokigen.a01d.camera.IFocusingControl;
13 import net.osdn.gokigen.a01d.camera.ILiveViewControl;
14 import net.osdn.gokigen.a01d.camera.IFocusingModeNotify;
15 import net.osdn.gokigen.a01d.camera.IZoomLensControl;
16 import net.osdn.gokigen.a01d.camera.ricohgr2.IRicohGr2InterfaceProvider;
17 import net.osdn.gokigen.a01d.camera.ricohgr2.operation.RicohGr2CameraCaptureControl;
18 import net.osdn.gokigen.a01d.camera.ricohgr2.operation.RicohGr2CameraFocusControl;
19 import net.osdn.gokigen.a01d.camera.ricohgr2.operation.RicohGr2CameraZoomLensControl;
20 import net.osdn.gokigen.a01d.camera.ricohgr2.wrapper.connection.RicohGr2Connection;
21 import net.osdn.gokigen.a01d.camera.IDisplayInjector;
22 import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
23 import net.osdn.gokigen.a01d.liveview.IIndicatorControl;
24 import net.osdn.gokigen.a01d.liveview.liveviewlistener.ILiveViewListener;
25 import net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor;
26
27 import androidx.annotation.NonNull;
28
29 /**
30  *
31  *
32  */
33 public class RicohGr2InterfaceProvider implements IRicohGr2InterfaceProvider, IDisplayInjector, IUsePentaxCommand
34 {
35     private final String TAG = toString();
36     private final Activity activity;
37     //private final ICameraStatusReceiver provider;
38     private final RicohGr2Connection gr2Connection;
39     private RicohGr2LiveViewControl liveViewControl;
40     private RicohGr2CameraCaptureControl captureControl;
41     private RicohGr2CameraZoomLensControl zoomControl;
42     private RicohGr2CameraFocusControl focusControl;
43
44     private boolean usePentaxCommand = false;
45
46     /**
47      *
48      *
49      */
50     public RicohGr2InterfaceProvider(@NonNull Activity context, @NonNull ICameraStatusReceiver provider)
51     {
52         this.activity = context;
53         //this.provider = provider;
54         gr2Connection = new RicohGr2Connection(context, provider, this);
55         liveViewControl = new RicohGr2LiveViewControl(context, this);
56         zoomControl = new RicohGr2CameraZoomLensControl();
57     }
58
59     /**
60      *
61      *
62      */
63     public void prepare()
64     {
65         // liveViewControl = new RicohGr2LiveViewControl();
66     }
67
68     /**
69      *
70      *
71      */
72     @Override
73     public void injectDisplay(IAutoFocusFrameDisplay frameDisplayer, IIndicatorControl indicator, IFocusingModeNotify focusingModeNotify)
74     {
75         Log.v(TAG, "injectDisplay()");
76         focusControl = new RicohGr2CameraFocusControl(frameDisplayer, indicator, this);
77         captureControl = new RicohGr2CameraCaptureControl(frameDisplayer, this);
78     }
79
80     /**
81      *
82      *
83      */
84     @Override
85     public ICameraConnection getRicohGr2CameraConnection()
86     {
87         return (gr2Connection);
88     }
89
90     /**
91      *
92      *
93      */
94     @Override
95     public ILiveViewControl getLiveViewControl()
96     {
97         return (liveViewControl);
98     }
99
100     /**
101      *
102      *
103      */
104     @Override
105     public ILiveViewListener getLiveViewListener()
106     {
107         if (liveViewControl == null)
108         {
109             return (null);
110         }
111         return (liveViewControl.getLiveViewListener());
112     }
113
114     @Override
115     public IFocusingControl getFocusingControl()
116     {
117         return (focusControl);
118     }
119
120     @Override
121     public ICameraInformation getCameraInformation()
122     {
123         return null;
124     }
125
126     @Override
127     public IZoomLensControl getZoomLensControl()
128     {
129         return (zoomControl);
130     }
131
132     @Override
133     public ICaptureControl getCaptureControl()
134     {
135         return (captureControl);
136     }
137
138     @Override
139     public IDisplayInjector getDisplayInjector() {
140         return (this);
141     }
142
143     @Override
144     public void setUsePentaxCommand(boolean usePentaxCommand)
145     {
146         this.usePentaxCommand = usePentaxCommand;
147         try
148         {
149             SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
150             SharedPreferences.Editor editor = preferences.edit();
151             editor.putBoolean(IPreferencePropertyAccessor.USE_PENTAX_AUTOFOCUS, usePentaxCommand);
152             editor.apply();
153         }
154         catch (Exception e)
155         {
156             e.printStackTrace();
157         }
158         Log.v(TAG, " setUsePentaxCommand : " + usePentaxCommand);
159     }
160
161     @Override
162     public boolean getUsePentaxCommand()
163     {
164         return (usePentaxCommand);
165     }
166 }