• R/O
  • HTTP
  • SSH
  • HTTPS

Gr2Control: コミット

Ricoh GR2 Control App for Android.


コミットメタ情報

リビジョン4eb7a863ade3713d8dd6af0a263aab6bc162019b (tree)
日時2020-05-09 22:20:45
作者MRSa <mrsa@myad...>
コミッターMRSa

ログメッセージ

FUJIFILM機のビデオ撮影機能を追加。

変更サマリ

差分

--- a/app/src/main/java/net/osdn/gokigen/gr2control/camera/fuji_x/wrapper/command/IFujiXMessages.java
+++ b/app/src/main/java/net/osdn/gokigen/gr2control/camera/fuji_x/wrapper/command/IFujiXMessages.java
@@ -42,4 +42,7 @@ public interface IFujiXMessages
4242 int SEQ_IMAGE_INFO = 104;
4343 int SEQ_THUMBNAIL = 105;
4444 int SEQ_FULL_IMAGE = 106;
45+
46+ int SEQ_START_MOVIE = 107;
47+ int SEQ_FINISH_MOVIE = 108;
4548 }
--- /dev/null
+++ b/app/src/main/java/net/osdn/gokigen/gr2control/camera/fuji_x/wrapper/command/messages/FinishRecordingMovie.java
@@ -0,0 +1,55 @@
1+package net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.command.messages;
2+
3+import androidx.annotation.NonNull;
4+
5+import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.command.IFujiXCommandCallback;
6+import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.command.IFujiXMessages;
7+
8+public class FinishRecordingMovie extends FujiXCommandBase
9+{
10+ private final IFujiXCommandCallback callback;
11+ private final byte data0;
12+ private final byte data1;
13+ private final byte data2;
14+ private final byte data3;
15+
16+ public FinishRecordingMovie(@NonNull IFujiXCommandCallback callback, int startSequenceNumber)
17+ {
18+ this.callback = callback;
19+
20+ data0 = ((byte) (0x000000ff & startSequenceNumber));
21+ data1 = ((byte)((0x0000ff00 & startSequenceNumber) >> 8));
22+ data2 = ((byte)((0x00ff0000 & startSequenceNumber) >> 16));
23+ data3 = ((byte)((0xff000000 & startSequenceNumber) >> 24));
24+ }
25+
26+ @Override
27+ public IFujiXCommandCallback responseCallback()
28+ {
29+ return (callback);
30+ }
31+
32+ @Override
33+ public int getId()
34+ {
35+ return (IFujiXMessages.SEQ_FINISH_MOVIE);
36+ }
37+
38+ @Override
39+ public byte[] commandBody()
40+ {
41+ return (new byte[] {
42+ // message_header.index : uint16 (0: terminate, 2: two_part_message, 1: other)
43+ (byte)0x01, (byte)0x00,
44+
45+ // message_header.type : stop_recording_movie (0x9021)
46+ (byte)0x21, (byte)0x90,
47+
48+ // sequence number
49+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
50+
51+ // data...
52+ data0, data1, data2, data3,
53+ });
54+ }
55+}
--- /dev/null
+++ b/app/src/main/java/net/osdn/gokigen/gr2control/camera/fuji_x/wrapper/command/messages/StartRecordingMovie.java
@@ -0,0 +1,48 @@
1+package net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.command.messages;
2+
3+import androidx.annotation.NonNull;
4+
5+import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.command.IFujiXCommandCallback;
6+import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.command.IFujiXMessages;
7+
8+public class StartRecordingMovie extends FujiXCommandBase
9+{
10+ private final IFujiXCommandCallback callback;
11+
12+ public StartRecordingMovie(@NonNull IFujiXCommandCallback callback)
13+ {
14+ this.callback = callback;
15+ }
16+
17+ @Override
18+ public IFujiXCommandCallback responseCallback()
19+ {
20+ return (callback);
21+ }
22+
23+ @Override
24+ public int getId()
25+ {
26+ return (IFujiXMessages.SEQ_START_MOVIE);
27+ }
28+
29+ @Override
30+ public byte[] commandBody()
31+ {
32+ return (new byte[] {
33+ // message_header.index : uint16 (0: terminate, 2: two_part_message, 1: other)
34+ (byte)0x01, (byte)0x00,
35+
36+ // message_header.type : start_movie_recording (0x9020)
37+ (byte)0x20, (byte)0x90,
38+
39+ // sequence number
40+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
41+
42+ // data
43+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
44+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
45+
46+ });
47+ }
48+}
--- a/app/src/main/java/net/osdn/gokigen/gr2control/liveview/LiveViewFragment.java
+++ b/app/src/main/java/net/osdn/gokigen/gr2control/liveview/LiveViewFragment.java
@@ -236,6 +236,7 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
236236 setFujiXKeyPanelClickListener(view, R.id.button_fuji_x_xv_plus);
237237 setFujiXKeyPanelClickListener(view, R.id.button_fuji_x_flash);
238238 setFujiXKeyPanelClickListener(view, R.id.button_fuji_x_timer);
239+ setFujiXKeyPanelClickListener(view, R.id.button_fuji_x_video_on_off);
239240
240241 connectStatus = view.findViewById(R.id.connect_disconnect_button);
241242 if (connectStatus != null)
--- a/app/src/main/java/net/osdn/gokigen/gr2control/liveview/LiveViewFujiXKeyPanelClickListener.java
+++ b/app/src/main/java/net/osdn/gokigen/gr2control/liveview/LiveViewFujiXKeyPanelClickListener.java
@@ -4,10 +4,12 @@ import android.content.DialogInterface;
44 import android.os.Vibrator;
55 import android.util.Log;
66 import android.view.View;
7+import android.widget.ImageView;
78
89 import androidx.annotation.NonNull;
910 import androidx.annotation.Nullable;
1011 import androidx.appcompat.app.AlertDialog;
12+import androidx.core.content.ContextCompat;
1113 import androidx.fragment.app.FragmentActivity;
1214
1315 import net.osdn.gokigen.gr2control.R;
@@ -16,7 +18,9 @@ import net.osdn.gokigen.gr2control.camera.IInterfaceProvider;
1618 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.command.IFujiXCommandCallback;
1719 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.command.IFujiXCommandPublisher;
1820 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.command.messages.CommandGeneric;
21+import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.command.messages.FinishRecordingMovie;
1922 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.command.messages.IFujiXCameraCommands;
23+import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.command.messages.StartRecordingMovie;
2024 import net.osdn.gokigen.gr2control.camera.utils.SimpleLogDumper;
2125
2226 import java.util.List;
@@ -28,6 +32,9 @@ public class LiveViewFujiXKeyPanelClickListener implements View.OnClickListener,
2832 private static final boolean isDumpLog = false;
2933 private final IInterfaceProvider interfaceProvider;
3034 private final Vibrator vibrator;
35+ private boolean isRecordingVideoMovie = false;
36+ private boolean commandIssued = false;
37+ private int startMovieSequenceNumber = 0;
3138
3239 LiveViewFujiXKeyPanelClickListener(@NonNull FragmentActivity activity, @NonNull IInterfaceProvider interfaceProvider, @Nullable Vibrator vibrator)
3340 {
@@ -71,7 +78,9 @@ public class LiveViewFujiXKeyPanelClickListener implements View.OnClickListener,
7178 updateSelection(ICameraStatus.SELF_TIMER);
7279 isVibrate = false;
7380 break;
74-
81+ case R.id.button_fuji_x_video_on_off:
82+ startFinishMovie();
83+ break;
7584 default:
7685 isVibrate = false;
7786 break;
@@ -196,6 +205,120 @@ public class LiveViewFujiXKeyPanelClickListener implements View.OnClickListener,
196205 }
197206
198207 /**
208+ * ビデオ撮影開始と終了
209+ *
210+ */
211+ private void startFinishMovie()
212+ {
213+ try
214+ {
215+ if (commandIssued)
216+ {
217+ // すでにコマンド発行中。コマンドの発行は抑止する
218+ Log.v(TAG, " COMMAND IS ALREADY ISSUED...");
219+ return;
220+ }
221+ commandIssued = true;
222+
223+ IFujiXCommandPublisher publisher = interfaceProvider.getFujiXInterfaceProvider().getCommandPublisher();
224+ if (isRecordingVideoMovie)
225+ {
226+ // 撮影中の場合には、撮影を止める
227+ publisher.enqueueCommand(new FinishRecordingMovie(new IFujiXCommandCallback() {
228+ @Override
229+ public void receivedMessage(int id, byte[] rx_body)
230+ {
231+ commandIssued = false;
232+ isRecordingVideoMovie = false;
233+ updateMovieRecordingIcon();
234+ SimpleLogDumper.dump_bytes(" STOP MOVIE REPLY (" + startMovieSequenceNumber + ") ", rx_body);
235+ startMovieSequenceNumber = 0;
236+ }
237+
238+ @Override
239+ public void onReceiveProgress(int currentBytes, int totalBytes, byte[] rx_body)
240+ {
241+ // 何もしない
242+ }
243+
244+ @Override
245+ public boolean isReceiveMulti()
246+ {
247+ return (false);
248+ }
249+ }, startMovieSequenceNumber));
250+ }
251+ else
252+ {
253+ // 撮影を開始する
254+ publisher.enqueueCommand(new StartRecordingMovie(new IFujiXCommandCallback() {
255+ @Override
256+ public void receivedMessage(int id, byte[] rx_body)
257+ {
258+ commandIssued = false;
259+ if ((rx_body[7] == (byte) 0x20)&&(rx_body[6] == (byte) 0x01))
260+ {
261+ // 応答コード OKの場合... SequenceNumberを記憶する
262+ startMovieSequenceNumber = ((((int) rx_body[11]) & 0xff) << 24) + ((((int) rx_body[10]) & 0xff) << 16) + ((((int) rx_body[9]) & 0xff) << 8) + (((int) rx_body[8]) & 0xff);
263+ isRecordingVideoMovie = true;
264+ }
265+ updateMovieRecordingIcon();
266+ SimpleLogDumper.dump_bytes(" START MOVIE REPLY (" + startMovieSequenceNumber + ") ", rx_body);
267+ }
268+
269+ @Override
270+ public void onReceiveProgress(int currentBytes, int totalBytes, byte[] rx_body)
271+ {
272+ // 何もしない
273+ }
274+
275+ @Override
276+ public boolean isReceiveMulti()
277+ {
278+ return (false);
279+ }
280+ }));
281+ }
282+ }
283+ catch (Exception e)
284+ {
285+ e.printStackTrace();
286+ commandIssued = false;
287+ }
288+ }
289+
290+ private void updateMovieRecordingIcon()
291+ {
292+ try
293+ {
294+ activity.runOnUiThread(new Runnable() {
295+ @Override
296+ public void run() {
297+ ImageView imageView = activity.findViewById(R.id.button_fuji_x_video_on_off);
298+ if (isRecordingVideoMovie)
299+ {
300+ //imageView.setImageDrawable(ContextCompat.getDrawable(activity,R.drawable.ic_videocam_off_black_24dp));
301+ imageView.setImageDrawable(ContextCompat.getDrawable(activity,R.drawable.ic_stop_black_24dp));
302+ }
303+ else
304+ {
305+ imageView.setImageDrawable(ContextCompat.getDrawable(activity,R.drawable.ic_videocam_black__24dp));
306+ }
307+ imageView.invalidate();
308+ }
309+ });
310+ }
311+ catch (Exception e)
312+ {
313+ e.printStackTrace();
314+ }
315+ }
316+
317+
318+
319+
320+
321+ /**
199322 * ぶるぶるさせる
200323 *
201324 */
--- /dev/null
+++ b/app/src/main/res/drawable/ic_stop_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="M6,6h12v12H6z"/>
9+</vector>
--- /dev/null
+++ b/app/src/main/res/drawable/ic_videocam_black__24dp.xml
@@ -0,0 +1,5 @@
1+<vector android:height="24dp" android:tint="#121212"
2+ android:viewportHeight="24.0" android:viewportWidth="24.0"
3+ android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
4+ <path android:fillColor="#FF000000" android:pathData="M17,10.5V7c0,-0.55 -0.45,-1 -1,-1H4c-0.55,0 -1,0.45 -1,1v10c0,0.55 0.45,1 1,1h12c0.55,0 1,-0.45 1,-1v-3.5l4,4v-11l-4,4z"/>
5+</vector>
--- /dev/null
+++ b/app/src/main/res/drawable/ic_videocam_off_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="M21,6.5l-4,4V7c0,-0.55 -0.45,-1 -1,-1H9.82L21,17.18V6.5zM3.27,2L2,3.27 4.73,6H4c-0.55,0 -1,0.45 -1,1v10c0,0.55 0.45,1 1,1h12c0.21,0 0.39,-0.08 0.54,-0.18L19.73,21 21,19.73 3.27,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
@@ -520,17 +520,17 @@
520520 android:gravity="center" />
521521
522522 <ImageView
523- android:id="@+id/button_fuji_x_dummy"
524- android:layout_width="34pt"
525- android:layout_height="9pt"
526- android:layout_below="@id/label_fuji_x_xv_center"
527- android:layout_alignLeft="@id/label_fuji_x_xv_center"
528- android:layout_alignStart="@id/label_fuji_x_xv_center"
523+ android:id="@+id/button_fuji_x_video_on_off"
524+ android:layout_width="20pt"
525+ android:layout_height="14pt"
526+ android:layout_below="@id/button_fuji_x_xv_minus"
527+ android:layout_alignLeft="@id/button_fuji_x_xv_minus"
528+ android:layout_alignStart="@id/button_fuji_x_xv_minus"
529529 android:scaleType="fitCenter"
530- android:visibility="invisible"
530+ android:visibility="visible"
531531 android:clickable="true"
532532 android:focusable="true"
533- android:src="@drawable/ic_camera_roll_black_24dp"
533+ android:src="@drawable/ic_videocam_black__24dp"
534534 android:layout_marginTop="6pt"
535535 android:gravity="center" />
536536
@@ -538,7 +538,7 @@
538538 android:id="@+id/button_fuji_x_flash"
539539 android:layout_width="20pt"
540540 android:layout_height="14pt"
541- android:layout_below="@id/button_fuji_x_dummy"
541+ android:layout_below="@id/button_fuji_x_video_on_off"
542542 android:layout_alignLeft="@id/button_fuji_x_tv_minus"
543543 android:layout_alignStart="@id/button_fuji_x_tv_minus"
544544 android:scaleType="fitCenter"
@@ -553,9 +553,9 @@
553553 android:id="@+id/button_fuji_x_timer"
554554 android:layout_width="34pt"
555555 android:layout_height="14pt"
556- android:layout_below="@id/button_fuji_x_dummy"
557- android:layout_alignLeft="@id/button_fuji_x_dummy"
558- android:layout_alignStart="@id/button_fuji_x_dummy"
556+ android:layout_below="@id/button_fuji_x_video_on_off"
557+ android:layout_alignLeft="@id/label_fuji_x_xv_center"
558+ android:layout_alignStart="@id/label_fuji_x_xv_center"
559559 android:scaleType="fitCenter"
560560 android:visibility="visible"
561561 android:clickable="true"
--- a/app/src/main/res/layout/fragment_live_view.xml
+++ b/app/src/main/res/layout/fragment_live_view.xml
@@ -613,17 +613,17 @@
613613 android:gravity="center" />
614614
615615 <ImageView
616- android:id="@+id/button_fuji_x_dummy"
617- android:layout_width="34pt"
618- android:layout_height="9pt"
619- android:layout_below="@id/label_fuji_x_xv_center"
620- android:layout_alignLeft="@id/label_fuji_x_xv_center"
621- android:layout_alignStart="@id/label_fuji_x_xv_center"
616+ android:id="@+id/button_fuji_x_video_on_off"
617+ android:layout_width="20pt"
618+ android:layout_height="14pt"
619+ android:layout_below="@id/button_fuji_x_xv_minus"
620+ android:layout_alignLeft="@id/button_fuji_x_xv_minus"
621+ android:layout_alignStart="@id/button_fuji_x_xv_minus"
622622 android:scaleType="fitCenter"
623- android:visibility="invisible"
623+ android:visibility="visible"
624624 android:clickable="true"
625625 android:focusable="true"
626- android:src="@drawable/ic_camera_roll_black_24dp"
626+ android:src="@drawable/ic_videocam_black__24dp"
627627 android:layout_marginTop="6pt"
628628 android:gravity="center" />
629629
@@ -631,7 +631,7 @@
631631 android:id="@+id/button_fuji_x_flash"
632632 android:layout_width="20pt"
633633 android:layout_height="14pt"
634- android:layout_below="@id/button_fuji_x_dummy"
634+ android:layout_below="@id/button_fuji_x_video_on_off"
635635 android:layout_alignLeft="@id/button_fuji_x_tv_minus"
636636 android:layout_alignStart="@id/button_fuji_x_tv_minus"
637637 android:scaleType="fitCenter"
@@ -646,9 +646,9 @@
646646 android:id="@+id/button_fuji_x_timer"
647647 android:layout_width="34pt"
648648 android:layout_height="14pt"
649- android:layout_below="@id/button_fuji_x_dummy"
650- android:layout_alignLeft="@id/button_fuji_x_dummy"
651- android:layout_alignStart="@id/button_fuji_x_dummy"
649+ android:layout_below="@id/button_fuji_x_video_on_off"
650+ android:layout_alignLeft="@id/label_fuji_x_xv_center"
651+ android:layout_alignStart="@id/label_fuji_x_xv_center"
652652 android:scaleType="fitCenter"
653653 android:visibility="visible"
654654 android:clickable="true"
旧リポジトリブラウザで表示