From ce6d9330b3e3ddaffb638c1635278a9e1509abab Mon Sep 17 00:00:00 2001 From: Preyea Regmi Date: Tue, 28 May 2019 14:34:58 +0545 Subject: [PATCH] Contact list updated --- .../gmeremittance_native/GmeApplication.java | 2 +- .../model/CustomerSupportContact.java | 28 ++++++++++ .../view/CustomerSupportFragment.java | 52 ++++++++++++++++++- .../utils/https/HttpClientV2.java | 7 +-- .../res/layout/fragment_customer_support.xml | 1 + 5 files changed, 81 insertions(+), 9 deletions(-) create mode 100644 app/src/main/java/com/gmeremit/online/gmeremittance_native/customer_support/model/CustomerSupportContact.java diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/GmeApplication.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/GmeApplication.java index d742586b..3d41b6bf 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/GmeApplication.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/GmeApplication.java @@ -193,7 +193,7 @@ public class GmeApplication extends MultiDexApplication { } - public static String getSelectedLanguage() + public static String getPreferredCountryCode() { if(gmeSharedPreferences==null) return "en"; diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/customer_support/model/CustomerSupportContact.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/customer_support/model/CustomerSupportContact.java new file mode 100644 index 00000000..76d58c2c --- /dev/null +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/customer_support/model/CustomerSupportContact.java @@ -0,0 +1,28 @@ +package com.gmeremit.online.gmeremittance_native.customer_support.model; + +public class CustomerSupportContact { + + String countryCode; + String customerContact; + + public CustomerSupportContact(String countryCode, String customerContact) { + this.countryCode = countryCode; + this.customerContact = customerContact; + } + + public String getCountryCode() { + return countryCode; + } + + public void setCountryCode(String countryCode) { + this.countryCode = countryCode; + } + + public String getCustomerContact() { + return customerContact; + } + + public void setCustomerContact(String customerContact) { + this.customerContact = customerContact; + } +} diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/customer_support/view/CustomerSupportFragment.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/customer_support/view/CustomerSupportFragment.java index 1f548ba4..592f0c73 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/customer_support/view/CustomerSupportFragment.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/customer_support/view/CustomerSupportFragment.java @@ -14,11 +14,17 @@ import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; +import com.gmeremit.online.gmeremittance_native.GmeApplication; import com.gmeremit.online.gmeremittance_native.R; import com.gmeremit.online.gmeremittance_native.customer_support.CustomerSupportContract; +import com.gmeremit.online.gmeremittance_native.customer_support.model.CustomerSupportContact; import com.gmeremit.online.gmeremittance_native.customer_support.presenter.CustomerSupportPresenter; +import com.gmeremit.online.gmeremittance_native.splash_screen.model.LanguageModel; import com.gmeremit.online.gmeremittance_native.supportV2.view.SupportActivityV2; +import java.util.ArrayList; +import java.util.List; + import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; @@ -41,6 +47,9 @@ public class CustomerSupportFragment extends DialogFragment implements CustomerS @BindView(R.id.btnCancel) TextView btnCancel; + @BindView(R.id.callTxtView) + TextView callTxtView; + private CustomerSupportPresenter presenter; public static CustomerSupportFragment newInstance() { @@ -60,14 +69,53 @@ public class CustomerSupportFragment extends DialogFragment implements CustomerS View view = inflater.inflate(R.layout.fragment_customer_support, container, false); init(view); - + performDefaultAction(); return view; } + private void performDefaultAction() { + + List contactList = getCustomerSupportContact(); + + CustomerSupportContact selectedContact = null; + String preferredCountry = GmeApplication.getPreferredCountryCode(); + + for (CustomerSupportContact contact : contactList) { + if (contact.getCountryCode().equalsIgnoreCase(preferredCountry)) { + selectedContact = contact; + break; + } + } + if (selectedContact == null) + selectedContact = contactList.get(0); + + callTxtView.setText(selectedContact.getCustomerContact()); + + } + + private List getCustomerSupportContact() { + + List contactList = new ArrayList<>(); + contactList.add(new CustomerSupportContact("EN", "")); + contactList.add(new CustomerSupportContact("KH", "")); + contactList.add(new CustomerSupportContact("KR", "")); + contactList.add(new CustomerSupportContact("TH", "")); + contactList.add(new CustomerSupportContact("LK", "")); + contactList.add(new CustomerSupportContact("MN", "")); + contactList.add(new CustomerSupportContact("MM", "")); + contactList.add(new CustomerSupportContact("NP", "")); + contactList.add(new CustomerSupportContact("ID", "")); + contactList.add(new CustomerSupportContact("BD", "")); + contactList.add(new CustomerSupportContact("RU", "")); + contactList.add(new CustomerSupportContact("UZ", "")); + contactList.add(new CustomerSupportContact("VN", "")); + } + private void init(View view) { ButterKnife.bind(this, view); presenter = new CustomerSupportPresenter(this); + } @OnClick({R.id.viewLiveChat, R.id.viewCall, R.id.viewEmail, R.id.btnCancel}) @@ -118,7 +166,7 @@ public class CustomerSupportFragment extends DialogFragment implements CustomerS @Override public void handleCall() { Intent call = new Intent(Intent.ACTION_DIAL); - call.setData(Uri.parse("tel: " + "1588 6864")); + call.setData(Uri.parse("tel: " + callTxtView.getText().toString())); startActivity(call); } diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/utils/https/HttpClientV2.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/utils/https/HttpClientV2.java index c6144b50..6bbccb1e 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/utils/https/HttpClientV2.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/utils/https/HttpClientV2.java @@ -1,6 +1,5 @@ package com.gmeremit.online.gmeremittance_native.utils.https; -import android.content.Context; import android.util.Log; import com.gmeremit.online.gmeremittance_native.BuildConfig; @@ -9,13 +8,9 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import java.io.File; -import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Calendar; import java.util.concurrent.TimeUnit; import okhttp3.Interceptor; @@ -53,7 +48,7 @@ public class HttpClientV2 { Interceptor authInterceptor = chain -> { Request newRequest = chain.request().newBuilder() .addHeader("GME-TOKEN", "39587YT398@FBQOW8RY3#948R7GB@CNEQW987GF87$TD18$1981..919@@##joghndvberteiru") - .addHeader("lang",GmeApplication.getSelectedLanguage().toLowerCase()) + .addHeader("lang",GmeApplication.getPreferredCountryCode().toLowerCase()) .build(); return chain.proceed(newRequest); }; diff --git a/app/src/main/res/layout/fragment_customer_support.xml b/app/src/main/res/layout/fragment_customer_support.xml index 9c7f7310..18b3808d 100644 --- a/app/src/main/res/layout/fragment_customer_support.xml +++ b/app/src/main/res/layout/fragment_customer_support.xml @@ -86,6 +86,7 @@ android:src="@drawable/ic_support_phone" />