Updated on 2026-08-14

This commit is contained in:
Tangem 2018-07-06 18:53:17 +03:00
parent b903dbb8f5
commit 41ffc78545
14 changed files with 73 additions and 137 deletions

View file

@ -7,21 +7,20 @@ import com.tangem.wallet.R;
* Created by dvol on 06.08.2017.
*/
public enum Blockchain {
Unknown("", "", 1.0, R.drawable.ic_logo_small, ""),
Bitcoin("BTC", "BTC", 100000000.0, R.drawable.bitcoins, "Bitcoin"),
BitcoinTestNet("BTC/test", "BTC", 100000000.0, R.drawable.bitcoins_testnet, "Bitcoin Testnet"),
Ethereum("ETH", "ETH", 1.0, R.drawable.ethereum, "Ethereum"),
EthereumTestNet("ETH/test", "ETH", 1.0, R.drawable.ethereum_testnet, "Ethereum Testnet"),
Token("ETH\\XTZ", "BAT", 1.0, R.drawable.bat_token, "Ethereum"),
BitcoinCash("BCH", "BCH", 100000000.0, R.drawable.bitcoin_cash, "Bitcoin Cash"),
BitcoinCashTestNet("BCH/test", "BTC", 100000000.0, R.drawable.bitcoin_cash, "Bitcoin Cash Testnet");
Unknown("", "", 1.0, R.drawable.ic_logo_unknown, ""),
Bitcoin("BTC", "BTC", 100000000.0, R.drawable.ic_logo_bitcoin, "Bitcoin"),
BitcoinTestNet("BTC/test", "BTC", 100000000.0, R.drawable.ic_logo_bitcoin_testnet, "Bitcoin Testnet"),
Ethereum("ETH", "ETH", 1.0, R.drawable.ic_logo_ethereum, "Ethereum"),
EthereumTestNet("ETH/test", "ETH", 1.0, R.drawable.ic_logo_ethereum_testnet, "Ethereum Testnet"),
Token("ETH\\XTZ", "BAT", 1.0, R.drawable.ic_logo_bat_token, "Ethereum"),
BitcoinCash("BCH", "BCH", 100000000.0, R.drawable.ic_logo_bitcoin_cash, "Bitcoin Cash"),
BitcoinCashTestNet("BCH/test", "BTC", 100000000.0, R.drawable.ic_logo_bitcoin_cash, "Bitcoin Cash Testnet");
Blockchain(String ID, String Currency, double Multiplier, int ImageResource, String officialName) {
Blockchain(String ID, String currency, double multiplier, int imageResource, String officialName) {
mID = ID;
mCurrency = Currency;
mMultiplier = Multiplier;
mImageResource = ImageResource;
mCurrency = currency;
mMultiplier = multiplier;
mImageResource = imageResource;
mOfficialName = officialName;
}
@ -68,7 +67,7 @@ public enum Blockchain {
return result;
}
public int getImageResource() {
private int getImageResource() {
return mImageResource;
}
@ -81,22 +80,25 @@ public enum Blockchain {
int resourceId = context.getResources().getIdentifier(name + "_token", "drawable", context.getPackageName());
if (resourceId <= 0)
return R.drawable.ethereum;
return R.drawable.ic_logo_ethereum;
return resourceId;
}
public int getLogoImageResource(String tokenSymbol) {
if (Strings.isNullOrEmpty(tokenSymbol))
return getImageResource();
public int getLogoImageResource(String blockchainID, String symbolName) {
switch (blockchainID) {
case "BTC":
return R.drawable.ic_logo_bitcoin;
switch (tokenSymbol) {
case "SEED":
return R.drawable.bitcoins;
case "SEEDq":
return R.drawable.bitcoins;
case "SEEDqq":
return R.drawable.bitcoins;
case "ETH\\XTZ":
if (symbolName.equals("SEED"))
return R.drawable.ic_logo_seed;
else
return R.drawable.ic_logo_ethereum;
case "ETH":
return R.drawable.ic_logo_ethereum;
}
return R.drawable.tangem2;
}
}

View file

@ -83,7 +83,6 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
private static final int REQUEST_CODE_SEND_PAYMENT = 1;
private static final int REQUEST_CODE_VERIFY_CARD = 4;
private static final int REQUEST_CODE_PURGE = 2;
private static final int REQUEST_CODE_REQUEST_PIN2_FOR_PURGE = 3;
private static final int REQUEST_CODE_ENTER_NEW_PIN = 5;
@ -91,39 +90,25 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
private static final int REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN = 7;
private static final int REQUEST_CODE_SWAP_PIN = 8;
private NfcManager mNfcManager;
private TangemCard mCard;
private TextView tvCardID;
private TextView tvBalance;
private TextView tvOffline;
private TextView tvBalanceEquivalent;
private TextView tvWallet;
private TextView tvInputs;
private TextView tvError;
private TextView tvMessage;
private TextView tvIssuer;
private TextView tvIssuerData;
private TextView tvBlockchain;
private TextView tvLastInput;
private TextView tvLastOutput;
private TextView lbLastOutput;
private TextView tvValidationNode;
private TextView tvHeader, tvCaution;
private Tag lastTag;
private SwipeRefreshLayout mSwipeRefreshLayout;
private RelativeLayout rlProgressBar;
private TextView tvCardID, tvBalance, tvOffline, tvBalanceEquivalent, tvWallet, tvInputs, tvError, tvMessage, tvIssuer, tvBlockchain, tvValidationNode, tvHeader, tvCaution;
private ProgressBar progressBar;
private ImageView ivBlockchain, ivPIN, ivPIN2orSecurityDelay, ivDeveloperVersion;
private SwipeRefreshLayout mSwipeRefreshLayout;
private AppCompatButton btnExtract;
private List<UpdateWalletInfoTask> updateTasks = new ArrayList<>();
private NfcManager mNfcManager;
private boolean lastReadSuccess = true;
private VerifyCardTask verifyCardTask = null;
private int requestPIN2Count = 0;
private Timer timerHideErrorAndMessage = null;
private String newPIN = "", newPIN2 = "";
private AppCompatButton btnExtract;
private FloatingActionButton fabInfo;
private Tag lastTag;
private ImageView ivTangemCard;
private RelativeLayout rlProgressBar;
private CardProtocol mCardProtocol;
private int scanTimes = 0;
public LoadedWallet() {
@ -242,7 +227,8 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
}
}
if (updateTasks.size() == 0) mSwipeRefreshLayout.setRefreshing(false);
if (updateTasks.size() == 0)
mSwipeRefreshLayout.setRefreshing(false);
}
}
@ -578,17 +564,15 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
mSwipeRefreshLayout = v.findViewById(R.id.swipe_container);
progressBar = v.findViewById(R.id.progressBar);
rlProgressBar = v.findViewById(R.id.rlProgressBar);
ivTangemCard = v.findViewById(R.id.ivTangemCard);
ImageView ivTangemCard = v.findViewById(R.id.ivTangemCard);
tvBalance = v.findViewById(R.id.tvBalance);
tvOffline = v.findViewById(R.id.tvOffline);
tvCardID = v.findViewById(R.id.tvCardID);
tvWallet = v.findViewById(R.id.tvWallet);
tvInputs = v.findViewById(R.id.tvInputs);
tvLastOutput = v.findViewById(R.id.tvLastOutput);
tvError = v.findViewById(R.id.tvError);
tvMessage = v.findViewById(R.id.tvMessage);
tvIssuer = v.findViewById(R.id.tvIssuer);
tvIssuerData = v.findViewById(R.id.tvIssuerData);
tvHeader = v.findViewById(R.id.tvHeader);
tvCaution = v.findViewById(R.id.tvCaution);
ImageView imgLookup = v.findViewById(R.id.imgLookup);
@ -600,7 +584,7 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
ivPIN2orSecurityDelay = v.findViewById(R.id.imgPIN2orSecurityDelay);
ivDeveloperVersion = v.findViewById(R.id.imgDeveloperVersion);
ImageView ivQR = v.findViewById(R.id.qrWallet);
fabInfo = v.findViewById(R.id.fabInfo);
FloatingActionButton fabInfo = v.findViewById(R.id.fabInfo);
FloatingActionButton fabNFC = v.findViewById(R.id.fabNFC);
AppCompatButton btnLoad = v.findViewById(R.id.btnLoad);
btnExtract = v.findViewById(R.id.btnExtract);
@ -632,6 +616,11 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
mSwipeRefreshLayout.postDelayed(this::onRefresh, 1000);
}
startVerify(lastTag);
tvWallet.setText(mCard.getWallet());
// set listeners
imgLookup.setOnClickListener(v15 -> {
if (!mCard.hasBalanceInfo()) return;
CoinEngine engineClick = CoinEngineFactory.Create(mCard.getBlockchain());
@ -653,7 +642,6 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
} catch (ActivityNotFoundException e) {
e.printStackTrace();
}
}
);
@ -666,7 +654,6 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
}
});
startVerify(lastTag);
fabNFC.setOnClickListener(view -> {
Intent intent = new Intent(getContext(), MainActivity.class);
@ -700,8 +687,6 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
startActivityForResult(intent, REQUEST_CODE_SEND_PAYMENT);
});
tvWallet.setText(mCard.getWallet());
return v;
}
@ -748,7 +733,7 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
case REQUEST_CODE_ENTER_NEW_PIN:
if (resultCode == Activity.RESULT_OK) {
if (data != null) {
if (Objects.requireNonNull(data.getExtras()).containsKey("confirmPIN")) {
if (data.getExtras() != null && data.getExtras().containsKey("confirmPIN")) {
Intent intent = new Intent(getContext(), RequestPINActivity.class);
intent.putExtra("mode", RequestPINActivity.Mode.RequestPIN2.toString());
intent.putExtra("UID", mCard.getUID());
@ -767,7 +752,7 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
case REQUEST_CODE_ENTER_NEW_PIN2:
if (resultCode == Activity.RESULT_OK) {
if (data != null) {
if (Objects.requireNonNull(data.getExtras()).containsKey("confirmPIN2")) {
if (data.getExtras() != null && data.getExtras().containsKey("confirmPIN2")) {
Intent intent = new Intent(getContext(), RequestPINActivity.class);
intent.putExtra("mode", RequestPINActivity.Mode.RequestPIN2.toString());
intent.putExtra("UID", mCard.getUID());
@ -785,9 +770,11 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
break;
case REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN:
if (resultCode == Activity.RESULT_OK) {
if (newPIN.equals("")) newPIN = mCard.getPIN();
if (newPIN.equals(""))
newPIN = mCard.getPIN();
if (newPIN2.equals("")) newPIN2 = PINStorage.getPIN2();
if (newPIN2.equals(""))
newPIN2 = PINStorage.getPIN2();
PINSwapWarningDialog pinSwapWarningDialog = new PINSwapWarningDialog();
pinSwapWarningDialog.setOnRefreshPage(this::startSwapPINActivity);
@ -805,17 +792,18 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
if (resultCode == Activity.RESULT_OK) {
if (data == null) {
data = new Intent();
data.putExtra("UID", mCard.getUID());
data.putExtra("Card", mCard.getAsBundle());
data.putExtra("modification", "delete");
} else {
} else
data.putExtra("modification", "update");
if (getActivity() != null) {
getActivity().setResult(Activity.RESULT_OK, data);
getActivity().finish();
}
Objects.requireNonNull(getActivity()).setResult(Activity.RESULT_OK, data);
getActivity().finish();
} else {
if (data != null && data.getExtras().containsKey("UID") && data.getExtras().containsKey("Card")) {
if (data != null && data.getExtras() != null && data.getExtras().containsKey("UID") && data.getExtras().containsKey("Card")) {
TangemCard updatedCard = new TangemCard(data.getStringExtra("UID"));
updatedCard.LoadFromBundle(data.getBundleExtra("Card"));
mCard = updatedCard;
@ -847,17 +835,18 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
if (resultCode == Activity.RESULT_OK) {
if (data == null) {
data = new Intent();
data.putExtra("UID", mCard.getUID());
data.putExtra("Card", mCard.getAsBundle());
data.putExtra("modification", "delete");
} else {
data.putExtra("modification", "update");
}
Objects.requireNonNull(getActivity()).setResult(Activity.RESULT_OK, data);
getActivity().finish();
if (getActivity() != null) {
getActivity().setResult(Activity.RESULT_OK, data);
getActivity().finish();
}
} else {
if (data != null && data.getExtras().containsKey("UID") && data.getExtras().containsKey("Card")) {
if (data != null && data.getExtras() != null && data.getExtras().containsKey("UID") && data.getExtras().containsKey("Card")) {
TangemCard updatedCard = new TangemCard(data.getStringExtra("UID"));
updatedCard.LoadFromBundle(data.getBundleExtra("Card"));
mCard = updatedCard;
@ -976,7 +965,7 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
RateInfoTask taskRate = new RateInfoTask();
ExchangeRequest rate = ExchangeRequest.GetRate(mCard.getWallet(), "ethereum", "ethereum");
ExchangeRequest rate = ExchangeRequest.GetRate(mCard.getWallet(), "ic_logo_ethereum", "ic_logo_ethereum");
taskRate.execute(rate);
} else if (mCard.getBlockchain() == Blockchain.Token) {
@ -996,7 +985,7 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
RateInfoTask taskRate = new RateInfoTask();
ExchangeRequest rate = ExchangeRequest.GetRate(mCard.getWallet(), "basic-attention-token", "ethereum");
ExchangeRequest rate = ExchangeRequest.GetRate(mCard.getWallet(), "basic-attention-token", "ic_logo_ethereum");
taskRate.execute(rate);
}
@ -1031,7 +1020,7 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
} else {
isoDep.setTimeout(65000);
}
//lastTag = tag;
verifyCardTask = new VerifyCardTask(getContext(), mCard, mNfcManager, isoDep, this);
verifyCardTask.start();
@ -1058,11 +1047,6 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
});
}
private CardProtocol mCardProtocol;
// private boolean needOpenVerify;
private int scanTimes = 0;
@Override
public void OnReadFinish(final CardProtocol cardProtocol) {
verifyCardTask = null;
@ -1219,15 +1203,8 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
else
tvInputs.setTextColor(ContextCompat.getColor(Objects.requireNonNull(getContext()), R.color.confirmed));
// if (btnSend != null) {
// btnSend.setText(mCard.getOutputsDescription());
// }
tvLastInput.setText(mCard.getLastInputDescription());
// tvLastOutput.setText(mCard.getLastOutputDescription());
tvBlockchain.setText(mCard.getBlockchainName());
ivBlockchain.setImageResource(mCard.getBlockchain().getImageResource(this.getContext(), mCard.getTokenSymbol()));
ivBlockchain.setImageResource(mCard.getBlockchain().getImageResource(getContext(), mCard.getTokenSymbol()));
if (tvValidationNode != null) {
tvValidationNode.setText(mCard.getValidationNodeDescription());
@ -1267,12 +1244,6 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
else
btnExtract.setEnabled(false);
// if (tvPurge != null)
// if (mCard.hasBalanceInfo())
// tvPurge.setEnabled(true);
// else
// tvPurge.setEnabled(false);
tvIssuer.setText(mCard.getIssuerDescription());
timerHideErrorAndMessage = new Timer();

View file

@ -88,7 +88,7 @@ public class VerifyCard extends Fragment implements NfcAdapter.ReaderCallback {
tvManufacturer = v.findViewById(R.id.tvManufacturerInfo);
tvCardIdentity = v.findViewById(R.id.tvCardIdentity);
tvRegistrationDate = v.findViewById(R.id.tvCardRegistredDate);
ivBlockchain = v.findViewById(R.id.imgBlockchain);
ivBlockchain = v.findViewById(R.id.ivBlockchain);
ivPIN = v.findViewById(R.id.imgPIN);
ivPIN2orSecurityDelay = v.findViewById(R.id.imgPIN2orSecurityDelay);
ivDeveloperVersion = v.findViewById(R.id.imgDeveloperVersion);
@ -356,8 +356,7 @@ public class VerifyCard extends Fragment implements NfcAdapter.ReaderCallback {
tvBlockchain.setText(mCard.getBlockchainName());
ivBlockchain.setImageResource(mCard.getBlockchain().getImageResource(getContext(), mCard.getTokenSymbol()));
ivBlockchain.setImageResource(mCard.getBlockchain().getLogoImageResource(mCard.getBlockchainID(), mCard.getTokenSymbol()));
if (mCard.isReusable())
tvReusable.setText(R.string.reusable);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

View file

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

View file

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

Before After
Before After

View file

@ -263,15 +263,6 @@
android:paddingRight="8dp"
android:visibility="gone">
<!--<TextView-->
<!--android:id="@+id/lbInputs"-->
<!--android:layout_width="110dp"-->
<!--android:layout_height="wrap_content"-->
<!--android:fontFamily="@font/raleway_r"-->
<!--android:text="@string/unspents"-->
<!--android:textColor="@color/primary_dark"-->
<!--android:textSize="@dimen/text_size_small"/>-->
<TextView
android:id="@+id/tvInputs"
android:layout_width="wrap_content"
@ -284,34 +275,6 @@
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:visibility="gone">
<TextView
android:layout_width="110dp"
android:layout_height="wrap_content"
android:fontFamily="@font/raleway_r"
android:text="@string/last_withdrawal"
android:textColor="@color/primary_dark"
android:textSize="@dimen/text_size_small"/>
<TextView
android:id="@+id/tvLastOutput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/montserrat_light"
android:text="@string/no_data_string"
android:textColor="@color/primary_dark"
android:textSize="@dimen/text_size_small"
android:textStyle="normal|bold"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -337,6 +300,7 @@
android:textSize="@dimen/text_size_small"
android:textStyle="normal|bold"
tools:text="TANGEM"/>
</LinearLayout>
<LinearLayout
@ -391,12 +355,12 @@
</LinearLayout>
<RelativeLayout
android:visibility="gone"
android:id="@+id/rlProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="215dp">
android:layout_marginTop="215dp"
android:visibility="gone">
<TextView
android:layout_width="wrap_content"

View file

@ -133,7 +133,7 @@
app:layout_constraintTop_toTopOf="@+id/tvBlockchainHeader"/>
<ImageView
android:id="@+id/imgBlockchain"
android:id="@+id/ivBlockchain"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginEnd="8dp"