Fix permissions

This commit is contained in:
Mieszko Wrzeszczyński 2018-11-05 10:04:32 +01:00
parent 8ca2f7dc31
commit 03c38a8f23
3 changed files with 10 additions and 22 deletions

View File

@ -57,8 +57,6 @@ public abstract class BaseActivity
private ActionBarDrawerToggle actionBarDrawerToggle;
private SharingFragment sharingFragment;
boolean boolean_permission;
private Fragment userListFragment;
private ActiveFragment activeFragment = ActiveFragment.NONE;
@ -111,12 +109,12 @@ public abstract class BaseActivity
sharingFragment = new SharingFragment();
userListFragment = new UsersListFragment();
isTutor = PrefUtils.getIsTutor(getApplicationContext());
if (!isTutor) {
navigationView.findViewById(R.id.nav_profile).setVisibility(View.GONE);
}
checkPermissions();
}
@ -168,25 +166,14 @@ public abstract class BaseActivity
}
public void startBackgroundLocalizationTask() {
if ((ContextCompat.checkSelfPermission(getApplicationContext(), android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED)) {
checkPermissions();
if ((ActivityCompat.shouldShowRequestPermissionRationale(this, android.Manifest.permission.ACCESS_FINE_LOCATION))) {
Intent startIntent = new Intent(getApplicationContext(), BackgroundLocalizationService.class);
} else {
ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION
},
REQUEST_PERMISSIONS);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForegroundService(startIntent);
} else {
Intent startIntent = new Intent(getApplicationContext(), BackgroundLocalizationService.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForegroundService(startIntent);
} else {
startService(startIntent);
}
startService(startIntent);
}
}

View File

@ -109,7 +109,6 @@ public class MapActivity extends BaseActivity
coordinateService = ApiClient.getClient(getApplicationContext())
.create(CoordinateService.class);
//
mStatusChecker = () -> {
try {
fetchTopCoords();
@ -466,7 +465,6 @@ public class MapActivity extends BaseActivity
locationComponent.setCameraMode(CameraMode.TRACKING);
locationComponent.setRenderMode(RenderMode.COMPASS);
// Button 4 centring
FloatingActionButton myLocFAB = findViewById(R.id.myLocationButton);
myLocFAB.setOnClickListener(v -> {

View File

@ -25,6 +25,7 @@ public class RestApiHelper extends Activity {
} catch (Exception e) {
return e.getMessage();
}
}
@ -34,6 +35,8 @@ public class RestApiHelper extends Activity {
if (e instanceof HttpException) {
ResponseBody responseBody = ((HttpException) e).response().errorBody();
message = RestApiHelper.getErrorMessage(responseBody);
} else {
message ="Network Error !";
}
Snackbar snackbar = Snackbar.make(findViewById(R.id.activity_content), message, Snackbar.LENGTH_LONG);