List of usage examples for java.math BigInteger signum
int signum
To view the source code for java.math BigInteger signum.
Click Source Link
From source file:com.feathercoin.wallet.feathercoin.ui.TransactionsListFragment.java
@Override public void onListItemClick(final ListView l, final View v, final int position, final long id) { final Transaction tx = (Transaction) adapter.getItem(position); activity.startActionMode(new ActionMode.Callback() { private Address address; public boolean onCreateActionMode(final ActionMode mode, final Menu menu) { final MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.wallet_transactions_context, menu); menu.findItem(R.id.wallet_transactions_context_show_transaction) .setVisible(prefs.getBoolean(Constants.PREFS_KEY_LABS_TRANSACTION_DETAILS, false)); return true; }//from w w w. j av a2 s .c o m public boolean onPrepareActionMode(final ActionMode mode, final Menu menu) { try { final Date time = tx.getUpdateTime(); final DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(activity); final DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(activity); mode.setTitle(time != null ? (DateUtils.isToday(time.getTime()) ? getString(R.string.time_today) : dateFormat.format(time)) + ", " + timeFormat.format(time) : null); final BigInteger value = tx.getValue(wallet); final boolean sent = value.signum() < 0; address = sent ? WalletUtils.getToAddress(tx) : WalletUtils.getFromAddress(tx); final String label; if (tx.isCoinBase()) label = getString(R.string.wallet_transactions_fragment_coinbase); else if (address != null) label = AddressBookProvider.resolveLabel(activity, address.toString()); else label = "?"; final String prefix = getString(sent ? R.string.symbol_to : R.string.symbol_from) + " "; mode.setSubtitle(label != null ? prefix + label : WalletUtils.formatAddress(prefix, address, Constants.ADDRESS_FORMAT_GROUP_SIZE, Constants.ADDRESS_FORMAT_LINE_SIZE)); menu.findItem(R.id.wallet_transactions_context_edit_address).setVisible(address != null); return true; } catch (final ScriptException x) { return false; } } public boolean onActionItemClicked(final ActionMode mode, final MenuItem item) { switch (item.getItemId()) { case R.id.wallet_transactions_context_edit_address: handleEditAddress(tx); mode.finish(); return true; case R.id.wallet_transactions_context_show_transaction: TransactionActivity.show(activity, tx); mode.finish(); return true; } return false; } public void onDestroyActionMode(final ActionMode mode) { } private void handleEditAddress(final Transaction tx) { EditAddressBookEntryFragment.edit(getFragmentManager(), address.toString()); } }); }
From source file:de.schildbach.wallet.ui.TransactionsListFragment.java
private void handleTransactionClick(final Transaction tx) { activity.startActionMode(new ActionMode.Callback() { private Address address; public boolean onCreateActionMode(final ActionMode mode, final Menu menu) { final MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.wallet_transactions_context, menu); menu.findItem(R.id.wallet_transactions_context_show_transaction) .setVisible(prefs.getBoolean(Constants.PREFS_KEY_LABS_TRANSACTION_DETAILS, false)); return true; }//from w w w . ja v a 2 s .c om public boolean onPrepareActionMode(final ActionMode mode, final Menu menu) { try { final Date time = tx.getUpdateTime(); final DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(activity); final DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(activity); mode.setTitle(time != null ? (DateUtils.isToday(time.getTime()) ? getString(R.string.time_today) : dateFormat.format(time)) + ", " + timeFormat.format(time) : null); final BigInteger value = tx.getValue(wallet); final boolean sent = value.signum() < 0; address = sent ? WalletUtils.getToAddress(tx) : WalletUtils.getFromAddress(tx); final String label; if (tx.isCoinBase()) label = getString(R.string.wallet_transactions_fragment_coinbase); else if (address != null) label = AddressBookProvider.resolveLabel(activity, address.toString()); else label = "?"; final String prefix = getString(sent ? R.string.symbol_to : R.string.symbol_from) + " "; mode.setSubtitle(label != null ? prefix + label : WalletUtils.formatAddress(prefix, address, Constants.ADDRESS_FORMAT_GROUP_SIZE, Constants.ADDRESS_FORMAT_LINE_SIZE)); menu.findItem(R.id.wallet_transactions_context_edit_address).setVisible(address != null); return true; } catch (final ScriptException x) { return false; } } public boolean onActionItemClicked(final ActionMode mode, final MenuItem item) { switch (item.getItemId()) { case R.id.wallet_transactions_context_edit_address: handleEditAddress(tx); mode.finish(); return true; case R.id.wallet_transactions_context_show_transaction: TransactionActivity.show(activity, tx); mode.finish(); return true; } return false; } public void onDestroyActionMode(final ActionMode mode) { } private void handleEditAddress(final Transaction tx) { EditAddressBookEntryFragment.edit(getFragmentManager(), address.toString()); } }); }
From source file:piuk.blockchain.android.ui.TransactionFragment.java
public void update(final MyTransaction tx) { final MyRemoteWallet wallet = ((WalletApplication) activity.getApplication()).getRemoteWallet(); final byte[] serializedTx = tx.unsafeBitcoinSerialize(); Address from = null;/*from w ww .java 2 s. com*/ boolean fromMine = false; try { from = tx.getInputs().get(0).getFromAddress(); fromMine = wallet.isMine(from.toString()); } catch (final ScriptException x) { x.printStackTrace(); } Address to = null; boolean toMine = false; try { to = tx.getOutputs().get(0).getScriptPubKey().getToAddress(); toMine = wallet.isMine(to.toString()); } catch (final ScriptException x) { x.printStackTrace(); } final ContentResolver contentResolver = activity.getContentResolver(); final View view = getView(); final Date time = tx.getUpdateTime(); view.findViewById(R.id.transaction_fragment_time_row) .setVisibility(time != null ? View.VISIBLE : View.GONE); if (time != null) { final TextView viewDate = (TextView) view.findViewById(R.id.transaction_fragment_time); viewDate.setText( (DateUtils.isToday(time.getTime()) ? getString(R.string.transaction_fragment_time_today) : dateFormat.format(time)) + ", " + timeFormat.format(time)); } final BigInteger amountSent = tx.getResult(); view.findViewById(R.id.transaction_fragment_amount_sent_row) .setVisibility(amountSent.signum() != 0 ? View.VISIBLE : View.GONE); if (amountSent.signum() != 0) { final TextView viewAmountSent = (TextView) view.findViewById(R.id.transaction_fragment_amount_sent); viewAmountSent.setText(Constants.CURRENCY_MINUS_SIGN + WalletUtils.formatValue(amountSent)); } final BigInteger amountReceived = tx.getResult(); view.findViewById(R.id.transaction_fragment_amount_received_row) .setVisibility(amountReceived.signum() != 0 ? View.VISIBLE : View.GONE); if (amountReceived.signum() != 0) { final TextView viewAmountReceived = (TextView) view .findViewById(R.id.transaction_fragment_amount_received); viewAmountReceived.setText(Constants.CURRENCY_PLUS_SIGN + WalletUtils.formatValue(amountReceived)); } final View viewFromButton = view.findViewById(R.id.transaction_fragment_from_button); final TextView viewFromLabel = (TextView) view.findViewById(R.id.transaction_fragment_from_label); if (from != null) { String label = null; if (tx instanceof MyTransaction && ((MyTransaction) tx).getTag() != null) label = ((MyTransaction) tx).getTag(); else label = AddressBookProvider.resolveLabel(contentResolver, from.toString()); final StringBuilder builder = new StringBuilder(); if (fromMine) builder.append(getString(R.string.transaction_fragment_you)).append(", "); if (label != null) { builder.append(label); } else { builder.append(from.toString()); viewFromLabel.setTypeface(Typeface.MONOSPACE); } viewFromLabel.setText(builder.toString()); final String addressStr = from.toString(); viewFromButton.setOnClickListener(new OnClickListener() { public void onClick(final View v) { EditAddressBookEntryFragment.edit(getFragmentManager(), addressStr); } }); } else { viewFromLabel.setText(null); } final View viewToButton = view.findViewById(R.id.transaction_fragment_to_button); final TextView viewToLabel = (TextView) view.findViewById(R.id.transaction_fragment_to_label); if (to != null) { String label = null; if (tx instanceof MyTransaction && ((MyTransaction) tx).getTag() != null) label = ((MyTransaction) tx).getTag(); else label = AddressBookProvider.resolveLabel(contentResolver, from.toString()); final StringBuilder builder = new StringBuilder(); if (toMine) builder.append(getString(R.string.transaction_fragment_you)).append(", "); if (label != null) { builder.append(label); } else { builder.append(to.toString()); viewToLabel.setTypeface(Typeface.MONOSPACE); } viewToLabel.setText(builder.toString()); final String addressStr = to.toString(); viewToButton.setOnClickListener(new OnClickListener() { public void onClick(final View v) { EditAddressBookEntryFragment.edit(getFragmentManager(), addressStr); } }); } else { viewToLabel.setText(null); } final TextView viewStatus = (TextView) view.findViewById(R.id.transaction_fragment_status); final ConfidenceType confidenceType = tx.getConfidence().getConfidenceType(); if (confidenceType == ConfidenceType.DEAD || confidenceType == ConfidenceType.NOT_IN_BEST_CHAIN) viewStatus.setText(R.string.transaction_fragment_status_dead); else if (confidenceType == ConfidenceType.NOT_SEEN_IN_CHAIN) viewStatus.setText(R.string.transaction_fragment_status_pending); else if (confidenceType == ConfidenceType.BUILDING) viewStatus.setText(R.string.transaction_fragment_status_confirmed); else viewStatus.setText(R.string.transaction_fragment_status_unknown); final TextView viewHash = (TextView) view.findViewById(R.id.transaction_fragment_hash); viewHash.setText(tx.getHash().toString()); final TextView viewLength = (TextView) view.findViewById(R.id.transaction_fragment_length); viewLength.setText(Integer.toString(serializedTx.length)); final ImageView viewQr = (ImageView) view.findViewById(R.id.transaction_fragment_qr); try { // encode transaction URI final ByteArrayOutputStream bos = new ByteArrayOutputStream(serializedTx.length); final GZIPOutputStream gos = new GZIPOutputStream(bos); gos.write(serializedTx); gos.close(); final byte[] gzippedSerializedTx = bos.toByteArray(); final boolean useCompressioon = gzippedSerializedTx.length < serializedTx.length; final StringBuilder txStr = new StringBuilder("btctx:"); txStr.append(useCompressioon ? 'Z' : '-'); txStr.append(Base43.encode(useCompressioon ? gzippedSerializedTx : serializedTx)); final Bitmap qrCodeBitmap = WalletUtils.getQRCodeBitmap(txStr.toString().toUpperCase(), 512); viewQr.setImageBitmap(qrCodeBitmap); viewQr.setOnClickListener(new OnClickListener() { public void onClick(final View v) { new QrDialog(activity, qrCodeBitmap).show(); } }); } catch (final IOException x) { throw new RuntimeException(x); } }
From source file:de.schildbach.wallet.ui.TransactionFragment.java
public void update(final Transaction tx) { final Wallet wallet = ((WalletApplication) activity.getApplication()).getWallet(); final byte[] serializedTx = tx.unsafeBitcoinSerialize(); Address from = null;/* w w w .ja va2 s.co m*/ boolean fromMine = false; try { from = tx.getInputs().get(0).getFromAddress(); fromMine = wallet.isPubKeyHashMine(from.getHash160()); } catch (final ScriptException x) { x.printStackTrace(); } Address to = null; boolean toMine = false; try { to = tx.getOutputs().get(0).getScriptPubKey().getToAddress(); toMine = wallet.isPubKeyHashMine(to.getHash160()); } catch (final ScriptException x) { x.printStackTrace(); } final ContentResolver contentResolver = activity.getContentResolver(); final View view = getView(); final Date time = tx.getUpdateTime(); view.findViewById(R.id.transaction_fragment_time_row) .setVisibility(time != null ? View.VISIBLE : View.GONE); if (time != null) { final TextView viewDate = (TextView) view.findViewById(R.id.transaction_fragment_time); viewDate.setText( (DateUtils.isToday(time.getTime()) ? getString(R.string.time_today) : dateFormat.format(time)) + ", " + timeFormat.format(time)); } try { final BigInteger amountSent = tx.getValueSentFromMe(wallet); view.findViewById(R.id.transaction_fragment_amount_sent_row) .setVisibility(amountSent.signum() != 0 ? View.VISIBLE : View.GONE); if (amountSent.signum() != 0) { final TextView viewAmountSent = (TextView) view.findViewById(R.id.transaction_fragment_amount_sent); viewAmountSent.setText(Constants.CURRENCY_MINUS_SIGN + WalletUtils.formatValue(amountSent)); } } catch (final ScriptException x) { x.printStackTrace(); } final BigInteger amountReceived = tx.getValueSentToMe(wallet); view.findViewById(R.id.transaction_fragment_amount_received_row) .setVisibility(amountReceived.signum() != 0 ? View.VISIBLE : View.GONE); if (amountReceived.signum() != 0) { final TextView viewAmountReceived = (TextView) view .findViewById(R.id.transaction_fragment_amount_received); viewAmountReceived.setText(Constants.CURRENCY_PLUS_SIGN + WalletUtils.formatValue(amountReceived)); } final View viewFromButton = view.findViewById(R.id.transaction_fragment_from_button); final TextView viewFromLabel = (TextView) view.findViewById(R.id.transaction_fragment_from_label); if (from != null) { final String label = AddressBookProvider.resolveLabel(contentResolver, from.toString()); final StringBuilder builder = new StringBuilder(); if (fromMine) builder.append(getString(R.string.transaction_fragment_you)).append(", "); if (label != null) { builder.append(label); } else { builder.append(from.toString()); viewFromLabel.setTypeface(Typeface.MONOSPACE); } viewFromLabel.setText(builder.toString()); final String addressStr = from.toString(); viewFromButton.setOnClickListener(new OnClickListener() { public void onClick(final View v) { EditAddressBookEntryFragment.edit(getFragmentManager(), addressStr); } }); } else { viewFromLabel.setText(null); } final View viewToButton = view.findViewById(R.id.transaction_fragment_to_button); final TextView viewToLabel = (TextView) view.findViewById(R.id.transaction_fragment_to_label); if (to != null) { final String label = AddressBookProvider.resolveLabel(contentResolver, to.toString()); final StringBuilder builder = new StringBuilder(); if (toMine) builder.append(getString(R.string.transaction_fragment_you)).append(", "); if (label != null) { builder.append(label); } else { builder.append(to.toString()); viewToLabel.setTypeface(Typeface.MONOSPACE); } viewToLabel.setText(builder.toString()); final String addressStr = to.toString(); viewToButton.setOnClickListener(new OnClickListener() { public void onClick(final View v) { EditAddressBookEntryFragment.edit(getFragmentManager(), addressStr); } }); } else { viewToLabel.setText(null); } final TextView viewStatus = (TextView) view.findViewById(R.id.transaction_fragment_status); final ConfidenceType confidenceType = tx.getConfidence().getConfidenceType(); if (confidenceType == ConfidenceType.DEAD || confidenceType == ConfidenceType.NOT_IN_BEST_CHAIN) viewStatus.setText(R.string.transaction_fragment_status_dead); else if (confidenceType == ConfidenceType.NOT_SEEN_IN_CHAIN) viewStatus.setText(R.string.transaction_fragment_status_pending); else if (confidenceType == ConfidenceType.BUILDING) viewStatus.setText(R.string.transaction_fragment_status_confirmed); else viewStatus.setText(R.string.transaction_fragment_status_unknown); final TextView viewHash = (TextView) view.findViewById(R.id.transaction_fragment_hash); viewHash.setText(tx.getHash().toString()); final TextView viewLength = (TextView) view.findViewById(R.id.transaction_fragment_length); viewLength.setText(Integer.toString(serializedTx.length)); final ImageView viewQr = (ImageView) view.findViewById(R.id.transaction_fragment_qr); try { // encode transaction URI final ByteArrayOutputStream bos = new ByteArrayOutputStream(serializedTx.length); final GZIPOutputStream gos = new GZIPOutputStream(bos); gos.write(serializedTx); gos.close(); final byte[] gzippedSerializedTx = bos.toByteArray(); final boolean useCompressioon = gzippedSerializedTx.length < serializedTx.length; final StringBuilder txStr = new StringBuilder("btctx:"); txStr.append(useCompressioon ? 'Z' : '-'); txStr.append(Base43.encode(useCompressioon ? gzippedSerializedTx : serializedTx)); final Bitmap qrCodeBitmap = WalletUtils.getQRCodeBitmap(txStr.toString().toUpperCase(Locale.US), 512); viewQr.setImageBitmap(qrCodeBitmap); viewQr.setOnClickListener(new OnClickListener() { public void onClick(final View v) { BitmapFragment.show(getFragmentManager(), qrCodeBitmap); } }); } catch (final IOException x) { throw new RuntimeException(x); } }
From source file:hashengineering.digitalcoin.wallet.ui.TransactionsListFragment.java
private void handleTransactionClick(@Nonnull final Transaction tx) { activity.startActionMode(new ActionMode.Callback() { private Address address; private byte[] serializedTx; private static final int SHOW_QR_THRESHOLD_BYTES = 2500; @Override/*from w ww.jav a 2 s.c o m*/ public boolean onCreateActionMode(final ActionMode mode, final Menu menu) { final MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.wallet_transactions_context, menu); return true; } @Override public boolean onPrepareActionMode(final ActionMode mode, final Menu menu) { try { final Date time = tx.getUpdateTime(); final DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(activity); final DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(activity); mode.setTitle(time != null ? (DateUtils.isToday(time.getTime()) ? getString(R.string.time_today) : dateFormat.format(time)) + ", " + timeFormat.format(time) : null); final BigInteger value = tx.getValue(wallet); final boolean sent = value.signum() < 0; address = sent ? WalletUtils.getToAddress(tx) : WalletUtils.getFromAddress(tx); final String label; if (tx.isCoinBase()) label = getString(R.string.wallet_transactions_fragment_coinbase); else if (address != null) label = AddressBookProvider.resolveLabel(activity, address.toString()); else label = "?"; final String prefix = getString(sent ? R.string.symbol_to : R.string.symbol_from) + " "; if (tx.getPurpose() != Purpose.KEY_ROTATION) mode.setSubtitle(label != null ? prefix + label : WalletUtils.formatAddress(prefix, address, Constants.ADDRESS_FORMAT_GROUP_SIZE, Constants.ADDRESS_FORMAT_LINE_SIZE)); else mode.setSubtitle(null); menu.findItem(R.id.wallet_transactions_context_edit_address).setVisible(address != null); serializedTx = tx.unsafeBitcoinSerialize(); menu.findItem(R.id.wallet_transactions_context_show_qr) .setVisible(serializedTx.length < SHOW_QR_THRESHOLD_BYTES); Nfc.publishMimeObject(nfcManager, activity, Constants.MIMETYPE_TRANSACTION, serializedTx, false); return true; } catch (final ScriptException x) { return false; } } @Override public boolean onActionItemClicked(final ActionMode mode, final MenuItem item) { switch (item.getItemId()) { case R.id.wallet_transactions_context_edit_address: handleEditAddress(tx); mode.finish(); return true; case R.id.wallet_transactions_context_show_qr: handleShowQr(); mode.finish(); return true; case R.id.wallet_transactions_context_open_blockexplorer: startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.BLOCKEXPLORER_BASE_URL + "tx/" + tx.getHashAsString()))); mode.finish(); return true; } return false; } @Override public void onDestroyActionMode(final ActionMode mode) { Nfc.unpublish(nfcManager, activity); } private void handleEditAddress(@Nonnull final Transaction tx) { EditAddressBookEntryFragment.edit(getFragmentManager(), address.toString()); } private void handleShowQr() { final int size = (int) (384 * getResources().getDisplayMetrics().density); final Bitmap qrCodeBitmap = Qr.bitmap(Qr.encodeBinary(serializedTx), size); BitmapFragment.show(getFragmentManager(), qrCodeBitmap); } }); }
From source file:com.guldencoin.androidwallet.nlg.ui.TransactionsListFragment.java
private void handleTransactionClick(@Nonnull final Transaction tx) { activity.startActionMode(new ActionMode.Callback() { private Address address; private byte[] serializedTx; private static final int SHOW_QR_THRESHOLD_BYTES = 2500; @Override/*from www .j av a2 s .co m*/ public boolean onCreateActionMode(final ActionMode mode, final Menu menu) { final MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.wallet_transactions_context, menu); return true; } @Override public boolean onPrepareActionMode(final ActionMode mode, final Menu menu) { try { final Date time = tx.getUpdateTime(); final DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(activity); final DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(activity); mode.setTitle(time != null ? (DateUtils.isToday(time.getTime()) ? getString(R.string.time_today) : dateFormat.format(time)) + ", " + timeFormat.format(time) : null); final BigInteger value = tx.getValue(wallet); final boolean sent = value.signum() < 0; address = sent ? WalletUtils.getFirstToAddress(tx) : WalletUtils.getFirstFromAddress(tx); final String label; if (tx.isCoinBase()) label = getString(R.string.wallet_transactions_fragment_coinbase); else if (address != null) label = AddressBookProvider.resolveLabel(activity, address.toString()); else label = "?"; final String prefix = getString(sent ? R.string.symbol_to : R.string.symbol_from) + " "; if (tx.getPurpose() != Purpose.KEY_ROTATION) mode.setSubtitle(label != null ? prefix + label : WalletUtils.formatAddress(prefix, address, Constants.ADDRESS_FORMAT_GROUP_SIZE, Constants.ADDRESS_FORMAT_LINE_SIZE)); else mode.setSubtitle(null); menu.findItem(R.id.wallet_transactions_context_edit_address).setVisible(address != null); serializedTx = tx.unsafeBitcoinSerialize(); menu.findItem(R.id.wallet_transactions_context_show_qr) .setVisible(serializedTx.length < SHOW_QR_THRESHOLD_BYTES); Nfc.publishMimeObject(nfcManager, activity, Constants.MIMETYPE_TRANSACTION, serializedTx, false); return true; } catch (final ScriptException x) { return false; } } @Override public boolean onActionItemClicked(final ActionMode mode, final MenuItem item) { switch (item.getItemId()) { case R.id.wallet_transactions_context_edit_address: handleEditAddress(tx); mode.finish(); return true; case R.id.wallet_transactions_context_show_qr: handleShowQr(); mode.finish(); return true; case R.id.wallet_transactions_context_browse: startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.EXPLORE_BASE_URL + "tx/" + tx.getHashAsString()))); mode.finish(); return true; } return false; } @Override public void onDestroyActionMode(final ActionMode mode) { Nfc.unpublish(nfcManager, activity); } private void handleEditAddress(@Nonnull final Transaction tx) { EditAddressBookEntryFragment.edit(getFragmentManager(), address.toString()); } private void handleShowQr() { final int size = (int) (384 * getResources().getDisplayMetrics().density); final Bitmap qrCodeBitmap = Qr.bitmap(Qr.encodeCompressBinary(serializedTx), size); BitmapFragment.show(getFragmentManager(), qrCodeBitmap); } }); }
From source file:devcoin.wallet.ui.TransactionsListFragment.java
private void handleTransactionClick(@Nonnull final Transaction tx) { activity.startActionMode(new ActionMode.Callback() { private Address address; private byte[] serializedTx; private static final int SHOW_QR_THRESHOLD_BYTES = 2500; @Override/*w w w . j a v a2 s. co m*/ public boolean onCreateActionMode(final ActionMode mode, final Menu menu) { final MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.wallet_transactions_context, menu); return true; } @Override public boolean onPrepareActionMode(final ActionMode mode, final Menu menu) { try { final Date time = tx.getUpdateTime(); final DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(activity); final DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(activity); mode.setTitle(time != null ? (DateUtils.isToday(time.getTime()) ? getString(R.string.time_today) : dateFormat.format(time)) + ", " + timeFormat.format(time) : null); final BigInteger value = tx.getValue(wallet); final boolean sent = value.signum() < 0; address = sent ? WalletUtils.getFirstToAddress(tx) : WalletUtils.getFirstFromAddress(tx); final String label; if (tx.isCoinBase()) label = getString(R.string.wallet_transactions_fragment_coinbase); else if (address != null) label = AddressBookProvider.resolveLabel(activity, address.toString()); else label = "?"; final String prefix = getString(sent ? R.string.symbol_to : R.string.symbol_from) + " "; if (tx.getPurpose() != Purpose.KEY_ROTATION) mode.setSubtitle(label != null ? prefix + label : WalletUtils.formatAddress(prefix, address, Constants.ADDRESS_FORMAT_GROUP_SIZE, Constants.ADDRESS_FORMAT_LINE_SIZE)); else mode.setSubtitle(null); menu.findItem(R.id.wallet_transactions_context_edit_address).setVisible(address != null); serializedTx = tx.unsafeBitcoinSerialize(); menu.findItem(R.id.wallet_transactions_context_show_qr) .setVisible(serializedTx.length < SHOW_QR_THRESHOLD_BYTES); Nfc.publishMimeObject(nfcManager, activity, Constants.MIMETYPE_TRANSACTION, serializedTx, false); return true; } catch (final ScriptException x) { return false; } } @Override public boolean onActionItemClicked(final ActionMode mode, final MenuItem item) { switch (item.getItemId()) { case R.id.wallet_transactions_context_edit_address: handleEditAddress(tx); mode.finish(); return true; case R.id.wallet_transactions_context_show_qr: handleShowQr(); mode.finish(); return true; case R.id.wallet_transactions_context_browse: startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.EXPLORE_BASE_URL + "tx/" + tx.getHashAsString()))); mode.finish(); return true; } return false; } @Override public void onDestroyActionMode(final ActionMode mode) { Nfc.unpublish(nfcManager, activity); } private void handleEditAddress(@Nonnull final Transaction tx) { EditAddressBookEntryFragment.edit(getFragmentManager(), address.toString()); } private void handleShowQr() { final int size = (int) (384 * getResources().getDisplayMetrics().density); final Bitmap qrCodeBitmap = Qr.bitmap(Qr.encodeBinary(serializedTx), size); BitmapFragment.show(getFragmentManager(), qrCodeBitmap); } }); }
From source file:com.bushstar.htmlcoin_android_wallet.ui.TransactionsListFragment.java
private void handleTransactionClick(@Nonnull final Transaction tx) { activity.startActionMode(new ActionMode.Callback() { private Address address; private byte[] serializedTx; private static final int SHOW_QR_THRESHOLD_BYTES = 2500; @Override//from ww w.j a v a 2 s .co m public boolean onCreateActionMode(final ActionMode mode, final Menu menu) { final MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.wallet_transactions_context, menu); return true; } @Override public boolean onPrepareActionMode(final ActionMode mode, final Menu menu) { try { final Date time = tx.getUpdateTime(); final DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(activity); final DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(activity); mode.setTitle(time != null ? (DateUtils.isToday(time.getTime()) ? getString(R.string.time_today) : dateFormat.format(time)) + ", " + timeFormat.format(time) : null); final BigInteger value = tx.getValue(wallet); final boolean sent = value.signum() < 0; address = sent ? WalletUtils.getFirstToAddress(tx) : WalletUtils.getFirstFromAddress(tx); final String label; if (tx.isCoinBase()) label = getString(R.string.wallet_transactions_fragment_coinbase); else if (address != null) label = AddressBookProvider.resolveLabel(activity, address.toString()); else label = "?"; final String prefix = getString(sent ? R.string.symbol_to : R.string.symbol_from) + " "; if (tx.getPurpose() != Purpose.KEY_ROTATION) mode.setSubtitle(label != null ? prefix + label : WalletUtils.formatAddress(prefix, address, Constants.ADDRESS_FORMAT_GROUP_SIZE, Constants.ADDRESS_FORMAT_LINE_SIZE)); else mode.setSubtitle(null); menu.findItem(R.id.wallet_transactions_context_edit_address).setVisible(address != null); serializedTx = tx.unsafeHTMLcoinSerialize(); menu.findItem(R.id.wallet_transactions_context_show_qr) .setVisible(serializedTx.length < SHOW_QR_THRESHOLD_BYTES); Nfc.publishMimeObject(nfcManager, activity, Constants.MIMETYPE_TRANSACTION, serializedTx); return true; } catch (final ScriptException x) { return false; } } @Override public boolean onActionItemClicked(final ActionMode mode, final MenuItem item) { switch (item.getItemId()) { case R.id.wallet_transactions_context_edit_address: handleEditAddress(tx); mode.finish(); return true; case R.id.wallet_transactions_context_show_qr: handleShowQr(); mode.finish(); return true; case R.id.wallet_transactions_context_browse: startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.EXPLORE_BASE_URL + "tx/" + tx.getHashAsString()))); mode.finish(); return true; } return false; } @Override public void onDestroyActionMode(final ActionMode mode) { Nfc.unpublish(nfcManager, activity); } private void handleEditAddress(@Nonnull final Transaction tx) { EditAddressBookEntryFragment.edit(getFragmentManager(), address.toString()); } private void handleShowQr() { final int size = (int) (384 * getResources().getDisplayMetrics().density); final Bitmap qrCodeBitmap = Qr.bitmap(Qr.encodeCompressBinary(serializedTx), size); BitmapFragment.show(getFragmentManager(), qrCodeBitmap); } }); }
From source file:com.bushstar.kobocoin_android_wallet.ui.TransactionsListFragment.java
private void handleTransactionClick(@Nonnull final Transaction tx) { activity.startActionMode(new ActionMode.Callback() { private Address address; private byte[] serializedTx; private static final int SHOW_QR_THRESHOLD_BYTES = 2500; @Override/*w w w .ja va2 s . co m*/ public boolean onCreateActionMode(final ActionMode mode, final Menu menu) { final MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.wallet_transactions_context, menu); return true; } @Override public boolean onPrepareActionMode(final ActionMode mode, final Menu menu) { try { final Date time = tx.getUpdateTime(); final DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(activity); final DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(activity); mode.setTitle(time != null ? (DateUtils.isToday(time.getTime()) ? getString(R.string.time_today) : dateFormat.format(time)) + ", " + timeFormat.format(time) : null); final BigInteger value = tx.getValue(wallet); final boolean sent = value.signum() < 0; address = sent ? WalletUtils.getFirstToAddress(tx) : WalletUtils.getFirstFromAddress(tx); final String label; if (tx.isCoinBase()) label = getString(R.string.wallet_transactions_fragment_coinbase); else if (address != null) label = AddressBookProvider.resolveLabel(activity, address.toString()); else label = "?"; final String prefix = getString(sent ? R.string.symbol_to : R.string.symbol_from) + " "; if (tx.getPurpose() != Purpose.KEY_ROTATION) mode.setSubtitle(label != null ? prefix + label : WalletUtils.formatAddress(prefix, address, Constants.ADDRESS_FORMAT_GROUP_SIZE, Constants.ADDRESS_FORMAT_LINE_SIZE)); else mode.setSubtitle(null); menu.findItem(R.id.wallet_transactions_context_edit_address).setVisible(address != null); serializedTx = tx.unsafeKobocoinSerialize(); menu.findItem(R.id.wallet_transactions_context_show_qr) .setVisible(serializedTx.length < SHOW_QR_THRESHOLD_BYTES); Nfc.publishMimeObject(nfcManager, activity, Constants.MIMETYPE_TRANSACTION, serializedTx); return true; } catch (final ScriptException x) { return false; } } @Override public boolean onActionItemClicked(final ActionMode mode, final MenuItem item) { switch (item.getItemId()) { case R.id.wallet_transactions_context_edit_address: handleEditAddress(tx); mode.finish(); return true; case R.id.wallet_transactions_context_show_qr: handleShowQr(); mode.finish(); return true; case R.id.wallet_transactions_context_browse: startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.EXPLORE_BASE_URL + "tx/" + tx.getHashAsString()))); mode.finish(); return true; } return false; } @Override public void onDestroyActionMode(final ActionMode mode) { Nfc.unpublish(nfcManager, activity); } private void handleEditAddress(@Nonnull final Transaction tx) { EditAddressBookEntryFragment.edit(getFragmentManager(), address.toString()); } private void handleShowQr() { final int size = (int) (384 * getResources().getDisplayMetrics().density); final Bitmap qrCodeBitmap = Qr.bitmap(Qr.encodeCompressBinary(serializedTx), size); BitmapFragment.show(getFragmentManager(), qrCodeBitmap); } }); }
From source file:com.matthewmitchell.nubits_android_wallet.ui.TransactionsListFragment.java
private void handleTransactionClick(@Nonnull final Transaction tx) { activity.startActionMode(new ActionMode.Callback() { private Address address; private byte[] serializedTx; private static final int SHOW_QR_THRESHOLD_BYTES = 2500; @Override// ww w .j a v a2 s . c om public boolean onCreateActionMode(final ActionMode mode, final Menu menu) { final MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.wallet_transactions_context, menu); return true; } @Override public boolean onPrepareActionMode(final ActionMode mode, final Menu menu) { try { final Date time = tx.getUpdateTime(); final DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(activity); final DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(activity); mode.setTitle(time != null ? (DateUtils.isToday(time.getTime()) ? getString(R.string.time_today) : dateFormat.format(time)) + ", " + timeFormat.format(time) : null); final BigInteger value = tx.getValue(wallet); final boolean sent = value.signum() < 0; address = sent ? WalletUtils.getFirstToAddress(tx) : WalletUtils.getFirstFromAddress(tx); final String label; if (tx.isCoinBase()) label = getString(R.string.wallet_transactions_fragment_coinbase); else if (address != null) label = AddressBookProvider.resolveLabel(activity, address.toString()); else label = "?"; final String prefix = getString(sent ? R.string.symbol_to : R.string.symbol_from) + " "; if (tx.getPurpose() != Purpose.KEY_ROTATION) mode.setSubtitle(label != null ? prefix + label : WalletUtils.formatAddress(prefix, address, Constants.ADDRESS_FORMAT_GROUP_SIZE, Constants.ADDRESS_FORMAT_LINE_SIZE)); else mode.setSubtitle(null); menu.findItem(R.id.wallet_transactions_context_edit_address).setVisible(address != null); serializedTx = tx.unsafeNubitsSerialize(); menu.findItem(R.id.wallet_transactions_context_show_qr) .setVisible(serializedTx.length < SHOW_QR_THRESHOLD_BYTES); Nfc.publishMimeObject(nfcManager, activity, Constants.MIMETYPE_TRANSACTION, serializedTx); return true; } catch (final ScriptException x) { return false; } } @Override public boolean onActionItemClicked(final ActionMode mode, final MenuItem item) { switch (item.getItemId()) { case R.id.wallet_transactions_context_edit_address: handleEditAddress(tx); mode.finish(); return true; case R.id.wallet_transactions_context_show_qr: handleShowQr(); mode.finish(); return true; case R.id.wallet_transactions_context_browse: startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.EXPLORE_BASE_URL + "tx/" + tx.getHashAsString()))); mode.finish(); return true; } return false; } @Override public void onDestroyActionMode(final ActionMode mode) { Nfc.unpublish(nfcManager, activity); } private void handleEditAddress(@Nonnull final Transaction tx) { EditAddressBookEntryFragment.edit(getFragmentManager(), address.toString()); } private void handleShowQr() { final int size = (int) (384 * getResources().getDisplayMetrics().density); final Bitmap qrCodeBitmap = Qr.bitmap(Qr.encodeCompressBinary(serializedTx), size); BitmapFragment.show(getFragmentManager(), qrCodeBitmap); } }); }