Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPS and Camera improvements #24

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion droidar/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
41 changes: 35 additions & 6 deletions droidar/src/geo/GeoUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion droidar/src/system/CameraView.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down