32
32
import github .umer0586 .sensorserver .ServerInfo ;
33
33
import github .umer0586 .service .SensorService ;
34
34
import github .umer0586 .service .ServiceBindHelper ;
35
+ import github .umer0586 .setting .AppSettings ;
35
36
import github .umer0586 .util .UIUtil ;
36
37
37
38
@@ -42,6 +43,7 @@ public class ServerFragment extends Fragment
42
43
43
44
private SensorService sensorService ;
44
45
private ServiceBindHelper serviceBindHelper ;
46
+ private AppSettings appSettings ;
45
47
46
48
// Button at center to start/stop server
47
49
private MaterialButton startButton ;
@@ -75,6 +77,8 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
75
77
pulseAnimation = view .findViewById (R .id .loading_animation );
76
78
cardView = view .findViewById (R .id .card_view );
77
79
80
+ appSettings = new AppSettings (getContext ());
81
+
78
82
serviceBindHelper = new ServiceBindHelper (
79
83
getContext (),
80
84
this ,
@@ -115,17 +119,26 @@ private void startServer()
115
119
Log .d (TAG , "startServer() called" );
116
120
117
121
WifiManager wifiManager = (WifiManager ) getContext ().getApplicationContext ().getSystemService (getContext ().WIFI_SERVICE );
118
-
119
- // TODO: ignore wifi check when user has enabled adb option
120
- if (!wifiManager .isWifiEnabled ())
122
+
123
+ //If user has enabled local-host option (for adb) then don't check wifi state
124
+ if (appSettings .isLocalHostOptionEnable ())
125
+ {
126
+ Intent intent = new Intent (getContext (), SensorService .class );
127
+ ContextCompat .startForegroundService (getContext (),intent );
128
+ }
129
+ //If user has not enabled local-host option then check if wifi is enabled
130
+ else if (wifiManager .isWifiEnabled ())
131
+ {
132
+ Intent intent = new Intent (getContext (), SensorService .class );
133
+ ContextCompat .startForegroundService (getContext (),intent );
134
+ }
135
+
136
+ else
121
137
{
122
138
showMessage ("Please enable Wi-Fi" );
123
- return ;
124
139
}
125
140
126
- serviceBindHelper .bindToService ();
127
- Intent intent = new Intent (getContext (), SensorService .class );
128
- ContextCompat .startForegroundService (getContext (),intent );
141
+
129
142
130
143
}
131
144
0 commit comments