diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index 56e6275b46..91eef56aee 100644 Binary files a/.idea/caches/build_file_checksums.ser and b/.idea/caches/build_file_checksums.ser differ diff --git a/app/src/main/java/com/tangem/domain/wallet/BtcEngine.java b/app/src/main/java/com/tangem/domain/wallet/BtcEngine.java index 771bc4b732..af38d3efd2 100644 --- a/app/src/main/java/com/tangem/domain/wallet/BtcEngine.java +++ b/app/src/main/java/com/tangem/domain/wallet/BtcEngine.java @@ -58,14 +58,25 @@ public class BtcEngine extends CoinEngine { return new String[]{/*"testnetnode.arihanc.com"*/"testnet.hsmiths.com", "testnet.qtornado.com", "testnet1.bauerj.eu"}; } - public static Integer[] GetBitcoinServicePorts() { - return new Integer[]{8080, 50001/* 8080*/, 50001, 50001, 50001, 50001, 50001, 50001, 50001, 50001}; - } - public static Integer[] GetBitcoinTestNetServicePorts() { return new Integer[]{/*51001*/53011, 51001, 50001}; } + +// public static String[] GetBitcoinTestNetServiceHosts() { +// return new String[]{"electrum.akinbo.org"/*, "testnet.hsmiths.com", "testnet.qtornado.com", "testnet1.bauerj.eu"*/}; +// } +// +// public static Integer[] GetBitcoinTestNetServicePorts() { +// return new Integer[]{51001/*53011, 51001, 50001*/}; +// } + + + + public static Integer[] GetBitcoinServicePorts() { + return new Integer[]{8080, 50001/* 8080*/, 50001, 50001, 50001, 50001, 50001, 50001, 50001, 50001}; + } + static int serviceIndex = GetNextBitconMainNetServiceIndex(); static int dynamicIndex = GetNextBitconMainNetServiceIndex(); diff --git a/app/src/main/java/com/tangem/presentation/activity/CardInfoActivity.java b/app/src/main/java/com/tangem/presentation/activity/CardInfoActivity.java index 751c84d00b..0c5d5281d3 100644 --- a/app/src/main/java/com/tangem/presentation/activity/CardInfoActivity.java +++ b/app/src/main/java/com/tangem/presentation/activity/CardInfoActivity.java @@ -11,10 +11,10 @@ import android.view.Menu; import android.view.MenuItem; import com.tangem.domain.wallet.TangemCard; +import com.tangem.presentation.fragment.WalletInfo; import com.tangem.wallet.R; -import com.tangem.presentation.fragment.WalletInfoFragment; -public class CardInfoActivity extends AppCompatActivity implements WalletInfoFragment.OnFragmentInteractionListener { +public class CardInfoActivity extends AppCompatActivity implements WalletInfo.OnFragmentInteractionListener { /** * The {@link android.support.v4.view.PagerAdapter} that will provide @@ -44,10 +44,10 @@ public class CardInfoActivity extends AppCompatActivity implements WalletInfoFra mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. - mViewPager = (ViewPager) findViewById(R.id.container); + mViewPager = findViewById(R.id.container); mViewPager.setAdapter(mSectionsPagerAdapter); - TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs); + TabLayout tabLayout = findViewById(R.id.tabs); tabLayout.setupWithViewPager(mViewPager); String UID = getIntent().getStringExtra("UID"); @@ -95,7 +95,7 @@ public class CardInfoActivity extends AppCompatActivity implements WalletInfoFra // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). if (position == 0) { - return WalletInfoFragment.newInstance(mCard); + return WalletInfo.newInstance(mCard); } /*else if (position == 1) { return WalletUnspentFragment.newInstance(mCard); } else if (position == 2) { diff --git a/app/src/main/java/com/tangem/presentation/activity/LoadedWalletActivity.java b/app/src/main/java/com/tangem/presentation/activity/LoadedWalletActivity.java index 94ee33cce4..3707d354b8 100644 --- a/app/src/main/java/com/tangem/presentation/activity/LoadedWalletActivity.java +++ b/app/src/main/java/com/tangem/presentation/activity/LoadedWalletActivity.java @@ -7,7 +7,7 @@ import android.nfc.Tag; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; -import com.tangem.presentation.fragment.LoadedWalletFragment; +import com.tangem.presentation.fragment.LoadedWallet; import com.tangem.wallet.R; import java.util.Objects; @@ -23,7 +23,7 @@ public class LoadedWalletActivity extends AppCompatActivity { if (Objects.requireNonNull(getIntent().getExtras()).containsKey(NfcAdapter.EXTRA_TAG)) { Tag tag = getIntent().getParcelableExtra(NfcAdapter.EXTRA_TAG); if (tag != null) { - LoadedWalletFragment fragment = (LoadedWalletFragment) (getSupportFragmentManager().findFragmentById(R.id.loaded_wallet_fragment)); + LoadedWallet fragment = (LoadedWallet) (getSupportFragmentManager().findFragmentById(R.id.loaded_wallet_fragment)); fragment.onTagDiscovered(tag); } } @@ -31,8 +31,8 @@ public class LoadedWalletActivity extends AppCompatActivity { @Override public void onBackPressed() { - LoadedWalletFragment loadedWalletFragment = (LoadedWalletFragment) getSupportFragmentManager().findFragmentById(R.id.loaded_wallet_fragment); - Intent data = loadedWalletFragment.prepareResultIntent(); + LoadedWallet loadedWallet = (LoadedWallet) getSupportFragmentManager().findFragmentById(R.id.loaded_wallet_fragment); + Intent data = loadedWallet.prepareResultIntent(); data.putExtra("modification", "update"); setResult(Activity.RESULT_OK, data); finish(); diff --git a/app/src/main/java/com/tangem/presentation/activity/MainActivity.java b/app/src/main/java/com/tangem/presentation/activity/MainActivity.java index fc9110cca0..205925140c 100644 --- a/app/src/main/java/com/tangem/presentation/activity/MainActivity.java +++ b/app/src/main/java/com/tangem/presentation/activity/MainActivity.java @@ -28,7 +28,7 @@ import com.tangem.domain.wallet.LastSignStorage; import com.tangem.domain.wallet.Logger; import com.tangem.domain.wallet.PINStorage; import com.tangem.presentation.dialog.RootFoundDialog; -import com.tangem.presentation.fragment.MainFragment; +import com.tangem.presentation.fragment.Main; import com.tangem.util.CommonUtil; import com.tangem.util.PhoneUtility; import com.tangem.wallet.BuildConfig; @@ -106,8 +106,8 @@ public class MainActivity extends AppCompatActivity implements PopupMenu.OnMenuI fab.setOnClickListener(this::showMenu); // add fragment - MainFragment mainFragment = (MainFragment) getSupportFragmentManager().findFragmentById(R.id.fragmentMain); - if (mainFragment.getCardListAdapter().getItemCount() > 0) + Main main = (Main) getSupportFragmentManager().findFragmentById(R.id.fragmentMain); + if (main.getCardListAdapter().getItemCount() > 0) showCleanButton(); else hideCleanButton(); diff --git a/app/src/main/java/com/tangem/presentation/activity/VerifyCardActivity.java b/app/src/main/java/com/tangem/presentation/activity/VerifyCardActivity.java index 38bd0103e5..4257b3bbd9 100644 --- a/app/src/main/java/com/tangem/presentation/activity/VerifyCardActivity.java +++ b/app/src/main/java/com/tangem/presentation/activity/VerifyCardActivity.java @@ -6,7 +6,7 @@ import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import com.tangem.wallet.R; -import com.tangem.presentation.fragment.VerifyCardFragment; +import com.tangem.presentation.fragment.VerifyCard; public class VerifyCardActivity extends AppCompatActivity { @@ -21,8 +21,8 @@ public class VerifyCardActivity extends AppCompatActivity { @Override public void onBackPressed() { //super.onBackPressed(); - VerifyCardFragment verifyCardFragment = (VerifyCardFragment) getSupportFragmentManager().findFragmentById(R.id.verify_card_fragment); - Intent data = verifyCardFragment.prepareResultIntent(); + VerifyCard verifyCard = (VerifyCard) getSupportFragmentManager().findFragmentById(R.id.verify_card_fragment); + Intent data = verifyCard.prepareResultIntent(); data.putExtra("modification", "update"); setResult(Activity.RESULT_OK, data); finish(); diff --git a/app/src/main/java/com/tangem/presentation/fragment/LoadedWalletFragment.java b/app/src/main/java/com/tangem/presentation/fragment/LoadedWallet.java similarity index 87% rename from app/src/main/java/com/tangem/presentation/fragment/LoadedWalletFragment.java rename to app/src/main/java/com/tangem/presentation/fragment/LoadedWallet.java index e59d35b94f..117006e10e 100644 --- a/app/src/main/java/com/tangem/presentation/fragment/LoadedWalletFragment.java +++ b/app/src/main/java/com/tangem/presentation/fragment/LoadedWallet.java @@ -17,7 +17,9 @@ import android.nfc.Tag; import android.nfc.tech.IsoDep; import android.os.AsyncTask; import android.os.Bundle; +import android.support.annotation.NonNull; import android.support.v4.app.Fragment; +import android.support.v4.content.ContextCompat; import android.support.v4.widget.SwipeRefreshLayout; import android.text.Html; import android.text.Spanned; @@ -76,16 +78,13 @@ import java.math.BigInteger; import java.util.ArrayList; import java.util.Hashtable; import java.util.List; +import java.util.Objects; import java.util.Timer; import java.util.TimerTask; import static android.content.Context.CLIPBOARD_SERVICE; -/** - * A placeholder fragment containing a simple view. - */ -public class LoadedWalletFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener, NfcAdapter.ReaderCallback, CardProtocol.Notifications { - +public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefreshListener, NfcAdapter.ReaderCallback, CardProtocol.Notifications { private static final int REQUEST_CODE_SEND_PAYMENT = 1; private static final int REQUEST_CODE_PURGE = 2; @@ -95,955 +94,27 @@ public class LoadedWalletFragment extends Fragment implements SwipeRefreshLayout private static final int REQUEST_CODE_ENTER_NEW_PIN2 = 6; private static final int REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN = 7; private static final int REQUEST_CODE_SWAP_PIN = 8; - TangemCard mCard; - TextView tvCardID, tvBalance, tvOffline, tvBalanceEquivalent, tvWallet, tvInputs, lbInputs, tvOutputs, tvSend, tvPurge, tvError, tvMessage, tvIssuer, tvIssuerData, tvBlockchain, tvLastInput, tvLastOutput, lbLastOutput, tvValidationNode; - TextView tvHeader, tvCaution; - ImageView imgLookup; - TextView tvLookup; - ProgressBar progressBar; - ImageView ivBlockchain, ivPIN, ivPIN2orSecurityDelay, ivDeveloperVersion, ivQR; - SwipeRefreshLayout mSwipeRefreshLayout; - List updateTasks = new ArrayList<>(); + + private TangemCard mCard; + private TextView tvCardID, tvBalance, tvOffline, tvBalanceEquivalent, tvWallet, tvInputs, lbInputs, tvOutputs, tvSend, tvPurge, tvError, tvMessage, tvIssuer, tvIssuerData, tvBlockchain, tvLastInput, tvLastOutput, lbLastOutput, tvValidationNode; + private TextView tvHeader, tvCaution; + private ImageView imgLookup; + private TextView tvLookup; + private ProgressBar progressBar; + private ImageView ivBlockchain, ivPIN, ivPIN2orSecurityDelay, ivDeveloperVersion, ivQR; + private SwipeRefreshLayout mSwipeRefreshLayout; + private List updateTasks = new ArrayList<>(); private NfcManager mNfcManager; - private final String logTag = "LoadedWalletFragment"; + private final String logTag = "LoadedWallet"; private boolean lastReadSuccess = true; private VerifyCardTask verifyCardTask = null; private int requestPIN2Count = 0; - public LoadedWalletFragment() { + private Timer timerHideErrorAndMessage = null; + private String newPIN = "", newPIN2 = ""; - } + public LoadedWallet() { - public void onRefresh() { - //Update - // Showing refresh animation before making http call - if (updateTasks.size() > 0) return; - ; - mSwipeRefreshLayout.setRefreshing(true); - mCard.clearInfo(); - mCard.setError(null); - mCard.setMessage(null); - - boolean needResendTX = LastSignStorage.getNeedTxSend(mCard.getWallet()); - - UpdateViews(); - - CoinEngine engine = CoinEngineFactory.Create(mCard.getBlockchain()); - - if (mCard.getBlockchain() == Blockchain.Bitcoin || mCard.getBlockchain() == Blockchain.BitcoinTestNet) { - SharedData data = new SharedData(SharedData.COUNT_REQUEST); - for (int i = 0; i < data.allRequest; ++i) { - String nodeAddress = engine.GetNextNode(mCard); - int nodePort = engine.GetNextNodePort(mCard); - UpdateWalletInfoTask connectTaskEx = new UpdateWalletInfoTask(nodeAddress, nodePort, data); - connectTaskEx.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, ElectrumRequest.CheckBalance(mCard.getWallet())); - } - - String nodeAddress = engine.GetNode(mCard); - int nodePort = engine.GetNodePort(mCard); - UpdateWalletInfoTask updateWalletInfoTask = new UpdateWalletInfoTask(nodeAddress, nodePort, data); - updateTasks.add(updateWalletInfoTask); - updateWalletInfoTask.execute(ElectrumRequest.ListUnspent(mCard.getWallet()), ElectrumRequest.ListHistory(mCard.getWallet())); - - RateInfoTask taskRate = new RateInfoTask(); - ExchangeRequest rate = ExchangeRequest.GetRate(mCard.getWallet(), "bitcoin", "bitcoin"); - taskRate.execute(rate); - - - } else if (mCard.getBlockchain() == Blockchain.BitcoinCash || mCard.getBlockchain() == Blockchain.BitcoinCashTestNet) { - SharedData data = new SharedData(SharedData.COUNT_REQUEST); - for (int i = 0; i < data.allRequest; ++i) { - String nodeAddress = engine.GetNextNode(mCard); - int nodePort = engine.GetNextNodePort(mCard); - UpdateWalletInfoTask connectTaskEx = new UpdateWalletInfoTask(nodeAddress, nodePort, data); - connectTaskEx.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, ElectrumRequest.CheckBalance(mCard.getWallet())); - } - - String nodeAddress = engine.GetNode(mCard); - int nodePort = engine.GetNodePort(mCard); - UpdateWalletInfoTask updateWalletInfoTask = new UpdateWalletInfoTask(nodeAddress, nodePort, data); - - updateTasks.add(updateWalletInfoTask); - updateWalletInfoTask.execute(ElectrumRequest.ListUnspent(mCard.getWallet()), ElectrumRequest.ListHistory(mCard.getWallet())); - - RateInfoTask taskRate = new RateInfoTask(); - ExchangeRequest rate = ExchangeRequest.GetRate(mCard.getWallet(), "bitcoin-cash", "bitcoin-cash"); - taskRate.execute(rate); - - - } else if (mCard.getBlockchain() == Blockchain.Ethereum || mCard.getBlockchain() == Blockchain.EthereumTestNet) { - ETHRequestTask updateETH = new ETHRequestTask(mCard.getBlockchain()); - InfuraRequest reqETH = InfuraRequest.GetBalance(mCard.getWallet()); - reqETH.setID(67); - reqETH.setBlockchain(mCard.getBlockchain()); - - InfuraRequest reqNonce = InfuraRequest.GetOutTransactionCount(mCard.getWallet()); - reqNonce.setID(67); - reqNonce.setBlockchain(mCard.getBlockchain()); - - updateETH.execute(reqETH, reqNonce); - - - RateInfoTask taskRate = new RateInfoTask(); - ExchangeRequest rate = ExchangeRequest.GetRate(mCard.getWallet(), "ethereum", "ethereum"); - taskRate.execute(rate); - - } else if (mCard.getBlockchain() == Blockchain.Token) { - ETHRequestTask updateETH = new ETHRequestTask(mCard.getBlockchain()); - InfuraRequest reqETH = InfuraRequest.GetTokenBalance(mCard.getWallet(), engine.GetContractAddress(mCard), engine.GetTokenDecimals(mCard)); - reqETH.setID(67); - reqETH.setBlockchain(mCard.getBlockchain()); - - InfuraRequest reqBalance = InfuraRequest.GetBalance(mCard.getWallet()); - reqBalance.setID(67); - reqBalance.setBlockchain(mCard.getBlockchain()); - - InfuraRequest reqNonce = InfuraRequest.GetOutTransactionCount(mCard.getWallet()); - reqNonce.setID(67); - reqNonce.setBlockchain(mCard.getBlockchain()); - updateETH.execute(reqETH, reqNonce, reqBalance); - - - RateInfoTask taskRate = new RateInfoTask(); - ExchangeRequest rate = ExchangeRequest.GetRate(mCard.getWallet(), "basic-attention-token", "ethereum"); - taskRate.execute(rate); - } - - if (needResendTX) { - SendTransaction(LastSignStorage.getTxForSend(mCard.getWallet())); - } - } - - void doShareWallet(boolean useURI) { - if (useURI) { - String txtShare = CoinEngineFactory.Create(mCard.getBlockchain()).getShareWalletURI(mCard).toString(); - //String txtShare = Blockchain.getShareWalletURI(mCard).toString(); - Intent intent = new Intent(Intent.ACTION_SEND); - intent.setType("text/plain"); - intent.putExtra(Intent.EXTRA_SUBJECT, "Wallet address"); - intent.putExtra(Intent.EXTRA_TEXT, txtShare); - - PackageManager packageManager = getActivity().getPackageManager(); - List activities = packageManager.queryIntentActivities(intent, PackageManager.MATCH_ALL); - boolean isIntentSafe = activities.size() > 0; - - if (isIntentSafe) { - String title = "Share wallet address with:"; - // Create intent to show chooser - Intent chooser = Intent.createChooser(intent, title); - // Verify the intent will resolve to at least one activity - if (intent.resolveActivity(getActivity().getPackageManager()) != null) { - startActivity(chooser); - } - } else { - ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(CLIPBOARD_SERVICE); - clipboard.setPrimaryClip(ClipData.newPlainText(txtShare, txtShare)); - Toast.makeText(getContext(), "Copied to clipboard", Toast.LENGTH_LONG).show(); - } - } else { - String txtShare = mCard.getWallet(); - ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(CLIPBOARD_SERVICE); - clipboard.setPrimaryClip(ClipData.newPlainText(txtShare, txtShare)); - Toast.makeText(getContext(), "Copied to clipboard", Toast.LENGTH_LONG).show(); - } - - - } - - @Override - public View onCreateView(final LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - View v = inflater.inflate(R.layout.fr_loaded_wallet, container, false); - - mNfcManager = new NfcManager(this.getActivity(), this); - - - // SwipeRefreshLayout - mSwipeRefreshLayout = v.findViewById(R.id.swipe_container); - mSwipeRefreshLayout.setOnRefreshListener(this); - - mCard = new TangemCard(getActivity().getIntent().getStringExtra("UID")); - mCard.LoadFromBundle(getActivity().getIntent().getExtras().getBundle("Card")); - tvCardID = v.findViewById(R.id.tvCardID); - - tvBalance = v.findViewById(R.id.tvBalance); - tvOffline = v.findViewById(R.id.tvOffline); - - if (mCard.getBlockchain() == Blockchain.Token) { - //tvBalance.setLines(2); - tvBalance.setSingleLine(false); - } - - tvBalanceEquivalent = v.findViewById(R.id.tvBalanceEquivalent); - - tvWallet = v.findViewById(R.id.tvWallet); - tvWallet.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - doShareWallet(false); - } - }); - - tvInputs = v.findViewById(R.id.tvInputs); - lbInputs = v.findViewById(R.id.lbInputs); - - tvLastOutput = v.findViewById(R.id.tvLastOutput); - lbLastOutput = v.findViewById(R.id.lbLastOutput); - - final CoinEngine engine = CoinEngineFactory.Create(mCard.getBlockchain()); - - boolean visibleFlag = engine != null ? engine.InOutPutVisible() : true; - int visibleIOPuts = visibleFlag ? View.VISIBLE : View.GONE; - if (tvInputs != null) { - tvInputs.setVisibility(visibleIOPuts); - } - - if (lbInputs != null) { - lbInputs.setVisibility(visibleIOPuts); - } - - if (tvLastOutput != null) { - tvLastOutput.setVisibility(visibleIOPuts); - } - - if (lbLastOutput != null) { - lbLastOutput.setVisibility(visibleIOPuts); - } - - tvValidationNode = v.findViewById(R.id.tvValidationNode); - - progressBar = v.findViewById(R.id.progressBar); - - tvBlockchain = v.findViewById(R.id.tvBlockchain); - ivBlockchain = v.findViewById(R.id.imgBlockchain); - ivPIN = v.findViewById(R.id.imgPIN); - ivPIN2orSecurityDelay = v.findViewById(R.id.imgPIN2orSecurityDelay); - ivDeveloperVersion = v.findViewById(R.id.imgDeveloperVersion); - - ivQR = v.findViewById(R.id.qrWallet); - - - try { - ivQR.setImageBitmap(generateQrCode(engine.getShareWalletURI(mCard).toString())); - } catch (WriterException e) { - e.printStackTrace(); - } - ivQR.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - doShareWallet(true); - } - }); - - 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); - - tvSend = v.findViewById(R.id.tvSend); - - imgLookup = v.findViewById(R.id.imgLookup); - - if (imgLookup != null) { - - imgLookup.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (!mCard.hasBalanceInfo()) { - return; - } - CoinEngine engineClick = CoinEngineFactory.Create(mCard.getBlockchain()); - - Intent browserIntent = new Intent(Intent.ACTION_VIEW, engineClick.getShareWalletURIExplorer(mCard)); - startActivity(browserIntent); - } - }); - - } - - tvLookup = v.findViewById(R.id.tvLookup); - - if (tvLookup != null) { - - tvLookup.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (!mCard.hasBalanceInfo()) { - return; - } - CoinEngine engineClick = CoinEngineFactory.Create(mCard.getBlockchain()); - - Intent browserIntent = new Intent(Intent.ACTION_VIEW, engineClick.getShareWalletURIExplorer(mCard)); - startActivity(browserIntent); - } - }); - } - - if (tvSend != null) { - tvSend.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (!mCard.hasBalanceInfo()) { - return; - } else if (!engine.IsBalanceNotZero(mCard)) { - Toast.makeText(getContext(), "The wallet is empty", Toast.LENGTH_LONG).show(); - return; - } else if (!engine.IsBalanceAlterNotZero(mCard)) { - Toast.makeText(getContext(), "Not enough funds for transaction fee (gas)!", Toast.LENGTH_LONG).show(); - return; - } else if (engine.AwaitingConfirmation(mCard)) { - Toast.makeText(getContext(), "Please wait while previous transaction is confirmed in blockchain", Toast.LENGTH_LONG).show(); - return; - } else if (!engine.CheckUnspentTransaction(mCard)) { - Toast.makeText(getContext(), "Please wait for confirmation of incoming transaction!", Toast.LENGTH_LONG).show(); - return; - } else if (mCard.getRemainingSignatures() == 0) { - Toast.makeText(getContext(), "Card hasn't remaining signature!", Toast.LENGTH_LONG).show(); - return; - } - - Intent intent = new Intent(getContext(), PreparePaymentActivity.class); - intent.putExtra("UID", mCard.getUID()); - intent.putExtra("Card", mCard.getAsBundle()); - startActivityForResult(intent, REQUEST_CODE_SEND_PAYMENT); - } - }); - } - - tvPurge = v.findViewById(R.id.tvPurge); - if (tvPurge != null) { - tvPurge.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - showMenu(tvPurge); - } - } - ); - } - UpdateViews(); - - if (!mCard.hasBalanceInfo()) { - mSwipeRefreshLayout.setRefreshing(true); - mSwipeRefreshLayout.postDelayed(new Runnable() { - @Override - public void run() { - onRefresh(); - } - }, 1000); - } - return v; - } - - public void showMenu(View v) { - final PopupMenu popup = new PopupMenu(getActivity(), v); - MenuInflater inflater = popup.getMenuInflater(); - inflater.inflate(R.menu.menu_loaded_wallet, popup.getMenu()); - - popup.getMenu().findItem(R.id.action_set_PIN1).setVisible(mCard.allowSwapPIN()); - popup.getMenu().findItem(R.id.action_reset_PIN1).setVisible(mCard.allowSwapPIN() && !mCard.useDefaultPIN1()); - popup.getMenu().findItem(R.id.action_set_PIN2).setVisible(mCard.allowSwapPIN2()); - popup.getMenu().findItem(R.id.action_reset_PIN2).setVisible(mCard.allowSwapPIN2() && !mCard.useDefaultPIN2()); - popup.getMenu().findItem(R.id.action_reset_PINs).setVisible(mCard.allowSwapPIN() && mCard.allowSwapPIN2() && !mCard.useDefaultPIN1() && !mCard.useDefaultPIN2()); - - popup.setOnMenuItemClickListener(item -> { - - int id = item.getItemId(); - switch (id) { - case R.id.action_set_PIN1: - doSetPin(); - return true; - - case R.id.action_reset_PIN1: - doResetPin(); - return true; - - case R.id.action_set_PIN2: - doSetPin2(); - return true; - - case R.id.action_reset_PIN2: - doResetPin2(); - return true; - - case R.id.action_reset_PINs: - doResetPins(); - return true; - - case R.id.action_purge: - doPurge(); - return true; - - default: - return false; - } - }); - - if (BuildConfig.DEBUG) { - popup.getMenu().findItem(R.id.action_set_PIN2).setEnabled(true); - popup.getMenu().findItem(R.id.action_reset_PIN2).setEnabled(true); - } - - popup.show(); - } - - String newPIN = "", newPIN2 = ""; - - void doSetPin() { - requestPIN2Count = 0; - Intent intent = new Intent(getContext(), RequestPINActivity.class); - intent.putExtra("mode", RequestPINActivity.Mode.RequestNewPIN.toString()); - newPIN = ""; - newPIN2 = ""; - startActivityForResult(intent, REQUEST_CODE_ENTER_NEW_PIN); - } - - void doResetPin() { - requestPIN2Count = 0; - Intent intent = new Intent(getContext(), RequestPINActivity.class); - intent.putExtra("mode", RequestPINActivity.Mode.RequestPIN2.toString()); - intent.putExtra("UID", mCard.getUID()); - intent.putExtra("Card", mCard.getAsBundle()); - newPIN = PINStorage.getDefaultPIN(); - newPIN2 = ""; - startActivityForResult(intent, REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN); - } - - void doResetPin2() { - requestPIN2Count = 0; - Intent intent = new Intent(getContext(), RequestPINActivity.class); - intent.putExtra("mode", RequestPINActivity.Mode.RequestPIN2.toString()); - intent.putExtra("UID", mCard.getUID()); - intent.putExtra("Card", mCard.getAsBundle()); - newPIN = ""; - newPIN2 = PINStorage.getDefaultPIN2(); - startActivityForResult(intent, REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN); - } - - void doResetPins() { - requestPIN2Count = 0; - Intent intent = new Intent(getContext(), RequestPINActivity.class); - intent.putExtra("mode", RequestPINActivity.Mode.RequestPIN2.toString()); - intent.putExtra("UID", mCard.getUID()); - intent.putExtra("Card", mCard.getAsBundle()); - newPIN = PINStorage.getDefaultPIN(); - newPIN2 = PINStorage.getDefaultPIN2(); - startActivityForResult(intent, REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN); - } - - - void doSetPin2() { - requestPIN2Count = 0; - Intent intent = new Intent(getContext(), RequestPINActivity.class); - intent.putExtra("mode", RequestPINActivity.Mode.RequestNewPIN2.toString()); - newPIN = ""; - newPIN2 = ""; - startActivityForResult(intent, REQUEST_CODE_ENTER_NEW_PIN2); - } - - void doPurge() { - requestPIN2Count = 0; - final CoinEngine engine = CoinEngineFactory.Create(mCard.getBlockchain()); - if (!mCard.hasBalanceInfo()) { - return; - } else if (engine.IsBalanceNotZero(mCard)) { - Toast.makeText(getContext(), "Cannot erase wallet with non-zero balance", Toast.LENGTH_LONG).show(); - return; - } - - Intent intent = new Intent(getContext(), RequestPINActivity.class); - intent.putExtra("mode", RequestPINActivity.Mode.RequestPIN2.toString()); - intent.putExtra("UID", mCard.getUID()); - intent.putExtra("Card", mCard.getAsBundle()); - startActivityForResult(intent, REQUEST_CODE_REQUEST_PIN2_FOR_PURGE); - } - - void UpdateViews() { - try { - if (timerHideErrorAndMessage != null) { - timerHideErrorAndMessage.cancel(); - timerHideErrorAndMessage = null; - } - tvCardID.setText(mCard.getCIDDescription()); - - if ((mCard.getError() == null || mCard.getError().isEmpty())) { - tvError.setVisibility(View.GONE); - tvError.setText(""); - } else { - tvError.setVisibility(View.VISIBLE); - tvError.setText(mCard.getError()); - } - - boolean needResendTX = LastSignStorage.getNeedTxSend(mCard.getWallet()); - - if ((mCard.getMessage() == null || mCard.getMessage().isEmpty()) && !needResendTX) { - tvMessage.setText(""); - tvMessage.setVisibility(View.GONE); - } else { - if (needResendTX) { - tvMessage.setText("Sending cached transaction..."); - } else { - tvMessage.setText(mCard.getMessage()); - } - tvMessage.setVisibility(View.VISIBLE); - - } - - - CoinEngine engine = CoinEngineFactory.Create(mCard.getBlockchain()); - - if (engine.HasBalanceInfo(mCard) || mCard.getOfflineBalance() == null) { - if (mCard.getBlockchain() == Blockchain.Token) { - Spanned html = Html.fromHtml(engine.GetBalanceWithAlter(mCard)); - tvBalance.setText(html); - } else { - tvBalance.setText(engine.GetBalanceWithAlter(mCard)); - } - - tvBalanceEquivalent.setText(engine.GetBalanceEquivalent(mCard)); - tvOffline.setVisibility(View.INVISIBLE); - } else { - String offlineAmount = engine.ConvertByteArrayToAmount(mCard, mCard.getOfflineBalance()); - if (mCard.getBlockchain() == Blockchain.Token) { - tvBalance.setText("NOT IMPLEMENTED"); - } else { - tvBalance.setText(engine.GetAmountDescription(mCard, offlineAmount)); - } - - tvBalanceEquivalent.setText(engine.GetAmountEqualentDescriptor(mCard, offlineAmount)); - tvOffline.setVisibility(View.VISIBLE); - } - - if (!mCard.getAmountEquivalentDescriptionAvailable()) { - //tvBalanceEquivalent.setError("Service unavailable"); - } else { - tvBalanceEquivalent.setError(null); - } - - tvWallet.setText(mCard.getWallet()); - - tvInputs.setText(mCard.getInputsDescription()); - if (mCard.getLastInputDescription().contains("awaiting")) { - tvInputs.setTextColor(getContext().getResources().getColor(R.color.not_confirmed, getContext().getTheme())); - } else if (mCard.getLastInputDescription().contains("None")) { - tvInputs.setTextColor(getContext().getResources().getColor(R.color.primary_dark, getContext().getTheme())); - } else { - tvInputs.setTextColor(getContext().getResources().getColor(R.color.confirmed, getContext().getTheme())); - } - - if (tvOutputs != null) { - tvOutputs.setText(mCard.getOutputsDescription()); - } - - if (tvLastInput != null) { - tvLastInput.setText(mCard.getLastInputDescription()); - } - if (tvLastOutput != null) { - tvLastOutput.setText(mCard.getLastOutputDescription()); - } - - tvBlockchain.setText(mCard.getBlockchainName()); - ivBlockchain.setImageResource(mCard.getBlockchain().getImageResource(this.getContext(), mCard.getTokenSymbol())); - - if (tvValidationNode != null) { - tvValidationNode.setText(mCard.getValidationNodeDescription()); - } - - if (mCard.useDefaultPIN1()) { - ivPIN.setImageResource(R.drawable.unlock_pin1); - ivPIN.setOnClickListener(v -> Toast.makeText(getContext(), "This banknote is protected by default PIN1 code", Toast.LENGTH_LONG).show()); - } else { - ivPIN.setImageResource(R.drawable.lock_pin1); - ivPIN.setOnClickListener(v -> Toast.makeText(getContext(), "This banknote is protected by user's PIN1 code", Toast.LENGTH_LONG).show()); - } - - if (mCard.getPauseBeforePIN2() > 0 && (mCard.useDefaultPIN2() || !mCard.useSmartSecurityDelay())) { - ivPIN2orSecurityDelay.setImageResource(R.drawable.timer); - ivPIN2orSecurityDelay.setOnClickListener(v -> Toast.makeText(getContext(), String.format("This banknote will enforce %.0f seconds security delay for all operations requiring PIN2 code", mCard.getPauseBeforePIN2() / 1000.0), Toast.LENGTH_LONG).show()); - - } else if (mCard.useDefaultPIN2()) { - ivPIN2orSecurityDelay.setImageResource(R.drawable.unlock_pin2); - ivPIN2orSecurityDelay.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Toast.makeText(getContext(), "This banknote is protected by default PIN2 code", Toast.LENGTH_LONG).show(); - } - }); - } else { - ivPIN2orSecurityDelay.setImageResource(R.drawable.lock_pin2); - ivPIN2orSecurityDelay.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Toast.makeText(getContext(), "This banknote is protected by user's PIN2 code", Toast.LENGTH_LONG).show(); - } - }); - } - - - if (mCard.useDevelopersFirmware()) { - ivDeveloperVersion.setImageResource(R.drawable.ic_developer_version); - ivDeveloperVersion.setVisibility(View.VISIBLE); - ivDeveloperVersion.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Toast.makeText(getContext(), "Unlocked banknote, only for development use", Toast.LENGTH_LONG).show(); - } - }); - } else { - ivDeveloperVersion.setVisibility(View.INVISIBLE); - } - - if (tvSend != null) { - if (mCard.hasBalanceInfo()) { - tvSend.setEnabled(true); - } else { - tvSend.setEnabled(false); - } - } - - if (tvPurge != null) { - if (mCard.hasBalanceInfo()) { - tvPurge.setEnabled(true); - } else { - tvPurge.setEnabled(false); - } - } - - tvIssuer.setText(mCard.getIssuerDescription()); - - timerHideErrorAndMessage = new Timer(); - - - timerHideErrorAndMessage.schedule(new TimerTask() { - @Override - public void run() { - tvError.post(new Runnable() { - @Override - public void run() { - tvMessage.setVisibility(View.GONE); - tvError.setVisibility(View.GONE); - mCard.setError(null); - mCard.setMessage(null); - } - }); - } - }, 5000); - - if (mCard.isReusable()) { - tvHeader.setText("REUSABLE WALLET"); - tvCaution.setVisibility(View.GONE); - } else { - if (mCard.getMaxSignatures() == mCard.getRemainingSignatures()) { - tvHeader.setText("BANKNOTE"); - tvCaution.setVisibility(View.GONE); - } else { - tvHeader.setText("NON-TRANSFERABLE BANKNOTE"); - tvCaution.setVisibility(View.VISIBLE); - } - } - - if (mCard.useDevelopersFirmware()) { - tvHeader.setText("DEVELOPER KIT"); - tvCaution.setVisibility(View.VISIBLE); - } - - } catch (Exception e) { - e.printStackTrace(); - } - } - - Timer timerHideErrorAndMessage = null; - - public Intent prepareResultIntent() { - Intent data = new Intent(); - data.putExtra("UID", mCard.getUID()); - data.putExtra("Card", mCard.getAsBundle()); - return data; - } - - private void SendTransaction(String tx) { - CoinEngine engine = CoinEngineFactory.Create(mCard.getBlockchain()); - if (mCard.getBlockchain() == Blockchain.Ethereum || mCard.getBlockchain() == Blockchain.EthereumTestNet || mCard.getBlockchain() == Blockchain.Token) { - ETHRequestTask task = new ETHRequestTask(mCard.getBlockchain()); - InfuraRequest req = InfuraRequest.SendTransaction(mCard.getWallet(), tx); - req.setID(67); - req.setBlockchain(mCard.getBlockchain()); - task.execute(req); - } else if (mCard.getBlockchain() == Blockchain.Bitcoin || mCard.getBlockchain() == Blockchain.BitcoinTestNet) { - String nodeAddress = engine.GetNode(mCard); - int nodePort = engine.GetNodePort(mCard); - - UpdateWalletInfoTask connectTask = new UpdateWalletInfoTask(nodeAddress, nodePort); - connectTask.execute(ElectrumRequest.Broadcast(mCard.getWallet(), tx)); - } else if (mCard.getBlockchain() == Blockchain.BitcoinCash || mCard.getBlockchain() == Blockchain.BitcoinCashTestNet) { - String nodeAddress = engine.GetNode(mCard); - int nodePort = engine.GetNodePort(mCard); - - UpdateWalletInfoTask connectTask = new UpdateWalletInfoTask(nodeAddress, nodePort); - connectTask.execute(ElectrumRequest.Broadcast(mCard.getWallet(), tx)); - } - } - - @Override - public void onActivityResult(int requestCode, int resultCode, Intent data) { - super.onActivityResult(requestCode, resultCode, data); - switch (requestCode) { - case REQUEST_CODE_ENTER_NEW_PIN: - if (resultCode == Activity.RESULT_OK) { - if (data != null) { - if (data.getExtras().containsKey("confirmPIN")) { - Intent intent = new Intent(getContext(), RequestPINActivity.class); - intent.putExtra("mode", RequestPINActivity.Mode.RequestPIN2.toString()); - intent.putExtra("UID", mCard.getUID()); - intent.putExtra("Card", mCard.getAsBundle()); - newPIN = data.getStringExtra("newPIN"); - startActivityForResult(intent, REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN); - } else { - Intent intent = new Intent(getContext(), RequestPINActivity.class); - intent.putExtra("newPIN", data.getStringExtra("newPIN")); - intent.putExtra("mode", RequestPINActivity.Mode.ConfirmNewPIN.toString()); - startActivityForResult(intent, REQUEST_CODE_ENTER_NEW_PIN); - } - } - } - break; - case REQUEST_CODE_ENTER_NEW_PIN2: - if (resultCode == Activity.RESULT_OK) { - if (data != null) { - if (data.getExtras().containsKey("confirmPIN2")) { - Intent intent = new Intent(getContext(), RequestPINActivity.class); - intent.putExtra("mode", RequestPINActivity.Mode.RequestPIN2.toString()); - intent.putExtra("UID", mCard.getUID()); - intent.putExtra("Card", mCard.getAsBundle()); - newPIN2 = data.getStringExtra("newPIN2"); - startActivityForResult(intent, REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN); - } else { - Intent intent = new Intent(getContext(), RequestPINActivity.class); - intent.putExtra("newPIN2", data.getStringExtra("newPIN2")); - intent.putExtra("mode", RequestPINActivity.Mode.ConfirmNewPIN2.toString()); - startActivityForResult(intent, REQUEST_CODE_ENTER_NEW_PIN2); - } - } - } - break; - case REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN: - if (resultCode == Activity.RESULT_OK) { - if (newPIN.equals("")) { - newPIN = mCard.getPIN(); - } - if (newPIN2.equals("")) { - newPIN2 = PINStorage.getPIN2(); - } - - PINSwapWarningDialog dialog = (new PINSwapWarningDialog()); - dialog.activityFragment = this; - if (!PINStorage.isDefaultPIN(newPIN) || !PINStorage.isDefaultPIN2(newPIN2)) { - dialog.message = "If you forget your new PIN you will lose your money forever!"; - } else { - dialog.message = "If you use default PIN someone can steal your money!"; - } - dialog.show(getActivity().getFragmentManager(), "PINSwapWarningDialog"); - } - break; - - case REQUEST_CODE_SWAP_PIN: - 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"); - } - getActivity().setResult(Activity.RESULT_OK, data); - getActivity().finish(); - } else { - if (data != null && data.getExtras().containsKey("UID") && data.getExtras().containsKey("Card")) { - TangemCard updatedCard = new TangemCard(data.getStringExtra("UID")); - updatedCard.LoadFromBundle(data.getBundleExtra("Card")); - mCard = updatedCard; - } - if (resultCode == CreateNewWalletActivity.RESULT_INVALID_PIN && requestPIN2Count < 2) { - requestPIN2Count++; - Intent intent = new Intent(getContext(), RequestPINActivity.class); - intent.putExtra("mode", RequestPINActivity.Mode.RequestPIN2.toString()); - intent.putExtra("UID", mCard.getUID()); - intent.putExtra("Card", mCard.getAsBundle()); - startActivityForResult(intent, REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN); - return; - } else { - if (data != null && data.getExtras().containsKey("message")) { - mCard.setError(data.getStringExtra("message")); - } - } - } - break; - case REQUEST_CODE_REQUEST_PIN2_FOR_PURGE: - if (resultCode == Activity.RESULT_OK) { - Intent intent = new Intent(getContext(), PurgeActivity.class); - intent.putExtra("UID", mCard.getUID()); - intent.putExtra("Card", mCard.getAsBundle()); - startActivityForResult(intent, REQUEST_CODE_PURGE); - } - break; - case REQUEST_CODE_PURGE: - 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"); - } - getActivity().setResult(Activity.RESULT_OK, data); - getActivity().finish(); - } else { - if (data != null && data.getExtras().containsKey("UID") && data.getExtras().containsKey("Card")) { - TangemCard updatedCard = new TangemCard(data.getStringExtra("UID")); - updatedCard.LoadFromBundle(data.getBundleExtra("Card")); - mCard = updatedCard; - } - if (resultCode == CreateNewWalletActivity.RESULT_INVALID_PIN && requestPIN2Count < 2) { - requestPIN2Count++; - Intent intent = new Intent(getContext(), RequestPINActivity.class); - intent.putExtra("mode", RequestPINActivity.Mode.RequestPIN2.toString()); - intent.putExtra("UID", mCard.getUID()); - intent.putExtra("Card", mCard.getAsBundle()); - startActivityForResult(intent, REQUEST_CODE_REQUEST_PIN2_FOR_PURGE); - return; - } else { - if (data != null && data.getExtras().containsKey("message")) { - mCard.setError(data.getStringExtra("message")); - } - } - UpdateViews(); - } - break; - case REQUEST_CODE_SEND_PAYMENT: - if (resultCode == Activity.RESULT_OK) { - mSwipeRefreshLayout.postDelayed(new Runnable() { - @Override - public void run() { - onRefresh(); - } - }, 10000); - mSwipeRefreshLayout.setRefreshing(true); - mCard.clearInfo(); - UpdateViews(); - } - - if (data != null) { - if (data.getExtras().containsKey("UID") && data.getExtras().containsKey("Card")) { - TangemCard updatedCard = new TangemCard(data.getStringExtra("UID")); - updatedCard.LoadFromBundle(data.getBundleExtra("Card")); - mCard = updatedCard; - } - if (data.getExtras().containsKey("message")) { - if (resultCode == Activity.RESULT_OK) { - mCard.setMessage(data.getStringExtra("message")); - } else { - mCard.setError(data.getStringExtra("message")); - } - } - UpdateViews(); - } - - break; - } - - } - - private void startSwapPINActivity() { - Intent intent = new Intent(getContext(), SwapPINActivity.class); - intent.putExtra("UID", mCard.getUID()); - intent.putExtra("Card", mCard.getAsBundle()); - intent.putExtra("newPIN", newPIN); - intent.putExtra("newPIN2", newPIN2); - startActivityForResult(intent, REQUEST_CODE_SWAP_PIN); - } - - public static Bitmap generateQrCode(String myCodeText) throws WriterException { - Hashtable hintMap = new Hashtable(); - hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H); // H = 30% damage - - QRCodeWriter qrCodeWriter = new QRCodeWriter(); - - int size = 256; - - BitMatrix bitMatrix = qrCodeWriter.encode(myCodeText, BarcodeFormat.QR_CODE, size, size, hintMap); - int width = bitMatrix.getWidth(); - Bitmap bmp = Bitmap.createBitmap(width, width, Bitmap.Config.RGB_565); - for (int x = 0; x < width; x++) { - for (int y = 0; y < width; y++) { - bmp.setPixel(y, x, bitMatrix.get(x, y) ? Color.BLACK : Color.WHITE); - } - } - return bmp; - } - - - @Override - public void onResume() { - super.onResume(); - mNfcManager.onResume(); - } - - @Override - public void onPause() { - super.onPause(); - mNfcManager.onPause(); - } - - @Override - public void onStop() { - super.onStop(); - for (UpdateWalletInfoTask ut : updateTasks) { - ut.cancel(true); - } - mNfcManager.onStop(); - } - - @Override - public void onTagDiscovered(Tag tag) { - try { - final IsoDep isoDep = IsoDep.get(tag); - if (isoDep == null) { - throw new CardProtocol.TangemException(getString(R.string.wrong_tag_err)); - } - byte UID[] = tag.getId(); - String sUID = Util.byteArrayToHexString(UID); - if (!mCard.getUID().equals(sUID)) { - Log.d(logTag, "Invalid UID: " + sUID); - mNfcManager.ignoreTag(isoDep.getTag()); - return; - } else { - Log.v(logTag, "UID: " + sUID); - } - - if (lastReadSuccess) { - isoDep.setTimeout(1000); - } else { - isoDep.setTimeout(65000); - } - //lastTag = tag; - verifyCardTask = new VerifyCardTask(getContext(), mCard, mNfcManager, isoDep, this); - verifyCardTask.start(); - - } catch (Exception e) { - e.printStackTrace(); - } - } - - public void ErrorOnUpdate(String message) { - mCard.setError("Cannot obtain data from blockchain"); - UpdateViews(); } private class ETHRequestTask extends InfuraTask { @@ -1144,7 +215,7 @@ public class LoadedWalletFragment extends Fragment implements SwipeRefreshLayout ErrorOnUpdate("Failed to send transaction. Try again"); } } - UpdateViews(); + updateViews(); } else { ErrorOnUpdate(request.error); } @@ -1158,111 +229,6 @@ public class LoadedWalletFragment extends Fragment implements SwipeRefreshLayout } } - public void OnReadStart(CardProtocol cardProtocol) { - progressBar.post(new Runnable() { - @Override - public void run() { - progressBar.setVisibility(View.VISIBLE); - progressBar.setProgress(5); - } - }); - } - - public void OnReadFinish(final CardProtocol cardProtocol) { - - verifyCardTask = null; - - if (cardProtocol != null) { - if (cardProtocol.getError() == null) { - progressBar.post(new Runnable() { - @Override - public void run() { - progressBar.setProgress(100); - progressBar.setProgressTintList(ColorStateList.valueOf(Color.GREEN)); - Intent intent = new Intent(getContext(), VerifyCardActivity.class); - // TODO обновить карту mCard - intent.putExtra("UID", cardProtocol.getCard().getUID()); - intent.putExtra("Card", cardProtocol.getCard().getAsBundle()); - startActivityForResult(intent, REQUEST_CODE_VERIFY_CARD); - //addCard(cardProtocol.getCard()); - } - }); - } else { - // remove last UIDs because of error and no card read - progressBar.post(new Runnable() { - @Override - public void run() { - lastReadSuccess = false; - if (cardProtocol.getError() instanceof CardProtocol.TangemException_ExtendedLengthNotSupported) { - if (!NoExtendedLengthSupportDialog.allreadyShowed) { - new NoExtendedLengthSupportDialog().show(getActivity().getFragmentManager(), "NoExtendedLengthSupportDialog"); - } - } else { - Toast.makeText(getContext(), "Try to scan again", Toast.LENGTH_LONG).show(); - } - progressBar.setProgress(100); - progressBar.setProgressTintList(ColorStateList.valueOf(Color.RED)); - } - }); - } - } - - progressBar.postDelayed(new Runnable() { - @Override - public void run() { - try { - progressBar.setProgress(0); - progressBar.setProgressTintList(ColorStateList.valueOf(Color.DKGRAY)); - progressBar.setVisibility(View.INVISIBLE); - } catch (Exception e) { - e.printStackTrace(); - } - } - }, 500); - } - - public void OnReadProgress(CardProtocol protocol, final int progress) { - progressBar.post(new Runnable() { - @Override - public void run() { - progressBar.setProgress(progress); - } - }); - } - - public void OnReadCancel() { - - verifyCardTask = null; - - progressBar.postDelayed(new Runnable() { - @Override - public void run() { - try { - progressBar.setProgress(0); - progressBar.setProgressTintList(ColorStateList.valueOf(Color.DKGRAY)); - progressBar.setVisibility(View.INVISIBLE); - } catch (Exception e) { - e.printStackTrace(); - } - } - }, 500); - } - - public void OnReadWait(int msec) { - WaitSecurityDelayDialog.OnReadWait(getActivity(), msec); - } - - @Override - public void OnReadBeforeRequest(int timeout) { - WaitSecurityDelayDialog.onReadBeforeRequest(getActivity(), timeout); - } - - @Override - public void OnReadAfterRequest() { - WaitSecurityDelayDialog.onReadAfterRequest(getActivity()); - } - - private class RateInfoTask extends ExchangeTask { protected void onPostExecute(List requests) { super.onPostExecute(requests); @@ -1282,7 +248,7 @@ public class LoadedWalletFragment extends Fragment implements SwipeRefreshLayout Float rate = Float.valueOf(usd); mCard.setRate(rate); - UpdateViews(); + updateViews(); stop = true; } @@ -1291,7 +257,7 @@ public class LoadedWalletFragment extends Fragment implements SwipeRefreshLayout Float rate = Float.valueOf(usd); mCard.setRateAlter(rate); - UpdateViews(); + updateViews(); stopAlter = true; } @@ -1543,7 +509,7 @@ public class LoadedWalletFragment extends Fragment implements SwipeRefreshLayout engine.SwitchNode(mCard); } } - UpdateViews(); + updateViews(); } else { if (sharedCounter != null) { int errCounter = sharedCounter.errorRequest.incrementAndGet(); @@ -1579,7 +545,7 @@ public class LoadedWalletFragment extends Fragment implements SwipeRefreshLayout public static class PINSwapWarningDialog extends DialogFragment { - LoadedWalletFragment activityFragment = null; + LoadedWallet activityFragment = null; String message; @Override @@ -1613,4 +579,960 @@ public class LoadedWalletFragment extends Fragment implements SwipeRefreshLayout } } -} + @Override + public View onCreateView(@NonNull final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + View v = inflater.inflate(R.layout.fr_loaded_wallet, container, false); + + mNfcManager = new NfcManager(this.getActivity(), this); + + mSwipeRefreshLayout = v.findViewById(R.id.swipe_container); + 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); + lbInputs = v.findViewById(R.id.lbInputs); + tvLastOutput = v.findViewById(R.id.tvLastOutput); + lbLastOutput = v.findViewById(R.id.lbLastOutput); + 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); + tvSend = v.findViewById(R.id.tvSend); + imgLookup = v.findViewById(R.id.imgLookup); + tvValidationNode = v.findViewById(R.id.tvValidationNode); + progressBar = v.findViewById(R.id.progressBar); + tvBlockchain = v.findViewById(R.id.tvBlockchain); + ivBlockchain = v.findViewById(R.id.imgBlockchain); + ivPIN = v.findViewById(R.id.imgPIN); + ivPIN2orSecurityDelay = v.findViewById(R.id.imgPIN2orSecurityDelay); + ivDeveloperVersion = v.findViewById(R.id.imgDeveloperVersion); + ivQR = v.findViewById(R.id.qrWallet); + tvLookup = v.findViewById(R.id.tvLookup); + tvPurge = v.findViewById(R.id.tvPurge); + + mSwipeRefreshLayout.setOnRefreshListener(this); + + mCard = new TangemCard(getActivity().getIntent().getStringExtra("UID")); + mCard.LoadFromBundle(getActivity().getIntent().getExtras().getBundle("Card")); + + if (mCard.getBlockchain() == Blockchain.Token) { + //tvBalance.setLines(2); + tvBalance.setSingleLine(false); + } + + tvBalanceEquivalent = v.findViewById(R.id.tvBalanceEquivalent); + + + tvWallet.setOnClickListener(v12 -> doShareWallet(false)); + + + final CoinEngine engine = CoinEngineFactory.Create(mCard.getBlockchain()); + + boolean visibleFlag = engine != null ? engine.InOutPutVisible() : true; + int visibleIOPuts = visibleFlag ? View.VISIBLE : View.GONE; + if (tvInputs != null) { + tvInputs.setVisibility(visibleIOPuts); + } + + if (lbInputs != null) { + lbInputs.setVisibility(visibleIOPuts); + } + + if (tvLastOutput != null) { + tvLastOutput.setVisibility(visibleIOPuts); + } + + if (lbLastOutput != null) { + lbLastOutput.setVisibility(visibleIOPuts); + } + + try { + ivQR.setImageBitmap(generateQrCode(engine.getShareWalletURI(mCard).toString())); + } catch (WriterException e) { + e.printStackTrace(); + } + ivQR.setOnClickListener(v1 -> doShareWallet(true)); + + + if (imgLookup != null) { + imgLookup.setOnClickListener(v15 -> { + if (!mCard.hasBalanceInfo()) { + return; + } + CoinEngine engineClick = CoinEngineFactory.Create(mCard.getBlockchain()); + + Intent browserIntent = new Intent(Intent.ACTION_VIEW, engineClick.getShareWalletURIExplorer(mCard)); + startActivity(browserIntent); + }); + + } + + if (tvLookup != null) { + tvLookup.setOnClickListener(v14 -> { + if (!mCard.hasBalanceInfo()) { + return; + } + CoinEngine engineClick = CoinEngineFactory.Create(mCard.getBlockchain()); + + Intent browserIntent = new Intent(Intent.ACTION_VIEW, engineClick.getShareWalletURIExplorer(mCard)); + startActivity(browserIntent); + }); + } + + if (tvSend != null) { + tvSend.setOnClickListener(v13 -> { + if (!mCard.hasBalanceInfo()) { + return; + } else if (!engine.IsBalanceNotZero(mCard)) { + Toast.makeText(getContext(), R.string.wallet_empty, Toast.LENGTH_LONG).show(); + return; + } else if (!engine.IsBalanceAlterNotZero(mCard)) { + Toast.makeText(getContext(), R.string.not_enough_funds, Toast.LENGTH_LONG).show(); + return; + } else if (engine.AwaitingConfirmation(mCard)) { + Toast.makeText(getContext(), R.string.please_wait_while_previous, Toast.LENGTH_LONG).show(); + return; + } else if (!engine.CheckUnspentTransaction(mCard)) { + Toast.makeText(getContext(), R.string.please_wait_for_confirmation, Toast.LENGTH_LONG).show(); + return; + } else if (mCard.getRemainingSignatures() == 0) { + Toast.makeText(getContext(), R.string.card_hasn_t_remaining_signature, Toast.LENGTH_LONG).show(); + return; + } + + Intent intent = new Intent(getContext(), PreparePaymentActivity.class); + intent.putExtra("UID", mCard.getUID()); + intent.putExtra("Card", mCard.getAsBundle()); + startActivityForResult(intent, REQUEST_CODE_SEND_PAYMENT); + }); + } + + + tvPurge.setOnClickListener(v16 -> showMenu(tvPurge)); + + + updateViews(); + + if (!mCard.hasBalanceInfo()) { + mSwipeRefreshLayout.setRefreshing(true); + mSwipeRefreshLayout.postDelayed(this::onRefresh, 1000); + } + return v; + } + + @Override + public void onResume() { + super.onResume(); + mNfcManager.onResume(); + } + + @Override + public void onPause() { + super.onPause(); + mNfcManager.onPause(); + } + + @Override + public void onStop() { + super.onStop(); + for (UpdateWalletInfoTask ut : updateTasks) { + ut.cancel(true); + } + mNfcManager.onStop(); + } + + @Override + public void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + switch (requestCode) { + case REQUEST_CODE_ENTER_NEW_PIN: + if (resultCode == Activity.RESULT_OK) { + if (data != null) { + if (data.getExtras().containsKey("confirmPIN")) { + Intent intent = new Intent(getContext(), RequestPINActivity.class); + intent.putExtra("mode", RequestPINActivity.Mode.RequestPIN2.toString()); + intent.putExtra("UID", mCard.getUID()); + intent.putExtra("Card", mCard.getAsBundle()); + newPIN = data.getStringExtra("newPIN"); + startActivityForResult(intent, REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN); + } else { + Intent intent = new Intent(getContext(), RequestPINActivity.class); + intent.putExtra("newPIN", data.getStringExtra("newPIN")); + intent.putExtra("mode", RequestPINActivity.Mode.ConfirmNewPIN.toString()); + startActivityForResult(intent, REQUEST_CODE_ENTER_NEW_PIN); + } + } + } + break; + case REQUEST_CODE_ENTER_NEW_PIN2: + if (resultCode == Activity.RESULT_OK) { + if (data != null) { + if (data.getExtras().containsKey("confirmPIN2")) { + Intent intent = new Intent(getContext(), RequestPINActivity.class); + intent.putExtra("mode", RequestPINActivity.Mode.RequestPIN2.toString()); + intent.putExtra("UID", mCard.getUID()); + intent.putExtra("Card", mCard.getAsBundle()); + newPIN2 = data.getStringExtra("newPIN2"); + startActivityForResult(intent, REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN); + } else { + Intent intent = new Intent(getContext(), RequestPINActivity.class); + intent.putExtra("newPIN2", data.getStringExtra("newPIN2")); + intent.putExtra("mode", RequestPINActivity.Mode.ConfirmNewPIN2.toString()); + startActivityForResult(intent, REQUEST_CODE_ENTER_NEW_PIN2); + } + } + } + break; + case REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN: + if (resultCode == Activity.RESULT_OK) { + if (newPIN.equals("")) { + newPIN = mCard.getPIN(); + } + if (newPIN2.equals("")) { + newPIN2 = PINStorage.getPIN2(); + } + + PINSwapWarningDialog dialog = (new PINSwapWarningDialog()); + dialog.activityFragment = this; + if (!PINStorage.isDefaultPIN(newPIN) || !PINStorage.isDefaultPIN2(newPIN2)) { + dialog.message = "If you forget your new PIN you will lose your money forever!"; + } else { + dialog.message = "If you use default PIN someone can steal your money!"; + } + dialog.show(getActivity().getFragmentManager(), "PINSwapWarningDialog"); + } + break; + + case REQUEST_CODE_SWAP_PIN: + 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"); + } + getActivity().setResult(Activity.RESULT_OK, data); + getActivity().finish(); + } else { + if (data != null && data.getExtras().containsKey("UID") && data.getExtras().containsKey("Card")) { + TangemCard updatedCard = new TangemCard(data.getStringExtra("UID")); + updatedCard.LoadFromBundle(data.getBundleExtra("Card")); + mCard = updatedCard; + } + if (resultCode == CreateNewWalletActivity.RESULT_INVALID_PIN && requestPIN2Count < 2) { + requestPIN2Count++; + Intent intent = new Intent(getContext(), RequestPINActivity.class); + intent.putExtra("mode", RequestPINActivity.Mode.RequestPIN2.toString()); + intent.putExtra("UID", mCard.getUID()); + intent.putExtra("Card", mCard.getAsBundle()); + startActivityForResult(intent, REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN); + return; + } else { + if (data != null && data.getExtras().containsKey("message")) { + mCard.setError(data.getStringExtra("message")); + } + } + } + break; + case REQUEST_CODE_REQUEST_PIN2_FOR_PURGE: + if (resultCode == Activity.RESULT_OK) { + Intent intent = new Intent(getContext(), PurgeActivity.class); + intent.putExtra("UID", mCard.getUID()); + intent.putExtra("Card", mCard.getAsBundle()); + startActivityForResult(intent, REQUEST_CODE_PURGE); + } + break; + case REQUEST_CODE_PURGE: + 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"); + } + getActivity().setResult(Activity.RESULT_OK, data); + getActivity().finish(); + } else { + if (data != null && data.getExtras().containsKey("UID") && data.getExtras().containsKey("Card")) { + TangemCard updatedCard = new TangemCard(data.getStringExtra("UID")); + updatedCard.LoadFromBundle(data.getBundleExtra("Card")); + mCard = updatedCard; + } + if (resultCode == CreateNewWalletActivity.RESULT_INVALID_PIN && requestPIN2Count < 2) { + requestPIN2Count++; + Intent intent = new Intent(getContext(), RequestPINActivity.class); + intent.putExtra("mode", RequestPINActivity.Mode.RequestPIN2.toString()); + intent.putExtra("UID", mCard.getUID()); + intent.putExtra("Card", mCard.getAsBundle()); + startActivityForResult(intent, REQUEST_CODE_REQUEST_PIN2_FOR_PURGE); + return; + } else { + if (data != null && data.getExtras().containsKey("message")) { + mCard.setError(data.getStringExtra("message")); + } + } + updateViews(); + } + break; + case REQUEST_CODE_SEND_PAYMENT: + if (resultCode == Activity.RESULT_OK) { + mSwipeRefreshLayout.postDelayed(this::onRefresh, 10000); + mSwipeRefreshLayout.setRefreshing(true); + mCard.clearInfo(); + updateViews(); + } + + if (data != null) { + if (data.getExtras().containsKey("UID") && data.getExtras().containsKey("Card")) { + TangemCard updatedCard = new TangemCard(data.getStringExtra("UID")); + updatedCard.LoadFromBundle(data.getBundleExtra("Card")); + mCard = updatedCard; + } + if (data.getExtras().containsKey("message")) { + if (resultCode == Activity.RESULT_OK) { + mCard.setMessage(data.getStringExtra("message")); + } else { + mCard.setError(data.getStringExtra("message")); + } + } + updateViews(); + } + + break; + } + } + + public void onRefresh() { + //Update + // Showing refresh animation before making http call + if (updateTasks.size() > 0) return; + + mSwipeRefreshLayout.setRefreshing(true); + mCard.clearInfo(); + mCard.setError(null); + mCard.setMessage(null); + + boolean needResendTX = LastSignStorage.getNeedTxSend(mCard.getWallet()); + + updateViews(); + + CoinEngine engine = CoinEngineFactory.Create(mCard.getBlockchain()); + + if (mCard.getBlockchain() == Blockchain.Bitcoin || mCard.getBlockchain() == Blockchain.BitcoinTestNet) { + SharedData data = new SharedData(SharedData.COUNT_REQUEST); + for (int i = 0; i < data.allRequest; ++i) { + String nodeAddress = engine.GetNextNode(mCard); + int nodePort = engine.GetNextNodePort(mCard); + UpdateWalletInfoTask connectTaskEx = new UpdateWalletInfoTask(nodeAddress, nodePort, data); + connectTaskEx.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, ElectrumRequest.CheckBalance(mCard.getWallet())); + } + + String nodeAddress = engine.GetNode(mCard); + int nodePort = engine.GetNodePort(mCard); + UpdateWalletInfoTask updateWalletInfoTask = new UpdateWalletInfoTask(nodeAddress, nodePort, data); + updateTasks.add(updateWalletInfoTask); + updateWalletInfoTask.execute(ElectrumRequest.ListUnspent(mCard.getWallet()), ElectrumRequest.ListHistory(mCard.getWallet())); + + RateInfoTask taskRate = new RateInfoTask(); + ExchangeRequest rate = ExchangeRequest.GetRate(mCard.getWallet(), "bitcoin", "bitcoin"); + taskRate.execute(rate); + + + } else if (mCard.getBlockchain() == Blockchain.BitcoinCash || mCard.getBlockchain() == Blockchain.BitcoinCashTestNet) { + SharedData data = new SharedData(SharedData.COUNT_REQUEST); + for (int i = 0; i < data.allRequest; ++i) { + String nodeAddress = engine.GetNextNode(mCard); + int nodePort = engine.GetNextNodePort(mCard); + UpdateWalletInfoTask connectTaskEx = new UpdateWalletInfoTask(nodeAddress, nodePort, data); + connectTaskEx.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, ElectrumRequest.CheckBalance(mCard.getWallet())); + } + + String nodeAddress = engine.GetNode(mCard); + int nodePort = engine.GetNodePort(mCard); + UpdateWalletInfoTask updateWalletInfoTask = new UpdateWalletInfoTask(nodeAddress, nodePort, data); + + updateTasks.add(updateWalletInfoTask); + updateWalletInfoTask.execute(ElectrumRequest.ListUnspent(mCard.getWallet()), ElectrumRequest.ListHistory(mCard.getWallet())); + + RateInfoTask taskRate = new RateInfoTask(); + ExchangeRequest rate = ExchangeRequest.GetRate(mCard.getWallet(), "bitcoin-cash", "bitcoin-cash"); + taskRate.execute(rate); + + + } else if (mCard.getBlockchain() == Blockchain.Ethereum || mCard.getBlockchain() == Blockchain.EthereumTestNet) { + ETHRequestTask updateETH = new ETHRequestTask(mCard.getBlockchain()); + InfuraRequest reqETH = InfuraRequest.GetBalance(mCard.getWallet()); + reqETH.setID(67); + reqETH.setBlockchain(mCard.getBlockchain()); + + InfuraRequest reqNonce = InfuraRequest.GetOutTransactionCount(mCard.getWallet()); + reqNonce.setID(67); + reqNonce.setBlockchain(mCard.getBlockchain()); + + updateETH.execute(reqETH, reqNonce); + + + RateInfoTask taskRate = new RateInfoTask(); + ExchangeRequest rate = ExchangeRequest.GetRate(mCard.getWallet(), "ethereum", "ethereum"); + taskRate.execute(rate); + + } else if (mCard.getBlockchain() == Blockchain.Token) { + ETHRequestTask updateETH = new ETHRequestTask(mCard.getBlockchain()); + InfuraRequest reqETH = InfuraRequest.GetTokenBalance(mCard.getWallet(), engine.GetContractAddress(mCard), engine.GetTokenDecimals(mCard)); + reqETH.setID(67); + reqETH.setBlockchain(mCard.getBlockchain()); + + InfuraRequest reqBalance = InfuraRequest.GetBalance(mCard.getWallet()); + reqBalance.setID(67); + reqBalance.setBlockchain(mCard.getBlockchain()); + + InfuraRequest reqNonce = InfuraRequest.GetOutTransactionCount(mCard.getWallet()); + reqNonce.setID(67); + reqNonce.setBlockchain(mCard.getBlockchain()); + updateETH.execute(reqETH, reqNonce, reqBalance); + + + RateInfoTask taskRate = new RateInfoTask(); + ExchangeRequest rate = ExchangeRequest.GetRate(mCard.getWallet(), "basic-attention-token", "ethereum"); + taskRate.execute(rate); + } + + if (needResendTX) { + sendTransaction(LastSignStorage.getTxForSend(mCard.getWallet())); + } + } + + @Override + public void onTagDiscovered(Tag tag) { + try { + final IsoDep isoDep = IsoDep.get(tag); + if (isoDep == null) { + throw new CardProtocol.TangemException(getString(R.string.wrong_tag_err)); + } + byte UID[] = tag.getId(); + String sUID = Util.byteArrayToHexString(UID); + if (!mCard.getUID().equals(sUID)) { + Log.d(logTag, "Invalid UID: " + sUID); + mNfcManager.ignoreTag(isoDep.getTag()); + return; + } else { + Log.v(logTag, "UID: " + sUID); + } + + if (lastReadSuccess) { + isoDep.setTimeout(1000); + } else { + isoDep.setTimeout(65000); + } + //lastTag = tag; + verifyCardTask = new VerifyCardTask(getContext(), mCard, mNfcManager, isoDep, this); + verifyCardTask.start(); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + public Intent prepareResultIntent() { + Intent data = new Intent(); + data.putExtra("UID", mCard.getUID()); + data.putExtra("Card", mCard.getAsBundle()); + return data; + } + + public void ErrorOnUpdate(String message) { + mCard.setError("Cannot obtain data from blockchain"); + updateViews(); + } + + + public void OnReadStart(CardProtocol cardProtocol) { + progressBar.post(() -> { + progressBar.setVisibility(View.VISIBLE); + progressBar.setProgress(5); + }); + } + + public void OnReadFinish(final CardProtocol cardProtocol) { + + verifyCardTask = null; + + if (cardProtocol != null) { + if (cardProtocol.getError() == null) { + progressBar.post(() -> { + progressBar.setProgress(100); + progressBar.setProgressTintList(ColorStateList.valueOf(Color.GREEN)); + Intent intent = new Intent(getContext(), VerifyCardActivity.class); + // TODO обновить карту mCard + intent.putExtra("UID", cardProtocol.getCard().getUID()); + intent.putExtra("Card", cardProtocol.getCard().getAsBundle()); + startActivityForResult(intent, REQUEST_CODE_VERIFY_CARD); + //addCard(cardProtocol.getCard()); + }); + } else { + // remove last UIDs because of error and no card read + progressBar.post(() -> { + lastReadSuccess = false; + if (cardProtocol.getError() instanceof CardProtocol.TangemException_ExtendedLengthNotSupported) { + if (!NoExtendedLengthSupportDialog.allreadyShowed) { + new NoExtendedLengthSupportDialog().show(getActivity().getFragmentManager(), "NoExtendedLengthSupportDialog"); + } + } else { + Toast.makeText(getContext(), "Try to scan again", Toast.LENGTH_LONG).show(); + } + progressBar.setProgress(100); + progressBar.setProgressTintList(ColorStateList.valueOf(Color.RED)); + }); + } + } + + progressBar.postDelayed(() -> { + try { + progressBar.setProgress(0); + progressBar.setProgressTintList(ColorStateList.valueOf(Color.DKGRAY)); + progressBar.setVisibility(View.INVISIBLE); + } catch (Exception e) { + e.printStackTrace(); + } + }, 500); + } + + public void OnReadProgress(CardProtocol protocol, final int progress) { + progressBar.post(() -> progressBar.setProgress(progress)); + } + + public void OnReadCancel() { + + verifyCardTask = null; + + progressBar.postDelayed(() -> { + try { + progressBar.setProgress(0); + progressBar.setProgressTintList(ColorStateList.valueOf(Color.DKGRAY)); + progressBar.setVisibility(View.INVISIBLE); + } catch (Exception e) { + e.printStackTrace(); + } + }, 500); + } + + public void OnReadWait(int msec) { + WaitSecurityDelayDialog.OnReadWait(getActivity(), msec); + } + + @Override + public void OnReadBeforeRequest(int timeout) { + WaitSecurityDelayDialog.onReadBeforeRequest(getActivity(), timeout); + } + + @Override + public void OnReadAfterRequest() { + WaitSecurityDelayDialog.onReadAfterRequest(getActivity()); + } + + private void showMenu(View v) { + final PopupMenu popup = new PopupMenu(getActivity(), v); + MenuInflater inflater = popup.getMenuInflater(); + inflater.inflate(R.menu.menu_loaded_wallet, popup.getMenu()); + + popup.getMenu().findItem(R.id.action_set_PIN1).setVisible(mCard.allowSwapPIN()); + popup.getMenu().findItem(R.id.action_reset_PIN1).setVisible(mCard.allowSwapPIN() && !mCard.useDefaultPIN1()); + popup.getMenu().findItem(R.id.action_set_PIN2).setVisible(mCard.allowSwapPIN2()); + popup.getMenu().findItem(R.id.action_reset_PIN2).setVisible(mCard.allowSwapPIN2() && !mCard.useDefaultPIN2()); + popup.getMenu().findItem(R.id.action_reset_PINs).setVisible(mCard.allowSwapPIN() && mCard.allowSwapPIN2() && !mCard.useDefaultPIN1() && !mCard.useDefaultPIN2()); + if (!mCard.isReusable()) + popup.getMenu().findItem(R.id.action_purge).setVisible(false); + + popup.setOnMenuItemClickListener(item -> { + + int id = item.getItemId(); + switch (id) { + case R.id.action_set_PIN1: + doSetPin(); + return true; + + case R.id.action_reset_PIN1: + doResetPin(); + return true; + + case R.id.action_set_PIN2: + doSetPin2(); + return true; + + case R.id.action_reset_PIN2: + doResetPin2(); + return true; + + case R.id.action_reset_PINs: + doResetPins(); + return true; + + case R.id.action_purge: + doPurge(); + return true; + + default: + return false; + } + }); + + if (BuildConfig.DEBUG) { + popup.getMenu().findItem(R.id.action_set_PIN2).setEnabled(true); + popup.getMenu().findItem(R.id.action_reset_PIN2).setEnabled(true); + } + + popup.show(); + } + + private void doSetPin() { + requestPIN2Count = 0; + Intent intent = new Intent(getContext(), RequestPINActivity.class); + intent.putExtra("mode", RequestPINActivity.Mode.RequestNewPIN.toString()); + newPIN = ""; + newPIN2 = ""; + startActivityForResult(intent, REQUEST_CODE_ENTER_NEW_PIN); + } + + private void doResetPin() { + requestPIN2Count = 0; + Intent intent = new Intent(getContext(), RequestPINActivity.class); + intent.putExtra("mode", RequestPINActivity.Mode.RequestPIN2.toString()); + intent.putExtra("UID", mCard.getUID()); + intent.putExtra("Card", mCard.getAsBundle()); + newPIN = PINStorage.getDefaultPIN(); + newPIN2 = ""; + startActivityForResult(intent, REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN); + } + + private void doResetPin2() { + requestPIN2Count = 0; + Intent intent = new Intent(getContext(), RequestPINActivity.class); + intent.putExtra("mode", RequestPINActivity.Mode.RequestPIN2.toString()); + intent.putExtra("UID", mCard.getUID()); + intent.putExtra("Card", mCard.getAsBundle()); + newPIN = ""; + newPIN2 = PINStorage.getDefaultPIN2(); + startActivityForResult(intent, REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN); + } + + private void doResetPins() { + requestPIN2Count = 0; + Intent intent = new Intent(getContext(), RequestPINActivity.class); + intent.putExtra("mode", RequestPINActivity.Mode.RequestPIN2.toString()); + intent.putExtra("UID", mCard.getUID()); + intent.putExtra("Card", mCard.getAsBundle()); + newPIN = PINStorage.getDefaultPIN(); + newPIN2 = PINStorage.getDefaultPIN2(); + startActivityForResult(intent, REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN); + } + + + private void doSetPin2() { + requestPIN2Count = 0; + Intent intent = new Intent(getContext(), RequestPINActivity.class); + intent.putExtra("mode", RequestPINActivity.Mode.RequestNewPIN2.toString()); + newPIN = ""; + newPIN2 = ""; + startActivityForResult(intent, REQUEST_CODE_ENTER_NEW_PIN2); + } + + private void doPurge() { + requestPIN2Count = 0; + final CoinEngine engine = CoinEngineFactory.Create(mCard.getBlockchain()); + if (!mCard.hasBalanceInfo()) { + return; + } else if (engine.IsBalanceNotZero(mCard)) { + Toast.makeText(getContext(), "Cannot erase wallet with non-zero balance", Toast.LENGTH_LONG).show(); + return; + } + + Intent intent = new Intent(getContext(), RequestPINActivity.class); + intent.putExtra("mode", RequestPINActivity.Mode.RequestPIN2.toString()); + intent.putExtra("UID", mCard.getUID()); + intent.putExtra("Card", mCard.getAsBundle()); + startActivityForResult(intent, REQUEST_CODE_REQUEST_PIN2_FOR_PURGE); + } + + private void updateViews() { + try { + if (timerHideErrorAndMessage != null) { + timerHideErrorAndMessage.cancel(); + timerHideErrorAndMessage = null; + } + tvCardID.setText(mCard.getCIDDescription()); + + if ((mCard.getError() == null || mCard.getError().isEmpty())) { + tvError.setVisibility(View.GONE); + tvError.setText(""); + } else { + tvError.setVisibility(View.VISIBLE); + tvError.setText(mCard.getError()); + } + + boolean needResendTX = LastSignStorage.getNeedTxSend(mCard.getWallet()); + + if ((mCard.getMessage() == null || mCard.getMessage().isEmpty()) && !needResendTX) { + tvMessage.setText(""); + tvMessage.setVisibility(View.GONE); + } else { + if (needResendTX) { + tvMessage.setText("Sending cached transaction..."); + } else { + tvMessage.setText(mCard.getMessage()); + } + tvMessage.setVisibility(View.VISIBLE); + } + + CoinEngine engine = CoinEngineFactory.Create(mCard.getBlockchain()); + + if (engine.HasBalanceInfo(mCard) || mCard.getOfflineBalance() == null) { + if (mCard.getBlockchain() == Blockchain.Token) { + Spanned html = Html.fromHtml(engine.GetBalanceWithAlter(mCard)); + tvBalance.setText(html); + } else { + tvBalance.setText(engine.GetBalanceWithAlter(mCard)); + } + + tvBalanceEquivalent.setText(engine.GetBalanceEquivalent(mCard)); + tvOffline.setVisibility(View.INVISIBLE); + } else { + String offlineAmount = engine.ConvertByteArrayToAmount(mCard, mCard.getOfflineBalance()); + if (mCard.getBlockchain() == Blockchain.Token) { + tvBalance.setText("NOT IMPLEMENTED"); + } else { + tvBalance.setText(engine.GetAmountDescription(mCard, offlineAmount)); + } + + tvBalanceEquivalent.setText(engine.GetAmountEqualentDescriptor(mCard, offlineAmount)); + tvOffline.setVisibility(View.VISIBLE); + } + + if (!mCard.getAmountEquivalentDescriptionAvailable()) { + //tvBalanceEquivalent.setError("Service unavailable"); + } else { + tvBalanceEquivalent.setError(null); + } + + tvWallet.setText(mCard.getWallet()); + + tvInputs.setText(mCard.getInputsDescription()); + if (mCard.getLastInputDescription().contains("awaiting")) + tvInputs.setTextColor(ContextCompat.getColor(Objects.requireNonNull(getContext()), R.color.not_confirmed)); + else if (mCard.getLastInputDescription().contains("None")) + tvInputs.setTextColor(ContextCompat.getColor(Objects.requireNonNull(getContext()), R.color.primary_dark)); + else + tvInputs.setTextColor(ContextCompat.getColor(Objects.requireNonNull(getContext()), R.color.confirmed)); + + if (tvOutputs != null) { + tvOutputs.setText(mCard.getOutputsDescription()); + } + + if (tvLastInput != null) { + tvLastInput.setText(mCard.getLastInputDescription()); + } + if (tvLastOutput != null) { + tvLastOutput.setText(mCard.getLastOutputDescription()); + } + + tvBlockchain.setText(mCard.getBlockchainName()); + ivBlockchain.setImageResource(mCard.getBlockchain().getImageResource(this.getContext(), mCard.getTokenSymbol())); + + if (tvValidationNode != null) { + tvValidationNode.setText(mCard.getValidationNodeDescription()); + } + + if (mCard.useDefaultPIN1()) { + ivPIN.setImageResource(R.drawable.unlock_pin1); + ivPIN.setOnClickListener(v -> Toast.makeText(getContext(), "This banknote is protected by default PIN1 code", Toast.LENGTH_LONG).show()); + } else { + ivPIN.setImageResource(R.drawable.lock_pin1); + ivPIN.setOnClickListener(v -> Toast.makeText(getContext(), "This banknote is protected by user's PIN1 code", Toast.LENGTH_LONG).show()); + } + + if (mCard.getPauseBeforePIN2() > 0 && (mCard.useDefaultPIN2() || !mCard.useSmartSecurityDelay())) { + ivPIN2orSecurityDelay.setImageResource(R.drawable.timer); + ivPIN2orSecurityDelay.setOnClickListener(v -> Toast.makeText(getContext(), String.format("This banknote will enforce %.0f seconds security delay for all operations requiring PIN2 code", mCard.getPauseBeforePIN2() / 1000.0), Toast.LENGTH_LONG).show()); + + } else if (mCard.useDefaultPIN2()) { + ivPIN2orSecurityDelay.setImageResource(R.drawable.unlock_pin2); + ivPIN2orSecurityDelay.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Toast.makeText(getContext(), "This banknote is protected by default PIN2 code", Toast.LENGTH_LONG).show(); + } + }); + } else { + ivPIN2orSecurityDelay.setImageResource(R.drawable.lock_pin2); + ivPIN2orSecurityDelay.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Toast.makeText(getContext(), "This banknote is protected by user's PIN2 code", Toast.LENGTH_LONG).show(); + } + }); + } + + + if (mCard.useDevelopersFirmware()) { + ivDeveloperVersion.setImageResource(R.drawable.ic_developer_version); + ivDeveloperVersion.setVisibility(View.VISIBLE); + ivDeveloperVersion.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Toast.makeText(getContext(), "Unlocked banknote, only for development use", Toast.LENGTH_LONG).show(); + } + }); + } else { + ivDeveloperVersion.setVisibility(View.INVISIBLE); + } + + if (tvSend != null) { + if (mCard.hasBalanceInfo()) { + tvSend.setEnabled(true); + } else { + tvSend.setEnabled(false); + } + } + + if (tvPurge != null) { + if (mCard.hasBalanceInfo()) { + tvPurge.setEnabled(true); + } else { + tvPurge.setEnabled(false); + } + } + + tvIssuer.setText(mCard.getIssuerDescription()); + + timerHideErrorAndMessage = new Timer(); + + + timerHideErrorAndMessage.schedule(new TimerTask() { + @Override + public void run() { + tvError.post(() -> { + tvMessage.setVisibility(View.GONE); + tvError.setVisibility(View.GONE); + mCard.setError(null); + mCard.setMessage(null); + }); + } + }, 5000); + + if (mCard.isReusable()) { + tvHeader.setText("REUSABLE WALLET"); + tvCaution.setVisibility(View.GONE); + } else { + if (mCard.getMaxSignatures() == mCard.getRemainingSignatures()) { + tvHeader.setText("BANKNOTE"); + tvCaution.setVisibility(View.GONE); + } else { + tvHeader.setText("NON-TRANSFERABLE BANKNOTE"); + tvCaution.setVisibility(View.VISIBLE); + } + } + + if (mCard.useDevelopersFirmware()) { + tvHeader.setText("DEVELOPER KIT"); + tvCaution.setVisibility(View.VISIBLE); + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + + private void doShareWallet(boolean useURI) { + if (useURI) { + String txtShare = CoinEngineFactory.Create(mCard.getBlockchain()).getShareWalletURI(mCard).toString(); + //String txtShare = Blockchain.getShareWalletURI(mCard).toString(); + Intent intent = new Intent(Intent.ACTION_SEND); + intent.setType("text/plain"); + intent.putExtra(Intent.EXTRA_SUBJECT, "Wallet address"); + intent.putExtra(Intent.EXTRA_TEXT, txtShare); + + PackageManager packageManager = getActivity().getPackageManager(); + List activities = packageManager.queryIntentActivities(intent, PackageManager.MATCH_ALL); + boolean isIntentSafe = activities.size() > 0; + + if (isIntentSafe) { + String title = "Share wallet address with:"; + // Create intent to show chooser + Intent chooser = Intent.createChooser(intent, title); + // Verify the intent will resolve to at least one activity + if (intent.resolveActivity(getActivity().getPackageManager()) != null) { + startActivity(chooser); + } + } else { + ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(CLIPBOARD_SERVICE); + clipboard.setPrimaryClip(ClipData.newPlainText(txtShare, txtShare)); + Toast.makeText(getContext(), "Copied to clipboard", Toast.LENGTH_LONG).show(); + } + } else { + String txtShare = mCard.getWallet(); + ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(CLIPBOARD_SERVICE); + clipboard.setPrimaryClip(ClipData.newPlainText(txtShare, txtShare)); + Toast.makeText(getContext(), "Copied to clipboard", Toast.LENGTH_LONG).show(); + } + } + + private void sendTransaction(String tx) { + CoinEngine engine = CoinEngineFactory.Create(mCard.getBlockchain()); + if (mCard.getBlockchain() == Blockchain.Ethereum || mCard.getBlockchain() == Blockchain.EthereumTestNet || mCard.getBlockchain() == Blockchain.Token) { + ETHRequestTask task = new ETHRequestTask(mCard.getBlockchain()); + InfuraRequest req = InfuraRequest.SendTransaction(mCard.getWallet(), tx); + req.setID(67); + req.setBlockchain(mCard.getBlockchain()); + task.execute(req); + } else if (mCard.getBlockchain() == Blockchain.Bitcoin || mCard.getBlockchain() == Blockchain.BitcoinTestNet) { + String nodeAddress = engine.GetNode(mCard); + int nodePort = engine.GetNodePort(mCard); + + UpdateWalletInfoTask connectTask = new UpdateWalletInfoTask(nodeAddress, nodePort); + connectTask.execute(ElectrumRequest.Broadcast(mCard.getWallet(), tx)); + } else if (mCard.getBlockchain() == Blockchain.BitcoinCash || mCard.getBlockchain() == Blockchain.BitcoinCashTestNet) { + String nodeAddress = engine.GetNode(mCard); + int nodePort = engine.GetNodePort(mCard); + + UpdateWalletInfoTask connectTask = new UpdateWalletInfoTask(nodeAddress, nodePort); + connectTask.execute(ElectrumRequest.Broadcast(mCard.getWallet(), tx)); + } + } + + private void startSwapPINActivity() { + Intent intent = new Intent(getContext(), SwapPINActivity.class); + intent.putExtra("UID", mCard.getUID()); + intent.putExtra("Card", mCard.getAsBundle()); + intent.putExtra("newPIN", newPIN); + intent.putExtra("newPIN2", newPIN2); + startActivityForResult(intent, REQUEST_CODE_SWAP_PIN); + } + + private static Bitmap generateQrCode(String myCodeText) throws WriterException { + Hashtable hintMap = new Hashtable(); + hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H); // H = 30% damage + + QRCodeWriter qrCodeWriter = new QRCodeWriter(); + + int size = 256; + + BitMatrix bitMatrix = qrCodeWriter.encode(myCodeText, BarcodeFormat.QR_CODE, size, size, hintMap); + int width = bitMatrix.getWidth(); + Bitmap bmp = Bitmap.createBitmap(width, width, Bitmap.Config.RGB_565); + for (int x = 0; x < width; x++) { + for (int y = 0; y < width; y++) { + bmp.setPixel(y, x, bitMatrix.get(x, y) ? Color.BLACK : Color.WHITE); + } + } + return bmp; + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/tangem/presentation/fragment/MainFragment.java b/app/src/main/java/com/tangem/presentation/fragment/Main.java similarity index 99% rename from app/src/main/java/com/tangem/presentation/fragment/MainFragment.java rename to app/src/main/java/com/tangem/presentation/fragment/Main.java index 068ff29e02..b23bbf5d86 100644 --- a/app/src/main/java/com/tangem/presentation/fragment/MainFragment.java +++ b/app/src/main/java/com/tangem/presentation/fragment/Main.java @@ -67,14 +67,14 @@ import java.util.Objects; /** * A placeholder fragment containing a simple view. */ -public class MainFragment extends Fragment implements NfcAdapter.ReaderCallback, CardListAdapter.UiCallbacks, CardProtocol.Notifications, MainActivity.OnCardsClean { +public class Main extends Fragment implements NfcAdapter.ReaderCallback, CardListAdapter.UiCallbacks, CardProtocol.Notifications, MainActivity.OnCardsClean { private static final int REQUEST_CODE_SHOW_CARD_ACTIVITY = 1; private static final int REQUEST_CODE_ENTER_PIN_ACTIVITY = 2; private static final int REQUEST_CODE_REQUEST_CAMERA_PERMISSIONS = 3; private NfcManager mNfcManager; private ArrayList slCardUIDs = new ArrayList<>(); - private static final String logTag = "MainFragment"; + private static final String logTag = "Main"; private ProgressBar progressBar; private CardListAdapter mCardListAdapter; @@ -87,7 +87,7 @@ public class MainFragment extends Fragment implements NfcAdapter.ReaderCallback, private SwipeRefreshLayout mSwipeRefreshLayout; //TODO: tmp List requestTasks = new ArrayList<>(); - public MainFragment() { + public Main() { } // @Override diff --git a/app/src/main/java/com/tangem/presentation/fragment/VerifyCardFragment.java b/app/src/main/java/com/tangem/presentation/fragment/VerifyCard.java similarity index 98% rename from app/src/main/java/com/tangem/presentation/fragment/VerifyCardFragment.java rename to app/src/main/java/com/tangem/presentation/fragment/VerifyCard.java index a76b6501c6..28786a2318 100644 --- a/app/src/main/java/com/tangem/presentation/fragment/VerifyCardFragment.java +++ b/app/src/main/java/com/tangem/presentation/fragment/VerifyCard.java @@ -23,7 +23,7 @@ import java.io.IOException; import java.util.Timer; import java.util.TimerTask; -public class VerifyCardFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener, NfcAdapter.ReaderCallback { +public class VerifyCard extends Fragment implements SwipeRefreshLayout.OnRefreshListener, NfcAdapter.ReaderCallback { TangemCard mCard; TextView tvCardID, tvManufacturer, tvRegistrationDate, tvCardIdentity, tvLastSigned, tvRemainingSignatures, tvReusable, tvOk, tvError, tvMessage, @@ -32,7 +32,7 @@ public class VerifyCardFragment extends Fragment implements SwipeRefreshLayout.O SwipeRefreshLayout mSwipeRefreshLayout; private NfcManager mNfcManager; - public VerifyCardFragment() { + public VerifyCard() { } diff --git a/app/src/main/java/com/tangem/presentation/fragment/WalletInfoFragment.java b/app/src/main/java/com/tangem/presentation/fragment/WalletInfo.java similarity index 93% rename from app/src/main/java/com/tangem/presentation/fragment/WalletInfoFragment.java rename to app/src/main/java/com/tangem/presentation/fragment/WalletInfo.java index c6bed94eee..f3ad22b70e 100644 --- a/app/src/main/java/com/tangem/presentation/fragment/WalletInfoFragment.java +++ b/app/src/main/java/com/tangem/presentation/fragment/WalletInfo.java @@ -32,17 +32,17 @@ import static android.content.Context.CLIPBOARD_SERVICE; * Activities that contain this fragment must implement the * {@link OnFragmentInteractionListener} interface * to handle interaction events. - * Use the {@link WalletInfoFragment#newInstance} factory method to + * Use the {@link WalletInfo#newInstance} factory method to * create an instance of this fragment. */ -public class WalletInfoFragment extends Fragment { +public class WalletInfo extends Fragment { // TODO: Rename and change types of parameters private TangemCard mCard; private OnFragmentInteractionListener mListener; - public WalletInfoFragment() { + public WalletInfo() { // Required empty public constructor } @@ -50,11 +50,11 @@ public class WalletInfoFragment extends Fragment { * Use this factory method to create a new instance of * this fragment using the provided parameters. * - * @return A new instance of fragment WalletInfoFragment. + * @return A new instance of fragment WalletInfo. */ // TODO: Rename and change types and number of parameters - public static WalletInfoFragment newInstance(TangemCard card) { - WalletInfoFragment fragment = new WalletInfoFragment(); + public static WalletInfo newInstance(TangemCard card) { + WalletInfo fragment = new WalletInfo(); Bundle args = new Bundle(); args.putString("UID",card.getUID()); card.SaveToBundle(args); diff --git a/app/src/main/res/layout/activity_loaded_wallet.xml b/app/src/main/res/layout/activity_loaded_wallet.xml index 61d97cb3b8..d5b6f2afa2 100644 --- a/app/src/main/res/layout/activity_loaded_wallet.xml +++ b/app/src/main/res/layout/activity_loaded_wallet.xml @@ -21,9 +21,7 @@ + layout="@layout/content_loaded_wallet"/> @@ -33,4 +31,4 @@ - + \ No newline at end of file diff --git a/app/src/main/res/layout/content_loaded_wallet.xml b/app/src/main/res/layout/content_loaded_wallet.xml index 5bdbfab5b8..1bd85f9209 100644 --- a/app/src/main/res/layout/content_loaded_wallet.xml +++ b/app/src/main/res/layout/content_loaded_wallet.xml @@ -3,7 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/loaded_wallet_fragment" - android:name="com.tangem.presentation.fragment.LoadedWalletFragment" + android:name="com.tangem.presentation.fragment.LoadedWallet" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" diff --git a/app/src/main/res/layout/content_main.xml b/app/src/main/res/layout/content_main.xml index eeb1a58952..6098a522ac 100644 --- a/app/src/main/res/layout/content_main.xml +++ b/app/src/main/res/layout/content_main.xml @@ -3,7 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/fragmentMain" - android:name="com.tangem.presentation.fragment.MainFragment" + android:name="com.tangem.presentation.fragment.Main" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" diff --git a/app/src/main/res/layout/content_verify_card.xml b/app/src/main/res/layout/content_verify_card.xml index 34488eeec3..04b43bbca9 100644 --- a/app/src/main/res/layout/content_verify_card.xml +++ b/app/src/main/res/layout/content_verify_card.xml @@ -3,7 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/verify_card_fragment" - android:name="com.tangem.presentation.fragment.VerifyCardFragment" + android:name="com.tangem.presentation.fragment.VerifyCard" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" diff --git a/app/src/main/res/layout/fr_loaded_wallet.xml b/app/src/main/res/layout/fr_loaded_wallet.xml index 2ae5608fad..e356f053d3 100644 --- a/app/src/main/res/layout/fr_loaded_wallet.xml +++ b/app/src/main/res/layout/fr_loaded_wallet.xml @@ -8,7 +8,7 @@ android:background="@color/white" android:orientation="vertical" android:padding="0dp" - tools:context="com.tangem.presentation.fragment.LoadedWalletFragment" + tools:context="com.tangem.presentation.fragment.LoadedWallet" tools:showIn="@layout/activity_loaded_wallet"> @@ -534,7 +533,6 @@ android:layout_toLeftOf="@+id/tvPurge" android:layout_weight="1" android:background="@color/colorPrimary" - android:capitalize="none" android:fontFamily="@font/raleway_r" android:padding="8dp" android:text="SEND" @@ -552,7 +550,6 @@ android:layout_weight="12" android:background="@drawable/ic_show_menu" android:backgroundTint="@color/colorPrimaryDark" - android:capitalize="none" android:fontFamily="@font/raleway_r" android:padding="8dp" android:textAlignment="center" diff --git a/app/src/main/res/layout/fr_main.xml b/app/src/main/res/layout/fr_main.xml index 1279b8ee9c..1f6aeafad3 100644 --- a/app/src/main/res/layout/fr_main.xml +++ b/app/src/main/res/layout/fr_main.xml @@ -5,7 +5,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - tools:context="com.tangem.presentation.fragment.MainFragment" + tools:context="com.tangem.presentation.fragment.Main" tools:showIn="@layout/content_main"> diff --git a/app/src/main/res/layout/fr_verify_card.xml b/app/src/main/res/layout/fr_verify_card.xml index c814bfb5a9..ba802c7447 100644 --- a/app/src/main/res/layout/fr_verify_card.xml +++ b/app/src/main/res/layout/fr_verify_card.xml @@ -8,7 +8,7 @@ android:background="@color/white" android:orientation="vertical" android:padding="0dp" - tools:context="com.tangem.presentation.fragment.VerifyCardFragment" + tools:context="com.tangem.presentation.fragment.VerifyCard" tools:showIn="@layout/activity_verify_card"> Reset PINs to default Erase wallet - + Tap Tangem card with your smartphone Scan a banknote with your \n smartphone as shown above Try to scan again @@ -69,6 +69,13 @@   BANKNOTE        BANKNOTE    REUSABLE       REUSABLE    + + The wallet is empty + Not enough funds for transaction fee (gas)! + Please wait while previous transaction is confirmed in blockchain + Please wait for confirmation of incoming transaction! + Card hasn\'t remaining signature! + BETA Smart Cash AG