diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index ce82d8ce..dcc268be 100644 Binary files a/.idea/caches/build_file_checksums.ser and b/.idea/caches/build_file_checksums.ser differ diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/model/datav2/PaymentServiceApiResponse.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/model/datav2/PaymentServiceApiResponse.java index 024a2707..9ca7a678 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/model/datav2/PaymentServiceApiResponse.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/model/datav2/PaymentServiceApiResponse.java @@ -1,7 +1,5 @@ package com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2; -import android.util.Log; - import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; @@ -27,7 +25,7 @@ public class PaymentServiceApiResponse { List countryPaymentServices; public PaymentServiceApiResponse() { - countryPaymentServices=new ArrayList<>(); + countryPaymentServices = new ArrayList<>(); } public List getCountryPaymentServices() { @@ -38,14 +36,14 @@ public class PaymentServiceApiResponse { this.countryPaymentServices = countryPaymentServices; } - public CountryPaymentService getCountryPaymentServiceFromCountryCodeAndCurrency(String countryCode,String currency){ - for(CountryPaymentService countryPaymentService:countryPaymentServices) - { + public CountryPaymentService getCountryPaymentServiceFromCountryCodeAndCurrency(String countryCode, String currency) { + for(CountryPaymentService countryPaymentService:countryPaymentServices) + { - if(countryPaymentService.getCountryCode().equalsIgnoreCase(countryCode)&&countryPaymentService.getCurrency().equalsIgnoreCase(currency)) - return countryPaymentService; - } - return null; + if(countryPaymentService.getCountryCode().equalsIgnoreCase(countryCode)&&countryPaymentService.getCurrency().equalsIgnoreCase(currency)) + return countryPaymentService; + } + return null; } public String getErrorCode() { @@ -71,4 +69,20 @@ public class PaymentServiceApiResponse { public void setId(String id) { Id = id; } + + /** + * Return default payoutMode for not listed Seed PAmount VAlues + * + * @param countrycode + * @return + */ + public CountryPaymentService getDefaultPayoutMode(String countrycode) { + if (countrycode != null && countrycode.length() > 1) + for (CountryPaymentService countryPaymentService : countryPaymentServices) { + + if (countryPaymentService.getCountryCode().equalsIgnoreCase(countrycode)) + return countryPaymentService; + } + return countryPaymentServices.get(0); + } } diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/splash_screen/adapter/PayoutModeSelectionRVAdapter.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/splash_screen/adapter/PayoutModeSelectionRVAdapter.java index 8b46fa7f..72add440 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/splash_screen/adapter/PayoutModeSelectionRVAdapter.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/splash_screen/adapter/PayoutModeSelectionRVAdapter.java @@ -54,7 +54,6 @@ public class PayoutModeSelectionRVAdapter extends RecyclerView.Adapter 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 getPaymentServiceInfoFromServer(String auth) { + return HttpClientV2.getInstance().getPaymentServiceV2(auth); + + } + + + @Override + public Observable> 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 + */ + List 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 Observable.just(seedData); + } + + @Override public void updatePreferredLocaleToStorage(String localeCode) { SharedPreferences myPreferences= GmeApplication.getStorage(); diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/splash_screen/presenter/SplashScreenPresenter.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/splash_screen/presenter/SplashScreenPresenter.java index 2f7ce361..aa7a7020 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/splash_screen/presenter/SplashScreenPresenter.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/splash_screen/presenter/SplashScreenPresenter.java @@ -23,6 +23,7 @@ import com.scottyab.rootbeer.RootBeer; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.TimeUnit; import io.reactivex.Observable; import io.reactivex.android.schedulers.AndroidSchedulers; @@ -43,6 +44,9 @@ public class SplashScreenPresenter extends BasePresenter implements SplashScreen */ private List payoutModeRelatedDataList; private CountryPaymentService selectedPayoutModeData; + private boolean calcByPayoutAmount; + private String cAmount; + private String pAmount; public SplashScreenPresenter(SplashScreenContractInterfacee view) { @@ -71,7 +75,6 @@ public class SplashScreenPresenter extends BasePresenter implements SplashScreen if (this.languageModels == null || this.languageModels.size() < 1) { this.languageModels = this.gateway.getRelatedLanguageData(); this.view.updateLanguageData(languageModels); - mockPayoutMode(); String appVersion = getStringfromStringId(R.string.app_version_text) + " " + BuildConfig.VERSION_NAME; if (!BuildConfig.BUILD_TYPE.equalsIgnoreCase("release")) appVersion = appVersion + " (" + BuildConfig.BUILD_TYPE + ")"; @@ -81,18 +84,8 @@ public class SplashScreenPresenter extends BasePresenter implements SplashScreen } } - private void mockPayoutMode() { - List data = new ArrayList<>(); - data.add(new PaymentMode("1", "Cash Pickup", "")); - data.add(new PaymentMode("14", "Card Payment", "")); - data.add(new PaymentMode("2", "Bank Deposit", "")); - data.add(new PaymentMode("12", "Home Delivery", "")); - data.add(new PaymentMode("13", "Wallet Deposit", "")); - view.updatePayoutModeData(data); - } - private boolean checkIfAppSafe() { boolean isSafe = false; try { @@ -134,8 +127,9 @@ public class SplashScreenPresenter extends BasePresenter implements SplashScreen public void getExrateRelatedData() { compositeDisposables.add( Observable.zip(getPaymentServiceInfo(), getDefaultValue(), PaymentServiceData::new) - .doOnSubscribe(disposable -> this.view.showProgressBar(true, getStringfromStringId(R.string.processing_request_text))) - .doFinally(() -> this.view.showProgressBar(false, "")) + .delay(300, TimeUnit.MILLISECONDS) +// .doOnSubscribe(disposable -> this.view.showProgressBar(true, getStringfromStringId(R.string.processing_request_text))) +// .doFinally(() -> this.view.showProgressBar(false, "")) .observeOn(AndroidSchedulers.mainThread()) .subscribeWith(new PaymentServiceDataObserver()) ); @@ -144,7 +138,7 @@ public class SplashScreenPresenter extends BasePresenter implements SplashScreen private Observable getDefaultValue() { return this.gateway.getAllSeedVAlues().flatMap(seedValueList -> { - String nativeCountryCode = this.gateway.getUserNativeCountryCode(); + String nativeCountryCode = this.gateway.getPreferredCountryCode(); if (nativeCountryCode == null || nativeCountryCode.length() < 1) return Observable.just(new CountryPaymentServiceSeedValueModel(null, null, null)); for (CountryPaymentServiceSeedValueModel seedValueModel : seedValueList) { @@ -168,7 +162,6 @@ public class SplashScreenPresenter extends BasePresenter implements SplashScreen if (paymentServiceApiResponse.getPaymentServiceApiResponse().getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2)&&paymentServiceApiResponse.getPaymentServiceApiResponse().getCountryPaymentServices().size()>0) { CountryPaymentServiceSeedValueModel seedValueModel = paymentServiceApiResponse.getCountryPaymentServiceSeedValueModel(); payoutModeRelatedDataList=paymentServiceApiResponse.getPaymentServiceApiResponse().getCountryPaymentServices(); - selectedPayoutModeData=paymentServiceApiResponse.getPaymentServiceApiResponse().getCountryPaymentServiceFromCountryCodeAndCurrency(seedValueModel.getCountryCode(), seedValueModel.getCurrency()); try { selectedPayoutModeData = paymentServiceApiResponse.getPaymentServiceApiResponse().getCountryPaymentServiceFromCountryCodeAndCurrency(seedValueModel.getCountryCode(), seedValueModel.getCurrency()); } @@ -180,9 +173,17 @@ public class SplashScreenPresenter extends BasePresenter implements SplashScreen if (selectedPayoutModeData == null || selectedPayoutModeData.getCountryCode() == null || selectedPayoutModeData.getCountry() == null || selectedPayoutModeData.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 + selectedPayoutModeData=paymentServiceApiResponse.getPaymentServiceApiResponse().getDefaultPayoutMode("NP"); + calcByPayoutAmount=false; + cAmount=Constants.DEFAULT_EXCHANGE_SEND_AMOUNT; + view.animateToExrateView(SplashScreenPresenter.this::updateViewWithSelectedValues); } else { //No Default PAmount available for the selected country //Update UI with PAmount,CAmount,SelectedPayoutMode,SelectedCurrency + calcByPayoutAmount=true; + pAmount=seedValueModel.getRecipientSeedValue(); + view.animateToExrateView(SplashScreenPresenter.this::updateViewWithSelectedValues); } } else { @@ -210,6 +211,15 @@ public class SplashScreenPresenter extends BasePresenter implements SplashScreen } } + private void updateViewWithSelectedValues() { + if(calcByPayoutAmount) + view.updatePayoutAmount(Utils.formatCurrencyWithoutTruncatingDecimal(pAmount)); + else + view.updateCollectionAmount(Utils.formatCurrency(cAmount)); + view.showSelectedPayoutMode(selectedPayoutModeData.getServiceAvailable(),0); + view.showSelectedPayoutCurrency(selectedPayoutModeData); + } + public class ExchangeRateCalcObserver extends GenericApiObserverResponse { @Override @@ -225,22 +235,22 @@ public class SplashScreenPresenter extends BasePresenter implements SplashScreen String transferDisplay = " - " + transferAmount + " " + sendingCurrency + " (" + getStringfromStringId(R.string.transfer_fee_included_text) + ")"; String exRateDisplay = " " + exRate + " (" + getStringfromStringId(R.string.current_exchange_rate_text) + ")"; - view.updateExchangeRates(recipientAmount, sendAmount, transferDisplay, exRateDisplay); +// view.updateExchangeRates(recipientAmount, sendAmount, transferDisplay, exRateDisplay); } else { - view.clearExrateAndServiceCharge(); +// view.clearExrateAndServiceCharge(); view.showPopUpMessage(exchangeCalculationApiResponse.getMsg(), CustomAlertDialog.AlertType.FAILED, null); } } @Override public void onFailed(String message) { - view.clearExrateAndServiceCharge(); +// view.clearExrateAndServiceCharge(); view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, alertType -> view.exitView()); } @Override protected void onConnectionNotEstablished(String message) { - view.clearExrateAndServiceCharge(); +// view.clearExrateAndServiceCharge(); view.showPopUpMessage(message, CustomAlertDialog.AlertType.NO_INTERNET, alertType -> view.exitView()); } @@ -258,10 +268,10 @@ public class SplashScreenPresenter extends BasePresenter implements SplashScreen @Override public void onNext(CountryPaymentServiceSeedValueModel countryPaymentServiceSeedValueModel) { String receivingAmount = countryPaymentServiceSeedValueModel.getRecipientSeedValue(); - if (receivingAmount != null) - view.updateReceivingAmountAndFetchExchangeRate(Utils.formatCurrency(receivingAmount)); - else - view.fallbackToSendingAmountAndFetchExchangeRate(Utils.formatCurrency(Constants.DEFAULT_EXCHANGE_SEND_AMOUNT)); +// if (receivingAmount != null) +// view.updateReceivingAmountAndFetchExchangeRate(Utils.formatCurrency(receivingAmount)); +// else +// view.fallbackToSendingAmountAndFetchExchangeRate(Utils.formatCurrency(Constants.DEFAULT_EXCHANGE_SEND_AMOUNT)); } diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/splash_screen/presenter/SplashScreenPresenterInterface.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/splash_screen/presenter/SplashScreenPresenterInterface.java index a578fdec..89f0e9ab 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/splash_screen/presenter/SplashScreenPresenterInterface.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/splash_screen/presenter/SplashScreenPresenterInterface.java @@ -5,6 +5,7 @@ import android.support.annotation.DrawableRes; 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.gmeremit.online.gmeremittance_native.splash_screen.model.LanguageModel; @@ -28,12 +29,22 @@ public interface SplashScreenPresenterInterface extends BasePresenterInterface { void updateLanguageData(List languageModels); - void updatePayoutModeData(List payoutModes); + //TODO for mocking Context getContext(); void updateFlagImage(int flagFromCountryCode); void showAppVersion(String appVersion); + + void updatePayoutAmount(String pAmount); + void updateCollectionAmount(String pAmount); + + + void showSelectedPayoutMode(List serviceAvailable, int selectedIndex); + + void showSelectedPayoutCurrency(CountryPaymentService selectedPayoutCountryCurrency); + + void animateToExrateView(Runnable task); } } diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/splash_screen/view/SplashScreen.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/splash_screen/view/SplashScreen.java index 5edb92db..18dfec65 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/splash_screen/view/SplashScreen.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/splash_screen/view/SplashScreen.java @@ -17,20 +17,24 @@ import android.support.transition.TransitionListenerAdapter; import android.support.transition.TransitionManager; import android.support.v4.app.Fragment; import android.support.v4.view.ViewCompat; -import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPropertyAnimatorListenerAdapter; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.StaggeredGridLayoutManager; +import android.text.Editable; +import android.text.TextWatcher; import android.view.View; import android.view.animation.AccelerateDecelerateInterpolator; import android.view.animation.AnticipateOvershootInterpolator; import android.view.animation.Interpolator; import android.view.animation.OvershootInterpolator; +import android.widget.EditText; import android.widget.ImageView; 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.exchangecountrylistingdialog.CountryFlagMapper; +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.view.SelectedRedBorderDecoration; import com.gmeremit.online.gmeremittance_native.homeV2.view.HomeActivityV2; @@ -45,7 +49,6 @@ import com.gmeremit.online.gmeremittance_native.splash_screen.presenter.SplashSc import com.gmeremit.online.gmeremittance_native.splash_screen.view.avdfrags.SplashAVD1Fragment; import com.gmeremit.online.gmeremittance_native.splash_screen.view.avdfrags.SplashAVD2Fragment; import com.gmeremit.online.gmeremittance_native.splash_screen.view.avdfrags.SplashAVD3Fragment; -import com.gmeremit.online.gmeremittance_native.splash_screen.view.avdfrags.SplashAnimatedViewPagerFragment; import java.util.ArrayList; import java.util.List; @@ -62,7 +65,6 @@ public class SplashScreen extends BaseActivity implements View.OnClickListener, ViewPagerAVDSplashAdapter viewPagerAdapter; - @BindView(R.id.rootLayout) ConstraintLayout rootLayout; @@ -87,46 +89,42 @@ public class SplashScreen extends BaseActivity implements View.OnClickListener, @BindView(R.id.appVersionTxtView) TextView appVersionTxtView; + + //EXrate Related View @BindView(R.id.paymentModeRV) RecyclerView paymentModeRV; - private int[] layouts; - private TextView[] dots; + @BindView(R.id.sendAmountEdTxt) + EditText sendAmountEdTxt; - LanguageViewTransitionManager languageViewTransitionManager; + @BindView(R.id.receiveAmountEdTxt) + EditText receiveAmountEdTxt; - LanguageSelectionRVAdapter languageSelectionRVAdapter; + @BindView(R.id.recepientFlagImageView) + ImageView receivingCountryFlagImageView; - LanguageModel selectedLanguage; + @BindView(R.id.recepientCurrencyTextView) + TextView receivingCurrencyCodeTxtView; - PayoutModeSelectionRVAdapter payoutModeSelectionRVAdapter; - private SplashScreenPresenterInterface presenter; - private ArrayList fragmentList; - - public final String TAG = getClass().getSimpleName(); + LanguageViewTransitionManager languageViewTransitionManager; + LanguageSelectionRVAdapter languageSelectionRVAdapter; - ViewPager.OnPageChangeListener viewPageChangeListener = new ViewPager.OnPageChangeListener() { - @Override - public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { + LanguageModel selectedLanguage; - } + PayoutModeSelectionRVAdapter payoutModeSelectionRVAdapter; - @Override - public void onPageSelected(int position) { - ((SplashAnimatedViewPagerFragment) fragmentList.get(position)).playAnimation(position == 0 ? 300 : 0); + private SplashScreenPresenterInterface presenter; - } + public final String TAG = getClass().getSimpleName(); - @Override - public void onPageScrollStateChanged(int state) { + private SendAmountTextWatcher sendMoneyTextWatcher; + private ReceiveAmountTextWatcher receiveMoneyTextWatcher; - } - }; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { @@ -143,10 +141,7 @@ public class SplashScreen extends BaseActivity implements View.OnClickListener, if (savedInstanceState == null) { languageViewTransitionManager.underlineTitleText(true); presenter.checkCurrentSelectedLanguage(); -// view_pager.post(() -> viewPageChangeListener.onPageSelected(view_pager.getCurrentItem())); - - //TODO - new Handler().postDelayed(()->languageViewTransitionManager.showMainViewLanguage(500,null),5000); + presenter.getExrateRelatedData(); } } @@ -157,14 +152,8 @@ public class SplashScreen extends BaseActivity implements View.OnClickListener, languageViewTransitionManager = new LanguageViewTransitionManager(this); initLanguageRV(); initPayoutModeRV(); - -// view_pager.addOnPageChangeListener(viewPageChangeListener); -// viewPagerAdapter = new ViewPagerAVDSplashAdapter(getSupportFragmentManager()); -//// viewPagerAdapter = new ViewPagerAdapter(); -// setupViewPagerAdapter(); -// view_pager.setAdapter(viewPagerAdapter); -// view_pager.setOffscreenPageLimit(3); - + sendMoneyTextWatcher = new SendAmountTextWatcher(); + receiveMoneyTextWatcher = new ReceiveAmountTextWatcher(); } @@ -182,18 +171,6 @@ public class SplashScreen extends BaseActivity implements View.OnClickListener, paymentModeRV.setAdapter(payoutModeSelectionRVAdapter); } - private void setupViewPagerAdapter() { - fragmentList = new ArrayList<>(); - - fragmentList.add(new SplashAVD1Fragment()); - fragmentList.add(new SplashAVD2Fragment()); - fragmentList.add(new SplashAVD3Fragment()); - - viewPagerAdapter.addFragments(fragmentList); - } - - - @Override public void onClick(View view) { switch (view.getId()) { @@ -242,7 +219,7 @@ public class SplashScreen extends BaseActivity implements View.OnClickListener, if (languageViewTransitionManager.isAnimationRunning()) return; else if (languageViewTransitionManager.isUserOnLanguageSelectionView()) - languageViewTransitionManager.showMainViewLanguage(0,null); + languageViewTransitionManager.showMainViewLanguageFromLanguageView(0, null); else super.onBackPressed(); } @@ -281,11 +258,6 @@ public class SplashScreen extends BaseActivity implements View.OnClickListener, languageSelectionRVAdapter.setData(languageModels); } - @Override - public void updatePayoutModeData(List payoutModes) { - payoutModeSelectionRVAdapter.setData(payoutModes); - payoutModeSelectionRVAdapter.setSelectedItem(0); - } @Override public Context getContext() { @@ -305,13 +277,64 @@ public class SplashScreen extends BaseActivity implements View.OnClickListener, appVersionTxtView.setText(appVersion); } + //-------------------Exrate Related View------------------- + + + 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 updatePayoutAmount(String pAmount) { + startReceiveAmountListener(false); + receiveAmountEdTxt.setText(pAmount); + startReceiveAmountListener(true); + } + + @Override + public void updateCollectionAmount(String pAmount) { + startSendAmountListener(false); + receiveAmountEdTxt.setText(pAmount); + startSendAmountListener(true); + } + + @Override + public void showSelectedPayoutMode(List serviceAvailable, int selectedIndex) { + payoutModeSelectionRVAdapter.setData(serviceAvailable); + payoutModeSelectionRVAdapter.setSelectedItem(selectedIndex); + } + + @Override + public void showSelectedPayoutCurrency(CountryPaymentService selectedPayoutCountryCurrency) { + receivingCurrencyCodeTxtView.setText(selectedPayoutCountryCurrency.getCurrency()); + receivingCountryFlagImageView.setBackgroundResource(CountryFlagMapper.getFlagFromCountryCode(selectedPayoutCountryCurrency.getCountryCode())); + } + + @Override + public void animateToExrateView(Runnable task) { + languageViewTransitionManager.showMainViewLanguageFromPreLoadingScreen(400, task); + } + @Override public void onPaymentModeSelected(PaymentMode selectedData) { } /** - * Helper class to switch back and forth the language selection view. + * Helper class to switch between different state of this activity layout. */ class LanguageViewTransitionManager { @@ -327,7 +350,6 @@ public class SplashScreen extends BaseActivity implements View.OnClickListener, private int textViewPaintFlags; private ConstraintSet mainViewConstraintSet; private ConstraintSet preLoadingConstraintSet; - private boolean notCalculatedInitialConstraint; LanguageViewTransitionManager(Context context) { isAnimationOnProgress = false; @@ -336,17 +358,16 @@ public class SplashScreen extends BaseActivity implements View.OnClickListener, languageSelectionViewConstraintSet = new ConstraintSet(); languageSelectionViewConstraintSet.clone(context, R.layout.activity_splash_screen_key_2); - mainViewConstraintSet =new ConstraintSet(); - mainViewConstraintSet.clone(context,R.layout.activity_splash_screen_key_1); + mainViewConstraintSet = new ConstraintSet(); + mainViewConstraintSet.clone(context, R.layout.activity_splash_screen_key_1); - preLoadingConstraintSet =new ConstraintSet(); + preLoadingConstraintSet = new ConstraintSet(); preLoadingConstraintSet.clone(rootLayout); anticipateOvershootInterpolator = new AnticipateOvershootInterpolator(.8f); overshootInterpolator = new OvershootInterpolator(); accelerateDecelerateInterpolator = new AccelerateDecelerateInterpolator(); textViewPaintFlags = selectedLanguageText.getPaintFlags(); - notCalculatedInitialConstraint = true; } @@ -401,12 +422,12 @@ public class SplashScreen extends BaseActivity implements View.OnClickListener, selectedLanguageText.invalidate(); } - void showMainViewLanguage(int duration,Runnable onAnimationCompleteCallback) { + void showMainViewLanguageFromLanguageView(int duration, Runnable onAnimationCompleteCallback) { ChangeBounds transition = new ChangeBounds(); transition.setPathMotion(new ArcMotion()); - transition.setInterpolator(duration!=0? accelerateDecelerateInterpolator:overshootInterpolator); - transition.setDuration(duration==0?ANIMATION_DURATION:duration); + transition.setInterpolator(duration != 0 ? accelerateDecelerateInterpolator : overshootInterpolator); + transition.setDuration(duration == 0 ? ANIMATION_DURATION : duration); transition.addListener(new TransitionListenerAdapter() { @Override public void onTransitionStart(@NonNull Transition transition) { @@ -446,6 +467,27 @@ public class SplashScreen extends BaseActivity implements View.OnClickListener, mainViewConstraintSet.applyTo(rootLayout); } + void showMainViewLanguageFromPreLoadingScreen(int duration, Runnable onAnimationCompleteCallback) { + + ChangeBounds transition = new ChangeBounds(); + transition.setPathMotion(new ArcMotion()); + transition.setInterpolator(duration != 0 ? accelerateDecelerateInterpolator : overshootInterpolator); + transition.setDuration(duration == 0 ? ANIMATION_DURATION : duration); + transition.addListener(new TransitionListenerAdapter() { + @Override + public void onTransitionEnd(@NonNull Transition transition) { + super.onTransitionEnd(transition); + isAnimationOnProgress = false; + userNavigatedToLanguageView = false; + if (onAnimationCompleteCallback != null) + onAnimationCompleteCallback.run(); + + } + }); + TransitionManager.beginDelayedTransition(rootLayout, transition); + mainViewConstraintSet.applyTo(rootLayout); + } + public boolean isAnimationRunning() { return this.isAnimationOnProgress; } @@ -458,6 +500,43 @@ public class SplashScreen extends BaseActivity implements View.OnClickListener, } + + class SendAmountTextWatcher implements TextWatcher { + + @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) { + + } + } + + class ReceiveAmountTextWatcher implements TextWatcher { + + @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) { + + } + } + static { System.loadLibrary("antidebugger"); } diff --git a/app/src/main/res/layout/activity_splash_screen_key_0.xml b/app/src/main/res/layout/activity_splash_screen_key_0.xml index c1bd06c5..3c0ed957 100644 --- a/app/src/main/res/layout/activity_splash_screen_key_0.xml +++ b/app/src/main/res/layout/activity_splash_screen_key_0.xml @@ -76,7 +76,6 @@ android:id="@+id/languageRv" android:layout_width="match_parent" android:layout_height="0dp" - android:layout_marginTop="@dimen/_13sdp" android:background="#33000000" android:clipToPadding="false" android:paddingTop="@dimen/_15sdp" diff --git a/app/src/main/res/layout/activity_splash_screen_key_1.xml b/app/src/main/res/layout/activity_splash_screen_key_1.xml index d7c8c50e..d88fab5b 100644 --- a/app/src/main/res/layout/activity_splash_screen_key_1.xml +++ b/app/src/main/res/layout/activity_splash_screen_key_1.xml @@ -69,7 +69,6 @@ android:id="@+id/languageRv" android:layout_width="match_parent" android:layout_height="0dp" - android:layout_marginTop="@dimen/_13sdp" android:background="#33000000" android:clipToPadding="false" android:paddingTop="@dimen/_15sdp"