Updated on 2026-08-14
This commit is contained in:
parent
c13348a018
commit
09ef09c8b2
56 changed files with 1443 additions and 1617 deletions
|
|
@ -0,0 +1,169 @@
|
|||
package com.tangem.ui.fragment.additional
|
||||
|
||||
import android.app.Activity
|
||||
import android.graphics.Color
|
||||
import android.nfc.NfcAdapter
|
||||
import android.nfc.Tag
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import com.tangem.Constant
|
||||
import com.tangem.data.Blockchain
|
||||
import com.tangem.data.network.CryptonitOtherApi
|
||||
import com.tangem.ui.activity.MainActivity
|
||||
import com.tangem.ui.fragment.BaseFragment
|
||||
import com.tangem.ui.navigation.NavigationResultListener
|
||||
import com.tangem.wallet.CoinEngineFactory
|
||||
import com.tangem.wallet.R
|
||||
import com.tangem.wallet.TangemContext
|
||||
import kotlinx.android.synthetic.main.fragment_prepare_cryptonit_other_api_withdrawal.*
|
||||
import java.io.IOException
|
||||
|
||||
class PrepareCryptonitOtherApiWithdrawalFragment : BaseFragment(), NavigationResultListener,
|
||||
NfcAdapter.ReaderCallback {
|
||||
|
||||
companion object {
|
||||
val TAG: String = PrepareCryptonitOtherApiWithdrawalFragment::class.java.simpleName
|
||||
}
|
||||
|
||||
override val layoutId = R.layout.fragment_prepare_cryptonit_other_api_withdrawal
|
||||
|
||||
private val ctx: TangemContext by lazy { TangemContext.loadFromBundle(context, arguments) }
|
||||
private val cryptonit: CryptonitOtherApi by lazy { CryptonitOtherApi(context) }
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
tvKey.text = cryptonit.key
|
||||
tvUserID.text = cryptonit.userId
|
||||
tvSecret.text = cryptonit.secretDescription
|
||||
|
||||
tvCardID.text = ctx.card!!.cidDescription
|
||||
tvWallet.text = ctx.coinData!!.wallet
|
||||
val engine = CoinEngineFactory.create(ctx)
|
||||
|
||||
tvCurrency.text = engine!!.balanceCurrency
|
||||
|
||||
etAmount.setText(engine.convertToAmount(engine.convertToInternalAmount(ctx.card!!.denomination)).toValueString())
|
||||
etAmount.filters = engine.amountInputFilters
|
||||
|
||||
// set listeners
|
||||
btnLoad.setOnClickListener {
|
||||
try {
|
||||
val strAmount: String = etAmount.text.toString().replace(",", ".")
|
||||
// if (!engine.checkAmount(card, strAmount))
|
||||
// etAmount.error = getString(R.string.unknown_amount_format)
|
||||
val dblAmount: Double = strAmount.toDouble()
|
||||
|
||||
rlProgressBar.visibility = View.VISIBLE
|
||||
tvProgressDescription.text = getString(R.string.cryptonit_request_withdrawal)
|
||||
|
||||
cryptonit.requestCryptoWithdrawal(ctx.blockchain.currency, dblAmount.toString(), ctx.coinData!!.wallet)
|
||||
} catch (e: Exception) {
|
||||
etAmount.error = getString(R.string.unknown_amount_format)
|
||||
}
|
||||
|
||||
//Toast.makeText(this, strAmount, Toast.LENGTH_LONG).show()
|
||||
// val balance = engine.getBalanceLong(card)!! / (card!!.blockchain.multiplier / 1000.0)
|
||||
// if (etAmount.text.toString().replace(",", ".").toDouble() > balance) {
|
||||
// etAmount.error = getString(R.string.not_enough_funds_on_your_account)
|
||||
// return@setOnClickListener
|
||||
// }
|
||||
|
||||
}
|
||||
ivCameraKey.setOnClickListener {
|
||||
navigateForResult(
|
||||
Constant.REQUEST_CODE_SCAN_QR_KEY,
|
||||
R.id.action_prepareCryptonitOtherApiWithdrawalFragment_to_qrScanFragment)
|
||||
}
|
||||
|
||||
ivCameraSecret.setOnClickListener {
|
||||
navigateForResult(
|
||||
Constant.REQUEST_CODE_SCAN_QR_SECRET,
|
||||
R.id.action_prepareCryptonitOtherApiWithdrawalFragment_to_qrScanFragment)
|
||||
}
|
||||
|
||||
ivCameraUserId.setOnClickListener {
|
||||
navigateForResult(
|
||||
Constant.REQUEST_CODE_SCAN_QR_USER_ID,
|
||||
R.id.action_prepareCryptonitOtherApiWithdrawalFragment_to_qrScanFragment)
|
||||
}
|
||||
|
||||
ivRefreshBalance.setOnClickListener { doRequestBalance() }
|
||||
|
||||
cryptonit.setBalanceListener { response ->
|
||||
when (ctx.blockchain) {
|
||||
Blockchain.Ethereum, Blockchain.EthereumTestNet -> {
|
||||
tvBalance.text = response.eth_available
|
||||
}
|
||||
Blockchain.Bitcoin, Blockchain.BitcoinTestNet, Blockchain.BitcoinCash -> {
|
||||
tvBalance.text = response.btc_available
|
||||
}
|
||||
else -> {
|
||||
}
|
||||
}
|
||||
|
||||
tvBalanceCurrency.text = ctx.blockchain.currency
|
||||
tvBalance.setTextColor(Color.BLACK)
|
||||
rlProgressBar.visibility = View.INVISIBLE
|
||||
btnLoad.isActivated = true
|
||||
}
|
||||
cryptonit.setErrorListener { throwable ->
|
||||
throwable.printStackTrace()
|
||||
rlProgressBar.visibility = View.INVISIBLE
|
||||
tvError.visibility = View.VISIBLE
|
||||
tvError.text = throwable.message
|
||||
}
|
||||
cryptonit.setWithdrawalListener { response ->
|
||||
rlProgressBar.visibility = View.INVISIBLE
|
||||
if (response.success != null && response.success!!) {
|
||||
navigateUp()
|
||||
} else {
|
||||
tvError.visibility = View.VISIBLE
|
||||
tvError.text = response.reason!!.toString()
|
||||
}
|
||||
}
|
||||
btnLoad.isActivated = false
|
||||
doRequestBalance()
|
||||
}
|
||||
|
||||
override fun onNavigationResult(requestCode: String, resultCode: Int, data: Bundle?) {
|
||||
if (resultCode == Activity.RESULT_OK && data != null && data.containsKey("QRCode")) {
|
||||
when (requestCode) {
|
||||
Constant.REQUEST_CODE_SCAN_QR_KEY -> {
|
||||
cryptonit.key = data.getString("QRCode")
|
||||
tvKey?.text = cryptonit.key
|
||||
}
|
||||
Constant.REQUEST_CODE_SCAN_QR_SECRET -> {
|
||||
cryptonit.secret = data.getString("QRCode")
|
||||
tvSecret?.text = cryptonit.secretDescription
|
||||
}
|
||||
Constant.REQUEST_CODE_SCAN_QR_USER_ID -> {
|
||||
cryptonit.userId = data.getString("QRCode")
|
||||
tvUserID?.text = cryptonit.userId
|
||||
}
|
||||
}
|
||||
cryptonit.saveAccountInfo()
|
||||
doRequestBalance()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onTagDiscovered(tag: Tag) {
|
||||
try {
|
||||
(activity as MainActivity).nfcManager.ignoreTag(tag)
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
private fun doRequestBalance() {
|
||||
if (cryptonit.havaAccountInfo()) {
|
||||
rlProgressBar.visibility = View.VISIBLE
|
||||
tvProgressDescription.text = getString(R.string.cryptonit_request_balance)
|
||||
tvError.visibility = View.INVISIBLE
|
||||
cryptonit.requestBalance(ctx.blockchain.currency, "USD")
|
||||
} else {
|
||||
tvError.visibility = View.VISIBLE
|
||||
tvError.text = getString(R.string.cryptonit_not_enough_account_data)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,149 @@
|
|||
package com.tangem.ui.fragment.additional
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.nfc.NfcAdapter
|
||||
import android.nfc.Tag
|
||||
import android.os.Bundle
|
||||
import android.text.InputFilter
|
||||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.Toast
|
||||
import com.tangem.data.Blockchain
|
||||
import com.tangem.data.network.Cryptonit
|
||||
import com.tangem.ui.activity.MainActivity
|
||||
import com.tangem.ui.fragment.BaseFragment
|
||||
import com.tangem.util.DecimalDigitsInputFilter
|
||||
import com.tangem.wallet.CoinEngineFactory
|
||||
import com.tangem.wallet.R
|
||||
import com.tangem.wallet.TangemContext
|
||||
import kotlinx.android.synthetic.main.fragment_prepare_cryptonit_withdrawal.*
|
||||
import java.io.IOException
|
||||
|
||||
class PrepareCryptonitWithdrawalFragment : BaseFragment(), NfcAdapter.ReaderCallback {
|
||||
|
||||
companion object {
|
||||
val TAG: String = PrepareCryptonitWithdrawalFragment::class.java.simpleName
|
||||
}
|
||||
|
||||
override val layoutId = R.layout.fragment_prepare_cryptonit_withdrawal
|
||||
|
||||
private val ctx: TangemContext by lazy { TangemContext.loadFromBundle(context, arguments) }
|
||||
private val cryptonit: Cryptonit by lazy { Cryptonit(context) }
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
etUsername.setText(cryptonit.username)
|
||||
etPassword.setText(cryptonit.password)
|
||||
etFee.setText(cryptonit.fee)
|
||||
|
||||
tvCardID.text = ctx.card!!.cidDescription
|
||||
tvWallet.text = ctx.coinData!!.wallet
|
||||
val engine = CoinEngineFactory.create(ctx)
|
||||
|
||||
tvCurrency.text = engine!!.balanceCurrency
|
||||
tvFeeCurrency.text = engine.feeCurrency
|
||||
|
||||
etAmount.setText(engine.convertToAmount(engine.convertToInternalAmount(ctx.card!!.denomination)).toValueString())
|
||||
etAmount.filters = engine.amountInputFilters
|
||||
|
||||
etAmount.setOnEditorActionListener { lv, actionId, _ ->
|
||||
if (actionId == EditorInfo.IME_ACTION_DONE) {
|
||||
val imm = lv.context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
imm.hideSoftInputFromWindow(lv.windowToken, 0)
|
||||
true
|
||||
} else
|
||||
false
|
||||
}
|
||||
|
||||
when (ctx.blockchain) {
|
||||
Blockchain.Bitcoin -> {
|
||||
etAmount.filters = arrayOf<InputFilter>(DecimalDigitsInputFilter(5))
|
||||
etFee.filters = arrayOf<InputFilter>(DecimalDigitsInputFilter(5))
|
||||
}
|
||||
Blockchain.BitcoinCash -> {
|
||||
etAmount.filters = arrayOf<InputFilter>(DecimalDigitsInputFilter(8))
|
||||
etFee.filters = arrayOf<InputFilter>(DecimalDigitsInputFilter(8))
|
||||
}
|
||||
Blockchain.Ethereum -> {
|
||||
etAmount.filters = arrayOf<InputFilter>(DecimalDigitsInputFilter(18))
|
||||
etFee.filters = arrayOf<InputFilter>(DecimalDigitsInputFilter(18))
|
||||
}
|
||||
else -> {
|
||||
}
|
||||
}
|
||||
|
||||
// set listeners
|
||||
btnLoad.setOnClickListener {
|
||||
try {
|
||||
val strAmount: String = etAmount.text.toString().replace(",", ".")
|
||||
val strFee: String = etFee.text.toString().replace(",", ".")
|
||||
val dblAmount: Double = strAmount.toDouble()
|
||||
cryptonit.fee = strFee
|
||||
|
||||
rlProgressBar.visibility = View.VISIBLE
|
||||
tvProgressDescription.text = getString(R.string.cryptonit_request_withdrawal)
|
||||
|
||||
cryptonit.requestWithdrawCoins(ctx.blockchain.currency, dblAmount, ctx.coinData!!.wallet)
|
||||
} catch (e: Exception) {
|
||||
etAmount.error = getString(R.string.unknown_amount_format)
|
||||
}
|
||||
}
|
||||
|
||||
ivRefreshBalance.setOnClickListener {
|
||||
cryptonit.username = etUsername.text.toString()
|
||||
cryptonit.password = etPassword.text.toString()
|
||||
cryptonit.saveAccountInfo()
|
||||
doRequestBalance()
|
||||
}
|
||||
|
||||
cryptonit.setBalanceListener { response ->
|
||||
tvBalance.text = response.results[0].balance.toString()
|
||||
tvBalanceCurrency.text = response.results[0].currency // card!!.blockchain.currency
|
||||
tvBalance.setTextColor(Color.BLACK)
|
||||
rlProgressBar.visibility = View.INVISIBLE
|
||||
btnLoad.visibility = View.VISIBLE
|
||||
}
|
||||
cryptonit.setErrorListener { throwable ->
|
||||
throwable.printStackTrace()
|
||||
rlProgressBar.visibility = View.INVISIBLE
|
||||
tvError.visibility = View.VISIBLE
|
||||
tvError.text = throwable.message
|
||||
}
|
||||
cryptonit.setWithdrawalListener { response ->
|
||||
rlProgressBar.visibility = View.INVISIBLE
|
||||
if (response.success != null && response.success!!) {
|
||||
Toast.makeText(context, R.string.withdrawal_successful, Toast.LENGTH_LONG).show();
|
||||
navigateUp()
|
||||
} else {
|
||||
tvError.visibility = View.VISIBLE
|
||||
tvError.text = response.errors.toString()
|
||||
}
|
||||
}
|
||||
btnLoad.visibility = View.INVISIBLE
|
||||
doRequestBalance()
|
||||
}
|
||||
|
||||
override fun onTagDiscovered(tag: Tag) {
|
||||
try {
|
||||
(activity as MainActivity).nfcManager.ignoreTag(tag)
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
private fun doRequestBalance() {
|
||||
if (cryptonit.haveAccountInfo()) {
|
||||
rlProgressBar.visibility = View.VISIBLE
|
||||
tvProgressDescription.text = getString(R.string.cryptonit_request_balance)
|
||||
tvError.visibility = View.INVISIBLE
|
||||
cryptonit.requestBalance(ctx.blockchain.currency)
|
||||
} else {
|
||||
tvError.visibility = View.VISIBLE
|
||||
tvError.text = getString(R.string.cryptonit_not_enough_account_data)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,240 @@
|
|||
package com.tangem.ui.fragment.additional
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.AlertDialog
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import android.graphics.Color
|
||||
import android.nfc.NfcAdapter
|
||||
import android.nfc.Tag
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.Toast
|
||||
import com.tangem.Constant
|
||||
import com.tangem.data.Blockchain
|
||||
import com.tangem.data.network.Kraken
|
||||
import com.tangem.ui.activity.MainActivity
|
||||
import com.tangem.ui.fragment.BaseFragment
|
||||
import com.tangem.ui.navigation.NavigationResultListener
|
||||
import com.tangem.wallet.CoinEngineFactory
|
||||
import com.tangem.wallet.R
|
||||
import com.tangem.wallet.TangemContext
|
||||
import kotlinx.android.synthetic.main.fragment_prepare_kraken_withdrawal.*
|
||||
import java.io.IOException
|
||||
import java.math.BigDecimal
|
||||
import java.net.URI
|
||||
import java.util.*
|
||||
|
||||
class PrepareKrakenWithdrawalFragment : BaseFragment(), NavigationResultListener,
|
||||
NfcAdapter.ReaderCallback {
|
||||
|
||||
companion object {
|
||||
val TAG: String = PrepareKrakenWithdrawalFragment::class.java.simpleName
|
||||
}
|
||||
|
||||
override val layoutId = R.layout.fragment_prepare_kraken_withdrawal
|
||||
|
||||
private val ctx: TangemContext by lazy { TangemContext.loadFromBundle(context, arguments) }
|
||||
private val kraken: Kraken by lazy { Kraken(context) }
|
||||
|
||||
private var fee: BigDecimal? = null
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
tvKey.text = kraken.key
|
||||
tvSecret.text = kraken.secretDescription
|
||||
|
||||
tvCardID.text = ctx.card!!.cidDescription
|
||||
tvWallet.text = ctx.coinData!!.wallet
|
||||
val engine = CoinEngineFactory.create(ctx)
|
||||
|
||||
tvCurrency.text = engine!!.balanceCurrency
|
||||
|
||||
etAmount.setText(engine.convertToAmount(engine.convertToInternalAmount(ctx.card!!.denomination)).toValueString())
|
||||
etAmount.filters = engine.amountInputFilters
|
||||
|
||||
etAmount.setOnEditorActionListener { lv, actionId, event ->
|
||||
if (actionId == EditorInfo.IME_ACTION_DONE) {
|
||||
val imm = lv.context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
imm.hideSoftInputFromWindow(lv.windowToken, 0)
|
||||
lv.clearFocus()
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
// set listeners
|
||||
btnLoad.setOnClickListener {
|
||||
try {
|
||||
val strAmount: String = etAmount.text.toString().replace(",", ".")
|
||||
|
||||
var dblAmount: Double = strAmount.toDouble()
|
||||
rlProgressBar.visibility = View.VISIBLE
|
||||
tvProgressDescription.text = getString(R.string.kraken_request_withdrawal)
|
||||
|
||||
kraken.requestWithdrawInfo(ctx.blockchain.currency, dblAmount.toString(), ctx.coinData!!.wallet)
|
||||
} catch (e: Exception) {
|
||||
etAmount.error = getString(R.string.unknown_amount_format)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ivCamera.setOnClickListener { navigator.showQrScanActivity(this, Constant.REQUEST_CODE_SCAN_QR) }
|
||||
|
||||
ivRefreshBalance.setOnClickListener { doRequestBalance() }
|
||||
|
||||
kraken.setBalanceListener { response ->
|
||||
if (response.error != null && response.error.isNotEmpty()) {
|
||||
tvError.visibility = View.VISIBLE
|
||||
tvError.text = Arrays.toString(response.error)
|
||||
} else {
|
||||
when (ctx.blockchain) {
|
||||
Blockchain.Ethereum -> {
|
||||
tvBalance.text = response.result.XETH.trimEnd('0')
|
||||
}
|
||||
Blockchain.Bitcoin -> {
|
||||
tvBalance.text = response.result.XXBT.trimEnd('0')
|
||||
}
|
||||
Blockchain.BitcoinCash -> {
|
||||
tvBalance.text = response.result.BCH.trimEnd('0')
|
||||
}
|
||||
else -> {
|
||||
tvBalance.text = "???"
|
||||
}
|
||||
}
|
||||
tvBalanceCurrency.text = ctx.blockchain.currency
|
||||
tvBalance.setTextColor(Color.BLACK)
|
||||
btnLoad.visibility = View.VISIBLE
|
||||
}
|
||||
rlProgressBar.visibility = View.INVISIBLE
|
||||
}
|
||||
kraken.setErrorListener { throwable ->
|
||||
throwable.printStackTrace()
|
||||
rlProgressBar.visibility = View.INVISIBLE
|
||||
tvError.visibility = View.VISIBLE
|
||||
tvError.text = throwable.message
|
||||
}
|
||||
kraken.setWithdrawalListener { response ->
|
||||
rlProgressBar.visibility = View.INVISIBLE
|
||||
if (response.error != null && response.error.isNotEmpty()) {
|
||||
tvError.visibility = View.VISIBLE
|
||||
tvError.text = Arrays.toString(response.error)
|
||||
} else {
|
||||
Toast.makeText(context, "Withdrawal successful!", Toast.LENGTH_LONG).show()
|
||||
navigateUp()
|
||||
}
|
||||
}
|
||||
kraken.setWithdrawalInfoListener { response ->
|
||||
rlProgressBar.visibility = View.INVISIBLE
|
||||
if (response.error != null && response.error.isNotEmpty()) {
|
||||
tvError.visibility = View.VISIBLE
|
||||
tvError.text = Arrays.toString(response.error)
|
||||
} else {
|
||||
fee = BigDecimal(response.result.fee)
|
||||
showConfirmDialog()
|
||||
}
|
||||
}
|
||||
|
||||
btnLoad.visibility = View.INVISIBLE
|
||||
doRequestBalance()
|
||||
}
|
||||
|
||||
// Method to show an alert dialog with yes, no and cancel button
|
||||
private fun showConfirmDialog() {
|
||||
// Late initialize an alert dialog object
|
||||
lateinit var dialog: AlertDialog
|
||||
|
||||
|
||||
// Initialize a new instance of alert dialog builder object
|
||||
val builder = AlertDialog.Builder(context)
|
||||
|
||||
// Set a title for alert dialog
|
||||
builder.setTitle(R.string.please_confirm_withdraw)
|
||||
|
||||
// Set a message for alert dialog
|
||||
builder.setMessage(String.format("Continue with fee %s %s?", fee!!.toString().trimEnd('0'), ctx.blockchain.currency))
|
||||
|
||||
// On click listener for dialog buttons
|
||||
val dialogClickListener = DialogInterface.OnClickListener { _, which ->
|
||||
when (which) {
|
||||
DialogInterface.BUTTON_POSITIVE -> {
|
||||
try {
|
||||
val strAmount: String = etAmount.text.toString().replace(",", ".")
|
||||
|
||||
var dblAmount: Double = strAmount.toDouble()
|
||||
|
||||
dblAmount += fee!!.toDouble()
|
||||
|
||||
rlProgressBar.visibility = View.VISIBLE
|
||||
tvProgressDescription.text = getString(R.string.kraken_request_withdrawal)
|
||||
|
||||
kraken.requestWithdraw(ctx.blockchain.currency, dblAmount.toString(), ctx.coinData!!.wallet)
|
||||
} catch (e: Exception) {
|
||||
etAmount.error = getString(R.string.unknown_amount_format)
|
||||
}
|
||||
}
|
||||
DialogInterface.BUTTON_NEGATIVE -> {
|
||||
Toast.makeText(context, R.string.operation_canceled, Toast.LENGTH_LONG).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set the alert dialog positive/yes button
|
||||
builder.setPositiveButton(R.string.yes, dialogClickListener)
|
||||
|
||||
// Set the alert dialog negative/no button
|
||||
builder.setNegativeButton(R.string.no, dialogClickListener)
|
||||
|
||||
|
||||
// Initialize the AlertDialog using builder object
|
||||
dialog = builder.create()
|
||||
|
||||
// Finally, display the alert dialog
|
||||
dialog.show()
|
||||
}
|
||||
|
||||
private fun doRequestBalance() {
|
||||
if (kraken!!.haveAccountInfo()) {
|
||||
rlProgressBar.visibility = View.VISIBLE
|
||||
tvProgressDescription.text = getString(R.string.kraken_request_balance)
|
||||
tvError.visibility = View.INVISIBLE
|
||||
kraken!!.requestBalance()
|
||||
} else {
|
||||
tvError.visibility = View.VISIBLE
|
||||
tvError.text = getString(R.string.kraken_not_enough_account_data)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onNavigationResult(requestCode: String, resultCode: Int, data: Bundle?) {
|
||||
if (resultCode == Activity.RESULT_OK && data != null && data.containsKey("QRCode")) {
|
||||
when (requestCode) {
|
||||
Constant.REQUEST_CODE_SCAN_QR -> {
|
||||
val uri = URI(data.getString("QRCode"))
|
||||
val query = uri.query
|
||||
val params = query.split("&")
|
||||
for (param in params) {
|
||||
if (param.startsWith("key=")) kraken.key = param.substring(4)
|
||||
else if (param.startsWith("secret=")) kraken.secret = param.substring(7)
|
||||
}
|
||||
tvKey!!.text = kraken.key
|
||||
tvSecret!!.text = kraken.secretDescription
|
||||
}
|
||||
}
|
||||
kraken.saveAccountInfo()
|
||||
doRequestBalance()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onTagDiscovered(tag: Tag) {
|
||||
try {
|
||||
(activity as MainActivity).nfcManager.ignoreTag(tag)
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue