Skip to content

Commit

Permalink
Fix attribution links not opening in some scenarios (#2301)
Browse files Browse the repository at this point in the history
  • Loading branch information
kiryldz authored Mar 8, 2024
1 parent 7fc9bb5 commit 654d3ba
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 24 deletions.
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
Mapbox welcomes participation and contributions from everyone.

# main
## Features ✨ and improvements 🏁
* Added Attribution and Telemetry pop-up dialogs and compass view content description translations for Arabic, Bulgarian, Catalan, Chinese Simplified, Chinese Traditional, Czech, Danish, Dutch, French, Galician, German, Hebrew, Italian, Japanese, Korean, Lithuanian, Norwegian, Polish, Belarusian, Russian, Spanish, Swedish, Ukranian and Vietnamese.

## Breaking changes ⚠️
* [compose] Replace `MapboxMap.compassSettings`, `MapboxMap.scaleBarSettings`, `MapboxMap.logoSettings`, `MapboxMap.attributionSettings` with composable functions in dedicated scopes: `MapCompassScope.Compass()`, `MapScaleBarScope.ScaleBar()`, `MapLogoScope.Logo()`, `MapAttributionScope.Attribution()`.

## Features ✨ and improvements 🏁
* Added Attribution and Telemetry pop-up dialogs and compass view content description translations for Arabic, Bulgarian, Catalan, Chinese Simplified, Chinese Traditional, Czech, Danish, Dutch, French, Galician, German, Hebrew, Italian, Japanese, Korean, Lithuanian, Norwegian, Polish, Belarusian, Russian, Spanish, Swedish, Ukranian and Vietnamese.

## Bug fixes 🐞
* [compose] Fix `ViewAnnotation` not cleared when it leaves composition.
* Fix attribution links not opening in some scenarios.

# 11.2.0 February 29, 2024
## Features ✨ and improvements 🏁
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.mapbox.maps.extension.compose.ornaments.attribution

import android.app.Activity
import android.content.ActivityNotFoundException
import android.content.Intent
import android.net.Uri
Expand Down Expand Up @@ -334,18 +333,22 @@ public class MapAttributionScope internal constructor(
}

private fun showWebPage(url: String) {
if (mapView.context is Activity) {
try {
val intent = Intent(Intent.ACTION_VIEW)
intent.data = Uri.parse(url)
mapView.context.startActivity(intent)
} catch (exception: ActivityNotFoundException) { // explicitly handling if the device hasn't have a web browser installed. #8899
Toast.makeText(
mapView.context,
R.string.mapbox_attributionErrorNoBrowser,
Toast.LENGTH_LONG
).show()
}
try {
val intent = Intent(Intent.ACTION_VIEW)
intent.data = Uri.parse(url)
mapView.context.startActivity(intent)
} catch (exception: ActivityNotFoundException) {
Toast.makeText(
mapView.context,
R.string.mapbox_attributionErrorNoBrowser,
Toast.LENGTH_LONG
).show()
} catch (t: Throwable) {
Toast.makeText(
mapView.context,
t.localizedMessage,
Toast.LENGTH_LONG
).show()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@ class AttributionDialogManagerImpl(
}

private fun showWebPage(url: String) {
if (context is Activity) {
try {
val intent = Intent(Intent.ACTION_VIEW)
intent.data = Uri.parse(url)
context.startActivity(intent)
} catch (exception: ActivityNotFoundException) { // explicitly handling if the device hasn't have a web browser installed. #8899
Toast.makeText(context, R.string.mapbox_attributionErrorNoBrowser, Toast.LENGTH_LONG).show()
}
try {
val intent = Intent(Intent.ACTION_VIEW)
intent.data = Uri.parse(url)
context.applicationContext.startActivity(intent)
} catch (exception: ActivityNotFoundException) {
Toast.makeText(context, R.string.mapbox_attributionErrorNoBrowser, Toast.LENGTH_LONG).show()
} catch (t: Throwable) {
Toast.makeText(context, t.localizedMessage, Toast.LENGTH_LONG).show()
}
}

Expand Down

0 comments on commit 654d3ba

Please sign in to comment.