File tree 3 files changed +30
-1
lines changed
java/com/jvdegithub/aiscatcher 3 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 67
67
public class MainActivity <binding > extends AppCompatActivity implements AisCatcherJava .AisCallback , DeviceManager .DeviceCallback {
68
68
69
69
private SharedPreferences .OnSharedPreferenceChangeListener preferenceChangeListener ;
70
+ private boolean firstRun = true ;
70
71
71
72
private LogBook logbook ;
72
73
private LocationHelper locationHelper ;
@@ -200,6 +201,17 @@ private void onWeb () {
200
201
startActivity (browserIntent );
201
202
}
202
203
204
+ protected void AutoStart () {
205
+ if (!Settings .getAutoStart (this )) return ;
206
+ if (DeviceManager .getDeviceType () != DeviceManager .DeviceType .RTLSDR &&
207
+ DeviceManager .getDeviceType () != DeviceManager .DeviceType .AIRSPY &&
208
+ DeviceManager .getDeviceType () != DeviceManager .DeviceType .AIRSPYHF )
209
+ return ;
210
+
211
+ if (!AisService .isRunning (getApplicationContext ())) {
212
+ onPlayStop ();
213
+ }
214
+ }
203
215
protected void onResume () {
204
216
205
217
super .onResume ();
@@ -210,6 +222,11 @@ protected void onResume () {
210
222
} else {
211
223
updateUIwithStop ();
212
224
}
225
+
226
+ if (firstRun ) {
227
+ firstRun = false ;
228
+ AutoStart ();
229
+ }
213
230
}
214
231
215
232
@ Override
Original file line number Diff line number Diff line change @@ -59,11 +59,11 @@ static void setDefault(Context context) {
59
59
60
60
preferences .edit ().putString ("sSHARINGKEY" , "" ).commit ();
61
61
preferences .edit ().putBoolean ("sSHARING" , false ).commit ();
62
+ preferences .edit ().putBoolean ("sAUTOSTART" , false ).commit ();
62
63
63
64
preferences .edit ().putBoolean ("w1SWITCH" , false ).commit ();
64
65
preferences .edit ().putString ("w1PORT" , "8100" ).commit ();
65
66
66
-
67
67
preferences .edit ().putString ("oCGF_WIDE" , "Default" ).commit ();
68
68
preferences .edit ().putString ("oMODEL_TYPE" , "Default" ).commit ();
69
69
preferences .edit ().putBoolean ("oFP_DS" , false ).commit ();
@@ -299,6 +299,12 @@ static public int getCGFSetting(Context context)
299
299
return 1 ;
300
300
}
301
301
302
+ static public boolean getAutoStart (Context context )
303
+ {
304
+ SharedPreferences preferences = PreferenceManager .getDefaultSharedPreferences (context );
305
+ return preferences .getBoolean ("sAUTOSTART" ,false );
306
+ }
307
+
302
308
static public boolean getFixedPointDownsampling (Context context )
303
309
{
304
310
SharedPreferences preferences = PreferenceManager .getDefaultSharedPreferences (context );
Original file line number Diff line number Diff line change 25
25
android : defaultValue =" False"
26
26
android : title =" Force Dark Mode" />
27
27
28
+ <SwitchPreferenceCompat
29
+ android : key =" sAUTOSTART"
30
+ android : summary =" Auto Start when USB device is available"
31
+ android : defaultValue =" False"
32
+ android : title =" Auto Start" />
33
+
28
34
</PreferenceCategory >
29
35
30
36
<PreferenceCategory
You can’t perform that action at this time.
0 commit comments