Updated on 2026-08-14
This commit is contained in:
parent
e229efff55
commit
8e2d0b90d2
8 changed files with 100 additions and 21 deletions
|
|
@ -438,6 +438,7 @@ public class BtcEngine extends CoinEngine {
|
|||
|
||||
@Override
|
||||
public String convertByteArrayToAmount(TangemCard mCard, byte[] bytes) throws Exception {
|
||||
if( bytes==null ) return "";
|
||||
byte[] reversed = new byte[bytes.length];
|
||||
for (int i = 0; i < bytes.length; i++) reversed[i] = bytes[bytes.length - i - 1];
|
||||
return FormatUtil.DoubleToString(1000.0 * mCard.AmountFromInternalUnits(Util.byteArrayToLong(reversed)));
|
||||
|
|
|
|||
|
|
@ -1,15 +1,20 @@
|
|||
package com.tangem.presentation.activity
|
||||
|
||||
import android.Manifest
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.ActivityInfo
|
||||
import android.content.pm.PackageManager
|
||||
import android.nfc.NfcAdapter
|
||||
import android.nfc.Tag
|
||||
import android.nfc.tech.IsoDep
|
||||
import android.os.Bundle
|
||||
import android.support.v4.app.ActivityCompat
|
||||
import android.support.v4.content.ContextCompat
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import android.support.v7.widget.PopupMenu
|
||||
import android.util.Log
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
|
|
@ -44,6 +49,7 @@ class MainActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoco
|
|||
private const val REQUEST_CODE_SEND_EMAIL = 3
|
||||
private const val REQUEST_CODE_ENTER_PIN_ACTIVITY = 2
|
||||
private const val REQUEST_CODE_SHOW_CARD_ACTIVITY = 1
|
||||
private const val REQUEST_CODE_REQUEST_CAMERA_PERMISSIONS = 3
|
||||
|
||||
const val EXTRA_LAST_DISCOVERED_TAG = "extra_last_tag"
|
||||
|
||||
|
|
@ -86,6 +92,7 @@ class MainActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoco
|
|||
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||
|
||||
nfcManager = NfcManager(this, this)
|
||||
verifyPermissions()
|
||||
|
||||
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR
|
||||
|
||||
|
|
@ -150,26 +157,34 @@ class MainActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoco
|
|||
}
|
||||
|
||||
val apiHelper = ServerApiHelper()
|
||||
apiHelper.setLastVersionListener {
|
||||
response->
|
||||
if(response!! != BuildConfig.VERSION_NAME) Toast.makeText(this, "There is a new application version: "+response.toString(),Toast.LENGTH_LONG).show()
|
||||
apiHelper.setLastVersionListener { response ->
|
||||
if (response!! != BuildConfig.VERSION_NAME) Toast.makeText(this, "There is a new application version: " + response.toString(), Toast.LENGTH_LONG).show()
|
||||
}
|
||||
apiHelper.requestLastVersion()
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
if (requestCode == REQUEST_CODE_SEND_EMAIL) {
|
||||
if (zipFile != null) {
|
||||
zipFile!!.delete()
|
||||
zipFile = null
|
||||
}
|
||||
fun verifyPermissions() {
|
||||
NfcManager.verifyPermissions(this)
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
|
||||
Log.e("QRScanActivity", "User hasn't granted permission to use camera")
|
||||
ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.CAMERA), REQUEST_CODE_REQUEST_CAMERA_PERMISSIONS)
|
||||
}
|
||||
}
|
||||
|
||||
if (requestCode == REQUEST_CODE_ENTER_PIN_ACTIVITY) {
|
||||
if (resultCode == Activity.RESULT_OK && lastTag != null)
|
||||
onTagDiscovered(lastTag!!)
|
||||
else
|
||||
ReadCardInfoTask.resetLastReadInfo()
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
when (requestCode) {
|
||||
REQUEST_CODE_SEND_EMAIL -> {
|
||||
if (zipFile != null) {
|
||||
zipFile!!.delete()
|
||||
zipFile = null
|
||||
}
|
||||
}
|
||||
REQUEST_CODE_ENTER_PIN_ACTIVITY -> {
|
||||
if (resultCode == Activity.RESULT_OK && lastTag != null)
|
||||
onTagDiscovered(lastTag!!)
|
||||
else
|
||||
ReadCardInfoTask.resetLastReadInfo()
|
||||
}
|
||||
}
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.tangem.presentation.activity
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.nfc.NfcAdapter
|
||||
import android.nfc.Tag
|
||||
|
|
@ -8,6 +9,8 @@ import android.os.Bundle
|
|||
import android.support.v7.app.AppCompatActivity
|
||||
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.network.Cryptonit
|
||||
import com.tangem.domain.cardReader.NfcManager
|
||||
|
|
@ -19,6 +22,7 @@ import com.tangem.wallet.R
|
|||
import kotlinx.android.synthetic.main.activity_prepare_cryptonit_withdrawal.*
|
||||
import java.io.IOException
|
||||
|
||||
|
||||
class PrepareCryptonitWithdrawalActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
||||
|
||||
companion object {
|
||||
|
|
@ -71,6 +75,15 @@ class PrepareCryptonitWithdrawalActivity : AppCompatActivity(), NfcAdapter.Reade
|
|||
tvFeeCurrency.text = tvCurrency.text
|
||||
|
||||
etAmount.setText(engine.convertByteArrayToAmount(card!!, card!!.denomination))
|
||||
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)
|
||||
true
|
||||
}else {
|
||||
false
|
||||
}
|
||||
}
|
||||
when (card!!.blockchain) {
|
||||
Blockchain.Bitcoin -> {
|
||||
etAmount.filters = arrayOf<InputFilter>(DecimalDigitsInputFilter(5))
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.tangem.presentation.activity
|
|||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.app.AlertDialog
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
|
|
@ -12,6 +13,8 @@ import android.os.Bundle
|
|||
import android.support.v7.app.AppCompatActivity
|
||||
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.network.Kraken
|
||||
import com.tangem.domain.cardReader.NfcManager
|
||||
|
|
@ -89,6 +92,17 @@ class PrepareKrakenWithdrawalActivity : AppCompatActivity(), NfcAdapter.ReaderCa
|
|||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
|
||||
|
|
@ -258,8 +272,8 @@ class PrepareKrakenWithdrawalActivity : AppCompatActivity(), NfcAdapter.ReaderCa
|
|||
when (requestCode) {
|
||||
REQUEST_CODE_SCAN_QR -> {
|
||||
val uri = URI(data.getStringExtra("QRCode"))
|
||||
var query = uri.query
|
||||
var params = query.split("&")
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.tangem.presentation.activity
|
|||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.nfc.NfcAdapter
|
||||
import android.nfc.Tag
|
||||
|
|
@ -9,9 +10,9 @@ import android.os.Bundle
|
|||
import android.support.v7.app.AppCompatActivity
|
||||
import android.text.Html
|
||||
import android.text.InputFilter
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import com.tangem.domain.cardReader.NfcManager
|
||||
import com.tangem.domain.wallet.Blockchain
|
||||
import com.tangem.domain.wallet.CoinEngineFactory
|
||||
|
|
@ -99,6 +100,18 @@ class PreparePaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
if (card!!.blockchain == Blockchain.Ethereum)
|
||||
etAmount.filters = arrayOf<InputFilter>(DecimalDigitsInputFilter(18))
|
||||
|
||||
|
||||
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
|
||||
btnVerify.setOnClickListener {
|
||||
val strAmount: String = etAmount.text.toString().replace(",", ".")
|
||||
|
|
@ -167,9 +180,24 @@ class PreparePaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
super.onActivityResult(requestCode, resultCode, data)
|
||||
if (requestCode == REQUEST_CODE_SCAN_QR && resultCode == Activity.RESULT_OK && data != null && data.extras!!.containsKey("QRCode")) {
|
||||
var code = data.getStringExtra("QRCode")
|
||||
if (code.contains("bitcoin:")) {
|
||||
val tmp = code.split("bitcoin:".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||
code = tmp[1]
|
||||
when (card!!.blockchain) {
|
||||
Blockchain.Bitcoin -> {
|
||||
if (code.contains("bitcoin:")) {
|
||||
val tmp = code.split("bitcoin:".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||
code = tmp[1]
|
||||
}
|
||||
}
|
||||
Blockchain.Ethereum -> {
|
||||
if (code.contains("ethereum:")) {
|
||||
val tmp = code.split("ethereum:".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||
code = tmp[1]
|
||||
} else if (code.contains("blockchain:")) {
|
||||
val tmp = code.split("blockchain:".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||
code = tmp[1]
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
}
|
||||
}
|
||||
etWallet!!.setText(code)
|
||||
} else if (requestCode == REQUEST_CODE_SEND_PAYMENT) {
|
||||
|
|
|
|||
|
|
@ -70,6 +70,8 @@
|
|||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/text_size_1_small"
|
||||
android:textStyle="bold"
|
||||
android:inputType="text"
|
||||
android:imeOptions="actionNext"
|
||||
tools:text="11111" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
@ -96,6 +98,7 @@
|
|||
android:layout_gravity="center"
|
||||
android:fontFamily="@font/maax"
|
||||
android:inputType="textWebPassword"
|
||||
android:imeOptions="actionNext"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/text_size_1_small"
|
||||
android:textStyle="bold"
|
||||
|
|
@ -128,6 +131,7 @@
|
|||
android:fontFamily="@font/maax"
|
||||
android:hint="@string/enter_amount"
|
||||
android:inputType="numberDecimal"
|
||||
android:imeOptions="actionNext"
|
||||
android:padding="12dp"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/text_size_1_small"
|
||||
|
|
@ -319,6 +323,7 @@
|
|||
android:textColor="@color/colorPrimaryDark"
|
||||
android:textSize="@dimen/text_size_large"
|
||||
android:textStyle="bold"
|
||||
android:imeOptions="actionDone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
|
|
|
|||
|
|
@ -284,6 +284,7 @@
|
|||
android:fontFamily="@font/maax"
|
||||
android:hint="@string/enter_amount"
|
||||
android:inputType="numberDecimal"
|
||||
android:imeOptions="actionDone"
|
||||
android:padding="12dp"
|
||||
android:textColor="@color/colorPrimaryDark"
|
||||
android:textSize="@dimen/text_size_large"
|
||||
|
|
|
|||
|
|
@ -142,6 +142,7 @@
|
|||
android:fontFamily="@font/maax"
|
||||
android:hint="@string/enter_wallet_address"
|
||||
android:inputType="text|textMultiLine|textNoSuggestions"
|
||||
android:imeOptions="actionNext"
|
||||
android:padding="12dp"
|
||||
android:singleLine="false"
|
||||
android:textColor="@color/colorPrimaryDark"
|
||||
|
|
@ -185,6 +186,7 @@
|
|||
android:fontFamily="@font/maax"
|
||||
android:hint="@string/enter_amount"
|
||||
android:inputType="numberDecimal"
|
||||
android:imeOptions="actionDone"
|
||||
android:padding="12dp"
|
||||
android:textColor="@color/colorPrimaryDark"
|
||||
android:textSize="@dimen/text_size_large"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue