diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-08-04 22:33:17 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-08-04 22:33:17 +0200 |
commit | aba375e64eee66ce0454ce791506718c4f6d62a0 (patch) | |
tree | 238f17dac56a1582d849732444e7345efbb7ca69 /src/main/java/de/pixart/messenger/ui | |
parent | b088fd439e4319fdc8a89f4e65ac80d618cfc119 (diff) |
add some more permission checks for locations
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/LocationActivity.java | 9 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ShareLocationActivity.java | 8 |
2 files changed, 13 insertions, 4 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/LocationActivity.java b/src/main/java/de/pixart/messenger/ui/LocationActivity.java index 1e5f2a643..ed42c4636 100644 --- a/src/main/java/de/pixart/messenger/ui/LocationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/LocationActivity.java @@ -1,16 +1,20 @@ package de.pixart.messenger.ui; +import android.Manifest; import android.content.Context; +import android.content.pm.PackageManager; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; +import android.support.v4.app.ActivityCompat; import android.support.v7.app.AppCompatActivity; import de.pixart.messenger.Config; public abstract class LocationActivity extends XmppActivity implements LocationListener { private LocationManager locationManager; + public static final int REQUEST_LOCATION_PERMISSION = 0x682f41; @Override protected void onCreate(final Bundle savedInstanceState) { @@ -60,7 +64,8 @@ public abstract class LocationActivity extends XmppActivity implements LocationL public void onResume() { super.onResume(); this.setmLastLocation(null); - - requestLocationUpdates(); + if (hasLocationPermission(REQUEST_LOCATION_PERMISSION)) { + requestLocationUpdates(); + } } }
\ No newline at end of file diff --git a/src/main/java/de/pixart/messenger/ui/ShareLocationActivity.java b/src/main/java/de/pixart/messenger/ui/ShareLocationActivity.java index 2ac05fffc..568370dff 100644 --- a/src/main/java/de/pixart/messenger/ui/ShareLocationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ShareLocationActivity.java @@ -105,11 +105,15 @@ public class ShareLocationActivity extends LocationActivity implements LocationL this.snackBar = Snackbar.make(snackBarCoordinator, R.string.location_sharing_disabled, Snackbar.LENGTH_INDEFINITE); snackBar.setAction(R.string.enable, view -> { if (isLocationEnabled()) { - requestLocationUpdates(); + if (hasLocationPermission(LocationActivity.REQUEST_LOCATION_PERMISSION)) { + requestLocationUpdates(); + } } else { showLocation(null, null); setShareButtonEnabled(false); - requestLocationUpdates(); + if (hasLocationPermission(LocationActivity.REQUEST_LOCATION_PERMISSION)) { + requestLocationUpdates(); + } startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS)); overridePendingTransition(R.animator.fade_in, R.animator.fade_out); } |