Search in sources :

Example 11 with QRCodeEncoder

use of com.google.zxing.client.android.encode.QRCodeEncoder in project samourai-wallet-android by Samourai-Wallet.

the class SendActivity method doShowTx.

private void doShowTx(final String hexTx, final String txHash) {
    // tx max size in bytes == 2148
    final int QR_ALPHANUM_CHAR_LIMIT = 4296;
    TextView showTx = new TextView(SendActivity.this);
    showTx.setText(hexTx);
    showTx.setTextIsSelectable(true);
    showTx.setPadding(40, 10, 40, 10);
    showTx.setTextSize(18.0f);
    final CheckBox cbMarkInputsUnspent = new CheckBox(SendActivity.this);
    cbMarkInputsUnspent.setText(R.string.mark_inputs_as_unspendable);
    cbMarkInputsUnspent.setChecked(false);
    LinearLayout hexLayout = new LinearLayout(SendActivity.this);
    hexLayout.setOrientation(LinearLayout.VERTICAL);
    hexLayout.addView(cbMarkInputsUnspent);
    hexLayout.addView(showTx);
    new AlertDialog.Builder(SendActivity.this).setTitle(txHash).setView(hexLayout).setCancelable(false).setPositiveButton(R.string.close, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
            if (cbMarkInputsUnspent.isChecked()) {
                markUTXOAsUnspendable(hexTx);
                Intent intent = new Intent("com.samourai.wallet.BalanceFragment.REFRESH");
                intent.putExtra("notifTx", false);
                intent.putExtra("fetch", true);
                LocalBroadcastManager.getInstance(SendActivity.this).sendBroadcast(intent);
            }
            dialog.dismiss();
            SendActivity.this.finish();
        }
    }).setNegativeButton(R.string.show_qr, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
            if (cbMarkInputsUnspent.isChecked()) {
                markUTXOAsUnspendable(hexTx);
                Intent intent = new Intent("com.samourai.wallet.BalanceFragment.REFRESH");
                intent.putExtra("notifTx", false);
                intent.putExtra("fetch", true);
                LocalBroadcastManager.getInstance(SendActivity.this).sendBroadcast(intent);
            }
            if (hexTx.length() <= QR_ALPHANUM_CHAR_LIMIT) {
                final ImageView ivQR = new ImageView(SendActivity.this);
                Display display = (SendActivity.this).getWindowManager().getDefaultDisplay();
                Point size = new Point();
                display.getSize(size);
                int imgWidth = Math.max(size.x - 240, 150);
                Bitmap bitmap = null;
                QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(hexTx, null, Contents.Type.TEXT, BarcodeFormat.QR_CODE.toString(), imgWidth);
                try {
                    bitmap = qrCodeEncoder.encodeAsBitmap();
                } catch (WriterException e) {
                    e.printStackTrace();
                }
                ivQR.setImageBitmap(bitmap);
                LinearLayout qrLayout = new LinearLayout(SendActivity.this);
                qrLayout.setOrientation(LinearLayout.VERTICAL);
                qrLayout.addView(ivQR);
                new AlertDialog.Builder(SendActivity.this).setTitle(txHash).setView(qrLayout).setCancelable(false).setPositiveButton(R.string.close, new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int whichButton) {
                        dialog.dismiss();
                        SendActivity.this.finish();
                    }
                }).setNegativeButton(R.string.share_qr, new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int whichButton) {
                        String strFileName = AppUtil.getInstance(SendActivity.this).getReceiveQRFilename();
                        File file = new File(strFileName);
                        if (!file.exists()) {
                            try {
                                file.createNewFile();
                            } catch (Exception e) {
                                Toast.makeText(SendActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
                            }
                        }
                        file.setReadable(true, false);
                        FileOutputStream fos = null;
                        try {
                            fos = new FileOutputStream(file);
                        } catch (FileNotFoundException fnfe) {
                            ;
                        }
                        if (file != null && fos != null) {
                            Bitmap bitmap = ((BitmapDrawable) ivQR.getDrawable()).getBitmap();
                            bitmap.compress(Bitmap.CompressFormat.PNG, 0, fos);
                            try {
                                fos.close();
                            } catch (IOException ioe) {
                                ;
                            }
                            Intent intent = new Intent();
                            intent.setAction(Intent.ACTION_SEND);
                            intent.setType("image/png");
                            intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
                            startActivity(Intent.createChooser(intent, SendActivity.this.getText(R.string.send_tx)));
                        }
                    }
                }).show();
            } else {
                Toast.makeText(SendActivity.this, R.string.tx_too_large_qr, Toast.LENGTH_SHORT).show();
            }
        }
    }).show();
}
Also used : DialogInterface(android.content.DialogInterface) QRCodeEncoder(com.google.zxing.client.android.encode.QRCodeEncoder) FileNotFoundException(java.io.FileNotFoundException) Intent(android.content.Intent) MyTransactionOutPoint(com.samourai.wallet.send.MyTransactionOutPoint) Point(android.graphics.Point) BitmapDrawable(android.graphics.drawable.BitmapDrawable) IOException(java.io.IOException) MyTransactionOutPoint(com.samourai.wallet.send.MyTransactionOutPoint) Point(android.graphics.Point) JSONException(org.json.JSONException) IOException(java.io.IOException) WriterException(com.google.zxing.WriterException) ParseException(java.text.ParseException) DecoderException(org.bouncycastle.util.encoders.DecoderException) FileNotFoundException(java.io.FileNotFoundException) MnemonicException(org.bitcoinj.crypto.MnemonicException) Bitmap(android.graphics.Bitmap) CheckBox(android.widget.CheckBox) FileOutputStream(java.io.FileOutputStream) TextView(android.widget.TextView) ImageView(android.widget.ImageView) File(java.io.File) LinearLayout(android.widget.LinearLayout) WriterException(com.google.zxing.WriterException) Display(android.view.Display)

Example 12 with QRCodeEncoder

use of com.google.zxing.client.android.encode.QRCodeEncoder in project samourai-wallet-android by Samourai-Wallet.

the class SettingsActivity2 method getXPUB.

private void getXPUB() {
    final String[] accounts;
    if (AddressFactory.getInstance(SettingsActivity2.this).getHighestTxReceiveIdx(SamouraiWallet.MIXING_ACCOUNT) == 0) {
        accounts = new String[] { getString(R.string.account_Samourai) };
    } else {
        accounts = new String[] { getString(R.string.account_Samourai), getString(R.string.account_shuffling) };
    }
    final int sel = 0;
    new AlertDialog.Builder(SettingsActivity2.this).setTitle(R.string.select_account).setSingleChoiceItems(accounts, sel, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            String xpub = null;
            try {
                xpub = HD_WalletFactory.getInstance(SettingsActivity2.this).get().getAccount(which).xpubstr();
            } catch (IOException ioe) {
                ioe.printStackTrace();
                Toast.makeText(SettingsActivity2.this, "HD wallet error", Toast.LENGTH_SHORT).show();
            } catch (MnemonicException.MnemonicLengthException mle) {
                mle.printStackTrace();
                Toast.makeText(SettingsActivity2.this, "HD wallet error", Toast.LENGTH_SHORT).show();
            }
            final String _xpub = xpub;
            ImageView showQR = new ImageView(SettingsActivity2.this);
            Bitmap bitmap = null;
            QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(xpub, null, Contents.Type.TEXT, BarcodeFormat.QR_CODE.toString(), 500);
            try {
                bitmap = qrCodeEncoder.encodeAsBitmap();
            } catch (WriterException e) {
                e.printStackTrace();
            }
            showQR.setImageBitmap(bitmap);
            TextView showText = new TextView(SettingsActivity2.this);
            showText.setText(xpub);
            showText.setTextIsSelectable(true);
            showText.setPadding(40, 10, 40, 10);
            showText.setTextSize(18.0f);
            LinearLayout xpubLayout = new LinearLayout(SettingsActivity2.this);
            xpubLayout.setOrientation(LinearLayout.VERTICAL);
            xpubLayout.addView(showQR);
            xpubLayout.addView(showText);
            new AlertDialog.Builder(SettingsActivity2.this).setTitle(R.string.app_name).setView(xpubLayout).setCancelable(false).setPositiveButton(R.string.copy_to_clipboard, new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int whichButton) {
                    android.content.ClipboardManager clipboard = (android.content.ClipboardManager) SettingsActivity2.this.getSystemService(android.content.Context.CLIPBOARD_SERVICE);
                    android.content.ClipData clip = null;
                    clip = android.content.ClipData.newPlainText("XPUB", _xpub);
                    clipboard.setPrimaryClip(clip);
                    Toast.makeText(SettingsActivity2.this, R.string.copied_to_clipboard, Toast.LENGTH_SHORT).show();
                }
            }).setNegativeButton(R.string.close, new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int whichButton) {
                    ;
                }
            }).show();
        }
    }).show();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) QRCodeEncoder(com.google.zxing.client.android.encode.QRCodeEncoder) IOException(java.io.IOException) MnemonicException(org.bitcoinj.crypto.MnemonicException) Bitmap(android.graphics.Bitmap) TextView(android.widget.TextView) ImageView(android.widget.ImageView) WriterException(com.google.zxing.WriterException) LinearLayout(android.widget.LinearLayout)

Example 13 with QRCodeEncoder

use of com.google.zxing.client.android.encode.QRCodeEncoder in project samourai-wallet-android by Samourai-Wallet.

the class UTXODetailsActivity method viewPrivateKey.

private void viewPrivateKey() {
    ECKey ecKey = SendFactory.getPrivKey(addr, account);
    String strPrivKey = ecKey.getPrivateKeyAsWiF(SamouraiWallet.getInstance().getCurrentNetworkParams());
    ImageView showQR = new ImageView(this);
    Bitmap bitmap = null;
    QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(strPrivKey, null, Contents.Type.TEXT, BarcodeFormat.QR_CODE.toString(), 500);
    try {
        bitmap = qrCodeEncoder.encodeAsBitmap();
    } catch (WriterException e) {
        e.printStackTrace();
    }
    showQR.setImageBitmap(bitmap);
    TextView showText = new TextView(this);
    showText.setText(strPrivKey);
    showText.setTextIsSelectable(true);
    showText.setPadding(40, 10, 40, 10);
    showText.setTextSize(18.0f);
    LinearLayout privkeyLayout = new LinearLayout(this);
    privkeyLayout.setOrientation(LinearLayout.VERTICAL);
    privkeyLayout.addView(showQR);
    privkeyLayout.addView(showText);
    new AlertDialog.Builder(this).setTitle(R.string.app_name).setView(privkeyLayout).setCancelable(false).setPositiveButton(R.string.ok, (dialog, whichButton) -> {
    }).show();
}
Also used : AlertDialog(android.app.AlertDialog) LinearLayout(android.widget.LinearLayout) Bundle(android.os.Bundle) Completable(io.reactivex.Completable) Uri(android.net.Uri) ImageView(android.widget.ImageView) TransitionManager(android.transition.TransitionManager) WriterException(com.google.zxing.WriterException) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) WhirlpoolMeta(com.samourai.wallet.whirlpool.WhirlpoolMeta) Picasso(com.squareup.picasso.Picasso) MyTransactionOutPoint(com.samourai.wallet.send.MyTransactionOutPoint) JSONException(org.json.JSONException) JSONObject(org.json.JSONObject) View(android.view.View) Button(android.widget.Button) SendActivity(com.samourai.wallet.send.SendActivity) UTXO(com.samourai.wallet.send.UTXO) Schedulers(io.reactivex.schedulers.Schedulers) Log(android.util.Log) AccessFactory(com.samourai.wallet.access.AccessFactory) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat) WebUtil(com.samourai.wallet.bip47.paynym.WebUtil) UUID(java.util.UUID) AppCompatActivity(android.support.v7.app.AppCompatActivity) ViewGroup(android.view.ViewGroup) ECKey(org.bitcoinj.core.ECKey) AlertDialog(android.app.AlertDialog) Objects(java.util.Objects) Contents(com.google.zxing.client.android.Contents) List(java.util.List) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Disposable(io.reactivex.disposables.Disposable) TextView(android.widget.TextView) Address(org.bitcoinj.core.Address) BIP47Meta(com.samourai.wallet.bip47.BIP47Meta) Snackbar(android.support.design.widget.Snackbar) BarcodeFormat(com.google.zxing.BarcodeFormat) FormatsUtil(com.samourai.wallet.util.FormatsUtil) BottomSheetDialog(android.support.design.widget.BottomSheetDialog) BlockedUTXO(com.samourai.wallet.send.BlockedUTXO) Intent(android.content.Intent) PayloadUtil(com.samourai.wallet.payload.PayloadUtil) MnemonicException(org.bitcoinj.crypto.MnemonicException) MenuItem(android.view.MenuItem) Hex(org.bouncycastle.util.encoders.Hex) ArrayList(java.util.ArrayList) BIP47Add(com.samourai.wallet.bip47.BIP47Add) SamouraiWallet(com.samourai.wallet.SamouraiWallet) SendFactory(com.samourai.wallet.send.SendFactory) Toast(android.widget.Toast) Menu(android.view.Menu) Observable(io.reactivex.Observable) DecryptionException(com.samourai.wallet.crypto.DecryptionException) CharSequenceX(com.samourai.wallet.util.CharSequenceX) UTXOCoin(com.samourai.wallet.utxos.models.UTXOCoin) MessageSignUtil(com.samourai.wallet.util.MessageSignUtil) SegwitAddress(com.samourai.wallet.segwit.SegwitAddress) PayNymDetailsActivity(com.samourai.wallet.paynym.paynymDetails.PayNymDetailsActivity) DecimalFormat(java.text.DecimalFormat) IOException(java.io.IOException) R(com.samourai.wallet.R) QRCodeEncoder(com.google.zxing.client.android.encode.QRCodeEncoder) Bitmap(android.graphics.Bitmap) WhirlpoolMain(com.samourai.wallet.whirlpool.WhirlpoolMain) APIFactory(com.samourai.wallet.api.APIFactory) LogUtil(com.samourai.wallet.util.LogUtil) EditText(android.widget.EditText) Bitmap(android.graphics.Bitmap) QRCodeEncoder(com.google.zxing.client.android.encode.QRCodeEncoder) ECKey(org.bitcoinj.core.ECKey) TextView(android.widget.TextView) ImageView(android.widget.ImageView) WriterException(com.google.zxing.WriterException) LinearLayout(android.widget.LinearLayout)

Example 14 with QRCodeEncoder

use of com.google.zxing.client.android.encode.QRCodeEncoder in project samourai-wallet-android by Samourai-Wallet.

the class ReceiveActivity method generateQRCode.

private Bitmap generateQRCode(String uri) {
    Bitmap bitmap = null;
    QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(uri, null, Contents.Type.TEXT, BarcodeFormat.QR_CODE.toString(), imgWidth);
    try {
        bitmap = qrCodeEncoder.encodeAsBitmap();
    } catch (WriterException e) {
        e.printStackTrace();
    }
    return bitmap;
}
Also used : Bitmap(android.graphics.Bitmap) QRCodeEncoder(com.google.zxing.client.android.encode.QRCodeEncoder) WriterException(com.google.zxing.WriterException)

Example 15 with QRCodeEncoder

use of com.google.zxing.client.android.encode.QRCodeEncoder in project samourai-wallet-android by Samourai-Wallet.

the class AddressCalcActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_address_calc);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    edIndex = (EditText) findViewById(R.id.index);
    spType = (Spinner) findViewById(R.id.address_type_spinner);
    spType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
            if (position == 3) {
                tvChain.setVisibility(View.INVISIBLE);
                rChain.setVisibility(View.INVISIBLE);
            } else {
                tvChain.setVisibility(View.VISIBLE);
                rChain.setVisibility(View.VISIBLE);
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parentView) {
            ;
        }
    });
    populateSpinner();
    tvChain = (TextView) findViewById(R.id.chain_label);
    rChain = (RadioGroup) findViewById(R.id.chain);
    btOK = (Button) findViewById(R.id.ok);
    btOK.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            try {
                HD_Address hd_addr = null;
                final SegwitAddress segwitAddress;
                String strIndex = edIndex.getText().toString();
                if (strIndex == null || strIndex.length() < 1) {
                    Toast.makeText(AddressCalcActivity.this, R.string.invalid_index, Toast.LENGTH_SHORT).show();
                    return;
                }
                int index = Integer.parseInt(strIndex);
                int chain = 0;
                int selectedId = rChain.getCheckedRadioButtonId();
                if (spType.getSelectedItemPosition() == 3) {
                    chain = 0;
                } else if (selectedId == R.id.change) {
                    chain = 1;
                } else {
                    chain = 0;
                }
                if (spType.getSelectedItemPosition() == 1) {
                    hd_addr = BIP84Util.getInstance(AddressCalcActivity.this).getWallet().getAccountAt(0).getChain(chain).getAddressAt(index);
                    segwitAddress = new SegwitAddress(hd_addr.getECKey(), SamouraiWallet.getInstance().getCurrentNetworkParams());
                } else if (spType.getSelectedItemPosition() == 2) {
                    segwitAddress = null;
                    hd_addr = HD_WalletFactory.getInstance(AddressCalcActivity.this).get().getAccount(0).getChain(chain).getAddressAt(index);
                } else if (spType.getSelectedItemPosition() == 3) {
                    hd_addr = BIP84Util.getInstance(AddressCalcActivity.this).getWallet().getAccountAt(RicochetMeta.getInstance(AddressCalcActivity.this).getRicochetAccount()).getChain(chain).getAddressAt(index);
                    segwitAddress = new SegwitAddress(hd_addr.getECKey(), SamouraiWallet.getInstance().getCurrentNetworkParams());
                } else if (spType.getSelectedItemPosition() == 4) {
                    hd_addr = BIP84Util.getInstance(AddressCalcActivity.this).getWallet().getAccountAt(WhirlpoolMeta.getInstance(AddressCalcActivity.this).getWhirlpoolPremixAccount()).getChain(chain).getAddressAt(index);
                    segwitAddress = new SegwitAddress(hd_addr.getECKey(), SamouraiWallet.getInstance().getCurrentNetworkParams());
                } else if (spType.getSelectedItemPosition() == 5) {
                    hd_addr = BIP84Util.getInstance(AddressCalcActivity.this).getWallet().getAccountAt(WhirlpoolMeta.getInstance(AddressCalcActivity.this).getWhirlpoolPostmix()).getChain(chain).getAddressAt(index);
                    segwitAddress = new SegwitAddress(hd_addr.getECKey(), SamouraiWallet.getInstance().getCurrentNetworkParams());
                } else if (spType.getSelectedItemPosition() == 6) {
                    hd_addr = BIP84Util.getInstance(AddressCalcActivity.this).getWallet().getAccountAt(WhirlpoolMeta.getInstance(AddressCalcActivity.this).getWhirlpoolBadBank()).getChain(chain).getAddressAt(index);
                    segwitAddress = new SegwitAddress(hd_addr.getECKey(), SamouraiWallet.getInstance().getCurrentNetworkParams());
                } else {
                    hd_addr = BIP49Util.getInstance(AddressCalcActivity.this).getWallet().getAccountAt(0).getChain(chain).getAddressAt(index);
                    segwitAddress = new SegwitAddress(hd_addr.getECKey(), SamouraiWallet.getInstance().getCurrentNetworkParams());
                }
                final ECKey ecKey;
                final String strAddress;
                if (spType.getSelectedItemPosition() == 2) {
                    ecKey = hd_addr.getECKey();
                    strAddress = hd_addr.getAddressString();
                } else {
                    ecKey = segwitAddress.getECKey();
                    if (spType.getSelectedItemPosition() == 0) {
                        strAddress = segwitAddress.getAddressAsString();
                    } else {
                        strAddress = segwitAddress.getBech32AsString();
                    }
                }
                String message = spType.getSelectedItem().toString();
                message += "\n";
                message += (chain == 1) ? AddressCalcActivity.this.getText(R.string.change_chain) : AddressCalcActivity.this.getText(R.string.receive_chain);
                message += "\n";
                message += index + ":";
                message += "\n";
                message += strAddress;
                final TextView tvText = new TextView(getApplicationContext());
                tvText.setText(message);
                tvText.setTextIsSelectable(true);
                tvText.setPadding(40, 10, 40, 10);
                tvText.setTextColor(0xffffffff);
                AlertDialog.Builder dlg = new AlertDialog.Builder(AddressCalcActivity.this).setTitle(R.string.app_name).setView(tvText).setCancelable(true).setNeutralButton(R.string.utxo_sign, new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int whichButton) {
                        dialog.dismiss();
                        String addr = strAddress;
                        String msg = null;
                        if (FormatsUtil.getInstance().isValidBech32(addr) || Address.fromBase58(SamouraiWallet.getInstance().getCurrentNetworkParams(), addr).isP2SHAddress()) {
                            msg = AddressCalcActivity.this.getString(R.string.utxo_sign_text3);
                            try {
                                JSONObject obj = new JSONObject();
                                obj.put("pubkey", ecKey.getPublicKeyAsHex());
                                obj.put("address", addr);
                                msg += " " + obj.toString();
                            } catch (JSONException je) {
                                msg += ":";
                                msg += addr;
                                msg += ", ";
                                msg += "pubkey:";
                                msg += ecKey.getPublicKeyAsHex();
                            }
                        } else {
                            msg = AddressCalcActivity.this.getString(R.string.utxo_sign_text2);
                        }
                        if (ecKey != null) {
                            MessageSignUtil.getInstance(AddressCalcActivity.this).doSign(AddressCalcActivity.this.getString(R.string.utxo_sign), AddressCalcActivity.this.getString(R.string.utxo_sign_text1), msg, ecKey);
                        }
                    }
                }).setNegativeButton(R.string.options_display_privkey, new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int whichButton) {
                        String strPrivKey = ecKey.getPrivateKeyAsWiF(SamouraiWallet.getInstance().getCurrentNetworkParams());
                        ImageView showQR = new ImageView(AddressCalcActivity.this);
                        Bitmap bitmap = null;
                        QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(strPrivKey, null, Contents.Type.TEXT, BarcodeFormat.QR_CODE.toString(), 500);
                        try {
                            bitmap = qrCodeEncoder.encodeAsBitmap();
                        } catch (WriterException e) {
                            e.printStackTrace();
                        }
                        showQR.setImageBitmap(bitmap);
                        TextView showText = new TextView(AddressCalcActivity.this);
                        showText.setText(strPrivKey);
                        showText.setTextIsSelectable(true);
                        showText.setPadding(40, 10, 40, 10);
                        showText.setTextSize(18.0f);
                        LinearLayout privkeyLayout = new LinearLayout(AddressCalcActivity.this);
                        privkeyLayout.setOrientation(LinearLayout.VERTICAL);
                        privkeyLayout.addView(showQR);
                        privkeyLayout.addView(showText);
                        new AlertDialog.Builder(AddressCalcActivity.this).setTitle(R.string.app_name).setView(privkeyLayout).setCancelable(false).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

                            public void onClick(DialogInterface dialog, int whichButton) {
                                ;
                            }
                        }).show();
                    }
                });
                if (spType.getSelectedItemPosition() != 2) {
                    dlg.setPositiveButton(R.string.options_display_redeem_script, new DialogInterface.OnClickListener() {

                        public void onClick(DialogInterface dialog, int whichButton) {
                            String redeemScript = org.spongycastle.util.encoders.Hex.toHexString(segwitAddress.segWitRedeemScript().getProgram());
                            TextView showText = new TextView(AddressCalcActivity.this);
                            showText.setText(redeemScript);
                            showText.setTextIsSelectable(true);
                            showText.setPadding(40, 10, 40, 10);
                            showText.setTextSize(18.0f);
                            new AlertDialog.Builder(AddressCalcActivity.this).setTitle(R.string.app_name).setView(showText).setCancelable(false).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

                                public void onClick(DialogInterface dialog, int whichButton) {
                                    dialog.dismiss();
                                }
                            }).show();
                        }
                    });
                }
                if (!isFinishing()) {
                    dlg.show();
                }
            } catch (Exception e) {
                Toast.makeText(AddressCalcActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
            }
        }
    });
    btCancel = (Button) findViewById(R.id.cancel);
    btCancel.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            finish();
        }
    });
}
Also used : AlertDialog(android.app.AlertDialog) SegwitAddress(com.samourai.wallet.segwit.SegwitAddress) DialogInterface(android.content.DialogInterface) QRCodeEncoder(com.google.zxing.client.android.encode.QRCodeEncoder) ECKey(org.bitcoinj.core.ECKey) Bitmap(android.graphics.Bitmap) TextView(android.widget.TextView) ImageView(android.widget.ImageView) HD_Address(com.samourai.wallet.hd.HD_Address) JSONException(org.json.JSONException) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) WriterException(com.google.zxing.WriterException) JSONException(org.json.JSONException) JSONObject(org.json.JSONObject) AdapterView(android.widget.AdapterView) WriterException(com.google.zxing.WriterException) LinearLayout(android.widget.LinearLayout)

Aggregations

Bitmap (android.graphics.Bitmap)18 WriterException (com.google.zxing.WriterException)18 QRCodeEncoder (com.google.zxing.client.android.encode.QRCodeEncoder)18 ImageView (android.widget.ImageView)12 TextView (android.widget.TextView)12 LinearLayout (android.widget.LinearLayout)11 DialogInterface (android.content.DialogInterface)10 IOException (java.io.IOException)7 AlertDialog (android.app.AlertDialog)6 Intent (android.content.Intent)6 MnemonicException (org.bitcoinj.crypto.MnemonicException)6 JSONException (org.json.JSONException)6 Point (android.graphics.Point)4 BitmapDrawable (android.graphics.drawable.BitmapDrawable)4 Display (android.view.Display)4 View (android.view.View)4 SegwitAddress (com.samourai.wallet.segwit.SegwitAddress)4 MyTransactionOutPoint (com.samourai.wallet.send.MyTransactionOutPoint)4 File (java.io.File)4 FileNotFoundException (java.io.FileNotFoundException)4