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

View File

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