From b455bf04aa78cf45165f89a5a2cf443b97dae3e8 Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Tue, 7 Jun 2022 15:07:41 +0300 Subject: [PATCH 1/9] Create new styles for map view copyright text. --- library/ui-styles/src/main/res/values/dimens_font.xml | 3 ++- library/ui-styles/src/main/res/values/styles_location.xml | 5 +++++ library/ui-styles/src/main/res/values/styles_text_view.xml | 7 ++++++- library/ui-styles/src/main/res/values/text_appearances.xml | 7 +++++++ 4 files changed, 20 insertions(+), 2 deletions(-) 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 + + From b284b92464adbf12a86febc78a958324581f74f4 Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Tue, 7 Jun 2022 15:11:23 +0300 Subject: [PATCH 2/9] Use custom TextView for map view copyright. --- .../detail/timeline/item/AbsMessageLocationItem.kt | 3 +++ .../im/vector/app/features/location/UrlMapProvider.kt | 6 ++---- .../res/layout/item_timeline_event_location_stub.xml | 10 ++++++++++ vector/src/main/res/values/strings.xml | 1 + 4 files changed, 16 insertions(+), 4 deletions(-) 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..300b7785f5 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.mapCopyrightTextView.isVisible = false return false } @@ -100,6 +101,7 @@ abstract class AbsMessageLocationItem : AbsMe holder.staticMapPinImageView.setImageDrawable(pinDrawable) } holder.staticMapErrorTextView.isVisible = false + holder.mapCopyrightTextView.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 mapCopyrightTextView by bind(R.id.mapCopyrightTextView) } } 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..8952ba8c15 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 @@ -63,10 +63,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=0") } } } diff --git a/vector/src/main/res/layout/item_timeline_event_location_stub.xml b/vector/src/main/res/layout/item_timeline_event_location_stub.xml index d99ac9fa26..5f895b6bff 100644 --- a/vector/src/main/res/layout/item_timeline_event_location_stub.xml +++ b/vector/src/main/res/layout/item_timeline_event_location_stub.xml @@ -62,4 +62,14 @@ android:orientation="horizontal" app:layout_constraintGuide_percent="0.5" /> + + diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index 788dee1bc3..25ded45616 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -3036,6 +3036,7 @@ Temporary implementation: locations persist in room history Stop sharing Updated %1$s ago + © MapTiler © OpenStreetMap contributors Show Message bubbles From ec1eb495a771e48763096e9b4ecace591a8d9e59 Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Tue, 7 Jun 2022 16:06:04 +0300 Subject: [PATCH 3/9] Fix position of the copyright on maximized map. --- .../im/vector/app/features/location/UrlMapProvider.kt | 1 - .../location/live/map/LocationLiveMapViewFragment.kt | 8 ++++++++ .../main/res/layout/fragment_location_live_map_view.xml | 2 +- .../main/res/layout/item_timeline_event_location_stub.xml | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) 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 8952ba8c15..74382cf7dd 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 @@ -18,7 +18,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 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..88a032041a 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 @@ -40,6 +40,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 +59,7 @@ class LocationLiveMapViewFragment @Inject constructor() : VectorBaseFragment + mapboxMap.uiSettings.apply { + // Place copyright above the user list bottom sheet + setLogoMargins(dimensionConverter.dpToPx(8), 0, 0, dimensionConverter.dpToPx(208)) + setAttributionMargins(dimensionConverter.dpToPx(96), 0, 0, dimensionConverter.dpToPx(208)) + } + 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"> Date: Tue, 7 Jun 2022 16:19:00 +0300 Subject: [PATCH 4/9] Changelog added. --- changelog.d/6247.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/6247.bugfix 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 From 68c6e524d288b2fe5d6fba0040309609a47c1c5c Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Tue, 7 Jun 2022 18:22:09 +0300 Subject: [PATCH 5/9] Use dynamic height to calculate the position of the copyright attributes. --- .../location/live/map/LocationLiveMapViewFragment.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 88a032041a..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 @@ -96,10 +97,11 @@ 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, dimensionConverter.dpToPx(208)) - setAttributionMargins(dimensionConverter.dpToPx(96), 0, 0, dimensionConverter.dpToPx(208)) + setLogoMargins(dimensionConverter.dpToPx(8), 0, 0, bottomSheetHeight + dimensionConverter.dpToPx(8)) + setAttributionMargins(dimensionConverter.dpToPx(96), 0, 0, bottomSheetHeight + dimensionConverter.dpToPx(8)) } lifecycleScope.launch { From adde210cfd6b310f2dce6ea5b9916501adcdfcc6 Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Wed, 8 Jun 2022 12:37:48 +0300 Subject: [PATCH 6/9] Code review fixes. --- .../room/detail/timeline/item/AbsMessageLocationItem.kt | 6 +++--- .../java/im/vector/app/features/location/UrlMapProvider.kt | 3 +-- .../main/res/layout/item_timeline_event_location_stub.xml | 2 +- vector/src/main/res/values/donottranslate.xml | 2 ++ vector/src/main/res/values/strings.xml | 1 - 5 files changed, 7 insertions(+), 7 deletions(-) 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 300b7785f5..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,7 +85,7 @@ abstract class AbsMessageLocationItem : AbsMe ): Boolean { holder.staticMapPinImageView.setImageResource(R.drawable.ic_location_pin_failed) holder.staticMapErrorTextView.isVisible = true - holder.mapCopyrightTextView.isVisible = false + holder.staticMapCopyrightTextView.isVisible = false return false } @@ -101,7 +101,7 @@ abstract class AbsMessageLocationItem : AbsMe holder.staticMapPinImageView.setImageDrawable(pinDrawable) } holder.staticMapErrorTextView.isVisible = false - holder.mapCopyrightTextView.isVisible = true + holder.staticMapCopyrightTextView.isVisible = true return false } }) @@ -113,6 +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 mapCopyrightTextView by bind(R.id.mapCopyrightTextView) + val staticMapCopyrightTextView by bind(R.id.staticMapCopyrightTextView) } } 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 74382cf7dd..1348662e75 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 @@ -25,7 +25,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,7 +62,7 @@ class UrlMapProvider @Inject constructor( append(".png") append(keyParam) // Since the default copyright font is too small we put a custom one on map - append("&attribution=0") + append("&attribution=false") } } } diff --git a/vector/src/main/res/layout/item_timeline_event_location_stub.xml b/vector/src/main/res/layout/item_timeline_event_location_stub.xml index 83d81a6a7f..a696140669 100644 --- a/vector/src/main/res/layout/item_timeline_event_location_stub.xml +++ b/vector/src/main/res/layout/item_timeline_event_location_stub.xml @@ -63,7 +63,7 @@ app:layout_constraintGuide_percent="0.5" /> 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 diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index 25ded45616..788dee1bc3 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -3036,7 +3036,6 @@ Temporary implementation: locations persist in room history Stop sharing Updated %1$s ago - © MapTiler © OpenStreetMap contributors Show Message bubbles From d0ab6af0b779de97c7601ed9ac150471c1ec1153 Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Wed, 8 Jun 2022 13:03:48 +0300 Subject: [PATCH 7/9] Remove unused import. --- .../main/java/im/vector/app/features/location/UrlMapProvider.kt | 1 - 1 file changed, 1 deletion(-) 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 1348662e75..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,7 +17,6 @@ package im.vector.app.features.location import im.vector.app.BuildConfig -import im.vector.app.core.resources.LocaleProvider import im.vector.app.features.raw.wellknown.getElementWellknown import org.matrix.android.sdk.api.extensions.tryOrNull import org.matrix.android.sdk.api.raw.RawService From 9b22880d57412e93b424270ac419f6d52c267829 Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Wed, 8 Jun 2022 15:18:25 +0300 Subject: [PATCH 8/9] Set translatable as false for the copyright text. --- vector/src/main/res/values/donottranslate.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vector/src/main/res/values/donottranslate.xml b/vector/src/main/res/values/donottranslate.xml index 5368e1bab3..d58bdbadfb 100755 --- a/vector/src/main/res/values/donottranslate.xml +++ b/vector/src/main/res/values/donottranslate.xml @@ -43,5 +43,5 @@ Did not receive an email? Resend email - © MapTiler © OpenStreetMap contributors + © MapTiler © OpenStreetMap contributors From f9f1b3e39af8154ec7281f774a05e443ba68764c Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Thu, 9 Jun 2022 13:09:10 +0300 Subject: [PATCH 9/9] Code review fix. --- .../im/vector/app/features/location/MapTilerMapView.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 ->