diff options
author | Torsten Grote <t@grobox.de> | 2020-09-16 10:21:33 -0300 |
---|---|---|
committer | Torsten Grote <t@grobox.de> | 2020-09-16 10:37:37 -0300 |
commit | c0a8673e9f97fbeb565000fe85d2f1ce55f6e8c2 (patch) | |
tree | afeef27bf7da0683560fb61f887c87e0be410dbc /wallet/src/main/java | |
parent | 85c2be5713eac244ffbe7a024ed2aa08b9816388 (diff) | |
download | taler-android-c0a8673e9f97fbeb565000fe85d2f1ce55f6e8c2.tar.gz taler-android-c0a8673e9f97fbeb565000fe85d2f1ce55f6e8c2.tar.bz2 taler-android-c0a8673e9f97fbeb565000fe85d2f1ce55f6e8c2.zip |
Make apps work on API 21+ (except cashier that needs 23+)
Diffstat (limited to 'wallet/src/main/java')
4 files changed, 9 insertions, 25 deletions
diff --git a/wallet/src/main/java/net/taler/wallet/UriInputFragment.kt b/wallet/src/main/java/net/taler/wallet/UriInputFragment.kt index d17977b..f4a5f23 100644 --- a/wallet/src/main/java/net/taler/wallet/UriInputFragment.kt +++ b/wallet/src/main/java/net/taler/wallet/UriInputFragment.kt @@ -26,6 +26,7 @@ import android.view.View import android.view.ViewGroup import android.widget.Toast import android.widget.Toast.LENGTH_LONG +import androidx.core.content.getSystemService import androidx.fragment.app.Fragment import net.taler.wallet.databinding.FragmentUriInputBinding @@ -43,10 +44,10 @@ class UriInputFragment : Fragment() { } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - val clipboard = requireContext().getSystemService(ClipboardManager::class.java)!! + val clipboard = requireContext().getSystemService<ClipboardManager>() ui.pasteButton.setOnClickListener { - val item = clipboard.primaryClip?.getItemAt(0) + val item = clipboard?.primaryClip?.getItemAt(0) if (item?.text != null) { ui.uriView.setText(item.text) } else { 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<WifiManager>()?.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('/') diff --git a/wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt b/wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt index 936bbbd..5e492f5 100644 --- a/wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt +++ b/wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt @@ -25,6 +25,7 @@ import android.view.View.VISIBLE import android.view.ViewGroup import android.widget.ImageView import android.widget.TextView +import androidx.core.content.ContextCompat.getColor import androidx.recyclerview.selection.ItemDetailsLookup import androidx.recyclerview.selection.ItemKeyProvider import androidx.recyclerview.selection.SelectionTracker @@ -80,13 +81,11 @@ internal class TransactionAdapter( private val amount: TextView = v.findViewById(R.id.amount) private val pendingView: TextView = v.findViewById(R.id.pendingView) - private val selectableForeground = v.foreground private val amountColor = amount.currentTextColor - private val red = context.getColor(R.color.red) - private val green = context.getColor(R.color.green) + private val red = getColor(context, R.color.red) + private val green = getColor(context, R.color.green) fun bind(transaction: Transaction, selected: Boolean) { - v.foreground = selectableForeground v.setOnClickListener { listener.onTransactionClicked(transaction) } v.isActivated = selected if (transaction.error == null) { diff --git a/wallet/src/main/java/net/taler/wallet/withdraw/ManualWithdrawFragment.kt b/wallet/src/main/java/net/taler/wallet/withdraw/ManualWithdrawFragment.kt index 4b56dd0..f368c68 100644 --- a/wallet/src/main/java/net/taler/wallet/withdraw/ManualWithdrawFragment.kt +++ b/wallet/src/main/java/net/taler/wallet/withdraw/ManualWithdrawFragment.kt @@ -53,7 +53,7 @@ class ManualWithdrawFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { ui.qrCodeButton.setOnClickListener { scanQrCode(requireActivity()) } ui.currencyView.text = exchangeItem.currency - val paymentOptions = exchangeItem.paytoUris.mapNotNull {paytoUri -> + val paymentOptions = exchangeItem.paytoUris.mapNotNull { paytoUri -> Uri.parse(paytoUri).authority?.toUpperCase(Locale.getDefault()) }.joinToString(separator = "\n", prefix = "• ") ui.paymentOptionsLabel.text = |