mirror of
https://github.com/ev-map/EVMap.git
synced 2026-02-07 05:30:59 -05:00
don't crash when no sharing app is found
This commit is contained in:
@@ -342,12 +342,20 @@ class MapsActivity : AppCompatActivity(),
|
||||
}
|
||||
}
|
||||
|
||||
fun shareUrl(url: String) {
|
||||
fun shareUrl(url: String, rootView: View) {
|
||||
val intent = Intent(Intent.ACTION_SEND).apply {
|
||||
type = "text/plain"
|
||||
putExtra(Intent.EXTRA_TEXT, url)
|
||||
}
|
||||
startActivity(intent)
|
||||
try {
|
||||
startActivity(intent)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
Snackbar.make(
|
||||
rootView,
|
||||
R.string.no_share_app_found,
|
||||
Snackbar.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPreferenceStartFragment(
|
||||
|
||||
@@ -513,7 +513,7 @@ class MapFragment : Fragment(), OnMapReadyCallback, MenuProvider {
|
||||
R.id.menu_share -> {
|
||||
val charger = vm.charger.value?.data
|
||||
if (charger != null && charger.url != null) {
|
||||
(activity as? MapsActivity)?.shareUrl(charger.url)
|
||||
(activity as? MapsActivity)?.shareUrl(charger.url, binding.root)
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<string name="no_maps_app_found">Bitte installiere eine Navigations-App</string>
|
||||
<string name="no_browser_app_found">Bitte installiere einen Webbrowser</string>
|
||||
<string name="no_email_app_found">Bitte installiere eine E-Mail-App</string>
|
||||
<string name="no_share_app_found">Keine App zum Teilen gefunden</string>
|
||||
<string name="address">Adresse</string>
|
||||
<string name="operator">Betreiber</string>
|
||||
<string name="network">Verbund</string>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<string name="no_maps_app_found">Install a navigation app first</string>
|
||||
<string name="no_browser_app_found">Install a web browser first</string>
|
||||
<string name="no_email_app_found">Install an email app first</string>
|
||||
<string name="no_share_app_found">Could not find an app to share with</string>
|
||||
<string name="address">Address</string>
|
||||
<string name="operator">Operator</string>
|
||||
<string name="network">Network</string>
|
||||
|
||||
Reference in New Issue
Block a user