diff --git a/droidar/project.properties b/droidar/project.properties index c32ffe5..8624e6b 100644 --- a/droidar/project.properties +++ b/droidar/project.properties @@ -11,4 +11,4 @@ android.library=true # Indicates whether an apk should be generated for each density. split.density=false # Project target. -target=android-8 +target=android-17 diff --git a/droidar/src/geo/GeoUtils.java b/droidar/src/geo/GeoUtils.java index 8507d70..d4f2e55 100644 --- a/droidar/src/geo/GeoUtils.java +++ b/droidar/src/geo/GeoUtils.java @@ -464,18 +464,47 @@ public static boolean disableGPS(Activity activity, */ public static boolean switchGPS(Activity activity, boolean enableGPS, boolean showSettingsIfAutoSwitchImpossible) { + + String provider = Settings.Secure.getString( + activity.getContentResolver(), + Settings.Secure.LOCATION_PROVIDERS_ALLOWED); + boolean currentlyEnabled = provider.contains("gps"); + if (canTurnOnGPSAutomatically(activity)) { - String provider = Settings.Secure.getString( - activity.getContentResolver(), - Settings.Secure.LOCATION_PROVIDERS_ALLOWED); - boolean currentlyEnabled = provider.contains("gps"); +// String provider = Settings.Secure.getString( +// activity.getContentResolver(), +// Settings.Secure.LOCATION_PROVIDERS_ALLOWED); +// boolean currentlyEnabled = provider.contains("gps"); if (!currentlyEnabled && enableGPS) { + + if (android.os.Build.VERSION.SDK_INT > 14){ + // to make it work in android 4.0 and higher - enable access to my location setting + Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE"); + intent.putExtra("enabled", true); + activity.sendBroadcast(intent); + } + pokeGPSButton(activity); - } else if (currentlyEnabled && !enableGPS) { - pokeGPSButton(activity); + + } else if (/*currentlyEnabled &&*/ !enableGPS) {// always send disable intent for higher OS versions and only poke if enabled, regardless of the version + + if (android.os.Build.VERSION.SDK_INT > 14){ + // to make it work in android 4.0 and higher - disable access to my location setting + Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE"); + intent.putExtra("enabled", false); + activity.sendBroadcast(intent); + } + + if(currentlyEnabled) + pokeGPSButton(activity); + } return true; } else if (showSettingsIfAutoSwitchImpossible) { + + if(currentlyEnabled) + return true; + Log.d(LOG_TAG, "Can't enable GPS automatically, will start " + "settings for manual enabling!"); openLocationSettingsPage(activity); diff --git a/droidar/src/system/CameraView.java b/droidar/src/system/CameraView.java index e7e2dc8..5329da3 100644 --- a/droidar/src/system/CameraView.java +++ b/droidar/src/system/CameraView.java @@ -17,7 +17,7 @@ public class CameraView extends SurfaceView implements SurfaceHolder.Callback { private static final String LOG_TAG = "CameraView"; SurfaceHolder mHolder; - Camera myCamera; + public Camera myCamera; public CameraView(Context context) { super(context);