Updated on 2026-08-14
This commit is contained in:
parent
68917838a4
commit
d1dc50123f
6 changed files with 62 additions and 69 deletions
|
|
@ -196,21 +196,7 @@ public class ServerApiHelper {
|
|||
}
|
||||
|
||||
public void cardVerifyAndGetInfo(TangemCard card) {
|
||||
|
||||
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
|
||||
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||
|
||||
OkHttpClient httpClient = new OkHttpClient.Builder().
|
||||
addInterceptor(logging).
|
||||
build();
|
||||
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
.baseUrl(Server.ApiTangem.URL_TANGEM)
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.client(httpClient)
|
||||
.build();
|
||||
|
||||
TangemApi tangemApi = retrofit.create(TangemApi.class);
|
||||
TangemApi tangemApi = App.getComponent().getRetrofitTangem().create(TangemApi.class);
|
||||
|
||||
List<CardVerifyAndGetInfo.Request.Item> requests = new ArrayList<>();
|
||||
requests.add(new CardVerifyAndGetInfo.Request.Item(Util.bytesToHex(card.getCID()), Util.bytesToHex(card.getCardPublicKey())));
|
||||
|
|
@ -251,19 +237,7 @@ public class ServerApiHelper {
|
|||
}
|
||||
|
||||
public void requestArtwork(String artworkId, Date updateDate, TangemCard card) {
|
||||
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
|
||||
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||
|
||||
OkHttpClient httpClient = new OkHttpClient.Builder().
|
||||
addInterceptor(logging).
|
||||
build();
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
.baseUrl(Server.ApiTangem.URL_TANGEM)
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.client(httpClient)
|
||||
.build();
|
||||
|
||||
TangemApi tangemApi = retrofit.create(TangemApi.class);
|
||||
TangemApi tangemApi = App.getComponent().getRetrofitTangem().create(TangemApi.class);
|
||||
|
||||
Call<ResponseBody> call = tangemApi.getArtwork(artworkId, Util.bytesToHex(card.getCID()), Util.bytesToHex(card.getCardPublicKey()));
|
||||
call.enqueue(new Callback<ResponseBody>() {
|
||||
|
|
@ -305,13 +279,7 @@ public class ServerApiHelper {
|
|||
|
||||
@SuppressLint("CheckResult")
|
||||
public void rateInfoData(String cryptoId) {
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
.baseUrl(Server.ApiCoinmarket.URL_COINMARKET)
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
|
||||
.build();
|
||||
|
||||
CoinmarketApi coinmarketApi = retrofit.create(CoinmarketApi.class);
|
||||
CoinmarketApi coinmarketApi = App.getComponent().getRetrofitCoinmarketcap().create(CoinmarketApi.class);
|
||||
|
||||
coinmarketApi.getRateInfoList()
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.tangem.di;
|
||||
|
||||
import com.tangem.data.network.Server;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
|
|
@ -10,9 +12,15 @@ import retrofit2.Retrofit;
|
|||
@Component(modules = {NetworkModule.class})
|
||||
public interface AppComponent {
|
||||
|
||||
@Named(NetworkModule.PROVIDE_RETROFIT_INFURA)
|
||||
@Named(Server.ApiInfura.URL_INFURA)
|
||||
Retrofit getRetrofitInfura();
|
||||
|
||||
@Named(NetworkModule.PROVIDE_RETROFIT_ESTIMATEFEE)
|
||||
@Named(Server.ApiEstimatefee.URL_ESTIMATEFEE)
|
||||
Retrofit getRetrofitEstimatefee();
|
||||
|
||||
@Named(Server.ApiTangem.URL_TANGEM)
|
||||
Retrofit getRetrofitTangem();
|
||||
|
||||
@Named(Server.ApiCoinmarket.URL_COINMARKET)
|
||||
Retrofit getRetrofitCoinmarketcap();
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package com.tangem.di;
|
||||
|
||||
import com.jakewharton.retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
|
||||
import com.tangem.data.network.Server;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
|
@ -7,18 +8,17 @@ import javax.inject.Singleton;
|
|||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.logging.HttpLoggingInterceptor;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
@Module
|
||||
class NetworkModule {
|
||||
|
||||
final static String PROVIDE_RETROFIT_INFURA = "provideRetrofitInfura";
|
||||
final static String PROVIDE_RETROFIT_ESTIMATEFEE = "provideRetrofitEstimatefee";
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
@Named(PROVIDE_RETROFIT_INFURA)
|
||||
@Named(Server.ApiInfura.URL_INFURA)
|
||||
Retrofit provideRetrofitInfura() {
|
||||
return new Retrofit.Builder()
|
||||
.baseUrl(Server.ApiInfura.URL_INFURA)
|
||||
|
|
@ -28,7 +28,7 @@ class NetworkModule {
|
|||
|
||||
@Singleton
|
||||
@Provides
|
||||
@Named(PROVIDE_RETROFIT_ESTIMATEFEE)
|
||||
@Named(Server.ApiEstimatefee.URL_ESTIMATEFEE)
|
||||
Retrofit provideRetrofitEstimatefee() {
|
||||
return new Retrofit.Builder()
|
||||
.baseUrl(Server.ApiEstimatefee.URL_ESTIMATEFEE)
|
||||
|
|
@ -36,4 +36,38 @@ class NetworkModule {
|
|||
.build();
|
||||
}
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
@Named(Server.ApiTangem.URL_TANGEM)
|
||||
Retrofit provideRetrofitTangem() {
|
||||
return new Retrofit.Builder()
|
||||
.baseUrl(Server.ApiTangem.URL_TANGEM)
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.client(createHttpClient())
|
||||
.build();
|
||||
}
|
||||
|
||||
private OkHttpClient createHttpClient() {
|
||||
return new OkHttpClient.Builder().
|
||||
addInterceptor(createLogging()).
|
||||
build();
|
||||
}
|
||||
|
||||
private HttpLoggingInterceptor createLogging() {
|
||||
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
|
||||
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||
return logging;
|
||||
}
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
@Named(Server.ApiCoinmarket.URL_COINMARKET)
|
||||
Retrofit provideRetrofitCoinmarketcap() {
|
||||
return new Retrofit.Builder()
|
||||
.baseUrl(Server.ApiCoinmarket.URL_COINMARKET)
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -19,7 +19,7 @@ import javax.crypto.Cipher;
|
|||
|
||||
public class PINStorage {
|
||||
private static String mSavedPIN, mUserPIN, mLastUsedPIN, mEncryptedPIN, mPIN2;
|
||||
private static SharedPreferences sharedPreferences=null;
|
||||
private static SharedPreferences sharedPreferences = null;
|
||||
|
||||
public static void Init(Context context) {
|
||||
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
|
@ -200,6 +200,7 @@ public class PINStorage {
|
|||
}
|
||||
|
||||
public static boolean needInit() {
|
||||
return sharedPreferences==null;
|
||||
return sharedPreferences == null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -122,16 +122,6 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
} else {
|
||||
rgFee!!.isEnabled = true
|
||||
|
||||
// val data = SharedData(SharedData.COUNT_REQUEST)
|
||||
// val engineCoin = CoinEngineFactory.create(card!!.blockchain)
|
||||
|
||||
// for (i in 0 until data.allRequest) {
|
||||
// val nodeAddress = engineCoin!!.getNode(card)
|
||||
// val nodePort = engineCoin.getNodePort(card)
|
||||
// val connectTaskEx = ConnectTask(this@ConfirmPaymentActivity, nodeAddress, nodePort, data)
|
||||
// connectTaskEx.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, ElectrumRequest.checkBalance(card!!.wallet))
|
||||
// }
|
||||
|
||||
requestElectrum(card!!, ElectrumRequest.checkBalance(card!!.wallet))
|
||||
|
||||
calcSize = 256
|
||||
|
|
@ -149,14 +139,6 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
serverApiHelper!!.estimateFee(ServerApiHelper.ESTIMATE_FEE_PRIORITY)
|
||||
serverApiHelper!!.estimateFee(ServerApiHelper.ESTIMATE_FEE_NORMAL)
|
||||
serverApiHelper!!.estimateFee(ServerApiHelper.ESTIMATE_FEE_MINIMAL)
|
||||
|
||||
// for (i in 0 until SharedData.COUNT_REQUEST) {
|
||||
// val feeTask = ConnectFeeTask(this@ConfirmPaymentActivity, sharedFee)
|
||||
// feeTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,
|
||||
// FeeRequest.GetFee(card!!.wallet, calcSize.toLong(), FeeRequest.NORMAL),
|
||||
// FeeRequest.GetFee(card!!.wallet, calcSize.toLong(), FeeRequest.MINIMAL),
|
||||
// FeeRequest.GetFee(card!!.wallet, calcSize.toLong(), FeeRequest.PRIORITY))
|
||||
// }
|
||||
}
|
||||
|
||||
// set listeners
|
||||
|
|
|
|||
|
|
@ -88,20 +88,19 @@ class PrepareKrakenWithdrawalActivity : AppCompatActivity(), NfcAdapter.ReaderCa
|
|||
}
|
||||
}
|
||||
|
||||
etAmount.setOnEditorActionListener{lv,actionId,event->
|
||||
etAmount.setOnEditorActionListener { lv, actionId, event ->
|
||||
if (actionId == EditorInfo.IME_ACTION_DONE) {
|
||||
val imm = lv.context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
imm.hideSoftInputFromWindow(lv.windowToken, 0)
|
||||
lv.clearFocus()
|
||||
true
|
||||
}else {
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
// set listeners
|
||||
btnLoad.setOnClickListener {
|
||||
|
||||
try {
|
||||
val strAmount: String = etAmount.text.toString().replace(",", ".")
|
||||
|
||||
|
|
@ -159,7 +158,7 @@ class PrepareKrakenWithdrawalActivity : AppCompatActivity(), NfcAdapter.ReaderCa
|
|||
tvError.visibility = View.VISIBLE
|
||||
tvError.text = Arrays.toString(response.error)
|
||||
} else {
|
||||
Toast.makeText(this,"Withdrawal successful!", Toast.LENGTH_LONG).show()
|
||||
Toast.makeText(this, "Withdrawal successful!", Toast.LENGTH_LONG).show()
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
|
@ -173,6 +172,7 @@ class PrepareKrakenWithdrawalActivity : AppCompatActivity(), NfcAdapter.ReaderCa
|
|||
showConfirmDialog()
|
||||
}
|
||||
}
|
||||
|
||||
btnLoad.visibility = View.INVISIBLE
|
||||
doRequestBalance()
|
||||
}
|
||||
|
|
@ -190,7 +190,7 @@ class PrepareKrakenWithdrawalActivity : AppCompatActivity(), NfcAdapter.ReaderCa
|
|||
builder.setTitle("Please confirm withdraw")
|
||||
|
||||
// Set a message for alert dialog
|
||||
builder.setMessage(String.format("Continue with fee %s %s?", fee!!.toString().trimEnd('0'),card!!.blockchain.currency))
|
||||
builder.setMessage(String.format("Continue with fee %s %s?", fee!!.toString().trimEnd('0'), card!!.blockchain.currency))
|
||||
|
||||
// On click listener for dialog buttons
|
||||
val dialogClickListener = DialogInterface.OnClickListener { _, which ->
|
||||
|
|
@ -201,7 +201,7 @@ class PrepareKrakenWithdrawalActivity : AppCompatActivity(), NfcAdapter.ReaderCa
|
|||
|
||||
var dblAmount: Double = strAmount.toDouble()
|
||||
|
||||
dblAmount+=fee!!.toDouble()
|
||||
dblAmount += fee!!.toDouble()
|
||||
|
||||
rlProgressBar.visibility = View.VISIBLE
|
||||
tvProgressDescription.text = getString(R.string.kraken_request_withdrawal)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue