diff --git a/build.gradle b/build.gradle
index 7a296438d..0353498be 100644
--- a/build.gradle
+++ b/build.gradle
@@ -62,7 +62,7 @@ dependencies {
}
implementation 'com.annimon:stream:1.1.8' // brings future java streams api to SDK Version < 24
implementation 'com.codewaves.stickyheadergrid:stickyheadergrid:0.9.4' // glues the current time segment text in the gallery to the top.
- implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:7.3.2'
+ implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:9.2.1'
testImplementation 'junit:junit:4.12'
testImplementation 'junit:junit:4.12'
diff --git a/res/layout/activity_map.xml b/res/layout/activity_map.xml
index f449ebe3e..940c3f623 100644
--- a/res/layout/activity_map.xml
+++ b/res/layout/activity_map.xml
@@ -5,11 +5,16 @@
android:layout_height="match_parent"
tools:context=".map.MapActivity">
-
+ android:layout_height="match_parent"
+ android:id="@+id/inputAwareContainer"
+ >
+
+
-
diff --git a/src/org/thoughtcrime/securesms/map/AddPoiView.java b/src/org/thoughtcrime/securesms/map/AddPoiView.java
index 10d144db9..cc7262f68 100644
--- a/src/org/thoughtcrime/securesms/map/AddPoiView.java
+++ b/src/org/thoughtcrime/securesms/map/AddPoiView.java
@@ -71,4 +71,8 @@ public class AddPoiView extends LinearLayoutCompat {
public void setOnMessageSentListener(SendingTask.OnMessageSentListener listener) {
this.listener = listener;
}
+
+ public EditText getMessageView() {
+ return messageView;
+ }
}
diff --git a/src/org/thoughtcrime/securesms/map/MapActivity.java b/src/org/thoughtcrime/securesms/map/MapActivity.java
index 7f0d55768..4a3f80877 100644
--- a/src/org/thoughtcrime/securesms/map/MapActivity.java
+++ b/src/org/thoughtcrime/securesms/map/MapActivity.java
@@ -28,6 +28,8 @@ import org.thoughtcrime.securesms.BaseActivity;
import org.thoughtcrime.securesms.BuildConfig;
import org.thoughtcrime.securesms.ConversationActivity;
import org.thoughtcrime.securesms.R;
+import org.thoughtcrime.securesms.components.InputAwareLayout;
+import org.thoughtcrime.securesms.components.KeyboardAwareLinearLayout;
import org.thoughtcrime.securesms.components.rangeslider.TimeRangeSlider;
import org.thoughtcrime.securesms.connect.DcHelper;
import org.thoughtcrime.securesms.geolocation.DcLocation;
@@ -48,7 +50,10 @@ import static org.thoughtcrime.securesms.map.MapDataManager.MARKER_SELECTED;
import static org.thoughtcrime.securesms.map.MapDataManager.MESSAGE_ID;
import static org.thoughtcrime.securesms.map.model.MapSource.INFO_WINDOW_LAYER;
-public class MapActivity extends BaseActivity implements Observer, TimeRangeSlider.OnTimestampChangedListener {
+public class MapActivity extends BaseActivity implements Observer,
+ TimeRangeSlider.OnTimestampChangedListener,
+ KeyboardAwareLinearLayout.OnKeyboardShownListener,
+ KeyboardAwareLinearLayout.OnKeyboardHiddenListener {
public static final String TAG = MapActivity.class.getSimpleName();
public static final String CHAT_ID = "chat_id";
@@ -61,6 +66,7 @@ public class MapActivity extends BaseActivity implements Observer, TimeRangeSlid
DCMapFragment mapFragment;
MarkerViewManager markerViewManager;
private int chatId;
+ private InputAwareLayout inputAwareContainer;
public static void lazyMapboxInit(Context context) {
try {
@@ -110,7 +116,9 @@ public class MapActivity extends BaseActivity implements Observer, TimeRangeSlid
this.mapboxMap = mapboxMap;
this.markerViewManager = new MarkerViewManager(mapFragment.getMapView(), mapboxMap);
-
+ inputAwareContainer = findViewById(R.id.inputAwareContainer);
+ inputAwareContainer.addOnKeyboardHiddenListener(this);
+ inputAwareContainer.addOnKeyboardShownListener(this);
final LatLng lastMapCenter = Prefs.getMapCenter(this.getApplicationContext(), chatId);
if (lastMapCenter != null) {
@@ -156,8 +164,7 @@ public class MapActivity extends BaseActivity implements Observer, TimeRangeSlid
handleAddPoiClick(point));
- mapboxMap.addOnMapLongClickListener(point ->
- handlePoiLongClick(point));
+ mapboxMap.addOnMapLongClickListener(this::handlePoiLongClick);
SwitchCompat switchCompat = this.findViewById(R.id.locationTraceSwitch);
switchCompat.setOnCheckedChangeListener((buttonView, isChecked) -> {
@@ -312,13 +319,21 @@ public class MapActivity extends BaseActivity implements Observer, TimeRangeSlid
}
if (markerViewManager.hasMarkers()) {
+ MarkerView markerView = markerViewManager.getCenteredMarker();
+ if (markerView != null && markerView.getView() instanceof AddPoiView) {
+ AddPoiView view = (AddPoiView) markerView.getView();
+ inputAwareContainer.hideCurrentInput(view.getMessageView());
+ }
markerViewManager.removeMarkers();
} else {
AddPoiView addPoiView = new AddPoiView(this);
addPoiView.setLatLng(point);
addPoiView.setChatId(chatId);
addPoiView.setOnMessageSentListener(markerViewManager);
- markerViewManager.addMarker(new MarkerView(point, addPoiView));
+ MarkerView markerView = new MarkerView(point, addPoiView);
+ markerViewManager.addMarker(markerView);
+ inputAwareContainer.showSoftkey(addPoiView.getMessageView());
+ markerViewManager.center(markerView);
}
return true;
}
@@ -349,4 +364,13 @@ public class MapActivity extends BaseActivity implements Observer, TimeRangeSlid
return false;
}
+ @Override
+ public void onKeyboardHidden() {
+ markerViewManager.onKeyboardShown(0);
+ }
+
+ @Override
+ public void onKeyboardShown() {
+ markerViewManager.onKeyboardShown(inputAwareContainer.getKeyboardHeight());
+ }
}
diff --git a/src/org/thoughtcrime/securesms/map/MarkerView.java b/src/org/thoughtcrime/securesms/map/MarkerView.java
index 4082abb95..71946e700 100644
--- a/src/org/thoughtcrime/securesms/map/MarkerView.java
+++ b/src/org/thoughtcrime/securesms/map/MarkerView.java
@@ -45,6 +45,10 @@ public class MarkerView {
update();
}
+ public LatLng getLatLng() {
+ return latLng;
+ }
+
/**
* Set a callback to be invoked when position placement is calculated.
*
diff --git a/src/org/thoughtcrime/securesms/map/MarkerViewManager.java b/src/org/thoughtcrime/securesms/map/MarkerViewManager.java
index 6a1a00b8d..9cf94927a 100644
--- a/src/org/thoughtcrime/securesms/map/MarkerViewManager.java
+++ b/src/org/thoughtcrime/securesms/map/MarkerViewManager.java
@@ -3,6 +3,9 @@ package org.thoughtcrime.securesms.map;
import androidx.annotation.NonNull;
import androidx.annotation.UiThread;
+import com.mapbox.mapboxsdk.camera.CameraPosition;
+import com.mapbox.mapboxsdk.camera.CameraUpdate;
+import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
@@ -18,6 +21,8 @@ public class MarkerViewManager implements MapView.OnDidFinishRenderingFrameListe
private final MapboxMap mapboxMap;
private final List markers = new ArrayList<>();
private boolean initialised;
+ private MarkerView centeredMarker;
+ private int keyboardHeight = 0;
/**
* Create a MarkerViewManager.
@@ -90,6 +95,8 @@ public class MarkerViewManager implements MapView.OnDidFinishRenderingFrameListe
for (MarkerView markerView : markers) {
mapView.removeView(markerView.getView());
}
+
+ centeredMarker = null;
markers.clear();
}
@@ -110,4 +117,34 @@ public class MarkerViewManager implements MapView.OnDidFinishRenderingFrameListe
public void onMessageSent() {
removeMarkers();
}
+
+ @UiThread
+ public void center(MarkerView view) {
+ centeredMarker = view;
+ view.getView().post(() -> {
+ int markerWidth = view.getView().getWidth();
+ CameraPosition currentPosition = mapboxMap.getCameraPosition();
+ CameraUpdate cameraUpdate = CameraUpdateFactory.newCameraPosition(
+ new CameraPosition.Builder().
+ target(view.getLatLng()).
+ bearing(currentPosition.bearing).
+ tilt(currentPosition.tilt).
+ zoom(currentPosition.zoom).
+ padding(0d , 0d, markerWidth / 2d, keyboardHeight).
+ build());
+ mapboxMap.easeCamera(cameraUpdate);
+ });
+ }
+
+ MarkerView getCenteredMarker() {
+ return centeredMarker;
+ }
+
+ @UiThread
+ void onKeyboardShown(int keyboardHeight) {
+ this.keyboardHeight = keyboardHeight;
+ if (centeredMarker != null) {
+ center(centeredMarker);
+ }
+ }
}