Browse Source

Exrate view and splash exrate made consistent

master
Preyea Regmi 5 years ago
parent
commit
7bd608d171
  1. BIN
      .idea/caches/build_file_checksums.ser
  2. 10
      app/src/main/AndroidManifest.xml
  3. 4
      app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/adapter/PaymentModeRvAdapter.java
  4. 135
      app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/gateway/ExchangeRateGateway.java
  5. 29
      app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/presenter/ExchangeRateInteractorInterface.java
  6. 323
      app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/presenter/ExchangeRatePresenter.java
  7. 48
      app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/presenter/ExchangeRatePresenterInterface.java
  8. 420
      app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/view/ExchangeRateActivity.java
  9. 4
      app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/view/HomeActivityV2.java
  10. 4
      app/src/main/java/com/gmeremit/online/gmeremittance_native/splash_screen/presenter/SplashScreenPresenter.java
  11. 4
      app/src/main/java/com/gmeremit/online/gmeremittance_native/splash_screen/presenter/SplashScreenPresenterInterface.java
  12. 7
      app/src/main/java/com/gmeremit/online/gmeremittance_native/splash_screen/view/SplashScreen.java

BIN
.idea/caches/build_file_checksums.ser

10
app/src/main/AndroidManifest.xml

@ -24,11 +24,17 @@
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:replace="android:allowBackup">
<activity android:name=".domesticremit.receipt.view.DomesticRemitReceiptActivity"
tools:replace="android:allowBackup"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name=".exchange_rate.view.ExchangeRateActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar"
android:windowSoftInputMode="stateAlwaysHidden"></activity>
<activity
android:name=".domesticremit.receipt.view.DomesticRemitReceiptActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar"
android:windowSoftInputMode="stateAlwaysHidden" />
<activity
android:name=".domesticremit.recenthistory.view.DomesticRemitRecipientHistoryActivity"
android:screenOrientation="portrait"

4
app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/adapter/PaymentModeRvAdapter.java

@ -38,11 +38,12 @@ public class PaymentModeRvAdapter extends RecyclerView.Adapter<PaymentModeViewHo
@Override
public void onClick(View v) {
setSelectedItem(holder.getAdapterPosition());
if(listener!=null)
listener.onPaymentModeSelected(data.get(holder.getAdapterPosition()));
}
});
holder.setImage(PaymentModeMapper.getPaymentModeImageFromId(data.get(holder.getAdapterPosition()).getId()));
holder.setTitle(data.get(holder.getAdapterPosition()).getDescription());
// holder.setDesc(data.get(holder.getAdapterPosition()).getDescription());
}
@Override
@ -58,7 +59,6 @@ public class PaymentModeRvAdapter extends RecyclerView.Adapter<PaymentModeViewHo
if(listener!=null)
{
notifyItemChanged(selectedItemPosition);
listener.onPaymentModeSelected(data.get(selectedItemPosition));
}
}
}

135
app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/gateway/ExchangeRateGateway.java

@ -0,0 +1,135 @@
package com.gmeremit.online.gmeremittance_native.exchange_rate.gateway;
import android.content.SharedPreferences;
import com.gmeremit.online.gmeremittance_native.GmeApplication;
import com.gmeremit.online.gmeremittance_native.R;
import com.gmeremit.online.gmeremittance_native.base.PrivilegedGateway;
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.CountryPaymentServiceSeedValueModel;
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.ExchangeCalculationApiResponse;
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.PaymentServiceApiResponse;
import com.gmeremit.online.gmeremittance_native.exchange_rate.presenter.ExchangeRateInteractorInterface;
import com.gmeremit.online.gmeremittance_native.splash_screen.model.LanguageModel;
import com.gmeremit.online.gmeremittance_native.utils.https.HttpClientV2;
import com.google.gson.JsonObject;
import java.util.ArrayList;
import java.util.List;
import io.reactivex.Observable;
import static com.gmeremit.online.gmeremittance_native.base.PrefKeys.USER_LOGGED_IN_STATUS;
import static com.gmeremit.online.gmeremittance_native.base.PrefKeys.USER_PREFERRED_COUNTRY_CODE;
import static com.gmeremit.online.gmeremittance_native.base.PrefKeys.USER_PREFERRED_LANGUAGE;
import static com.gmeremit.online.gmeremittance_native.base.PrefKeys.USER_PREFERRED_LOCALE;
public class ExchangeRateGateway extends PrivilegedGateway implements ExchangeRateInteractorInterface.ExchangeRateGatewayInterface {
@Override
public Observable<ExchangeCalculationApiResponse> sendDataForForexCalculation(String auth, String senderCountryId, String senderCurrency, String recieverCurrency,
String senderAmount, String recieverAmount, String paymentMethodId,
String calculationPreference, String recipientCountryName, String recieverCountryId) {
JsonObject jsonObject=new JsonObject();
jsonObject.addProperty("sCountry",senderCountryId);
jsonObject.addProperty("sCurrency",senderCurrency);
jsonObject.addProperty("pCurrency",recieverCurrency);
jsonObject.addProperty("calcBy",calculationPreference);
jsonObject.addProperty("cAmount",senderAmount);
jsonObject.addProperty("pAmount",recieverAmount);
jsonObject.addProperty("serviceType",paymentMethodId);
jsonObject.addProperty("pCountry",recieverCountryId);
jsonObject.addProperty("pCountryName",recipientCountryName);
return HttpClientV2.getInstance().calculateExchangeRateV2(auth,jsonObject);
}
@Override
public Observable<PaymentServiceApiResponse> getPaymentServiceInfoFromServer(String auth) {
return HttpClientV2.getInstance().getPaymentServiceV2(auth);
}
@Override
public Observable<List<CountryPaymentServiceSeedValueModel>> getAllSeedVAlues() {
/**
* azerbaijan 1,000 AZ USD
Bangladesh 100,000 BD USD
Belarus 1,000 BY USD
Cambodia 500 KH USD
Georgia 1,000 GE USD
India 100,000 IN INR
Indonesia 15,000,000 ID IDR
Kazakhstan 1,000 KZ USD
Kyrgyzstan 1,000 KG USD
Malaysia 10,000 MY MYR
Moldova 1,000 MD USD
Mongolia(USD) 1,000 MN USD
Mongolia(MNT) 2,000,000 MN MNT
Myanmar 1,500,000 MM MMK
Nepal 100,000 NP NPR
Pakistan 100,000 PK PKR
Philippines 500 PH PHP
Russian Federation 1,000 RU USD
Singapore 2,000 SG SGD
Sri Lanka(LKR) 100,000 LK LKR
Sri Lanka(USD) 1,000 LK USD
Tajikistan 1,000 TJ USD
Thailand(THB) 30,000 TH THB
Uzbekistan 1,000 UZ USD
Vietnam(VND) 50,000,000 VN VND
Vietnam(USD) 2,000 VN USD
*/
return Observable.just(getAllSeedVAluesV2());
}
@Override
public List<CountryPaymentServiceSeedValueModel> getAllSeedVAluesV2() {
List<CountryPaymentServiceSeedValueModel> seedData=new ArrayList<>();
seedData.add(new CountryPaymentServiceSeedValueModel("AZ","1000","USD"));
seedData.add(new CountryPaymentServiceSeedValueModel("BD","100000","BDT"));
seedData.add(new CountryPaymentServiceSeedValueModel("BY","1000","USD"));
seedData.add(new CountryPaymentServiceSeedValueModel("KH","500","USD"));
seedData.add(new CountryPaymentServiceSeedValueModel("GE","1000","USD"));
seedData.add(new CountryPaymentServiceSeedValueModel("IN","100000","INR"));
// seedData.add(new CountryPaymentServiceSeedValueModel("ID","15000000","IDR"));
seedData.add(new CountryPaymentServiceSeedValueModel("KZ","1000","USD"));
seedData.add(new CountryPaymentServiceSeedValueModel("KG","1000","USD"));
seedData.add(new CountryPaymentServiceSeedValueModel("MY","10000","MYR"));
seedData.add(new CountryPaymentServiceSeedValueModel("MD","1000","USD"));
seedData.add(new CountryPaymentServiceSeedValueModel("MN","1000","USD"));
seedData.add(new CountryPaymentServiceSeedValueModel("MN","2000000","MNT"));
seedData.add(new CountryPaymentServiceSeedValueModel("MM","1500000","MMK"));
seedData.add(new CountryPaymentServiceSeedValueModel("NP","100000","NPR"));
seedData.add(new CountryPaymentServiceSeedValueModel("PK","100000","PKR"));
seedData.add(new CountryPaymentServiceSeedValueModel("PH","500","PHP"));
seedData.add(new CountryPaymentServiceSeedValueModel("RU","1000","USD"));
seedData.add(new CountryPaymentServiceSeedValueModel("SG","2000","SGD"));
seedData.add(new CountryPaymentServiceSeedValueModel("LK","100000","LKR"));
seedData.add(new CountryPaymentServiceSeedValueModel("LK","1000","USD"));
seedData.add(new CountryPaymentServiceSeedValueModel("TJ","1000","USD"));
seedData.add(new CountryPaymentServiceSeedValueModel("TH","30000","THB"));
seedData.add(new CountryPaymentServiceSeedValueModel("UZ","1000","USD"));
seedData.add(new CountryPaymentServiceSeedValueModel("VN","50000000","VND"));
seedData.add(new CountryPaymentServiceSeedValueModel("VN","2000","USD"));
return seedData;
}
@Override
public String getPreferredCountryCode() {
return GmeApplication.getStorage().getString(USER_PREFERRED_COUNTRY_CODE,"en");
}
}

29
app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/presenter/ExchangeRateInteractorInterface.java

@ -0,0 +1,29 @@
package com.gmeremit.online.gmeremittance_native.exchange_rate.presenter;
import com.gmeremit.online.gmeremittance_native.base.BaseInteractorInterface;
import com.gmeremit.online.gmeremittance_native.base.PrivilegedGatewayInterface;
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.CountryPaymentServiceSeedValueModel;
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.ExchangeCalculationApiResponse;
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.PaymentServiceApiResponse;
import java.util.List;
import io.reactivex.Observable;
public interface ExchangeRateInteractorInterface extends BaseInteractorInterface {
interface ExchangeRateGatewayInterface extends PrivilegedGatewayInterface
{
Observable<PaymentServiceApiResponse> getPaymentServiceInfoFromServer(String auth);
Observable<List<CountryPaymentServiceSeedValueModel>> getAllSeedVAlues();
List<CountryPaymentServiceSeedValueModel> getAllSeedVAluesV2();
Observable<ExchangeCalculationApiResponse> sendDataForForexCalculation(String auth, String senderCountryId, String senderCurrency, String recieverCurrency,
String senderAmount, String recieverAmount, String paymentMethodId,
String calculationPreference, String recipientCountryName, String recieverCountryId);
String getPreferredCountryCode();
}
}

323
app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/presenter/ExchangeRatePresenter.java

@ -0,0 +1,323 @@
package com.gmeremit.online.gmeremittance_native.exchange_rate.presenter;
import android.os.Handler;
import com.gmeremit.online.gmeremittance_native.GmeApplication;
import com.gmeremit.online.gmeremittance_native.R;
import com.gmeremit.online.gmeremittance_native.base.BasePresenter;
import com.gmeremit.online.gmeremittance_native.customwidgets.CustomAlertDialog;
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.CountryPaymentService;
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.CountryPaymentServiceSeedValueModel;
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.ExchangeCalculationApiResponse;
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.ExchangeCalculationModel;
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.PaymentMode;
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.PaymentServiceApiResponse;
import com.gmeremit.online.gmeremittance_native.splash_screen.presenter.SplashScreenPresenter;
import com.gmeremit.online.gmeremittance_native.utils.Constants;
import com.gmeremit.online.gmeremittance_native.utils.Utils;
import com.gmeremit.online.gmeremittance_native.utils.https.GenericApiObserverResponse;
import java.util.List;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.schedulers.Schedulers;
public class ExchangeRatePresenter extends BasePresenter implements ExchangeRatePresenterInterface {
private final ExchangeRatePresenterInterface.ExchangeRateContractInterfacee view;
private final CompositeDisposable compositeDisposables;
private final String sendCountryDefault = "118";
private final ExchangeRateInteractorInterface.ExchangeRateGatewayInterface gateway;
private List<CountryPaymentService> countryRelatedCurrencyList;
private CountryPaymentService selectedCountryPaymentService;
private PaymentMode selectedPaymentMode;
private boolean calcByPayoutAmount;
private String cAmount;
private String pAmount;
public ExchangeRatePresenter(ExchangeRatePresenterInterface.ExchangeRateContractInterfacee view, ExchangeRateInteractorInterface.ExchangeRateGatewayInterface gateway) {
this.view=view;
this.gateway=gateway;
this.compositeDisposables = new CompositeDisposable();
cAmount = "";
pAmount = "";
}
@Override
public void getExrateRelatedData() {
compositeDisposables.add(
getPaymentServiceInfo()
.observeOn(AndroidSchedulers.mainThread())
.subscribeWith(new PaymentServiceDataObserver())
);
}
@Override
public void setPaymentMode(PaymentMode paymentMode) {
this.selectedPaymentMode = paymentMode;
calcExrate();
}
@Override
public void setPAmount(String amount) {
this.pAmount = Utils.removeCommaFromAmount(amount);
this.cAmount = "";
view.showCollectionAmount("");
}
@Override
public void setCAmount(String amount) {
this.cAmount = Utils.removeCommaFromAmount(amount);
this.pAmount = "";
view.showPayoutAmount("");
}
@Override
public void setCalcByPayoutAmount(boolean action) {
calcByPayoutAmount = action;
}
@Override
public List<CountryPaymentService> getAvailableCountryRelatedCurrency() {
return this.countryRelatedCurrencyList;
}
@Override
public void setCountryRelatedCurrencyData(CountryPaymentService countryPaymentService) {
this.selectedCountryPaymentService = countryPaymentService;
selectedPaymentMode = selectedCountryPaymentService.getServiceAvailable().get(0);
view.showSelectedPayoutMode(selectedCountryPaymentService.getServiceAvailable(), 0);
view.showSelectedPayoutCurrency(selectedCountryPaymentService);
pAmount = "";
cAmount = "";
CountryPaymentServiceSeedValueModel countryPaymentServiceSeedValueModel = getDefaultValueByCountryPaymentService(countryPaymentService);
if (countryPaymentServiceSeedValueModel.getRecipientSeedValue() != null &&
countryPaymentServiceSeedValueModel.getCountryCode().equalsIgnoreCase(countryPaymentService.getCountryCode())
&& countryPaymentServiceSeedValueModel.getCurrency().equalsIgnoreCase(countryPaymentService.getCurrency())) {
calcByPayoutAmount = true;
pAmount = countryPaymentServiceSeedValueModel.getRecipientSeedValue();
} else {
calcByPayoutAmount = false;
cAmount = Constants.DEFAULT_EXCHANGE_SEND_AMOUNT;
}
view.showCollectionAmount(Utils.formatCurrency(cAmount));
view.showPayoutAmount(Utils.formatCurrencyWithoutTruncatingDecimal(pAmount));
calcExrate();
}
@Override
public void calcExrate() {
view.hideKeyBoard();
if (selectedCountryPaymentService == null)
return;
if (!validateAmount())
return;
String calculateFlag = calcByPayoutAmount ? Constants.CALC_BY_RECIPEINT : Constants.CALC_BY_SENDER;
String auth = "Basic " + Utils.toBase64("172017F9EC11222E8107142733:QRK2UM0Q:" + GmeApplication.getAppRelatedMetaData(view.getContext()).getDeviceId());
compositeDisposables.add(
this.gateway.sendDataForForexCalculation(auth,
sendCountryDefault,
gateway.getUserPreferredCurrency(), selectedCountryPaymentService.getCurrency(),
Utils.removeCommaFromAmount(cAmount), Utils.removeCommaFromAmount(pAmount), selectedPaymentMode.getId(), calculateFlag, selectedCountryPaymentService.getCountry(),
selectedCountryPaymentService.getCountryId()
).doOnSubscribe(disposable -> {
this.view.showProgressBar(true, getStringfromStringId(R.string.processing_request_text));
})
.doOnError((err) -> this.view.showProgressBar(false, ""))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.doFinally(() -> this.view.showProgressBar(false, ""))
.subscribeWith(new ExchangeRateCalcObserver())
);
}
@Override
public void onExRateViewLoadedSuccessfully() {
updateViewWithDefaulValues();
calcExrate();
}
private boolean validateAmount() {
if (calcByPayoutAmount && pAmount.length() < 1) {
view.showToastMessage(getStringfromStringId(R.string.receiving_amount_error));
return false;
} else if (!calcByPayoutAmount && cAmount.length() < 1) {
view.showToastMessage(getStringfromStringId(R.string.sending_amount_error));
return false;
}
return true;
}
private CountryPaymentServiceSeedValueModel getDefaultValueByCountryPaymentService(CountryPaymentService countryPaymentService) {
//Default preferredLanguage = "NP"
String preferredLanguage = "NP";
String preferredCurrency;
if (countryPaymentService != null) {
preferredLanguage = countryPaymentService.getCountryCode();
preferredCurrency = countryPaymentService.getCurrency();
List<CountryPaymentServiceSeedValueModel> seedValueList = this.gateway.getAllSeedVAluesV2();
for (CountryPaymentServiceSeedValueModel seedValueModel : seedValueList) {
if (seedValueModel.getCountryCode().equalsIgnoreCase(preferredLanguage) && seedValueModel.getCurrency().equalsIgnoreCase(preferredCurrency))
return seedValueModel;
}
}
return new CountryPaymentServiceSeedValueModel(preferredLanguage, null, null);
}
/**
* Delay is added intentionally to work in conjunction with {@link android.support.transition.TransitionManager} API.
* ChangeBound Transition is used for switch between different UI State. This transition works by calculating bound difference between two frames.
* So if network is extremely responsive TransitionManager.beginDelayedTransition sees no difference in change bounds and as a result no corresponding callbacks are invoked.
*/
private Observable<PaymentServiceApiResponse> getPaymentServiceInfo() {
String auth = "Basic " + Utils.toBase64("172017F9EC11222E8107142733:QRK2UM0Q:" + GmeApplication.getAppRelatedMetaData(view.getContext()).getDeviceId());
return this.gateway.getPaymentServiceInfoFromServer(auth).subscribeOn(Schedulers.io()).delay(500, TimeUnit.MILLISECONDS);
}
public class PaymentServiceDataObserver extends GenericApiObserverResponse<PaymentServiceApiResponse> {
@Override
protected void onSuccess(PaymentServiceApiResponse paymentServiceApiResponse) {
view.showProgressBar(false,"");
if (paymentServiceApiResponse.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2) && paymentServiceApiResponse.getCountryPaymentServices().size() > 0) {
selectedCountryPaymentService = paymentServiceApiResponse.getCountryPaymentServicesByCountryCode(gateway.getPreferredCountryCode());
CountryPaymentServiceSeedValueModel seedValueModel = getDefaultValueByCountryPaymentService(selectedCountryPaymentService);
countryRelatedCurrencyList = paymentServiceApiResponse.getCountryPaymentServices();
try {
selectedCountryPaymentService = paymentServiceApiResponse.getCountryPaymentServiceFromCountryCodeAndCurrency(seedValueModel.getCountryCode(), seedValueModel.getCurrency());
} catch (Exception e) {
selectedCountryPaymentService = null;
}
if (selectedCountryPaymentService == null || selectedCountryPaymentService.getCountryCode() == null || selectedCountryPaymentService.getCountry() == null || selectedCountryPaymentService.getCurrency() == null) {
//No Default PAmount available for the selected country
//Update UI with PAmount,CAmount,SelectedPayoutMode,SelectedCurrency
//TODO Select a default payoutModeData for this case
selectedCountryPaymentService = paymentServiceApiResponse.getDefaultPayoutMode(seedValueModel.getCountryCode());
selectedPaymentMode = selectedCountryPaymentService.getServiceAvailable().get(0);
calcByPayoutAmount = false;
cAmount = Constants.DEFAULT_EXCHANGE_SEND_AMOUNT;
view.showExrateView(null);
} else {
//No Default PAmount available for the selected country
//Update UI with PAmount,CAmount,SelectedPayoutMode,SelectedCurrency
selectedPaymentMode = selectedCountryPaymentService.getServiceAvailable().get(0);
calcByPayoutAmount = true;
pAmount = seedValueModel.getRecipientSeedValue();
view.showExrateView(null);
}
} else {
view.showPopUpMessage(paymentServiceApiResponse.getMessage(), CustomAlertDialog.AlertType.ALERT_RETRY, alertType -> {
new Handler().postDelayed(ExchangeRatePresenter.this::getExrateRelatedData, 200);
});
}
}
@Override
public void onFailed(String message) {
view.showPopUpMessage(message, CustomAlertDialog.AlertType.ALERT_RETRY, alertType -> {
new Handler().postDelayed(ExchangeRatePresenter.this::getExrateRelatedData, 200);
});
}
@Override
protected void onConnectionNotEstablished(String message) {
view.showPopUpMessage(message, CustomAlertDialog.AlertType.ALERT_RETRY, alertType -> {
new Handler().postDelayed(ExchangeRatePresenter.this::getExrateRelatedData, 200);
});
}
@Override
protected void unauthorizedAccess(String message) {
view.showProgressBar(false,"");
gateway.clearAllUserData();
view.showPopUpMessage(message, CustomAlertDialog.AlertType.ALERT, alertType -> view.exitView());
}
}
private void updateViewWithDefaulValues() {
if (calcByPayoutAmount)
view.showPayoutAmount(Utils.formatCurrencyWithoutTruncatingDecimal(pAmount));
else
view.showCollectionAmount(Utils.formatCurrency(cAmount));
view.showSelectedPayoutMode(selectedCountryPaymentService.getServiceAvailable(), 0);
view.showSelectedPayoutCurrency(selectedCountryPaymentService);
}
private void clearExistingRateOnFailure() {
if (calcByPayoutAmount)
view.showCollectionAmount("");
else
view.showPayoutAmount("");
view.showTransferChargeAndExrate("", "", false);
}
public class ExchangeRateCalcObserver extends GenericApiObserverResponse<ExchangeCalculationApiResponse> {
@Override
protected void onSuccess(ExchangeCalculationApiResponse exchangeCalculationApiResponse) {
if (exchangeCalculationApiResponse.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2)) {
ExchangeCalculationModel data = exchangeCalculationApiResponse.getData();
String transferAmount = Utils.formatCurrency(data.getScCharge());
String exRate = data.getExRateDisplay();
pAmount = data.getpAmt();
cAmount = data.getCollAmt();
String sendingCurrency = data.getCollCurr();
String transferDisplay = " - " + transferAmount + " " + sendingCurrency + " (" + getStringfromStringId(R.string.transfer_fee_included_text) + ")";
String exRateDisplay = " " + exRate + " (" + getStringfromStringId(R.string.current_exchange_rate_text) + ")";
view.showTransferChargeAndExrate(transferDisplay, exRateDisplay, true);
view.showPayoutAmount(Utils.formatCurrencyWithoutTruncatingDecimal(pAmount));
view.showCollectionAmount(Utils.formatCurrency(cAmount));
} else {
clearExistingRateOnFailure();
view.showPopUpMessage(exchangeCalculationApiResponse.getMsg(), CustomAlertDialog.AlertType.FAILED, null);
}
}
@Override
public void onFailed(String message) {
clearExistingRateOnFailure();
view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, null);
}
@Override
protected void onConnectionNotEstablished(String message) {
clearExistingRateOnFailure();
view.showPopUpMessage(message, CustomAlertDialog.AlertType.NO_INTERNET, null);
}
@Override
protected void unauthorizedAccess(String message) {
clearExistingRateOnFailure();
gateway.clearAllUserData();
view.showPopUpMessage(message, CustomAlertDialog.AlertType.ALERT, alertType -> view.logout());
}
}
}

48
app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/presenter/ExchangeRatePresenterInterface.java

@ -0,0 +1,48 @@
package com.gmeremit.online.gmeremittance_native.exchange_rate.presenter;
import com.gmeremit.online.gmeremittance_native.base.BaseContractInterface;
import com.gmeremit.online.gmeremittance_native.base.BasePresenterInterface;
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.CountryPaymentService;
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.PaymentMode;
import com.zoyi.channel.plugin.android.contract.BasePresenter;
import java.util.List;
public interface ExchangeRatePresenterInterface extends BasePresenterInterface {
void getExrateRelatedData();
void setPaymentMode(PaymentMode paymentMode);
void setPAmount(String amount);
void setCAmount(String amount);
void setCalcByPayoutAmount(boolean action);
List<CountryPaymentService> getAvailableCountryRelatedCurrency();
void setCountryRelatedCurrencyData(CountryPaymentService countryPaymentService);
void calcExrate();
void onExRateViewLoadedSuccessfully();
interface ExchangeRateContractInterfacee extends BaseContractInterface{
void showPayoutAmount(String pAmount);
void showCollectionAmount(String pAmount);
void showSelectedPayoutMode(List<PaymentMode> serviceAvailable, int selectedIndex);
void showSelectedPayoutCurrency(CountryPaymentService selectedPayoutCountryCurrency);
void showTransferChargeAndExrate(String chargeAmount,String exRate,boolean playAnimation);
void showExrateView(Runnable task);
}
}

420
app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/view/ExchangeRateActivity.java

@ -0,0 +1,420 @@
package com.gmeremit.online.gmeremittance_native.exchange_rate.view;
import android.graphics.Rect;
import android.support.v4.view.GestureDetectorCompat;
import android.os.Bundle;
import android.support.v4.view.ViewCompat;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.RecyclerView;
import android.text.Editable;
import android.view.GestureDetector;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.Interpolator;
import android.view.inputmethod.EditorInfo;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ScrollView;
import android.widget.TextView;
import com.gmeremit.online.gmeremittance_native.R;
import com.gmeremit.online.gmeremittance_native.base.BaseActivity;
import com.gmeremit.online.gmeremittance_native.customwidgets.CurrencyFormatterTextWatcher;
import com.gmeremit.online.gmeremittance_native.customwidgets.GmeTextView;
import com.gmeremit.online.gmeremittance_native.customwidgets.exchangecountrylistingdialog.CountryFlagMapper;
import com.gmeremit.online.gmeremittance_native.customwidgets.exchangecountrylistingdialog.ExchangeRateCurrencyListingDialog;
import com.gmeremit.online.gmeremittance_native.exchange_rate.adapter.PaymentModeRvAdapter;
import com.gmeremit.online.gmeremittance_native.exchange_rate.gateway.ExchangeRateGateway;
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.CountryPaymentService;
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.PaymentMode;
import com.gmeremit.online.gmeremittance_native.exchange_rate.presenter.ExchangeRatePresenter;
import com.gmeremit.online.gmeremittance_native.exchange_rate.presenter.ExchangeRatePresenterInterface;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
public class ExchangeRateActivity extends BaseActivity implements ExchangeRatePresenterInterface.ExchangeRateContractInterfacee, PaymentModeRvAdapter.OnPaymentModeSelectionListener, TextView.OnEditorActionListener, View.OnClickListener {
@BindView(R.id.sendAmountEdTxt)
EditText sendAmountEdTxt;
@BindView(R.id.receiveAmountEdTxt)
EditText receiveAmountEdTxt;
@BindView(R.id.paymentModeRV)
RecyclerView paymentModeRv;
@BindView(R.id.toolbar_title)
GmeTextView toolbarTitle;
@BindView(R.id.countrySelectionSpinner)
View countrySelectionSpinner;
@BindView(R.id.recepientFlagImageView)
ImageView recepientFlagImageView;
@BindView(R.id.recepientCurrencyTextView)
TextView recepientCurrencyTextView;
@BindView(R.id.transferFeeTxtView)
TextView transferFeeTxtView;
@BindView(R.id.exchangeRateTxtView)
TextView exchangeRateTxtView;
@BindView(R.id.paymentModeViewContainer)
ViewGroup paymentModeViewContainer;
@BindView(R.id.iv_back)
View iv_back;
@BindView(R.id.iv_cancel)
View iv_cancel;
@BindView(R.id.rootView)
ScrollView rootView;
@BindView(R.id.receiveMoneyViewContainer)
View receiveMoneyViewContainer;
@BindView(R.id.sendMoneyViewContainer)
View sendMoneyViewContainer;
@BindView(R.id.generic_toolbar)
View toolbar;
@BindView(R.id.exRateCalculateButton)
Button exRateCalculateButton;
private ExchangeRateCurrencyListingDialog countryListingDialog;
private SendAmountTextWatcher sendMoneyTextWatcher;
private ReceiveAmountTextWatcher receiveMoneyTextWatcher;
private GestureDetectorCompat gestureDetector;
private AmountChangeAndFocusOutDetector myViewGestureDetector;
private PaymentModeRvAdapter paymentModeRvAdapter;
private ExchangeRatePresenterInterface presenter;
private Interpolator interpolator=new AccelerateDecelerateInterpolator();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_exchange_method_v2);
ButterKnife.bind(this);
init();
performDefaultAction(savedInstanceState);
}
private void performDefaultAction(Bundle savedInstanceState) {
showProgressBar(true,getString(R.string.processing_request_text));
presenter.getExrateRelatedData();
}
private void init()
{
presenter=new ExchangeRatePresenter(this,new ExchangeRateGateway());
initPayoutModeRV();
sendMoneyTextWatcher = new SendAmountTextWatcher(sendAmountEdTxt);
receiveMoneyTextWatcher = new ReceiveAmountTextWatcher(receiveAmountEdTxt);
myViewGestureDetector = new AmountChangeAndFocusOutDetector();
gestureDetector = new GestureDetectorCompat(this, myViewGestureDetector);
iv_cancel.setVisibility(View.GONE);
toolbarTitle.setText(getString(R.string.todays_rate_title_text));
}
private void initPayoutModeRV() {
paymentModeRvAdapter = new PaymentModeRvAdapter(this);
paymentModeRv.setAdapter(paymentModeRvAdapter);
paymentModeRv.addItemDecoration(new SelectedRedBorderDecoration(this));
paymentModeRv.setItemAnimator(new DefaultItemAnimator());
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
gestureDetector.onTouchEvent(ev);
return super.dispatchTouchEvent(ev);
}
private void showCountryListinDialog() {
if (countryListingDialog == null)
countryListingDialog = new ExchangeRateCurrencyListingDialog();
countryListingDialog.setCountryPaymentData(presenter.getAvailableCountryRelatedCurrency());
countryListingDialog.setListener(new ExchangeRateCurrencyListingDialog.CountrySelectionListener() {
@Override
public void onCountrySelected(CountryPaymentService countryPaymentService) {
presenter.setCountryRelatedCurrencyData(countryPaymentService);
countryListingDialog.dismiss();
}
});
if (!countryListingDialog.isAdded())
countryListingDialog.show(getSupportFragmentManager(), "GenericTextListingDialog");
}
private void startSendAmountListener(boolean action) {
if (action) {
sendAmountEdTxt.addTextChangedListener(sendMoneyTextWatcher);
} else {
sendAmountEdTxt.removeTextChangedListener(sendMoneyTextWatcher);
}
}
private void startReceiveAmountListener(boolean action) {
if (action) {
receiveAmountEdTxt.addTextChangedListener(receiveMoneyTextWatcher);
} else {
receiveAmountEdTxt.removeTextChangedListener(receiveMoneyTextWatcher);
}
}
@Override
public void showPayoutAmount(String pAmount) {
startReceiveAmountListener(false);
receiveAmountEdTxt.setText(pAmount);
startReceiveAmountListener(true);
}
@Override
public void showCollectionAmount(String pAmount) {
startSendAmountListener(false);
sendAmountEdTxt.setText(pAmount);
startSendAmountListener(true);
}
@Override
public void showSelectedPayoutMode(List<PaymentMode> serviceAvailable, int selectedIndex) {
paymentModeRvAdapter.setData(serviceAvailable);
paymentModeRvAdapter.setSelectedItem(selectedIndex);
}
@Override
public void showSelectedPayoutCurrency(CountryPaymentService selectedPayoutCountryCurrency) {
recepientCurrencyTextView.setText(selectedPayoutCountryCurrency.getCurrency());
recepientFlagImageView.setBackgroundResource(CountryFlagMapper.getFlagFromCountryCode(selectedPayoutCountryCurrency.getCountryCode()));
// Glide.with(receivingCountryFlagImageView.getContext())
// .load(CountryFlagMapper.getFlagFromCountryCode(selectedPayoutCountryCurrency.getCountryCode()))
// .into(receivingCountryFlagImageView);
}
@Override
public void showTransferChargeAndExrate(String chargeAmount, String exRate, boolean playAnimation) {
if (playAnimation) {
this.exchangeRateTxtView.setVisibility(View.INVISIBLE);
this.exchangeRateTxtView.setText(exRate);
this.exchangeRateTxtView.setTranslationY(this.exchangeRateTxtView.getHeight());
this.exchangeRateTxtView.setVisibility(View.VISIBLE);
ViewCompat.animate(this.exchangeRateTxtView).translationY(0).setDuration(550).setInterpolator(this.interpolator).start();
this.transferFeeTxtView.setVisibility(View.INVISIBLE);
this.transferFeeTxtView.setText(chargeAmount);
this.transferFeeTxtView.setTranslationY(this.transferFeeTxtView.getHeight());
this.transferFeeTxtView.setVisibility(View.VISIBLE);
ViewCompat.animate(this.transferFeeTxtView).translationY(0).setDuration(550).setInterpolator(this.interpolator).start();
} else {
transferFeeTxtView.setText(chargeAmount);
exchangeRateTxtView.setText(exRate);
}
}
@Override
public void showExrateView(Runnable task) {
showProgressBar(false,getString(R.string.processing_request_text));
presenter.onExRateViewLoadedSuccessfully();
}
@Override
public void onPaymentModeSelected(PaymentMode selectedData) {
presenter.setPaymentMode(selectedData);
}
@Override
protected void onStart() {
super.onStart();
exRateCalculateButton.setOnClickListener(this);
iv_back.setOnClickListener(this);
receiveAmountEdTxt.setOnEditorActionListener(this);
sendAmountEdTxt.setOnEditorActionListener(this);
countrySelectionSpinner.setOnClickListener(this);
iv_back.setOnClickListener(this);
}
@Override
protected void onStop() {
super.onStop();
exRateCalculateButton.setOnClickListener(null);
iv_back.setOnClickListener(null);
receiveAmountEdTxt.setOnEditorActionListener(null);
sendAmountEdTxt.setOnEditorActionListener(null);
countrySelectionSpinner.setOnClickListener(null);
iv_back.setOnClickListener(null);
}
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
switch (v.getId()) {
case R.id.sendAmountEdTxt:
if (actionId == EditorInfo.IME_ACTION_DONE) {
presenter.setCalcByPayoutAmount(false);
presenter.calcExrate();
return true;
}
case R.id.receiveAmountEdTxt:
if (actionId == EditorInfo.IME_ACTION_DONE) {
presenter.setCalcByPayoutAmount(true);
presenter.calcExrate();
return true;
}
}
return false;
}
@Override
public void onClick(View v) {
switch (v.getId())
{
case R.id.countrySelectionSpinner:
showCountryListinDialog();
break;
case R.id.exRateCalculateButton:
presenter.calcExrate();
break;
case R.id.iv_back:
onBackPressed();
break;
}
}
private class AmountChangeAndFocusOutDetector extends GestureDetector.SimpleOnGestureListener {
@Override
public boolean onSingleTapUp(MotionEvent e) {
if (e.getAction() == MotionEvent.ACTION_UP) {
if (hasValidOutsideAmountWidgetTouch(e.getX(), e.getY())) {
presenter.calcExrate();
return true;
}
}
return super.onSingleTapUp(e);
}
private boolean hasValidOutsideAmountWidgetTouch(float x, float y) {
int posX=(int)x;
int posY=(int)y;
int[] sendMoneyLeftAndTopCoordinates = new int[2];
int[] receiveMoneyLeftAndTopCoordinates = new int[2];
int[] backButtonLeftAndTopCoordinates = new int[2];
int[] calculateButtonLeftAndTopCoordinates = new int[2];
sendMoneyViewContainer.getLocationOnScreen(sendMoneyLeftAndTopCoordinates);
receiveMoneyViewContainer.getLocationOnScreen(receiveMoneyLeftAndTopCoordinates);
iv_back.getLocationOnScreen(backButtonLeftAndTopCoordinates);
exRateCalculateButton.getLocationOnScreen(calculateButtonLeftAndTopCoordinates);
Rect sendMoneyBoundRect = new Rect(sendMoneyLeftAndTopCoordinates[0], sendMoneyLeftAndTopCoordinates[1],
sendMoneyLeftAndTopCoordinates[0] + sendMoneyViewContainer.getMeasuredWidth(),
sendMoneyLeftAndTopCoordinates[1] + sendMoneyViewContainer.getMeasuredHeight());
Rect receiveMoneyBoundRect = new Rect(receiveMoneyLeftAndTopCoordinates[0], receiveMoneyLeftAndTopCoordinates[1],
receiveMoneyLeftAndTopCoordinates[0] + receiveMoneyViewContainer.getMeasuredWidth(),
receiveMoneyLeftAndTopCoordinates[1] + receiveMoneyViewContainer.getMeasuredHeight());
Rect backButtonBoundRect = new Rect(backButtonLeftAndTopCoordinates[0], backButtonLeftAndTopCoordinates[1],
backButtonLeftAndTopCoordinates[0] + iv_back.getMeasuredWidth(),
backButtonLeftAndTopCoordinates[1] + iv_back.getMeasuredHeight());
Rect calcButtonBoundRect = new Rect(calculateButtonLeftAndTopCoordinates[0], calculateButtonLeftAndTopCoordinates[1],
calculateButtonLeftAndTopCoordinates[0] + exRateCalculateButton.getMeasuredWidth(),
calculateButtonLeftAndTopCoordinates[1] + exRateCalculateButton.getMeasuredHeight());
return (receiveAmountEdTxt.hasFocus()|| sendAmountEdTxt.hasFocus())
&&!sendMoneyBoundRect.contains(posX, posY)
&& !receiveMoneyBoundRect.contains(posX, posY)
&&!backButtonBoundRect.contains(posX, posY)
&&!calcButtonBoundRect.contains(posX,posY);
}
}
class SendAmountTextWatcher extends CurrencyFormatterTextWatcher {
public SendAmountTextWatcher(EditText editText) {
super(editText);
}
@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 afterTextChanged(Editable s) {
super.afterTextChanged(s);
presenter.setCalcByPayoutAmount(false);
presenter.setCAmount(s.toString());
}
}
class ReceiveAmountTextWatcher extends CurrencyFormatterTextWatcher {
public ReceiveAmountTextWatcher(EditText editText) {
super(editText);
}
@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 afterTextChanged(Editable s) {
super.afterTextChanged(s);
presenter.setCalcByPayoutAmount(true);
presenter.setPAmount(s.toString());
}
}
}

4
app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/view/HomeActivityV2.java

@ -34,6 +34,7 @@ import com.gmeremit.online.gmeremittance_native.customer_support.view.CustomerSu
import com.gmeremit.online.gmeremittance_native.customwidgets.CustomAlertDialog;
import com.gmeremit.online.gmeremittance_native.domesticremit.send.view.DomesticRemitActivity;
import com.gmeremit.online.gmeremittance_native.exchange_rate.view.ExchangeMethodV2Activity;
import com.gmeremit.online.gmeremittance_native.exchange_rate.view.ExchangeRateActivity;
import com.gmeremit.online.gmeremittance_native.homeV2.HomeParentViewContractV2;
import com.gmeremit.online.gmeremittance_native.homeV2.gateway.HomeV2Gateway;
import com.gmeremit.online.gmeremittance_native.homeV2.presenter.HomeV2Presenter;
@ -327,7 +328,8 @@ public class HomeActivityV2 extends BaseActivity implements HomeParentViewContra
public void showTodaysRateView() {
if (isNotificaitonViewActive())
return;
startActivity(new Intent(this, ExchangeMethodV2Activity.class));
// startActivity(new Intent(this, ExchangeMethodV2Activity.class));
startActivity(new Intent(this, ExchangeRateActivity.class));
}

4
app/src/main/java/com/gmeremit/online/gmeremittance_native/splash_screen/presenter/SplashScreenPresenter.java

@ -280,7 +280,7 @@ public class SplashScreenPresenter extends BasePresenter implements SplashScreen
selectedPaymentMode = selectedCountryPaymentService.getServiceAvailable().get(0);
calcByPayoutAmount = false;
cAmount = Constants.DEFAULT_EXCHANGE_SEND_AMOUNT;
view.animateToExrateView(null);
view.showExrateView(null);
} else {
//No Default PAmount available for the selected country
@ -288,7 +288,7 @@ public class SplashScreenPresenter extends BasePresenter implements SplashScreen
selectedPaymentMode = selectedCountryPaymentService.getServiceAvailable().get(0);
calcByPayoutAmount = true;
pAmount = seedValueModel.getRecipientSeedValue();
view.animateToExrateView(null);
view.showExrateView(null);
}
} else {

4
app/src/main/java/com/gmeremit/online/gmeremittance_native/splash_screen/presenter/SplashScreenPresenterInterface.java

@ -63,6 +63,8 @@ public interface SplashScreenPresenterInterface extends BasePresenterInterface {
void showTransferChargeAndExrate(String chargeAmount,String exRate,boolean playAnimation);
void animateToExrateView(Runnable task);
void showExrateView(Runnable task);
}
}

7
app/src/main/java/com/gmeremit/online/gmeremittance_native/splash_screen/view/SplashScreen.java

@ -178,8 +178,6 @@ public class SplashScreen extends BaseActivity implements View.OnClickListener,
}
private void performDefaultAction(Bundle savedInstanceState) {
languageViewTransitionManager.underlineTitleText(true);
@ -486,7 +484,7 @@ public class SplashScreen extends BaseActivity implements View.OnClickListener,
@Override
public void animateToExrateView(Runnable task) {
public void showExrateView(Runnable task) {
languageViewTransitionManager.showMainViewLanguageFromPreLoadingScreen(400, task);
}
@ -495,7 +493,6 @@ public class SplashScreen extends BaseActivity implements View.OnClickListener,
presenter.setPaymentMode(selectedData);
}
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
switch (v.getId()) {
@ -512,7 +509,6 @@ public class SplashScreen extends BaseActivity implements View.OnClickListener,
presenter.calcExrate();
return true;
}
}
return false;
}
@ -836,7 +832,6 @@ public class SplashScreen extends BaseActivity implements View.OnClickListener,
}
public native void startAntiDebugger();
private void initAntiDebugger() {

Loading…
Cancel
Save