예제 #1
0
  public void sendPop(View view) {
    try {
      if (txidToProve == null) {
        Toast.makeText(this, R.string.pop_no_transaction_selected, Toast.LENGTH_LONG).show();
      }
      WalletAccount account = _mbwManager.getSelectedAccount();

      final UnsignedTransaction unsignedPop =
          account.createUnsignedPop(txidToProve, popRequest.getN());

      _mbwManager.runPinProtectedFunction(
          PopActivity.this,
          new Runnable() {

            @Override
            public void run() {
              disableButtons();
              SignTransactionActivity.callMe(
                  PopActivity.this,
                  _mbwManager.getSelectedAccount().getId(),
                  false,
                  unsignedPop,
                  SIGN_TRANSACTION_REQUEST_CODE);
            }
          });
    } catch (Exception e) {
      Toast.makeText(this, "An internal error occurred:" + e.getMessage(), Toast.LENGTH_LONG)
          .show();
    }
  }
예제 #2
0
  private void updateUi(TransactionSummary transactionSummary) {
    MetadataStorage metadataStorage = _mbwManager.getMetadataStorage();

    // Set Date
    Date date = new Date(transactionSummary.time * 1000L);
    DateFormat dateFormat = new AdaptiveDateFormat(getApplicationContext());
    setText(R.id.pop_transaction_date, dateFormat.format(date));

    // Set amount
    long amountSatoshis = getPaymentAmountSatoshis(transactionSummary);
    String value = _mbwManager.getBtcValueString(amountSatoshis);
    String fiatValue =
        _mbwManager.getCurrencySwitcher().getFormattedFiatValue(amountSatoshis, true);
    String fiatAppendment = "";
    if (!Strings.isNullOrEmpty(fiatValue)) {
      fiatAppendment = " (" + fiatValue + ")";
    }
    setText(R.id.pop_transaction_amount, value + fiatAppendment);

    // Set label
    String label = metadataStorage.getLabelByTransaction(transactionSummary.txid);
    setText(R.id.pop_transaction_label, label);

    URL url = getUrl(popRequest.getP());
    if (url == null) {
      Toast.makeText(this, "Invalid URL:" + popRequest.getP(), Toast.LENGTH_LONG).show();
      finish();
      return;
    }

    TextView textView = (TextView) findViewById(R.id.pop_recipient_host);
    textView.setText(url.getHost());
    String protocol = url.getProtocol();
    if ("https".equals(protocol)) {
      textView.setCompoundDrawablesWithIntrinsicBounds(
          R.drawable.holo_dark_ic_action_secure, 0, 0, 0);
    } else if ("http".equals(protocol)) {
      textView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
    } else {
      Toast.makeText(this, "Unsupported protocol:" + url.getProtocol(), Toast.LENGTH_LONG).show();
      finish();
    }
  }