From c0a8673e9f97fbeb565000fe85d2f1ce55f6e8c2 Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Wed, 16 Sep 2020 10:21:33 -0300 Subject: Make apps work on API 21+ (except cashier that needs 23+) --- wallet/src/main/java/net/taler/wallet/Utils.kt | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) (limited to 'wallet/src/main/java/net/taler/wallet/Utils.kt') diff --git a/wallet/src/main/java/net/taler/wallet/Utils.kt b/wallet/src/main/java/net/taler/wallet/Utils.kt index ea01552..388bf61 100644 --- a/wallet/src/main/java/net/taler/wallet/Utils.kt +++ b/wallet/src/main/java/net/taler/wallet/Utils.kt @@ -29,8 +29,8 @@ import android.os.Build.VERSION.SDK_INT import android.widget.Toast import android.widget.Toast.LENGTH_LONG import androidx.annotation.RequiresApi +import androidx.core.content.getSystemService import com.google.zxing.integration.android.IntentIntegrator -import org.json.JSONObject fun scanQrCode(activity: Activity) { IntentIntegrator(activity).apply { @@ -69,7 +69,7 @@ private fun connectToWifi29(context: Context, ssid: String) { @Suppress("DEPRECATION") private fun connectToWifiDeprecated(context: Context, ssid: String) { - context.getSystemService(WifiManager::class.java)?.apply { + context.getSystemService()?.apply { if (!isWifiEnabled) { val enabledResult = setWifiEnabled(true) while (enabledResult && !isWifiEnabled) Thread.sleep(25) @@ -91,22 +91,6 @@ private fun connectToWifiDeprecated(context: Context, ssid: String) { } } -fun getErrorString(json: JSONObject): String { - return StringBuilder().apply { - append(json.getString("talerErrorCode")) - append(" ") - append(json.getString("message")) - json.optJSONObject("details")?.let { details -> - details.optJSONObject("errorResponse")?.let { errorResponse -> - append("\n\n") - append(errorResponse.optString("code")) - append(" ") - append(errorResponse.optString("hint")) - } - } - }.toString() -} - fun cleanExchange(exchange: String) = exchange.let { if (it.startsWith("https://")) it.substring(8) else it }.trimEnd('/') -- cgit v1.2.3