17
17
18
18
package com .googleresearch .capturesync ;
19
19
20
- import static android .hardware .camera2 .CameraMetadata .CONTROL_AF_MODE_AUTO ;
21
20
import static android .hardware .camera2 .CameraMetadata .CONTROL_AF_MODE_OFF ;
22
21
import static android .hardware .camera2 .CameraMetadata .CONTROL_AF_TRIGGER_CANCEL ;
23
- import static android .hardware .camera2 .CameraMetadata .CONTROL_AF_TRIGGER_IDLE ;
24
22
import static android .hardware .camera2 .CaptureRequest .CONTROL_AF_MODE ;
25
- import static android .hardware .camera2 .CaptureRequest .CONTROL_AF_TRIGGER ;
26
- import static android .hardware .camera2 .CaptureRequest .LENS_FOCUS_DISTANCE ;
27
- import static java .security .AccessController .getContext ;
28
23
29
24
import android .Manifest .permission ;
30
25
import android .annotation .SuppressLint ;
50
45
import android .media .CamcorderProfile ;
51
46
import android .media .MediaCodec ;
52
47
import android .media .MediaRecorder ;
53
- import android .net .wifi .WifiInfo ;
54
48
import android .net .wifi .WifiManager ;
55
49
import android .os .Bundle ;
56
50
import android .os .Environment ;
57
51
import android .os .Handler ;
58
52
import android .os .HandlerThread ;
59
53
import android .provider .Settings ;
60
- import android .telephony .TelephonyManager ;
61
54
import android .util .Log ;
62
55
import android .util .Size ;
63
56
import android .view .Gravity ;
72
65
import android .widget .SeekBar .OnSeekBarChangeListener ;
73
66
import android .widget .TextView ;
74
67
import android .widget .Toast ;
75
- import android .provider .Settings .Secure ;
76
68
77
69
import com .googleresearch .capturesync .softwaresync .CSVLogger ;
78
70
import com .googleresearch .capturesync .softwaresync .SoftwareSyncLeader ;
131
123
*/
132
124
public class MainActivity extends Activity {
133
125
private static final String TAG = "MainActivity" ;
134
- private static final int STATIC_LEN = 15_000 ;
135
126
private static final int REC_QUALITY = CamcorderProfile .QUALITY_1080P ;
136
127
private static final int REC_BITRATE = 10 *1000 *1000 ;
137
128
private static final int REC_FPS = 30 ;
129
+ private static final String REC_SUBDIR_NAME = "RecSync" ;
130
+
138
131
139
132
private String lastTimeStamp ;
140
133
private PeriodCalculator periodCalculator ;
@@ -161,24 +154,12 @@ public Integer getLastVideoSeqId() {
161
154
162
155
private Integer lastVideoSeqId ;
163
156
164
- public int getCurSequence () {
165
- return curSequence ;
166
- }
167
-
168
- // public void setLogger(CSVLogger mLogger) {
169
- // this.mLogger = mLogger;
170
- // }
171
-
172
157
public CSVLogger getLogger () {
173
158
return mLogger ;
174
159
}
175
160
176
161
private CSVLogger mLogger ;
177
162
178
- private int curSequence ;
179
-
180
- private static final String SUBDIR_NAME = "RecSync" ;
181
-
182
163
private boolean permissionsGranted = false ;
183
164
private boolean isAutofocusStarted = false ;
184
165
// Phase config file to use for phase alignment, configs are located in the raw folder.
@@ -209,9 +190,7 @@ public CSVLogger getLogger() {
209
190
private Button captureStillButton ;
210
191
private Button getPeriodButton ;
211
192
private Button phaseAlignButton ;
212
- private Button makeFocusButton ;
213
- private Button unlockFocusButton ;
214
- private TextView focusDistanceTextView ;
193
+ private Button toggleFocusButton ;
215
194
private SeekBar exposureSeekBar ;
216
195
private SeekBar sensitivitySeekBar ;
217
196
private TextView statusTextView ;
@@ -526,7 +505,7 @@ private void handleWebSocketMsg(@NotNull WsMessageContext wsMessageContext){
526
505
((SoftwareSyncLeader ) softwareSyncController .softwareSync )
527
506
.broadcastRpc (SoftwareSyncController .METHOD_START_FOCUS ,"" );
528
507
529
- makeFocusButton .setText ("Stop Autofocus" );
508
+ toggleFocusButton .setText ("Stop Autofocus" );
530
509
break ;
531
510
532
511
case "STOP_AUTOFOCUS" :
@@ -537,7 +516,7 @@ private void handleWebSocketMsg(@NotNull WsMessageContext wsMessageContext){
537
516
((SoftwareSyncLeader ) softwareSyncController .softwareSync )
538
517
.broadcastRpc (SoftwareSyncController .METHOD_STOP_FOCUS ,"" );
539
518
540
- makeFocusButton .setText ("Start Autofocus" );
519
+ toggleFocusButton .setText ("Start Autofocus" );
541
520
break ;
542
521
}
543
522
}
@@ -643,8 +622,7 @@ private void setLeaderClientControls(boolean isLeader) {
643
622
// Leader, all controls visible and set.
644
623
captureStillButton .setVisibility (View .VISIBLE );
645
624
phaseAlignButton .setVisibility (View .VISIBLE );
646
- makeFocusButton .setVisibility (View .VISIBLE );
647
- focusDistanceTextView .setVisibility (View .VISIBLE );
625
+ toggleFocusButton .setVisibility (View .VISIBLE );
648
626
649
627
getPeriodButton .setVisibility (View .VISIBLE );
650
628
exposureSeekBar .setVisibility (View .VISIBLE );
@@ -707,16 +685,16 @@ private void setLeaderClientControls(boolean isLeader) {
707
685
.broadcastRpc (SoftwareSyncController .METHOD_DO_PHASE_ALIGN , "" );
708
686
});
709
687
710
- makeFocusButton .setOnClickListener (
688
+ toggleFocusButton .setOnClickListener (
711
689
view -> {
712
690
if (isAutofocusStarted ) {
713
691
stopAutofocus ();
714
- makeFocusButton .setText ("Start Autofocus" );
692
+ toggleFocusButton .setText ("Start Autofocus" );
715
693
((SoftwareSyncLeader ) softwareSyncController .softwareSync )
716
694
.broadcastRpc (SoftwareSyncController .METHOD_STOP_FOCUS ,"" );
717
695
} else {
718
696
startAutofocus ();
719
- makeFocusButton .setText ("Stop Autofocus" );
697
+ toggleFocusButton .setText ("Stop Autofocus" );
720
698
((SoftwareSyncLeader ) softwareSyncController .softwareSync )
721
699
.broadcastRpc (SoftwareSyncController .METHOD_START_FOCUS ,"" );
722
700
}
@@ -789,8 +767,7 @@ public void onStopTrackingTouch(SeekBar seekBar) {
789
767
getPeriodButton .setVisibility (View .VISIBLE );
790
768
exposureSeekBar .setVisibility (View .INVISIBLE );
791
769
sensitivitySeekBar .setVisibility (View .INVISIBLE );
792
- makeFocusButton .setVisibility (View .INVISIBLE );
793
- focusDistanceTextView .setVisibility (View .VISIBLE );
770
+ toggleFocusButton .setVisibility (View .INVISIBLE );
794
771
795
772
captureStillButton .setOnClickListener (null );
796
773
phaseAlignButton .setOnClickListener (null );
@@ -1047,7 +1024,7 @@ private void createUi() {
1047
1024
// Controls.
1048
1025
captureStillButton = findViewById (R .id .capture_still_button );
1049
1026
phaseAlignButton = findViewById (R .id .phase_align_button );
1050
- makeFocusButton = findViewById (R .id .make_focus_button );
1027
+ toggleFocusButton = findViewById (R .id .make_focus_button );
1051
1028
1052
1029
getPeriodButton = findViewById (R .id .get_period_button );
1053
1030
@@ -1256,7 +1233,7 @@ private String getOutputMediaFilePath(String prefixText) throws IOException {
1256
1233
1257
1234
File sdcard = Environment .getExternalStorageDirectory ();
1258
1235
1259
- Path dir = Files .createDirectories (Paths .get (sdcard .getAbsolutePath (), SUBDIR_NAME , "VID" ));
1236
+ Path dir = Files .createDirectories (Paths .get (sdcard .getAbsolutePath (), REC_SUBDIR_NAME , "VID" ));
1260
1237
1261
1238
lastTimeStamp = new SimpleDateFormat ("yyyyMMdd_HHmmss" ,
1262
1239
Locale .getDefault ()).format (new Date ());
@@ -1471,7 +1448,7 @@ public void startVideo(boolean wantAutoExp, String prefixText) {
1471
1448
String filename = prefixText +"_" +lastTimeStamp + ".csv" ;
1472
1449
// Creates frame timestamps logger
1473
1450
try {
1474
- mLogger = new CSVLogger (SUBDIR_NAME , filename , this );
1451
+ mLogger = new CSVLogger (REC_SUBDIR_NAME , filename , this );
1475
1452
} catch (IOException e ) {
1476
1453
e .printStackTrace ();
1477
1454
}
0 commit comments