Expose LocationComponentOptions#trackingMultiFingerProtectedMoveArea
This option provides a way of defining a protected area on the screen which prevents breaking the camera location when executing a multi finger gesture as long as the focal point of the gesture is within this area.
This commit is contained in:
@@ -2,6 +2,7 @@ package com.mapbox.mapboxsdk.testapp.activity.location;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.RectF;
|
||||
import android.location.Location;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -9,6 +10,7 @@ import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.ListPopupWindow;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.Toast;
|
||||
@@ -39,6 +41,7 @@ public class LocationModesActivity extends AppCompatActivity implements OnMapRea
|
||||
private MapView mapView;
|
||||
private Button locationModeBtn;
|
||||
private Button locationTrackingBtn;
|
||||
private View protectedGestureArea;
|
||||
|
||||
private PermissionsManager permissionsManager;
|
||||
|
||||
@@ -64,6 +67,7 @@ public class LocationModesActivity extends AppCompatActivity implements OnMapRea
|
||||
setContentView(R.layout.activity_location_layer_mode);
|
||||
|
||||
mapView = findViewById(R.id.mapView);
|
||||
protectedGestureArea = findViewById(R.id.view_protected_gesture_area);
|
||||
|
||||
locationModeBtn = findViewById(R.id.button_location_mode);
|
||||
locationModeBtn.setOnClickListener(v -> {
|
||||
@@ -245,6 +249,9 @@ public class LocationModesActivity extends AppCompatActivity implements OnMapRea
|
||||
return;
|
||||
}
|
||||
|
||||
protectedGestureArea.getLayoutParams().height = 0;
|
||||
protectedGestureArea.getLayoutParams().width = 0;
|
||||
|
||||
LocationComponentOptions options = locationComponent
|
||||
.getLocationComponentOptions()
|
||||
.toBuilder()
|
||||
@@ -258,10 +265,16 @@ public class LocationModesActivity extends AppCompatActivity implements OnMapRea
|
||||
return;
|
||||
}
|
||||
|
||||
RectF rectF = new RectF(0f, 0f, mapView.getWidth() / 2f, mapView.getHeight() / 2f);
|
||||
protectedGestureArea.getLayoutParams().height = (int) rectF.bottom;
|
||||
protectedGestureArea.getLayoutParams().width = (int) rectF.right;
|
||||
|
||||
LocationComponentOptions options = locationComponent
|
||||
.getLocationComponentOptions()
|
||||
.toBuilder()
|
||||
.trackingGesturesManagement(true)
|
||||
.trackingMultiFingerProtectedMoveArea(rectF)
|
||||
.trackingMultiFingerMoveThreshold(500)
|
||||
.build();
|
||||
locationComponent.applyStyle(options);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,15 @@
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:mapbox_uiAttribution="false" />
|
||||
|
||||
<View
|
||||
android:id="@+id/view_protected_gesture_area"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:alpha="0.5"
|
||||
android:background="@android:color/holo_red_light"
|
||||
app:layout_constraintStart_toStartOf="@id/mapView"
|
||||
app:layout_constraintTop_toTopOf="@id/mapView" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linearLayout"
|
||||
style="?android:attr/buttonBarStyle"
|
||||
|
||||
Reference in New Issue
Block a user