Skip to content
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package de.cidaas.sdk.android.library.common;

public final class Privacy {
private static volatile boolean locationEnabled = true;

private Privacy() {}

/** Enable/disable any SDK path that depends on location permission. */
public static void setLocationEnabled(boolean enabled) {
locationEnabled = enabled;
}

/** Current location toggle state (true = enabled / legacy behavior). */
public static boolean isLocationEnabled() {
return locationEnabled;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

import static android.content.Context.LOCATION_SERVICE;

import de.cidaas.sdk.android.library.common.Privacy;

public class LocationDetails implements LocationListener {

private final Context mContext;
Expand Down Expand Up @@ -96,6 +98,11 @@ public Location getLocation() {

@RequiresApi(api = Build.VERSION_CODES.M)
private void getLocationPermissions() {

if (!Privacy.isLocationEnabled()) {
return false;
}

if (ContextCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED ||
ContextCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
getLocationAfterPermission();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import de.cidaas.sdk.android.entities.DeviceInfoEntity;
import de.cidaas.sdk.android.helper.general.DBHelper;
import de.cidaas.sdk.android.library.locationlibrary.LocationDetails;
import de.cidaas.sdk.android.library.common.Privacy;
import timber.log.Timber;

public class Headers {
Expand Down Expand Up @@ -55,8 +56,11 @@ public Map<String, String> getHeaders(String accessToken, boolean verification_a
headers.put("Content-Type", contentType);
}

headers.put("lat", LocationDetails.getShared(context).getLatitude());
headers.put("lon", LocationDetails.getShared(context).getLongitude());
if (Privacy.isLocationEnabled()) {

headers.put("lat", LocationDetails.getShared(context).getLatitude());
headers.put("lon", LocationDetails.getShared(context).getLongitude());
}

DeviceInfoEntity deviceInfoEntity = DBHelper.getShared().getDeviceInfo();

Expand Down