diff --git a/app/build.gradle b/app/build.gradle index 98688b6..b7e6bb0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,7 +6,7 @@ android { buildToolsVersion "28.0.3" defaultConfig { applicationId "telegra.ph" - minSdkVersion 17 + minSdkVersion 19 targetSdkVersion 28 versionCode 15 versionName "1.5.2" @@ -34,6 +34,7 @@ dependencies { implementation 'com.github.delight-im:Android-AdvancedWebView:3.1.3' implementation 'com.afollestad.material-dialogs:core:2.0.0-rc10' implementation 'com.afollestad.material-dialogs:input:2.0.0-rc10' - implementation 'com.github.kittinunf.fuel:fuel:1.16.0' - implementation 'com.github.kittinunf.fuel:fuel-android:1.16.0' + implementation 'com.github.kittinunf.fuel:fuel:2.0.1' + implementation 'com.github.kittinunf.fuel:fuel-android:2.0.1' + implementation 'com.github.kittinunf.fuel:fuel-json:2.0.1' } diff --git a/app/src/main/java/telegra/ph/TelegraphApi.kt b/app/src/main/java/telegra/ph/TelegraphApi.kt index e078f3c..e6e1e63 100644 --- a/app/src/main/java/telegra/ph/TelegraphApi.kt +++ b/app/src/main/java/telegra/ph/TelegraphApi.kt @@ -1,14 +1,13 @@ package telegra.ph -import com.github.kittinunf.fuel.android.core.Json -import com.github.kittinunf.fuel.android.extension.responseJson import com.github.kittinunf.fuel.core.FuelError import com.github.kittinunf.fuel.core.FuelManager import com.github.kittinunf.fuel.core.Request import com.github.kittinunf.fuel.core.Response import com.github.kittinunf.fuel.core.interceptors.redirectResponseInterceptor -import com.github.kittinunf.fuel.core.interceptors.validatorResponseInterceptor import com.github.kittinunf.fuel.httpPost +import com.github.kittinunf.fuel.json.FuelJson +import com.github.kittinunf.fuel.json.responseJson import com.github.kittinunf.result.Result import org.json.JSONArray import org.json.JSONObject @@ -27,12 +26,11 @@ object TelegraphApi { // Fix login FuelManager.instance.addResponseInterceptor { redirectResponseInterceptor(FuelManager.instance) - validatorResponseInterceptor(200..299) it } } - private fun callService(method: String, parameters: List>, handler: (Request, Response, Result) -> Unit) { + private fun callService(method: String, parameters: List>, handler: (Request, Response, Result) -> Unit) { val requestObject = JSONObject() parameters.forEach { requestObject.put(it.first, it.second) @@ -153,7 +151,7 @@ object TelegraphApi { // Teleposter - private fun handleResponse(result: Result, handler: (success: Boolean, obj: T?, error: String?) -> Unit, callback: (obj: JSONObject) -> Unit) { + private fun handleResponse(result: Result, handler: (success: Boolean, obj: T?, error: String?) -> Unit, callback: (obj: JSONObject) -> Unit) { val (json, error) = result if (error == null && json != null) { val jsonObj = json.obj() @@ -182,8 +180,8 @@ object TelegraphApi { private fun telegraphLoginInterceptor(): (Request, Response) -> Response = { _, response -> response.headers["Set-Cookie"] - ?.flatMap { HttpCookie.parse(it) } - ?.find { it.name == "tph_token" } + .flatMap { HttpCookie.parse(it) } + .find { it.name == "tph_token" } ?.let { loginAccessToken = it.value }