• R/O
  • HTTP
  • SSH
  • HTTPS

A01d: Commit

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


Commit MetaInfo

Révision6bb3cf7c73aa9f1ad35eed444e80aab1c1072ee6 (tree)
l'heure2018-10-05 00:05:11
AuteurMRSa <mrsa@myad...>
CommiterMRSa

Message de Log

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

Change Summary

Modification

--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/IFocusingControl.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/IFocusingControl.java
@@ -10,4 +10,5 @@ public interface IFocusingControl
1010 {
1111 boolean driveAutoFocus(MotionEvent motionEvent);
1212 void unlockAutoFocus();
13+ void halfPressShutter(boolean isPressed);
1314 }
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/olympus/wrapper/OlyCameraFocusControl.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/olympus/wrapper/OlyCameraFocusControl.java
@@ -69,4 +69,39 @@ public class OlyCameraFocusControl implements IFocusingControl
6969 }
7070 }
7171
72+ @Override
73+ public void halfPressShutter(boolean isPressed)
74+ {
75+ if (isPressed)
76+ {
77+ // 中心にフォーカスを合わせる
78+ if (frameDisplay != null)
79+ {
80+ Thread thread = new Thread(new Runnable() {
81+ @Override
82+ public void run() {
83+ PointF point = new PointF(0.5f, 0.5f);
84+ if (frameDisplay.isContainsPoint(point))
85+ {
86+ afControl.lockAutoFocus(point);
87+ }
88+ }
89+ });
90+ try
91+ {
92+ thread.start();
93+ }
94+ catch (Exception e)
95+ {
96+ e.printStackTrace();
97+ }
98+ }
99+ }
100+ else
101+ {
102+ // フォーカスを解除する
103+ unlockAutoFocus();
104+ }
105+ }
106+
72107 }
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/ricohgr2/operation/RicohGr2CameraFocusControl.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/ricohgr2/operation/RicohGr2CameraFocusControl.java
@@ -50,4 +50,10 @@ public class RicohGr2CameraFocusControl implements IFocusingControl
5050 {
5151 afControl.unlockAutoFocus();
5252 }
53+
54+ @Override
55+ public void halfPressShutter(boolean isPressed)
56+ {
57+ afControl.halfPressShutter(isPressed);
58+ }
5359 }
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/ricohgr2/operation/takepicture/RicohGr2AutoFocusControl.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/ricohgr2/operation/takepicture/RicohGr2AutoFocusControl.java
@@ -5,7 +5,6 @@ import android.graphics.RectF;
55 import android.support.annotation.NonNull;
66 import android.util.Log;
77
8-import net.osdn.gokigen.a01d.camera.sony.operation.takepicture.SonyAutoFocusControl;
98 import net.osdn.gokigen.a01d.camera.utils.SimpleHttpClient;
109 import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
1110 import net.osdn.gokigen.a01d.liveview.IIndicatorControl;
@@ -17,8 +16,9 @@ public class RicohGr2AutoFocusControl
1716 private static final String TAG = RicohGr2AutoFocusControl.class.getSimpleName();
1817 private final IIndicatorControl indicator;
1918 private final IAutoFocusFrameDisplay frameDisplayer;
20- private String lockAutoFocusUrl = "http://192.168.0.1/v1/lens/focus/lock";
19+ private String lockAutoFocusUrl = "http://192.168.0.1/v1/lens/focus/lock"; // Pentax機の場合は /v1/lens/focus
2120 private String unlockAutoFocusUrl = "http://192.168.0.1/v1/lens/focus/unlock";
21+ private String halfPressShutterUrl = "http://192.168.0.1/_gr";
2222 private int timeoutMs = 6000;
2323
2424
@@ -132,6 +132,43 @@ public class RicohGr2AutoFocusControl
132132 *
133133 *
134134 */
135+ public void halfPressShutter(final boolean isPressed)
136+ {
137+ Log.v(TAG, "halfPressShutter() " + isPressed);
138+ try
139+ {
140+ Thread thread = new Thread(new Runnable()
141+ {
142+ @Override
143+ public void run()
144+ {
145+ try
146+ {
147+ String postData = (isPressed) ? "cmd=baf 1" : "cmd=baf 0";
148+ String result = SimpleHttpClient.httpPost(halfPressShutterUrl, postData, timeoutMs);
149+ if ((result == null)||(result.length() < 1))
150+ {
151+ Log.v(TAG, "halfPressShutter() [" + isPressed + "] reply is null.");
152+ }
153+ }
154+ catch (Exception e)
155+ {
156+ e.printStackTrace();
157+ }
158+ }
159+ });
160+ thread.start();
161+ }
162+ catch (Exception e)
163+ {
164+ e.printStackTrace();
165+ }
166+ }
167+
168+ /**
169+ *
170+ *
171+ */
135172 private void showFocusFrame(RectF rect, IAutoFocusFrameDisplay.FocusFrameStatus status, double duration)
136173 {
137174 frameDisplayer.showFocusFrame(rect, status, duration);
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/operation/SonyCameraFocusControl.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/operation/SonyCameraFocusControl.java
@@ -65,4 +65,18 @@ public class SonyCameraFocusControl implements IFocusingControl
6565 e.printStackTrace();
6666 }
6767 }
68+
69+ @Override
70+ public void halfPressShutter(boolean isPressed)
71+ {
72+ Log.v(TAG, "halfPressShutter() " + isPressed);
73+ try
74+ {
75+ afControl.halfPressShutter(isPressed);
76+ }
77+ catch (Exception e)
78+ {
79+ e.printStackTrace();
80+ }
81+ }
6882 }
--- 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
@@ -111,6 +111,47 @@ public class SonyAutoFocusControl
111111 }
112112
113113 /**
114+ * シャッター半押し処理
115+ *
116+ */
117+ public void halfPressShutter(final boolean isPressed)
118+ {
119+ Log.v(TAG, "halfPressShutter() : " + isPressed);
120+ if (cameraApi == null)
121+ {
122+ Log.v(TAG, "ISonyCameraApi is null...");
123+ return;
124+ }
125+ try
126+ {
127+ Thread thread = new Thread(new Runnable()
128+ {
129+ @Override
130+ public void run()
131+ {
132+ try
133+ {
134+ JSONObject resultsObj = (isPressed) ? cameraApi.actHalfPressShutter() : cameraApi.cancelHalfPressShutter();
135+ if (resultsObj == null)
136+ {
137+ Log.v(TAG, "lockAutoFocus() [" + isPressed + "] reply is null.");
138+ }
139+ }
140+ catch (Exception e)
141+ {
142+ e.printStackTrace();
143+ }
144+ }
145+ });
146+ thread.start();
147+ }
148+ catch (Exception e)
149+ {
150+ e.printStackTrace();
151+ }
152+ }
153+
154+ /**
114155 *
115156 *
116157 */
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/wrapper/ISonyCameraApi.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/wrapper/ISonyCameraApi.java
@@ -21,6 +21,9 @@ public interface ISonyCameraApi
2121 JSONObject getTouchAFPosition();
2222 JSONObject cancelTouchAFPosition();
2323
24+ JSONObject actHalfPressShutter();
25+ JSONObject cancelHalfPressShutter();
26+
2427 JSONObject setFocusMode(String focusMode);
2528 JSONObject getFocusMode();
2629 JSONObject getSupportedFocusMode();
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/wrapper/SonyCameraApi.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/wrapper/SonyCameraApi.java
@@ -209,6 +209,34 @@ class SonyCameraApi implements ISonyCameraApi
209209 }
210210
211211 @Override
212+ public JSONObject actHalfPressShutter()
213+ {
214+ try
215+ {
216+ return (communicateJSON("camera", "actHalfPressShutter", new JSONArray(), "1.0", -1));
217+ }
218+ catch (Exception e)
219+ {
220+ e.printStackTrace();
221+ }
222+ return (new JSONObject());
223+ }
224+
225+ @Override
226+ public JSONObject cancelHalfPressShutter()
227+ {
228+ try
229+ {
230+ return (communicateJSON("camera", "cancelHalfPressShutter", new JSONArray(), "1.0", -1));
231+ }
232+ catch (Exception e)
233+ {
234+ e.printStackTrace();
235+ }
236+ return (new JSONObject());
237+ }
238+
239+ @Override
212240 public JSONObject setFocusMode(String focusMode)
213241 {
214242 try
--- a/app/src/main/java/net/osdn/gokigen/a01d/liveview/LiveViewClickTouchListener.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/liveview/LiveViewClickTouchListener.java
@@ -143,6 +143,11 @@ class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchLi
143143 actionZoomout();
144144 break;
145145
146+ case R.id.focus_indicator:
147+ // フォーカスインジケータをクリックした
148+ actionFocusButton();
149+ break;
150+
146151 default:
147152 Log.v(TAG, "onClick() : " + id);
148153 break;
@@ -246,6 +251,17 @@ class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchLi
246251 }
247252
248253 /**
254+ * フォーカスボタンが押されたとき...
255+ *
256+ */
257+ private void actionFocusButton()
258+ {
259+
260+
261+
262+ }
263+
264+ /**
249265 * お気に入り設定ダイアログの表示
250266 *
251267 */
--- a/app/src/main/java/net/osdn/gokigen/a01d/liveview/LiveViewFragment.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/liveview/LiveViewFragment.java
@@ -151,6 +151,7 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
151151 view.findViewById(R.id.shutter_button).setOnClickListener(onClickTouchListener);
152152 view.findViewById(R.id.btn_zoomin).setOnClickListener(onClickTouchListener);
153153 view.findViewById(R.id.btn_zoomout).setOnClickListener(onClickTouchListener);
154+ view.findViewById(R.id.focus_indicator).setOnClickListener(onClickTouchListener);
154155
155156 manualFocus = view.findViewById(R.id.focusing_button);
156157 changeLiveViewScale = view.findViewById(R.id.live_view_scale_button);
--- /dev/null
+++ b/app/src/main/res/drawable/ic_center_focus_strong_black_24dp.xml
@@ -0,0 +1,9 @@
1+<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+ android:width="24dp"
3+ android:height="24dp"
4+ android:viewportWidth="24.0"
5+ android:viewportHeight="24.0">
6+ <path
7+ android:fillColor="#FF000000"
8+ android:pathData="M12,8c-2.21,0 -4,1.79 -4,4s1.79,4 4,4 4,-1.79 4,-4 -1.79,-4 -4,-4zM5,15L3,15v4c0,1.1 0.9,2 2,2h4v-2L5,19v-4zM5,5h4L9,3L5,3c-1.1,0 -2,0.9 -2,2v4h2L5,5zM19,3h-4v2h4v4h2L21,5c0,-1.1 -0.9,-2 -2,-2zM19,19h-4v2h4c1.1,0 2,-0.9 2,-2v-4h-2v4z"/>
9+</vector>
--- /dev/null
+++ b/app/src/main/res/drawable/ic_crop_free_black_24dp.xml
@@ -0,0 +1,9 @@
1+<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+ android:width="24dp"
3+ android:height="24dp"
4+ android:viewportWidth="24.0"
5+ android:viewportHeight="24.0">
6+ <path
7+ android:fillColor="#FF000000"
8+ android:pathData="M3,5v4h2L5,5h4L9,3L5,3c-1.1,0 -2,0.9 -2,2zM5,15L3,15v4c0,1.1 0.9,2 2,2h4v-2L5,19v-4zM19,19h-4v2h4c1.1,0 2,-0.9 2,-2v-4h-2v4zM19,3h-4v2h4v4h2L21,5c0,-1.1 -0.9,-2 -2,-2z"/>
9+</vector>
--- a/app/src/main/res/layout-land/fragment_live_view.xml
+++ b/app/src/main/res/layout-land/fragment_live_view.xml
@@ -123,13 +123,31 @@
123123 android:visibility="visible"
124124 />
125125
126+ <ImageView
127+ android:id="@+id/focus_indicator"
128+ android:layout_width="wrap_content"
129+ android:layout_height="wrap_content"
130+ android:layout_alignLeft="@id/live_view_scale_button"
131+ android:layout_alignStart="@id/live_view_scale_button"
132+ android:layout_marginStart="8pt"
133+ android:layout_marginLeft="8pt"
134+ android:layout_marginBottom="3pt"
135+ android:layout_above="@id/live_view_scale_button"
136+ android:clickable="true"
137+ android:contentDescription="@string/button"
138+ android:focusable="true"
139+ android:gravity="center"
140+ android:scaleType="fitCenter"
141+ android:src="@drawable/ic_crop_free_black_24dp"
142+ android:visibility="visible" />
143+
126144 <TextView
127145 android:id="@+id/focal_length_with_digital_zoom_view"
128146 android:layout_width="match_parent"
129147 android:layout_height="wrap_content"
130148 android:layout_marginRight="2pt"
131149 android:layout_marginEnd="2pt"
132- android:layout_above="@id/live_view_scale_button"
150+ android:layout_above="@id/focus_indicator"
133151 android:layout_alignLeft="@id/live_view_scale_button"
134152 android:layout_alignStart="@id/live_view_scale_button"
135153 android:layout_marginLeft="4pt"
--- a/app/src/main/res/layout/fragment_live_view.xml
+++ b/app/src/main/res/layout/fragment_live_view.xml
@@ -51,10 +51,10 @@
5151 <ImageView
5252 android:id="@+id/focusing_button"
5353 android:layout_width="wrap_content"
54- android:layout_height="match_parent"
54+ android:layout_height="wrap_content"
5555 android:layout_alignParentLeft="true"
5656 android:layout_alignParentStart="true"
57- android:layout_alignParentTop="true"
57+ android:layout_alignParentBottom="true"
5858 android:layout_marginLeft="2pt"
5959 android:layout_marginStart="2pt"
6060 android:clickable="true"
@@ -144,6 +144,23 @@
144144 android:visibility="visible"
145145 android:src="@drawable/ic_zoom_in_black_24dp" />
146146
147+ <ImageView
148+ android:id="@+id/focus_indicator"
149+ android:layout_width="wrap_content"
150+ android:layout_height="wrap_content"
151+ android:layout_alignTop="@id/live_view_scale_button"
152+ android:layout_alignParentStart="true"
153+ android:layout_alignParentLeft="true"
154+ android:layout_marginStart="4pt"
155+ android:layout_marginLeft="4pt"
156+ android:clickable="true"
157+ android:contentDescription="@string/button"
158+ android:focusable="true"
159+ android:gravity="center"
160+ android:scaleType="fitEnd"
161+ android:src="@drawable/ic_crop_free_black_24dp"
162+ android:visibility="visible" />
163+
147164 </RelativeLayout>
148165
149166 <RelativeLayout
Afficher sur ancien navigateur de dépôt.