Add support for opening openchargemap.org links in EVMap

This commit is contained in:
johan12345
2022-11-13 14:14:08 +01:00
parent 0f525a6c48
commit 0ed82d15ff
4 changed files with 38 additions and 0 deletions

View File

@@ -252,6 +252,10 @@
android:host="www.goingelectric.de"
android:pathPattern="/stromtankstellen/Ungarn/..*/..*/..*/"
android:scheme="https" />
<data
android:host="openchargemap.org"
android:pathPattern="/site/poi/details/..*"
android:scheme="https" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

View File

@@ -8,6 +8,7 @@ import android.os.Build
import android.os.Bundle
import android.os.SystemClock
import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.browser.customtabs.CustomTabColorSchemeParams
import androidx.browser.customtabs.CustomTabsIntent
@@ -131,6 +132,37 @@ class MapsActivity : AppCompatActivity(),
} else if (intent?.scheme == "https" && intent?.data?.host == "www.goingelectric.de") {
val id = intent.data?.pathSegments?.last()?.toLongOrNull()
if (id != null) {
if (prefs.dataSource != "goingelectric") {
prefs.dataSource = "goingelectric"
Toast.makeText(
this,
getString(
R.string.data_source_switched_to,
getString(R.string.data_source_goingelectric)
),
Toast.LENGTH_LONG
).show()
}
deepLink = navController.createDeepLink()
.setGraph(R.navigation.nav_graph)
.setDestination(R.id.map)
.setArguments(MapFragmentArgs(chargerId = id).toBundle())
.createPendingIntent()
}
} else if (intent?.scheme == "https" && intent?.data?.host == "openchargemap.org") {
val id = intent.data?.pathSegments?.last()?.toLongOrNull()
if (id != null) {
if (prefs.dataSource != "openchargemap") {
prefs.dataSource = "openchargemap"
Toast.makeText(
this,
getString(
R.string.data_source_switched_to,
getString(R.string.data_source_openchargemap)
),
Toast.LENGTH_LONG
).show()
}
deepLink = navController.createDeepLink()
.setGraph(R.navigation.nav_graph)
.setDestination(R.id.map)

View File

@@ -283,4 +283,5 @@
<string name="pref_prediction_enabled_summary">für unterstützte Ladestationen\n(momentan nur Schnellader in Deutschland)</string>
<string name="prediction_only">(nur %s)</string>
<string name="prediction_dc_plugs_only">DC-Anschlüsse</string>
<string name="data_source_switched_to">Datenquelle zu %s umgeschaltet</string>
</resources>

View File

@@ -282,4 +282,5 @@
<string name="pref_prediction_enabled_summary">for supported chargers\n(currently only DC in Germany)</string>
<string name="prediction_only">(%s only)</string>
<string name="prediction_dc_plugs_only">DC plugs</string>
<string name="data_source_switched_to">Data source switched to %s</string>
</resources>