aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/de/pixart/messenger/ui/LocationActivity.java9
-rw-r--r--src/main/java/de/pixart/messenger/ui/ShareLocationActivity.java8
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);
}