add some more permission checks for locations
This commit is contained in:
parent
b088fd439e
commit
aba375e64e
2 changed files with 13 additions and 4 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
|
Reference in a new issue