diff --git a/changelog.d/6247.bugfix b/changelog.d/6247.bugfix new file mode 100644 index 0000000000..260c059212 --- /dev/null +++ b/changelog.d/6247.bugfix @@ -0,0 +1 @@ +Fix copyright attributions of map views diff --git a/library/ui-styles/src/main/res/values/dimens_font.xml b/library/ui-styles/src/main/res/values/dimens_font.xml index 1b5a826acb..ad8f012a16 100644 --- a/library/ui-styles/src/main/res/values/dimens_font.xml +++ b/library/ui-styles/src/main/res/values/dimens_font.xml @@ -7,7 +7,8 @@ 14sp 12sp 10sp + 8sp 14sp - \ No newline at end of file + diff --git a/library/ui-styles/src/main/res/values/styles_location.xml b/library/ui-styles/src/main/res/values/styles_location.xml index 9d9fc862f6..6777450a63 100644 --- a/library/ui-styles/src/main/res/values/styles_location.xml +++ b/library/ui-styles/src/main/res/values/styles_location.xml @@ -40,4 +40,9 @@ center + + diff --git a/library/ui-styles/src/main/res/values/styles_text_view.xml b/library/ui-styles/src/main/res/values/styles_text_view.xml index 77e32da345..0dcaf30f48 100644 --- a/library/ui-styles/src/main/res/values/styles_text_view.xml +++ b/library/ui-styles/src/main/res/values/styles_text_view.xml @@ -48,4 +48,9 @@ 16sp - \ No newline at end of file + + + diff --git a/library/ui-styles/src/main/res/values/text_appearances.xml b/library/ui-styles/src/main/res/values/text_appearances.xml index 8e30dd00d6..1e60e05acf 100644 --- a/library/ui-styles/src/main/res/values/text_appearances.xml +++ b/library/ui-styles/src/main/res/values/text_appearances.xml @@ -85,4 +85,11 @@ 0.02 + + diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/AbsMessageLocationItem.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/AbsMessageLocationItem.kt index 935d5e9aa1..ee3a9f6746 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/AbsMessageLocationItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/AbsMessageLocationItem.kt @@ -85,6 +85,7 @@ abstract class AbsMessageLocationItem : AbsMe ): Boolean { holder.staticMapPinImageView.setImageResource(R.drawable.ic_location_pin_failed) holder.staticMapErrorTextView.isVisible = true + holder.staticMapCopyrightTextView.isVisible = false return false } @@ -100,6 +101,7 @@ abstract class AbsMessageLocationItem : AbsMe holder.staticMapPinImageView.setImageDrawable(pinDrawable) } holder.staticMapErrorTextView.isVisible = false + holder.staticMapCopyrightTextView.isVisible = true return false } }) @@ -111,5 +113,6 @@ abstract class AbsMessageLocationItem : AbsMe val staticMapImageView by bind(R.id.staticMapImageView) val staticMapPinImageView by bind(R.id.staticMapPinImageView) val staticMapErrorTextView by bind(R.id.staticMapErrorTextView) + val staticMapCopyrightTextView by bind(R.id.staticMapCopyrightTextView) } } diff --git a/vector/src/main/java/im/vector/app/features/location/MapTilerMapView.kt b/vector/src/main/java/im/vector/app/features/location/MapTilerMapView.kt index dd2a56fb3a..1f9cb44c91 100644 --- a/vector/src/main/java/im/vector/app/features/location/MapTilerMapView.kt +++ b/vector/src/main/java/im/vector/app/features/location/MapTilerMapView.kt @@ -33,6 +33,7 @@ import com.mapbox.mapboxsdk.plugins.annotation.SymbolManager import com.mapbox.mapboxsdk.plugins.annotation.SymbolOptions import com.mapbox.mapboxsdk.style.layers.Property import im.vector.app.R +import im.vector.app.core.utils.DimensionConverter import timber.log.Timber class MapTilerMapView @JvmOverloads constructor( @@ -56,6 +57,7 @@ class MapTilerMapView @JvmOverloads constructor( private var mapRefs: MapRefs? = null private var initZoomDone = false private var showLocationButton = false + private var dimensionConverter: DimensionConverter? = null init { context.theme.obtainStyledAttributes( @@ -70,6 +72,7 @@ class MapTilerMapView @JvmOverloads constructor( recycle() } } + dimensionConverter = DimensionConverter(resources) } private fun setLocateButtonVisibility(typedArray: TypedArray) { @@ -151,7 +154,12 @@ class MapTilerMapView @JvmOverloads constructor( pendingState = state } - safeMapRefs.map.uiSettings.setLogoMargins(0, 0, 0, state.logoMarginBottom) + safeMapRefs.map.uiSettings.apply { + setLogoMargins(0, 0, 0, state.logoMarginBottom) + dimensionConverter?.let { + setAttributionMargins(it.dpToPx(88), 0, 0, state.logoMarginBottom) + } + } val pinDrawable = state.pinDrawable ?: userLocationDrawable pinDrawable?.let { drawable -> diff --git a/vector/src/main/java/im/vector/app/features/location/UrlMapProvider.kt b/vector/src/main/java/im/vector/app/features/location/UrlMapProvider.kt index f0d1581724..f043006d70 100644 --- a/vector/src/main/java/im/vector/app/features/location/UrlMapProvider.kt +++ b/vector/src/main/java/im/vector/app/features/location/UrlMapProvider.kt @@ -17,8 +17,6 @@ package im.vector.app.features.location import im.vector.app.BuildConfig -import im.vector.app.core.resources.LocaleProvider -import im.vector.app.core.resources.isRTL import im.vector.app.features.raw.wellknown.getElementWellknown import org.matrix.android.sdk.api.extensions.tryOrNull import org.matrix.android.sdk.api.raw.RawService @@ -26,7 +24,6 @@ import org.matrix.android.sdk.api.session.Session import javax.inject.Inject class UrlMapProvider @Inject constructor( - private val localeProvider: LocaleProvider, private val session: Session, private val rawService: RawService ) { @@ -63,10 +60,8 @@ class UrlMapProvider @Inject constructor( append(height) append(".png") append(keyParam) - if (!localeProvider.isRTL()) { - // On LTR languages we want the legal mentions to be displayed on the bottom left of the image - append("&attribution=bottomleft") - } + // Since the default copyright font is too small we put a custom one on map + append("&attribution=false") } } } 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 9a4975e2e0..5f2410d697 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 @@ -25,6 +25,7 @@ import androidx.core.graphics.drawable.toBitmap import androidx.lifecycle.lifecycleScope import com.airbnb.mvrx.fragmentViewModel import com.airbnb.mvrx.withState +import com.google.android.material.bottomsheet.BottomSheetBehavior import com.mapbox.mapboxsdk.geometry.LatLng import com.mapbox.mapboxsdk.geometry.LatLngBounds import com.mapbox.mapboxsdk.maps.MapView @@ -40,6 +41,7 @@ import im.vector.app.R 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.databinding.FragmentLocationLiveMapViewBinding import im.vector.app.features.location.UrlMapProvider import im.vector.app.features.location.zoomToBounds @@ -58,6 +60,7 @@ class LocationLiveMapViewFragment @Inject constructor() : VectorBaseFragment + val bottomSheetHeight = BottomSheetBehavior.from(views.bottomSheet).peekHeight + mapboxMap.uiSettings.apply { + // Place copyright above the user list bottom sheet + setLogoMargins(dimensionConverter.dpToPx(8), 0, 0, bottomSheetHeight + dimensionConverter.dpToPx(8)) + setAttributionMargins(dimensionConverter.dpToPx(96), 0, 0, bottomSheetHeight + dimensionConverter.dpToPx(8)) + } + lifecycleScope.launch { mapboxMap.setStyle(urlMapProvider.getMapUrl()) { style -> mapStyle = style 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 9b576c6485..0be45197f1 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 @@ -16,8 +16,8 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/bg_live_location_users_bottom_sheet" - app:behavior_peekHeight="200dp" app:behavior_hideable="false" + app:behavior_peekHeight="200dp" app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"> + + diff --git a/vector/src/main/res/values/donottranslate.xml b/vector/src/main/res/values/donottranslate.xml index eb8efa0ad2..d58bdbadfb 100755 --- a/vector/src/main/res/values/donottranslate.xml +++ b/vector/src/main/res/values/donottranslate.xml @@ -42,4 +42,6 @@ To confirm your email address, tap the button in the email we just sent to %s Did not receive an email? Resend email + + © MapTiler © OpenStreetMap contributors