Updated on 2026-08-14
This commit is contained in:
commit
700f62e25e
597 changed files with 23678 additions and 1823 deletions
|
|
@ -1,7 +1,7 @@
|
|||
package com.tangem;
|
||||
|
||||
import android.app.Application;
|
||||
import android.support.v7.app.AppCompatDelegate;
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
|
@ -22,7 +22,6 @@ import java.lang.reflect.Type;
|
|||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class App extends Application {
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ object Constant {
|
|||
const val EXTRA_MODIFICATION_UPDATE = "update"
|
||||
|
||||
// LoadedWallet, VerifyCard
|
||||
const val REQUEST_CODE_SEND_PAYMENT = 1
|
||||
const val REQUEST_CODE_SEND_TRANSACTION = 1
|
||||
const val REQUEST_CODE_PURGE = 2
|
||||
const val REQUEST_CODE_REQUEST_PIN2_FOR_PURGE = 3
|
||||
const val REQUEST_CODE_VERIFY_CARD = 4
|
||||
|
|
@ -21,7 +21,7 @@ object Constant {
|
|||
const val REQUEST_CODE_ENTER_NEW_PIN2 = 6
|
||||
const val REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN = 7
|
||||
const val REQUEST_CODE_SWAP_PIN = 8
|
||||
const val REQUEST_CODE_RECEIVE_PAYMENT = 9
|
||||
const val REQUEST_CODE_RECEIVE_TRANSACTION = 9
|
||||
|
||||
// MainActivity
|
||||
const val REQUEST_CODE_SHOW_CARD_ACTIVITY = 1
|
||||
|
|
@ -57,26 +57,26 @@ object Constant {
|
|||
const val REQUEST_CODE_CREATE_NEW_WALLET_ACTIVITY = 2
|
||||
const val REQUEST_CODE_REQUEST_PIN2 = 3
|
||||
|
||||
// ConfirmPaymentActivity
|
||||
const val REQUEST_CODE_SIGN_PAYMENT = 1
|
||||
// ConfirmTransactionActivity
|
||||
const val REQUEST_CODE_SIGN_TRANSACTION = 1
|
||||
const val REQUEST_CODE_REQUEST_PIN2_ = 2
|
||||
|
||||
// SendTransactionActivity
|
||||
const val EXTRA_TX: String = "TX"
|
||||
|
||||
// SignPaymentActivity
|
||||
// SignTransactionActivity
|
||||
const val EXTRA_AMOUNT = "Amount"
|
||||
const val EXTRA_AMOUNT_CURRENCY = "AmountCurrency"
|
||||
const val EXTRA_FEE = "Fee"
|
||||
const val EXTRA_FEE_CURRENCY = "FeeCurrency"
|
||||
const val EXTRA_FEE_INCLUDED = "FeeIncluded"
|
||||
const val EXTRA_TARGET_ADDRESS = "TargetAddress"
|
||||
const val REQUEST_CODE_SEND_PAYMENT_ = 1
|
||||
const val REQUEST_CODE_SEND_TRANSACTION_ = 1
|
||||
const val RESULT_INVALID_PIN_ = Activity.RESULT_FIRST_USER
|
||||
|
||||
// PreparePaymentActivity
|
||||
// PrepareTransactionActivity
|
||||
const val REQUEST_CODE_SCAN_QR = 1
|
||||
const val REQUEST_CODE_SEND_PAYMENT__ = 2
|
||||
const val REQUEST_CODE_SEND_TRANSACTION__ = 2
|
||||
|
||||
// PrepareCryptonitOtherApiWithdrawalActivity
|
||||
const val REQUEST_CODE_SCAN_QR_KEY = 1
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package com.tangem.data.network;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.support.annotation.NonNull;
|
||||
import androidx.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
|
||||
import com.tangem.App;
|
||||
|
|
@ -24,18 +24,18 @@ public class ServerApiCommon {
|
|||
public static final int ESTIMATE_FEE_PRIORITY = 2;
|
||||
public static final int ESTIMATE_FEE_NORMAL = 3;
|
||||
public static final int ESTIMATE_FEE_MINIMAL = 6;
|
||||
private EstimateFeeListener estimateFeeListener;
|
||||
private EstimatedFeeListener estimatedFeeListener;
|
||||
|
||||
public interface EstimateFeeListener {
|
||||
public interface EstimatedFeeListener {
|
||||
void onSuccess(int blockCount, String estimateFeeResponse);
|
||||
void onFail(int blockCount, String message);
|
||||
}
|
||||
|
||||
public void setEstimateFee(EstimateFeeListener listener) {
|
||||
estimateFeeListener = listener;
|
||||
public void setBtcEstimatedFeeListener(EstimatedFeeListener listener) {
|
||||
estimatedFeeListener = listener;
|
||||
}
|
||||
|
||||
public void estimateFee(int blockCount) {
|
||||
public void requestBtcEstimatedFee(int blockCount) {
|
||||
EstimatefeeApi estimatefeeApi = App.getNetworkComponent().getRetrofitEstimatefee().create(EstimatefeeApi.class);
|
||||
|
||||
Call<String> call;
|
||||
|
|
@ -60,17 +60,17 @@ public class ServerApiCommon {
|
|||
@Override
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||
if (response.code() == 200) {
|
||||
estimateFeeListener.onSuccess(blockCount, response.body());
|
||||
Log.i(TAG, "estimateFee onResponse " + response.code() + " " + response.body());
|
||||
estimatedFeeListener.onSuccess(blockCount, response.body());
|
||||
Log.i(TAG, "requestBtcEstimatedFee onResponse " + response.code() + " " + response.body());
|
||||
} else
|
||||
estimateFeeListener.onFail(blockCount, response.body());
|
||||
Log.e(TAG, "estimateFee onResponse " + response.code());
|
||||
estimatedFeeListener.onFail(blockCount, response.body());
|
||||
Log.e(TAG, "requestBtcEstimatedFee onResponse " + response.code());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
|
||||
estimateFeeListener.onFail(blockCount, t.getMessage());
|
||||
Log.e(TAG, "estimateFee onFailure " + t.getMessage());
|
||||
estimatedFeeListener.onFail(blockCount, t.getMessage());
|
||||
Log.e(TAG, "requestBtcEstimatedFee onFailure " + t.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -79,18 +79,18 @@ public class ServerApiCommon {
|
|||
* HTTP
|
||||
* Used in Crypto-currency course
|
||||
*/
|
||||
private RateInfoDataListener rateInfoDataListener;
|
||||
private RateInfoListener rateInfoListener;
|
||||
|
||||
public interface RateInfoDataListener {
|
||||
public interface RateInfoListener {
|
||||
void onSuccess(RateInfoResponse rateInfoResponse);
|
||||
}
|
||||
|
||||
public void setRateInfoData(RateInfoDataListener listener) {
|
||||
rateInfoDataListener = listener;
|
||||
public void setRateInfoListener(RateInfoListener listener) {
|
||||
rateInfoListener = listener;
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
public void rateInfoData(String cryptoId) {
|
||||
public void requestRateInfo(String cryptoId) {
|
||||
CoinmarketApi coinmarketApi = App.getNetworkComponent().getRetrofitCoinmarketcap().create(CoinmarketApi.class);
|
||||
|
||||
coinmarketApi.getRateInfoList()
|
||||
|
|
@ -100,12 +100,12 @@ public class ServerApiCommon {
|
|||
if (!rateInfoModelList.isEmpty()) {
|
||||
for (RateInfoResponse rateInfoMode : rateInfoModelList) {
|
||||
if (rateInfoMode.getId().equals(cryptoId)) {
|
||||
rateInfoDataListener.onSuccess(rateInfoMode);
|
||||
Log.i(TAG, "rateInfoData " + cryptoId + " onResponse " + "200");
|
||||
rateInfoListener.onSuccess(rateInfoMode);
|
||||
Log.i(TAG, "requestRateInfo " + cryptoId + " onResponse " + "200");
|
||||
}
|
||||
}
|
||||
} else
|
||||
Log.e(TAG, "rateInfoData " + cryptoId + " onResponse " + "Empty");
|
||||
Log.e(TAG, "requestRateInfo " + cryptoId + " onResponse " + "Empty");
|
||||
},
|
||||
// handle error
|
||||
Throwable::printStackTrace);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import com.tangem.domain.wallet.bch.BitcoinCashNode;
|
|||
import com.tangem.domain.wallet.btc.BitcoinNode;
|
||||
import com.tangem.domain.wallet.btc.BitcoinNodeTestNet;
|
||||
import com.tangem.domain.wallet.ltc.LitecoinNode;
|
||||
import com.tangem.tangemcard.reader.CardProtocol;
|
||||
import com.tangem.wallet.R;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
|
|
@ -24,7 +23,6 @@ import java.net.InetSocketAddress;
|
|||
import java.net.Socket;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
|
@ -47,13 +45,13 @@ import io.reactivex.schedulers.Schedulers;
|
|||
/**
|
||||
* Request processor for Electrum Api
|
||||
* Every request live cycle:
|
||||
* 1. In application create request and call {@link ServerApiElectrum}.electrumRequestData(..)
|
||||
* 1. In application create request and call {@link ServerApiElectrum}.requestData(..)
|
||||
* 2. Try send every request for max 4 times,
|
||||
* 3. If all 4 times fail call DefaultObserver<ElectrumRequest>.onError (defined in .electrumRequestData(..)) and than
|
||||
* {@link ElectrumRequestDataListener}.onFail(...) callback
|
||||
* 3. If all 4 times fail call DefaultObserver<ElectrumRequest>.onError (defined in .requestData(..)) and than
|
||||
* {@link ResponseListener}.onFail(...) callback
|
||||
* Error can be acquired with {@link ElectrumRequest}.getError() method
|
||||
* 4. If request network communication finished successfully then call DefaultObserver<ElectrumRequest>.onComplete (defined in .electrumRequestData) and than
|
||||
* {@link ElectrumRequestDataListener}.onSuccess(...) callback
|
||||
* 4. If request network communication finished successfully then call DefaultObserver<ElectrumRequest>.onComplete (defined in .requestData) and than
|
||||
* {@link ResponseListener}.onSuccess(...) callback
|
||||
*/
|
||||
public class ServerApiElectrum {
|
||||
private static String TAG = ServerApiElectrum.class.getSimpleName();
|
||||
|
|
@ -62,7 +60,7 @@ public class ServerApiElectrum {
|
|||
* TCP, SSL
|
||||
* Used in BTC, BCH
|
||||
*/
|
||||
private ElectrumRequestDataListener electrumRequestDataListener;
|
||||
private ResponseListener responseListener;
|
||||
private String host;
|
||||
private int port;
|
||||
|
||||
|
|
@ -76,7 +74,7 @@ public class ServerApiElectrum {
|
|||
/**
|
||||
* Interface for notification every request result
|
||||
*/
|
||||
public interface ElectrumRequestDataListener {
|
||||
public interface ResponseListener {
|
||||
|
||||
/**
|
||||
* Notify that request processing was successful
|
||||
|
|
@ -94,8 +92,8 @@ public class ServerApiElectrum {
|
|||
* Set notificaion listener
|
||||
* @param listener
|
||||
*/
|
||||
public void setElectrumRequestData(ElectrumRequestDataListener listener) {
|
||||
electrumRequestDataListener = listener;
|
||||
public void setResponseListener(ResponseListener listener) {
|
||||
responseListener = listener;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -104,7 +102,7 @@ public class ServerApiElectrum {
|
|||
* @param ctx
|
||||
* @param electrumRequest
|
||||
*/
|
||||
public void electrumRequestData(TangemContext ctx, ElectrumRequest electrumRequest) {
|
||||
public void requestData(TangemContext ctx, ElectrumRequest electrumRequest) {
|
||||
requestsCount++;
|
||||
Log.i(TAG, String.format("New request[%d]: %s", requestsCount,electrumRequest.getMethod()));
|
||||
Observable<ElectrumRequest> checkElectrumDataObserver = Observable.just(electrumRequest)
|
||||
|
|
@ -129,20 +127,20 @@ public class ServerApiElectrum {
|
|||
@Override
|
||||
public void onNext(ElectrumRequest v) {
|
||||
if (electrumRequest.answerData != null) {
|
||||
Log.i(TAG, "electrumRequestData " + electrumRequest.getMethod() + " onNext != null");
|
||||
Log.i(TAG, "requestData " + electrumRequest.getMethod() + " onNext != null");
|
||||
} else {
|
||||
Log.e(TAG, "electrumRequestData " + electrumRequest.getMethod() + " onNext == null");
|
||||
Log.e(TAG, "requestData " + electrumRequest.getMethod() + " onNext == null");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
requestsCount--;
|
||||
Log.e(TAG, "electrumRequestData " + electrumRequest.getMethod() + " onError " + e.getMessage());
|
||||
Log.e(TAG, "requestData " + electrumRequest.getMethod() + " onError " + e.getMessage());
|
||||
Log.e(TAG, String.format("%d requests left in processing",requestsCount));
|
||||
electrumRequest.setError(ctx.getString(R.string.cannot_obtain_data_from_blockchain));
|
||||
//setErrorOccurred(e.getMessage());//;
|
||||
electrumRequestDataListener.onFail(electrumRequest);
|
||||
responseListener.onFail(electrumRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -152,16 +150,16 @@ public class ServerApiElectrum {
|
|||
public void onComplete() {
|
||||
requestsCount--;
|
||||
if (electrumRequest.answerData != null) {
|
||||
Log.i(TAG, "electrumRequestData " + electrumRequest.getMethod() + " onComplete, answerData!=null");
|
||||
Log.i(TAG, "requestData " + electrumRequest.getMethod() + " onComplete, answerData!=null");
|
||||
} else {
|
||||
Log.e(TAG, "electrumRequestData " + electrumRequest.getMethod() + " onComplete, answerData==null");
|
||||
Log.e(TAG, "requestData " + electrumRequest.getMethod() + " onComplete, answerData==null");
|
||||
}
|
||||
Log.e(TAG, String.format("%d requests left in processing",requestsCount));
|
||||
if (electrumRequest.answerData != null && electrumRequest.getError()==null) {
|
||||
electrumRequestDataListener.onSuccess(electrumRequest);
|
||||
responseListener.onSuccess(electrumRequest);
|
||||
} else {
|
||||
// if( error==null || error.isEmpty() ) setErrorOccurred(ctx.getString(R.string.cannot_obtain_data_from_blockchain));
|
||||
electrumRequestDataListener.onFail(electrumRequest);
|
||||
responseListener.onFail(electrumRequest);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -257,7 +255,7 @@ public class ServerApiElectrum {
|
|||
|
||||
} catch (ConnectException e) {
|
||||
//e.printStackTrace();
|
||||
//electrumRequestDataListener.onFail(e.getMessage());
|
||||
//responseListener.onFail(e.getMessage());
|
||||
electrumRequest.setError(App.getInstance().getString(R.string.cannot_obtain_data_from_blockchain_no_connection));
|
||||
Log.e(TAG, "doElectrumRequestTcp " + electrumRequest.getMethod() + " ConnectException " + e.getMessage());
|
||||
} finally {
|
||||
|
|
@ -274,7 +272,7 @@ public class ServerApiElectrum {
|
|||
}
|
||||
} catch (IOException e) {
|
||||
//e.printStackTrace();
|
||||
//electrumRequestDataListener.onFail(e.getMessage());
|
||||
//responseListener.onFail(e.getMessage());
|
||||
electrumRequest.setError(App.getInstance().getString(R.string.cannot_obtain_data_from_blockchain_communication_error));
|
||||
Log.e(TAG, "doElectrumRequestTcp " + electrumRequest.getMethod() + " IOException " + e.getMessage());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package com.tangem.data.network;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import androidx.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
|
||||
import com.tangem.App;
|
||||
|
|
@ -38,19 +38,19 @@ public class ServerApiInfura {
|
|||
return requestsCount <= 0;
|
||||
}
|
||||
|
||||
private InfuraBodyListener infuraBodyListener;
|
||||
private ResponseListener responseListener;
|
||||
|
||||
public interface InfuraBodyListener {
|
||||
public interface ResponseListener {
|
||||
void onSuccess(String method, InfuraResponse infuraResponse);
|
||||
|
||||
void onFail(String method, String message);
|
||||
}
|
||||
|
||||
public void setInfuraResponse(InfuraBodyListener listener) {
|
||||
infuraBodyListener = listener;
|
||||
public void setResponseListener(ResponseListener listener) {
|
||||
responseListener = listener;
|
||||
}
|
||||
|
||||
public void infura(String method, int id, String wallet, String contract, String tx) {
|
||||
public void requestData(String method, int id, String wallet, String contract, String tx) {
|
||||
requestsCount++;
|
||||
InfuraApi infuraApi = App.getNetworkComponent().getRetrofitInfura().create(InfuraApi.class);
|
||||
|
||||
|
|
@ -86,18 +86,18 @@ public class ServerApiInfura {
|
|||
public void onResponse(@NonNull Call<InfuraResponse> call, @NonNull Response<InfuraResponse> response) {
|
||||
if (response.code() == 200) {
|
||||
requestsCount--;
|
||||
infuraBodyListener.onSuccess(method, response.body());
|
||||
Log.i(TAG, "infura " + method + " onResponse " + response.code());
|
||||
responseListener.onSuccess(method, response.body());
|
||||
Log.i(TAG, "requestData " + method + " onResponse " + response.code());
|
||||
} else {
|
||||
infuraBodyListener.onFail(method, String.valueOf(response.code()));
|
||||
Log.e(TAG, "infura " + method + " onResponse " + response.code());
|
||||
responseListener.onFail(method, String.valueOf(response.code()));
|
||||
Log.e(TAG, "requestData " + method + " onResponse " + response.code());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<InfuraResponse> call, @NonNull Throwable t) {
|
||||
infuraBodyListener.onFail(method, String.valueOf(t.getMessage()));
|
||||
Log.e(TAG, "infura " + method + " onFailure " + t.getMessage());
|
||||
responseListener.onFail(method, String.valueOf(t.getMessage()));
|
||||
Log.e(TAG, "requestData " + method + " onFailure " + t.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package com.tangem.data.network;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import androidx.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
|
||||
import com.tangem.data.network.model.InsightBody;
|
||||
|
|
@ -32,21 +32,21 @@ public class ServerApiInsight {
|
|||
return requestsCount <= 0;
|
||||
}
|
||||
|
||||
private InsightBodyListener insightBodyListener;
|
||||
private ResponseListener responseListener;
|
||||
|
||||
public interface InsightBodyListener {
|
||||
public interface ResponseListener {
|
||||
void onSuccess(String method, InsightResponse insightResponse);
|
||||
void onSuccess(String method, List<InsightResponse> utxoList);
|
||||
void onFail(String method, String message);
|
||||
}
|
||||
|
||||
public void setInsightResponse(InsightBodyListener listener) {
|
||||
insightBodyListener = listener;
|
||||
public void setResponseListener(ResponseListener listener) {
|
||||
responseListener = listener;
|
||||
}
|
||||
|
||||
public void insight(String method, String wallet, String tx) {
|
||||
public void requestData(String method, String wallet, String tx) {
|
||||
requestsCount++;
|
||||
String insightURL = "http://130.185.109.17:3001/insight-api"; //TODO: make random selection
|
||||
String insightURL = "http://130.185.109.17:3001/requestData-api"; //TODO: make random selection
|
||||
this.lastNode = insightURL; //TODO: show node instead of URL
|
||||
|
||||
Retrofit retrofitInsight = new Retrofit.Builder() //TODO: move to NetworkModule+NetworkComponent if possible
|
||||
|
|
@ -64,18 +64,18 @@ public class ServerApiInsight {
|
|||
public void onResponse(@NonNull Call<List<InsightResponse>> call, @NonNull Response<List<InsightResponse>> response) {
|
||||
if (response.code() == 200) {
|
||||
requestsCount--;
|
||||
insightBodyListener.onSuccess(method, response.body());
|
||||
Log.i(TAG, "insight " + method + " onResponse " + response.code());
|
||||
responseListener.onSuccess(method, response.body());
|
||||
Log.i(TAG, "requestData " + method + " onResponse " + response.code());
|
||||
} else {
|
||||
insightBodyListener.onFail(method, String.valueOf(response.code()));
|
||||
Log.e(TAG, "insight " + method + " onResponse " + response.code());
|
||||
responseListener.onFail(method, String.valueOf(response.code()));
|
||||
Log.e(TAG, "requestData " + method + " onResponse " + response.code());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<InsightResponse>> call, @NonNull Throwable t) {
|
||||
insightBodyListener.onFail(method, String.valueOf(t.getMessage()));
|
||||
Log.e(TAG, "insight " + method + " onFailure " + t.getMessage());
|
||||
responseListener.onFail(method, String.valueOf(t.getMessage()));
|
||||
Log.e(TAG, "requestData " + method + " onFailure " + t.getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -112,18 +112,18 @@ public class ServerApiInsight {
|
|||
public void onResponse(@NonNull Call<InsightResponse> call, @NonNull Response<InsightResponse> response) {
|
||||
if (response.code() == 200) {
|
||||
requestsCount--;
|
||||
insightBodyListener.onSuccess(method, response.body());
|
||||
Log.i(TAG, "insight " + method + " onResponse " + response.code());
|
||||
responseListener.onSuccess(method, response.body());
|
||||
Log.i(TAG, "requestData " + method + " onResponse " + response.code());
|
||||
} else {
|
||||
insightBodyListener.onFail(method, String.valueOf(response.code()));
|
||||
Log.e(TAG, "insight " + method + " onResponse " + response.code());
|
||||
responseListener.onFail(method, String.valueOf(response.code()));
|
||||
Log.e(TAG, "requestData " + method + " onResponse " + response.code());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<InsightResponse> call, @NonNull Throwable t) {
|
||||
insightBodyListener.onFail(method, String.valueOf(t.getMessage()));
|
||||
Log.e(TAG, "insight " + method + " onFailure " + t.getMessage());
|
||||
responseListener.onFail(method, String.valueOf(t.getMessage()));
|
||||
Log.e(TAG, "requestData " + method + " onFailure " + t.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package com.tangem.data.network;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import androidx.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
|
||||
import com.tangem.App;
|
||||
|
|
@ -38,19 +38,19 @@ public class ServerApiRootstock {
|
|||
return requestsCount <= 0;
|
||||
}
|
||||
|
||||
private RootstockBodyListener rootstockBodyListener;
|
||||
private ResponseListener responseListener;
|
||||
|
||||
public interface RootstockBodyListener {
|
||||
public interface ResponseListener {
|
||||
void onSuccess(String method, InfuraResponse infuraResponse);
|
||||
|
||||
void onFail(String method, String message);
|
||||
}
|
||||
|
||||
public void setRootstockResponse(RootstockBodyListener listener) {
|
||||
rootstockBodyListener = listener;
|
||||
public void setResponseListener(ResponseListener listener) {
|
||||
responseListener = listener;
|
||||
}
|
||||
|
||||
public void rootstock(String method, int id, String wallet, String contract, String tx) {
|
||||
public void requestData(String method, int id, String wallet, String contract, String tx) {
|
||||
requestsCount++;
|
||||
RootstockApi rootstockApi = App.getNetworkComponent().getRetrofitRootstock().create(RootstockApi.class);
|
||||
|
||||
|
|
@ -86,18 +86,18 @@ public class ServerApiRootstock {
|
|||
public void onResponse(@NonNull Call<InfuraResponse> call, @NonNull Response<InfuraResponse> response) {
|
||||
if (response.code() == 200) {
|
||||
requestsCount--;
|
||||
rootstockBodyListener.onSuccess(method, response.body());
|
||||
Log.i(TAG, "rootstock " + method + " onResponse " + response.code());
|
||||
responseListener.onSuccess(method, response.body());
|
||||
Log.i(TAG, "requestData " + method + " onResponse " + response.code());
|
||||
} else {
|
||||
rootstockBodyListener.onFail(method, String.valueOf(response.code()));
|
||||
Log.e(TAG, "rootstock " + method + " onResponse " + response.code());
|
||||
responseListener.onFail(method, String.valueOf(response.code()));
|
||||
Log.e(TAG, "requestData " + method + " onResponse " + response.code());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<InfuraResponse> call, @NonNull Throwable t) {
|
||||
rootstockBodyListener.onFail(method, String.valueOf(t.getMessage()));
|
||||
Log.e(TAG, "rootstock " + method + " onFailure " + t.getMessage());
|
||||
responseListener.onFail(method, String.valueOf(t.getMessage()));
|
||||
Log.e(TAG, "requestData " + method + " onFailure " + t.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package com.tangem.data.network;
|
|||
class ServerURL {
|
||||
static final String API_TANGEM = "https://verify.tangem.com/";
|
||||
static final String API_COINMARKETCAP = "https://api.coinmarketcap.com/";
|
||||
static final String API_INFURA = "https://mainnet.infura.io/";
|
||||
static final String API_INFURA = "https://mainnet.requestData.io/";
|
||||
static final String API_ESTIMATEFEE = "https://estimatefee.com/";
|
||||
static final String API_UPDATE_VERSION = "https://raw.githubusercontent.com/";
|
||||
static final String API_ROOTSTOCK = "https://public-node.rsk.co/";
|
||||
|
|
|
|||
|
|
@ -68,8 +68,8 @@ class Navigator {
|
|||
context.startActivityForResult(PurgeActivity.callingIntent(context, ctx), Constant.REQUEST_CODE_PURGE)
|
||||
}
|
||||
|
||||
fun showPreparePayment(context: Activity, ctx: TangemContext) {
|
||||
context.startActivityForResult(PreparePaymentActivity.callingIntent(context, ctx), Constant.REQUEST_CODE_SEND_PAYMENT)
|
||||
fun showPrepareTransaction(context: Activity, ctx: TangemContext) {
|
||||
context.startActivityForResult(PrepareTransactionActivity.callingIntent(context, ctx), Constant.REQUEST_CODE_SEND_TRANSACTION)
|
||||
}
|
||||
|
||||
fun showCreateNewWallet(context: Activity, ctx: TangemContext) {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import com.tangem.presentation.activity.LogoActivity;
|
|||
import com.tangem.presentation.activity.MainActivity;
|
||||
import com.tangem.presentation.activity.PrepareCryptonitOtherApiWithdrawalActivity;
|
||||
import com.tangem.presentation.activity.PrepareKrakenWithdrawalActivity;
|
||||
import com.tangem.presentation.activity.PreparePaymentActivity;
|
||||
import com.tangem.presentation.activity.PrepareTransactionActivity;
|
||||
import com.tangem.presentation.activity.VerifyCardActivity;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
|
@ -23,7 +23,7 @@ public interface NavigatorComponent {
|
|||
|
||||
void inject(MainActivity activity);
|
||||
|
||||
void inject(PreparePaymentActivity activity);
|
||||
void inject(PrepareTransactionActivity activity);
|
||||
|
||||
void inject(PrepareCryptonitOtherApiWithdrawalActivity activity);
|
||||
|
||||
|
|
|
|||
|
|
@ -29,9 +29,6 @@ public interface NetworkComponent {
|
|||
@Named(Server.ApiRootstock.URL_ROOTSTOCK)
|
||||
Retrofit getRetrofitRootstock();
|
||||
|
||||
// @Named("Insight") //TODO:check
|
||||
// Retrofit getRetrofitInsight(String insightURL);
|
||||
|
||||
@Named("socket")
|
||||
Socket getSocket();
|
||||
|
||||
|
|
|
|||
|
|
@ -41,16 +41,6 @@ class NetworkModule {
|
|||
.build();
|
||||
}
|
||||
|
||||
// //@Singleton // TODO:check
|
||||
// @Provides
|
||||
// @Named("Insight")
|
||||
// Retrofit provideRetrofitInsight(String insightURL) {
|
||||
// return new Retrofit.Builder()
|
||||
// .baseUrl(insightURL)
|
||||
// .addConverterFactory(GsonConverterFactory.create())
|
||||
// .build();
|
||||
// }
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
@Named(Server.ApiEstimatefee.URL_ESTIMATEFEE)
|
||||
|
|
|
|||
|
|
@ -181,12 +181,10 @@ public abstract class CoinEngine {
|
|||
|
||||
public abstract boolean isBalanceNotZero();
|
||||
|
||||
// public abstract byte[] sign(Amount feeValue, Amount amountValue, boolean IncFee, String targetAddress, CardProtocol protocol) throws Exception;
|
||||
|
||||
// TODO - change isExtractPossible to isExtractPossible and if not - return string message
|
||||
// TODO - return string message
|
||||
public abstract boolean isExtractPossible();
|
||||
|
||||
public abstract Uri getShareWalletUriExplorer();
|
||||
public abstract Uri getWalletExplorerUri();
|
||||
|
||||
public abstract Uri getShareWalletUri();
|
||||
|
||||
|
|
@ -245,14 +243,14 @@ public abstract class CoinEngine {
|
|||
}
|
||||
|
||||
/**
|
||||
* Create instance of {@link SignTask.PaymentToSign} used for transaction signing and sending
|
||||
* Create instance of {@link SignTask.TransactionToSign} used for transaction signing and sending
|
||||
*
|
||||
* Transaction processing sequence:
|
||||
* 1. User enter transaction attributes
|
||||
* 2. Application create instance of {@link SignTask.PaymentToSign} by call {@see constructPayment}
|
||||
* 3. Application set notification when transaction were prepared {@see setOnNeedSendPayment} and start {@link SignTask}
|
||||
* 2. Application create instance of {@link SignTask.TransactionToSign} by call {@see constructTransaction}
|
||||
* 3. Application set notification when transaction were prepared {@see setOnNeedSendTransaction} and start {@link SignTask}
|
||||
* 4. User tap card and card sign transaction
|
||||
* 5. Application receive {@link CoinEngine.OnNeedSendPayment} notification with prepared raw transaction
|
||||
* 5. Application receive {@link OnNeedSendTransaction} notification with prepared raw transaction
|
||||
* 6. Application show user information that transaction ready for sending and start sending procedure by call {@see requestSendTransaction}
|
||||
* 7. Application receive notification of sending result through {@link CoinEngine.BlockchainRequestsCallbacks} and show result to user
|
||||
*
|
||||
|
|
@ -260,32 +258,32 @@ public abstract class CoinEngine {
|
|||
* @param feeValue - fee amount of desired transaction
|
||||
* @param IncFee - true if fee amount is included in amountValue (amountValue is total amount of transaction)
|
||||
* @param targetAddress - target address of transaction
|
||||
* @return instance of {@link SignTask.PaymentToSign}
|
||||
* @return instance of {@link SignTask.TransactionToSign}
|
||||
* @throws Exception if something goes wrong
|
||||
*/
|
||||
public abstract SignTask.PaymentToSign constructPayment(Amount amountValue, Amount feeValue, boolean IncFee, String targetAddress) throws Exception;
|
||||
public abstract SignTask.TransactionToSign constructTransaction(Amount amountValue, Amount feeValue, boolean IncFee, String targetAddress) throws Exception;
|
||||
|
||||
/**
|
||||
* Interface used to notify main application when new transaction is prepared to send
|
||||
*/
|
||||
public interface OnNeedSendPayment {
|
||||
void onPaymentPrepared(byte[] txForSend);
|
||||
public interface OnNeedSendTransaction {
|
||||
void onTransactionPrepared(byte[] txForSend);
|
||||
}
|
||||
|
||||
protected OnNeedSendPayment onNeedSendPayment;
|
||||
protected OnNeedSendTransaction onNeedSendTransaction;
|
||||
|
||||
|
||||
/**
|
||||
* Set notification callback when new transaction is prepared to send
|
||||
*/
|
||||
public void setOnNeedSendPayment(OnNeedSendPayment onNeedSendPayment) {
|
||||
this.onNeedSendPayment = onNeedSendPayment;
|
||||
public void setOnNeedSendTransaction(OnNeedSendTransaction onNeedSendTransaction) {
|
||||
this.onNeedSendTransaction = onNeedSendTransaction;
|
||||
}
|
||||
|
||||
protected void notifyOnNeedSendPayment(byte[] txForSend) throws Exception {
|
||||
if (onNeedSendPayment == null)
|
||||
throw new Exception("Payment signed but no callback defined to send!");
|
||||
onNeedSendPayment.onPaymentPrepared(txForSend);
|
||||
protected void notifyOnNeedSendTransaction(byte[] txForSend) throws Exception {
|
||||
if (onNeedSendTransaction == null)
|
||||
throw new Exception("Transaction was signed but no callback defined to send!");
|
||||
onNeedSendTransaction.onTransactionPrepared(txForSend);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ public class BtcCashEngine extends CoinEngine {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Uri getShareWalletUriExplorer() {
|
||||
public Uri getWalletExplorerUri() {
|
||||
return Uri.parse("https://bch.btc.com/" + ctx.getCoinData().getWallet());
|
||||
}
|
||||
|
||||
|
|
@ -454,7 +454,7 @@ public class BtcCashEngine extends CoinEngine {
|
|||
|
||||
|
||||
@Override
|
||||
public SignTask.PaymentToSign constructPayment(Amount amountValue, Amount feeValue, boolean IncFee, String targetAddress) throws Exception {
|
||||
public SignTask.TransactionToSign constructTransaction(Amount amountValue, Amount feeValue, boolean IncFee, String targetAddress) throws Exception {
|
||||
checkBlockchainDataExists();
|
||||
|
||||
String srcLegacyAddress = convertToLegacyAddress(ctx.getCoinData().getWallet());
|
||||
|
|
@ -500,7 +500,7 @@ public class BtcCashEngine extends CoinEngine {
|
|||
bodyDoubleHash[i] = Util.calculateSHA256(bodyHash[i]);
|
||||
}
|
||||
|
||||
return new SignTask.PaymentToSign() {
|
||||
return new SignTask.TransactionToSign() {
|
||||
|
||||
@Override
|
||||
public boolean isSigningMethodSupported(TangemCard.SigningMethod signingMethod) {
|
||||
|
|
@ -551,7 +551,7 @@ public class BtcCashEngine extends CoinEngine {
|
|||
|
||||
byte[] txForSend = BCHUtils.buildTXForSend(destLegacyAddress, srcLegacyAddress, unspentOutputs, amountFinal, changeFinal);
|
||||
|
||||
notifyOnNeedSendPayment(txForSend);
|
||||
notifyOnNeedSendTransaction(txForSend);
|
||||
return txForSend;
|
||||
}
|
||||
};
|
||||
|
|
@ -561,7 +561,7 @@ public class BtcCashEngine extends CoinEngine {
|
|||
public void requestBalanceAndUnspentTransactions(BlockchainRequestsCallbacks blockchainRequestsCallbacks) throws Exception {
|
||||
final ServerApiElectrum serverApiElectrum = new ServerApiElectrum();
|
||||
|
||||
ServerApiElectrum.ElectrumRequestDataListener electrumBodyListener = new ServerApiElectrum.ElectrumRequestDataListener() {
|
||||
ServerApiElectrum.ResponseListener electrumBodyListener = new ServerApiElectrum.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(ElectrumRequest electrumRequest) {
|
||||
if (electrumRequest.isMethod(ElectrumRequest.METHOD_GetBalance)) {
|
||||
|
|
@ -606,7 +606,7 @@ public class BtcCashEngine extends CoinEngine {
|
|||
String hash = jsUnspent.getString("tx_hash");
|
||||
if (height != -1) {
|
||||
if (blockchainRequestsCallbacks.allowAdvance()) {
|
||||
serverApiElectrum.electrumRequestData(ctx, ElectrumRequest.getTransaction(walletAddress, hash));
|
||||
serverApiElectrum.requestData(ctx, ElectrumRequest.getTransaction(walletAddress, hash));
|
||||
} else {
|
||||
ctx.setError("Terminated by user");
|
||||
}
|
||||
|
|
@ -649,22 +649,22 @@ public class BtcCashEngine extends CoinEngine {
|
|||
}
|
||||
};
|
||||
|
||||
serverApiElectrum.setElectrumRequestData(electrumBodyListener);
|
||||
serverApiElectrum.setResponseListener(electrumBodyListener);
|
||||
|
||||
serverApiElectrum.electrumRequestData(ctx, ElectrumRequest.checkBalance(convertToLegacyAddress(coinData.getWallet())));
|
||||
serverApiElectrum.electrumRequestData(ctx, ElectrumRequest.listUnspent(convertToLegacyAddress(coinData.getWallet())));
|
||||
serverApiElectrum.requestData(ctx, ElectrumRequest.checkBalance(convertToLegacyAddress(coinData.getWallet())));
|
||||
serverApiElectrum.requestData(ctx, ElectrumRequest.listUnspent(convertToLegacyAddress(coinData.getWallet())));
|
||||
}
|
||||
|
||||
private Integer calculateEstimatedTransactionSize(String outputAddress, String outAmount) {
|
||||
try {
|
||||
SignTask.PaymentToSign ps=constructPayment(new Amount(outAmount, getBalanceCurrency()),new Amount("0.00",getFeeCurrency()), true, outputAddress );
|
||||
OnNeedSendPayment onNeedSendPaymentBackup=onNeedSendPayment;
|
||||
onNeedSendPayment=(tx)->{}; // empty function to bypass exception
|
||||
SignTask.TransactionToSign ps= constructTransaction(new Amount(outAmount, getBalanceCurrency()),new Amount("0.00",getFeeCurrency()), true, outputAddress );
|
||||
OnNeedSendTransaction onNeedSendTransactionBackup = onNeedSendTransaction;
|
||||
onNeedSendTransaction =(tx)->{}; // empty function to bypass exception
|
||||
|
||||
byte[][] hashesToSign=ps.getHashesToSign();
|
||||
byte[] signFromCard = new byte[64 * hashesToSign.length];
|
||||
byte[] txForSend=ps.onSignCompleted(signFromCard);
|
||||
onNeedSendPayment=onNeedSendPaymentBackup;
|
||||
onNeedSendTransaction = onNeedSendTransactionBackup;
|
||||
Log.e(TAG,"txForSend.length="+String.valueOf(txForSend.length));
|
||||
return txForSend.length;
|
||||
} catch (Exception e) {
|
||||
|
|
@ -686,7 +686,7 @@ public class BtcCashEngine extends CoinEngine {
|
|||
|
||||
final ServerApiElectrum serverApiElectrum = new ServerApiElectrum();
|
||||
|
||||
final ServerApiElectrum.ElectrumRequestDataListener electrumListener = new ServerApiElectrum.ElectrumRequestDataListener () {
|
||||
final ServerApiElectrum.ResponseListener electrumListener = new ServerApiElectrum.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(ElectrumRequest electrumRequest) {
|
||||
BigDecimal fee;
|
||||
|
|
@ -695,13 +695,13 @@ public class BtcCashEngine extends CoinEngine {
|
|||
fee = new BigDecimal(electrumRequest.getResultString()); //fee per KB
|
||||
|
||||
if (fee.equals(BigDecimal.ZERO)) {
|
||||
serverApiElectrum.electrumRequestData(ctx, ElectrumRequest.getFee());
|
||||
serverApiElectrum.requestData(ctx, ElectrumRequest.getFee());
|
||||
}
|
||||
|
||||
// if (calcSize != 0) {
|
||||
fee = fee.multiply(new BigDecimal(calcSize)).divide(new BigDecimal(1024)); // (per KB -> per byte)*size
|
||||
// } else {
|
||||
// serverApiElectrum.electrumRequestData(ctx, ElectrumRequest.getFee());
|
||||
// serverApiElectrum.requestData(ctx, ElectrumRequest.getFee());
|
||||
// }
|
||||
|
||||
//compare fee to usual relay fee
|
||||
|
|
@ -732,9 +732,9 @@ public class BtcCashEngine extends CoinEngine {
|
|||
blockchainRequestsCallbacks.onComplete(false);
|
||||
}
|
||||
};
|
||||
serverApiElectrum.setElectrumRequestData(electrumListener);
|
||||
serverApiElectrum.setResponseListener(electrumListener);
|
||||
|
||||
serverApiElectrum.electrumRequestData(ctx, ElectrumRequest.getFee());
|
||||
serverApiElectrum.requestData(ctx, ElectrumRequest.getFee());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -742,7 +742,7 @@ public class BtcCashEngine extends CoinEngine {
|
|||
final ServerApiElectrum serverApiElectrum = new ServerApiElectrum();
|
||||
final String txStr = BTCUtils.toHex(txForSend);
|
||||
|
||||
ServerApiElectrum.ElectrumRequestDataListener electrumBodyListener = new ServerApiElectrum.ElectrumRequestDataListener() {
|
||||
ServerApiElectrum.ResponseListener electrumBodyListener = new ServerApiElectrum.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(ElectrumRequest electrumRequest) {
|
||||
if (electrumRequest.isMethod(ElectrumRequest.METHOD_SendTransaction)) {
|
||||
|
|
@ -773,10 +773,10 @@ public class BtcCashEngine extends CoinEngine {
|
|||
blockchainRequestsCallbacks.onComplete(false);
|
||||
}
|
||||
};
|
||||
serverApiElectrum.setElectrumRequestData(electrumBodyListener);
|
||||
serverApiElectrum.setResponseListener(electrumBodyListener);
|
||||
|
||||
|
||||
serverApiElectrum.electrumRequestData(ctx, ElectrumRequest.broadcast(ctx.getCoinData().getWallet(), txStr));
|
||||
serverApiElectrum.requestData(ctx, ElectrumRequest.broadcast(ctx.getCoinData().getWallet(), txStr));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ public class BtcEngine extends CoinEngine {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Uri getShareWalletUriExplorer() {
|
||||
public Uri getWalletExplorerUri() {
|
||||
return Uri.parse((ctx.getBlockchain() == Blockchain.Bitcoin ? "https://blockchain.info/address/" : "https://testnet.blockchain.info/address/") + ctx.getCoinData().getWallet());
|
||||
}
|
||||
|
||||
|
|
@ -422,7 +422,7 @@ public class BtcEngine extends CoinEngine {
|
|||
}
|
||||
|
||||
@Override
|
||||
public SignTask.PaymentToSign constructPayment(Amount amountValue, Amount feeValue, boolean IncFee, String targetAddress) throws Exception {
|
||||
public SignTask.TransactionToSign constructTransaction(Amount amountValue, Amount feeValue, boolean IncFee, String targetAddress) throws Exception {
|
||||
final ArrayList<UnspentOutputInfo> unspentOutputs;
|
||||
checkBlockchainDataExists();
|
||||
|
||||
|
|
@ -467,7 +467,7 @@ public class BtcEngine extends CoinEngine {
|
|||
bodyDoubleHash[i] = Util.calculateSHA256(bodyHash[i]);
|
||||
}
|
||||
|
||||
return new SignTask.PaymentToSign() {
|
||||
return new SignTask.TransactionToSign() {
|
||||
|
||||
@Override
|
||||
public boolean isSigningMethodSupported(TangemCard.SigningMethod signingMethod) {
|
||||
|
|
@ -517,7 +517,7 @@ public class BtcEngine extends CoinEngine {
|
|||
}
|
||||
|
||||
byte[] txForSend = BTCUtils.buildTXForSend(targetAddress, myAddress, unspentOutputs, amountFinal, changeFinal);
|
||||
notifyOnNeedSendPayment(txForSend);
|
||||
notifyOnNeedSendTransaction(txForSend);
|
||||
return txForSend;
|
||||
}
|
||||
};
|
||||
|
|
@ -527,7 +527,7 @@ public class BtcEngine extends CoinEngine {
|
|||
public void requestBalanceAndUnspentTransactions(BlockchainRequestsCallbacks blockchainRequestsCallbacks) {
|
||||
final ServerApiElectrum serverApiElectrum = new ServerApiElectrum();
|
||||
|
||||
ServerApiElectrum.ElectrumRequestDataListener electrumListener = new ServerApiElectrum.ElectrumRequestDataListener() {
|
||||
ServerApiElectrum.ResponseListener electrumListener = new ServerApiElectrum.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(ElectrumRequest electrumRequest) {
|
||||
Log.i(TAG, "onSuccess: "+electrumRequest.getMethod());
|
||||
|
|
@ -576,7 +576,7 @@ public class BtcEngine extends CoinEngine {
|
|||
String hash = jsUnspent.getString("tx_hash");
|
||||
if (height != -1) {
|
||||
if (blockchainRequestsCallbacks.allowAdvance()) {
|
||||
serverApiElectrum.electrumRequestData(ctx, ElectrumRequest.getTransaction(walletAddress, hash));
|
||||
serverApiElectrum.requestData(ctx, ElectrumRequest.getTransaction(walletAddress, hash));
|
||||
} else {
|
||||
ctx.setError("Terminated by user");
|
||||
}
|
||||
|
|
@ -617,14 +617,14 @@ public class BtcEngine extends CoinEngine {
|
|||
}
|
||||
};
|
||||
|
||||
serverApiElectrum.setElectrumRequestData(electrumListener);
|
||||
serverApiElectrum.setResponseListener(electrumListener);
|
||||
|
||||
serverApiElectrum.electrumRequestData(ctx, ElectrumRequest.checkBalance(coinData.getWallet()));
|
||||
serverApiElectrum.electrumRequestData(ctx, ElectrumRequest.listUnspent(coinData.getWallet()));
|
||||
serverApiElectrum.requestData(ctx, ElectrumRequest.checkBalance(coinData.getWallet()));
|
||||
serverApiElectrum.requestData(ctx, ElectrumRequest.listUnspent(coinData.getWallet()));
|
||||
}
|
||||
|
||||
protected Integer calculateEstimatedTransactionSize(String outputAddress, String outAmount) {
|
||||
//todo - правильней было бы использовать constructPayment
|
||||
//todo - правильней было бы использовать constructTransaction
|
||||
try {
|
||||
// String myAddress = coinData.getWallet();
|
||||
// byte[] pbKey = ctx.getCard().getWalletPublicKey();
|
||||
|
|
@ -685,14 +685,14 @@ public class BtcEngine extends CoinEngine {
|
|||
//
|
||||
// byte[] realTX = BTCUtils.buildTXForSend(outputAddress, myAddress, unspentOutputs, amount, change);
|
||||
|
||||
SignTask.PaymentToSign ps=constructPayment(new Amount(outAmount, getBalanceCurrency()),new Amount("0.00",getFeeCurrency()), true, outputAddress );
|
||||
OnNeedSendPayment onNeedSendPaymentBackup=onNeedSendPayment;
|
||||
onNeedSendPayment=(tx)->{}; // empty function to bypass exception
|
||||
SignTask.TransactionToSign ps= constructTransaction(new Amount(outAmount, getBalanceCurrency()),new Amount("0.00",getFeeCurrency()), true, outputAddress );
|
||||
OnNeedSendTransaction onNeedSendTransactionBackup = onNeedSendTransaction;
|
||||
onNeedSendTransaction =(tx)->{}; // empty function to bypass exception
|
||||
|
||||
byte[][] hashesToSign=ps.getHashesToSign();
|
||||
byte[] signFromCard = new byte[64 * hashesToSign.length];
|
||||
byte[] txForSend=ps.onSignCompleted(signFromCard);
|
||||
onNeedSendPayment=onNeedSendPaymentBackup;
|
||||
onNeedSendTransaction = onNeedSendTransactionBackup;
|
||||
Log.e(TAG,"txForSend.length="+String.valueOf(txForSend.length));
|
||||
return txForSend.length;
|
||||
|
||||
|
|
@ -717,14 +717,14 @@ public class BtcEngine extends CoinEngine {
|
|||
|
||||
final ServerApiCommon serverApiCommon = new ServerApiCommon();
|
||||
|
||||
final ServerApiCommon.EstimateFeeListener estimateFeeListener = new ServerApiCommon.EstimateFeeListener() {
|
||||
final ServerApiCommon.EstimatedFeeListener estimatedFeeListener = new ServerApiCommon.EstimatedFeeListener() {
|
||||
@Override
|
||||
public void onSuccess(int blockCount, String estimateFeeResponse) {
|
||||
BigDecimal fee = new BigDecimal(estimateFeeResponse); // BTC per 1 kb
|
||||
|
||||
if (fee.equals(BigDecimal.ZERO)) {
|
||||
if (blockchainRequestsCallbacks.allowAdvance()) {
|
||||
serverApiCommon.estimateFee(blockCount);
|
||||
serverApiCommon.requestBtcEstimatedFee(blockCount);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -733,7 +733,7 @@ public class BtcEngine extends CoinEngine {
|
|||
fee = fee.multiply(new BigDecimal(calcSize)).divide(new BigDecimal(1024), BigDecimal.ROUND_DOWN); // per Kb -> per byte
|
||||
} else {
|
||||
if (blockchainRequestsCallbacks.allowAdvance()) {
|
||||
serverApiCommon.estimateFee(blockCount);
|
||||
serverApiCommon.requestBtcEstimatedFee(blockCount);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -763,18 +763,18 @@ public class BtcEngine extends CoinEngine {
|
|||
public void onFail(int blockCount, String message) {
|
||||
// TODO - add fail counter to terminate after NNN tries
|
||||
if (blockchainRequestsCallbacks.allowAdvance()) {
|
||||
serverApiCommon.estimateFee(blockCount);
|
||||
serverApiCommon.requestBtcEstimatedFee(blockCount);
|
||||
return;
|
||||
}
|
||||
ctx.setError(ctx.getContext().getString(R.string.cannot_calculate_fee_wrong_data_received_from_node));
|
||||
blockchainRequestsCallbacks.onComplete(false);
|
||||
}
|
||||
};
|
||||
serverApiCommon.setEstimateFee(estimateFeeListener);
|
||||
serverApiCommon.setBtcEstimatedFeeListener(estimatedFeeListener);
|
||||
|
||||
serverApiCommon.estimateFee(ServerApiCommon.ESTIMATE_FEE_PRIORITY);
|
||||
serverApiCommon.estimateFee(ServerApiCommon.ESTIMATE_FEE_NORMAL);
|
||||
serverApiCommon.estimateFee(ServerApiCommon.ESTIMATE_FEE_MINIMAL);
|
||||
serverApiCommon.requestBtcEstimatedFee(ServerApiCommon.ESTIMATE_FEE_PRIORITY);
|
||||
serverApiCommon.requestBtcEstimatedFee(ServerApiCommon.ESTIMATE_FEE_NORMAL);
|
||||
serverApiCommon.requestBtcEstimatedFee(ServerApiCommon.ESTIMATE_FEE_MINIMAL);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -783,7 +783,7 @@ public class BtcEngine extends CoinEngine {
|
|||
final ServerApiElectrum serverApiElectrum = new ServerApiElectrum();
|
||||
final String txStr = BTCUtils.toHex(txForSend);
|
||||
|
||||
ServerApiElectrum.ElectrumRequestDataListener electrumListener = new ServerApiElectrum.ElectrumRequestDataListener() {
|
||||
ServerApiElectrum.ResponseListener electrumListener = new ServerApiElectrum.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(ElectrumRequest electrumRequest) {
|
||||
if (electrumRequest.isMethod(ElectrumRequest.METHOD_SendTransaction)) {
|
||||
|
|
@ -814,10 +814,10 @@ public class BtcEngine extends CoinEngine {
|
|||
blockchainRequestsCallbacks.onComplete(false);
|
||||
}
|
||||
};
|
||||
serverApiElectrum.setElectrumRequestData(electrumListener);
|
||||
serverApiElectrum.setResponseListener(electrumListener);
|
||||
|
||||
|
||||
serverApiElectrum.electrumRequestData(ctx, ElectrumRequest.broadcast(ctx.getCoinData().getWallet(), txStr));
|
||||
serverApiElectrum.requestData(ctx, ElectrumRequest.broadcast(ctx.getCoinData().getWallet(), txStr));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@ import android.net.Uri;
|
|||
import android.text.InputFilter;
|
||||
import android.util.Log;
|
||||
|
||||
import com.tangem.data.network.ElectrumRequest;
|
||||
import com.tangem.data.network.InsightApi;
|
||||
import com.tangem.data.network.ServerApiInsight;
|
||||
import com.tangem.data.network.model.InsightResponse;
|
||||
import com.tangem.domain.wallet.BTCUtils;
|
||||
|
|
@ -26,10 +24,6 @@ import com.tangem.util.DecimalDigitsInputFilter;
|
|||
import com.tangem.util.DerEncodingUtil;
|
||||
import com.tangem.wallet.R;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
|
|
@ -179,7 +173,7 @@ public class DucatusEngine extends BtcEngine {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Uri getShareWalletUriExplorer() {
|
||||
public Uri getWalletExplorerUri() {
|
||||
return Uri.parse("https://live.blockcypher.com/ltc/address/" + ctx.getCoinData().getWallet());
|
||||
}
|
||||
|
||||
|
|
@ -397,7 +391,7 @@ public class DucatusEngine extends BtcEngine {
|
|||
}
|
||||
|
||||
@Override
|
||||
public SignTask.PaymentToSign constructPayment(Amount amountValue, Amount feeValue, boolean IncFee, String targetAddress) throws Exception {
|
||||
public SignTask.TransactionToSign constructTransaction(Amount amountValue, Amount feeValue, boolean IncFee, String targetAddress) throws Exception {
|
||||
final ArrayList<UnspentOutputInfo> unspentOutputs;
|
||||
checkBlockchainDataExists();
|
||||
|
||||
|
|
@ -442,7 +436,7 @@ public class DucatusEngine extends BtcEngine {
|
|||
bodyDoubleHash[i] = Util.calculateSHA256(bodyHash[i]);
|
||||
}
|
||||
|
||||
return new SignTask.PaymentToSign() {
|
||||
return new SignTask.TransactionToSign() {
|
||||
|
||||
@Override
|
||||
public boolean isSigningMethodSupported(TangemCard.SigningMethod signingMethod) {
|
||||
|
|
@ -492,7 +486,7 @@ public class DucatusEngine extends BtcEngine {
|
|||
}
|
||||
|
||||
byte[] txForSend=BTCUtils.buildTXForSend(targetAddress, myAddress, unspentOutputs, amountFinal, changeFinal);
|
||||
notifyOnNeedSendPayment(txForSend);
|
||||
notifyOnNeedSendTransaction(txForSend);
|
||||
return txForSend;
|
||||
}
|
||||
};
|
||||
|
|
@ -502,7 +496,7 @@ public class DucatusEngine extends BtcEngine {
|
|||
public void requestBalanceAndUnspentTransactions(BlockchainRequestsCallbacks blockchainRequestsCallbacks) {
|
||||
final ServerApiInsight serverApiInsight = new ServerApiInsight();
|
||||
|
||||
ServerApiInsight.InsightBodyListener insightBodyListener = new ServerApiInsight.InsightBodyListener() {
|
||||
ServerApiInsight.ResponseListener responseListener = new ServerApiInsight.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String method, InsightResponse insightResponse) {
|
||||
switch (method) {
|
||||
|
|
@ -562,7 +556,7 @@ public class DucatusEngine extends BtcEngine {
|
|||
for (InsightResponse utxo : utxoList) {
|
||||
//if (height != -1) { TODO: check
|
||||
if (blockchainRequestsCallbacks.allowAdvance()) {
|
||||
serverApiInsight.insight(ServerApiInsight.INSIGHT_TRANSACTION, "", utxo.getTxid());
|
||||
serverApiInsight.requestData(ServerApiInsight.INSIGHT_TRANSACTION, "", utxo.getTxid());
|
||||
} else {
|
||||
ctx.setError("Terminated by user");
|
||||
}
|
||||
|
|
@ -582,10 +576,10 @@ public class DucatusEngine extends BtcEngine {
|
|||
}
|
||||
};
|
||||
|
||||
serverApiInsight.setInsightResponse(insightBodyListener);
|
||||
serverApiInsight.setResponseListener(responseListener);
|
||||
|
||||
serverApiInsight.insight(ServerApiInsight.INSIGHT_ADDRESS, coinData.getWallet(), "");
|
||||
serverApiInsight.insight(ServerApiInsight.INSIGHT_UNSPENT_OUTPUTS, coinData.getWallet(), "");
|
||||
serverApiInsight.requestData(ServerApiInsight.INSIGHT_ADDRESS, coinData.getWallet(), "");
|
||||
serverApiInsight.requestData(ServerApiInsight.INSIGHT_UNSPENT_OUTPUTS, coinData.getWallet(), "");
|
||||
}
|
||||
|
||||
// private final static BigDecimal relayFee = new BigDecimal(0.00001);
|
||||
|
|
@ -600,7 +594,7 @@ public class DucatusEngine extends BtcEngine {
|
|||
|
||||
final ServerApiInsight serverApiInsight = new ServerApiInsight();
|
||||
|
||||
final ServerApiInsight.InsightBodyListener insightBodyListener = new ServerApiInsight.InsightBodyListener () {
|
||||
final ServerApiInsight.ResponseListener responseListener = new ServerApiInsight.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String method, InsightResponse insightResponse) {
|
||||
if ( method.equals(ServerApiInsight.INSIGHT_FEE)) {
|
||||
|
|
@ -610,7 +604,7 @@ public class DucatusEngine extends BtcEngine {
|
|||
BigDecimal maxFee = new BigDecimal(insightResponse.getFee6());
|
||||
|
||||
if (minFee.equals(BigDecimal.ZERO) || normalFee.equals(BigDecimal.ZERO) || maxFee.equals(BigDecimal.ZERO)) {
|
||||
serverApiInsight.insight(ServerApiInsight.INSIGHT_FEE, "","");
|
||||
serverApiInsight.requestData(ServerApiInsight.INSIGHT_FEE, "","");
|
||||
}
|
||||
|
||||
minFee = minFee.multiply(new BigDecimal(calcSize)).divide(new BigDecimal(1024)); // (per KB -> per byte)*size
|
||||
|
|
@ -650,9 +644,9 @@ public class DucatusEngine extends BtcEngine {
|
|||
}
|
||||
}
|
||||
};
|
||||
serverApiInsight.setInsightResponse(insightBodyListener);
|
||||
serverApiInsight.setResponseListener(responseListener);
|
||||
|
||||
serverApiInsight.insight(ServerApiInsight.INSIGHT_FEE, "", "");
|
||||
serverApiInsight.requestData(ServerApiInsight.INSIGHT_FEE, "", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -660,7 +654,7 @@ public class DucatusEngine extends BtcEngine {
|
|||
final ServerApiInsight serverApiInsight = new ServerApiInsight();
|
||||
final String txStr = BTCUtils.toHex(txForSend);
|
||||
|
||||
final ServerApiInsight.InsightBodyListener insightBodyListener = new ServerApiInsight.InsightBodyListener () {
|
||||
final ServerApiInsight.ResponseListener responseListener = new ServerApiInsight.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String method, InsightResponse insightResponse) {
|
||||
if (method.equals(ServerApiInsight.INSIGHT_SEND)) {
|
||||
|
|
@ -700,8 +694,8 @@ public class DucatusEngine extends BtcEngine {
|
|||
}
|
||||
}
|
||||
};
|
||||
serverApiInsight.setInsightResponse(insightBodyListener);
|
||||
serverApiInsight.setResponseListener(responseListener);
|
||||
|
||||
serverApiInsight.insight(ServerApiInsight.INSIGHT_SEND, "", txStr);
|
||||
serverApiInsight.requestData(ServerApiInsight.INSIGHT_SEND, "", txStr);
|
||||
}
|
||||
}
|
||||
|
|
@ -236,7 +236,7 @@ public class EthEngine extends CoinEngine {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Uri getShareWalletUriExplorer() {
|
||||
public Uri getWalletExplorerUri() {
|
||||
if (ctx.getBlockchain() == Blockchain.EthereumTestNet)
|
||||
return Uri.parse("https://rinkeby.etherscan.io/address/" + ctx.getCoinData().getWallet());
|
||||
else
|
||||
|
|
@ -379,9 +379,9 @@ public class EthEngine extends CoinEngine {
|
|||
}
|
||||
|
||||
@Override
|
||||
public SignTask.PaymentToSign constructPayment(Amount amountValue, Amount feeValue, boolean IncFee, String targetAddress) {
|
||||
public SignTask.TransactionToSign constructTransaction(Amount amountValue, Amount feeValue, boolean IncFee, String targetAddress) {
|
||||
|
||||
Log.e(TAG, "Construct payment " + amountValue.toString() + " with fee " + feeValue.toString() + (IncFee ? " including" : " excluding"));
|
||||
Log.e(TAG, "Construct transaction " + amountValue.toString() + " with fee " + feeValue.toString() + (IncFee ? " including" : " excluding"));
|
||||
|
||||
BigInteger nonceValue = coinData.getConfirmedTXCount();
|
||||
byte[] pbKey = ctx.getCard().getWalletPublicKey();
|
||||
|
|
@ -405,7 +405,7 @@ public class EthEngine extends CoinEngine {
|
|||
|
||||
final EthTransaction tx = EthTransaction.create(to, weiAmount, nonceValue, gasPrice, gasLimit, chainId);
|
||||
|
||||
return new SignTask.PaymentToSign() {
|
||||
return new SignTask.TransactionToSign() {
|
||||
@Override
|
||||
public boolean isSigningMethodSupported(TangemCard.SigningMethod signingMethod) {
|
||||
return signingMethod == TangemCard.SigningMethod.Sign_Hash;
|
||||
|
|
@ -456,7 +456,7 @@ public class EthEngine extends CoinEngine {
|
|||
Log.e(this.getClass().getSimpleName(), " V: " +String.valueOf(v));
|
||||
|
||||
byte[] txForSend = tx.getEncoded();
|
||||
notifyOnNeedSendPayment(txForSend);
|
||||
notifyOnNeedSendTransaction(txForSend);
|
||||
return txForSend;
|
||||
}
|
||||
};
|
||||
|
|
@ -465,8 +465,8 @@ public class EthEngine extends CoinEngine {
|
|||
@Override
|
||||
public void requestBalanceAndUnspentTransactions(BlockchainRequestsCallbacks blockchainRequestsCallbacks) {
|
||||
final ServerApiInfura serverApiInfura = new ServerApiInfura();
|
||||
// request infura listener
|
||||
ServerApiInfura.InfuraBodyListener infuraBodyListener = new ServerApiInfura.InfuraBodyListener() {
|
||||
// request requestData listener
|
||||
ServerApiInfura.ResponseListener responseListener = new ServerApiInfura.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String method, InfuraResponse infuraResponse) {
|
||||
switch (method) {
|
||||
|
|
@ -518,18 +518,18 @@ public class EthEngine extends CoinEngine {
|
|||
}
|
||||
}
|
||||
};
|
||||
serverApiInfura.setInfuraResponse(infuraBodyListener);
|
||||
serverApiInfura.setResponseListener(responseListener);
|
||||
|
||||
serverApiInfura.infura(ServerApiInfura.INFURA_ETH_GET_BALANCE, 67, coinData.getWallet(), "", "");
|
||||
serverApiInfura.infura(ServerApiInfura.INFURA_ETH_GET_TRANSACTION_COUNT, 67, coinData.getWallet(), "", "");
|
||||
serverApiInfura.infura(ServerApiInfura.INFURA_ETH_GET_PENDING_COUNT, 67, coinData.getWallet(), "", "");
|
||||
serverApiInfura.requestData(ServerApiInfura.INFURA_ETH_GET_BALANCE, 67, coinData.getWallet(), "", "");
|
||||
serverApiInfura.requestData(ServerApiInfura.INFURA_ETH_GET_TRANSACTION_COUNT, 67, coinData.getWallet(), "", "");
|
||||
serverApiInfura.requestData(ServerApiInfura.INFURA_ETH_GET_PENDING_COUNT, 67, coinData.getWallet(), "", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestFee(BlockchainRequestsCallbacks blockchainRequestsCallbacks, String targetAddress, Amount amount) {
|
||||
ServerApiInfura serverApiInfura = new ServerApiInfura();
|
||||
// request infura eth gasPrice listener
|
||||
ServerApiInfura.InfuraBodyListener infuraBodyListener = new ServerApiInfura.InfuraBodyListener() {
|
||||
// request requestData eth gasPrice listener
|
||||
ServerApiInfura.ResponseListener responseListener = new ServerApiInfura.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String method, InfuraResponse infuraResponse) {
|
||||
String gasPrice = infuraResponse.getResult();
|
||||
|
|
@ -567,9 +567,9 @@ public class EthEngine extends CoinEngine {
|
|||
blockchainRequestsCallbacks.onComplete(false);
|
||||
}
|
||||
};
|
||||
serverApiInfura.setInfuraResponse(infuraBodyListener);
|
||||
serverApiInfura.setResponseListener(responseListener);
|
||||
|
||||
serverApiInfura.infura(ServerApiInfura.INFURA_ETH_GAS_PRICE, 67, coinData.getWallet(), "", "");
|
||||
serverApiInfura.requestData(ServerApiInfura.INFURA_ETH_GAS_PRICE, 67, coinData.getWallet(), "", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -578,8 +578,8 @@ public class EthEngine extends CoinEngine {
|
|||
String txStr = String.format("0x%s", BTCUtils.toHex(txForSend));
|
||||
|
||||
ServerApiInfura serverApiInfura = new ServerApiInfura();
|
||||
// request infura eth gasPrice listener
|
||||
ServerApiInfura.InfuraBodyListener infuraBodyListener = new ServerApiInfura.InfuraBodyListener() {
|
||||
// request requestData eth gasPrice listener
|
||||
ServerApiInfura.ResponseListener responseListener = new ServerApiInfura.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String method, InfuraResponse infuraResponse) {
|
||||
if (method.equals(ServerApiInfura.INFURA_ETH_SEND_RAW_TRANSACTION)) {
|
||||
|
|
@ -605,9 +605,9 @@ public class EthEngine extends CoinEngine {
|
|||
}
|
||||
};
|
||||
|
||||
serverApiInfura.setInfuraResponse(infuraBodyListener);
|
||||
serverApiInfura.setResponseListener(responseListener);
|
||||
|
||||
serverApiInfura.infura(ServerApiInfura.INFURA_ETH_SEND_RAW_TRANSACTION, 67, coinData.getWallet(), "", txStr);
|
||||
serverApiInfura.requestData(ServerApiInfura.INFURA_ETH_SEND_RAW_TRANSACTION, 67, coinData.getWallet(), "", txStr);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ public class LtcEngine extends BtcEngine {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Uri getShareWalletUriExplorer() {
|
||||
public Uri getWalletExplorerUri() {
|
||||
return Uri.parse("https://live.blockcypher.com/ltc/address/" + ctx.getCoinData().getWallet());
|
||||
}
|
||||
|
||||
|
|
@ -394,7 +394,7 @@ public class LtcEngine extends BtcEngine {
|
|||
}
|
||||
|
||||
@Override
|
||||
public SignTask.PaymentToSign constructPayment(Amount amountValue, Amount feeValue, boolean IncFee, String targetAddress) throws Exception {
|
||||
public SignTask.TransactionToSign constructTransaction(Amount amountValue, Amount feeValue, boolean IncFee, String targetAddress) throws Exception {
|
||||
final ArrayList<UnspentOutputInfo> unspentOutputs;
|
||||
checkBlockchainDataExists();
|
||||
|
||||
|
|
@ -439,7 +439,7 @@ public class LtcEngine extends BtcEngine {
|
|||
bodyDoubleHash[i] = Util.calculateSHA256(bodyHash[i]);
|
||||
}
|
||||
|
||||
return new SignTask.PaymentToSign() {
|
||||
return new SignTask.TransactionToSign() {
|
||||
|
||||
@Override
|
||||
public boolean isSigningMethodSupported(TangemCard.SigningMethod signingMethod) {
|
||||
|
|
@ -489,7 +489,7 @@ public class LtcEngine extends BtcEngine {
|
|||
}
|
||||
|
||||
byte[] txForSend=BTCUtils.buildTXForSend(targetAddress, myAddress, unspentOutputs, amountFinal, changeFinal);
|
||||
notifyOnNeedSendPayment(txForSend);
|
||||
notifyOnNeedSendTransaction(txForSend);
|
||||
return txForSend;
|
||||
}
|
||||
};
|
||||
|
|
@ -507,7 +507,7 @@ public class LtcEngine extends BtcEngine {
|
|||
|
||||
final ServerApiElectrum serverApiElectrum = new ServerApiElectrum();
|
||||
|
||||
final ServerApiElectrum.ElectrumRequestDataListener electrumListener = new ServerApiElectrum.ElectrumRequestDataListener () {
|
||||
final ServerApiElectrum.ResponseListener electrumListener = new ServerApiElectrum.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(ElectrumRequest electrumRequest) {
|
||||
BigDecimal fee;
|
||||
|
|
@ -516,13 +516,13 @@ public class LtcEngine extends BtcEngine {
|
|||
fee = new BigDecimal(electrumRequest.getResultString()); //fee per KB
|
||||
|
||||
if (fee.equals(BigDecimal.ZERO)) {
|
||||
serverApiElectrum.electrumRequestData(ctx, ElectrumRequest.getFee());
|
||||
serverApiElectrum.requestData(ctx, ElectrumRequest.getFee());
|
||||
}
|
||||
|
||||
// if (calcSize != 0) {
|
||||
fee = fee.multiply(new BigDecimal(calcSize)).divide(new BigDecimal(1024)); // (per KB -> per byte)*size
|
||||
// } else {
|
||||
// serverApiElectrum.electrumRequestData(ctx, ElectrumRequest.getFee());
|
||||
// serverApiElectrum.requestData(ctx, ElectrumRequest.getFee());
|
||||
// }
|
||||
|
||||
//compare fee to usual relay fee
|
||||
|
|
@ -553,8 +553,8 @@ public class LtcEngine extends BtcEngine {
|
|||
blockchainRequestsCallbacks.onComplete(false);
|
||||
}
|
||||
};
|
||||
serverApiElectrum.setElectrumRequestData(electrumListener);
|
||||
serverApiElectrum.setResponseListener(electrumListener);
|
||||
|
||||
serverApiElectrum.electrumRequestData(ctx, ElectrumRequest.getFee());
|
||||
serverApiElectrum.requestData(ctx, ElectrumRequest.getFee());
|
||||
}
|
||||
}
|
||||
|
|
@ -60,15 +60,15 @@ public class RskEngine extends EthEngine {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Uri getShareWalletUriExplorer() {
|
||||
public Uri getWalletExplorerUri()) {
|
||||
return Uri.parse("https://explorer.rsk.co/address/" + ctx.getCoinData().getWallet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestBalanceAndUnspentTransactions(BlockchainRequestsCallbacks blockchainRequestsCallbacks) {
|
||||
final ServerApiRootstock serverApiRootstock = new ServerApiRootstock();
|
||||
// request rootstock listener
|
||||
ServerApiRootstock.RootstockBodyListener rootstockBodyListener = new ServerApiRootstock.RootstockBodyListener() {
|
||||
// request requestData listener
|
||||
ServerApiRootstock.ResponseListener responseListener = new ServerApiRootstock.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String method, InfuraResponse rootstockResponse) {
|
||||
switch (method) {
|
||||
|
|
@ -120,18 +120,18 @@ public class RskEngine extends EthEngine {
|
|||
}
|
||||
}
|
||||
};
|
||||
serverApiRootstock.setRootstockResponse(rootstockBodyListener);
|
||||
serverApiRootstock.setResponseListener(responseListener);
|
||||
|
||||
serverApiRootstock.rootstock(ServerApiRootstock.ROOTSTOCK_ETH_GET_BALANCE, 67, coinData.getWallet(), "", "");
|
||||
serverApiRootstock.rootstock(ServerApiRootstock.ROOTSTOCK_ETH_GET_TRANSACTION_COUNT, 67, coinData.getWallet(), "", "");
|
||||
serverApiRootstock.rootstock(ServerApiRootstock.ROOTSTOCK_ETH_GET_PENDING_COUNT, 67, coinData.getWallet(), "", "");
|
||||
serverApiRootstock.requestData(ServerApiRootstock.ROOTSTOCK_ETH_GET_BALANCE, 67, coinData.getWallet(), "", "");
|
||||
serverApiRootstock.requestData(ServerApiRootstock.ROOTSTOCK_ETH_GET_TRANSACTION_COUNT, 67, coinData.getWallet(), "", "");
|
||||
serverApiRootstock.requestData(ServerApiRootstock.ROOTSTOCK_ETH_GET_PENDING_COUNT, 67, coinData.getWallet(), "", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestFee(BlockchainRequestsCallbacks blockchainRequestsCallbacks, String targetAddress, Amount amount) {
|
||||
ServerApiRootstock serverApiRootstock = new ServerApiRootstock();
|
||||
// request rootstock gasPrice listener
|
||||
ServerApiRootstock.RootstockBodyListener rootstockBodyListener = new ServerApiRootstock.RootstockBodyListener() {
|
||||
// request requestData gasPrice listener
|
||||
ServerApiRootstock.ResponseListener responseListener = new ServerApiRootstock.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String method, InfuraResponse rootstockResponse) {
|
||||
String gasPrice = rootstockResponse.getResult();
|
||||
|
|
@ -169,9 +169,9 @@ public class RskEngine extends EthEngine {
|
|||
blockchainRequestsCallbacks.onComplete(false);
|
||||
}
|
||||
};
|
||||
serverApiRootstock.setRootstockResponse(rootstockBodyListener);
|
||||
serverApiRootstock.setResponseListener(responseListener);
|
||||
|
||||
serverApiRootstock.rootstock(ServerApiRootstock.ROOTSTOCK_ETH_GAS_PRICE, 67, coinData.getWallet(), "", "");
|
||||
serverApiRootstock.requestData(ServerApiRootstock.ROOTSTOCK_ETH_GAS_PRICE, 67, coinData.getWallet(), "", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -180,7 +180,7 @@ public class RskEngine extends EthEngine {
|
|||
String txStr = String.format("0x%s", BTCUtils.toHex(txForSend));
|
||||
|
||||
ServerApiRootstock serverApiRootstock = new ServerApiRootstock();
|
||||
ServerApiRootstock.RootstockBodyListener rootstockBodyListener = new ServerApiRootstock.RootstockBodyListener() {
|
||||
ServerApiRootstock.ResponseListener responseListener = new ServerApiRootstock.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String method, InfuraResponse rootstockResponse) {
|
||||
if (method.equals(ServerApiRootstock.ROOTSTOCK_ETH_SEND_RAW_TRANSACTION)) {
|
||||
|
|
@ -206,9 +206,9 @@ public class RskEngine extends EthEngine {
|
|||
}
|
||||
};
|
||||
|
||||
serverApiRootstock.setRootstockResponse(rootstockBodyListener);
|
||||
serverApiRootstock.setResponseListener(responseListener);
|
||||
|
||||
serverApiRootstock.rootstock(ServerApiRootstock.ROOTSTOCK_ETH_SEND_RAW_TRANSACTION, 67, coinData.getWallet(), "", txStr);
|
||||
serverApiRootstock.requestData(ServerApiRootstock.ROOTSTOCK_ETH_SEND_RAW_TRANSACTION, 67, coinData.getWallet(), "", txStr);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,9 +48,7 @@ public class RskTokenEngine extends TokenEngine {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Uri getShareWalletUriExplorer() {
|
||||
return Uri.parse("https://explorer.rsk.co/address/" + ctx.getCoinData().getWallet());
|
||||
} // Only RSK explorer for now
|
||||
public Uri getWalletExplorerUri() { return Uri.parse("https://explorer.rsk.co/address/" + ctx.getCoinData().getWallet()); } // Only RSK explorer for now
|
||||
|
||||
@Override
|
||||
public Uri getShareWalletUri() {
|
||||
|
|
@ -76,8 +74,8 @@ public class RskTokenEngine extends TokenEngine {
|
|||
@Override
|
||||
public void requestBalanceAndUnspentTransactions(BlockchainRequestsCallbacks blockchainRequestsCallbacks) {
|
||||
final ServerApiRootstock serverApiRootstock = new ServerApiRootstock();
|
||||
// request rootstock listener
|
||||
ServerApiRootstock.RootstockBodyListener rootstockBodyListener = new ServerApiRootstock.RootstockBodyListener() {
|
||||
// request requestData listener
|
||||
ServerApiRootstock.ResponseListener responseListener = new ServerApiRootstock.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String method, InfuraResponse rootstockResponse) {
|
||||
switch (method) {
|
||||
|
|
@ -123,9 +121,9 @@ public class RskTokenEngine extends TokenEngine {
|
|||
// Log.i("$TAG eth_call", balanceCap)
|
||||
|
||||
if (blockchainRequestsCallbacks.allowAdvance()) {
|
||||
serverApiRootstock.rootstock(ServerApiRootstock.ROOTSTOCK_ETH_GET_BALANCE, 67, coinData.getWallet(), "", "");
|
||||
serverApiRootstock.rootstock(ServerApiRootstock.ROOTSTOCK_ETH_GET_TRANSACTION_COUNT, 67, coinData.getWallet(), "", "");
|
||||
serverApiRootstock.rootstock(ServerApiRootstock.ROOTSTOCK_ETH_GET_PENDING_COUNT, 67, coinData.getWallet(), "", "");
|
||||
serverApiRootstock.requestData(ServerApiRootstock.ROOTSTOCK_ETH_GET_BALANCE, 67, coinData.getWallet(), "", "");
|
||||
serverApiRootstock.requestData(ServerApiRootstock.ROOTSTOCK_ETH_GET_TRANSACTION_COUNT, 67, coinData.getWallet(), "", "");
|
||||
serverApiRootstock.requestData(ServerApiRootstock.ROOTSTOCK_ETH_GET_PENDING_COUNT, 67, coinData.getWallet(), "", "");
|
||||
} else {
|
||||
ctx.setError("Terminated by user");
|
||||
}
|
||||
|
|
@ -152,16 +150,16 @@ public class RskTokenEngine extends TokenEngine {
|
|||
}
|
||||
}
|
||||
};
|
||||
serverApiRootstock.setRootstockResponse(rootstockBodyListener);
|
||||
serverApiRootstock.setResponseListener(responseListener);
|
||||
|
||||
serverApiRootstock.rootstock(ServerApiRootstock.ROOTSTOCK_ETH_CALL, 67, coinData.getWallet(), getContractAddress(ctx.getCard()), "");
|
||||
serverApiRootstock.requestData(ServerApiRootstock.ROOTSTOCK_ETH_CALL, 67, coinData.getWallet(), getContractAddress(ctx.getCard()), "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestFee(BlockchainRequestsCallbacks blockchainRequestsCallbacks, String targetAddress, Amount amount) {
|
||||
ServerApiRootstock serverApiRootstock = new ServerApiRootstock();
|
||||
// request rootstock gasPrice listener
|
||||
ServerApiRootstock.RootstockBodyListener rootstockBodyListener = new ServerApiRootstock.RootstockBodyListener() {
|
||||
// request requestData gasPrice listener
|
||||
ServerApiRootstock.ResponseListener responseListener = new ServerApiRootstock.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String method, InfuraResponse rootstockResponse) {
|
||||
String gasPrice = rootstockResponse.getResult();
|
||||
|
|
@ -204,9 +202,9 @@ public class RskTokenEngine extends TokenEngine {
|
|||
blockchainRequestsCallbacks.onComplete(false);
|
||||
}
|
||||
};
|
||||
serverApiRootstock.setRootstockResponse(rootstockBodyListener);
|
||||
serverApiRootstock.setResponseListener(responseListener);
|
||||
|
||||
serverApiRootstock.rootstock(ServerApiRootstock.ROOTSTOCK_ETH_GAS_PRICE, 67, coinData.getWallet(), "", "");
|
||||
serverApiRootstock.requestData(ServerApiRootstock.ROOTSTOCK_ETH_GAS_PRICE, 67, coinData.getWallet(), "", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -215,8 +213,8 @@ public class RskTokenEngine extends TokenEngine {
|
|||
String txStr = String.format("0x%s", BTCUtils.toHex(txForSend));
|
||||
|
||||
ServerApiRootstock serverApiRootstock = new ServerApiRootstock();
|
||||
// request rootstock listener
|
||||
ServerApiRootstock.RootstockBodyListener rootstockBodyListener = new ServerApiRootstock.RootstockBodyListener() {
|
||||
// request requestData listener
|
||||
ServerApiRootstock.ResponseListener responseListener = new ServerApiRootstock.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String method, InfuraResponse infuraResponse) {
|
||||
if (method.equals(ServerApiRootstock.ROOTSTOCK_ETH_SEND_RAW_TRANSACTION)) {
|
||||
|
|
@ -242,9 +240,9 @@ public class RskTokenEngine extends TokenEngine {
|
|||
}
|
||||
};
|
||||
|
||||
serverApiRootstock.setRootstockResponse(rootstockBodyListener);
|
||||
serverApiRootstock.setResponseListener(responseListener);
|
||||
|
||||
serverApiRootstock.rootstock(ServerApiRootstock.ROOTSTOCK_ETH_SEND_RAW_TRANSACTION, 67, coinData.getWallet(), "", txStr);
|
||||
serverApiRootstock.requestData(ServerApiRootstock.ROOTSTOCK_ETH_SEND_RAW_TRANSACTION, 67, coinData.getWallet(), "", txStr);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -297,7 +297,7 @@ public class TokenEngine extends CoinEngine {
|
|||
|
||||
|
||||
@Override
|
||||
public Uri getShareWalletUriExplorer() {
|
||||
public Uri getWalletExplorerUri() {
|
||||
return Uri.parse("https://etherscan.io/token/" + getContractAddress(ctx.getCard()) + "?a=" + ctx.getCoinData().getWallet());
|
||||
}
|
||||
|
||||
|
|
@ -437,15 +437,15 @@ public class TokenEngine extends CoinEngine {
|
|||
}
|
||||
|
||||
@Override
|
||||
public SignTask.PaymentToSign constructPayment(Amount amountValue, Amount feeValue, boolean IncFee, String targetAddress) throws Exception {
|
||||
public SignTask.TransactionToSign constructPayment(Amount amountValue, Amount feeValue, boolean IncFee, String targetAddress) throws Exception {
|
||||
if (amountValue.getCurrency().equals(this.getBlockchain().getCurrency())) {
|
||||
return constructPaymentCoin(feeValue, amountValue, IncFee, targetAddress);
|
||||
return constructTransactionCoin(feeValue, amountValue, IncFee, targetAddress);
|
||||
} else {
|
||||
return constructPaymentToken(feeValue, amountValue, IncFee, targetAddress);
|
||||
return constructTransactionToken(feeValue, amountValue, IncFee, targetAddress);
|
||||
}
|
||||
}
|
||||
|
||||
protected SignTask.PaymentToSign constructPaymentCoin(Amount feeValue, Amount amountValue, boolean IncFee, String targetAddress) throws Exception {
|
||||
protected SignTask.TransactionToSign constructTransactionCoin(Amount feeValue, Amount amountValue, boolean IncFee, String targetAddress) throws Exception {
|
||||
Log.e(TAG, "Construct " + this.getBlockchain().getCurrency() + " payment " + amountValue.toString() + " with fee " + feeValue.toString() + (IncFee ? " including" : " excluding"));
|
||||
|
||||
BigInteger nonceValue = coinData.getConfirmedTXCount();
|
||||
|
|
@ -470,7 +470,7 @@ public class TokenEngine extends CoinEngine {
|
|||
|
||||
final EthTransaction tx = EthTransaction.create(to, weiAmount, nonceValue, gasPrice, gasLimit, chainId);
|
||||
|
||||
return new SignTask.PaymentToSign() {
|
||||
return new SignTask.TransactionToSign() {
|
||||
@Override
|
||||
public boolean isSigningMethodSupported(TangemCard.SigningMethod signingMethod) {
|
||||
return signingMethod == TangemCard.SigningMethod.Sign_Hash;
|
||||
|
|
@ -521,14 +521,14 @@ public class TokenEngine extends CoinEngine {
|
|||
Log.e(TAG, this.getClass().getSimpleName() + " V: " + String.valueOf(v));
|
||||
|
||||
byte[] txForSend = tx.getEncoded();
|
||||
notifyOnNeedSendPayment(txForSend);
|
||||
notifyOnNeedSendTransaction(txForSend);
|
||||
return txForSend;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected SignTask.PaymentToSign constructPaymentToken(Amount feeValue, Amount amountValue, boolean IncFee, String targetAddress) throws Exception {
|
||||
Log.e(TAG, "Construct TOKEN payment " + amountValue.toString() + " with fee " + feeValue.toString() + (IncFee ? " including" : " excluding"));
|
||||
private SignTask.TransactionToSign constructTransactionToken(Amount feeValue, Amount amountValue, boolean IncFee, String targetAddress) throws Exception {
|
||||
Log.e(TAG, "Construct TOKEN transaction "+amountValue.toString()+" with fee "+feeValue.toString()+(IncFee?" including":" excluding"));
|
||||
|
||||
BigInteger nonceValue = coinData.getConfirmedTXCount();
|
||||
byte[] pbKey = ctx.getCard().getWalletPublicKey();
|
||||
|
|
@ -578,7 +578,7 @@ public class TokenEngine extends CoinEngine {
|
|||
byte[] data = BTCUtils.fromHex(cmd);
|
||||
EthTransaction tx = EthTransaction.create(contractAddress, amountZero, nonceValue, gasPrice, gasLimit, chainId, data);
|
||||
|
||||
return new SignTask.PaymentToSign() {
|
||||
return new SignTask.TransactionToSign() {
|
||||
@Override
|
||||
public boolean isSigningMethodSupported(TangemCard.SigningMethod signingMethod) {
|
||||
return signingMethod == TangemCard.SigningMethod.Sign_Hash;
|
||||
|
|
@ -629,7 +629,7 @@ public class TokenEngine extends CoinEngine {
|
|||
Log.e(TAG, this.getClass().getSimpleName() + " V: " + String.valueOf(v));
|
||||
|
||||
byte[] txForSend = tx.getEncoded();
|
||||
notifyOnNeedSendPayment(txForSend);
|
||||
notifyOnNeedSendTransaction(txForSend);
|
||||
return txForSend;
|
||||
|
||||
}
|
||||
|
|
@ -640,8 +640,8 @@ public class TokenEngine extends CoinEngine {
|
|||
@Override
|
||||
public void requestBalanceAndUnspentTransactions(BlockchainRequestsCallbacks blockchainRequestsCallbacks) {
|
||||
final ServerApiInfura serverApiInfura = new ServerApiInfura();
|
||||
// request infura listener
|
||||
ServerApiInfura.InfuraBodyListener infuraBodyListener = new ServerApiInfura.InfuraBodyListener() {
|
||||
// request requestData listener
|
||||
ServerApiInfura.ResponseListener responseListener = new ServerApiInfura.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String method, InfuraResponse infuraResponse) {
|
||||
switch (method) {
|
||||
|
|
@ -687,9 +687,9 @@ public class TokenEngine extends CoinEngine {
|
|||
// Log.i("$TAG eth_call", balanceCap)
|
||||
|
||||
if (blockchainRequestsCallbacks.allowAdvance()) {
|
||||
serverApiInfura.infura(ServerApiInfura.INFURA_ETH_GET_BALANCE, 67, coinData.getWallet(), "", "");
|
||||
serverApiInfura.infura(ServerApiInfura.INFURA_ETH_GET_TRANSACTION_COUNT, 67, coinData.getWallet(), "", "");
|
||||
serverApiInfura.infura(ServerApiInfura.INFURA_ETH_GET_PENDING_COUNT, 67, coinData.getWallet(), "", "");
|
||||
serverApiInfura.requestData(ServerApiInfura.INFURA_ETH_GET_BALANCE, 67, coinData.getWallet(), "", "");
|
||||
serverApiInfura.requestData(ServerApiInfura.INFURA_ETH_GET_TRANSACTION_COUNT, 67, coinData.getWallet(), "", "");
|
||||
serverApiInfura.requestData(ServerApiInfura.INFURA_ETH_GET_PENDING_COUNT, 67, coinData.getWallet(), "", "");
|
||||
} else {
|
||||
ctx.setError("Terminated by user");
|
||||
}
|
||||
|
|
@ -716,16 +716,16 @@ public class TokenEngine extends CoinEngine {
|
|||
}
|
||||
}
|
||||
};
|
||||
serverApiInfura.setInfuraResponse(infuraBodyListener);
|
||||
serverApiInfura.setResponseListener(responseListener);
|
||||
|
||||
serverApiInfura.infura(ServerApiInfura.INFURA_ETH_CALL, 67, coinData.getWallet(), getContractAddress(ctx.getCard()), "");
|
||||
serverApiInfura.requestData(ServerApiInfura.INFURA_ETH_CALL, 67, coinData.getWallet(), getContractAddress(ctx.getCard()), "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestFee(BlockchainRequestsCallbacks blockchainRequestsCallbacks, String targetAddress, Amount amount) {
|
||||
ServerApiInfura serverApiInfura = new ServerApiInfura();
|
||||
// request infura eth gasPrice listener
|
||||
ServerApiInfura.InfuraBodyListener infuraBodyListener = new ServerApiInfura.InfuraBodyListener() {
|
||||
// request requestData eth gasPrice listener
|
||||
ServerApiInfura.ResponseListener responseListener = new ServerApiInfura.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String method, InfuraResponse infuraResponse) {
|
||||
String gasPrice = infuraResponse.getResult();
|
||||
|
|
@ -768,9 +768,9 @@ public class TokenEngine extends CoinEngine {
|
|||
blockchainRequestsCallbacks.onComplete(false);
|
||||
}
|
||||
};
|
||||
serverApiInfura.setInfuraResponse(infuraBodyListener);
|
||||
serverApiInfura.setResponseListener(responseListener);
|
||||
|
||||
serverApiInfura.infura(ServerApiInfura.INFURA_ETH_GAS_PRICE, 67, coinData.getWallet(), "", "");
|
||||
serverApiInfura.requestData(ServerApiInfura.INFURA_ETH_GAS_PRICE, 67, coinData.getWallet(), "", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -779,8 +779,8 @@ public class TokenEngine extends CoinEngine {
|
|||
String txStr = String.format("0x%s", BTCUtils.toHex(txForSend));
|
||||
|
||||
ServerApiInfura serverApiInfura = new ServerApiInfura();
|
||||
// request infura eth gasPrice listener
|
||||
ServerApiInfura.InfuraBodyListener infuraBodyListener = new ServerApiInfura.InfuraBodyListener() {
|
||||
// request requestData eth gasPrice listener
|
||||
ServerApiInfura.ResponseListener responseListener = new ServerApiInfura.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String method, InfuraResponse infuraResponse) {
|
||||
if (method.equals(ServerApiInfura.INFURA_ETH_SEND_RAW_TRANSACTION)) {
|
||||
|
|
@ -806,9 +806,9 @@ public class TokenEngine extends CoinEngine {
|
|||
}
|
||||
};
|
||||
|
||||
serverApiInfura.setInfuraResponse(infuraBodyListener);
|
||||
serverApiInfura.setResponseListener(responseListener);
|
||||
|
||||
serverApiInfura.infura(ServerApiInfura.INFURA_ETH_SEND_RAW_TRANSACTION, 67, coinData.getWallet(), "", txStr);
|
||||
serverApiInfura.requestData(ServerApiInfura.INFURA_ETH_SEND_RAW_TRANSACTION, 67, coinData.getWallet(), "", txStr);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import android.content.Intent
|
|||
import android.nfc.NfcAdapter
|
||||
import android.nfc.Tag
|
||||
import android.os.Bundle
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.text.Editable
|
||||
import android.text.Html
|
||||
import android.text.TextWatcher
|
||||
|
|
@ -23,12 +23,12 @@ import com.tangem.tangemcard.data.TangemCard
|
|||
import com.tangem.tangemcard.data.loadFromBundle
|
||||
import com.tangem.util.UtilHelper
|
||||
import com.tangem.wallet.R
|
||||
import kotlinx.android.synthetic.main.activity_confirm_payment.*
|
||||
import kotlinx.android.synthetic.main.activity_confirm_transaction.*
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import java.io.IOException
|
||||
import java.util.*
|
||||
|
||||
class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
||||
class ConfirmTransactionActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
||||
|
||||
private lateinit var nfcManager: NfcManager
|
||||
private lateinit var ctx: TangemContext
|
||||
|
|
@ -41,7 +41,7 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_confirm_payment)
|
||||
setContentView(R.layout.activity_confirm_transaction)
|
||||
|
||||
nfcManager = NfcManager(this, this)
|
||||
|
||||
|
|
@ -71,11 +71,12 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
tvCurrency2.text = engine.feeCurrency
|
||||
tvCardID.text = ctx.card!!.cidDescription
|
||||
etWallet.setText(intent.getStringExtra(Constant.EXTRA_TARGET_ADDRESS))
|
||||
etFee.setText("")
|
||||
|
||||
btnSend.visibility = View.INVISIBLE
|
||||
|
||||
rgFee.isEnabled = !(ctx.blockchain == Blockchain.Ethereum || ctx.blockchain == Blockchain.EthereumTestNet || ctx.blockchain == Blockchain.Token || ctx.blockchain == Blockchain.BitcoinCash || ctx.blockchain == Blockchain.Litecoin)
|
||||
for (lol in rgFee.touchables) {
|
||||
lol.isEnabled = !(ctx.blockchain == Blockchain.Ethereum || ctx.blockchain == Blockchain.EthereumTestNet || ctx.blockchain == Blockchain.Token || ctx.blockchain == Blockchain.BitcoinCash || ctx.blockchain == Blockchain.Litecoin)
|
||||
}
|
||||
|
||||
// set listeners
|
||||
rgFee.setOnCheckedChangeListener { _, checkedId -> doSetFee(checkedId) }
|
||||
|
|
@ -87,11 +88,11 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
|
||||
try {
|
||||
val engine = CoinEngineFactory.create(ctx)
|
||||
val eqFee = engine!!.evaluateFeeEquivalent(etFee!!.text.toString())
|
||||
val eqFee = engine?.evaluateFeeEquivalent(etFee!!.text.toString())
|
||||
tvFeeEquivalent.text = eqFee
|
||||
|
||||
if (!ctx.coinData!!.amountEquivalentDescriptionAvailable) {
|
||||
tvFeeEquivalent.error = "Service unavailable"
|
||||
tvFeeEquivalent.error = getString(R.string.service_unavailable)
|
||||
tvCurrency2.visibility = View.GONE
|
||||
tvFeeEquivalent.visibility = View.GONE
|
||||
} else
|
||||
|
|
@ -108,48 +109,51 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
}
|
||||
})
|
||||
btnSend.setOnClickListener {
|
||||
val calendar = Calendar.getInstance()
|
||||
calendar.add(Calendar.MINUTE, -1)
|
||||
if (UtilHelper.isOnline(this)) {
|
||||
val calendar = Calendar.getInstance()
|
||||
calendar.add(Calendar.MINUTE, -1)
|
||||
|
||||
if (dtVerified == null || dtVerified!!.before(calendar.time)) {
|
||||
finishWithError(Activity.RESULT_CANCELED, getString(R.string.the_obtained_data_is_outdated_try_again))
|
||||
return@setOnClickListener
|
||||
}
|
||||
if (dtVerified == null || dtVerified!!.before(calendar.time)) {
|
||||
finishWithError(Activity.RESULT_CANCELED, getString(R.string.the_obtained_data_is_outdated_try_again))
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
val engineCoin = CoinEngineFactory.create(ctx)
|
||||
val engineCoin = CoinEngineFactory.create(ctx)
|
||||
|
||||
if (engineCoin!!.isNeedCheckNode && !nodeCheck) {
|
||||
Toast.makeText(baseContext, getString(R.string.cannot_reach_current_active_blockchain_node_try_again), Toast.LENGTH_LONG).show()
|
||||
return@setOnClickListener
|
||||
}
|
||||
if (engineCoin!!.isNeedCheckNode && !nodeCheck) {
|
||||
Toast.makeText(baseContext, getString(R.string.cannot_reach_current_active_blockchain_node_try_again), Toast.LENGTH_LONG).show()
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
val txFee = engineCoin.convertToAmount(etFee.text.toString(), tvCurrency2.text.toString())
|
||||
val txAmount = engineCoin.convertToAmount(etAmount.text.toString(), tvCurrency.text.toString())
|
||||
val txFee = engineCoin.convertToAmount(etFee.text.toString(), tvCurrency2.text.toString())
|
||||
val txAmount = engineCoin.convertToAmount(etAmount.text.toString(), tvCurrency.text.toString())
|
||||
|
||||
if (!engineCoin.hasBalanceInfo()) {
|
||||
finishWithError(Activity.RESULT_CANCELED, getString(R.string.cannot_check_balance_no_connection_with_blockchain_nodes))
|
||||
return@setOnClickListener
|
||||
if (!engineCoin.hasBalanceInfo()) {
|
||||
finishWithError(Activity.RESULT_CANCELED, getString(R.string.cannot_check_balance_no_connection_with_blockchain_nodes))
|
||||
return@setOnClickListener
|
||||
|
||||
} else if (!engineCoin.isBalanceNotZero) {
|
||||
finishWithError(Activity.RESULT_CANCELED, getString(R.string.the_wallet_is_empty))
|
||||
return@setOnClickListener
|
||||
} else if (!engineCoin.isBalanceNotZero) {
|
||||
finishWithError(Activity.RESULT_CANCELED, getString(R.string.the_wallet_is_empty))
|
||||
return@setOnClickListener
|
||||
|
||||
} else if (!engineCoin.isExtractPossible) {
|
||||
finishWithError(Activity.RESULT_CANCELED, getString(R.string.please_wait_for_confirmation_of_incoming_transaction))
|
||||
return@setOnClickListener
|
||||
}
|
||||
} else if (!engineCoin.isExtractPossible) {
|
||||
finishWithError(Activity.RESULT_CANCELED, getString(R.string.please_wait_for_confirmation_of_incoming_transaction))
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
if (!engineCoin.checkNewTransactionAmountAndFee(txAmount, txFee, isIncludeFee)) {
|
||||
finishWithError(Activity.RESULT_CANCELED, getString(R.string.not_enough_funds_on_your_card))
|
||||
return@setOnClickListener
|
||||
}
|
||||
if (!engineCoin.checkNewTransactionAmountAndFee(txAmount, txFee, isIncludeFee)) {
|
||||
finishWithError(Activity.RESULT_CANCELED, getString(R.string.not_enough_funds_on_your_card))
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
requestPIN2Count = 0
|
||||
val intent = Intent(baseContext, PinRequestActivity::class.java)
|
||||
intent.putExtra(Constant.EXTRA_MODE, PinRequestActivity.Mode.RequestPIN2.toString())
|
||||
ctx.saveToIntent(intent)
|
||||
intent.putExtra(Constant.EXTRA_FEE_INCLUDED, isIncludeFee)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_REQUEST_PIN2_)
|
||||
requestPIN2Count = 0
|
||||
val intent = Intent(baseContext, PinRequestActivity::class.java)
|
||||
intent.putExtra(Constant.EXTRA_MODE, PinRequestActivity.Mode.RequestPIN2.toString())
|
||||
ctx.saveToIntent(intent)
|
||||
intent.putExtra(Constant.EXTRA_FEE_INCLUDED, isIncludeFee)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_REQUEST_PIN2_)
|
||||
} else
|
||||
Toast.makeText(this, getString(R.string.no_connection), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
val coinEngine = CoinEngineFactory.create(ctx)
|
||||
|
|
@ -173,7 +177,7 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
}
|
||||
|
||||
override fun allowAdvance(): Boolean {
|
||||
return UtilHelper.isOnline(this@ConfirmPaymentActivity)
|
||||
return UtilHelper.isOnline(this@ConfirmTransactionActivity)
|
||||
}
|
||||
},
|
||||
etWallet.text.toString(),
|
||||
|
|
@ -197,7 +201,7 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
if (requestCode == Constant.REQUEST_CODE_SIGN_PAYMENT) {
|
||||
if (requestCode == Constant.REQUEST_CODE_SIGN_TRANSACTION) {
|
||||
if (data != null && data.extras != null) {
|
||||
if (data.extras!!.containsKey("UID") && data.extras!!.containsKey("Card")) {
|
||||
val updatedCard = TangemCard(data.getStringExtra("UID"))
|
||||
|
|
@ -220,7 +224,7 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
finish()
|
||||
} else if (requestCode == Constant.REQUEST_CODE_REQUEST_PIN2_) {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
val intent = Intent(baseContext, SignPaymentActivity::class.java)
|
||||
val intent = Intent(baseContext, SignTransactionActivity::class.java)
|
||||
ctx.saveToIntent(intent)
|
||||
intent.putExtra(Constant.EXTRA_TARGET_ADDRESS, etWallet!!.text.toString())
|
||||
intent.putExtra(Constant.EXTRA_AMOUNT, etAmount.text.toString())
|
||||
|
|
@ -228,9 +232,9 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
intent.putExtra(Constant.EXTRA_FEE, etFee.text.toString())
|
||||
intent.putExtra(Constant.EXTRA_FEE_CURRENCY, tvCurrency2.text.toString())
|
||||
intent.putExtra(Constant.EXTRA_FEE_INCLUDED, isIncludeFee)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_SIGN_PAYMENT)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_SIGN_TRANSACTION)
|
||||
} else
|
||||
Toast.makeText(baseContext, R.string.pin_2_is_required_to_sign_the_payment, Toast.LENGTH_LONG).show()
|
||||
Toast.makeText(baseContext, R.string.pin_2_is_required_to_sign_the_transaction, Toast.LENGTH_LONG).show()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -9,15 +9,20 @@ import android.nfc.NfcAdapter
|
|||
import android.nfc.Tag
|
||||
import android.nfc.tech.IsoDep
|
||||
import android.os.Bundle
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.view.View
|
||||
import android.view.animation.Animation
|
||||
import android.view.animation.DecelerateInterpolator
|
||||
import android.view.animation.Transformation
|
||||
import android.widget.ProgressBar
|
||||
import android.widget.RelativeLayout
|
||||
import android.widget.Toast
|
||||
import com.tangem.App
|
||||
import com.tangem.Constant
|
||||
import com.tangem.domain.wallet.TangemContext
|
||||
import com.tangem.presentation.dialog.NoExtendedLengthSupportDialog
|
||||
import com.tangem.presentation.dialog.WaitSecurityDelayDialog
|
||||
import com.tangem.tangemcard.android.nfc.DeviceNFCAntennaLocation
|
||||
import com.tangem.tangemcard.android.reader.NfcManager
|
||||
import com.tangem.tangemcard.android.reader.NfcReader
|
||||
import com.tangem.tangemcard.data.asBundle
|
||||
|
|
@ -26,6 +31,7 @@ import com.tangem.tangemcard.tasks.CreateNewWalletTask
|
|||
import com.tangem.tangemcard.util.Util
|
||||
import com.tangem.wallet.R
|
||||
import kotlinx.android.synthetic.main.activity_create_new_wallet.*
|
||||
import kotlinx.android.synthetic.main.layout_touch_card.*
|
||||
|
||||
class CreateNewWalletActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtocol.Notifications {
|
||||
companion object {
|
||||
|
|
@ -40,6 +46,8 @@ class CreateNewWalletActivity : AppCompatActivity(), NfcAdapter.ReaderCallback,
|
|||
private lateinit var nfcManager: NfcManager
|
||||
private lateinit var ctx: TangemContext
|
||||
|
||||
private lateinit var antenna: DeviceNFCAntennaLocation
|
||||
|
||||
private var createNewWalletTask: CreateNewWalletTask? = null
|
||||
private var lastReadSuccess = true
|
||||
|
||||
|
|
@ -58,6 +66,31 @@ class CreateNewWalletActivity : AppCompatActivity(), NfcAdapter.ReaderCallback,
|
|||
progressBar = findViewById(R.id.progressBar)
|
||||
progressBar!!.progressTintList = ColorStateList.valueOf(Color.DKGRAY)
|
||||
progressBar!!.visibility = View.INVISIBLE
|
||||
|
||||
// get NFC Antenna
|
||||
antenna = DeviceNFCAntennaLocation()
|
||||
antenna.getAntennaLocation()
|
||||
|
||||
// set card orientation
|
||||
when (antenna.orientation) {
|
||||
DeviceNFCAntennaLocation.CARD_ORIENTATION_HORIZONTAL -> {
|
||||
ivHandCardHorizontal.visibility = View.VISIBLE
|
||||
ivHandCardVertical.visibility = View.GONE
|
||||
}
|
||||
|
||||
DeviceNFCAntennaLocation.CARD_ORIENTATION_VERTICAL -> {
|
||||
ivHandCardVertical.visibility = View.VISIBLE
|
||||
ivHandCardHorizontal.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
// set card z position
|
||||
when (antenna.z) {
|
||||
DeviceNFCAntennaLocation.CARD_ON_BACK -> llHand.elevation = 0.0f
|
||||
DeviceNFCAntennaLocation.CARD_ON_FRONT -> llHand.elevation = 30.0f
|
||||
}
|
||||
|
||||
animate()
|
||||
}
|
||||
|
||||
override fun onTagDiscovered(tag: Tag) {
|
||||
|
|
@ -70,11 +103,11 @@ class CreateNewWalletActivity : AppCompatActivity(), NfcAdapter.ReaderCallback,
|
|||
// Log.v(TAG, "UID: " + sUID);
|
||||
|
||||
if (sUID == ctx.card!!.uid) {
|
||||
if (lastReadSuccess) {
|
||||
if (lastReadSuccess)
|
||||
isoDep.timeout = ctx.card!!.pauseBeforePIN2 + 5000
|
||||
} else {
|
||||
else
|
||||
isoDep.timeout = ctx.card!!.pauseBeforePIN2 + 65000
|
||||
}
|
||||
|
||||
createNewWalletTask = CreateNewWalletTask(ctx.card, NfcReader(nfcManager, isoDep), App.localStorage, App.pinStorage, this)
|
||||
createNewWalletTask!!.start()
|
||||
} else {
|
||||
|
|
@ -108,6 +141,8 @@ class CreateNewWalletActivity : AppCompatActivity(), NfcAdapter.ReaderCallback,
|
|||
}
|
||||
|
||||
override fun onReadStart(cardProtocol: CardProtocol) {
|
||||
rlProgressBar.post { rlProgressBar.visibility = View.VISIBLE }
|
||||
|
||||
progressBar!!.post {
|
||||
progressBar!!.visibility = View.VISIBLE
|
||||
progressBar!!.progress = 5
|
||||
|
|
@ -118,6 +153,8 @@ class CreateNewWalletActivity : AppCompatActivity(), NfcAdapter.ReaderCallback,
|
|||
createNewWalletTask = null
|
||||
if (cardProtocol != null) {
|
||||
if (cardProtocol.error == null) {
|
||||
rlProgressBar.post { rlProgressBar.visibility = View.GONE }
|
||||
|
||||
progressBar!!.post {
|
||||
progressBar!!.progress = 100
|
||||
progressBar!!.progressTintList = ColorStateList.valueOf(Color.GREEN)
|
||||
|
|
@ -165,6 +202,14 @@ class CreateNewWalletActivity : AppCompatActivity(), NfcAdapter.ReaderCallback,
|
|||
}
|
||||
}
|
||||
|
||||
rlProgressBar.postDelayed({
|
||||
try {
|
||||
rlProgressBar.visibility = View.GONE
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}, 500)
|
||||
|
||||
progressBar!!.postDelayed({
|
||||
try {
|
||||
progressBar!!.progress = 0
|
||||
|
|
@ -206,4 +251,24 @@ class CreateNewWalletActivity : AppCompatActivity(), NfcAdapter.ReaderCallback,
|
|||
WaitSecurityDelayDialog.onReadAfterRequest(this)
|
||||
}
|
||||
|
||||
private fun animate() {
|
||||
val lp = llHand.layoutParams as RelativeLayout.LayoutParams
|
||||
val lp2 = llNfc.layoutParams as RelativeLayout.LayoutParams
|
||||
val dp = resources.displayMetrics.density
|
||||
val lm = dp * (69 + antenna.x * 75)
|
||||
lp.topMargin = (dp * (-100 + antenna.y * 250)).toInt()
|
||||
lp2.topMargin = (dp * (-125 + antenna.y * 250)).toInt()
|
||||
llNfc.layoutParams = lp2
|
||||
|
||||
val a = object : Animation() {
|
||||
override fun applyTransformation(interpolatedTime: Float, t: Transformation) {
|
||||
lp.leftMargin = (lm * interpolatedTime).toInt()
|
||||
llHand.layoutParams = lp
|
||||
}
|
||||
}
|
||||
a.duration = 2000
|
||||
a.interpolator = DecelerateInterpolator()
|
||||
llHand.startAnimation(a)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@ import android.nfc.NfcAdapter
|
|||
import android.nfc.Tag
|
||||
import android.nfc.tech.IsoDep
|
||||
import android.os.Bundle
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.text.Html
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
|
|
@ -28,8 +28,10 @@ import com.tangem.tangemcard.reader.CardProtocol
|
|||
import com.tangem.tangemcard.tasks.VerifyCardTask
|
||||
import com.tangem.tangemcard.util.Util
|
||||
import com.tangem.util.LOG
|
||||
import com.tangem.util.UtilHelper
|
||||
import com.tangem.wallet.R
|
||||
import kotlinx.android.synthetic.main.activity_empty_wallet.*
|
||||
import kotlinx.android.synthetic.main.layout_tangem_card.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class EmptyWalletActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtocol.Notifications {
|
||||
|
|
@ -52,6 +54,8 @@ class EmptyWalletActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Card
|
|||
private var verifyCardTask: VerifyCardTask? = null
|
||||
private var requestPIN2Count = 0
|
||||
|
||||
private var cardProtocol: CardProtocol? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_empty_wallet)
|
||||
|
|
@ -71,34 +75,7 @@ class EmptyWalletActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Card
|
|||
tvBlockchain.text = ctx.blockchainName
|
||||
|
||||
tvCardID.text = ctx.card!!.cidDescription
|
||||
imgBlockchain.setImageResource(ctx.blockchain.getImageResource(this, ctx.card!!.tokenSymbol))
|
||||
|
||||
if (ctx.card!!.useDefaultPIN1()) {
|
||||
imgPIN.setImageResource(R.drawable.unlock_pin1)
|
||||
imgPIN.setOnClickListener { Toast.makeText(this@EmptyWalletActivity, R.string.this_banknote_protected_default_PIN1_code, Toast.LENGTH_LONG).show() }
|
||||
} else {
|
||||
imgPIN.setImageResource(R.drawable.lock_pin1)
|
||||
imgPIN.setOnClickListener { Toast.makeText(this@EmptyWalletActivity, R.string.this_banknote_protected_user_PIN1_code, Toast.LENGTH_LONG).show() }
|
||||
}
|
||||
|
||||
if (ctx.card!!.pauseBeforePIN2 > 0 && (ctx.card!!.useDefaultPIN2()!! || !ctx.card!!.useSmartSecurityDelay())) {
|
||||
imgPIN2orSecurityDelay.setImageResource(R.drawable.timer)
|
||||
imgPIN2orSecurityDelay.setOnClickListener { Toast.makeText(this@EmptyWalletActivity, String.format(getString(R.string.this_banknote_will_enforce), ctx.card!!.pauseBeforePIN2 / 1000.0), Toast.LENGTH_LONG).show() }
|
||||
|
||||
} else if (ctx.card!!.useDefaultPIN2()!!) {
|
||||
imgPIN2orSecurityDelay.setImageResource(R.drawable.unlock_pin2)
|
||||
imgPIN2orSecurityDelay.setOnClickListener { Toast.makeText(this@EmptyWalletActivity, R.string.this_banknote_protected_default_PIN2_code, Toast.LENGTH_LONG).show() }
|
||||
} else {
|
||||
imgPIN2orSecurityDelay.setImageResource(R.drawable.lock_pin2)
|
||||
imgPIN2orSecurityDelay.setOnClickListener { Toast.makeText(this@EmptyWalletActivity, R.string.this_banknote_protected_user_PIN2_code, Toast.LENGTH_LONG).show() }
|
||||
}
|
||||
|
||||
if (ctx.card!!.useDevelopersFirmware()!!) {
|
||||
imgDeveloperVersion.setImageResource(R.drawable.ic_developer_version)
|
||||
imgDeveloperVersion.visibility = View.VISIBLE
|
||||
imgDeveloperVersion.setOnClickListener { Toast.makeText(this@EmptyWalletActivity, R.string.unlocked_banknote_only_development_use, Toast.LENGTH_LONG).show() }
|
||||
} else
|
||||
imgDeveloperVersion.visibility = View.INVISIBLE
|
||||
ivTangemCard.setImageBitmap(App.localStorage.getCardArtworkBitmap(ctx.card))
|
||||
|
||||
// set listeners
|
||||
btnNewWallet.setOnClickListener {
|
||||
|
|
@ -109,6 +86,13 @@ class EmptyWalletActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Card
|
|||
intent.putExtra("Card", ctx.card!!.asBundle)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_REQUEST_PIN2)
|
||||
}
|
||||
|
||||
btnDetails.setOnClickListener {
|
||||
if (cardProtocol != null)
|
||||
navigator.showVerifyCard(this, ctx)
|
||||
else
|
||||
UtilHelper.showSingleToast(this, getString(R.string.need_attach_card_again))
|
||||
}
|
||||
}
|
||||
|
||||
public override fun onResume() {
|
||||
|
|
@ -129,7 +113,6 @@ class EmptyWalletActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Card
|
|||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
if (requestCode == Constant.REQUEST_CODE_CREATE_NEW_WALLET_ACTIVITY) {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
|
||||
if (data != null) {
|
||||
data.putExtra("modification", "updateAndViewCard")
|
||||
data.putExtra("updateDelay", 0)
|
||||
|
|
@ -175,23 +158,24 @@ class EmptyWalletActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Card
|
|||
LOG.d(TAG, "UID: $sUID")
|
||||
}
|
||||
|
||||
if (lastReadSuccess) {
|
||||
if (lastReadSuccess)
|
||||
isoDep.timeout = 1000
|
||||
} else {
|
||||
else
|
||||
isoDep.timeout = 65000
|
||||
}
|
||||
//lastTag = tag;
|
||||
|
||||
verifyCardTask = VerifyCardTask(ctx.card, NfcReader(nfcManager, isoDep), App.localStorage, App.pinStorage, App.firmwaresStorage, this)
|
||||
verifyCardTask!!.start()
|
||||
verifyCardTask?.start()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onReadStart(cardProtocol: CardProtocol) {
|
||||
progressBar!!.post {
|
||||
progressBar!!.visibility = View.VISIBLE
|
||||
progressBar!!.progress = 5
|
||||
rlProgressBar?.post { rlProgressBar.visibility = View.VISIBLE }
|
||||
|
||||
progressBar?.post {
|
||||
progressBar?.visibility = View.VISIBLE
|
||||
progressBar?.progress = 5
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -199,37 +183,42 @@ class EmptyWalletActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Card
|
|||
verifyCardTask = null
|
||||
if (cardProtocol != null) {
|
||||
if (cardProtocol.error == null) {
|
||||
progressBar!!.post {
|
||||
progressBar!!.progress = 100
|
||||
progressBar!!.progressTintList = ColorStateList.valueOf(Color.GREEN)
|
||||
// val intent = Intent(this@EmptyWalletActivity, VerifyCardActivity::class.java)
|
||||
// intent.putExtra("UID", cardProtocol.card.uid)
|
||||
// intent.putExtra("Card", cardProtocol.card.asBundle)
|
||||
// startActivityForResult(intent, REQUEST_CODE_VERIFY_CARD)
|
||||
//addCard(cardProtocol.getCard());
|
||||
rlProgressBar?.post { rlProgressBar.visibility = View.GONE }
|
||||
|
||||
progressBar?.post {
|
||||
progressBar?.progress = 100
|
||||
progressBar?.progressTintList = ColorStateList.valueOf(Color.GREEN)
|
||||
this.cardProtocol = cardProtocol
|
||||
}
|
||||
} else {
|
||||
// remove last UIDs because of error and no card read
|
||||
progressBar!!.post {
|
||||
progressBar?.post {
|
||||
lastReadSuccess = false
|
||||
if (cardProtocol.error is CardProtocol.TangemException_ExtendedLengthNotSupported) {
|
||||
if (!NoExtendedLengthSupportDialog.allReadyShowed) {
|
||||
if (!NoExtendedLengthSupportDialog.allReadyShowed)
|
||||
NoExtendedLengthSupportDialog().show(supportFragmentManager, NoExtendedLengthSupportDialog.TAG)
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
Toast.makeText(this@EmptyWalletActivity, R.string.try_to_scan_again, Toast.LENGTH_LONG).show()
|
||||
}
|
||||
progressBar!!.progress = 100
|
||||
progressBar!!.progressTintList = ColorStateList.valueOf(Color.RED)
|
||||
|
||||
progressBar?.progress = 100
|
||||
progressBar?.progressTintList = ColorStateList.valueOf(Color.RED)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
progressBar!!.postDelayed({
|
||||
rlProgressBar?.postDelayed({
|
||||
try {
|
||||
progressBar!!.progress = 0
|
||||
progressBar!!.progressTintList = ColorStateList.valueOf(Color.DKGRAY)
|
||||
progressBar!!.visibility = View.INVISIBLE
|
||||
rlProgressBar?.visibility = View.GONE
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}, 500)
|
||||
|
||||
progressBar?.postDelayed({
|
||||
try {
|
||||
progressBar?.progress = 0
|
||||
progressBar?.progressTintList = ColorStateList.valueOf(Color.DKGRAY)
|
||||
progressBar?.visibility = View.INVISIBLE
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
|
@ -237,16 +226,25 @@ class EmptyWalletActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Card
|
|||
}
|
||||
|
||||
override fun onReadProgress(protocol: CardProtocol, progress: Int) {
|
||||
progressBar!!.post { progressBar!!.progress = progress }
|
||||
progressBar?.post { progressBar!!.progress = progress }
|
||||
}
|
||||
|
||||
override fun onReadCancel() {
|
||||
verifyCardTask = null
|
||||
progressBar!!.postDelayed({
|
||||
|
||||
rlProgressBar?.postDelayed({
|
||||
try {
|
||||
progressBar!!.progress = 0
|
||||
progressBar!!.progressTintList = ColorStateList.valueOf(Color.DKGRAY)
|
||||
progressBar!!.visibility = View.INVISIBLE
|
||||
rlProgressBar?.visibility = View.GONE
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}, 500)
|
||||
|
||||
progressBar?.postDelayed({
|
||||
try {
|
||||
progressBar?.progress = 0
|
||||
progressBar?.progressTintList = ColorStateList.valueOf(Color.DKGRAY)
|
||||
progressBar?.visibility = View.INVISIBLE
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import android.content.Intent
|
|||
import android.nfc.NfcAdapter
|
||||
import android.nfc.Tag
|
||||
import android.os.Bundle
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.tangem.App
|
||||
import com.tangem.Constant
|
||||
import com.tangem.di.Navigator
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import android.annotation.SuppressLint
|
|||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.tangem.App
|
||||
import com.tangem.Constant
|
||||
import com.tangem.di.Navigator
|
||||
|
|
|
|||
|
|
@ -10,10 +10,10 @@ 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 androidx.core.app.ActivityCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.widget.PopupMenu
|
||||
import android.util.Log
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
|
|
@ -48,6 +48,7 @@ import com.tangem.util.PhoneUtility
|
|||
import com.tangem.wallet.BuildConfig
|
||||
import com.tangem.wallet.R
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import kotlinx.android.synthetic.main.layout_touch_card.*
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
|
@ -65,7 +66,7 @@ class MainActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoco
|
|||
private lateinit var nfcManager: NfcManager
|
||||
|
||||
private var zipFile: File? = null
|
||||
private var antenna: DeviceNFCAntennaLocation? = null
|
||||
private lateinit var antenna: DeviceNFCAntennaLocation
|
||||
private var unsuccessReadCount = 0
|
||||
private var lastTag: Tag? = null
|
||||
private var readCardInfoTask: ReadCardInfoTask? = null
|
||||
|
|
@ -98,11 +99,12 @@ class MainActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoco
|
|||
|
||||
rippleBackgroundNfc.startRippleAnimation()
|
||||
|
||||
// get NFC Antenna
|
||||
antenna = DeviceNFCAntennaLocation()
|
||||
antenna!!.getAntennaLocation()
|
||||
antenna.getAntennaLocation()
|
||||
|
||||
// set card orientation
|
||||
when (antenna!!.orientation) {
|
||||
when (antenna.orientation) {
|
||||
DeviceNFCAntennaLocation.CARD_ORIENTATION_HORIZONTAL -> {
|
||||
ivHandCardHorizontal.visibility = View.VISIBLE
|
||||
ivHandCardVertical.visibility = View.GONE
|
||||
|
|
@ -115,19 +117,19 @@ class MainActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoco
|
|||
}
|
||||
|
||||
// set card z position
|
||||
when (antenna!!.z) {
|
||||
when (antenna.z) {
|
||||
DeviceNFCAntennaLocation.CARD_ON_BACK -> llHand.elevation = 0.0f
|
||||
DeviceNFCAntennaLocation.CARD_ON_FRONT -> llHand.elevation = 30.0f
|
||||
}
|
||||
|
||||
animate()
|
||||
|
||||
// set phone name
|
||||
if (antenna!!.fullName != "")
|
||||
if (antenna.fullName != "")
|
||||
tvNFCHint.text = String.format(getString(R.string.scan_banknote), antenna!!.fullName)
|
||||
else
|
||||
tvNFCHint.text = String.format(getString(R.string.scan_banknote), getString(R.string.phone))
|
||||
|
||||
animate()
|
||||
|
||||
// NFC
|
||||
val intent = intent
|
||||
if (intent != null && (NfcAdapter.ACTION_TECH_DISCOVERED == intent.action || NfcAdapter.ACTION_NDEF_DISCOVERED == intent.action)) {
|
||||
|
|
@ -388,9 +390,9 @@ class MainActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoco
|
|||
val lp = llHand.layoutParams as RelativeLayout.LayoutParams
|
||||
val lp2 = llNfc.layoutParams as RelativeLayout.LayoutParams
|
||||
val dp = resources.displayMetrics.density
|
||||
val lm = dp * (69 + antenna!!.x * 75)
|
||||
lp.topMargin = (dp * (-100 + antenna!!.y * 250)).toInt()
|
||||
lp2.topMargin = (dp * (-125 + antenna!!.y * 250)).toInt()
|
||||
val lm = dp * (69 + antenna.x * 75)
|
||||
lp.topMargin = (dp * (-100 + antenna.y * 250)).toInt()
|
||||
lp2.topMargin = (dp * (-125 + antenna.y * 250)).toInt()
|
||||
llNfc.layoutParams = lp2
|
||||
|
||||
val a = object : Animation() {
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ import android.nfc.NfcAdapter
|
|||
import android.nfc.Tag
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.support.v4.app.ActivityCompat
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.text.TextUtils
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ import android.os.Bundle
|
|||
import android.security.keystore.KeyGenParameterSpec
|
||||
import android.security.keystore.KeyPermanentlyInvalidatedException
|
||||
import android.security.keystore.KeyProperties
|
||||
import android.support.v4.app.ActivityCompat
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.text.TextUtils
|
||||
import android.view.View
|
||||
import android.widget.Button
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import android.nfc.NfcAdapter
|
|||
import android.nfc.Tag
|
||||
import android.nfc.tech.IsoDep
|
||||
import android.os.Bundle
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.view.View
|
||||
import android.widget.ProgressBar
|
||||
import android.widget.Toast
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import android.graphics.Color
|
|||
import android.nfc.NfcAdapter
|
||||
import android.nfc.Tag
|
||||
import android.os.Bundle
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.view.View
|
||||
import com.tangem.App
|
||||
import com.tangem.Constant
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import android.graphics.Color
|
|||
import android.nfc.NfcAdapter
|
||||
import android.nfc.Tag
|
||||
import android.os.Bundle
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.text.InputFilter
|
||||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import android.graphics.Color
|
|||
import android.nfc.NfcAdapter
|
||||
import android.nfc.Tag
|
||||
import android.os.Bundle
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import android.content.Intent
|
|||
import android.nfc.NfcAdapter
|
||||
import android.nfc.Tag
|
||||
import android.os.Bundle
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.text.Html
|
||||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
|
|
@ -20,20 +20,22 @@ import com.tangem.domain.wallet.CoinEngineFactory
|
|||
import com.tangem.domain.wallet.TangemContext
|
||||
import com.tangem.tangemcard.android.reader.NfcManager
|
||||
import com.tangem.wallet.R
|
||||
import kotlinx.android.synthetic.main.activity_prepare_payment.*
|
||||
import kotlinx.android.synthetic.main.activity_prepare_transaction.*
|
||||
import java.io.IOException
|
||||
import javax.inject.Inject
|
||||
|
||||
class PreparePaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
||||
class PrepareTransactionActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
||||
|
||||
companion object {
|
||||
val TAG: String = PreparePaymentActivity::class.java.simpleName
|
||||
val TAG: String = PrepareTransactionActivity::class.java.simpleName
|
||||
fun callingIntent(context: Context, ctx: TangemContext): Intent {
|
||||
val intent = Intent(context, PreparePaymentActivity::class.java)
|
||||
val intent = Intent(context, PrepareTransactionActivity::class.java)
|
||||
ctx.saveToIntent(intent)
|
||||
return intent
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Inject
|
||||
internal lateinit var navigator: Navigator
|
||||
|
||||
|
|
@ -43,7 +45,7 @@ class PreparePaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
@SuppressLint("SetTextI18n")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_prepare_payment)
|
||||
setContentView(R.layout.activity_prepare_transaction)
|
||||
|
||||
App.getNavigatorComponent().inject(this)
|
||||
|
||||
|
|
@ -116,13 +118,13 @@ class PreparePaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
return@setOnClickListener
|
||||
}
|
||||
|
||||
val intent = Intent(baseContext, ConfirmPaymentActivity::class.java)
|
||||
val intent = Intent(baseContext, ConfirmTransactionActivity::class.java)
|
||||
ctx.saveToIntent(intent)
|
||||
intent.putExtra(Constant.EXTRA_TARGET_ADDRESS, etWallet!!.text.toString())
|
||||
intent.putExtra(Constant.EXTRA_FEE_INCLUDED, (rgIncFee!!.checkedRadioButtonId == R.id.rbFeeIn))
|
||||
intent.putExtra(Constant.EXTRA_AMOUNT, strAmount)
|
||||
intent.putExtra(Constant.EXTRA_AMOUNT_CURRENCY, tvCurrency.text.toString())
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_SEND_PAYMENT__)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_SEND_TRANSACTION__)
|
||||
}
|
||||
|
||||
ivCamera.setOnClickListener { navigator.showQrScanActivity(this, Constant.REQUEST_CODE_SCAN_QR) }
|
||||
|
|
@ -167,7 +169,7 @@ class PreparePaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
}
|
||||
}
|
||||
etWallet!!.setText(code)
|
||||
} else if (requestCode == Constant.REQUEST_CODE_SEND_PAYMENT__) {
|
||||
} else if (requestCode == Constant.REQUEST_CODE_SEND_TRANSACTION__) {
|
||||
setResult(resultCode, data)
|
||||
finish()
|
||||
}
|
||||
|
|
@ -10,8 +10,12 @@ import android.nfc.NfcAdapter
|
|||
import android.nfc.Tag
|
||||
import android.nfc.tech.IsoDep
|
||||
import android.os.Bundle
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.view.View
|
||||
import android.view.animation.Animation
|
||||
import android.view.animation.DecelerateInterpolator
|
||||
import android.view.animation.Transformation
|
||||
import android.widget.RelativeLayout
|
||||
import android.widget.Toast
|
||||
import com.tangem.App
|
||||
import com.tangem.tangemcard.tasks.PurgeTask
|
||||
|
|
@ -20,15 +24,18 @@ import com.tangem.tangemcard.android.reader.NfcManager
|
|||
import com.tangem.domain.wallet.TangemContext
|
||||
import com.tangem.presentation.dialog.NoExtendedLengthSupportDialog
|
||||
import com.tangem.presentation.dialog.WaitSecurityDelayDialog
|
||||
import com.tangem.presentation.event.DeletingWalletFinish
|
||||
import com.tangem.tangemcard.android.nfc.DeviceNFCAntennaLocation
|
||||
import com.tangem.tangemcard.android.reader.NfcReader
|
||||
import com.tangem.tangemcard.data.asBundle
|
||||
import com.tangem.tangemcard.util.Util
|
||||
import com.tangem.util.LOG
|
||||
import com.tangem.wallet.R
|
||||
import kotlinx.android.synthetic.main.activity_purge.*
|
||||
import kotlinx.android.synthetic.main.layout_touch_card.*
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
|
||||
class PurgeActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtocol.Notifications {
|
||||
|
||||
companion object {
|
||||
val TAG: String = PurgeActivity::class.java.simpleName
|
||||
|
||||
|
|
@ -44,6 +51,8 @@ class PurgeActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoc
|
|||
private lateinit var nfcManager: NfcManager
|
||||
private lateinit var ctx: TangemContext
|
||||
|
||||
private lateinit var antenna: DeviceNFCAntennaLocation
|
||||
|
||||
private var purgeTask: PurgeTask? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
|
@ -59,6 +68,31 @@ class PurgeActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoc
|
|||
tvCardID.text = ctx.card!!.cidDescription
|
||||
progressBar.progressTintList = ColorStateList.valueOf(Color.DKGRAY)
|
||||
progressBar.visibility = View.INVISIBLE
|
||||
|
||||
// get NFC Antenna
|
||||
antenna = DeviceNFCAntennaLocation()
|
||||
antenna.getAntennaLocation()
|
||||
|
||||
// set card orientation
|
||||
when (antenna.orientation) {
|
||||
DeviceNFCAntennaLocation.CARD_ORIENTATION_HORIZONTAL -> {
|
||||
ivHandCardHorizontal.visibility = View.VISIBLE
|
||||
ivHandCardVertical.visibility = View.GONE
|
||||
}
|
||||
|
||||
DeviceNFCAntennaLocation.CARD_ORIENTATION_VERTICAL -> {
|
||||
ivHandCardVertical.visibility = View.VISIBLE
|
||||
ivHandCardHorizontal.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
// set card z position
|
||||
when (antenna.z) {
|
||||
DeviceNFCAntennaLocation.CARD_ON_BACK -> llHand.elevation = 0.0f
|
||||
DeviceNFCAntennaLocation.CARD_ON_FRONT -> llHand.elevation = 30.0f
|
||||
}
|
||||
|
||||
animate()
|
||||
}
|
||||
|
||||
public override fun onResume() {
|
||||
|
|
@ -114,6 +148,8 @@ class PurgeActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoc
|
|||
}
|
||||
|
||||
override fun onReadStart(cardProtocol: CardProtocol) {
|
||||
rlProgressBar.post { rlProgressBar.visibility = View.VISIBLE }
|
||||
|
||||
progressBar.post {
|
||||
progressBar.visibility = View.VISIBLE
|
||||
progressBar.progress = 5
|
||||
|
|
@ -125,26 +161,33 @@ class PurgeActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoc
|
|||
|
||||
if (cardProtocol != null) {
|
||||
if (cardProtocol.error == null) {
|
||||
progressBar!!.post {
|
||||
progressBar!!.progress = 100
|
||||
progressBar!!.progressTintList = ColorStateList.valueOf(Color.GREEN)
|
||||
rlProgressBar.post { rlProgressBar.visibility = View.GONE }
|
||||
|
||||
progressBar?.post {
|
||||
progressBar?.progress = 100
|
||||
progressBar?.progressTintList = ColorStateList.valueOf(Color.GREEN)
|
||||
|
||||
val intent = Intent()
|
||||
intent.putExtra("UID", cardProtocol.card.uid)
|
||||
intent.putExtra("Card", cardProtocol.card.asBundle)
|
||||
setResult(Activity.RESULT_OK, intent)
|
||||
|
||||
EventBus.getDefault().post(DeletingWalletFinish())
|
||||
|
||||
finish()
|
||||
}
|
||||
} else {
|
||||
if (cardProtocol.error is CardProtocol.TangemException_InvalidPIN) {
|
||||
progressBar!!.post {
|
||||
progressBar!!.progress = 100
|
||||
progressBar!!.progressTintList = ColorStateList.valueOf(Color.RED)
|
||||
progressBar?.post {
|
||||
progressBar?.progress = 100
|
||||
progressBar?.progressTintList = ColorStateList.valueOf(Color.RED)
|
||||
}
|
||||
progressBar!!.postDelayed({
|
||||
progressBar?.postDelayed({
|
||||
try {
|
||||
progressBar!!.progress = 0
|
||||
progressBar!!.progressTintList = ColorStateList.valueOf(Color.DKGRAY)
|
||||
progressBar!!.visibility = View.INVISIBLE
|
||||
progressBar?.progress = 0
|
||||
progressBar?.progressTintList = ColorStateList.valueOf(Color.DKGRAY)
|
||||
progressBar?.visibility = View.INVISIBLE
|
||||
|
||||
val intent = Intent()
|
||||
intent.putExtra("UID", cardProtocol.card.uid)
|
||||
intent.putExtra("Card", cardProtocol.card.asBundle)
|
||||
|
|
@ -170,11 +213,19 @@ class PurgeActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoc
|
|||
}
|
||||
}
|
||||
|
||||
progressBar!!.postDelayed({
|
||||
rlProgressBar?.postDelayed({
|
||||
try {
|
||||
progressBar!!.progress = 0
|
||||
progressBar!!.progressTintList = ColorStateList.valueOf(Color.DKGRAY)
|
||||
progressBar!!.visibility = View.INVISIBLE
|
||||
rlProgressBar.visibility = View.GONE
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}, 500)
|
||||
|
||||
progressBar?.postDelayed({
|
||||
try {
|
||||
progressBar?.progress = 0
|
||||
progressBar?.progressTintList = ColorStateList.valueOf(Color.DKGRAY)
|
||||
progressBar?.visibility = View.INVISIBLE
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
|
@ -182,20 +233,40 @@ class PurgeActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoc
|
|||
}
|
||||
|
||||
override fun onReadProgress(protocol: CardProtocol, progress: Int) {
|
||||
progressBar!!.post { progressBar!!.progress = progress }
|
||||
progressBar?.post { progressBar?.progress = progress }
|
||||
}
|
||||
|
||||
override fun onReadCancel() {
|
||||
purgeTask = null
|
||||
progressBar!!.postDelayed({
|
||||
progressBar?.postDelayed({
|
||||
try {
|
||||
progressBar!!.progress = 0
|
||||
progressBar!!.progressTintList = ColorStateList.valueOf(Color.DKGRAY)
|
||||
progressBar!!.visibility = View.INVISIBLE
|
||||
progressBar?.progress = 0
|
||||
progressBar?.progressTintList = ColorStateList.valueOf(Color.DKGRAY)
|
||||
progressBar?.visibility = View.INVISIBLE
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}, 500)
|
||||
}
|
||||
|
||||
private fun animate() {
|
||||
val lp = llHand.layoutParams as RelativeLayout.LayoutParams
|
||||
val lp2 = llNfc.layoutParams as RelativeLayout.LayoutParams
|
||||
val dp = resources.displayMetrics.density
|
||||
val lm = dp * (69 + antenna.x * 75)
|
||||
lp.topMargin = (dp * (-100 + antenna.y * 250)).toInt()
|
||||
lp2.topMargin = (dp * (-125 + antenna.y * 250)).toInt()
|
||||
llNfc.layoutParams = lp2
|
||||
|
||||
val a = object : Animation() {
|
||||
override fun applyTransformation(interpolatedTime: Float, t: Transformation) {
|
||||
lp.leftMargin = (lm * interpolatedTime).toInt()
|
||||
llHand.layoutParams = lp
|
||||
}
|
||||
}
|
||||
a.duration = 2000
|
||||
a.interpolator = DecelerateInterpolator()
|
||||
llHand.startAnimation(a)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -6,8 +6,8 @@ import android.content.Context
|
|||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Bundle
|
||||
import android.support.v4.app.ActivityCompat
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.google.zxing.Result
|
||||
import com.tangem.Constant
|
||||
import me.dm7.barcodescanner.zxing.ZXingScannerView
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import android.content.Intent
|
|||
import android.nfc.NfcAdapter
|
||||
import android.nfc.Tag
|
||||
import android.os.Bundle
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.view.KeyEvent
|
||||
import android.widget.Toast
|
||||
import com.tangem.Constant
|
||||
|
|
@ -43,7 +43,7 @@ class SendTransactionActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
if (success)
|
||||
finishWithSuccess()
|
||||
else
|
||||
finishWithError(this@SendTransactionActivity.getString(R.string.try_again_failed_to_send_transaction))
|
||||
finishWithError(ctx.error)
|
||||
}
|
||||
|
||||
override fun onProgress() {
|
||||
|
|
|
|||
|
|
@ -8,10 +8,14 @@ import android.nfc.NfcAdapter
|
|||
import android.nfc.Tag
|
||||
import android.nfc.tech.IsoDep
|
||||
import android.os.Bundle
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.view.KeyEvent
|
||||
import android.view.View
|
||||
import android.view.animation.Animation
|
||||
import android.view.animation.DecelerateInterpolator
|
||||
import android.view.animation.Transformation
|
||||
import android.widget.ProgressBar
|
||||
import android.widget.RelativeLayout
|
||||
import android.widget.Toast
|
||||
import com.tangem.App
|
||||
import com.tangem.Constant
|
||||
|
|
@ -20,6 +24,7 @@ import com.tangem.domain.wallet.CoinEngineFactory
|
|||
import com.tangem.domain.wallet.TangemContext
|
||||
import com.tangem.presentation.dialog.NoExtendedLengthSupportDialog
|
||||
import com.tangem.presentation.dialog.WaitSecurityDelayDialog
|
||||
import com.tangem.tangemcard.android.nfc.DeviceNFCAntennaLocation
|
||||
import com.tangem.tangemcard.android.reader.NfcManager
|
||||
import com.tangem.tangemcard.android.reader.NfcReader
|
||||
import com.tangem.tangemcard.data.asBundle
|
||||
|
|
@ -28,18 +33,21 @@ import com.tangem.tangemcard.tasks.SignTask
|
|||
import com.tangem.tangemcard.util.Util
|
||||
import com.tangem.util.LOG
|
||||
import com.tangem.wallet.R
|
||||
import kotlinx.android.synthetic.main.activity_sign_payment.*
|
||||
import kotlinx.android.synthetic.main.activity_sign_transaction.*
|
||||
import kotlinx.android.synthetic.main.layout_touch_card.*
|
||||
|
||||
class SignPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtocol.Notifications {
|
||||
class SignTransactionActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtocol.Notifications {
|
||||
|
||||
companion object {
|
||||
val TAG: String = SignPaymentActivity::class.java.simpleName
|
||||
val TAG: String = SignTransactionActivity::class.java.simpleName
|
||||
}
|
||||
|
||||
private lateinit var nfcManager: NfcManager
|
||||
private lateinit var ctx: TangemContext
|
||||
|
||||
private var signPaymentTask: SignTask? = null
|
||||
private lateinit var antenna: DeviceNFCAntennaLocation
|
||||
|
||||
private var signTransactionTask: SignTask? = null
|
||||
|
||||
private lateinit var amount: CoinEngine.Amount
|
||||
private lateinit var fee: CoinEngine.Amount
|
||||
|
|
@ -51,7 +59,7 @@ class SignPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Card
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_sign_payment)
|
||||
setContentView(R.layout.activity_sign_transaction)
|
||||
|
||||
nfcManager = NfcManager(this, this)
|
||||
|
||||
|
|
@ -67,6 +75,31 @@ class SignPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Card
|
|||
progressBar = findViewById(R.id.progressBar)
|
||||
progressBar!!.progressTintList = ColorStateList.valueOf(Color.DKGRAY)
|
||||
progressBar!!.visibility = View.INVISIBLE
|
||||
|
||||
// get NFC Antenna
|
||||
antenna = DeviceNFCAntennaLocation()
|
||||
antenna.getAntennaLocation()
|
||||
|
||||
// set card orientation
|
||||
when (antenna.orientation) {
|
||||
DeviceNFCAntennaLocation.CARD_ORIENTATION_HORIZONTAL -> {
|
||||
ivHandCardHorizontal.visibility = View.VISIBLE
|
||||
ivHandCardVertical.visibility = View.GONE
|
||||
}
|
||||
|
||||
DeviceNFCAntennaLocation.CARD_ORIENTATION_VERTICAL -> {
|
||||
ivHandCardVertical.visibility = View.VISIBLE
|
||||
ivHandCardHorizontal.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
// set card z position
|
||||
when (antenna.z) {
|
||||
DeviceNFCAntennaLocation.CARD_ON_BACK -> llHand.elevation = 0.0f
|
||||
DeviceNFCAntennaLocation.CARD_ON_FRONT -> llHand.elevation = 30.0f
|
||||
}
|
||||
|
||||
animate()
|
||||
}
|
||||
|
||||
public override fun onResume() {
|
||||
|
|
@ -76,21 +109,21 @@ class SignPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Card
|
|||
|
||||
public override fun onPause() {
|
||||
nfcManager.onPause()
|
||||
if (signPaymentTask != null)
|
||||
signPaymentTask!!.cancel(true)
|
||||
if (signTransactionTask != null)
|
||||
signTransactionTask!!.cancel(true)
|
||||
super.onPause()
|
||||
}
|
||||
|
||||
public override fun onStop() {
|
||||
// dismiss enable NFC dialog
|
||||
nfcManager.onStop()
|
||||
if (signPaymentTask != null)
|
||||
signPaymentTask!!.cancel(true)
|
||||
if (signTransactionTask != null)
|
||||
signTransactionTask!!.cancel(true)
|
||||
super.onStop()
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
if (requestCode == Constant.REQUEST_CODE_SEND_PAYMENT_) {
|
||||
if (requestCode == Constant.REQUEST_CODE_SEND_TRANSACTION_) {
|
||||
setResult(resultCode, data)
|
||||
finish()
|
||||
return
|
||||
|
|
@ -127,18 +160,18 @@ class SignPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Card
|
|||
|
||||
val coinEngine = CoinEngineFactory.create(ctx)
|
||||
?: throw CardProtocol.TangemException("Can't create CoinEngine!")
|
||||
coinEngine.setOnNeedSendPayment { tx ->
|
||||
coinEngine.setOnNeedSendTransaction { tx ->
|
||||
if (tx != null) {
|
||||
val intent = Intent(this, SendTransactionActivity::class.java)
|
||||
ctx.saveToIntent(intent)
|
||||
intent.putExtra(Constant.EXTRA_TX, tx)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_SEND_PAYMENT_)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_SEND_TRANSACTION_)
|
||||
}
|
||||
}
|
||||
val paymentToSign = coinEngine.constructPayment(amount, fee, isIncludeFee, outAddressStr)
|
||||
val transactionToSign = coinEngine.constructTransaction(amount, fee, isIncludeFee, outAddressStr)
|
||||
|
||||
signPaymentTask = SignTask(ctx.card, NfcReader(nfcManager, isoDep), App.localStorage, App.pinStorage, this, paymentToSign)
|
||||
signPaymentTask!!.start()
|
||||
signTransactionTask = SignTask(ctx.card, NfcReader(nfcManager, isoDep), App.localStorage, App.pinStorage, this, transactionToSign)
|
||||
signTransactionTask!!.start()
|
||||
} else
|
||||
nfcManager.ignoreTag(isoDep.tag)
|
||||
|
||||
|
|
@ -159,6 +192,8 @@ class SignPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Card
|
|||
}
|
||||
|
||||
override fun onReadStart(cardProtocol: CardProtocol) {
|
||||
rlProgressBar.post { rlProgressBar.visibility = View.VISIBLE }
|
||||
|
||||
progressBar!!.post {
|
||||
progressBar!!.visibility = View.VISIBLE
|
||||
progressBar!!.progress = 5
|
||||
|
|
@ -170,9 +205,11 @@ class SignPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Card
|
|||
}
|
||||
|
||||
override fun onReadFinish(cardProtocol: CardProtocol?) {
|
||||
signPaymentTask = null
|
||||
signTransactionTask = null
|
||||
if (cardProtocol != null) {
|
||||
if (cardProtocol.error == null) {
|
||||
rlProgressBar.post { rlProgressBar.visibility = View.GONE }
|
||||
|
||||
progressBar!!.post {
|
||||
progressBar!!.progress = 100
|
||||
progressBar!!.progressTintList = ColorStateList.valueOf(Color.GREEN)
|
||||
|
|
@ -228,6 +265,14 @@ class SignPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Card
|
|||
}
|
||||
}
|
||||
|
||||
rlProgressBar.postDelayed({
|
||||
try {
|
||||
rlProgressBar.visibility = View.GONE
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}, 500)
|
||||
|
||||
progressBar!!.postDelayed({
|
||||
try {
|
||||
progressBar!!.progress = 0
|
||||
|
|
@ -240,7 +285,7 @@ class SignPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Card
|
|||
}
|
||||
|
||||
override fun onReadCancel() {
|
||||
signPaymentTask = null
|
||||
signTransactionTask = null
|
||||
|
||||
progressBar!!.postDelayed({
|
||||
try {
|
||||
|
|
@ -289,5 +334,25 @@ class SignPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Card
|
|||
|
||||
}
|
||||
|
||||
private fun animate() {
|
||||
val lp = llHand.layoutParams as RelativeLayout.LayoutParams
|
||||
val lp2 = llNfc.layoutParams as RelativeLayout.LayoutParams
|
||||
val dp = resources.displayMetrics.density
|
||||
val lm = dp * (69 + antenna.x * 75)
|
||||
lp.topMargin = (dp * (-100 + antenna.y * 250)).toInt()
|
||||
lp2.topMargin = (dp * (-125 + antenna.y * 250)).toInt()
|
||||
llNfc.layoutParams = lp2
|
||||
|
||||
val a = object : Animation() {
|
||||
override fun applyTransformation(interpolatedTime: Float, t: Transformation) {
|
||||
lp.leftMargin = (lm * interpolatedTime).toInt()
|
||||
llHand.layoutParams = lp
|
||||
}
|
||||
}
|
||||
a.duration = 2000
|
||||
a.interpolator = DecelerateInterpolator()
|
||||
llHand.startAnimation(a)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@ package com.tangem.presentation.activity
|
|||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.tangem.App
|
||||
import com.tangem.Constant
|
||||
import com.tangem.di.Navigator
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package com.tangem.presentation.dialog
|
|||
import android.app.AlertDialog
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import android.support.v4.app.DialogFragment
|
||||
import androidx.fragment.app.DialogFragment
|
||||
|
||||
import com.tangem.wallet.R
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import android.app.AlertDialog;
|
|||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
|
||||
import com.tangem.wallet.R;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package com.tangem.presentation.dialog
|
|||
import android.app.AlertDialog
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import android.support.v4.app.DialogFragment
|
||||
import androidx.fragment.app.DialogFragment
|
||||
|
||||
import com.tangem.wallet.R
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package com.tangem.presentation.dialog;
|
|||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
|
|
@ -16,6 +15,9 @@ import android.widget.TextView;
|
|||
import com.tangem.util.UtilHelper;
|
||||
import com.tangem.wallet.R;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
|
||||
/**
|
||||
* Created by dvol on 06.03.2018.
|
||||
*/
|
||||
|
|
@ -66,11 +68,11 @@ public class ShowQRCodeDialog extends DialogFragment {
|
|||
}
|
||||
}
|
||||
|
||||
public static void show(final Activity activity, final String content) {
|
||||
public static void show(final AppCompatActivity activity, final String content) {
|
||||
activity.runOnUiThread(() -> {
|
||||
ShowQRCodeDialog instance = new ShowQRCodeDialog();
|
||||
instance.setup(content);
|
||||
instance.show(activity.getFragmentManager(), "ShowQRCodeDialog");
|
||||
instance.show(activity.getSupportFragmentManager(), "ShowQRCodeDialog");
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package com.tangem.presentation.dialog;
|
|||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
|
|
@ -15,6 +15,9 @@ import com.tangem.wallet.R;
|
|||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
|
||||
/**
|
||||
* Created by dvol on 06.03.2018.
|
||||
*/
|
||||
|
|
@ -101,14 +104,15 @@ public class WaitSecurityDelayDialog extends DialogFragment {
|
|||
// return instance;
|
||||
// }
|
||||
|
||||
private final static int MinRemainingDelayToShowDialog=1000;
|
||||
private final static int DelayBeforeShowDialog=5000;
|
||||
private final static int MinRemainingDelayToShowDialog = 1000;
|
||||
private final static int DelayBeforeShowDialog = 5000;
|
||||
|
||||
public static void onReadBeforeRequest(final Activity activity, final int timeout) {
|
||||
public static void onReadBeforeRequest(final AppCompatActivity activity, final int timeout) {
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (timerToShowDelayDialog != null || timeout < DelayBeforeShowDialog+MinRemainingDelayToShowDialog) return;
|
||||
if (timerToShowDelayDialog != null || timeout < DelayBeforeShowDialog + MinRemainingDelayToShowDialog)
|
||||
return;
|
||||
timerToShowDelayDialog = new Timer();
|
||||
timerToShowDelayDialog.schedule(new TimerTask() {
|
||||
@Override
|
||||
|
|
@ -117,7 +121,7 @@ public class WaitSecurityDelayDialog extends DialogFragment {
|
|||
instance = new WaitSecurityDelayDialog();
|
||||
instance.setup(timeout, DelayBeforeShowDialog);
|
||||
instance.setCancelable(false);
|
||||
instance.show(activity.getFragmentManager(), "WaitSecurityDelayDialog");
|
||||
instance.show(activity.getSupportFragmentManager(), "WaitSecurityDelayDialog");
|
||||
}
|
||||
}, DelayBeforeShowDialog);
|
||||
}
|
||||
|
|
@ -135,7 +139,7 @@ public class WaitSecurityDelayDialog extends DialogFragment {
|
|||
});
|
||||
}
|
||||
|
||||
public static void onReadWait(final Activity activity, final int msec) {
|
||||
public static void onReadWait(final AppCompatActivity activity, final int msec) {
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
|
@ -146,18 +150,19 @@ public class WaitSecurityDelayDialog extends DialogFragment {
|
|||
|
||||
if (msec == 0) {
|
||||
if (instance != null) {
|
||||
//TODO remove onNext java.lang.IllegalStateException: Fragment WaitSecurityDelayDialog{ba2c429 (2368a785-523e-4c3d-b46a-402d2c4f102b)} not associated with a fragment manager.
|
||||
instance.dismiss();
|
||||
instance = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (instance == null) {
|
||||
if( msec>MinRemainingDelayToShowDialog ) {
|
||||
if (msec > MinRemainingDelayToShowDialog) {
|
||||
instance = new WaitSecurityDelayDialog();
|
||||
// 1000ms - card delay notification interval
|
||||
instance.setup(msec + 1000, 1000);
|
||||
instance.setCancelable(false);
|
||||
instance.show(activity.getFragmentManager(), "WaitSecurityDelayDialog");
|
||||
instance.show(activity.getSupportFragmentManager(), "WaitSecurityDelayDialog");
|
||||
}
|
||||
} else {
|
||||
instance.setRemainingTimeout(msec);
|
||||
|
|
|
|||
|
|
@ -4,13 +4,11 @@ import android.annotation.SuppressLint
|
|||
import android.app.AlertDialog
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import android.support.v7.app.AppCompatDialogFragment
|
||||
import androidx.appcompat.app.AppCompatDialogFragment
|
||||
import android.widget.ProgressBar
|
||||
import com.tangem.presentation.activity.SignPaymentActivity
|
||||
import com.tangem.presentation.event.ReadAfterRequest
|
||||
import com.tangem.presentation.event.ReadBeforeRequest
|
||||
import com.tangem.presentation.event.ReadWait
|
||||
import com.tangem.presentation.event.TransactionFinishWithSuccess
|
||||
import com.tangem.util.LOG
|
||||
import com.tangem.wallet.R
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
|
|
@ -84,8 +82,11 @@ class WaitSecurityDelayDialogNew : AppCompatDialogFragment() {
|
|||
override fun run() {
|
||||
setup(readBeforeRequest.timeout!!, DELAY_BEFORE_SHOW_DIALOG)
|
||||
isCancelable = false
|
||||
if (!isAdded)
|
||||
show(activity?.supportFragmentManager, TAG)
|
||||
|
||||
|
||||
|
||||
// if (!isAdded)
|
||||
// show(activity?.supportFragmentManager, TAG)
|
||||
}
|
||||
}, DELAY_BEFORE_SHOW_DIALOG.toLong())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
package com.tangem.presentation.event
|
||||
|
||||
class DeletingWalletFinish
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
package com.tangem.presentation.event
|
||||
|
||||
class ReadAfterRequest {
|
||||
}
|
||||
class ReadAfterRequest
|
||||
|
|
@ -10,14 +10,14 @@ import android.nfc.NfcAdapter
|
|||
import android.nfc.Tag
|
||||
import android.nfc.tech.IsoDep
|
||||
import android.os.Bundle
|
||||
import android.support.v4.app.Fragment
|
||||
import android.support.v4.content.ContextCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import android.text.Html
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.tangem.App
|
||||
import com.tangem.Constant
|
||||
import com.tangem.data.Blockchain
|
||||
|
|
@ -34,6 +34,7 @@ import com.tangem.presentation.dialog.NoExtendedLengthSupportDialog
|
|||
import com.tangem.presentation.dialog.PINSwapWarningDialog
|
||||
import com.tangem.presentation.dialog.ShowQRCodeDialog
|
||||
import com.tangem.presentation.dialog.WaitSecurityDelayDialog
|
||||
import com.tangem.presentation.event.DeletingWalletFinish
|
||||
import com.tangem.presentation.event.TransactionFinishWithError
|
||||
import com.tangem.presentation.event.TransactionFinishWithSuccess
|
||||
import com.tangem.tangemcard.android.reader.NfcManager
|
||||
|
|
@ -51,13 +52,15 @@ import com.tangem.util.LOG
|
|||
import com.tangem.util.UtilHelper
|
||||
import com.tangem.wallet.R
|
||||
import kotlinx.android.synthetic.main.fr_loaded_wallet.*
|
||||
import kotlinx.android.synthetic.main.layout_btn_details.*
|
||||
import kotlinx.android.synthetic.main.layout_tangem_card.*
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import java.io.InputStream
|
||||
import java.util.*
|
||||
import kotlin.concurrent.timerTask
|
||||
|
||||
class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notifications, SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
class LoadedWallet : androidx.fragment.app.Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notifications, SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
companion object {
|
||||
val TAG: String = LoadedWallet::class.java.simpleName
|
||||
}
|
||||
|
|
@ -90,6 +93,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
//updateViews()
|
||||
} else if (srl != null && !srl.isRefreshing) srl.isRefreshing = true
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
nfcManager = NfcManager(activity, this)
|
||||
|
|
@ -123,7 +127,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
|
||||
btnExplore.setOnClickListener {
|
||||
val engine = CoinEngineFactory.create(ctx)
|
||||
startActivity(Intent(Intent.ACTION_VIEW, engine?.shareWalletUriExplorer))
|
||||
startActivity(Intent(Intent.ACTION_VIEW, engine?.walletExplorerUri))
|
||||
}
|
||||
btnCopy.setOnClickListener { doShareWallet(false) }
|
||||
|
||||
|
|
@ -150,19 +154,19 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
|
||||
getString(R.string.load_via_qr) -> {
|
||||
val engine = CoinEngineFactory.create(ctx)
|
||||
ShowQRCodeDialog.show(activity, engine!!.shareWalletUri.toString())
|
||||
ShowQRCodeDialog.show(activity as AppCompatActivity?, engine!!.shareWalletUri.toString())
|
||||
}
|
||||
|
||||
getString(R.string.via_cryptonit) -> {
|
||||
val intent = Intent(activity, PrepareCryptonitWithdrawalActivity::class.java)
|
||||
ctx.saveToIntent(intent)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_RECEIVE_PAYMENT)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_RECEIVE_TRANSACTION)
|
||||
}
|
||||
|
||||
getString(R.string.via_kraken) -> {
|
||||
val intent = Intent(activity, PrepareKrakenWithdrawalActivity::class.java)
|
||||
ctx.saveToIntent(intent)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_RECEIVE_PAYMENT)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_RECEIVE_TRANSACTION)
|
||||
}
|
||||
else -> {
|
||||
}
|
||||
|
|
@ -182,7 +186,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
else if (ctx.card!!.remainingSignatures == 0)
|
||||
UtilHelper.showSingleToast(context, getString(R.string.card_has_no_remaining_signature))
|
||||
else
|
||||
(activity as LoadedWalletActivity).navigator.showPreparePayment(context as Activity, ctx)
|
||||
(activity as LoadedWalletActivity).navigator.showPrepareTransaction(context as Activity, ctx)
|
||||
else
|
||||
Toast.makeText(activity, getString(R.string.no_connection), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
|
@ -258,8 +262,8 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
serverApiTangem.setArtworkListener(artworkListener)
|
||||
|
||||
// request rate info listener
|
||||
serverApiCommon.setRateInfoData {
|
||||
if (activity == null || !UtilHelper.isOnline(activity!!)) return@setRateInfoData
|
||||
serverApiCommon.setRateInfoListener {
|
||||
if (activity == null || !UtilHelper.isOnline(activity!!)) return@setRateInfoListener
|
||||
val rate = it.priceUsd.toFloat()
|
||||
ctx.coinData!!.rate = rate
|
||||
ctx.coinData!!.rateAlter = rate
|
||||
|
|
@ -305,7 +309,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
ctx.message = transactionFinishWithSuccess.message
|
||||
ctx.coinData.clearInfo()
|
||||
updateViews()
|
||||
srl?.isRefreshing=true
|
||||
srl?.isRefreshing = true
|
||||
srl?.postDelayed({ refresh() }, 5000)
|
||||
}
|
||||
|
||||
|
|
@ -315,6 +319,11 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
updateViews()
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
fun onDeleteWalletFinish(deletingWalletFinish: DeletingWalletFinish) {
|
||||
activity?.finish()
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
when (requestCode) {
|
||||
|
|
@ -353,7 +362,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
else
|
||||
bundle.putString(PINSwapWarningDialog.EXTRA_MESSAGE, getString(R.string.if_you_use_default))
|
||||
pinSwapWarningDialog.arguments = bundle
|
||||
pinSwapWarningDialog.show(activity?.supportFragmentManager, PINSwapWarningDialog.TAG)
|
||||
activity?.supportFragmentManager?.let { pinSwapWarningDialog.show(it, PINSwapWarningDialog.TAG) }
|
||||
}
|
||||
|
||||
Constant.REQUEST_CODE_SWAP_PIN -> if (resultCode == Activity.RESULT_OK) {
|
||||
|
|
@ -416,7 +425,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
updateViews()
|
||||
}
|
||||
|
||||
Constant.REQUEST_CODE_SEND_PAYMENT, Constant.REQUEST_CODE_RECEIVE_PAYMENT -> {
|
||||
Constant.REQUEST_CODE_SEND_TRANSACTION, Constant.REQUEST_CODE_RECEIVE_TRANSACTION -> {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
ctx.coinData?.clearInfo()
|
||||
srl?.postDelayed({ this.refresh() }, 5000)
|
||||
|
|
@ -448,8 +457,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
}
|
||||
|
||||
override fun onReadStart(cardProtocol: CardProtocol) {
|
||||
if (rlProgressBar != null)
|
||||
rlProgressBar.post { rlProgressBar.visibility = View.VISIBLE }
|
||||
rlProgressBar?.post { rlProgressBar.visibility = View.VISIBLE }
|
||||
}
|
||||
|
||||
override fun onReadProgress(protocol: CardProtocol, progress: Int) {
|
||||
|
|
@ -472,7 +480,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
lastReadSuccess = false
|
||||
if (cardProtocol.error is CardProtocol.TangemException_ExtendedLengthNotSupported)
|
||||
if (!NoExtendedLengthSupportDialog.allReadyShowed)
|
||||
NoExtendedLengthSupportDialog().show(activity?.supportFragmentManager, NoExtendedLengthSupportDialog.TAG)
|
||||
activity?.supportFragmentManager?.let { NoExtendedLengthSupportDialog().show(it, NoExtendedLengthSupportDialog.TAG) }
|
||||
else
|
||||
Toast.makeText(activity, R.string.try_to_scan_again, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
|
@ -500,11 +508,11 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
}
|
||||
|
||||
override fun onReadWait(msec: Int) {
|
||||
WaitSecurityDelayDialog.onReadWait(activity, msec)
|
||||
WaitSecurityDelayDialog.onReadWait(activity as AppCompatActivity?, msec)
|
||||
}
|
||||
|
||||
override fun onReadBeforeRequest(timeout: Int) {
|
||||
WaitSecurityDelayDialog.onReadBeforeRequest(activity, timeout)
|
||||
WaitSecurityDelayDialog.onReadBeforeRequest(activity as AppCompatActivity?, timeout)
|
||||
}
|
||||
|
||||
override fun onReadAfterRequest() {
|
||||
|
|
@ -632,8 +640,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
|
||||
requestRateInfo()
|
||||
|
||||
if( requestCounter==0 )
|
||||
{
|
||||
if (requestCounter == 0) {
|
||||
// if no connection and no requests posted
|
||||
srl?.isRefreshing = false
|
||||
updateViews()
|
||||
|
|
@ -647,7 +654,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
coinEngine!!.requestBalanceAndUnspentTransactions(
|
||||
object : CoinEngine.BlockchainRequestsCallbacks {
|
||||
override fun onComplete(success: Boolean) {
|
||||
LOG.i(TAG, "requestBalanceAndUnspentTransactions onComplete: " + success.toString() + ", request counter " + requestCounter.toString())
|
||||
LOG.i(TAG, "requestBalanceAndUnspentTransactions onComplete: $success, request counter $requestCounter")
|
||||
if (activity == null) return
|
||||
requestCounter--
|
||||
if (!success) {
|
||||
|
|
@ -666,7 +673,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
}
|
||||
|
||||
override fun allowAdvance(): Boolean {
|
||||
return UtilHelper.isOnline(context as Activity)
|
||||
return context?.let { UtilHelper.isOnline(it) }!!
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
@ -706,12 +713,12 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
Blockchain.BitcoinCash -> "bitcoin-cash"
|
||||
Blockchain.Litecoin -> "litecoin"
|
||||
Blockchain.Rootstock -> "bitcoin"
|
||||
Blockchain.RootstockToken ->"bitcoin"
|
||||
Blockchain.RootstockToken -> "bitcoin"
|
||||
else -> {
|
||||
throw Exception("Can''t get rate for blockchain " + ctx.blockchainName)
|
||||
}
|
||||
}
|
||||
serverApiCommon.rateInfoData(cryptoId)
|
||||
serverApiCommon.requestRateInfo(cryptoId)
|
||||
} else {
|
||||
ctx.error = getString(R.string.no_connection)
|
||||
updateViews()
|
||||
|
|
|
|||
|
|
@ -5,8 +5,7 @@ import android.content.Intent
|
|||
import android.nfc.NfcAdapter
|
||||
import android.nfc.Tag
|
||||
import android.os.Bundle
|
||||
import android.support.v4.app.Fragment
|
||||
import android.support.v4.content.ContextCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import android.text.Html
|
||||
import android.text.format.DateUtils
|
||||
import android.view.LayoutInflater
|
||||
|
|
@ -21,24 +20,27 @@ import com.tangem.domain.wallet.CoinEngineFactory
|
|||
import com.tangem.domain.wallet.TangemContext
|
||||
import com.tangem.presentation.activity.*
|
||||
import com.tangem.presentation.dialog.PINSwapWarningDialog
|
||||
import com.tangem.presentation.event.DeletingWalletFinish
|
||||
import com.tangem.tangemcard.android.data.PINStorage
|
||||
import com.tangem.tangemcard.android.reader.NfcManager
|
||||
import com.tangem.tangemcard.data.TangemCard
|
||||
import com.tangem.tangemcard.data.loadFromBundle
|
||||
import com.tangem.tangemcard.reader.CardProtocol
|
||||
import com.tangem.util.LOG
|
||||
import com.tangem.wallet.BuildConfig
|
||||
import com.tangem.wallet.R
|
||||
import kotlinx.android.synthetic.main.fr_verify_card.*
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import java.io.IOException
|
||||
import java.util.*
|
||||
|
||||
class VerifyCard : Fragment(), NfcAdapter.ReaderCallback {
|
||||
|
||||
class VerifyCard : androidx.fragment.app.Fragment(), NfcAdapter.ReaderCallback {
|
||||
companion object {
|
||||
val TAG: String = VerifyCard::class.java.simpleName
|
||||
}
|
||||
|
||||
private var nfcManager: NfcManager? = null
|
||||
private lateinit var nfcManager: NfcManager
|
||||
private lateinit var ctx: TangemContext
|
||||
|
||||
private var requestPIN2Count = 0
|
||||
|
|
@ -49,7 +51,6 @@ class VerifyCard : Fragment(), NfcAdapter.ReaderCallback {
|
|||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
nfcManager = NfcManager(activity, this)
|
||||
|
||||
ctx = TangemContext.loadFromBundle(activity, activity?.intent?.extras)
|
||||
}
|
||||
|
||||
|
|
@ -74,24 +75,25 @@ class VerifyCard : Fragment(), NfcAdapter.ReaderCallback {
|
|||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
nfcManager!!.onResume()
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
if (!EventBus.getDefault().isRegistered(this))
|
||||
EventBus.getDefault().register(this)
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
nfcManager!!.onPause()
|
||||
override fun onDestroy() {
|
||||
EventBus.getDefault().unregister(this)
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
nfcManager!!.onStop()
|
||||
@Subscribe
|
||||
fun onDeleteWalletFinish(deletingWalletFinish: DeletingWalletFinish) {
|
||||
activity?.finish()
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
// var data = data
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
LOG.i(TAG, "requestCode $requestCode resultCode $resultCode")
|
||||
when (requestCode) {
|
||||
Constant.REQUEST_CODE_ENTER_NEW_PIN -> if (resultCode == Activity.RESULT_OK) {
|
||||
if (data != null) {
|
||||
|
|
@ -109,6 +111,7 @@ class VerifyCard : Fragment(), NfcAdapter.ReaderCallback {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Constant.REQUEST_CODE_ENTER_NEW_PIN2 -> if (resultCode == Activity.RESULT_OK) {
|
||||
if (data != null) {
|
||||
if (data.extras!!.containsKey("confirmPIN2")) {
|
||||
|
|
@ -125,10 +128,11 @@ class VerifyCard : Fragment(), NfcAdapter.ReaderCallback {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Constant.REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN -> if (resultCode == Activity.RESULT_OK) {
|
||||
if (newPIN == "") newPIN = ctx.card!!.pin
|
||||
|
||||
if (newPIN2 == "") newPIN2 = App.pinStorage.getPIN2()
|
||||
if (newPIN2 == "") newPIN2 = App.pinStorage.piN2
|
||||
|
||||
val pinSwapWarningDialog = PINSwapWarningDialog()
|
||||
pinSwapWarningDialog.setOnRefreshPage { (activity as VerifyCardActivity).navigator.showPinSwap(context as Activity, newPIN, newPIN2) }
|
||||
|
|
@ -138,12 +142,11 @@ class VerifyCard : Fragment(), NfcAdapter.ReaderCallback {
|
|||
else
|
||||
bundle.putString(PINSwapWarningDialog.EXTRA_MESSAGE, getString(R.string.if_you_use_default))
|
||||
pinSwapWarningDialog.arguments = bundle
|
||||
pinSwapWarningDialog.show(activity?.supportFragmentManager, PINSwapWarningDialog.TAG)
|
||||
activity?.supportFragmentManager?.let { pinSwapWarningDialog.show(it, PINSwapWarningDialog.TAG) }
|
||||
}
|
||||
|
||||
Constant.REQUEST_CODE_SWAP_PIN -> if (resultCode == Activity.RESULT_OK) {
|
||||
if (data == null) {
|
||||
// data = Intent()
|
||||
ctx.saveToIntent(data)
|
||||
data?.putExtra("modification", "delete")
|
||||
} else
|
||||
|
|
@ -173,16 +176,18 @@ class VerifyCard : Fragment(), NfcAdapter.ReaderCallback {
|
|||
Constant.REQUEST_CODE_REQUEST_PIN2_FOR_PURGE -> if (resultCode == Activity.RESULT_OK)
|
||||
(activity as VerifyCardActivity).navigator.showPurge(context as Activity, ctx)
|
||||
|
||||
Constant.REQUEST_CODE_PURGE -> if (resultCode == Activity.RESULT_OK) {
|
||||
if (data == null) {
|
||||
ctx.saveToIntent(data)
|
||||
data?.putExtra(Constant.EXTRA_MODIFICATION, "delete")
|
||||
} else {
|
||||
data.putExtra(Constant.EXTRA_MODIFICATION, "update")
|
||||
}
|
||||
activity!!.setResult(Activity.RESULT_OK, data)
|
||||
activity!!.finish()
|
||||
} else {
|
||||
// Constant.REQUEST_CODE_PURGE -> if (resultCode == Activity.RESULT_OK) {
|
||||
// if (data == null) {
|
||||
// ctx.saveToIntent(data)
|
||||
// data?.putExtra(Constant.EXTRA_MODIFICATION, "delete")
|
||||
// } else
|
||||
// data.putExtra(Constant.EXTRA_MODIFICATION, "update")
|
||||
//
|
||||
// activity?.setResult(Activity.RESULT_OK, data)
|
||||
// activity?.finish()
|
||||
// }
|
||||
|
||||
else {
|
||||
if (data != null && data.extras!!.containsKey("UID") && data.extras!!.containsKey("Card")) {
|
||||
val updatedCard = TangemCard(data.getStringExtra("UID"))
|
||||
updatedCard.loadFromBundle(data.getBundleExtra("Card"))
|
||||
|
|
@ -205,9 +210,24 @@ class VerifyCard : Fragment(), NfcAdapter.ReaderCallback {
|
|||
}
|
||||
}
|
||||
|
||||
override fun onTagDiscovered(tag: Tag) {
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
nfcManager.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
nfcManager.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
nfcManager.onStop()
|
||||
}
|
||||
|
||||
override fun onTagDiscovered(tag: Tag?) {
|
||||
try {
|
||||
nfcManager!!.ignoreTag(tag)
|
||||
nfcManager.ignoreTag(tag)
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
|
@ -369,20 +389,6 @@ class VerifyCard : Fragment(), NfcAdapter.ReaderCallback {
|
|||
tvWallet!!.setText(R.string.not_available)
|
||||
tvWalletIdentity.setText(R.string.no_data_string)
|
||||
}
|
||||
|
||||
// timerHideErrorAndMessage = Timer()
|
||||
// timerHideErrorAndMessage!!.schedule(object : TimerTask() {
|
||||
// override fun run() {
|
||||
// tvError.post {
|
||||
// tvMessage!!.visibility = View.GONE
|
||||
// tvError!!.visibility = View.GONE
|
||||
// mCard!!.error = null
|
||||
// mCard!!.message = null
|
||||
// }
|
||||
// }
|
||||
// }, 5000)
|
||||
|
||||
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@
|
|||
*/
|
||||
package com.tangem.presentation.viewmodel
|
||||
|
||||
import android.arch.lifecycle.MutableLiveData
|
||||
import android.arch.lifecycle.ViewModel
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import com.tangem.data.network.exception.Failure
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package com.tangem.presentation.viewmodel
|
||||
|
||||
import android.arch.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.tangem.data.network.exception.Failure
|
||||
|
||||
class LoadedWalletViewModel : BaseViewModel() {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ package com.tangem.util;
|
|||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.support.annotation.WorkerThread;
|
||||
import androidx.annotation.WorkerThread;
|
||||
import android.text.TextUtils;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ object UtilHelper {
|
|||
return bmp
|
||||
}
|
||||
|
||||
fun isOnline(context: Activity): Boolean {
|
||||
fun isOnline(context: Context): Boolean {
|
||||
return try {
|
||||
val cm = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||
val netInfo: NetworkInfo?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue