Updated on 2026-08-14
This commit is contained in:
parent
f8590dfa83
commit
6bfb453c6d
43 changed files with 210 additions and 230 deletions
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.domain.wallet
|
||||
package com.tangem.data.db
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
|
|
@ -12,6 +12,7 @@ import com.google.gson.annotations.SerializedName
|
|||
import com.google.gson.reflect.TypeToken
|
||||
import com.tangem.data.network.model.CardVerifyAndGetInfo
|
||||
import com.tangem.domain.cardReader.CardCrypto
|
||||
import com.tangem.domain.wallet.TangemCard
|
||||
import com.tangem.util.Util
|
||||
import com.tangem.wallet.R
|
||||
import java.io.InputStream
|
||||
|
|
@ -1,9 +1,8 @@
|
|||
package com.tangem.data.network.task.save_pin;
|
||||
package com.tangem.data.fingerprint;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.tangem.domain.wallet.FingerprintHelper;
|
||||
import com.tangem.presentation.activity.PinSaveActivity;
|
||||
import com.tangem.wallet.R;
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.domain.wallet;
|
||||
package com.tangem.data.fingerprint;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.data.network.task.request_pin;
|
||||
package com.tangem.data.fingerprint;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
|
|
@ -8,7 +8,6 @@ import android.security.keystore.KeyGenParameterSpec;
|
|||
import android.security.keystore.KeyPermanentlyInvalidatedException;
|
||||
import android.security.keystore.KeyProperties;
|
||||
|
||||
import com.tangem.domain.wallet.FingerprintHelper;
|
||||
import com.tangem.data.db.PINStorage;
|
||||
import com.tangem.presentation.activity.PinRequestActivity;
|
||||
|
||||
|
|
@ -3,8 +3,8 @@ package com.tangem.data.network;
|
|||
import android.util.Log;
|
||||
|
||||
import com.tangem.App;
|
||||
import com.tangem.domain.BitcoinNode;
|
||||
import com.tangem.domain.BitcoinNodeTestNet;
|
||||
import com.tangem.domain.wallet.btc.BitcoinNode;
|
||||
import com.tangem.domain.wallet.btc.BitcoinNodeTestNet;
|
||||
import com.tangem.domain.wallet.Blockchain;
|
||||
import com.tangem.domain.wallet.TangemCard;
|
||||
|
||||
|
|
@ -26,8 +26,6 @@ import java.util.Random;
|
|||
import javax.net.SocketFactory;
|
||||
import javax.net.ssl.HostnameVerifier;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import javax.net.ssl.SSLHandshakeException;
|
||||
import javax.net.ssl.SSLPeerUnverifiedException;
|
||||
import javax.net.ssl.SSLSession;
|
||||
import javax.net.ssl.SSLSocket;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import com.tangem.domain.wallet.CoinEngineFactory;
|
|||
import com.tangem.domain.wallet.TangemContext;
|
||||
import com.tangem.presentation.activity.SendTransactionActivity;
|
||||
import com.tangem.presentation.activity.SignPaymentActivity;
|
||||
import com.tangem.util.BTCUtils;
|
||||
import com.tangem.domain.wallet.BTCUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ public class SignPaymentTask extends Thread {
|
|||
// SignBTC_TX(protocol);
|
||||
// }
|
||||
|
||||
CoinEngine engine = CoinEngineFactory.create(mCtx);
|
||||
CoinEngine engine = CoinEngineFactory.INSTANCE.create(mCtx);
|
||||
if (engine != null) {
|
||||
if (mCtx.getCard().getPauseBeforePIN2() > 0) {
|
||||
mNotifications.onReadWait(mCtx.getCard().getPauseBeforePIN2());
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import android.util.Log;
|
|||
import com.tangem.domain.wallet.CoinEngine;
|
||||
import com.tangem.domain.wallet.CoinEngineFactory;
|
||||
import com.tangem.domain.wallet.Issuer;
|
||||
import com.tangem.domain.wallet.LocalStorage;
|
||||
import com.tangem.data.db.LocalStorage;
|
||||
import com.tangem.domain.wallet.TangemCard;
|
||||
import com.tangem.domain.wallet.Manufacturer;
|
||||
import com.tangem.domain.wallet.TangemContext;
|
||||
|
|
@ -587,7 +587,7 @@ public class CardProtocol {
|
|||
|
||||
TangemContext ctx = new TangemContext(mCard);
|
||||
try {
|
||||
CoinEngine engineCoin = CoinEngineFactory.create(ctx);
|
||||
CoinEngine engineCoin = CoinEngineFactory.INSTANCE.create(ctx);
|
||||
if( engineCoin==null ) throw new Exception("Can't create CoinEngine!");
|
||||
String wallet = engineCoin.calculateAddress(pkUncompressed);
|
||||
mCard.setWallet(wallet);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.util;
|
||||
package com.tangem.domain.wallet;
|
||||
|
||||
/**
|
||||
* Created by Ilia on 29.09.2017.
|
||||
|
|
@ -6,12 +6,12 @@ package com.tangem.util;
|
|||
|
||||
import android.util.Log;
|
||||
|
||||
import com.tangem.domain.wallet.Base58;
|
||||
import com.tangem.domain.wallet.BitcoinException;
|
||||
import com.tangem.domain.wallet.BitcoinOutputStream;
|
||||
import com.tangem.domain.wallet.BtcData;
|
||||
import com.tangem.domain.wallet.Transaction;
|
||||
import com.tangem.domain.wallet.UnspentOutputInfo;
|
||||
import com.tangem.domain.wallet.btc.BitcoinException;
|
||||
import com.tangem.domain.wallet.btc.BitcoinOutputStream;
|
||||
import com.tangem.domain.wallet.btc.BtcData;
|
||||
import com.tangem.util.CryptoUtil;
|
||||
import com.tangem.util.FormatUtil;
|
||||
import com.tangem.util.Util;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
|
@ -103,8 +103,7 @@ public final class BTCUtils {
|
|||
return new String(hexChars);
|
||||
}
|
||||
|
||||
public static String satoshiToBtc(byte[] satoshi)
|
||||
{
|
||||
public static String satoshiToBtc(byte[] satoshi) {
|
||||
satoshi = reverse(satoshi);
|
||||
|
||||
BigInteger num = new BigInteger(1, satoshi);
|
||||
|
|
@ -114,7 +113,7 @@ public final class BTCUtils {
|
|||
|
||||
String pattern = "#0.00000000";
|
||||
DecimalFormat myFormatter = new DecimalFormat(pattern);
|
||||
String output = myFormatter.format(dec).replace(",",".");
|
||||
String output = myFormatter.format(dec).replace(",", ".");
|
||||
return output;
|
||||
}
|
||||
|
||||
|
|
@ -147,34 +146,30 @@ public final class BTCUtils {
|
|||
forSign.writeInt32(0x01);//write(new byte[]{0x02, 0x00, 0x00, 0x00}); // version
|
||||
|
||||
//01
|
||||
byte inputCount = (byte)unspentOutputs.size();
|
||||
byte inputCount = (byte) unspentOutputs.size();
|
||||
forSign.write(inputCount); // input count
|
||||
//hex str hash prev btc
|
||||
|
||||
for(int i = 0; i < inputCount; ++i)
|
||||
{
|
||||
for (int i = 0; i < inputCount; ++i) {
|
||||
UnspentOutputInfo outPut = unspentOutputs.get(i);
|
||||
int outputIndex = outPut.outputIndex;
|
||||
byte[] txHash = BTCUtils.reverse(Util.hexToBytes(outPut.txHashForBuild));//Sha256Hash.hash(rawTxByte);
|
||||
forSign.write(txHash);
|
||||
forSign.writeInt32(outputIndex); //output index in prev tx
|
||||
if(inputPos ==-1 || i == inputPos)
|
||||
{
|
||||
if (inputPos == -1 || i == inputPos) {
|
||||
// hex str 1976a914....88ac
|
||||
forSign.write((byte)outPut.scriptForBuild.length);
|
||||
forSign.write((byte) outPut.scriptForBuild.length);
|
||||
forSign.write(outPut.scriptForBuild);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
forSign.write(0x00);
|
||||
}
|
||||
//ffffffff
|
||||
forSign.write(new byte[]{(byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff}); // sequence
|
||||
forSign.write(new byte[]{(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff}); // sequence
|
||||
}
|
||||
|
||||
|
||||
//02
|
||||
byte outputCount = (byte)((change==0) ? 1 : 2); // outputCount
|
||||
byte outputCount = (byte) ((change == 0) ? 1 : 2); // outputCount
|
||||
forSign.write(outputCount);
|
||||
|
||||
//8 bytes
|
||||
|
|
@ -182,15 +177,15 @@ public final class BTCUtils {
|
|||
forSign.writeInt64(amount); //amount
|
||||
byte[] sendScript = Transaction.Script.buildOutput(outputAddress).bytes; // build out
|
||||
//hex str 1976a914....88ac
|
||||
forSign.write((byte)sendScript.length);
|
||||
forSign.write((byte) sendScript.length);
|
||||
forSign.write(sendScript);
|
||||
|
||||
if(change!=0){
|
||||
if (change != 0) {
|
||||
//8 bytes
|
||||
forSign.writeInt64(change); // change
|
||||
//hex str 1976a914....88ac
|
||||
byte[] chancheScript = Transaction.Script.buildOutput(changeAddress).bytes; //build out
|
||||
forSign.write((byte)chancheScript.length);
|
||||
forSign.write((byte) chancheScript.length);
|
||||
forSign.write(chancheScript);
|
||||
|
||||
}
|
||||
|
|
@ -207,16 +202,14 @@ public final class BTCUtils {
|
|||
return rawData;
|
||||
}
|
||||
|
||||
int calculateSize(int inputCount, int outputCount)
|
||||
{
|
||||
int calculateSize(int inputCount, int outputCount) {
|
||||
int size = 0;
|
||||
size += 4; // header
|
||||
size += 1; //inputCount
|
||||
|
||||
//hex str hash prev btc
|
||||
|
||||
for(int i = 0; i < inputCount; ++i)
|
||||
{
|
||||
for (int i = 0; i < inputCount; ++i) {
|
||||
size += 32; //prevtx
|
||||
size += 4; //outputIndex;
|
||||
size += 1; //scriptLength
|
||||
|
|
@ -224,23 +217,21 @@ public final class BTCUtils {
|
|||
size += 4; //ffffffff
|
||||
}
|
||||
|
||||
size+=1; //outputCount
|
||||
size+=8; //amount
|
||||
size+=1;
|
||||
size += 1; //outputCount
|
||||
size += 8; //amount
|
||||
size += 1;
|
||||
// size+=script;
|
||||
|
||||
if(outputCount > 1)
|
||||
{
|
||||
size+=8;
|
||||
size+=1;
|
||||
if (outputCount > 1) {
|
||||
size += 8;
|
||||
size += 1;
|
||||
//scriptLen;
|
||||
}
|
||||
|
||||
size+=4;
|
||||
size += 4;
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
public static byte[] buildBodyTX(String outputAddress, String changeAddress, int outputIndex, String prevID, long amount, long change, byte[] script) throws BitcoinException, IOException {
|
||||
|
||||
//0200000000
|
||||
|
|
@ -260,14 +251,14 @@ public final class BTCUtils {
|
|||
//forSign.write(0x00);
|
||||
|
||||
// hex str 1976a914....88ac
|
||||
forSign.write((byte)script.length);
|
||||
forSign.write((byte) script.length);
|
||||
forSign.write(script);
|
||||
|
||||
//ffffffff
|
||||
forSign.write(new byte[]{(byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff}); // sequence
|
||||
forSign.write(new byte[]{(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff}); // sequence
|
||||
|
||||
//02
|
||||
byte outputCount = (byte)((change==0) ? 1 : 2); // outputCount
|
||||
byte outputCount = (byte) ((change == 0) ? 1 : 2); // outputCount
|
||||
forSign.write(outputCount);
|
||||
|
||||
//8 bytes
|
||||
|
|
@ -275,15 +266,15 @@ public final class BTCUtils {
|
|||
forSign.writeInt64(amount); //amount
|
||||
byte[] sendScript = Transaction.Script.buildOutput(outputAddress).bytes; // build out
|
||||
//hex str 1976a914....88ac
|
||||
forSign.write((byte)sendScript.length);
|
||||
forSign.write((byte) sendScript.length);
|
||||
forSign.write(sendScript);
|
||||
|
||||
if(change!=0){
|
||||
if (change != 0) {
|
||||
//8 bytes
|
||||
forSign.writeInt64(change); // change
|
||||
//hex str 1976a914....88ac
|
||||
byte[] chancheScript = Transaction.Script.buildOutput(changeAddress).bytes; //build out
|
||||
forSign.write((byte)chancheScript.length);
|
||||
forSign.write((byte) chancheScript.length);
|
||||
forSign.write(chancheScript);
|
||||
|
||||
}
|
||||
|
|
@ -301,8 +292,7 @@ public final class BTCUtils {
|
|||
byte[] rawTxByte = fromHex(hex);
|
||||
Transaction baseTx = new Transaction(rawTxByte);
|
||||
ArrayList<byte[]> prevHashes = new ArrayList<byte[]>();
|
||||
for(int i =0; i < baseTx.inputs.length; ++i)
|
||||
{
|
||||
for (int i = 0; i < baseTx.inputs.length; ++i) {
|
||||
Transaction.Input input = baseTx.inputs[i];
|
||||
prevHashes.add(input.outPoint.hash);
|
||||
}
|
||||
|
|
@ -313,32 +303,30 @@ public final class BTCUtils {
|
|||
byte[] rawTxByte = fromHex(hex);
|
||||
Transaction baseTx = new Transaction(rawTxByte);
|
||||
byte[] myScript = Transaction.Script.buildOutput(myAddress).bytes;
|
||||
for(int i =0; i < baseTx.inputs.length; ++i)
|
||||
{
|
||||
for (int i = 0; i < baseTx.inputs.length; ++i) {
|
||||
Transaction.Input input = baseTx.inputs[i];
|
||||
byte[] script = input.script.bytes;
|
||||
|
||||
// find outputs
|
||||
if (Arrays.equals(myScript, script)){
|
||||
if (Arrays.equals(myScript, script)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ArrayList<UnspentOutputInfo> getOutputs(List<BtcData.UnspentTransaction> rawTxList, byte[] outputScriptWeAreAbleToSpend) throws BitcoinException {
|
||||
ArrayList<UnspentOutputInfo> unspentOutputs = new ArrayList<>();
|
||||
|
||||
for(BtcData.UnspentTransaction current: rawTxList)
|
||||
{
|
||||
for (BtcData.UnspentTransaction current : rawTxList) {
|
||||
byte[] rawTxByte = BTCUtils.fromHex(current.Raw);
|
||||
if (rawTxByte == null || current.Raw.isEmpty())
|
||||
{
|
||||
if (rawTxByte == null || current.Raw.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Transaction baseTx = new Transaction(rawTxByte);
|
||||
|
||||
if(baseTx.inputs.length == 0 || baseTx.outputs.length == 0)
|
||||
if (baseTx.inputs.length == 0 || baseTx.outputs.length == 0)
|
||||
throw new IllegalArgumentException("Unable to decode given transaction");
|
||||
|
||||
byte[] txHash = BTCUtils.reverse(CryptoUtil.doubleSha256(rawTxByte));
|
||||
|
|
@ -2,8 +2,6 @@ package com.tangem.domain.wallet;
|
|||
|
||||
import com.tangem.wallet.R;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
public class BalanceValidator {
|
||||
private String firstLine;
|
||||
private String secondLine;
|
||||
|
|
@ -14,7 +12,7 @@ public class BalanceValidator {
|
|||
}
|
||||
|
||||
public void setFirstLine(String value) {
|
||||
firstLine=value;
|
||||
firstLine = value;
|
||||
}
|
||||
|
||||
public String getSecondLine(Boolean recommend) {
|
||||
|
|
@ -31,7 +29,7 @@ public class BalanceValidator {
|
|||
}
|
||||
|
||||
public void setSecondLine(String value) {
|
||||
secondLine=value;
|
||||
secondLine = value;
|
||||
}
|
||||
|
||||
public void setScore(int score) {
|
||||
|
|
@ -53,10 +51,10 @@ public class BalanceValidator {
|
|||
public void Check(TangemContext ctx, Boolean attest) {
|
||||
firstLine = "Verification failed";
|
||||
secondLine = "";
|
||||
TangemCard card=ctx.getCard();
|
||||
CoinEngine engine=CoinEngineFactory.create(ctx);
|
||||
TangemCard card = ctx.getCard();
|
||||
CoinEngine engine = CoinEngineFactory.INSTANCE.create(ctx);
|
||||
|
||||
if( !engine.validateBalance(this) ) return;
|
||||
if (!engine.validateBalance(this)) return;
|
||||
|
||||
// Verify card?
|
||||
if (attest) {
|
||||
|
|
@ -97,6 +95,6 @@ public class BalanceValidator {
|
|||
secondLine += "Card identity was not verified. Cannot reach Tangem attestation service. ";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -63,7 +63,7 @@ public abstract class CoinData {
|
|||
}
|
||||
|
||||
public static CoinData fromBundle(Blockchain blockchain, Bundle bundle) {
|
||||
CoinEngine engine=CoinEngineFactory.create(blockchain);
|
||||
CoinEngine engine= CoinEngineFactory.INSTANCE.create(blockchain);
|
||||
if( engine==null ) return null;
|
||||
CoinData result = engine.createCoinData();
|
||||
result.loadFromBundle(bundle);
|
||||
|
|
|
|||
|
|
@ -1,51 +0,0 @@
|
|||
package com.tangem.domain.wallet;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* Created by Ilia on 15.02.2018.
|
||||
*/
|
||||
|
||||
public class CoinEngineFactory {
|
||||
public static CoinEngine create(Blockchain blockchain) {
|
||||
switch (blockchain) {
|
||||
case Bitcoin:
|
||||
case BitcoinTestNet:
|
||||
return new BtcEngine();
|
||||
case BitcoinCash:
|
||||
case BitcoinCashTestNet:
|
||||
return new BtcCashEngine();
|
||||
case Ethereum:
|
||||
case EthereumTestNet:
|
||||
return new EthEngine();
|
||||
case Token:
|
||||
return new TokenEngine();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static CoinEngine create(TangemContext context) {
|
||||
CoinEngine result;
|
||||
try {
|
||||
if (Blockchain.BitcoinCash == context.getBlockchain() || Blockchain.BitcoinCashTestNet == context.getBlockchain()) {
|
||||
result = new BtcCashEngine(context);
|
||||
} else if (Blockchain.Bitcoin == context.getBlockchain() || Blockchain.BitcoinTestNet == context.getBlockchain()) {
|
||||
result = new BtcEngine(context);
|
||||
} else if (Blockchain.Ethereum == context.getBlockchain() || Blockchain.EthereumTestNet == context.getBlockchain()) {
|
||||
result = new EthEngine(context);
|
||||
} else if (Blockchain.Token == context.getBlockchain()) {
|
||||
result = new TokenEngine(context);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
Log.e("CoinEngineFactory","Can't create CoinEngine!");
|
||||
result=null;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
package com.tangem.domain.wallet
|
||||
|
||||
import android.util.Log
|
||||
|
||||
import com.tangem.domain.wallet.btc.BtcEngine
|
||||
import com.tangem.domain.wallet.btc_cash.BtcCashEngine
|
||||
import com.tangem.domain.wallet.eth.EthEngine
|
||||
import com.tangem.domain.wallet.token.TokenEngine
|
||||
|
||||
/**
|
||||
* Factory for create specific engine.
|
||||
*
|
||||
* @param Blockchain
|
||||
* @param TangemContext
|
||||
*
|
||||
*/
|
||||
|
||||
object CoinEngineFactory {
|
||||
private val TAG = CoinEngineFactory::class.java.simpleName
|
||||
|
||||
fun create(blockchain: Blockchain): CoinEngine? {
|
||||
return when (blockchain) {
|
||||
Blockchain.Bitcoin, Blockchain.BitcoinTestNet -> BtcEngine()
|
||||
Blockchain.BitcoinCash, Blockchain.BitcoinCashTestNet -> BtcCashEngine()
|
||||
Blockchain.Ethereum, Blockchain.EthereumTestNet -> EthEngine()
|
||||
Blockchain.Token -> TokenEngine()
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
fun create(context: TangemContext): CoinEngine? {
|
||||
var result: CoinEngine?
|
||||
try {
|
||||
result = if (Blockchain.BitcoinCash == context.blockchain || Blockchain.BitcoinCashTestNet == context.blockchain)
|
||||
BtcCashEngine(context)
|
||||
else if (Blockchain.Bitcoin == context.blockchain || Blockchain.BitcoinTestNet == context.blockchain)
|
||||
BtcEngine(context)
|
||||
else if (Blockchain.Ethereum == context.blockchain || Blockchain.EthereumTestNet == context.blockchain)
|
||||
EthEngine(context)
|
||||
else if (Blockchain.Token == context.blockchain)
|
||||
TokenEngine(context)
|
||||
else
|
||||
return null
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
result = null
|
||||
Log.e(TAG, "Can't create CoinEngine!")
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -2,7 +2,6 @@ package com.tangem.domain.wallet;
|
|||
|
||||
import android.util.Log;
|
||||
|
||||
import com.tangem.util.BTCUtils;
|
||||
import com.tangem.util.ByteUtil;
|
||||
import com.tangem.util.CryptoUtil;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
package com.tangem.domain.wallet;
|
||||
|
||||
import com.tangem.util.BTCUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -251,7 +251,7 @@ public class TangemCard {
|
|||
return contractAddress;
|
||||
}
|
||||
|
||||
String tokenSymbol = "";
|
||||
public String tokenSymbol = "";
|
||||
|
||||
public void setTokenSymbol(String symbol) {
|
||||
tokenSymbol = symbol;
|
||||
|
|
@ -599,7 +599,7 @@ public class TangemCard {
|
|||
public void setDenomination(byte[] denomination) {
|
||||
this.Denomination = denomination;
|
||||
try {
|
||||
CoinEngine engine=CoinEngineFactory.create(getBlockchain());
|
||||
CoinEngine engine= CoinEngineFactory.INSTANCE.create(getBlockchain());
|
||||
CoinEngine.InternalAmount internalAmount=engine.convertToInternalAmount(denomination);
|
||||
CoinEngine.Amount amount=engine.convertToAmount(internalAmount);
|
||||
this.DenominationText = amount.toString();
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ public class TangemContext {
|
|||
if (bundle.containsKey(EXTRA_BLOCKCHAIN_DATA)) {
|
||||
tangemContext.coinData = CoinData.fromBundle(tangemContext.getBlockchain(), bundle.getBundle(EXTRA_BLOCKCHAIN_DATA));
|
||||
} else {
|
||||
tangemContext.coinData = CoinEngineFactory.create(tangemContext).createCoinData();
|
||||
tangemContext.coinData = CoinEngineFactory.INSTANCE.create(tangemContext).createCoinData();
|
||||
}
|
||||
}
|
||||
tangemContext.error = bundle.getString("Error");
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@ package com.tangem.domain.wallet;
|
|||
* Created by Ilia on 29.09.2017.
|
||||
*/
|
||||
|
||||
import com.tangem.util.BTCUtils;
|
||||
import com.tangem.domain.wallet.btc.BitcoinException;
|
||||
import com.tangem.domain.wallet.btc.BitcoinInputStream;
|
||||
import com.tangem.domain.wallet.btc.BitcoinOutputStream;
|
||||
import com.tangem.util.CryptoUtil;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.domain.wallet;
|
||||
package com.tangem.domain.wallet.btc;
|
||||
|
||||
/**
|
||||
* Created by Ilia on 29.09.2017.
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.domain.wallet;
|
||||
package com.tangem.domain.wallet.btc;
|
||||
|
||||
/**
|
||||
* Created by Ilia on 29.09.2017.
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.domain
|
||||
package com.tangem.domain.wallet.btc
|
||||
|
||||
enum class BitcoinNode(val host: String, val port: Int) {
|
||||
n1("electrum.anduck.net", 50001),
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.domain
|
||||
package com.tangem.domain.wallet.btc
|
||||
|
||||
enum class BitcoinNodeTestNet(val host: String, val port: Int) {
|
||||
n1("testnetnode.arihanc.com", 51001),
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.domain.wallet;
|
||||
package com.tangem.domain.wallet.btc;
|
||||
|
||||
/**
|
||||
* Created by Ilia on 29.09.2017.
|
||||
|
|
@ -1,8 +1,11 @@
|
|||
package com.tangem.domain.wallet;
|
||||
package com.tangem.domain.wallet.btc;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import com.tangem.domain.wallet.CoinData;
|
||||
import com.tangem.domain.wallet.CoinEngine;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.domain.wallet;
|
||||
package com.tangem.domain.wallet.btc;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.text.InputFilter;
|
||||
|
|
@ -6,7 +6,16 @@ import android.text.InputFilter;
|
|||
import com.tangem.data.db.PINStorage;
|
||||
import com.tangem.domain.cardReader.CardProtocol;
|
||||
import com.tangem.domain.cardReader.TLV;
|
||||
import com.tangem.util.BTCUtils;
|
||||
import com.tangem.domain.wallet.BalanceValidator;
|
||||
import com.tangem.domain.wallet.Base58;
|
||||
import com.tangem.domain.wallet.Blockchain;
|
||||
import com.tangem.domain.wallet.CoinData;
|
||||
import com.tangem.domain.wallet.CoinEngine;
|
||||
import com.tangem.domain.wallet.TangemCard;
|
||||
import com.tangem.domain.wallet.TangemContext;
|
||||
import com.tangem.domain.wallet.Transaction;
|
||||
import com.tangem.domain.wallet.UnspentOutputInfo;
|
||||
import com.tangem.domain.wallet.BTCUtils;
|
||||
import com.tangem.util.CryptoUtil;
|
||||
import com.tangem.util.DecimalDigitsInputFilter;
|
||||
import com.tangem.util.DerEncodingUtil;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.domain.wallet;
|
||||
package com.tangem.domain.wallet.btc_cash;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.text.InputFilter;
|
||||
|
|
@ -6,7 +6,17 @@ import android.text.InputFilter;
|
|||
import com.tangem.data.db.PINStorage;
|
||||
import com.tangem.domain.cardReader.CardProtocol;
|
||||
import com.tangem.domain.cardReader.TLV;
|
||||
import com.tangem.util.BTCUtils;
|
||||
import com.tangem.domain.wallet.BalanceValidator;
|
||||
import com.tangem.domain.wallet.Base58;
|
||||
import com.tangem.domain.wallet.Blockchain;
|
||||
import com.tangem.domain.wallet.CoinData;
|
||||
import com.tangem.domain.wallet.CoinEngine;
|
||||
import com.tangem.domain.wallet.TangemCard;
|
||||
import com.tangem.domain.wallet.TangemContext;
|
||||
import com.tangem.domain.wallet.Transaction;
|
||||
import com.tangem.domain.wallet.UnspentOutputInfo;
|
||||
import com.tangem.domain.wallet.btc.BtcData;
|
||||
import com.tangem.domain.wallet.BTCUtils;
|
||||
import com.tangem.util.CryptoUtil;
|
||||
import com.tangem.util.DecimalDigitsInputFilter;
|
||||
import com.tangem.util.DerEncodingUtil;
|
||||
|
|
@ -1,7 +1,11 @@
|
|||
package com.tangem.domain.wallet;
|
||||
package com.tangem.domain.wallet.eth;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import com.tangem.domain.wallet.CoinData;
|
||||
import com.tangem.domain.wallet.CoinEngine;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
public class EthData extends CoinData {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.domain.wallet;
|
||||
package com.tangem.domain.wallet.eth;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.text.InputFilter;
|
||||
|
|
@ -7,7 +7,17 @@ import android.util.Log;
|
|||
import com.tangem.data.db.PINStorage;
|
||||
import com.tangem.domain.cardReader.CardProtocol;
|
||||
import com.tangem.domain.cardReader.TLV;
|
||||
import com.tangem.util.BTCUtils;
|
||||
import com.tangem.domain.wallet.BalanceValidator;
|
||||
import com.tangem.domain.wallet.Blockchain;
|
||||
import com.tangem.domain.wallet.CoinData;
|
||||
import com.tangem.domain.wallet.CoinEngine;
|
||||
import com.tangem.domain.wallet.ECDSASignatureETH;
|
||||
import com.tangem.domain.wallet.EthTransaction;
|
||||
import com.tangem.domain.wallet.Issuer;
|
||||
import com.tangem.domain.wallet.Keccak256;
|
||||
import com.tangem.domain.wallet.TangemCard;
|
||||
import com.tangem.domain.wallet.TangemContext;
|
||||
import com.tangem.domain.wallet.BTCUtils;
|
||||
import com.tangem.util.CryptoUtil;
|
||||
import com.tangem.util.DecimalDigitsInputFilter;
|
||||
import com.tangem.wallet.R;
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
package com.tangem.domain.wallet;
|
||||
package com.tangem.domain.wallet.token;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import com.tangem.domain.wallet.CoinEngine;
|
||||
import com.tangem.domain.wallet.eth.EthData;
|
||||
|
||||
public class TokenData extends EthData {
|
||||
private CoinEngine.InternalAmount balanceAlter = null;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.domain.wallet;
|
||||
package com.tangem.domain.wallet.token;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.text.InputFilter;
|
||||
|
|
@ -8,7 +8,16 @@ import com.google.common.base.Strings;
|
|||
import com.tangem.data.db.PINStorage;
|
||||
import com.tangem.domain.cardReader.CardProtocol;
|
||||
import com.tangem.domain.cardReader.TLV;
|
||||
import com.tangem.util.BTCUtils;
|
||||
import com.tangem.domain.wallet.BalanceValidator;
|
||||
import com.tangem.domain.wallet.CoinData;
|
||||
import com.tangem.domain.wallet.CoinEngine;
|
||||
import com.tangem.domain.wallet.ECDSASignatureETH;
|
||||
import com.tangem.domain.wallet.EthTransaction;
|
||||
import com.tangem.domain.wallet.Issuer;
|
||||
import com.tangem.domain.wallet.Keccak256;
|
||||
import com.tangem.domain.wallet.TangemCard;
|
||||
import com.tangem.domain.wallet.TangemContext;
|
||||
import com.tangem.domain.wallet.BTCUtils;
|
||||
import com.tangem.util.CryptoUtil;
|
||||
import com.tangem.util.DecimalDigitsInputFilter;
|
||||
import com.tangem.wallet.R;
|
||||
|
|
@ -19,6 +19,7 @@ import com.tangem.data.network.ServerApiHelperElectrum
|
|||
import com.tangem.data.network.model.InfuraResponse
|
||||
import com.tangem.domain.cardReader.NfcManager
|
||||
import com.tangem.domain.wallet.*
|
||||
import com.tangem.domain.wallet.btc.BtcData
|
||||
import com.tangem.util.*
|
||||
import com.tangem.wallet.R
|
||||
import kotlinx.android.synthetic.main.activity_confirm_payment.*
|
||||
|
|
@ -200,7 +201,7 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
try {
|
||||
if (etFee.text.toString().isEmpty()) etFee.setText(getString(R.string.empty))
|
||||
val engine = CoinEngineFactory.create(ctx)
|
||||
val balance = engine.convertToAmount(CoinEngine.InternalAmount(electrumRequest.result.getLong("confirmed") + electrumRequest.result.getLong("unconfirmed"), "Satoshi"))
|
||||
val balance = engine!!.convertToAmount(CoinEngine.InternalAmount(electrumRequest.result.getLong("confirmed") + electrumRequest.result.getLong("unconfirmed"), "Satoshi"))
|
||||
val amount = CoinEngine.Amount(etAmount.text.toString(), ctx.blockchain.currency)
|
||||
if (balance < amount) {
|
||||
etFee.error = getString(R.string.not_enough_funds)
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@ import android.text.TextUtils
|
|||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.widget.Button
|
||||
import com.tangem.data.network.task.request_pin.StartFingerprintReaderTask
|
||||
import com.tangem.data.fingerprint.StartFingerprintReaderTask
|
||||
import com.tangem.domain.cardReader.NfcManager
|
||||
import com.tangem.domain.wallet.FingerprintHelper
|
||||
import com.tangem.data.fingerprint.FingerprintHelper
|
||||
import com.tangem.data.db.PINStorage
|
||||
import com.tangem.domain.wallet.TangemCard
|
||||
import com.tangem.wallet.R
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ import android.text.TextUtils
|
|||
import android.view.View
|
||||
import android.widget.Button
|
||||
import android.widget.Toast
|
||||
import com.tangem.data.network.task.save_pin.ConfirmWithFingerprintTask
|
||||
import com.tangem.domain.wallet.FingerprintHelper
|
||||
import com.tangem.data.fingerprint.ConfirmWithFingerprintTask
|
||||
import com.tangem.data.fingerprint.FingerprintHelper
|
||||
import com.tangem.data.db.PINStorage
|
||||
import com.tangem.wallet.R
|
||||
import kotlinx.android.synthetic.main.activity_pin_save.*
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ class PrepareCryptonitOtherAPIWithdrawalActivity : AppCompatActivity(), NfcAdapt
|
|||
tvWallet.text = ctx.card!!.wallet
|
||||
val engine = CoinEngineFactory.create(ctx)
|
||||
|
||||
tvCurrency.text = engine.balanceCurrency
|
||||
tvCurrency.text = engine!!.balanceCurrency
|
||||
|
||||
etAmount.setText(engine.convertToAmount(engine.convertToInternalAmount(ctx.card!!.denomination)).toValueString())
|
||||
etAmount.filters=engine.amountInputFilters
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class PrepareCryptonitWithdrawalActivity : AppCompatActivity(), NfcAdapter.Reade
|
|||
tvWallet.text = ctx.card!!.wallet
|
||||
val engine = CoinEngineFactory.create(ctx)
|
||||
|
||||
tvCurrency.text = engine.balanceCurrency
|
||||
tvCurrency.text = engine!!.balanceCurrency
|
||||
tvFeeCurrency.text = engine.feeCurrency
|
||||
|
||||
etAmount.setText(engine.convertToAmount(engine.convertToInternalAmount(ctx.card!!.denomination)).toValueString())
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ class PrepareKrakenWithdrawalActivity : AppCompatActivity(), NfcAdapter.ReaderCa
|
|||
tvWallet.text = ctx.card!!.wallet
|
||||
val engine = CoinEngineFactory.create(ctx)
|
||||
|
||||
tvCurrency.text = engine.balanceCurrency
|
||||
tvCurrency.text = engine!!.balanceCurrency
|
||||
|
||||
etAmount.setText(engine.convertToAmount(engine.convertToInternalAmount(ctx.card!!.denomination)).toValueString())
|
||||
etAmount.filters=engine.amountInputFilters
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ class PreparePaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
val engine1 = CoinEngineFactory.create(ctx)
|
||||
|
||||
val strAmount: String = etAmount.text.toString().replace(",", ".")
|
||||
val amount = engine1.convertToAmount(etAmount.text.toString(), tvCurrency.text.toString())
|
||||
val amount = engine1!!.convertToAmount(etAmount.text.toString(), tvCurrency.text.toString())
|
||||
|
||||
try {
|
||||
if (!engine.checkNewTransactionAmount(amount))
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ import com.tangem.data.network.ServerApiHelperElectrum
|
|||
import com.tangem.data.network.model.InfuraResponse
|
||||
import com.tangem.domain.cardReader.NfcManager
|
||||
import com.tangem.domain.wallet.*
|
||||
import com.tangem.domain.wallet.eth.EthData
|
||||
import com.tangem.util.UtilHelper
|
||||
import com.tangem.wallet.R
|
||||
import org.json.JSONException
|
||||
import java.io.IOException
|
||||
import java.math.BigInteger
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Toast
|
||||
import com.tangem.data.db.LocalStorage
|
||||
import com.tangem.data.db.PINStorage
|
||||
import com.tangem.data.network.ElectrumRequest
|
||||
import com.tangem.data.network.ServerApiHelper
|
||||
|
|
@ -29,6 +30,10 @@ import com.tangem.data.nfc.VerifyCardTask
|
|||
import com.tangem.domain.cardReader.CardProtocol
|
||||
import com.tangem.domain.cardReader.NfcManager
|
||||
import com.tangem.domain.wallet.*
|
||||
import com.tangem.domain.wallet.btc.BtcData
|
||||
import com.tangem.domain.wallet.eth.EthData
|
||||
import com.tangem.domain.wallet.token.TokenData
|
||||
import com.tangem.domain.wallet.token.TokenEngine
|
||||
import com.tangem.presentation.activity.*
|
||||
import com.tangem.presentation.dialog.NoExtendedLengthSupportDialog
|
||||
import com.tangem.presentation.dialog.PINSwapWarningDialog
|
||||
|
|
@ -121,7 +126,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
// set listeners
|
||||
srl!!.setOnRefreshListener { refresh() }
|
||||
btnLookup.setOnClickListener {
|
||||
val engine=CoinEngineFactory.create(ctx)
|
||||
val engine = CoinEngineFactory.create(ctx)
|
||||
val browserIntent = Intent(Intent.ACTION_VIEW, engine!!.shareWalletUriExplorer)
|
||||
startActivity(browserIntent)
|
||||
}
|
||||
|
|
@ -137,7 +142,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
when (items[which]) {
|
||||
getString(R.string.in_app) -> {
|
||||
try {
|
||||
val engine=CoinEngineFactory.create(ctx)
|
||||
val engine = CoinEngineFactory.create(ctx)
|
||||
val intent = Intent(Intent.ACTION_VIEW, engine!!.shareWalletUri)
|
||||
intent.addCategory(Intent.CATEGORY_DEFAULT)
|
||||
startActivity(intent)
|
||||
|
|
@ -149,7 +154,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
doShareWallet(true)
|
||||
}
|
||||
getString(R.string.load_via_qr) -> {
|
||||
val engine=CoinEngineFactory.create(ctx)
|
||||
val engine = CoinEngineFactory.create(ctx)
|
||||
ShowQRCodeDialog.show(activity, engine!!.shareWalletUri.toString())
|
||||
}
|
||||
// getString(R.string.via_cryptonit2) -> {
|
||||
|
|
@ -178,7 +183,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
dlg.window.attributes = wlp
|
||||
} else {
|
||||
try {
|
||||
val engine=CoinEngineFactory.create(ctx)
|
||||
val engine = CoinEngineFactory.create(ctx)
|
||||
val intent = Intent(Intent.ACTION_VIEW, engine!!.shareWalletUri)
|
||||
intent.addCategory(Intent.CATEGORY_DEFAULT)
|
||||
startActivity(intent)
|
||||
|
|
@ -198,7 +203,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
startActivity(intent)
|
||||
}
|
||||
btnExtract.setOnClickListener {
|
||||
val engine=CoinEngineFactory.create(ctx)
|
||||
val engine = CoinEngineFactory.create(ctx)
|
||||
if (UtilHelper.isOnline(activity)) {
|
||||
if (!engine!!.isExtractPossible)
|
||||
showSingleToast(ctx.message)
|
||||
|
|
@ -305,8 +310,8 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
// (ctx.coinData!! as EthData).balanceUnconfirmed = 0L
|
||||
if (ctx.blockchain != Blockchain.Token) {
|
||||
(ctx.coinData!! as EthData).isBalanceReceived = true
|
||||
(ctx.coinData!! as EthData).balanceInInternalUnits = CoinEngine.InternalAmount(l.toBigDecimal(),"wei")
|
||||
}else{
|
||||
(ctx.coinData!! as EthData).balanceInInternalUnits = CoinEngine.InternalAmount(l.toBigDecimal(), "wei")
|
||||
} else {
|
||||
(ctx.coinData!! as TokenData).isBalanceReceived = true
|
||||
//(ctx.coinData!! as TokenData).balanceInInternalUnits = CoinEngine.InternalAmount(l.toBigDecimal(),ctx.card.tokenSymbol)
|
||||
(ctx.coinData!! as TokenData).balanceAlterInInternalUnits = CoinEngine.InternalAmount(l.toBigDecimal(), "wei")
|
||||
|
|
@ -355,7 +360,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
// requestInfura(ServerApiHelper.INFURA_ETH_GET_PENDING_COUNT, "")
|
||||
// return
|
||||
// }
|
||||
(ctx.coinData!! as EthData).balanceInInternalUnits = CoinEngine.InternalAmount(l.toBigDecimal(),ctx.card.tokenSymbol)
|
||||
(ctx.coinData!! as EthData).balanceInInternalUnits = CoinEngine.InternalAmount(l.toBigDecimal(), ctx.card.tokenSymbol)
|
||||
|
||||
// Log.i("$TAG eth_call", balanceCap)
|
||||
|
||||
|
|
@ -760,7 +765,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
tvBalanceLine2.text = validator.getSecondLine(false)
|
||||
}
|
||||
|
||||
val engine=CoinEngineFactory.create(ctx)
|
||||
val engine = CoinEngineFactory.create(ctx)
|
||||
if (engine!!.hasBalanceInfo() || ctx.card!!.offlineBalance == null) {
|
||||
val html = Html.fromHtml(engine!!.balanceHTML)
|
||||
tvBalance.text = html
|
||||
|
|
|
|||
|
|
@ -286,7 +286,7 @@ class VerifyCard : Fragment(), NfcAdapter.ReaderCallback {
|
|||
|
||||
val engine = CoinEngineFactory.create(ctx)
|
||||
|
||||
tvInputs.text = engine.unspentInputsDescription
|
||||
tvInputs.text = engine!!.unspentInputsDescription
|
||||
|
||||
ivBlockchain.setImageResource(Blockchain.getLogoImageResource(ctx.card!!.blockchainID, ctx.card!!.tokenSymbol))
|
||||
|
||||
|
|
@ -468,7 +468,7 @@ class VerifyCard : Fragment(), NfcAdapter.ReaderCallback {
|
|||
private fun doPurge() {
|
||||
requestPIN2Count = 0
|
||||
val engine=CoinEngineFactory.create(ctx)
|
||||
if (!engine.hasBalanceInfo()) {
|
||||
if (!engine!!.hasBalanceInfo()) {
|
||||
return
|
||||
} else if (engine.isBalanceNotZero) {
|
||||
Toast.makeText(context, R.string.cannot_erase_wallet_with_non_zero_balance, Toast.LENGTH_LONG).show()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package com.tangem.util;
|
||||
|
||||
import com.tangem.domain.wallet.BitcoinOutputStream;
|
||||
import com.tangem.domain.wallet.btc.BitcoinOutputStream;
|
||||
|
||||
import org.spongycastle.asn1.ASN1Integer;
|
||||
import org.spongycastle.asn1.DERSequenceGenerator;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.domain.wallet;
|
||||
package com.tangem.util;
|
||||
|
||||
/**
|
||||
* Created by Ilia on 20.04.2018.
|
||||
|
|
@ -2,8 +2,6 @@ package com.tangem.util;
|
|||
|
||||
import android.os.Build;
|
||||
|
||||
import com.tangem.domain.wallet.DeviceName;
|
||||
|
||||
/**
|
||||
* Created by Ilia on 20.04.2018.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,52 +0,0 @@
|
|||
package com.tangem.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.support.v7.widget.AppCompatTextView;
|
||||
import android.text.TextPaint;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.Gravity;
|
||||
|
||||
public class VerticalTextView extends AppCompatTextView {
|
||||
final boolean topDown;
|
||||
|
||||
public VerticalTextView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
final int gravity = getGravity();
|
||||
if (Gravity.isVertical(gravity) && (gravity & Gravity.VERTICAL_GRAVITY_MASK) == Gravity.BOTTOM) {
|
||||
setGravity((gravity & Gravity.HORIZONTAL_GRAVITY_MASK) | Gravity.TOP);
|
||||
topDown = false;
|
||||
} else {
|
||||
topDown = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(heightMeasureSpec, widthMeasureSpec);
|
||||
setMeasuredDimension(getMeasuredHeight(), getMeasuredWidth());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
TextPaint textPaint = getPaint();
|
||||
textPaint.setColor(getCurrentTextColor());
|
||||
textPaint.drawableState = getDrawableState();
|
||||
|
||||
canvas.save();
|
||||
|
||||
if (topDown) {
|
||||
canvas.translate(getWidth(), 0);
|
||||
canvas.rotate(90);
|
||||
} else {
|
||||
canvas.translate(0, getHeight());
|
||||
canvas.rotate(-90);
|
||||
}
|
||||
|
||||
canvas.translate(getCompoundPaddingLeft(), getExtendedPaddingTop());
|
||||
|
||||
getLayout().draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue