11
11
import android .hardware .usb .UsbDevice ;
12
12
import android .hardware .usb .UsbManager ;
13
13
import android .os .Bundle ;
14
+ import android .preference .PreferenceManager ;
14
15
import android .util .Log ;
15
16
import android .view .GestureDetector ;
16
17
import android .view .MotionEvent ;
22
23
23
24
import androidx .appcompat .app .ActionBar ;
24
25
import androidx .appcompat .app .AppCompatActivity ;
25
- import androidx .preference .PreferenceManager ;
26
+ import io .sentry .SentryLevel ;
27
+ import io .sentry .android .core .SentryAndroid ;
28
+
26
29
import com .fpvout .digiview .dvr .DVR ;
27
30
import java .io .IOException ;
28
31
import java .util .HashMap ;
29
32
30
- import io .sentry .SentryLevel ;
31
- import io .sentry .android .core .SentryAndroid ;
32
33
33
34
import static com .fpvout .digiview .VideoReaderExoplayer .VideoZoomedIn ;
34
35
@@ -40,6 +41,7 @@ public class MainActivity extends AppCompatActivity implements UsbDeviceListener
40
41
private int shortAnimationDuration ;
41
42
private float buttonAlpha = 1 ;
42
43
private View settingsButton ;
44
+ private View recordButton ;
43
45
private View watermarkView ;
44
46
private OverlayView overlayView ;
45
47
PendingIntent permissionIntent ;
@@ -113,6 +115,7 @@ public void onClick(View v) {
113
115
v .getContext ().startActivity (intent );
114
116
}
115
117
});
118
+ recordButton = findViewById (R .id .recordbt );
116
119
117
120
sharedPreferences = PreferenceManager .getDefaultSharedPreferences (this );
118
121
@@ -137,7 +140,7 @@ private void setupGestureDetectors() {
137
140
gestureDetector = new GestureDetector (this , new GestureDetector .SimpleOnGestureListener () {
138
141
@ Override
139
142
public boolean onSingleTapConfirmed (MotionEvent e ) {
140
- toggleSettingsButton ();
143
+ toggleButton ();
141
144
return super .onSingleTapConfirmed (e );
142
145
}
143
146
@@ -162,7 +165,7 @@ public void onScaleEnd(ScaleGestureDetector detector) {
162
165
watermarkView .setVisibility (View .GONE );
163
166
164
167
mUsbMaskConnection = new UsbMaskConnection ();
165
- mVideoReader = new VideoReaderExoplayer (fpvView , overlayView , this , recorder );
168
+ mVideoReader = new VideoReaderExoplayer (fpvView , overlayView , this );
166
169
167
170
if (!usbConnected ) {
168
171
if (searchDevice ()) {
@@ -232,9 +235,10 @@ private void updateVideoZoom() {
232
235
}
233
236
}
234
237
235
- private void toggleSettingsButton () {
238
+ private void toggleButton () {
236
239
// cancel any pending delayed animations first
237
240
settingsButton .getHandler ().removeCallbacksAndMessages (null );
241
+ recordButton .getHandler ().removeCallbacksAndMessages (null );
238
242
239
243
if (buttonAlpha == 1 ) {
240
244
buttonAlpha = 0 ;
@@ -251,6 +255,10 @@ public void onAnimationEnd(Animator animation) {
251
255
autoHideSettingsButton ();
252
256
}
253
257
});
258
+
259
+ recordButton .animate ()
260
+ .alpha (buttonAlpha )
261
+ .setDuration (shortAnimationDuration );
254
262
}
255
263
256
264
private void autoHideSettingsButton () {
@@ -265,6 +273,16 @@ public void run() {
265
273
.setDuration (shortAnimationDuration );
266
274
}
267
275
}, 3000 );
276
+
277
+ recordButton .postDelayed (new Runnable () {
278
+ @ Override
279
+ public void run () {
280
+ buttonAlpha = 0 ;
281
+ recordButton .animate ()
282
+ .alpha (0 )
283
+ .setDuration (shortAnimationDuration );
284
+ }
285
+ }, 3000 );
268
286
}
269
287
270
288
@ Override
@@ -347,15 +365,10 @@ public void onResume() {
347
365
}
348
366
349
367
settingsButton .setAlpha (1 );
368
+ recordButton .setAlpha (1 );
350
369
autoHideSettingsButton ();
351
370
updateWatermark ();
352
371
updateVideoZoom ();
353
-
354
- try {
355
- recorder .init ();
356
- } catch (IOException e ) {
357
- e .printStackTrace ();
358
- }
359
372
}
360
373
361
374
@ Override
0 commit comments