Author: Adam Evyčędo <git@apiote.xyz>
support c responses
app/src/main/java/xyz/apiote/bimba/czwek/api/Api.kt | 37 ++++++++++++-- app/src/main/res/drawable/error_accept.xml | 11 ++++ app/src/main/res/values/strings.xml | 1
diff --git a/app/src/main/java/xyz/apiote/bimba/czwek/api/Api.kt b/app/src/main/java/xyz/apiote/bimba/czwek/api/Api.kt index 64e559277e1b76d14ecfe65b0746196cbe9e9e57..00f07b1aab4839fa64de9b894f87b72fe3ee4e55 100644 --- a/app/src/main/java/xyz/apiote/bimba/czwek/api/Api.kt +++ b/app/src/main/java/xyz/apiote/bimba/czwek/api/Api.kt @@ -58,7 +58,7 @@ suspend fun getFeeds(cm: ConnectivityManager, server: Server): Result { return try { rawRequest( - URL("${server.apiPath}/"), server, cm, arrayOf(1u) + URL("${server.apiPath}/"), server, cm, arrayOf(1u, 2u) ) } catch (_: MalformedURLException) { Result(null, Error(0, R.string.error_url, R.drawable.error_url)) @@ -72,7 +72,15 @@ val params = mutableMapOf("q" to query) if (limit != null) { params["limit"] = limit.toString() } - return request(server, "queryables", null, params, cm, arrayOf(1u, 2u), null) + return request( + server, + "queryables", + null, + params, + cm, + arrayOf(1u, 2u, 3u), + null + ) } suspend fun locateQueryables(cm: ConnectivityManager, server: Server, near: PositionV1): Result { @@ -82,7 +90,7 @@ "queryables", null, mapOf("near" to near.toString()), cm, - arrayOf(1u, 2u), + arrayOf(1u, 2u, 3u), null ) } @@ -96,13 +104,21 @@ "locatables", null, mapOf("lb" to bl.toString(), "rt" to tr.toString()), cm, - arrayOf(1u, 2u), + arrayOf(1u, 2u, 3u), null ) } suspend fun getLine(cm: ConnectivityManager, server: Server, feedID: String, line: String): Result { - return request(server, "lines", line, mapOf(), cm, arrayOf(1u), feedID) + return request( + server, + "lines", + line, + mapOf(), + cm, + arrayOf(1u, 2u), + feedID + ) } suspend fun getDepartures( @@ -112,7 +128,15 @@ val params = mutableMapOf("code" to stop) if (line != null) { params["line"] = line } - return request(server, "departures", null, params, cm, arrayOf(1u, 2u), feedID) + return request( + server, + "departures", + null, + params, + cm, + arrayOf(1u, 2u, 3u), + feedID + ) } suspend fun rawRequest( @@ -136,6 +160,7 @@ 400 -> Pair(R.string.error_400, R.drawable.error_app) 401 -> Pair(R.string.error_401, R.drawable.error_sec) 403 -> Pair(R.string.error_403, R.drawable.error_sec) 404 -> Pair(R.string.error_404, R.drawable.error_search) + 406 -> Pair(R.string.error_406, R.drawable.error_accept) 429 -> Pair(R.string.error_429, R.drawable.error_limit) 500 -> Pair(R.string.error_50x, R.drawable.error_server) 502 -> Pair(R.string.error_50x, R.drawable.error_server) diff --git a/app/src/main/res/drawable/error_accept.xml b/app/src/main/res/drawable/error_accept.xml new file mode 100644 index 0000000000000000000000000000000000000000..f4ad7b4f999940ed57c21dc0a315a73e5568baf4 --- /dev/null +++ b/app/src/main/res/drawable/error_accept.xml @@ -0,0 +1,11 @@ +<!-- +SPDX-FileCopyrightText: Google + +SPDX-License-Identifier: Apache-2.0 +--> + +<vector android:autoMirrored="true" android:height="24dp" + android:tint="?attr/colorOnSurface" android:viewportHeight="24" + android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> + <path android:fillColor="@android:color/white" android:pathData="M9.01,14H2v2h7.01v3L13,15l-3.99,-4V14zM14.99,13v-3H22V8h-7.01V5L11,9L14.99,13z"/> +</vector> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index bb318f8b3b8560f527858737a74b1f5de2929e9d..2243ddb33dcaf64b8b83cfb29f41dda6e5cb5497 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -110,4 +110,5 @@link to Mastodon <string name="use_online_feed">Use online feed</string> <string name="information_may_be_outdated">Information may be outdated</string> <string name="current_timetable_validity">Current timetable valid: %1$s to %2$s</string> + <string name="error_406">App version is not compatible with the server</string> </resources> \ No newline at end of file