Skip to content

Commit e296852

Browse files
committed
Merge remote-tracking branch 'origin/remotecontrolling' into remotecontrolling
2 parents cce05f1 + 88bdfd2 commit e296852

File tree

2 files changed

+26
-36
lines changed

2 files changed

+26
-36
lines changed

app/src/main/java/com/googleresearch/capturesync/MainActivity.java

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,9 @@
1717

1818
package com.googleresearch.capturesync;
1919

20-
import static android.hardware.camera2.CameraMetadata.CONTROL_AF_MODE_AUTO;
2120
import static android.hardware.camera2.CameraMetadata.CONTROL_AF_MODE_OFF;
2221
import static android.hardware.camera2.CameraMetadata.CONTROL_AF_TRIGGER_CANCEL;
23-
import static android.hardware.camera2.CameraMetadata.CONTROL_AF_TRIGGER_IDLE;
2422
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;
2823

2924
import android.Manifest.permission;
3025
import android.annotation.SuppressLint;
@@ -50,14 +45,12 @@
5045
import android.media.CamcorderProfile;
5146
import android.media.MediaCodec;
5247
import android.media.MediaRecorder;
53-
import android.net.wifi.WifiInfo;
5448
import android.net.wifi.WifiManager;
5549
import android.os.Bundle;
5650
import android.os.Environment;
5751
import android.os.Handler;
5852
import android.os.HandlerThread;
5953
import android.provider.Settings;
60-
import android.telephony.TelephonyManager;
6154
import android.util.Log;
6255
import android.util.Size;
6356
import android.view.Gravity;
@@ -72,7 +65,6 @@
7265
import android.widget.SeekBar.OnSeekBarChangeListener;
7366
import android.widget.TextView;
7467
import android.widget.Toast;
75-
import android.provider.Settings.Secure;
7668

7769
import com.googleresearch.capturesync.softwaresync.CSVLogger;
7870
import com.googleresearch.capturesync.softwaresync.SoftwareSyncLeader;
@@ -131,10 +123,11 @@
131123
*/
132124
public class MainActivity extends Activity {
133125
private static final String TAG = "MainActivity";
134-
private static final int STATIC_LEN = 15_000;
135126
private static final int REC_QUALITY = CamcorderProfile.QUALITY_1080P ;
136127
private static final int REC_BITRATE = 10*1000*1000;
137128
private static final int REC_FPS = 30;
129+
private static final String REC_SUBDIR_NAME = "RecSync";
130+
138131

139132
private String lastTimeStamp;
140133
private PeriodCalculator periodCalculator;
@@ -161,24 +154,12 @@ public Integer getLastVideoSeqId() {
161154

162155
private Integer lastVideoSeqId;
163156

164-
public int getCurSequence() {
165-
return curSequence;
166-
}
167-
168-
// public void setLogger(CSVLogger mLogger) {
169-
// this.mLogger = mLogger;
170-
// }
171-
172157
public CSVLogger getLogger() {
173158
return mLogger;
174159
}
175160

176161
private CSVLogger mLogger;
177162

178-
private int curSequence;
179-
180-
private static final String SUBDIR_NAME = "RecSync";
181-
182163
private boolean permissionsGranted = false;
183164
private boolean isAutofocusStarted = false;
184165
// Phase config file to use for phase alignment, configs are located in the raw folder.
@@ -209,9 +190,7 @@ public CSVLogger getLogger() {
209190
private Button captureStillButton;
210191
private Button getPeriodButton;
211192
private Button phaseAlignButton;
212-
private Button makeFocusButton;
213-
private Button unlockFocusButton;
214-
private TextView focusDistanceTextView ;
193+
private Button toggleFocusButton;
215194
private SeekBar exposureSeekBar;
216195
private SeekBar sensitivitySeekBar;
217196
private TextView statusTextView;
@@ -526,7 +505,7 @@ private void handleWebSocketMsg(@NotNull WsMessageContext wsMessageContext){
526505
((SoftwareSyncLeader) softwareSyncController.softwareSync)
527506
.broadcastRpc(SoftwareSyncController.METHOD_START_FOCUS,"");
528507

529-
makeFocusButton.setText("Stop Autofocus");
508+
toggleFocusButton.setText("Stop Autofocus");
530509
break;
531510

532511
case "STOP_AUTOFOCUS":
@@ -537,7 +516,7 @@ private void handleWebSocketMsg(@NotNull WsMessageContext wsMessageContext){
537516
((SoftwareSyncLeader) softwareSyncController.softwareSync)
538517
.broadcastRpc(SoftwareSyncController.METHOD_STOP_FOCUS,"");
539518

540-
makeFocusButton.setText("Start Autofocus");
519+
toggleFocusButton.setText("Start Autofocus");
541520
break ;
542521
}
543522
}
@@ -643,8 +622,7 @@ private void setLeaderClientControls(boolean isLeader) {
643622
// Leader, all controls visible and set.
644623
captureStillButton.setVisibility(View.VISIBLE);
645624
phaseAlignButton.setVisibility(View.VISIBLE);
646-
makeFocusButton.setVisibility(View.VISIBLE);
647-
focusDistanceTextView.setVisibility(View.VISIBLE);
625+
toggleFocusButton.setVisibility(View.VISIBLE);
648626

649627
getPeriodButton.setVisibility(View.VISIBLE);
650628
exposureSeekBar.setVisibility(View.VISIBLE);
@@ -707,16 +685,16 @@ private void setLeaderClientControls(boolean isLeader) {
707685
.broadcastRpc(SoftwareSyncController.METHOD_DO_PHASE_ALIGN, "");
708686
});
709687

710-
makeFocusButton.setOnClickListener(
688+
toggleFocusButton.setOnClickListener(
711689
view -> {
712690
if (isAutofocusStarted) {
713691
stopAutofocus();
714-
makeFocusButton.setText("Start Autofocus");
692+
toggleFocusButton.setText("Start Autofocus");
715693
((SoftwareSyncLeader) softwareSyncController.softwareSync)
716694
.broadcastRpc(SoftwareSyncController.METHOD_STOP_FOCUS,"");
717695
} else {
718696
startAutofocus();
719-
makeFocusButton.setText("Stop Autofocus");
697+
toggleFocusButton.setText("Stop Autofocus");
720698
((SoftwareSyncLeader) softwareSyncController.softwareSync)
721699
.broadcastRpc(SoftwareSyncController.METHOD_START_FOCUS,"");
722700
}
@@ -789,8 +767,7 @@ public void onStopTrackingTouch(SeekBar seekBar) {
789767
getPeriodButton.setVisibility(View.VISIBLE);
790768
exposureSeekBar.setVisibility(View.INVISIBLE);
791769
sensitivitySeekBar.setVisibility(View.INVISIBLE);
792-
makeFocusButton.setVisibility(View.INVISIBLE);
793-
focusDistanceTextView.setVisibility(View.VISIBLE);
770+
toggleFocusButton.setVisibility(View.INVISIBLE);
794771

795772
captureStillButton.setOnClickListener(null);
796773
phaseAlignButton.setOnClickListener(null);
@@ -1047,7 +1024,7 @@ private void createUi() {
10471024
// Controls.
10481025
captureStillButton = findViewById(R.id.capture_still_button);
10491026
phaseAlignButton = findViewById(R.id.phase_align_button);
1050-
makeFocusButton = findViewById(R.id.make_focus_button);
1027+
toggleFocusButton = findViewById(R.id.make_focus_button);
10511028

10521029
getPeriodButton = findViewById(R.id.get_period_button);
10531030

@@ -1256,7 +1233,7 @@ private String getOutputMediaFilePath(String prefixText) throws IOException {
12561233

12571234
File sdcard = Environment.getExternalStorageDirectory();
12581235

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"));
12601237

12611238
lastTimeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss",
12621239
Locale.getDefault()).format(new Date());
@@ -1471,7 +1448,7 @@ public void startVideo(boolean wantAutoExp, String prefixText) {
14711448
String filename = prefixText+"_"+lastTimeStamp + ".csv";
14721449
// Creates frame timestamps logger
14731450
try {
1474-
mLogger = new CSVLogger(SUBDIR_NAME, filename, this);
1451+
mLogger = new CSVLogger(REC_SUBDIR_NAME, filename, this);
14751452
} catch (IOException e) {
14761453
e.printStackTrace();
14771454
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:orientation="vertical"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent">
6+
<TextView
7+
android:id="@+id/log_text_view"
8+
android:layout_width="match_parent"
9+
android:layout_height="wrap_content"
10+
android:textSize="14sp"
11+
android:textColor="@android:color/black" />
12+
13+
</LinearLayout>

0 commit comments

Comments
 (0)