Disable Chargeprice button for unsupported countries (fixes #117)

This commit is contained in:
johan12345
2021-08-24 08:59:55 +02:00
parent 4ceef7997d
commit cf6c662832
2 changed files with 49 additions and 0 deletions

View File

@@ -74,5 +74,51 @@ interface ChargepriceApi {
.build()
return retrofit.create(ChargepriceApi::class.java)
}
@JvmStatic
fun isCountrySupported(country: String, dataSource: String): Boolean = when (dataSource) {
// list of countries updated 2021/08/24
"goingelectric" -> country in listOf(
"Deutschland",
"Österreich",
"Schweiz",
"Frankreich",
"Belgien",
"Niederlande",
"Luxemburg",
"Dänemark",
"Norwegen",
"Schweden",
"Slowenien",
"Kroatien",
"Ungarn",
"Tschechien",
"Italien",
"Spanien",
"Großbritannien",
"Irland"
)
"openchargemap" -> country in listOf(
"DE",
"AT",
"CH",
"FR",
"BE",
"NE",
"LU",
"DK",
"NO",
"SE",
"SI",
"HR",
"HU",
"CZ",
"IT",
"ES",
"GB",
"IE"
)
else -> false
}
}
}

View File

@@ -25,6 +25,8 @@
<import type="net.vonforst.evmap.api.ChargepointApiKt" />
<import type="net.vonforst.evmap.api.chargeprice.ChargepriceApi" />
<variable
name="charger"
type="Resource&lt;ChargeLocation&gt;" />
@@ -315,6 +317,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/go_to_chargeprice"
app:goneUnless="@{charger.data != null &amp;&amp; ChargepriceApi.isCountrySupported(charger.data.chargepriceData.country, charger.data.dataSource)}"
app:icon="@drawable/ic_chargeprice"
app:layout_constraintEnd_toStartOf="@+id/guideline2"
app:layout_constraintStart_toStartOf="@+id/guideline"