diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/customwidgets/exchangecountrylistingdialog/ExchangeRateCurrencyListingDialog.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/customwidgets/exchangecountrylistingdialog/ExchangeRateCurrencyListingDialog.java index fa9a72f7..7ab9ae48 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/customwidgets/exchangecountrylistingdialog/ExchangeRateCurrencyListingDialog.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/customwidgets/exchangecountrylistingdialog/ExchangeRateCurrencyListingDialog.java @@ -78,7 +78,6 @@ public class ExchangeRateCurrencyListingDialog extends DialogFragment implements @Override public void onStart() { - super.onStart(); super.onStart(); Window window = getDialog().getWindow(); if (window != null) { diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/view/amountdetail/AmountDetailExRateCountryListingDialog.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/view/amountdetail/AmountDetailExRateCountryListingDialog.java index 19125377..23c1e3d9 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/view/amountdetail/AmountDetailExRateCountryListingDialog.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/view/amountdetail/AmountDetailExRateCountryListingDialog.java @@ -10,6 +10,7 @@ import android.support.v7.widget.RecyclerView; import android.text.Editable; import android.text.TextWatcher; import android.view.View; +import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; import android.view.inputmethod.InputMethodManager; @@ -33,8 +34,7 @@ public class AmountDetailExRateCountryListingDialog extends DialogFragment imple private EditText noCurrencyFoundView; private EditText searchEditTextView; private ExRateCurrencyListingAmountDetailRvAdapter currencyListingAdapter; - private Window window; - private boolean windowHieghtNotFixed=true; + private TextView dialogTitle; @Override @@ -50,16 +50,8 @@ public class AmountDetailExRateCountryListingDialog extends DialogFragment imple builder.setView(view); - Dialog dialog = builder.create(); - try { - this.window = dialog.getWindow(); - window.setBackgroundDrawableResource(R.drawable.ic_rounded_country_listing_gray); - - } catch (NullPointerException e) { - - } initialize(); - return dialog; + return builder.create(); } private void initialize() { cancelButton.setOnClickListener(this); @@ -70,7 +62,7 @@ public class AmountDetailExRateCountryListingDialog extends DialogFragment imple LineDividerItemDecoration lineDividerItemDecoration = new LineDividerItemDecoration(getActivity(), LineDividerItemDecoration.VERTICAL_LIST); currencyListRv.addItemDecoration(lineDividerItemDecoration); dialogTitle.setText("Select Currency"); - noCurrencyFoundView.setText("No currency found."); + noCurrencyFoundView.setHint("No currency found."); } @@ -88,16 +80,11 @@ public class AmountDetailExRateCountryListingDialog extends DialogFragment imple @Override public void onStart() { super.onStart(); - if(windowHieghtNotFixed&&window!=null) - { - WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); - lp.copyFrom(window.getAttributes()); - lp.height = WindowManager.LayoutParams.MATCH_PARENT; - float multi = getActivity().getResources().getDisplayMetrics().density; - lp.verticalMargin=10*multi; - window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); - window.setAttributes(lp); - windowHieghtNotFixed=false; + Window window = getDialog().getWindow(); + if (window != null) { + window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); + window.setBackgroundDrawableResource(R.drawable.ic_rounded_grey_bg_with_inset); + } } @@ -121,13 +108,15 @@ public class AmountDetailExRateCountryListingDialog extends DialogFragment imple private void showCurrencyNotFoundView(boolean action) { if (action) { - int rvHeight = currencyListRv.getHeight(); - noCurrencyFoundView.setHeight(rvHeight); - currencyListRv.setVisibility(View.INVISIBLE); - noCurrencyFoundView.setVisibility(View.VISIBLE); + if (currencyListRv.getVisibility() == View.VISIBLE) { + currencyListRv.setVisibility(View.GONE); + noCurrencyFoundView.setVisibility(View.VISIBLE); + } } else { - noCurrencyFoundView.setVisibility(View.INVISIBLE); - currencyListRv.setVisibility(View.VISIBLE); + if (currencyListRv.getVisibility() != View.VISIBLE) { + noCurrencyFoundView.setVisibility(View.GONE); + currencyListRv.setVisibility(View.VISIBLE); + } } } diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/view/amountdetail/AmountDetailSendMoneyFragment.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/view/amountdetail/AmountDetailSendMoneyFragment.java index 8d920e4a..09db911f 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/view/amountdetail/AmountDetailSendMoneyFragment.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/view/amountdetail/AmountDetailSendMoneyFragment.java @@ -181,14 +181,7 @@ public class AmountDetailSendMoneyFragment extends BaseFragment implements View. public void onClick(View v) { switch (v.getId()) { case R.id.amountDetailContinueButton: -// if(validateAmountIsNotEmpty(sendMoneyEditText.getText().toString())) { -// ((SendMoneyActionListener) getActivity()).getPresenter().setSendingAmount(sendMoneyEditText.getText().toString(),selectedsendingCurrency,selectedExRate,selectedTransferFeeAmount); -// ((SendMoneyV2Activity) getActivity()).addScreenToSendMoney(R.layout.fragment_verification_send_money_v2, true); -// } -// else -// { -// showToastMessage("Please specify sending amount."); -// } + if (shouldCalculateExRate) { if (shouldCaulatedByRecipient && !validateAmountIsNotEmpty(recieveMoneyEditText.getText().toString())) { @@ -264,239 +257,250 @@ public class AmountDetailSendMoneyFragment extends BaseFragment implements View. } - private void showSendAndRecieveAmount (String sendAmount, String recieveAmount){ - updateSendAmount(sendAmount); - updateRecievingAmount(recieveAmount); - } + private void showSendAndRecieveAmount(String sendAmount, String recieveAmount) { + updateSendAmount(sendAmount); + updateRecievingAmount(recieveAmount); + } - private boolean validateAmountIsNotEmpty (String amount){ - return amount != null && amount.length() > 0; + private boolean validateAmountIsNotEmpty(String amount) { + return amount != null && amount.length() > 0; + } + + @Override + public void onCurrencySelected(RecipientCurrencyModel selectedCurrency) { + if (amountDetailRelatedData != null && amountDetailRelatedData.getDefaultSelectedCurrency() != null && + amountDetailRelatedData.getDefaultSelectedCurrency().getCountryName() != null && + amountDetailRelatedData.getDefaultSelectedCurrency().getCurrencyCode() != null && + amountDetailRelatedData.getDefaultSelectedCurrency().getCountryName().length() > 0 && + amountDetailRelatedData.getDefaultSelectedCurrency().getCurrencyCode().length() > 0) { + if (!amountDetailRelatedData.getDefaultSelectedCurrency().getCurrencyCode().equalsIgnoreCase(selectedCurrency.getCurrencyCode()) && !amountDetailRelatedData.getDefaultSelectedCurrency().getCountryName().equalsIgnoreCase(selectedCurrency.getCountryCode())) { + updateRecievingAmount(""); + updateButtonToCalculate(true); + shouldCaulatedByRecipient = false; + } } - @Override - public void onCurrencySelected (RecipientCurrencyModel selectedCurrency){ - amountDetailRelatedData.setDefaultSelectedCurrency(selectedCurrency); + amountDetailRelatedData.setDefaultSelectedCurrency(selectedCurrency); - if (exRateCountryListingDialog != null) - exRateCountryListingDialog.dismiss(); - exRateCountryListingDialog = null; + if (exRateCountryListingDialog != null) + exRateCountryListingDialog.dismiss(); + exRateCountryListingDialog = null; - showSelectedCurrency(amountDetailRelatedData.getDefaultSelectedCurrency().getCountryCode(), amountDetailRelatedData.getDefaultSelectedCurrency().getCurrencyCode()); - } + showSelectedCurrency(amountDetailRelatedData.getDefaultSelectedCurrency().getCountryCode(), amountDetailRelatedData.getDefaultSelectedCurrency().getCurrencyCode()); - @Override - public boolean onEditorAction (TextView v,int actionId, KeyEvent event){ - switch (v.getId()) { - case R.id.sendAmountEdTxt: - if (actionId == EditorInfo.IME_ACTION_DONE) { - hideKeyBoard(); - shouldCaulatedByRecipient = false; - if (validateAmountIsNotEmpty(sendMoneyEditText.getText().toString())) - getForex(); - else - showToastMessage("Please specify sending amount."); - } - return true; - - case R.id.receiveAmountEdTxt: - if (actionId == EditorInfo.IME_ACTION_DONE) { - hideKeyBoard(); - shouldCaulatedByRecipient = true; - if (validateAmountIsNotEmpty(recieveMoneyEditText.getText().toString())) - getForex(); - else - showToastMessage("Please specify recieving amount."); - } - return true; + } + + @Override + public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { + switch (v.getId()) { + case R.id.sendAmountEdTxt: + if (actionId == EditorInfo.IME_ACTION_DONE) { + hideKeyBoard(); + shouldCaulatedByRecipient = false; + if (validateAmountIsNotEmpty(sendMoneyEditText.getText().toString())) + getForex(); + else + showToastMessage("Please specify sending amount."); + } + return true; + + case R.id.receiveAmountEdTxt: + if (actionId == EditorInfo.IME_ACTION_DONE) { + hideKeyBoard(); + shouldCaulatedByRecipient = true; + if (validateAmountIsNotEmpty(recieveMoneyEditText.getText().toString())) + getForex(); + else + showToastMessage("Please specify recieving amount."); + } + return true; - } - return false; } + return false; + } - public class ExchangeRateCalcObserver extends GenericApiObserverResponse { - - @Override - protected void onSuccess(ExchangeCalculationApiResponse exchangeCalculationApiResponse) { - if (isUIReady()) { - showProgressBar(false, ""); - if (exchangeCalculationApiResponse.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2)) { - ExchangeCalculationModel data = exchangeCalculationApiResponse.getData(); - selectedTransferFeeAmount = data.getScCharge(); - selectedExRate = data.getExRateDisplay(); - selectedExRateWithoutTrunc=data.getExRate(); - selectedRecipientAmount = data.getpAmt(); - selectedSendAmount = data.getCollAmt(); - selectedsendingCurrency = data.getCollCurr(); - selectedExRateId = data.getExrateId(); - - String transferDisplay = " - " + selectedTransferFeeAmount + " " + selectedsendingCurrency + " (Transfer Fee Included)"; - String exRateDisplay = " " + selectedExRate + " (Current Exchange Rate)"; - - showTransferfeeAndExRate(true,transferDisplay, exRateDisplay); - showSendAndRecieveAmount(selectedSendAmount, selectedRecipientAmount); - updateButtonToCalculate(false); - - } else - showPopUpMessage(exchangeCalculationApiResponse.getMsg(), CustomAlertDialog.AlertType.FAILED, null); - } - } + public class ExchangeRateCalcObserver extends GenericApiObserverResponse { - @Override - public void onFailed(String message) { + @Override + protected void onSuccess(ExchangeCalculationApiResponse exchangeCalculationApiResponse) { + if (isUIReady()) { showProgressBar(false, ""); - showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, null); + if (exchangeCalculationApiResponse.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2)) { + ExchangeCalculationModel data = exchangeCalculationApiResponse.getData(); + selectedTransferFeeAmount = data.getScCharge(); + selectedExRate = data.getExRateDisplay(); + selectedExRateWithoutTrunc = data.getExRate(); + selectedRecipientAmount = data.getpAmt(); + selectedSendAmount = data.getCollAmt(); + selectedsendingCurrency = data.getCollCurr(); + selectedExRateId = data.getExrateId(); + + String transferDisplay = " - " + selectedTransferFeeAmount + " " + selectedsendingCurrency + " (Transfer Fee Included)"; + String exRateDisplay = " " + selectedExRate + " (Current Exchange Rate)"; + + showTransferfeeAndExRate(true, transferDisplay, exRateDisplay); + showSendAndRecieveAmount(selectedSendAmount, selectedRecipientAmount); + updateButtonToCalculate(false); + + } else + showPopUpMessage(exchangeCalculationApiResponse.getMsg(), CustomAlertDialog.AlertType.FAILED, null); } + } - @Override - protected void onConnectionNotEstablished(String message) { - showProgressBar(false, ""); - showPopUpMessage(message, CustomAlertDialog.AlertType.NO_INTERNET, null); - } + @Override + public void onFailed(String message) { + showProgressBar(false, ""); + showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, null); } - public class AmountDetailRelatedDataObserver extends GenericApiObserverResponse { + @Override + protected void onConnectionNotEstablished(String message) { + showProgressBar(false, ""); + showPopUpMessage(message, CustomAlertDialog.AlertType.NO_INTERNET, null); + } + } - @Override - protected void onSuccess(AmountDetailRelatedDataModel amountDetailRelatedDataModel) { - if (isUIReady()) { - amountDetailRelatedData = amountDetailRelatedDataModel; - if (amountDetailRelatedData.getDefaultSelectedCurrency() != null) - showSelectedCurrency(amountDetailRelatedData.getDefaultSelectedCurrency().getCountryCode(), amountDetailRelatedData.getDefaultSelectedCurrency().getCurrencyCode()); - updateButtonToCalculate(true); - } - scheduleTaskLater(() -> { - amountDetailRelatedData = amountDetailRelatedDataModel; - if (amountDetailRelatedData.getDefaultSelectedCurrency() != null) - showSelectedCurrency(amountDetailRelatedData.getDefaultSelectedCurrency().getCountryCode(), amountDetailRelatedData.getDefaultSelectedCurrency().getCurrencyCode()); - updateButtonToCalculate(true); + public class AmountDetailRelatedDataObserver extends GenericApiObserverResponse { - }); + @Override + protected void onSuccess(AmountDetailRelatedDataModel amountDetailRelatedDataModel) { + if (isUIReady()) { + amountDetailRelatedData = amountDetailRelatedDataModel; + if (amountDetailRelatedData.getDefaultSelectedCurrency() != null) + showSelectedCurrency(amountDetailRelatedData.getDefaultSelectedCurrency().getCountryCode(), amountDetailRelatedData.getDefaultSelectedCurrency().getCurrencyCode()); + updateButtonToCalculate(true); } + scheduleTaskLater(() -> { + amountDetailRelatedData = amountDetailRelatedDataModel; + if (amountDetailRelatedData.getDefaultSelectedCurrency() != null) + showSelectedCurrency(amountDetailRelatedData.getDefaultSelectedCurrency().getCountryCode(), amountDetailRelatedData.getDefaultSelectedCurrency().getCurrencyCode()); + updateButtonToCalculate(true); - @Override - public void onFailed(String message) { - - } + }); + } - @Override - protected void onConnectionNotEstablished(String message) { + @Override + public void onFailed(String message) { - } } - private boolean validateAll () - { - if (validateAmountIsNotEmpty(sendMoneyEditText.getText().toString())) { - if (validateAmountIsNotEmpty(sendMoneyEditText.getText().toString())) - return true; + @Override + protected void onConnectionNotEstablished(String message) { - else { - showToastMessage("Please specify recieving amount."); - return false; - } + } + } + + private boolean validateAll() { + if (validateAmountIsNotEmpty(sendMoneyEditText.getText().toString())) { + if (validateAmountIsNotEmpty(sendMoneyEditText.getText().toString())) + return true; - } else { - showToastMessage("Please specify sending amount."); + else { + showToastMessage("Please specify recieving amount."); return false; } - } - private void updateButtonToCalculate ( boolean action) - { - shouldCalculateExRate = action; - if (action) - continueBtn.setText("Calculate"); - else - continueBtn.setText("Continue"); - } - private void updateSendAmount (String amount) - { - registerAvailableTextWatchersForEditText(sendMoneyEditText, false); - sendMoneyEditText.setText(amount); - registerAvailableTextWatchersForEditText(sendMoneyEditText, true); - } - private void updateRecievingAmount (String amount) - { - registerAvailableTextWatchersForEditText(recieveMoneyEditText, false); - recieveMoneyEditText.setText(amount); - registerAvailableTextWatchersForEditText(recieveMoneyEditText, true); + } else { + showToastMessage("Please specify sending amount."); + return false; } + } - private void registerTextWatchers ( boolean action){ - if (action) { - if (sendAmountTextWatcher == null) - sendAmountTextWatcher = new SendAmountTextWatcher(); - if (recepientAmountTextWatcher == null) - recepientAmountTextWatcher = new RecipientAmountTextWatcher(); - - sendMoneyEditText.addTextChangedListener(sendAmountTextWatcher); - recieveMoneyEditText.addTextChangedListener(recepientAmountTextWatcher); - } else { - sendMoneyEditText.addTextChangedListener(null); - recieveMoneyEditText.addTextChangedListener(null); - } + private void updateButtonToCalculate(boolean action) { + shouldCalculateExRate = action; + if (action) + continueBtn.setText("Calculate"); + else + continueBtn.setText("Continue"); + } + + private void updateSendAmount(String amount) { + registerAvailableTextWatchersForEditText(sendMoneyEditText, false); + sendMoneyEditText.setText(amount); + registerAvailableTextWatchersForEditText(sendMoneyEditText, true); + } + + private void updateRecievingAmount(String amount) { + registerAvailableTextWatchersForEditText(recieveMoneyEditText, false); + recieveMoneyEditText.setText(amount); + registerAvailableTextWatchersForEditText(recieveMoneyEditText, true); + } + + private void registerTextWatchers(boolean action) { + if (action) { + if (sendAmountTextWatcher == null) + sendAmountTextWatcher = new SendAmountTextWatcher(); + if (recepientAmountTextWatcher == null) + recepientAmountTextWatcher = new RecipientAmountTextWatcher(); + + sendMoneyEditText.addTextChangedListener(sendAmountTextWatcher); + recieveMoneyEditText.addTextChangedListener(recepientAmountTextWatcher); + } else { + sendMoneyEditText.addTextChangedListener(null); + recieveMoneyEditText.addTextChangedListener(null); } + } - private void registerAvailableTextWatchersForEditText (EditText editText,boolean action){ - switch (editText.getId()) { - case R.id.sendAmountEdTxt: - if (action) - sendMoneyEditText.addTextChangedListener(sendAmountTextWatcher); - else - sendMoneyEditText.removeTextChangedListener(sendAmountTextWatcher); - break; - case R.id.receiveAmountEdTxt: - if (action) - recieveMoneyEditText.addTextChangedListener(recepientAmountTextWatcher); - else - recieveMoneyEditText.removeTextChangedListener(recepientAmountTextWatcher); - break; - } + private void registerAvailableTextWatchersForEditText(EditText editText, boolean action) { + switch (editText.getId()) { + case R.id.sendAmountEdTxt: + if (action) + sendMoneyEditText.addTextChangedListener(sendAmountTextWatcher); + else + sendMoneyEditText.removeTextChangedListener(sendAmountTextWatcher); + break; + case R.id.receiveAmountEdTxt: + if (action) + recieveMoneyEditText.addTextChangedListener(recepientAmountTextWatcher); + else + recieveMoneyEditText.removeTextChangedListener(recepientAmountTextWatcher); + break; } + } - private class SendAmountTextWatcher implements TextWatcher { + private class SendAmountTextWatcher implements TextWatcher { - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { - } + } - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { - } + } - @Override - public void afterTextChanged(Editable s) { - shouldCaulatedByRecipient = false; - updateRecievingAmount(""); - updateButtonToCalculate(true); - showTransferfeeAndExRate(false,"",""); - } + @Override + public void afterTextChanged(Editable s) { + shouldCaulatedByRecipient = false; + updateRecievingAmount(""); + updateButtonToCalculate(true); + showTransferfeeAndExRate(false, "", ""); } + } - private class RecipientAmountTextWatcher implements TextWatcher { + private class RecipientAmountTextWatcher implements TextWatcher { - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { - } + } - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { - } + } - @Override - public void afterTextChanged(Editable s) { - shouldCaulatedByRecipient = true; - updateSendAmount(""); - updateButtonToCalculate(true); - showTransferfeeAndExRate(false,"",""); + @Override + public void afterTextChanged(Editable s) { + shouldCaulatedByRecipient = true; + updateSendAmount(""); + updateButtonToCalculate(true); + showTransferfeeAndExRate(false, "", ""); - } } - } + +} diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/utils/Utils.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/utils/Utils.java index 81a83dde..eb902550 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/utils/Utils.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/utils/Utils.java @@ -503,6 +503,6 @@ public class Utils { } else { result = sentence.toCharArray()[0] + "".toUpperCase(); } - return result; + return result.toUpperCase(); } } diff --git a/app/src/main/res/layout/acitivity_recipient_listing_v2.xml b/app/src/main/res/layout/acitivity_recipient_listing_v2.xml index f61c13a4..117d3194 100644 --- a/app/src/main/res/layout/acitivity_recipient_listing_v2.xml +++ b/app/src/main/res/layout/acitivity_recipient_listing_v2.xml @@ -3,6 +3,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto" + android:background="@color/background_gray" android:orientation="vertical"> diff --git a/app/src/main/res/layout/fragment_verification_send_money_v2.xml b/app/src/main/res/layout/fragment_verification_send_money_v2.xml index 61d1498b..c4f9b079 100644 --- a/app/src/main/res/layout/fragment_verification_send_money_v2.xml +++ b/app/src/main/res/layout/fragment_verification_send_money_v2.xml @@ -3,7 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="@color/default_bg_color" + android:background="@color/background_gray" android:clickable="true" android:scrollbars="none" android:focusable="true"> @@ -13,6 +13,7 @@ android:layout_height="wrap_content" android:orientation="vertical" android:background="@drawable/ic_rounded_white" + android:paddingEnd="20dp" android:paddingTop="20dp" android:paddingLeft="20dp" @@ -21,7 +22,6 @@