Commit 9c6d26f5 authored by Bastien Zigmann's avatar Bastien Zigmann

MOBILE APP : Factorisation du test de l'activation du gps

parent 16ee83c9
......@@ -47,6 +47,10 @@ public class MainActivity extends AppCompatActivity {
}
}
private boolean isGPSOn(){
return (((LocationManager) getSystemService( Context.LOCATION_SERVICE ))).isProviderEnabled(LocationManager.GPS_PROVIDER);
}
private void buildAlertMessageNoGps() {
final AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.MyDialogTheme);
builder.setMessage("Le GPS semble être désactivé, l'activer?")
......@@ -59,8 +63,8 @@ public class MainActivity extends AppCompatActivity {
.setNegativeButton("Non", new DialogInterface.OnClickListener() {
public void onClick(final DialogInterface dialog, @SuppressWarnings("unused") final int id) {
dialog.cancel();
boolean IsLocalised = (((LocationManager) getSystemService( Context.LOCATION_SERVICE ))).isProviderEnabled(LocationManager.GPS_PROVIDER);
if ( !IsLocalised ) {
//boolean IsLocalised = (((LocationManager) getSystemService( Context.LOCATION_SERVICE ))).isProviderEnabled(LocationManager.GPS_PROVIDER);
if ( !isGPSOn() ) {
callJS("geocropping.MobileSetGPSPosition(false);");
}else{
callJS("geocropping.MobileSetGPSPosistion(true);");
......@@ -203,8 +207,8 @@ public class MainActivity extends AppCompatActivity {
}
// Vérification du GPS au lancement
boolean IsLocalised = (((LocationManager) getSystemService( Context.LOCATION_SERVICE ))).isProviderEnabled(LocationManager.GPS_PROVIDER);
if ( !IsLocalised ) {
//boolean IsLocalised = (((LocationManager) getSystemService( Context.LOCATION_SERVICE ))).isProviderEnabled(LocationManager.GPS_PROVIDER);
if ( !isGPSOn() ) {
buildAlertMessageNoGps();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment