diff --git a/changelog.d/6567.feature b/changelog.d/6567.feature new file mode 100644 index 0000000000..9624c57a66 --- /dev/null +++ b/changelog.d/6567.feature @@ -0,0 +1 @@ +Share location with other apps diff --git a/vector/src/main/java/im/vector/app/features/location/live/map/LocationLiveMapMarkerOptionsDialog.kt b/vector/src/main/java/im/vector/app/features/location/live/map/LocationLiveMapMarkerOptionsDialog.kt new file mode 100644 index 0000000000..5f9d4a4db5 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/location/live/map/LocationLiveMapMarkerOptionsDialog.kt @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.app.features.location.live.map + +import android.content.Context +import android.view.View +import android.view.ViewGroup +import android.widget.PopupWindow +import im.vector.app.R +import im.vector.app.databinding.ViewLiveLocationMarkerPopupBinding + +class LocationLiveMapMarkerOptionsDialog( + context: Context, +) : PopupWindow() { + + interface Callback { + fun onShareLocationClicked() + } + + private val views: ViewLiveLocationMarkerPopupBinding + + var callback: Callback? = null + + init { + contentView = View.inflate(context, R.layout.view_live_location_marker_popup, null) + + views = ViewLiveLocationMarkerPopupBinding.bind(contentView) + + width = ViewGroup.LayoutParams.WRAP_CONTENT + height = ViewGroup.LayoutParams.WRAP_CONTENT + inputMethodMode = INPUT_METHOD_NOT_NEEDED + isFocusable = true + isTouchable = true + + contentView.setOnClickListener { + callback?.onShareLocationClicked() + } + } + + fun show(anchorView: View) { + contentView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED) + // By default the left side of the dialog is aligned with the pin. We need shift it to the left to make it's center aligned with the pin. + showAsDropDown(anchorView, -contentView.measuredWidth / 2, 0) + } +} diff --git a/vector/src/main/java/im/vector/app/features/location/live/map/LocationLiveMapViewFragment.kt b/vector/src/main/java/im/vector/app/features/location/live/map/LocationLiveMapViewFragment.kt index a57ba74685..1d6afa9cda 100644 --- a/vector/src/main/java/im/vector/app/features/location/live/map/LocationLiveMapViewFragment.kt +++ b/vector/src/main/java/im/vector/app/features/location/live/map/LocationLiveMapViewFragment.kt @@ -33,6 +33,7 @@ import com.mapbox.mapboxsdk.maps.MapboxMap import com.mapbox.mapboxsdk.maps.MapboxMapOptions import com.mapbox.mapboxsdk.maps.Style import com.mapbox.mapboxsdk.maps.SupportMapFragment +import com.mapbox.mapboxsdk.plugins.annotation.Symbol import com.mapbox.mapboxsdk.plugins.annotation.SymbolManager import com.mapbox.mapboxsdk.plugins.annotation.SymbolOptions import com.mapbox.mapboxsdk.style.layers.Property @@ -42,6 +43,7 @@ import im.vector.app.core.extensions.addChildFragment import im.vector.app.core.extensions.configureWith import im.vector.app.core.platform.VectorBaseFragment import im.vector.app.core.utils.DimensionConverter +import im.vector.app.core.utils.openLocation import im.vector.app.databinding.FragmentLocationLiveMapViewBinding import im.vector.app.features.location.UrlMapProvider import im.vector.app.features.location.zoomToBounds @@ -120,6 +122,10 @@ class LocationLiveMapViewFragment @Inject constructor() : VectorBaseFragment + + + + diff --git a/vector/src/main/res/layout/fragment_location_live_map_view.xml b/vector/src/main/res/layout/fragment_location_live_map_view.xml index 0be45197f1..c5e978e4ee 100644 --- a/vector/src/main/res/layout/fragment_location_live_map_view.xml +++ b/vector/src/main/res/layout/fragment_location_live_map_view.xml @@ -6,6 +6,11 @@ android:layout_height="match_parent" android:background="@drawable/bg_live_location_users_bottom_sheet"> + + + + + + + + + diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index a03684d72a..e99c1065e5 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -3116,6 +3116,7 @@ Stop sharing Updated %1$s ago + Share location Show Message bubbles