Search in sources :

Example 11 with Address

use of run.wallet.iota.model.Address in project run-wallet-android by runplay.

the class SnTrFragment method fillBalanceAddress.

private void fillBalanceAddress() {
    remainderAddress.removeAllViews();
    int bgcolor = B.getColor(getActivity(), AppTheme.getPrimary());
    int white = B.getColor(getActivity(), R.color.white);
    int green = B.getColor(getActivity(), R.color.green);
    long fromAddTotal = 0L;
    for (Address add : PayPacket.getPayFrom()) {
        fromAddTotal += add.getValue();
    }
    if (PayPacket.getTotalToPay() == fromAddTotal) {
        remainderPod.setVisibility(View.GONE);
    } else {
        // for(Address address: PayPacket.getPayFrom()) {
        remainderPod.setVisibility(View.VISIBLE);
        LinearLayout layout = new LinearLayout(getActivity());
        layout.setOrientation(LinearLayout.HORIZONTAL);
        layout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
        layout.setPadding(0, 0, 10, 0);
        LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        TextView addId = new TextView(getActivity());
        addId.setLayoutParams(param);
        addId.setText("a" + PayPacket.getRemainder().getIndexName());
        addId.setBackgroundColor(bgcolor);
        addId.setTypeface(addId.getTypeface(), Typeface.BOLD);
        addId.setPadding(6, 2, 6, 2);
        addId.setPadding(2, 2, 2, 2);
        addId.setTextColor(white);
        TextView remainderValue = new TextView(getActivity());
        remainderValue.setLayoutParams(param);
        remainderValue.setText("+" + IotaToText.convertRawIotaAmountToDisplayText(fromAddTotal - PayPacket.getTotalToPay(), true));
        remainderValue.setTextColor(green);
        remainderValue.setTextSize(16F);
        remainderValue.setTypeface(addId.getTypeface(), Typeface.BOLD);
        remainderValue.setPadding(10, 2, 2, 2);
        TextView text = new TextView(getActivity());
        text.setLayoutParams(param);
        text.setText(" > ");
        text.setTextSize(16F);
        text.setPadding(10, 2, 10, 2);
        layout.addView(remainderValue);
        layout.addView(text);
        layout.addView(addId);
        remainderAddress.addView(layout);
        synchronized (remainderAddress) {
            remainderAddress.notifyAll();
        }
    }
// }
}
Also used : Address(run.wallet.iota.model.Address) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout)

Example 12 with Address

use of run.wallet.iota.model.Address in project run-wallet-android by runplay.

the class SnTrFragment method fillFromAddresses.

private void fillFromAddresses() {
    fromAddresses.removeAllViews();
    int bgcolor = B.getColor(getActivity(), AppTheme.getPrimary());
    int white = B.getColor(getActivity(), R.color.white);
    // Log.e("FROM-ADD","add: "+PayPacket.getPayFrom().size());
    for (Address address : PayPacket.getPayFrom()) {
        LinearLayout layout = new LinearLayout(getActivity());
        layout.setOrientation(LinearLayout.HORIZONTAL);
        layout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
        layout.setPadding(0, 0, 10, 0);
        layout.canScrollHorizontally(View.LAYOUT_DIRECTION_LTR);
        LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        TextView addId = new TextView(getActivity());
        addId.setLayoutParams(param);
        addId.setText("a" + address.getIndexName());
        addId.setBackgroundColor(bgcolor);
        addId.setTypeface(addId.getTypeface(), Typeface.BOLD);
        addId.setPadding(6, 2, 6, 2);
        addId.setTextColor(white);
        TextView addValue = new TextView(getActivity());
        addValue.setLayoutParams(param);
        addValue.setText(IotaToText.convertRawIotaAmountToDisplayText(address.getValue(), true));
        addValue.setTextColor(bgcolor);
        addValue.setTextSize(16F);
        addValue.setTypeface(addId.getTypeface(), Typeface.BOLD);
        addValue.setPadding(10, 2, 2, 2);
        layout.addView(addId);
        layout.addView(addValue);
        fromAddresses.addView(layout);
    }
    synchronized (fromAddresses) {
        fromAddresses.notifyAll();
    }
}
Also used : Address(run.wallet.iota.model.Address) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout)

Example 13 with Address

use of run.wallet.iota.model.Address in project run-wallet-android by runplay.

the class TransferViewManager method populateTransferTransactionOuts.

public static void populateTransferTransactionOuts(Activity context, LinearLayout uselayout, List<TransferTransaction> transactions, Transfer transfer) {
    uselayout.removeAllViews();
    int bgcolor = B.getColor(context, AppTheme.getPrimary());
    int bglight = B.getColor(context, R.color.colorLight);
    int white = B.getColor(context, R.color.white);
    int red = B.getColor(context, R.color.flatRed);
    int green = B.getColor(context, R.color.green);
    List<Address> allAddresses = Store.getAddresses();
    main.weight = 1;
    param.setMargins(8, 4, 8, 4);
    param2.setMargins(8, 4, 8, 4);
    param3.setMargins(0, 4, 8, 4);
    for (TransferTransaction trans : transactions) {
        Address address = Store.isAlreadyAddress(trans.getAddress(), allAddresses);
        // if (address != null) {
        LinearLayout layout = new LinearLayout(context);
        layout.setBackgroundColor(bglight);
        layout.setOrientation(LinearLayout.HORIZONTAL);
        layout.setLayoutParams(mainouts);
        layout.setPadding(2, 6, 2, 6);
        layout.canScrollHorizontally(View.LAYOUT_DIRECTION_LTR);
        TextView balance = new TextView(context);
        balance.setLayoutParams(param5);
        balance.setText(IotaToText.convertRawIotaAmountToDisplayText(trans.getPayFromAddressZero(), true));
        balance.setPadding(2, 2, 2, 2);
        if (address == null) {
            if (trans.getPayFromAddressZero() == 0 && trans.getValue() < 0) {
                balance.setBackgroundColor(red);
                balance.setTextColor(white);
            } else {
                balance.setTextColor(white);
            }
        } else {
            if (trans.getValue() < 0 && trans.getPayFromAddressZero() == 0) {
                balance.setBackgroundColor(red);
                balance.setTextColor(white);
            }
            if (trans.getPayFromAddressZero() > 0)
                balance.setTextColor(green);
            else
                balance.setTextColor(white);
        }
        TextView addId = new TextView(context);
        addId.setLayoutParams(param4);
        if (address != null) {
            addId.setBackgroundColor(bgcolor);
            addId.setText("a" + address.getIndexName());
        } else {
            addId.setText(" ");
        }
        addId.setPadding(2, 2, 2, 2);
        addId.setTextColor(white);
        // addId.setMa
        TextView addValue = new TextView(context);
        addValue.setLayoutParams(param3);
        addValue.setText(IotaToText.convertRawIotaAmountToDisplayText(trans.getValue(), true));
        addValue.setTextSize(20F);
        addValue.setGravity(Gravity.RIGHT);
        addValue.setTypeface(null, Typeface.BOLD);
        if (trans.getValue() < 0) {
            addValue.setTextColor(red);
        } else {
            addValue.setTextColor(green);
        }
        addValue.setPadding(5, 2, 2, 2);
        addValue.setSingleLine();
        TextView addAddress = new TextView(context);
        addAddress.setLayoutParams(param2);
        addAddress.setText(trans.getAddress());
        addAddress.setTextColor(bgcolor);
        addAddress.setTextSize(12F);
        addAddress.setPadding(5, 2, 2, 2);
        addAddress.setSingleLine();
        addAddress.setOnClickListener(new OpenClick(context, trans.getAddress()));
        layout.addView(balance);
        layout.addView(addId);
        layout.addView(addValue);
        layout.addView(addAddress);
        uselayout.addView(layout);
    // } else {
    // Log.e("NULL-ADD","Null adrress: "+trans.getAddress()+" - "+transfer.getValue()+" - hash: "+transfer.getHash());
    // }
    // uselayout.notify();
    }
}
Also used : Address(run.wallet.iota.model.Address) TextView(android.widget.TextView) TransferTransaction(run.wallet.iota.model.TransferTransaction) Paint(android.graphics.Paint) LinearLayout(android.widget.LinearLayout)

Example 14 with Address

use of run.wallet.iota.model.Address in project run-wallet-android by runplay.

the class TransferViewManager method populateTransferTransactions.

private static void populateTransferTransactions(Context context, LinearLayout uselayout, List<TransferTransaction> transactions, boolean isOtherTransactions) {
    uselayout.removeAllViews();
    int bgcolor = B.getColor(context, AppTheme.getPrimary());
    int bglight = B.getColor(context, R.color.colorLight);
    int white = B.getColor(context, R.color.white);
    int red = B.getColor(context, R.color.flatRed);
    int green = B.getColor(context, R.color.green);
    main.weight = 1;
    param.setMargins(8, 4, 8, 4);
    param2.setMargins(8, 4, 8, 4);
    param3.setMargins(0, 4, 8, 4);
    for (TransferTransaction trans : transactions) {
        LinearLayout layout = new LinearLayout(context);
        layout.setBackgroundColor(bglight);
        layout.setOrientation(LinearLayout.HORIZONTAL);
        layout.setLayoutParams(main);
        layout.setPadding(2, 2, 2, 2);
        layout.canScrollHorizontally(View.LAYOUT_DIRECTION_LTR);
        TextView addValue = new TextView(context);
        addValue.setLayoutParams(param2);
        addValue.setText(IotaToText.convertRawIotaAmountToDisplayText(trans.getValue(), true));
        addValue.setTextSize(16F);
        addValue.setTypeface(null, Typeface.BOLD);
        if (trans.getValue() < 0) {
            addValue.setTextColor(red);
        } else {
            addValue.setTextColor(green);
        }
        addValue.setPadding(5, 2, 2, 2);
        addValue.setSingleLine();
        TextView addAddress = new TextView(context);
        addAddress.setLayoutParams(param3);
        addAddress.setText(trans.getAddress());
        addAddress.setTextColor(bgcolor);
        addAddress.setTextSize(12F);
        addAddress.setPadding(5, 2, 2, 2);
        addAddress.setSingleLine();
        if (!isOtherTransactions) {
            List<Address> allAddresses = Store.getAddresses();
            Address address = Store.isAlreadyAddress(trans.getAddress(), allAddresses);
            if (address != null) {
                TextView addId = new TextView(context);
                addId.setLayoutParams(param);
                addId.setText("a" + address.getIndexName());
                addId.setBackgroundColor(bgcolor);
                addId.setPadding(2, 2, 2, 2);
                addId.setTextColor(white);
                layout.addView(addId);
            }
        }
        layout.addView(addValue);
        layout.addView(addAddress);
        uselayout.addView(layout);
    }
}
Also used : Address(run.wallet.iota.model.Address) TextView(android.widget.TextView) TransferTransaction(run.wallet.iota.model.TransferTransaction) Paint(android.graphics.Paint) LinearLayout(android.widget.LinearLayout)

Example 15 with Address

use of run.wallet.iota.model.Address in project run-wallet-android by runplay.

the class UiManager method createProcessRunningPod.

private static LinearLayout createProcessRunningPod(Context context, int Rdrawable, String name, long value) {
    List<Address> allAddresses = Store.getAddresses();
    LinearLayout layout = new LinearLayout(context);
    layout.setOrientation(LinearLayout.HORIZONTAL);
    layout.setGravity(Gravity.CENTER_VERTICAL);
    layout.setLayoutParams(main);
    layout.setPadding(2, 2, 2, 2);
    ImageView addId = new ImageView(context);
    addId.setLayoutParams(param);
    addId.setImageResource(Rdrawable);
    TextView addValue = new TextView(context);
    addValue.setLayoutParams(param2);
    String text = IotaToText.convertRawIotaAmountToDisplayText(value, true);
    addValue.setText(text);
    addValue.setTextSize(20F);
    addValue.setTypeface(null, Typeface.BOLD);
    if (value < 0) {
        addValue.setTextColor(red);
    } else if (value > 0) {
        addValue.setTextColor(green);
    }
    addValue.setPadding(5, 2, 2, 2);
    addValue.setSingleLine();
    TextView addAddress = new TextView(context);
    addAddress.setLayoutParams(param3);
    addAddress.setText(name);
    addAddress.setTextColor(white);
    addAddress.setTextSize(12F);
    addAddress.setPadding(5, 2, 2, 2);
    addAddress.setSingleLine();
    layout.addView(addId);
    layout.addView(addAddress);
    if (value != 0) {
        layout.addView(addValue);
    }
    return layout;
}
Also used : Address(run.wallet.iota.model.Address) TextView(android.widget.TextView) ImageView(android.widget.ImageView) LinearLayout(android.widget.LinearLayout)

Aggregations

Address (run.wallet.iota.model.Address)23 ArrayList (java.util.ArrayList)10 Transfer (run.wallet.iota.model.Transfer)9 ApiResponse (run.wallet.iota.api.responses.ApiResponse)8 ArgumentException (jota.error.ArgumentException)7 NetworkError (run.wallet.iota.api.responses.error.NetworkError)6 Wallet (run.wallet.iota.model.Wallet)6 LinearLayout (android.widget.LinearLayout)5 TextView (android.widget.TextView)5 TransferTransaction (run.wallet.iota.model.TransferTransaction)5 GetNewAddressResponse (jota.dto.response.GetNewAddressResponse)4 Bundle (jota.model.Bundle)4 Paint (android.graphics.Paint)3 GetBalancesResponse (jota.dto.response.GetBalancesResponse)3 GetTransferResponse (jota.dto.response.GetTransferResponse)3 StopWatch (jota.utils.StopWatch)3 GetNewAddressRequest (run.wallet.iota.api.requests.GetNewAddressRequest)3 NudgeTransfer (run.wallet.iota.model.NudgeTransfer)3 SharedPreferences (android.content.SharedPreferences)2 Bundle (android.os.Bundle)2