From 0ce5f2b6ca70fb510e29cee04cecac948db24c1c Mon Sep 17 00:00:00 2001 From: m2049r Date: Sun, 4 Aug 2019 13:19:42 +0200 Subject: [PATCH] create ExchangeEditText & use without numpad (#613) --- .../send/SendAddressWizardFragment.java | 34 ++--- .../send/SendAmountWizardFragment.java | 32 ++-- .../send/SendBtcAmountWizardFragment.java | 33 ++-- ...TextView.java => ExchangeBtcEditText.java} | 79 +++++----- ...ngeTextView.java => ExchangeEditText.java} | 75 ++++----- .../m2049r/xmrwallet/widget/ExchangeView.java | 45 +----- .../xmrwallet/widget/NumberPadView.java | 87 ----------- .../main/res/layout/fragment_send_address.xml | 2 +- .../main/res/layout/fragment_send_amount.xml | 30 +--- .../res/layout/fragment_send_btc_amount.xml | 12 +- ...tc_text.xml => view_exchange_btc_edit.xml} | 8 +- ...change_text.xml => view_exchange_edit.xml} | 12 +- app/src/main/res/layout/view_number_pad.xml | 144 ------------------ app/src/main/res/values-cat/strings.xml | 2 +- app/src/main/res/values-de/strings.xml | 2 +- app/src/main/res/values-el/strings.xml | 2 +- app/src/main/res/values-eo/strings.xml | 2 +- app/src/main/res/values-es/strings.xml | 2 +- app/src/main/res/values-et/strings.xml | 2 +- app/src/main/res/values-fr/strings.xml | 2 +- app/src/main/res/values-hu/strings.xml | 2 +- app/src/main/res/values-it/strings.xml | 2 +- app/src/main/res/values-ja/strings.xml | 2 +- app/src/main/res/values-nb/strings.xml | 2 +- app/src/main/res/values-nl/strings.xml | 2 +- app/src/main/res/values-pt-rBR/strings.xml | 2 +- app/src/main/res/values-pt/strings.xml | 2 +- app/src/main/res/values-ro/strings.xml | 2 +- app/src/main/res/values-ru/strings.xml | 2 +- app/src/main/res/values-sk/strings.xml | 2 +- app/src/main/res/values-sr/strings.xml | 2 +- app/src/main/res/values-sv/strings.xml | 2 +- app/src/main/res/values-ua/strings.xml | 2 +- app/src/main/res/values-zh-rCN/strings.xml | 2 +- app/src/main/res/values-zh-rTW/strings.xml | 2 +- app/src/main/res/values/strings.xml | 2 +- 36 files changed, 147 insertions(+), 492 deletions(-) rename app/src/main/java/com/m2049r/xmrwallet/widget/{ExchangeBtcTextView.java => ExchangeBtcEditText.java} (76%) rename app/src/main/java/com/m2049r/xmrwallet/widget/{ExchangeTextView.java => ExchangeEditText.java} (90%) delete mode 100644 app/src/main/java/com/m2049r/xmrwallet/widget/NumberPadView.java rename app/src/main/res/layout/{view_exchange_btc_text.xml => view_exchange_btc_edit.xml} (91%) rename app/src/main/res/layout/{view_exchange_text.xml => view_exchange_edit.xml} (91%) delete mode 100644 app/src/main/res/layout/view_number_pad.xml diff --git a/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendAddressWizardFragment.java b/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendAddressWizardFragment.java index 11e4fcd2..b5cd86cd 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendAddressWizardFragment.java +++ b/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendAddressWizardFragment.java @@ -144,24 +144,8 @@ public class SendAddressWizardFragment extends SendWizardFragment { if (bip70 != null) { // looks good - resolve through xmr.to processBip70(bip70); - next = null; - } else if (checkAddress()) { - if (llPaymentId.getVisibility() == View.VISIBLE) { - next = etPaymentId; - } else { - next = etNotes; - } } } - if (next != null) { - final View focus = next; - etAddress.post(new Runnable() { - @Override - public void run() { - focus.requestFocus(); - } - }); - } } } }); @@ -176,6 +160,7 @@ public class SendAddressWizardFragment extends SendWizardFragment { Timber.d("isIntegratedAddress"); etPaymentId.getEditText().getText().clear(); llPaymentId.setVisibility(View.INVISIBLE); + etAddress.setError(getString(R.string.info_paymentid_integrated)); tvPaymentIdIntegrated.setVisibility(View.VISIBLE); llXmrTo.setVisibility(View.INVISIBLE); sendListener.setMode(SendFragment.Mode.XMR); @@ -208,9 +193,12 @@ public class SendAddressWizardFragment extends SendWizardFragment { if (clip == null) return; // clean it up final String address = clip.replaceAll("[^0-9A-Z-a-z]", ""); - if (Wallet.isAddressValid(address) || BitcoinAddressValidator.validate(address)) - etAddress.getEditText().setText(address); - else + if (Wallet.isAddressValid(address) || BitcoinAddressValidator.validate(address)) { + final EditText et = etAddress.getEditText(); + et.setText(address); + et.setSelection(et.getText().length()); + etAddress.requestFocus(); + } else Toast.makeText(getActivity(), getString(R.string.send_address_invalid), Toast.LENGTH_SHORT).show(); } }); @@ -248,7 +236,10 @@ public class SendAddressWizardFragment extends SendWizardFragment { bPaymentId.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - etPaymentId.getEditText().setText((Wallet.generatePaymentId())); + final EditText et = etPaymentId.getEditText(); + et.setText((Wallet.generatePaymentId())); + et.setSelection(et.getText().length()); + etPaymentId.requestFocus(); } }); @@ -259,7 +250,6 @@ public class SendAddressWizardFragment extends SendWizardFragment { if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN)) || (actionId == EditorInfo.IME_ACTION_DONE)) { etDummy.requestFocus(); - Helper.hideKeyboard(getActivity()); return true; } return false; @@ -277,7 +267,6 @@ public class SendAddressWizardFragment extends SendWizardFragment { etDummy = view.findViewById(R.id.etDummy); etDummy.setRawInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); etDummy.requestFocus(); - Helper.hideKeyboard(getActivity()); View tvNfc = view.findViewById(R.id.tvNfc); NfcManager manager = (NfcManager) getContext().getSystemService(Context.NFC_SERVICE); @@ -551,7 +540,6 @@ public class SendAddressWizardFragment extends SendWizardFragment { public void onResumeFragment() { super.onResumeFragment(); Timber.d("onResumeFragment()"); - Helper.hideKeyboard(getActivity()); etDummy.requestFocus(); } diff --git a/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendAmountWizardFragment.java b/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendAmountWizardFragment.java index c0b5fb5b..5c32174e 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendAmountWizardFragment.java +++ b/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendAmountWizardFragment.java @@ -21,8 +21,6 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageButton; -import android.widget.ImageView; -import android.widget.LinearLayout; import android.widget.TextView; import com.m2049r.xmrwallet.R; @@ -30,8 +28,7 @@ import com.m2049r.xmrwallet.data.BarcodeData; import com.m2049r.xmrwallet.data.TxData; import com.m2049r.xmrwallet.model.Wallet; import com.m2049r.xmrwallet.util.Helper; -import com.m2049r.xmrwallet.widget.ExchangeTextView; -import com.m2049r.xmrwallet.widget.NumberPadView; +import com.m2049r.xmrwallet.widget.ExchangeEditText; import timber.log.Timber; @@ -59,8 +56,7 @@ public class SendAmountWizardFragment extends SendWizardFragment { } private TextView tvFunds; - private ExchangeTextView evAmount; - private View llAmount; + private ExchangeEditText etAmount; private View rlSweep; private ImageButton ibSweep; @@ -75,12 +71,9 @@ public class SendAmountWizardFragment extends SendWizardFragment { View view = inflater.inflate(R.layout.fragment_send_amount, container, false); tvFunds = view.findViewById(R.id.tvFunds); - - evAmount = view.findViewById(R.id.evAmount); - ((NumberPadView) view.findViewById(R.id.numberPad)).setListener(evAmount); - + etAmount = view.findViewById(R.id.etAmount); rlSweep = view.findViewById(R.id.rlSweep); - llAmount = view.findViewById(R.id.llAmount); + view.findViewById(R.id.ivSweep).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -97,8 +90,7 @@ public class SendAmountWizardFragment extends SendWizardFragment { } }); - Helper.hideKeyboard(getActivity()); - + etAmount.requestFocus(); return view; } @@ -107,11 +99,11 @@ public class SendAmountWizardFragment extends SendWizardFragment { private void sweepAll(boolean spendAllMode) { if (spendAllMode) { ibSweep.setVisibility(View.INVISIBLE); - llAmount.setVisibility(View.GONE); + etAmount.setVisibility(View.GONE); rlSweep.setVisibility(View.VISIBLE); } else { ibSweep.setVisibility(View.VISIBLE); - llAmount.setVisibility(View.VISIBLE); + etAmount.setVisibility(View.VISIBLE); rlSweep.setVisibility(View.GONE); } this.spendAllMode = spendAllMode; @@ -124,12 +116,12 @@ public class SendAmountWizardFragment extends SendWizardFragment { sendListener.getTxData().setAmount(Wallet.SWEEP_ALL); } } else { - if (!evAmount.validate(maxFunds)) { + if (!etAmount.validate(maxFunds)) { return false; } if (sendListener != null) { - String xmr = evAmount.getAmount(); + String xmr = etAmount.getAmount(); if (xmr != null) { sendListener.getTxData().setAmount(Wallet.getAmountFromString(xmr)); } else { @@ -146,7 +138,7 @@ public class SendAmountWizardFragment extends SendWizardFragment { public void onResumeFragment() { super.onResumeFragment(); Timber.d("onResumeFragment()"); - Helper.hideKeyboard(getActivity()); + Helper.showKeyboard(getActivity()); final long funds = getTotalFunds(); maxFunds = 1.0 * funds / 1000000000000L; if (!sendListener.getActivityCallback().isStreetMode()) { @@ -157,10 +149,10 @@ public class SendAmountWizardFragment extends SendWizardFragment { getString(R.string.unknown_amount))); } // getAmount is null if exchange is in progress - if ((evAmount.getAmount() != null) && evAmount.getAmount().isEmpty()) { + if ((etAmount.getAmount() != null) && etAmount.getAmount().isEmpty()) { final BarcodeData data = sendListener.popBarcodeData(); if ((data != null) && (data.amount != null)) { - evAmount.setAmount(data.amount); + etAmount.setAmount(data.amount); } } } diff --git a/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendBtcAmountWizardFragment.java b/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendBtcAmountWizardFragment.java index 6728ec76..45a814f1 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendBtcAmountWizardFragment.java +++ b/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendBtcAmountWizardFragment.java @@ -31,8 +31,7 @@ import com.m2049r.xmrwallet.data.TxDataBtc; import com.m2049r.xmrwallet.model.Wallet; import com.m2049r.xmrwallet.util.Helper; import com.m2049r.xmrwallet.util.OkHttpHelper; -import com.m2049r.xmrwallet.widget.ExchangeBtcTextView; -import com.m2049r.xmrwallet.widget.NumberPadView; +import com.m2049r.xmrwallet.widget.ExchangeBtcEditText; import com.m2049r.xmrwallet.widget.SendProgressView; import com.m2049r.xmrwallet.xmrto.XmrToError; import com.m2049r.xmrwallet.xmrto.XmrToException; @@ -62,8 +61,7 @@ public class SendBtcAmountWizardFragment extends SendWizardFragment { } private TextView tvFunds; - private ExchangeBtcTextView evAmount; - private NumberPadView numberPad; + private ExchangeBtcEditText etAmount; private TextView tvXmrToParms; private SendProgressView evParams; @@ -86,24 +84,20 @@ public class SendBtcAmountWizardFragment extends SendWizardFragment { tvXmrToParms = view.findViewById(R.id.tvXmrToParms); - evAmount = view.findViewById(R.id.evAmount); - numberPad = view.findViewById(R.id.numberPad); - numberPad.setListener(evAmount); - - Helper.hideKeyboard(getActivity()); - + etAmount = view.findViewById(R.id.etAmount); + etAmount.requestFocus(); return view; } @Override public boolean onValidateFields() { - if (!evAmount.validate(maxBtc, minBtc)) { + if (!etAmount.validate(maxBtc, minBtc)) { return false; } if (sendListener != null) { TxDataBtc txDataBtc = (TxDataBtc) sendListener.getTxData(); - String btcString = evAmount.getAmount(); + String btcString = etAmount.getAmount(); if (btcString != null) { try { double btc = Double.parseDouble(btcString); @@ -122,10 +116,12 @@ public class SendBtcAmountWizardFragment extends SendWizardFragment { private void setBip70Mode() { TxDataBtc txDataBtc = (TxDataBtc) sendListener.getTxData(); - if (txDataBtc.getBip70() != null) { - numberPad.setVisibility(View.INVISIBLE); + if (txDataBtc.getBip70() == null) { + etAmount.setEditable(true); + Helper.showKeyboard(getActivity()); } else { - numberPad.setVisibility(View.VISIBLE); + etAmount.setEditable(false); + Helper.hideKeyboard(getActivity()); } } @@ -141,7 +137,6 @@ public class SendBtcAmountWizardFragment extends SendWizardFragment { public void onResumeFragment() { super.onResumeFragment(); Timber.d("onResumeFragment()"); - Helper.hideKeyboard(getActivity()); final long funds = getTotalFunds(); if (!sendListener.getActivityCallback().isStreetMode()) { tvFunds.setText(getString(R.string.send_available, @@ -153,7 +148,7 @@ public class SendBtcAmountWizardFragment extends SendWizardFragment { final BarcodeData data = sendListener.popBarcodeData(); if (data != null) { if (data.amount != null) { - evAmount.setAmount(data.amount); + etAmount.setAmount(data.amount); } } setBip70Mode(); @@ -171,7 +166,7 @@ public class SendBtcAmountWizardFragment extends SendWizardFragment { getView().post(new Runnable() { @Override public void run() { - evAmount.setRate(1.0d / orderParameters.getPrice()); + etAmount.setRate(1.0d / orderParameters.getPrice()); NumberFormat df = NumberFormat.getInstance(Locale.US); df.setMaximumFractionDigits(6); String min = df.format(orderParameters.getLowerLimit()); @@ -211,7 +206,7 @@ public class SendBtcAmountWizardFragment extends SendWizardFragment { } private void processOrderParmsError(final Exception ex) { - evAmount.setRate(0); + etAmount.setRate(0); orderParameters = null; maxBtc = 0; minBtc = 0; diff --git a/app/src/main/java/com/m2049r/xmrwallet/widget/ExchangeBtcTextView.java b/app/src/main/java/com/m2049r/xmrwallet/widget/ExchangeBtcEditText.java similarity index 76% rename from app/src/main/java/com/m2049r/xmrwallet/widget/ExchangeBtcTextView.java rename to app/src/main/java/com/m2049r/xmrwallet/widget/ExchangeBtcEditText.java index 7f1735b7..be47e0ce 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/widget/ExchangeBtcTextView.java +++ b/app/src/main/java/com/m2049r/xmrwallet/widget/ExchangeBtcEditText.java @@ -19,9 +19,12 @@ package com.m2049r.xmrwallet.widget; import android.content.Context; +import android.text.Editable; +import android.text.TextWatcher; import android.util.AttributeSet; import android.view.LayoutInflater; import android.widget.ArrayAdapter; +import android.widget.EditText; import android.widget.LinearLayout; import android.widget.Spinner; import android.widget.TextView; @@ -31,8 +34,7 @@ import com.m2049r.xmrwallet.util.Helper; import timber.log.Timber; -public class ExchangeBtcTextView extends LinearLayout - implements NumberPadView.NumberPadListener { +public class ExchangeBtcEditText extends LinearLayout { String btcAmount = null; String xmrAmount = null; @@ -67,7 +69,7 @@ public class ExchangeBtcTextView extends LinearLayout } void shakeAmountField() { - tvAmountA.startAnimation(Helper.getShakeAnimation(getContext())); + etAmountA.startAnimation(Helper.getShakeAnimation(getContext())); } void shakeExchangeField() { @@ -86,31 +88,35 @@ public class ExchangeBtcTextView extends LinearLayout public void setAmount(String btcAmount) { this.btcAmount = btcAmount; - tvAmountA.setText(btcAmount); + etAmountA.setText(btcAmount); xmrAmount = null; exchange(); } + public void setEditable(boolean editable) { + etAmountA.setEnabled(editable); + } + public String getAmount() { return btcAmount; } - TextView tvAmountA; + EditText etAmountA; TextView tvAmountB; Spinner sCurrencyA; Spinner sCurrencyB; - public ExchangeBtcTextView(Context context) { + public ExchangeBtcEditText(Context context) { super(context); initializeViews(context); } - public ExchangeBtcTextView(Context context, AttributeSet attrs) { + public ExchangeBtcEditText(Context context, AttributeSet attrs) { super(context, attrs); initializeViews(context); } - public ExchangeBtcTextView(Context context, + public ExchangeBtcEditText(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); @@ -125,13 +131,28 @@ public class ExchangeBtcTextView extends LinearLayout private void initializeViews(Context context) { LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); - inflater.inflate(R.layout.view_exchange_btc_text, this); + inflater.inflate(R.layout.view_exchange_btc_edit, this); } @Override protected void onFinishInflate() { super.onFinishInflate(); - tvAmountA = findViewById(R.id.tvAmountA); + etAmountA = findViewById(R.id.etAmountA); + etAmountA.addTextChangedListener(new TextWatcher() { + @Override + public void afterTextChanged(Editable s) { + exchange(); + } + + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + } + + }); tvAmountB = findViewById(R.id.tvAmountB); sCurrencyA = findViewById(R.id.sCurrencyA); sCurrencyB = findViewById(R.id.sCurrencyB); @@ -146,12 +167,14 @@ public class ExchangeBtcTextView extends LinearLayout new String[]{"XMR"}); sCurrencyB.setAdapter(xmrAdapter); sCurrencyB.setEnabled(false); + etAmountA.setFocusable(true); + etAmountA.setFocusableInTouchMode(true); } double xmrBtcRate = 0; public void exchange() { - btcAmount = tvAmountA.getText().toString(); + btcAmount = etAmountA.getText().toString(); if (!btcAmount.isEmpty() && (xmrBtcRate > 0)) { double xmr = xmrBtcRate * Double.parseDouble(btcAmount); xmrAmount = Helper.getFormattedAmount(xmr, true); @@ -161,38 +184,4 @@ public class ExchangeBtcTextView extends LinearLayout tvAmountB.setText(getResources().getString(R.string.send_amount_btc_xmr, xmrAmount)); Timber.d("%s BTC =%f> %s XMR", btcAmount, xmrBtcRate, xmrAmount); } - - // deal with attached numpad - @Override - public void onDigitPressed(final int digit) { - tvAmountA.append(String.valueOf(digit)); - exchange(); - } - - @Override - public void onPointPressed() { - //TODO locale? - if (tvAmountA.getText().toString().indexOf('.') == -1) { - if (tvAmountA.getText().toString().isEmpty()) { - tvAmountA.append("0"); - } - tvAmountA.append("."); - } - } - - @Override - public void onBackSpacePressed() { - String entry = tvAmountA.getText().toString(); - int length = entry.length(); - if (length > 0) { - tvAmountA.setText(entry.substring(0, entry.length() - 1)); - exchange(); - } - } - - @Override - public void onClearAll() { - tvAmountA.setText(null); - exchange(); - } } \ No newline at end of file diff --git a/app/src/main/java/com/m2049r/xmrwallet/widget/ExchangeTextView.java b/app/src/main/java/com/m2049r/xmrwallet/widget/ExchangeEditText.java similarity index 90% rename from app/src/main/java/com/m2049r/xmrwallet/widget/ExchangeTextView.java rename to app/src/main/java/com/m2049r/xmrwallet/widget/ExchangeEditText.java index f0db87ab..901c4e00 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/widget/ExchangeTextView.java +++ b/app/src/main/java/com/m2049r/xmrwallet/widget/ExchangeEditText.java @@ -21,11 +21,13 @@ package com.m2049r.xmrwallet.widget; import android.content.Context; import android.os.Handler; import android.os.Looper; +import android.text.Editable; +import android.text.TextWatcher; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; import android.widget.AdapterView; -import android.widget.ImageButton; +import android.widget.EditText; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ProgressBar; @@ -43,10 +45,7 @@ import java.util.Locale; import timber.log.Timber; -public class ExchangeTextView extends LinearLayout - implements NumberPadView.NumberPadListener { - - private static String MAX = "\u221E"; +public class ExchangeEditText extends LinearLayout { String xmrAmount = null; String notXmrAmount = null; @@ -89,7 +88,7 @@ public class ExchangeTextView extends LinearLayout } void shakeAmountField() { - tvAmountA.startAnimation(Helper.getShakeAnimation(getContext())); + etAmountA.startAnimation(Helper.getShakeAnimation(getContext())); } void shakeExchangeField() { @@ -99,7 +98,7 @@ public class ExchangeTextView extends LinearLayout public void setAmount(String xmrAmount) { if (xmrAmount != null) { setCurrencyA(0); - tvAmountA.setText(xmrAmount); + etAmountA.setText(xmrAmount); setXmr(xmrAmount); this.notXmrAmount = null; doExchange(); @@ -114,7 +113,7 @@ public class ExchangeTextView extends LinearLayout return xmrAmount; } - TextView tvAmountA; + EditText etAmountA; TextView tvAmountB; Spinner sCurrencyA; Spinner sCurrencyB; @@ -146,17 +145,17 @@ public class ExchangeTextView extends LinearLayout return sCurrencyB.getSelectedItemPosition(); } - public ExchangeTextView(Context context) { + public ExchangeEditText(Context context) { super(context); initializeViews(context); } - public ExchangeTextView(Context context, AttributeSet attrs) { + public ExchangeEditText(Context context, AttributeSet attrs) { super(context, attrs); initializeViews(context); } - public ExchangeTextView(Context context, + public ExchangeEditText(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); @@ -171,13 +170,28 @@ public class ExchangeTextView extends LinearLayout private void initializeViews(Context context) { LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); - inflater.inflate(R.layout.view_exchange_text, this); + inflater.inflate(R.layout.view_exchange_edit, this); } @Override protected void onFinishInflate() { super.onFinishInflate(); - tvAmountA = findViewById(R.id.tvAmountA); + etAmountA = findViewById(R.id.etAmountA); + etAmountA.addTextChangedListener(new TextWatcher() { + @Override + public void afterTextChanged(Editable s) { + doExchange(); + } + + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + } + + }); tvAmountB = findViewById(R.id.tvAmountB); sCurrencyA = findViewById(R.id.sCurrencyA); sCurrencyB = findViewById(R.id.sCurrencyB); @@ -317,7 +331,7 @@ public class ExchangeTextView extends LinearLayout boolean prepareExchange() { Timber.d("prepareExchange()"); - String enteredAmount = tvAmountA.getText().toString(); + String enteredAmount = etAmountA.getText().toString(); if (!enteredAmount.isEmpty()) { String cleanAmount = ""; if (getCurrencyA() == 0) { @@ -426,37 +440,4 @@ public class ExchangeTextView extends LinearLayout public void setOnFailedExchangeListener(OnFailedExchangeListener listener) { onFailedExchangeListener = listener; } - - @Override - public void onDigitPressed(final int digit) { - tvAmountA.append(String.valueOf(digit)); - doExchange(); - } - - @Override - public void onPointPressed() { - //TODO locale? - if (tvAmountA.getText().toString().indexOf('.') == -1) { - if (tvAmountA.getText().toString().isEmpty()) { - tvAmountA.append("0"); - } - tvAmountA.append("."); - } - } - - @Override - public void onBackSpacePressed() { - String entry = tvAmountA.getText().toString(); - int length = entry.length(); - if (length > 0) { - tvAmountA.setText(entry.substring(0, entry.length() - 1)); - doExchange(); - } - } - - @Override - public void onClearAll() { - tvAmountA.setText(null); - doExchange(); - } } diff --git a/app/src/main/java/com/m2049r/xmrwallet/widget/ExchangeView.java b/app/src/main/java/com/m2049r/xmrwallet/widget/ExchangeView.java index 54d59246..0b546778 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/widget/ExchangeView.java +++ b/app/src/main/java/com/m2049r/xmrwallet/widget/ExchangeView.java @@ -48,18 +48,9 @@ import java.util.Locale; import timber.log.Timber; -// TODO combine this with ExchangeTextView - -public class ExchangeView extends LinearLayout - implements NumberPadView.NumberPadListener { - - public void enableSoftKeyboard(final boolean isEnabled) { - etAmount.getEditText().setShowSoftInputOnFocus(isEnabled); - } - - public boolean focus() { - return etAmount.requestFocus(); - } +public class ExchangeView extends LinearLayout { + String xmrAmount = null; + String notXmrAmount = null; public void enable(boolean enable) { etAmount.setEnabled(enable); @@ -67,9 +58,6 @@ public class ExchangeView extends LinearLayout sCurrencyB.setEnabled(enable); } - String xmrAmount = null; - String notXmrAmount = null; - void setXmr(String xmr) { xmrAmount = xmr; if (onNewAmountListener != null) { @@ -482,31 +470,4 @@ public class ExchangeView extends LinearLayout public void setOnFailedExchangeListener(OnFailedExchangeListener listener) { onFailedExchangeListener = listener; } - - @Override - public void onDigitPressed(final int digit) { - etAmount.getEditText().append(String.valueOf(digit)); - } - - @Override - public void onPointPressed() { - //TODO locale? - if (etAmount.getEditText().getText().toString().indexOf('.') == -1) { - etAmount.getEditText().append("."); - } - } - - @Override - public void onBackSpacePressed() { - Editable editable = etAmount.getEditText().getText(); - int length = editable.length(); - if (length > 0) { - editable.delete(length - 1, length); - } - } - - @Override - public void onClearAll() { - etAmount.getEditText().getText().clear(); - } } diff --git a/app/src/main/java/com/m2049r/xmrwallet/widget/NumberPadView.java b/app/src/main/java/com/m2049r/xmrwallet/widget/NumberPadView.java deleted file mode 100644 index 6a164742..00000000 --- a/app/src/main/java/com/m2049r/xmrwallet/widget/NumberPadView.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.m2049r.xmrwallet.widget; - - -import android.content.Context; -import android.support.annotation.Nullable; -import android.util.AttributeSet; -import android.view.View; -import android.widget.LinearLayout; - -import com.m2049r.xmrwallet.R; - -public class NumberPadView extends LinearLayout - implements View.OnClickListener, View.OnLongClickListener { - - @Override - public void onClick(final View view) { - if (listener == null) { - throw new IllegalArgumentException("NumberPadListener has to be set, use setListener() to set it."); - } - switch (view.getId()) { - case R.id.numberPadPoint: - listener.onPointPressed(); - break; - case R.id.numberPadBackSpace: - listener.onBackSpacePressed(); - break; - default: - if (view.getTag() != null) { - listener.onDigitPressed(Integer.parseInt(view.getTag().toString())); - } - } - } - - @Override - public boolean onLongClick(final View view) { - if (view.getId() == R.id.numberPadBackSpace) { - listener.onClearAll(); - return true; - } - return false; - } - - public void setListener(final NumberPadListener listener) { - this.listener = listener; - } - - public interface NumberPadListener { - void onDigitPressed(final int digit); - - void onBackSpacePressed(); - - void onPointPressed(); - - void onClearAll(); - } - - private NumberPadListener listener; - - public NumberPadView(final Context context) { - this(context, null); - } - - public NumberPadView(final Context context, - @Nullable final AttributeSet attrs) { - this(context, attrs, 0); - } - - public NumberPadView(final Context context, @Nullable final AttributeSet attrs, - final int defStyleAttr) { - super(context, attrs, defStyleAttr); - final View view = View.inflate(context, R.layout.view_number_pad, this); - setOrientation(VERTICAL); - view.findViewById(R.id.numberPad0).setOnClickListener(this); - view.findViewById(R.id.numberPad1).setOnClickListener(this); - view.findViewById(R.id.numberPad2).setOnClickListener(this); - view.findViewById(R.id.numberPad3).setOnClickListener(this); - view.findViewById(R.id.numberPad4).setOnClickListener(this); - view.findViewById(R.id.numberPad5).setOnClickListener(this); - view.findViewById(R.id.numberPad6).setOnClickListener(this); - view.findViewById(R.id.numberPad7).setOnClickListener(this); - view.findViewById(R.id.numberPad8).setOnClickListener(this); - view.findViewById(R.id.numberPad9).setOnClickListener(this); - view.findViewById(R.id.numberPadPoint).setOnClickListener(this); - view.findViewById(R.id.numberPadBackSpace).setOnClickListener(this); - view.findViewById(R.id.numberPadBackSpace).setOnLongClickListener(this); - } -} diff --git a/app/src/main/res/layout/fragment_send_address.xml b/app/src/main/res/layout/fragment_send_address.xml index b874980d..de4a5730 100644 --- a/app/src/main/res/layout/fragment_send_address.xml +++ b/app/src/main/res/layout/fragment_send_address.xml @@ -75,7 +75,7 @@ android:drawableStart="@drawable/ic_check_gray_24dp" android:drawablePadding="8dp" android:gravity="center" - android:text="@string/info_paymentid_intergrated" + android:text="@string/info_paymentid_integrated" android:textSize="18sp" android:visibility="invisible" /> diff --git a/app/src/main/res/layout/fragment_send_amount.xml b/app/src/main/res/layout/fragment_send_amount.xml index f6cdfcaa..7d70d95e 100644 --- a/app/src/main/res/layout/fragment_send_amount.xml +++ b/app/src/main/res/layout/fragment_send_amount.xml @@ -27,35 +27,19 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentEnd="true" - android:paddingEnd="12dp" android:paddingStart="12dp" + android:paddingEnd="12dp" android:src="@drawable/ic_all_inclusive_24dp" android:visibility="visible" /> - - - - - - - + android:layout_height="wrap_content" + android:layout_marginTop="16dp" + android:layout_marginBottom="16dp" + android:orientation="vertical" /> - - - - diff --git a/app/src/main/res/layout/view_exchange_btc_text.xml b/app/src/main/res/layout/view_exchange_btc_edit.xml similarity index 91% rename from app/src/main/res/layout/view_exchange_btc_text.xml rename to app/src/main/res/layout/view_exchange_btc_edit.xml index 5c4434c0..156dbd34 100644 --- a/app/src/main/res/layout/view_exchange_btc_text.xml +++ b/app/src/main/res/layout/view_exchange_btc_edit.xml @@ -17,8 +17,8 @@ android:gravity="center" android:textAlignment="center" /> - - - - + android:layout_marginStart="8sp" + android:layout_marginEnd="0sp"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/values-cat/strings.xml b/app/src/main/res/values-cat/strings.xml index 774d933f..810124c6 100644 --- a/app/src/main/res/values-cat/strings.xml +++ b/app/src/main/res/values-cat/strings.xml @@ -58,7 +58,7 @@ Balanç: %2$s BTC (%1$s XMR) - ID de pagment integrat + ✔ ID de pagment integrat Preparant la seva transacció Creant ordre XMR.TO diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index c54373f0..779a90f4 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -59,7 +59,7 @@ Guthaben: %2$s BTC (%1$s XMR) - Zahlungs-ID integriert + ✔ Zahlungs-ID integriert Bereite deine Transaktion vor Erstelle XMR.TO-Auftrag diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml index 972f5d99..26a6b9cf 100644 --- a/app/src/main/res/values-el/strings.xml +++ b/app/src/main/res/values-el/strings.xml @@ -57,7 +57,7 @@ Σύνολο: %2$s BTC (%1$s XMR) - ID πληρωμής ενσωματωμένο + ✔ ID πληρωμής ενσωματωμένο Προετοιμασία της συναλλαγής σου Δημιουργία εντολής με XMR.TO diff --git a/app/src/main/res/values-eo/strings.xml b/app/src/main/res/values-eo/strings.xml index 0934ef0b..d118909a 100644 --- a/app/src/main/res/values-eo/strings.xml +++ b/app/src/main/res/values-eo/strings.xml @@ -58,7 +58,7 @@ Saldo: %2$s BTC (%1$s XMR) - Paga-ID integriĝis + ✔ Paga-ID integriĝis Preparante vian transakcion Kreante mendon al XMR.TO diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index c701bf01..9ae51116 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -30,7 +30,7 @@ Toca para mostrar código QR - ID de pago integrado + ✔ ID de pago integrado Preparando tu transacción ¡ID de transacción copiado al portapapeles! diff --git a/app/src/main/res/values-et/strings.xml b/app/src/main/res/values-et/strings.xml index 1f35f299..c1bd8ac0 100644 --- a/app/src/main/res/values-et/strings.xml +++ b/app/src/main/res/values-et/strings.xml @@ -58,7 +58,7 @@ Kontojääk: %2$s BTC (%1$s XMR) - Makse ID integreeritud + ✔ Makse ID integreeritud Valmistan ülekannet ette Loon XMR.TO tellimust diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 6419876b..25aacaba 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -59,7 +59,7 @@ Solde : %2$s BTC (%1$s XMR) - ID de Paiement intégré + ✔ ID de Paiement intégré Préparation de votre transaction Création de l\'ordre XMR.TO diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index ea714cf2..634280cd 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -58,7 +58,7 @@ Egyenleg: %2$s BTC (%1$s XMR) - Fizetési azonosító integrálva + ✔ Fizetési azonosító integrálva Tranzakció előkészítése XMR.TO megrendelés létrehozása diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index dc3d6b49..ccf58892 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -59,7 +59,7 @@ Saldo: %2$s BTC (%1$s XMR) - ID pagamento integrato + ✔ ID pagamento integrato Preparando la tua transazione Creando l\'ordine XMR.TO diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 28c9d4e0..968c6fa3 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -59,7 +59,7 @@ 残高: %2$s BTC (%1$s XMR) - ペイメントID組み込み済み + ✔ ペイメントID組み込み済み 取引を準備しています XMR.TO の注文を作成しています diff --git a/app/src/main/res/values-nb/strings.xml b/app/src/main/res/values-nb/strings.xml index ca08dd72..767b9320 100644 --- a/app/src/main/res/values-nb/strings.xml +++ b/app/src/main/res/values-nb/strings.xml @@ -57,7 +57,7 @@ Saldo: %2$s BTC (%1$s XMR) - Betalings ID integrert + ✔ Betalings ID integrert Forbereder din transaksjon Lager XMR.TO ordre diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 2e5e4ebf..18bff3c3 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -58,7 +58,7 @@ Saldo: %2$s BTC (%1$s XMR) - Betalings-ID geïntegreerd + ✔ Betalings-ID geïntegreerd Transactie wordt voorbereid XMR.TO-opdracht maken diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index eae4f1af..13d54bc4 100755 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -58,7 +58,7 @@ Saldo: %2$s BTC (%1$s XMR) - ID do pagamento integrado + ✔ ID do pagamento integrado Preparando sua transação Criando a ordem no XMR.TO diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index 6baf18f7..028b6be8 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -58,7 +58,7 @@ Saldo: %2$s BTC (%1$s XMR) - ID do pagamento integrado + ✔ ID do pagamento integrado A preparar a transacção A criar um pedido XMR.TO diff --git a/app/src/main/res/values-ro/strings.xml b/app/src/main/res/values-ro/strings.xml index 8ceb2b9b..c07e40c8 100644 --- a/app/src/main/res/values-ro/strings.xml +++ b/app/src/main/res/values-ro/strings.xml @@ -57,7 +57,7 @@ Balanță: %2$s BTC (%1$s XMR) - Payment ID integrat + ✔ Payment ID integrat Se pregătește tranzacția Creearea ordinului XMR.TO diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index a5a662ac..19b7a348 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -59,7 +59,7 @@ Баланс: %2$s BTC (%1$s XMR) - Интегрированный ID платежа + ✔ Интегрированный ID платежа Подготовка транзакции Создание заказа XMR.TO diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml index 3434dbf2..f7a5caf5 100644 --- a/app/src/main/res/values-sk/strings.xml +++ b/app/src/main/res/values-sk/strings.xml @@ -59,7 +59,7 @@ Zostatok: %2$s BTC (%1$s XMR) - Payment ID integrované + ✔ Payment ID integrované Pripravujem transakciu Vytváram objednávku na XMR.TO diff --git a/app/src/main/res/values-sr/strings.xml b/app/src/main/res/values-sr/strings.xml index 0f6d9be9..81276a4d 100644 --- a/app/src/main/res/values-sr/strings.xml +++ b/app/src/main/res/values-sr/strings.xml @@ -59,7 +59,7 @@ Stanje: %2$s BTC (%1$s XMR) - ID plaćanja integrisan + ✔ ID plaćanja integrisan Priprema tvoje transakcije Kreiranje XMR.TO Nalog diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 61d08e55..6b7ebb0d 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -51,7 +51,7 @@ Saldo: %2$s BTC (%1$s XMR) - Betalnings-ID integrerat + ✔ Betalnings-ID integrerat Förbereder din transaktion Skapar XMR.TO-beställning diff --git a/app/src/main/res/values-ua/strings.xml b/app/src/main/res/values-ua/strings.xml index 9dd22147..67cf0221 100644 --- a/app/src/main/res/values-ua/strings.xml +++ b/app/src/main/res/values-ua/strings.xml @@ -59,7 +59,7 @@ Баланс: %2$s BTC (%1$s XMR) - Інтегрований ID платежу + ✔ Інтегрований ID платежу Підготовка транзакції Створення заявки XMR.TO diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 667d6021..779b27f1 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -44,7 +44,7 @@ 至多%1$s BTC将会即刻发送! ]]> 余额: %2$s BTC (%1$s XMR) - 支付ID已集成 + ✔ 支付ID已集成 正在为您的交易做准备工作 创建XMR.TO订单 XMR.TO订单查询中 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index b3537001..a97a6a7d 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -59,7 +59,7 @@ 餘額:%2$s BTC (%1$s XMR) - 已加入付款 ID + ✔ 已加入付款 ID 正在準備你的交易 建立 XMR.TO 訂單 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 01c9c2f4..d20c27a3 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -59,7 +59,7 @@ Balance: %2$s BTC (%1$s XMR) - Payment ID integrated + ✔ Payment ID integrated Preparing your transaction Creating XMR.TO Order