button view gone

This commit is contained in:
Adam Domagalski 2018-11-05 01:22:09 +01:00
parent 90074affb1
commit 8ca2f7dc31
2 changed files with 19 additions and 8 deletions

View File

@ -1,5 +1,6 @@
package com.uam.wmi.findmytutor.activity;
import android.Manifest;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
@ -134,9 +135,8 @@ public class MapActivity extends BaseActivity
@Override
public void onMapReady(MapboxMap mapboxMap) {
MapActivity.this.mapboxMap = mapboxMap;
enableLocationPlugin();
mStatusChecker.run();
enableLocationPlugin();
// // TODO what should happend on click?
// mapboxMap.setOnMarkerClickListener(marker1 -> {
@ -438,8 +438,14 @@ public class MapActivity extends BaseActivity
@SuppressWarnings({"MissingPermission"})
private void enableLocationPlugin() {
Log.e(tag, "enableLocationPlugin");
// Check if permissions are enabled and if not request
if (PermissionsManager.areLocationPermissionsGranted(this)) {
Log.e(tag, "enableLocationPlugin true");
FloatingActionButton myLocationButton = findViewById(R.id.myLocationButton);
myLocationButton.setVisibility(View.VISIBLE);
LocationComponentOptions options = LocationComponentOptions.builder(this)
.trackingGesturesManagement(true)
@ -485,8 +491,12 @@ public class MapActivity extends BaseActivity
tiltParam = (tiltParam == 30) ? 0 : 30;
});
} else {
Log.e(tag, "enableLocationPlugin false");
permissionsManager = new PermissionsManager(this);
permissionsManager.requestLocationPermissions(this);
permissionsManager.onRequestPermissionsResult(0, new String[] {Manifest.permission.ACCESS_FINE_LOCATION}, new int[] {0});
}
}
@ -503,11 +513,11 @@ public class MapActivity extends BaseActivity
@Override
public void onPermissionResult(boolean granted) {
if (granted) {
enableLocationPlugin();
} else {
Toast.makeText(this, R.string.user_location_permission_not_granted, Toast.LENGTH_LONG).show();
finish();
}
// if (granted) {
// enableLocationPlugin();
// } else {
// Toast.makeText(this, R.string.user_location_permission_not_granted, Toast.LENGTH_LONG).show();
// finish();
// }
}
}

View File

@ -52,6 +52,7 @@
android:background="@color/half_black"
android:backgroundTint="@color/materialDarkGrey"
android:src="@android:drawable/ic_menu_mylocation"
android:visibility="invisible"
app:borderWidth="0dp"
app:elevation="6dp"
app:fabSize="normal"