• R/O
  • HTTP
  • SSH
  • HTTPS

A01d: Commit

OPC(Olympus Air)用望遠鏡アプリ。


Commit MetaInfo

Révisionea6ee62c6629beca072eb855547f625e52590e33 (tree)
l'heure2018-10-08 22:00:19
AuteurMRSa <mrsa@myad...>
CommiterMRSa

Message de Log

SONYのシャッター半押し機能を追加する途中。

Change Summary

Modification

--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/CameraInterfaceProvider.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/CameraInterfaceProvider.java
@@ -12,6 +12,7 @@ import net.osdn.gokigen.a01d.camera.ricohgr2.IRicohGr2InterfaceProvider;
1212 import net.osdn.gokigen.a01d.camera.ricohgr2.wrapper.RicohGr2InterfaceProvider;
1313 import net.osdn.gokigen.a01d.camera.sony.ISonyInterfaceProvider;
1414 import net.osdn.gokigen.a01d.camera.sony.wrapper.SonyCameraWrapper;
15+import net.osdn.gokigen.a01d.liveview.ICameraStatusUpdateNotify;
1516 import net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor;
1617
1718 public class CameraInterfaceProvider implements IInterfaceProvider
@@ -20,16 +21,31 @@ public class CameraInterfaceProvider implements IInterfaceProvider
2021 private final OlympusInterfaceProvider olympus;
2122 private final SonyCameraWrapper sony;
2223 private final RicohGr2InterfaceProvider ricohGr2;
24+ private final CameraStatusListener statusListener;
2325
2426 public CameraInterfaceProvider(@NonNull Activity context, @NonNull ICameraStatusReceiver provider)
2527 {
2628 this.context = context;
29+ this.statusListener = new CameraStatusListener();
2730 olympus = new OlympusInterfaceProvider(context, provider);
28- sony = new SonyCameraWrapper(context, provider);
31+ sony = new SonyCameraWrapper(context, provider, statusListener);
2932 ricohGr2 = new RicohGr2InterfaceProvider(context, provider);
3033 }
3134
3235 @Override
36+ public void setUpdateReceiver(@NonNull ICameraStatusUpdateNotify receiver)
37+ {
38+ try
39+ {
40+ statusListener.setUpdateReceiver(receiver);
41+ }
42+ catch (Exception e)
43+ {
44+ e.printStackTrace();
45+ }
46+ }
47+
48+ @Override
3349 public IOlympusInterfaceProvider getOlympusInterface()
3450 {
3551 return (olympus);
--- /dev/null
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/CameraStatusListener.java
@@ -0,0 +1,142 @@
1+package net.osdn.gokigen.a01d.camera;
2+
3+import android.support.annotation.NonNull;
4+import android.util.Log;
5+
6+import net.osdn.gokigen.a01d.camera.sony.wrapper.eventlistener.CameraChangeListerTemplate;
7+import net.osdn.gokigen.a01d.liveview.ICameraStatusUpdateNotify;
8+
9+public class CameraStatusListener extends CameraChangeListerTemplate implements ICameraStatusUpdateNotify
10+{
11+ private final String TAG = toString();
12+ private ICameraStatusUpdateNotify updateReceiver = null;
13+
14+
15+ CameraStatusListener()
16+ {
17+ Log.v(TAG, "CameraStatusListener()");
18+ }
19+
20+ void setUpdateReceiver(@NonNull ICameraStatusUpdateNotify receiver)
21+ {
22+ updateReceiver = receiver;
23+ }
24+
25+ @Override
26+ public void onFocusStatusChanged(String focusStatus)
27+ {
28+ Log.v(TAG, "onFocusStatusChanged() : " + focusStatus);
29+ if ((focusStatus == null)||(updateReceiver == null))
30+ {
31+ Log.v(TAG, "focusStatus or updateReceiver is NULL.");
32+ return;
33+ }
34+ switch (focusStatus)
35+ {
36+ case "Focused":
37+ updateReceiver.updateFocusedStatus(true, true);
38+ break;
39+ case "Failed":
40+ updateReceiver.updateFocusedStatus(false, true);
41+ break;
42+ case "Focusing":
43+ case "Not Focusing":
44+ default:
45+ updateReceiver.updateFocusedStatus(false, false);
46+ break;
47+ }
48+ }
49+
50+ @Override
51+ public void updateDriveMode(String driveMode)
52+ {
53+ Log.v(TAG, "updateDriveMode() : " + driveMode);
54+ }
55+
56+ @Override
57+ public void updateAeLockState(boolean isAeLocked)
58+ {
59+
60+ }
61+
62+ @Override
63+ public void updateCameraStatus(String message)
64+ {
65+
66+ }
67+
68+ @Override
69+ public void updateLevelGauge(String orientation, float roll, float pitch)
70+ {
71+
72+ }
73+
74+ @Override
75+ public void updatedTakeMode(String mode)
76+ {
77+
78+ }
79+
80+ @Override
81+ public void updatedShutterSpeed(String tv)
82+ {
83+
84+ }
85+
86+ @Override
87+ public void updatedAperture(String av)
88+ {
89+
90+ }
91+
92+ @Override
93+ public void updatedExposureCompensation(String xv)
94+ {
95+
96+ }
97+
98+ @Override
99+ public void updatedMeteringMode(String meteringMode)
100+ {
101+
102+ }
103+
104+ @Override
105+ public void updatedWBMode(String wbMode)
106+ {
107+
108+ }
109+
110+ @Override
111+ public void updateRemainBattery(int percentage)
112+ {
113+
114+ }
115+
116+ @Override
117+ public void updateFocusedStatus(boolean focused, boolean focusLocked)
118+ {
119+ if (updateReceiver != null)
120+ {
121+ updateReceiver.updateFocusedStatus(focused, focusLocked);
122+ }
123+ }
124+
125+ @Override
126+ public void updateIsoSensitivity(String sv)
127+ {
128+
129+ }
130+
131+ @Override
132+ public void updateWarning(String warning)
133+ {
134+
135+ }
136+
137+ @Override
138+ public void updateStorageStatus(String status)
139+ {
140+
141+ }
142+}
--- /dev/null
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/ICameraStatus.java
@@ -0,0 +1,43 @@
1+package net.osdn.gokigen.a01d.camera;
2+
3+import android.support.annotation.NonNull;
4+
5+import java.util.List;
6+
7+public interface ICameraStatus
8+{
9+ @NonNull List<String> getStatusList(@NonNull final String key);
10+ String getStatus(@NonNull final String key);
11+ void setStatus(@NonNull final String key, @NonNull final String value);
12+
13+ String BATTERY = "battery";
14+ String STATE = "state";
15+ String FOCUS_MODE = "focusMode";
16+ String AF_MODE = "AFMode";
17+
18+ String RESOLUTION = "reso";
19+ String DRIVE_MODE = "shootMode";
20+ String WHITE_BALANCE = "WBMode";
21+
22+ String AE = "meteringMode";
23+
24+ String AE_STATUS_MULTI = "multi";
25+ String AE_STATUS_ESP = "ESP";
26+ String AE_STATUS_SPOT = "spot";
27+ String AE_STATUS_PINPOINT = "Spot";
28+ String AE_STATUS_CENTER = "center";
29+ String AE_STATUS_CENTER2 = "Ctr-Weighted";
30+
31+ String EFFECT = "effect";
32+ String TAKE_MODE = "exposureMode";
33+ String IMAGESIZE = "stillSize";
34+ String MOVIESIZE = "movieSize";
35+
36+ String APERATURE = "av";
37+ String SHUTTER_SPEED = "tv";
38+ String ISO_SENSITIVITY = "sv";
39+ String EXPREV = "xv";
40+ String FLASH_XV = "flashxv";
41+
42+ String TAKE_MODE_MOVIE = "movie";
43+}
--- /dev/null
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/ICameraStatusWatcher.java
@@ -0,0 +1,11 @@
1+package net.osdn.gokigen.a01d.camera;
2+
3+import android.support.annotation.NonNull;
4+
5+import net.osdn.gokigen.a01d.liveview.ICameraStatusUpdateNotify;
6+
7+public interface ICameraStatusWatcher
8+{
9+ void startStatusWatch(@NonNull ICameraStatusUpdateNotify notifier);
10+ void stopStatusWatch();
11+}
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/IInterfaceProvider.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/IInterfaceProvider.java
@@ -1,9 +1,12 @@
11 package net.osdn.gokigen.a01d.camera;
22
3+import android.support.annotation.NonNull;
4+
35 import net.osdn.gokigen.a01d.camera.olympus.wrapper.IOlympusLiveViewListener;
46 import net.osdn.gokigen.a01d.camera.olympus.IOlympusInterfaceProvider;
57 import net.osdn.gokigen.a01d.camera.ricohgr2.IRicohGr2InterfaceProvider;
68 import net.osdn.gokigen.a01d.camera.sony.ISonyInterfaceProvider;
9+import net.osdn.gokigen.a01d.liveview.ICameraStatusUpdateNotify;
710
811 /**
912 *
@@ -16,5 +19,7 @@ public interface IInterfaceProvider
1619 ISonyInterfaceProvider getSonyInterface();
1720 IRicohGr2InterfaceProvider getRicohGr2Infterface();
1821
22+ void setUpdateReceiver(@NonNull ICameraStatusUpdateNotify receiver);
23+
1924 ICameraConnection.CameraConnectionMethod getCammeraConnectionMethod();
2025 }
--- /dev/null
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/ricohgr2/status/RicohGr2StatusChecker.java
@@ -0,0 +1,246 @@
1+package net.osdn.gokigen.a01d.camera.ricohgr2.status;
2+
3+import android.support.annotation.NonNull;
4+import android.util.Log;
5+
6+import net.osdn.gokigen.a01d.camera.ICameraStatus;
7+import net.osdn.gokigen.a01d.camera.ICameraStatusWatcher;
8+import net.osdn.gokigen.a01d.camera.utils.SimpleHttpClient;
9+import net.osdn.gokigen.a01d.liveview.ICameraStatusUpdateNotify;
10+
11+import java.util.ArrayList;
12+import java.util.List;
13+
14+public class RicohGr2StatusChecker implements ICameraStatusWatcher, ICameraStatus
15+{
16+ private final String TAG = toString();
17+ private final String statusCheckUrl = "http://192.168.0.1/v1/props";
18+ private final String statusSetUrl = "http://192.168.0.1/v1/params/camera";
19+ private final String grCommandUrl = "http://192.168.0.1/_gr";
20+ private final int sleepMs;
21+
22+ private final boolean useGrCommand;
23+
24+ private int timeoutMs = 5000;
25+ private boolean whileFetching = false;
26+ private RicohGr2StatusHolder statusHolder;
27+
28+ /**
29+ *
30+ *
31+ */
32+ RicohGr2StatusChecker(int sleepMs, boolean useGrCommand)
33+ {
34+ this.useGrCommand = useGrCommand;
35+ this.sleepMs = sleepMs;
36+ }
37+
38+ /**
39+ *
40+ *
41+ */
42+ @Override
43+ public void startStatusWatch(@NonNull ICameraStatusUpdateNotify notifier)
44+ {
45+ Log.v(TAG, "startStatusWatch()");
46+ try
47+ {
48+ this.statusHolder = new RicohGr2StatusHolder(notifier);
49+ Thread thread = new Thread(new Runnable()
50+ {
51+ @Override
52+ public void run()
53+ {
54+ try
55+ {
56+ start(statusCheckUrl);
57+ }
58+ catch (Exception e)
59+ {
60+ e.printStackTrace();
61+ }
62+ }
63+ });
64+ thread.start();
65+ }
66+ catch (Exception e)
67+ {
68+ e.printStackTrace();
69+ }
70+ }
71+
72+ /**
73+ *
74+ *
75+ */
76+ @Override
77+ public void stopStatusWatch()
78+ {
79+ Log.v(TAG, "stoptStatusWatch()");
80+ whileFetching = false;
81+ }
82+
83+ /**
84+ *
85+ *
86+ */
87+ private void start(@NonNull final String watchUrl)
88+ {
89+ if (whileFetching)
90+ {
91+ Log.v(TAG, "start() already starting.");
92+ return;
93+ }
94+
95+ try
96+ {
97+ whileFetching = true;
98+ Thread thread = new Thread(new Runnable()
99+ {
100+ @Override
101+ public void run()
102+ {
103+ Log.d(TAG, "Start status watch.");
104+ while (whileFetching)
105+ {
106+ try
107+ {
108+ statusHolder.updateStatus(SimpleHttpClient.httpGet(watchUrl, timeoutMs));
109+ Thread.sleep(sleepMs);
110+ }
111+ catch (Exception e)
112+ {
113+ e.printStackTrace();
114+ }
115+ }
116+ Log.v(TAG, "STATUS WATCH STOPPED.");
117+ }
118+ });
119+ thread.start();
120+ }
121+ catch (Exception e)
122+ {
123+ e.printStackTrace();
124+ }
125+ }
126+
127+ @Override
128+ public @NonNull
129+ List<String> getStatusList(@NonNull final String key)
130+ {
131+ try
132+ {
133+ if (statusHolder == null)
134+ {
135+ return (new ArrayList<>());
136+ }
137+ String listKey = key + "List";
138+ return (statusHolder.getAvailableItemList(listKey));
139+ }
140+ catch (Exception e)
141+ {
142+ e.printStackTrace();
143+ }
144+ return (new ArrayList<>());
145+ }
146+
147+ @Override
148+ public String getStatus(@NonNull String key)
149+ {
150+ try
151+ {
152+ if (statusHolder == null)
153+ {
154+ return ("");
155+ }
156+ return (statusHolder.getItemStatus(key));
157+ }
158+ catch (Exception e)
159+ {
160+ e.printStackTrace();
161+ }
162+ return ("");
163+ }
164+
165+ @Override
166+ public void setStatus(@NonNull final String key, @NonNull final String value)
167+ {
168+ Thread thread = new Thread(new Runnable() {
169+ @Override
170+ public void run() {
171+ try
172+ {
173+ String response;
174+ String postData = key + "=" + value;
175+ if ((useGrCommand)&&(key.equals("exposureMode")))
176+ {
177+ // 撮影モードを変更するときは、GR専用コマンドを送ることにする。
178+ postData = "cmd=" + decideButtonCode(value);
179+ response = SimpleHttpClient.httpPost(grCommandUrl, postData, timeoutMs);
180+ Log.v(TAG, "CHANGE MODE : " + postData + " resp. (" + response.length() + "bytes.)");
181+ } else {
182+ // 通常の変更コマンド
183+ response = SimpleHttpClient.httpPut(statusSetUrl, postData, timeoutMs);
184+ Log.v(TAG, "SET PROPERTY : " + postData + " resp. (" + response.length() + "bytes.)");
185+ }
186+ if (useGrCommand)
187+ {
188+ // GR専用コマンドで、画面表示をリフレッシュ
189+ response = SimpleHttpClient.httpPost(grCommandUrl, "cmd=mode refresh", timeoutMs);
190+ Log.v(TAG, "refresh resp. (" + response.length() + "bytes.)");
191+ }
192+ }
193+ catch (Exception e)
194+ {
195+ e.printStackTrace();
196+ }
197+ }
198+ });
199+ try
200+ {
201+ thread.start();
202+ }
203+ catch (Exception e)
204+ {
205+ e.printStackTrace();
206+ }
207+ }
208+
209+ /**
210+ * 撮影モードをGRのダイアルコマンドに変更する
211+ *
212+ */
213+ private String decideButtonCode(String exposureMode)
214+ {
215+ String buttonCode = "bdial AUTO";
216+ if (exposureMode == null)
217+ {
218+ return (buttonCode);
219+ }
220+ switch (exposureMode)
221+ {
222+ case "movie":
223+ buttonCode = "bdial MOVIE";
224+ break;
225+ case "M":
226+ buttonCode = "bdial M";
227+ break;
228+ case "TAV":
229+ buttonCode = "bdial TAV";
230+ break;
231+ case "AV":
232+ buttonCode = "bdial AV";
233+ break;
234+ case "TV":
235+ buttonCode = "bdial TV";
236+ break;
237+ case "P":
238+ buttonCode = "bdial P";
239+ break;
240+ case "auto":
241+ buttonCode = "bdial AUTO";
242+ break;
243+ }
244+ return (buttonCode);
245+ }
246+}
--- /dev/null
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/ricohgr2/status/RicohGr2StatusHolder.java
@@ -0,0 +1,186 @@
1+package net.osdn.gokigen.a01d.camera.ricohgr2.status;
2+
3+import android.support.annotation.NonNull;
4+import android.util.Log;
5+
6+import net.osdn.gokigen.a01d.liveview.ICameraStatusUpdateNotify;
7+
8+import org.json.JSONArray;
9+import org.json.JSONObject;
10+
11+import java.util.ArrayList;
12+import java.util.List;
13+
14+public class RicohGr2StatusHolder
15+{
16+ private final String TAG = toString();
17+ private final ICameraStatusUpdateNotify notifier;
18+
19+ private JSONObject latestResultObject = null;
20+ private boolean focused = false;
21+ private boolean focusLocked = false;
22+ private String avStatus = "";
23+ private String tvStatus = "";
24+ private String xvStatus = "";
25+ private String exposureModeStatus = "";
26+ private String meteringModeStatus = "";
27+ private String wbModeStatus = "";
28+ private String batteryStatus = "";
29+
30+ /**
31+ *
32+ *
33+ */
34+ RicohGr2StatusHolder(ICameraStatusUpdateNotify notifier)
35+ {
36+ this.notifier = notifier;
37+ }
38+
39+ /**
40+ *
41+ *
42+ */
43+ List<String> getAvailableItemList(@NonNull String key)
44+ {
45+ List<String> itemList = new ArrayList<>();
46+ try
47+ {
48+ JSONArray array = latestResultObject.getJSONArray(key);
49+ if (array == null)
50+ {
51+ return (itemList);
52+ }
53+ int nofItems = array.length();
54+ for (int index = 0; index < nofItems; index++)
55+ {
56+ try
57+ {
58+ itemList.add(array.getString(index));
59+ }
60+ catch (Exception e)
61+ {
62+ e.printStackTrace();
63+ }
64+ }
65+ }
66+ catch (Exception e)
67+ {
68+ e.printStackTrace();
69+ }
70+ return (itemList);
71+ }
72+
73+ String getItemStatus(@NonNull String key)
74+ {
75+ try
76+ {
77+ return (latestResultObject.getString(key));
78+ }
79+ catch (Exception e)
80+ {
81+ e.printStackTrace();
82+ }
83+ return ("");
84+ }
85+
86+ private String getStatusString(JSONObject obj, String name)
87+ {
88+ try
89+ {
90+ return (obj.getString(name));
91+ }
92+ catch (Exception e)
93+ {
94+ e.printStackTrace();
95+ }
96+ return ("");
97+ }
98+
99+ private boolean getBooleanStatus(JSONObject obj, String name)
100+ {
101+ try {
102+ return (obj.getBoolean(name));
103+ } catch (Exception e) {
104+ //e.printStackTrace();
105+ }
106+ return (false);
107+ }
108+
109+ /**
110+ *
111+ *
112+ */
113+ void updateStatus(String replyString)
114+ {
115+ if ((replyString == null)||(replyString.length() < 1))
116+ {
117+ Log.v(TAG, "httpGet() reply is null. ");
118+ return;
119+ }
120+
121+ try
122+ {
123+ latestResultObject = new JSONObject(replyString);
124+ String result = getStatusString(latestResultObject,"errMsg");
125+ String av = getStatusString(latestResultObject,"av");
126+ String tv = getStatusString(latestResultObject,"tv");
127+ String xv = getStatusString(latestResultObject,"xv");
128+ String exposureMode = getStatusString(latestResultObject,"exposureMode");
129+ String meteringMode = getStatusString(latestResultObject,"meteringMode");
130+ String wbMode = getStatusString(latestResultObject,"WBMode");
131+ String battery = getStatusString(latestResultObject,"battery");
132+ boolean focus = getBooleanStatus(latestResultObject,"focused");
133+ boolean focusLock = getBooleanStatus(latestResultObject,"focusLocked");
134+
135+ if (result.contains("OK"))
136+ {
137+ if (!avStatus.equals(av))
138+ {
139+ avStatus = av;
140+ notifier.updatedAperture(avStatus);
141+ }
142+ if (!tvStatus.equals(tv))
143+ {
144+ tvStatus = tv;
145+ notifier.updatedShutterSpeed(tvStatus);
146+ }
147+ if (!xvStatus.equals(xv))
148+ {
149+ xvStatus = xv;
150+ notifier.updatedExposureCompensation(xvStatus);
151+ }
152+ if (!exposureModeStatus.equals(exposureMode))
153+ {
154+ exposureModeStatus = exposureMode;
155+ notifier.updatedTakeMode(exposureModeStatus);
156+ }
157+ if (!meteringModeStatus.equals(meteringMode))
158+ {
159+ meteringModeStatus = meteringMode;
160+ notifier.updatedMeteringMode(meteringModeStatus);
161+ }
162+ if (!wbModeStatus.equals(wbMode))
163+ {
164+ wbModeStatus = wbMode;
165+ notifier.updatedWBMode(wbModeStatus);
166+ }
167+ if (!batteryStatus.equals(battery))
168+ {
169+ batteryStatus = battery;
170+ notifier.updateRemainBattery(Integer.parseInt(batteryStatus));
171+ }
172+ if ((focus != focused)||(focusLock != focusLocked))
173+ {
174+ focused = focus;
175+ focusLocked = focusLock;
176+ notifier.updateFocusedStatus(focused, focusLocked);
177+ }
178+ }
179+ System.gc();
180+ }
181+ catch (Exception e)
182+ {
183+ e.printStackTrace();
184+ }
185+ }
186+}
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/operation/takepicture/SonyAutoFocusControl.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/operation/takepicture/SonyAutoFocusControl.java
@@ -134,7 +134,11 @@ public class SonyAutoFocusControl
134134 JSONObject resultsObj = (isPressed) ? cameraApi.actHalfPressShutter() : cameraApi.cancelHalfPressShutter();
135135 if (resultsObj == null)
136136 {
137- Log.v(TAG, "lockAutoFocus() [" + isPressed + "] reply is null.");
137+ Log.v(TAG, "halfPressShutter() [" + isPressed + "] reply is null.");
138+ }
139+ else
140+ {
141+ indicator.onAfLockUpdate(isPressed);
138142 }
139143 }
140144 catch (Exception e)
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/wrapper/SonyCameraWrapper.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/wrapper/SonyCameraWrapper.java
@@ -36,6 +36,7 @@ public class SonyCameraWrapper implements ISonyCameraHolder, ISonyInterfaceProvi
3636 private final String TAG = toString();
3737 private final Activity context;
3838 private final ICameraStatusReceiver provider;
39+ private final ICameraChangeListener listener;
3940 private ISonyCamera sonyCamera = null;
4041 private ISonyCameraApi sonyCameraApi = null;
4142 private ICameraEventObserver eventObserver = null;
@@ -44,10 +45,11 @@ public class SonyCameraWrapper implements ISonyCameraHolder, ISonyInterfaceProvi
4445 private SonyCameraCaptureControl captureControl = null;
4546 private SonyCameraZoomLensControl zoomControl = null;
4647
47- public SonyCameraWrapper(final Activity context, final ICameraStatusReceiver statusReceiver)
48+ public SonyCameraWrapper(final Activity context, final ICameraStatusReceiver statusReceiver , final @NonNull ICameraChangeListener listener)
4849 {
4950 this.context = context;
5051 this.provider = statusReceiver;
52+ this.listener = listener;
5153 }
5254
5355 @Override
@@ -102,7 +104,7 @@ public class SonyCameraWrapper implements ISonyCameraHolder, ISonyInterfaceProvi
102104 @Override
103105 public ICameraConnection getSonyCameraConnection()
104106 {
105- return (new SonyCameraConnection(context, provider, this));
107+ return (new SonyCameraConnection(context, provider, this, listener));
106108 }
107109
108110 @Override
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/wrapper/connection/SonyCameraConnectSequence.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/wrapper/connection/SonyCameraConnectSequence.java
@@ -10,6 +10,7 @@ import net.osdn.gokigen.a01d.camera.ICameraStatusReceiver;
1010 import net.osdn.gokigen.a01d.camera.sony.wrapper.ISonyCamera;
1111 import net.osdn.gokigen.a01d.camera.sony.wrapper.ISonyCameraHolder;
1212 import net.osdn.gokigen.a01d.camera.sony.wrapper.eventlistener.CameraChangeListerTemplate;
13+import net.osdn.gokigen.a01d.camera.sony.wrapper.eventlistener.ICameraChangeListener;
1314
1415
1516 /**
@@ -23,15 +24,17 @@ public class SonyCameraConnectSequence implements Runnable, SonySsdpClient.ISear
2324 private final ICameraConnection cameraConnection;
2425 private final ISonyCameraHolder cameraHolder;
2526 private final ICameraStatusReceiver cameraStatusReceiver;
27+ private final ICameraChangeListener listener;
2628 private final SonySsdpClient client;
2729
28- SonyCameraConnectSequence(Activity context, ICameraStatusReceiver statusReceiver, final ICameraConnection cameraConnection, final @NonNull ISonyCameraHolder cameraHolder)
30+ SonyCameraConnectSequence(Activity context, ICameraStatusReceiver statusReceiver, final ICameraConnection cameraConnection, final @NonNull ISonyCameraHolder cameraHolder, final @NonNull ICameraChangeListener listener)
2931 {
3032 Log.v(TAG, "SonyCameraConnectSequence");
3133 this.context = context;
3234 this.cameraConnection = cameraConnection;
3335 this.cameraStatusReceiver = statusReceiver;
3436 this.cameraHolder = cameraHolder;
37+ this.listener = listener;
3538 client = new SonySsdpClient(context, this, statusReceiver, 1);
3639 }
3740
@@ -78,7 +81,7 @@ public class SonyCameraConnectSequence implements Runnable, SonySsdpClient.ISear
7881 try
7982 {
8083 cameraHolder.prepare();
81- cameraHolder.startEventWatch(new CameraChangeListerTemplate());
84+ cameraHolder.startEventWatch(listener);
8285 }
8386 catch (Exception e)
8487 {
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/wrapper/connection/SonyCameraConnection.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/wrapper/connection/SonyCameraConnection.java
@@ -18,6 +18,7 @@ import net.osdn.gokigen.a01d.R;
1818 import net.osdn.gokigen.a01d.camera.ICameraConnection;
1919 import net.osdn.gokigen.a01d.camera.ICameraStatusReceiver;
2020 import net.osdn.gokigen.a01d.camera.sony.wrapper.ISonyCameraHolder;
21+import net.osdn.gokigen.a01d.camera.sony.wrapper.eventlistener.ICameraChangeListener;
2122
2223 import java.util.concurrent.Executor;
2324 import java.util.concurrent.Executors;
@@ -35,16 +36,18 @@ public class SonyCameraConnection implements ICameraConnection
3536 private final ISonyCameraHolder cameraHolder;
3637 //private final ConnectivityManager connectivityManager;
3738 private final Executor cameraExecutor = Executors.newFixedThreadPool(1);
39+ private final ICameraChangeListener listener;
3840 //private final Handler networkConnectionTimeoutHandler;
3941 //private static final int MESSAGE_CONNECTIVITY_TIMEOUT = 1;
4042 private CameraConnectionStatus connectionStatus = CameraConnectionStatus.UNKNOWN;
4143
42- public SonyCameraConnection(final Activity context, final ICameraStatusReceiver statusReceiver, @NonNull ISonyCameraHolder cameraHolder)
44+ public SonyCameraConnection(final Activity context, final ICameraStatusReceiver statusReceiver, @NonNull ISonyCameraHolder cameraHolder, final @NonNull ICameraChangeListener listener)
4345 {
4446 Log.v(TAG, "SonyCameraConnection()");
4547 this.context = context;
4648 this.statusReceiver = statusReceiver;
4749 this.cameraHolder = cameraHolder;
50+ this.listener = listener;
4851 /*
4952 ConnectivityManager connectivityManager = (ConnectivityManager) context.getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
5053 networkConnectionTimeoutHandler = new Handler()
@@ -264,7 +267,7 @@ public class SonyCameraConnection implements ICameraConnection
264267 connectionStatus = CameraConnectionStatus.CONNECTING;
265268 try
266269 {
267- cameraExecutor.execute(new SonyCameraConnectSequence(context,statusReceiver, this, cameraHolder));
270+ cameraExecutor.execute(new SonyCameraConnectSequence(context,statusReceiver, this, cameraHolder, listener));
268271 }
269272 catch (Exception e)
270273 {
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/wrapper/eventlistener/CameraChangeListerTemplate.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/wrapper/eventlistener/CameraChangeListerTemplate.java
@@ -51,6 +51,12 @@ public class CameraChangeListerTemplate implements ICameraChangeListener
5151 }
5252
5353 @Override
54+ public void onFocusStatusChanged(String focusStatus)
55+ {
56+ Log.v(TAG, "onFocusStatusChanged() : " + focusStatus);
57+ }
58+
59+ @Override
5460 public void onResponseError()
5561 {
5662 Log.v(TAG, "onResponseError() ");
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/wrapper/eventlistener/CameraEventObserver.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/wrapper/eventlistener/CameraEventObserver.java
@@ -22,7 +22,7 @@ public class CameraEventObserver implements ICameraEventObserver
2222
2323 private final ISonyCameraApi remoteApi;
2424 private final ReplyJsonParser replyParser;
25- private final String eventVersion = "1.0";
25+ private String eventVersion = "1.1"; // 初期値を "1.0" から "1.1" に更新
2626
2727 public static ICameraEventObserver newInstance(@NonNull Context context, @NonNull ISonyCameraApi apiClient)
2828 {
@@ -81,6 +81,12 @@ public class CameraEventObserver implements ICameraEventObserver
8181 break;
8282 case 1: // "Any" error
8383 case 12: // "No such method" error
84+ if (eventVersion.equals("1.1"))
85+ {
86+ // "1.1" でエラーが発生した時には "1.0" にダウングレードして再実行
87+ eventVersion = "1.0";
88+ continue MONITORLOOP;
89+ }
8490 replyParser.fireResponseErrorListener();
8591 break MONITORLOOP; // end monitoring.
8692
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/wrapper/eventlistener/ICameraChangeListener.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/wrapper/eventlistener/ICameraChangeListener.java
@@ -14,5 +14,6 @@ public interface ICameraChangeListener
1414 void onShootModeChanged(String shootMode);
1515 void onZoomPositionChanged(int zoomPosition);
1616 void onStorageIdChanged(String storageId);
17+ void onFocusStatusChanged(String focusStatus);
1718 void onResponseError();
1819 }
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/wrapper/eventlistener/ReplyJsonParser.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/wrapper/eventlistener/ReplyJsonParser.java
@@ -23,6 +23,7 @@ public class ReplyJsonParser implements ICameraStatusHolder
2323 private List<String> currentAvailableShootModes = Collections.unmodifiableList(new ArrayList<String>());
2424 private int currentZoomPosition;
2525 private String currentStorageId;
26+ private String currentFocusStatus;
2627
2728 ReplyJsonParser(final @NonNull Handler uiHandler)
2829 {
@@ -81,6 +82,13 @@ public class ReplyJsonParser implements ICameraStatusHolder
8182 fireStorageIdChangeListener(storageId);
8283 }
8384
85+ // focusStatus (v1.1)
86+ String focusStatus = findFocusStatus(replyJson);
87+ Log.d(TAG, "getEvent focusStatus:" + focusStatus);
88+ if (focusStatus != null && !focusStatus.equals(currentFocusStatus)) {
89+ currentFocusStatus = focusStatus;
90+ fireFocusStatusChangeListener(focusStatus);
91+ }
8492 }
8593
8694 void setEventChangeListener(ICameraChangeListener listener)
@@ -184,6 +192,17 @@ public class ReplyJsonParser implements ICameraStatusHolder
184192 });
185193 }
186194
195+ private void fireFocusStatusChangeListener(final String focusStatus) {
196+ uiHandler.post(new Runnable() {
197+ @Override
198+ public void run() {
199+ if (listener != null) {
200+ listener.onFocusStatusChanged(focusStatus);
201+ }
202+ }
203+ });
204+ }
205+
187206 private static List<String> findAvailableApiList(JSONObject replyJson) {
188207 List<String> availableApis = new ArrayList<>();
189208 int indexOfAvailableApiList = 0;
@@ -343,6 +362,26 @@ public class ReplyJsonParser implements ICameraStatusHolder
343362 return (storageId);
344363 }
345364
365+ private static String findFocusStatus(JSONObject replyJson)
366+ {
367+ String focusStatus = null;
368+ try {
369+ int indexOfFocusStatus= 35;
370+ JSONArray resultsObj = replyJson.getJSONArray("result");
371+ if (!resultsObj.isNull(indexOfFocusStatus)) {
372+ JSONObject focustatusObj = resultsObj.getJSONObject(indexOfFocusStatus);
373+ String type = focustatusObj.getString("type");
374+ if ("focusStatus".equals(type)) {
375+ focusStatus = focustatusObj.getString("focusStatus");
376+ } else {
377+ Log.w(TAG, "Event reply: Illegal Index (21: ShootMode) " + type);
378+ }
379+ }
380+ } catch (Exception e) {
381+ e.printStackTrace();
382+ }
383+ return (focusStatus);
384+ }
346385
347386 @Override
348387 public String getCameraStatus()
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/utils/SimpleHttpClient.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/utils/SimpleHttpClient.java
@@ -1,5 +1,8 @@
11 package net.osdn.gokigen.a01d.camera.utils;
22
3+import android.graphics.Bitmap;
4+import android.graphics.BitmapFactory;
5+import android.support.annotation.NonNull;
36 import android.util.Log;
47
58 import java.io.BufferedReader;
@@ -20,6 +23,7 @@ public class SimpleHttpClient
2023 {
2124 private static final String TAG = SimpleHttpClient.class.getSimpleName();
2225 private static final int DEFAULT_TIMEOUT = 10 * 1000; // [ms]
26+ private static final int BUFFER_SIZE = 131072 * 2; // 256kB
2327
2428 public SimpleHttpClient()
2529 {
@@ -123,8 +127,171 @@ public class SimpleHttpClient
123127 *
124128 *
125129 */
130+ public static void httpGetBytes(String url, int timeoutMs, @NonNull IReceivedMessageCallback callback)
131+ {
132+ HttpURLConnection httpConn = null;
133+ InputStream inputStream = null;
134+ int timeout = timeoutMs;
135+ if (timeoutMs < 0)
136+ {
137+ timeout = DEFAULT_TIMEOUT;
138+ }
139+
140+ // HTTP GETメソッドで要求を投げる
141+ try
142+ {
143+ final URL urlObj = new URL(url);
144+ httpConn = (HttpURLConnection) urlObj.openConnection();
145+ httpConn.setRequestMethod("GET");
146+ httpConn.setConnectTimeout(timeout);
147+ httpConn.setReadTimeout(timeout);
148+ httpConn.connect();
149+
150+ int responseCode = httpConn.getResponseCode();
151+ if (responseCode == HttpURLConnection.HTTP_OK)
152+ {
153+ inputStream = httpConn.getInputStream();
154+ }
155+ if (inputStream == null)
156+ {
157+ Log.w(TAG, "httpGet: Response Code Error: " + responseCode + ": " + url);
158+ callback.onErrorOccurred(new NullPointerException());
159+ callback.onCompleted();
160+ return;
161+ }
162+ }
163+ catch (Exception e)
164+ {
165+ Log.w(TAG, "httpGet: " + url + " " + e.getMessage());
166+ e.printStackTrace();
167+ if (httpConn != null)
168+ {
169+ httpConn.disconnect();
170+ }
171+ callback.onErrorOccurred(e);
172+ callback.onCompleted();
173+ return;
174+ }
175+
176+ // 応答を確認する
177+ try
178+ {
179+ int contentLength = httpConn.getContentLength();
180+ byte[] buffer = new byte[BUFFER_SIZE];
181+ int readBytes = 0;
182+ int readSize = inputStream.read(buffer, 0, BUFFER_SIZE);
183+ while (readSize != -1)
184+ {
185+ callback.onReceive(readBytes, contentLength, readSize, buffer);
186+ readBytes += readSize;
187+ readSize = inputStream.read(buffer, 0, BUFFER_SIZE);
188+ }
189+ Log.v(TAG, "RECEIVED " + readBytes + " BYTES. (contentLength : " + contentLength + ")");
190+ inputStream.close();
191+ }
192+ catch (Exception e)
193+ {
194+ Log.w(TAG, "httpGet: exception: " + e.getMessage());
195+ e.printStackTrace();
196+ callback.onErrorOccurred(e);
197+ }
198+ finally
199+ {
200+ try
201+ {
202+ inputStream.close();
203+ }
204+ catch (Exception e)
205+ {
206+ e.printStackTrace();
207+ }
208+ }
209+ callback.onCompleted();
210+ }
211+
212+ /**
213+ *
214+ *
215+ *
216+ */
217+ public static Bitmap httpGetBitmap(String url, int timeoutMs)
218+ {
219+ HttpURLConnection httpConn = null;
220+ InputStream inputStream = null;
221+ Bitmap bmp = null;
222+
223+ int timeout = timeoutMs;
224+ if (timeoutMs < 0)
225+ {
226+ timeout = DEFAULT_TIMEOUT;
227+ }
228+
229+ // HTTP GETメソッドで要求を投げる
230+ try
231+ {
232+ final URL urlObj = new URL(url);
233+ httpConn = (HttpURLConnection) urlObj.openConnection();
234+ httpConn.setRequestMethod("GET");
235+ httpConn.setConnectTimeout(timeout);
236+ httpConn.setReadTimeout(timeout);
237+ httpConn.connect();
238+
239+ int responseCode = httpConn.getResponseCode();
240+ if (responseCode == HttpURLConnection.HTTP_OK)
241+ {
242+ inputStream = httpConn.getInputStream();
243+ if (inputStream != null)
244+ {
245+ bmp = BitmapFactory.decodeStream(inputStream);
246+ }
247+ }
248+ if (inputStream == null)
249+ {
250+ Log.w(TAG, "httpGet: Response Code Error: " + responseCode + ": " + url);
251+ return (null);
252+ }
253+ inputStream.close();
254+ }
255+ catch (Exception e)
256+ {
257+ Log.w(TAG, "httpGet: " + url + " " + e.getMessage());
258+ e.printStackTrace();
259+ if (httpConn != null)
260+ {
261+ httpConn.disconnect();
262+ }
263+ return (null);
264+ }
265+ return (bmp);
266+ }
267+
268+ /**
269+ *
270+ *
271+ *
272+ */
126273 public static String httpPost(String url, String postData, int timeoutMs)
127274 {
275+ return (httpCommand(url, "POST", postData, timeoutMs));
276+ }
277+
278+ /**
279+ *
280+ *
281+ *
282+ */
283+ public static String httpPut(String url, String postData, int timeoutMs)
284+ {
285+ return (httpCommand(url, "PUT", postData, timeoutMs));
286+ }
287+
288+ /**
289+ *
290+ *
291+ *
292+ */
293+ private static String httpCommand(String url, String requestMethod, String postData, int timeoutMs)
294+ {
128295 HttpURLConnection httpConn = null;
129296 OutputStream outputStream = null;
130297 OutputStreamWriter writer = null;
@@ -136,12 +303,12 @@ public class SimpleHttpClient
136303 timeout = DEFAULT_TIMEOUT;
137304 }
138305
139- // HTTP Postメソッドで要求を送出
306+ // HTTP メソッドで要求を送出
140307 try
141308 {
142309 final URL urlObj = new URL(url);
143310 httpConn = (HttpURLConnection) urlObj.openConnection();
144- httpConn.setRequestMethod("POST");
311+ httpConn.setRequestMethod(requestMethod);
145312 httpConn.setConnectTimeout(timeout);
146313 httpConn.setReadTimeout(timeout);
147314 httpConn.setDoInput(true);
@@ -163,13 +330,13 @@ public class SimpleHttpClient
163330 }
164331 if (inputStream == null)
165332 {
166- Log.w(TAG, "httpPost: Response Code Error: " + responseCode + ": " + url);
333+ Log.w(TAG, "http " + requestMethod + " : Response Code Error: " + responseCode + ": " + url);
167334 return ("");
168335 }
169336 }
170337 catch (Exception e)
171338 {
172- Log.w(TAG, "httpPost: IOException: " + e.getMessage());
339+ Log.w(TAG, "http " + requestMethod + " : IOException: " + e.getMessage());
173340 e.printStackTrace();
174341 if (httpConn != null)
175342 {
@@ -238,4 +405,11 @@ public class SimpleHttpClient
238405 }
239406 return (replyString);
240407 }
408+
409+ public interface IReceivedMessageCallback
410+ {
411+ void onCompleted();
412+ void onErrorOccurred(Exception e);
413+ void onReceive(int readBytes, int length, int size, byte[] data);
414+ }
241415 }
--- a/app/src/main/java/net/osdn/gokigen/a01d/liveview/CameraLiveImageView.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/liveview/CameraLiveImageView.java
@@ -61,6 +61,7 @@ public class CameraLiveImageView extends View implements IImageDataReceiver, IAu
6161 private IPreviewImageConverter bitmapConverter = null;
6262 private IMessageHolder messageHolder;
6363 private IStoreImage storeImage = null;
64+ private IFocusLockIndicator focusLockIndicator = null;
6465
6566 public CameraLiveImageView(Context context)
6667 {
@@ -151,6 +152,10 @@ public class CameraLiveImageView extends View implements IImageDataReceiver, IAu
151152 return getIntrinsicContentSizeHeight();
152153 }
153154
155+ public void setFocuslockIndicator(IFocusLockIndicator focuslockIndicator)
156+ {
157+ focusLockIndicator = focuslockIndicator;
158+ }
154159
155160 private float getIntrinsicContentSizeWidth()
156161 {
@@ -996,7 +1001,11 @@ public class CameraLiveImageView extends View implements IImageDataReceiver, IAu
9961001 @Override
9971002 public void onAfLockUpdate(boolean isAfLocked)
9981003 {
999- //Log.v(TAG, "onAfLockUpdate() : " + isAfLocked);
1004+ Log.v(TAG, "onAfLockUpdate() : " + isAfLocked);
1005+ if (focusLockIndicator != null)
1006+ {
1007+ focusLockIndicator.updateFocusLockIndicator(isAfLocked, isAfLocked);
1008+ }
10001009 }
10011010
10021011 @Override
--- a/app/src/main/java/net/osdn/gokigen/a01d/liveview/ICameraStatusDisplay.java
+++ /dev/null
@@ -1,17 +0,0 @@
1-package net.osdn.gokigen.a01d.liveview;
2-
3-/**
4- *
5- */
6-public interface ICameraStatusDisplay
7-{
8- void updateTakeMode();
9- void updateDriveMode();
10- void updateWhiteBalance();
11- void updateBatteryLevel();
12- void updateAeMode();
13- void updateAeLockState();
14- void updateCameraStatus();
15- void updateCameraStatus(String message);
16- void updateLevelGauge(String orientation, float roll, float pitch);
17-}
--- /dev/null
+++ b/app/src/main/java/net/osdn/gokigen/a01d/liveview/ICameraStatusUpdateNotify.java
@@ -0,0 +1,24 @@
1+package net.osdn.gokigen.a01d.liveview;
2+
3+/**
4+ *
5+ */
6+public interface ICameraStatusUpdateNotify
7+{
8+ void updateDriveMode(String driveMode);
9+ void updateAeLockState(boolean isAeLocked);
10+ void updateCameraStatus(String message);
11+ void updateLevelGauge(String orientation, float roll, float pitch);
12+
13+ void updatedTakeMode(String mode);
14+ void updatedShutterSpeed(String tv);
15+ void updatedAperture(String av);
16+ void updatedExposureCompensation(String xv);
17+ void updatedMeteringMode(String meteringMode);
18+ void updatedWBMode(String wbMode);
19+ void updateRemainBattery(final int percentage);
20+ void updateFocusedStatus(boolean focused, boolean focusLocked);
21+ void updateIsoSensitivity(String sv);
22+ void updateWarning(String warning);
23+ void updateStorageStatus(String status);
24+}
--- /dev/null
+++ b/app/src/main/java/net/osdn/gokigen/a01d/liveview/IFocusLockIndicator.java
@@ -0,0 +1,6 @@
1+package net.osdn.gokigen.a01d.liveview;
2+
3+public interface IFocusLockIndicator
4+{
5+ void updateFocusLockIndicator(final boolean focused, final boolean focusLocked);
6+}
--- a/app/src/main/java/net/osdn/gokigen/a01d/liveview/IStatusViewDrawer.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/liveview/IStatusViewDrawer.java
@@ -9,4 +9,6 @@ public interface IStatusViewDrawer
99 void updateStatusView(String message);
1010 void updateLiveViewScale(boolean isChangeScale);
1111 void startLiveView();
12+
13+ boolean isFocusLocked();
1214 }
--- a/app/src/main/java/net/osdn/gokigen/a01d/liveview/LiveViewClickTouchListener.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/liveview/LiveViewClickTouchListener.java
@@ -256,9 +256,20 @@ class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchLi
256256 */
257257 private void actionFocusButton()
258258 {
259-
260-
261-
259+ try
260+ {
261+ // シャッターを半押しする
262+ if (focusingControl != null)
263+ {
264+ boolean isHalfPress = !statusViewDrawer.isFocusLocked();
265+ focusingControl.halfPressShutter(isHalfPress);
266+ Log.v(TAG, " actionFocusButton() : isHalfPress " + isHalfPress);
267+ }
268+ }
269+ catch (Exception e)
270+ {
271+ e.printStackTrace();
272+ }
262273 }
263274
264275 /**
--- a/app/src/main/java/net/osdn/gokigen/a01d/liveview/LiveViewFragment.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/liveview/LiveViewFragment.java
@@ -3,11 +3,14 @@ package net.osdn.gokigen.a01d.liveview;
33 import android.app.Activity;
44 import android.content.Context;
55 import android.content.SharedPreferences;
6+import android.graphics.Color;
7+import android.graphics.drawable.Drawable;
68 import android.os.Bundle;
79 import android.support.annotation.NonNull;
810 import android.support.v4.app.Fragment;
911 import android.support.v4.app.FragmentManager;
1012 import android.support.v4.content.res.ResourcesCompat;
13+import android.support.v4.graphics.drawable.DrawableCompat;
1114 import android.support.v7.preference.PreferenceManager;
1215 import android.util.Log;
1316 import android.view.LayoutInflater;
@@ -39,7 +42,7 @@ import net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor;
3942 * 撮影用ライブビュー画面
4043 *
4144 */
42-public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFocusingModeNotify, IFavoriteSettingDialogKicker
45+public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFocusingModeNotify, IFavoriteSettingDialogKicker, ICameraStatusUpdateNotify, IFocusLockIndicator
4346 {
4447 private final String TAG = this.toString();
4548 private static final int COMMAND_MY_PROPERTY = 0x00000100;
@@ -58,6 +61,7 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
5861 private CameraLiveImageView imageView = null;
5962
6063 private ImageView manualFocus = null;
64+ private ImageView focusIndicator = null;
6165 private ImageButton showGrid = null;
6266 private ImageButton connectStatus = null;
6367 private Button changeLiveViewScale = null;
@@ -65,6 +69,7 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
6569 private boolean imageViewCreated = false;
6670 private View myView = null;
6771 private String messageValue = "";
72+ private boolean focusLocked = false;
6873
6974 private ICameraConnection.CameraConnectionStatus currentConnectionStatus = ICameraConnection.CameraConnectionStatus.UNKNOWN;
7075
@@ -145,14 +150,19 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
145150 }
146151 imageView.setOnClickListener(onClickTouchListener);
147152 imageView.setOnTouchListener(onClickTouchListener);
153+ imageView.setFocuslockIndicator(this);
148154
149155 view.findViewById(R.id.show_preference_button).setOnClickListener(onClickTouchListener);
150156 view.findViewById(R.id.camera_property_settings_button).setOnClickListener(onClickTouchListener);
151157 view.findViewById(R.id.shutter_button).setOnClickListener(onClickTouchListener);
152158 view.findViewById(R.id.btn_zoomin).setOnClickListener(onClickTouchListener);
153159 view.findViewById(R.id.btn_zoomout).setOnClickListener(onClickTouchListener);
154- view.findViewById(R.id.focus_indicator).setOnClickListener(onClickTouchListener);
155160
161+ focusIndicator = view.findViewById(R.id.focus_indicator);
162+ if (focusIndicator != null)
163+ {
164+ focusIndicator.setOnClickListener(onClickTouchListener);
165+ }
156166 manualFocus = view.findViewById(R.id.focusing_button);
157167 changeLiveViewScale = view.findViewById(R.id.live_view_scale_button);
158168
@@ -161,6 +171,12 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
161171 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
162172 {
163173 view.findViewById(R.id.show_favorite_settings_button).setOnClickListener(onClickTouchListener);
174+
175+ // OPCのときには、フォーカスインジケータのマークを消す。
176+ if (focusIndicator != null)
177+ {
178+ focusIndicator.setVisibility(View.INVISIBLE);
179+ }
164180 }
165181 else
166182 {
@@ -189,13 +205,21 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
189205 {
190206 changeLiveViewScale.setVisibility(View.INVISIBLE);
191207 }
208+ if (focusIndicator != null)
209+ {
210+ focusIndicator.setVisibility(View.VISIBLE);
211+ }
192212 }
193- else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
213+ else if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
194214 {
195215 if (changeLiveViewScale != null)
196216 {
197217 changeLiveViewScale.setVisibility(View.VISIBLE);
198218 }
219+ if (focusIndicator != null)
220+ {
221+ focusIndicator.setVisibility(View.INVISIBLE);
222+ }
199223 }
200224 }
201225
@@ -273,6 +297,7 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
273297 this.zoomLensControl = interfaceProvider.getOlympusInterface().getZoomLensControl();
274298 this.cameraInformation = interfaceProvider.getOlympusInterface().getCameraInformation();
275299 }
300+ interfaceProvider.setUpdateReceiver(this);
276301 }
277302
278303 /**
@@ -602,6 +627,17 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
602627 }
603628 }
604629
630+
631+ /**
632+ * フォーカスロック中かどうか
633+ *
634+ */
635+ @Override
636+ public boolean isFocusLocked()
637+ {
638+ return (this.focusLocked);
639+ }
640+
605641 /**
606642 * 測光モードをスポットに切り替える
607643 *
@@ -654,4 +690,144 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
654690 }
655691 activity.runOnUiThread(action);
656692 }
693+
694+ @Override
695+ public void updateDriveMode(String driveMode)
696+ {
697+ Log.v(TAG, "updateDriveMode() : " + driveMode);
698+ }
699+
700+ @Override
701+ public void updateAeLockState(boolean isAeLocked)
702+ {
703+ Log.v(TAG, "updateAeLockState() : " + isAeLocked);
704+ }
705+
706+ @Override
707+ public void updateCameraStatus(String message)
708+ {
709+ Log.v(TAG, "updateCameraStatus() : " + message);
710+ }
711+
712+ @Override
713+ public void updateLevelGauge(String orientation, float roll, float pitch)
714+ {
715+ Log.v(TAG, "updateLevelGauge() : " + orientation + " roll : " + roll + " pitch : " + pitch);
716+ }
717+
718+ @Override
719+ public void updatedTakeMode(String mode)
720+ {
721+ Log.v(TAG, "updatedTakeMode() : " + mode);
722+ }
723+
724+ @Override
725+ public void updatedShutterSpeed(String tv)
726+ {
727+ Log.v(TAG, "updatedShutterSpeed() : " + tv);
728+ }
729+
730+ @Override
731+ public void updatedAperture(String av)
732+ {
733+ Log.v(TAG, "updatedAperture() : " + av);
734+ }
735+
736+ @Override
737+ public void updatedExposureCompensation(String xv)
738+ {
739+ Log.v(TAG, "updatedExposureCompensation() : " + xv);
740+ }
741+
742+ @Override
743+ public void updatedMeteringMode(String meteringMode)
744+ {
745+ Log.v(TAG, "updatedExposureCompensation() : " + meteringMode);
746+ }
747+
748+ @Override
749+ public void updatedWBMode(String wbMode)
750+ {
751+ Log.v(TAG, "updatedWBMode() : " + wbMode);
752+ }
753+
754+ @Override
755+ public void updateRemainBattery(int percentage)
756+ {
757+ Log.v(TAG, "updateRemainBattery() : " + percentage);
758+ }
759+
760+ @Override
761+ public void updateFocusedStatus(final boolean focused, final boolean focusLocked)
762+ {
763+ Log.v(TAG, "updateFocusedStatus() : f: " + focused + " fl: " + focusLocked);
764+ this.focusLocked = focusLocked;
765+ Activity activity = getActivity();
766+ if ((activity == null)||(focusIndicator == null)|| (focusIndicator.getVisibility() != View.VISIBLE))
767+ {
768+ Log.v(TAG, "updateFocusedStatus() : INVISIBLE");
769+ return;
770+ }
771+
772+ try
773+ {
774+ activity.runOnUiThread(new Runnable() {
775+ @Override
776+ public void run() {
777+ if (focused)
778+ {
779+ Drawable icon = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_center_focus_strong_black_24dp, null);
780+ if (icon != null)
781+ {
782+ DrawableCompat.setTint(icon, Color.GREEN);
783+ focusIndicator.setImageDrawable(icon);
784+ }
785+ }
786+ else
787+ {
788+ Drawable icon = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_crop_free_black_24dp, null);
789+ if (icon != null)
790+ {
791+ int color = Color.BLACK;
792+ if (focusLocked)
793+ {
794+ color = Color.RED;
795+ }
796+ DrawableCompat.setTint(icon, color);
797+ focusIndicator.setImageDrawable(icon);
798+ }
799+ }
800+ focusIndicator.invalidate();
801+ }
802+ });
803+ }
804+ catch (Exception e)
805+ {
806+ e.printStackTrace();
807+ }
808+ }
809+
810+ @Override
811+ public void updateIsoSensitivity(String sv)
812+ {
813+ Log.v(TAG, "updateIsoSensitivity() : " + sv);
814+ }
815+
816+ @Override
817+ public void updateWarning(String warning)
818+ {
819+ Log.v(TAG, "updateWarning() : " + warning);
820+ }
821+
822+ @Override
823+ public void updateStorageStatus(String status)
824+ {
825+ Log.v(TAG, "updateStorageStatus() : " + status);
826+ }
827+
828+ @Override
829+ public void updateFocusLockIndicator(final boolean focused, final boolean focusLocked)
830+ {
831+ updateFocusedStatus(focused, focusLocked);
832+ }
657833 }
Afficher sur ancien navigateur de dépôt.