Skip to content

Commit

Permalink
Added option to disable use of location data.
Browse files Browse the repository at this point in the history
  • Loading branch information
jklmnn committed Mar 7, 2015
1 parent 8a2c553 commit fb13ab3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
11 changes: 7 additions & 4 deletions app/src/main/java/de/jkliemann/parkendd/GlobalSettings.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package de.jkliemann.parkendd;

import android.content.Context;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.location.LocationProvider;
import android.os.Bundle;
import android.os.Looper;
import android.preference.PreferenceManager;

/**
* Created by jkliemann on 07.01.15.
Expand Down Expand Up @@ -67,8 +66,12 @@ public void onProviderDisabled(String provider) {
locationManager.requestLocationUpdates(locationProvider, (long) 60000, (float) 50, locationListener, Looper.getMainLooper());
}

public Location getLastKnownLocation(){
return locationManager.getLastKnownLocation(locationProvider);
public Location getLastKnownLocation() {
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("use_location", true)){
return locationManager.getLastKnownLocation(locationProvider);
}else {
return null;
}
}


Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<string name="header_network">Netzwerk</string>
<string name="setting_server">Server</string>
<string name="setting_city">Stadt</string>
<string name="setting_location">Standort nutzen</string>
<string name="setting_reset">Zurücksetzen</string>
<string name="setting_ignore_cert">SSL-Zertifikat ignorieren (unsicher!)</string>
<!--defaults-->
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/res/xml/pref_general.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

<ListPreference
android:key="city"
android:title="Stadt"
android:title="@string/setting_city"
android:defaultValue="Dresden"/>
<CheckBoxPreference
android:key="use_location"
android:title="@string/setting_location"
android:defaultValue="true"/>

</PreferenceScreen>

0 comments on commit fb13ab3

Please sign in to comment.