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 215ca027..fbc7f7dd 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 @@ -18,19 +18,17 @@ import android.widget.Toast; import com.gmeremit.online.gmeremittance_native.GmeApplication; import com.gmeremit.online.gmeremittance_native.R; -import com.gmeremit.online.gmeremittance_native.base.PrefKeys; import com.gmeremit.online.gmeremittance_native.customer_support.CustomerSupportContract; import com.gmeremit.online.gmeremittance_native.customer_support.presenter.CustomerSupportPresenter; import com.gmeremit.online.gmeremittance_native.customwidgets.CustomAlertDialog; import com.gmeremit.online.gmeremittance_native.customwidgets.CustomProgressDialog; import com.gmeremit.online.gmeremittance_native.homeV2.HomeParentViewContractV2; import com.gmeremit.online.gmeremittance_native.supportV2.view.SupportActivityV2; +import com.gmeremit.online.gmeremittance_native.utils.ChatUtils; import com.zoyi.channel.plugin.android.ChannelIO; import com.zoyi.channel.plugin.android.ChannelPluginCompletionStatus; -import com.zoyi.channel.plugin.android.ChannelPluginSettings; import com.zoyi.channel.plugin.android.Guest; import com.zoyi.channel.plugin.android.OnBootListener; -import com.zoyi.channel.plugin.android.Profile; import butterknife.BindView; import butterknife.ButterKnife; @@ -215,15 +213,10 @@ public class CustomerSupportFragment extends DialogFragment implements CustomerS customAlertDialog.setActionListener(new CustomAlertDialog.CustomDialogActionListener() { @Override public void onCutomDialogActionPressed(CustomAlertDialog.AlertType alertType) { - ChannelPluginSettings settings = new ChannelPluginSettings("24dc2dfd-3ed1-4953-b395-a2255ed41dae"); - settings.setUserId(GmeApplication.getStorage().getString(PrefKeys.USER_EMAIL,"")); - - Profile profile = Profile.create() - .setName(GmeApplication.getStorage().getString(PrefKeys.USER_FIRST_NAME,"")) - .setEmail(GmeApplication.getStorage().getString(PrefKeys.USER_EMAIL,"")); + ChatUtils.ChatInitData initializer=ChatUtils.startChannelIoCredential(false); showProgressBar(true,getString(R.string.processing_request_text)); - ChannelIO.boot(settings, profile,CustomerSupportFragment.this); + ChannelIO.boot(initializer.getChannelPluginSettings(), initializer.getProfile(),CustomerSupportFragment.this); } }); diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/view/HomeActivityV2.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/view/HomeActivityV2.java index 517b06e5..cce82f66 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/view/HomeActivityV2.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/view/HomeActivityV2.java @@ -40,6 +40,7 @@ import com.gmeremit.online.gmeremittance_native.settings.view.SettingsView; import com.gmeremit.online.gmeremittance_native.static_pages.view.AboutGME; import com.gmeremit.online.gmeremittance_native.transactionhistoryV2.view.TransactionHistoryActivityV2; import com.gmeremit.online.gmeremittance_native.user_profile.view.ProfileActivity; +import com.gmeremit.online.gmeremittance_native.utils.ChatUtils; import com.gmeremit.online.gmeremittance_native.utils.Utils; import com.gmeremit.online.gmeremittance_native.walletstatementV2.view.WalletStatementV2Activity; import com.gmeremit.online.gmeremittance_native.withdrawV2.view.WithdrawV2Activity; @@ -55,8 +56,6 @@ import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; -import static com.zoyi.channel.plugin.android.ChannelPluginCompletionStatus.SUCCESS; - public class HomeActivityV2 extends BaseActivity implements HomeParentViewContractV2, HomeV2PresenterInterface.HomeV2ContractInterface { @@ -83,6 +82,8 @@ public class HomeActivityV2 extends BaseActivity implements HomeParentViewContra @BindView(R.id.iv_close) ImageView iv_close; + + @BindView(R.id.notificationCounterTxtView) TextView notificationCounterTxtView; @@ -535,10 +536,10 @@ public class HomeActivityV2 extends BaseActivity implements HomeParentViewContra @Override public void onChangeBadge(int count) { String countString; - if(count>99) - countString="99+"; + if (count > 99) + countString = "99+"; else - countString=count+""; + countString = count + ""; presenter.persistNotificationCount(countString); notificationCounterTxtView.setText(countString); @@ -567,36 +568,12 @@ public class HomeActivityV2 extends BaseActivity implements HomeParentViewContra @Override public void onCompletion(ChannelPluginCompletionStatus status, @Nullable Guest guest) { - if (status == SUCCESS) { + String errorMessage = ChatUtils.errorMessage(status, HomeActivityV2.this); + if (errorMessage == null) ChannelIO.open(HomeActivityV2.this); - } else { - String serviceNotAvailable = getString(R.string.channelIO_error_message_text); - switch (status) { - case NOT_INITIALIZED: - serviceNotAvailable += "(1)"; - break; - case NETWORK_TIMEOUT: - serviceNotAvailable += "(2)"; - break; - case NOT_AVAILABLE_VERSION: - serviceNotAvailable += "(3)"; - break; - case SERVICE_UNDER_CONSTRUCTION: - serviceNotAvailable += "(4)"; - break; - case REQUIRE_PAYMENT: - serviceNotAvailable += "(5)"; - break; - case ACCESS_DENIED: - serviceNotAvailable += "(6)"; - break; - case UNKNOWN_ERROR: - serviceNotAvailable += "(7)"; - break; - - } - showPopUpMessage(serviceNotAvailable, CustomAlertDialog.AlertType.FAILED, null); - } + else + showPopUpMessage(errorMessage, CustomAlertDialog.AlertType.FAILED, null); } } } + 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 aa4090ad..20a31575 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 @@ -15,6 +15,7 @@ import android.support.transition.ChangeBounds; import android.support.transition.Transition; import android.support.transition.TransitionListenerAdapter; import android.support.transition.TransitionManager; +import android.support.v4.app.FragmentManager; import android.support.v4.view.GestureDetectorCompat; import android.support.v4.view.ViewCompat; import android.support.v4.view.ViewPropertyAnimatorListenerAdapter; @@ -36,7 +37,9 @@ 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.customer_support.view.CustomerSupportFragment; import com.gmeremit.online.gmeremittance_native.customwidgets.CurrencyFormatterTextWatcher; +import com.gmeremit.online.gmeremittance_native.customwidgets.CustomAlertDialog; 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.model.datav2.CountryPaymentService; @@ -50,6 +53,11 @@ import com.gmeremit.online.gmeremittance_native.splash_screen.adapter.PayoutMode import com.gmeremit.online.gmeremittance_native.splash_screen.model.LanguageModel; import com.gmeremit.online.gmeremittance_native.splash_screen.presenter.SplashScreenPresenter; import com.gmeremit.online.gmeremittance_native.splash_screen.presenter.SplashScreenPresenterInterface; +import com.gmeremit.online.gmeremittance_native.utils.ChatUtils; +import com.zoyi.channel.plugin.android.ChannelIO; +import com.zoyi.channel.plugin.android.ChannelPluginCompletionStatus; +import com.zoyi.channel.plugin.android.Guest; +import com.zoyi.channel.plugin.android.OnBootListener; import java.util.List; @@ -57,7 +65,7 @@ import butterknife.BindView; import butterknife.ButterKnife; -public class SplashScreen extends BaseActivity implements View.OnClickListener, LanguageSelectionRVAdapter.LanguageSelectionListener, SplashScreenPresenterInterface.SplashScreenContractInterfacee, PayoutModeSelectionRVAdapter.OnPaymentModeSelectionListener, TextView.OnEditorActionListener { +public class SplashScreen extends BaseActivity implements View.OnClickListener, LanguageSelectionRVAdapter.LanguageSelectionListener, SplashScreenPresenterInterface.SplashScreenContractInterfacee, PayoutModeSelectionRVAdapter.OnPaymentModeSelectionListener, TextView.OnEditorActionListener, OnBootListener { @BindView(R.id.view_pager) ConstraintLayout view_pager; @@ -88,6 +96,8 @@ public class SplashScreen extends BaseActivity implements View.OnClickListener, @BindView(R.id.appVersionTxtView) TextView appVersionTxtView; + @BindView(R.id.fab_chat) + View fab_chat; //EXrate Related View @BindView(R.id.paymentModeRV) @@ -207,6 +217,9 @@ public class SplashScreen extends BaseActivity implements View.OnClickListener, if (languageViewTransitionManager.isUserOnLanguageSelectionView()) onBackPressed(); break; + case R.id.fab_chat: + promptToChat(); + break; case R.id.selectedLanguageText: case R.id.selectedLanguageIcon: if (!languageViewTransitionManager.isUserOnLanguageSelectionView()) @@ -222,6 +235,7 @@ public class SplashScreen extends BaseActivity implements View.OnClickListener, btn_login.setOnClickListener(this); btn_new_user.setOnClickListener(this); iv_back.setOnClickListener(this); + fab_chat.setOnClickListener(this); selectedLanguageText.setOnClickListener(this); selectedLanguageIcon.setOnClickListener(this); countrySelectionSpinner.setOnClickListener(this); @@ -235,6 +249,7 @@ public class SplashScreen extends BaseActivity implements View.OnClickListener, btn_login.setOnClickListener(null); btn_new_user.setOnClickListener(null); iv_back.setOnClickListener(null); + fab_chat.setOnClickListener(null); selectedLanguageText.setOnClickListener(null); selectedLanguageIcon.setOnClickListener(null); countrySelectionSpinner.setOnClickListener(null); @@ -304,7 +319,39 @@ public class SplashScreen extends BaseActivity implements View.OnClickListener, selectedLanguageIcon.setImageResource(flagFromCountryCode); } - @Override + private void promptToChat() { + + try { + FragmentManager fragmentManager = getSupportFragmentManager(); + if (fragmentManager == null) + return; + CustomAlertDialog customAlertDialog; + + customAlertDialog = new CustomAlertDialog(); + customAlertDialog.setMessage(getString(R.string.check_start_chat_text)); + customAlertDialog.setAlertType(CustomAlertDialog.AlertType.ALERT); + customAlertDialog.setPositiveBtnString(getString(R.string.yes_text)); + customAlertDialog.setNegativeBtnString(getString(R.string.no_text)); + customAlertDialog.setActionListener(new CustomAlertDialog.CustomDialogActionListener() { + @Override + public void onCutomDialogActionPressed(CustomAlertDialog.AlertType alertType) { + + ChatUtils.ChatInitData initializer=ChatUtils.startChannelIoCredential(true); + showProgressBar(true,getString(R.string.loading_text)); + ChannelIO.boot(initializer.getChannelPluginSettings(), initializer.getProfile(), SplashScreen.this); + } + }); + + + customAlertDialog.show(fragmentManager, "CustomerMes"); + } catch (Exception e) { + + + } + } + + + @Override public void showAppVersion(String appVersion) { appVersionTxtView.setText(appVersion); } @@ -432,6 +479,17 @@ public class SplashScreen extends BaseActivity implements View.OnClickListener, } + @Override + public void onCompletion(ChannelPluginCompletionStatus status, @Nullable Guest guest) { + showProgressBar(false,getString(R.string.loading_text)); + + String errorMessage = ChatUtils.errorMessage(status, SplashScreen.this); + if (errorMessage == null) + ChannelIO.open(SplashScreen.this); + else + showPopUpMessage(errorMessage, CustomAlertDialog.AlertType.FAILED, null); + } + /** * Helper class to switch between different state of this activity layout. */ diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/utils/ChatUtils.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/utils/ChatUtils.java new file mode 100644 index 00000000..fa250030 --- /dev/null +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/utils/ChatUtils.java @@ -0,0 +1,82 @@ +package com.gmeremit.online.gmeremittance_native.utils; + +import android.content.Context; + +import com.gmeremit.online.gmeremittance_native.GmeApplication; +import com.gmeremit.online.gmeremittance_native.R; +import com.gmeremit.online.gmeremittance_native.base.PrefKeys; +import com.zoyi.channel.plugin.android.ChannelPluginCompletionStatus; +import com.zoyi.channel.plugin.android.ChannelPluginSettings; +import com.zoyi.channel.plugin.android.Profile; + +public class ChatUtils { + + public static ChatInitData startChannelIoCredential(boolean isUserGuest) + { + ChannelPluginSettings settings = new ChannelPluginSettings("24dc2dfd-3ed1-4953-b395-a2255ed41dae"); + settings.setUserId(GmeApplication.getStorage().getString(PrefKeys.USER_EMAIL,"")); + + + if(!isUserGuest) { + Profile profile = Profile.create() + .setName(GmeApplication.getStorage().getString(PrefKeys.USER_FIRST_NAME, "")) + .setEmail(GmeApplication.getStorage().getString(PrefKeys.USER_EMAIL, "")); + return new ChatInitData(profile,settings); + } + else + return new ChatInitData(null,settings); + + } + + public static class ChatInitData + { + Profile profile; + ChannelPluginSettings channelPluginSettings; + + public ChatInitData(Profile profile, ChannelPluginSettings channelPluginSettings) { + this.profile = profile; + this.channelPluginSettings = channelPluginSettings; + } + + public Profile getProfile() { + return profile; + } + + public ChannelPluginSettings getChannelPluginSettings() { + return channelPluginSettings; + } + } + + + public static String errorMessage(ChannelPluginCompletionStatus status, Context context) + { + String errorMessage = context.getString(R.string.channelIO_error_message_text); + switch (status) { + case NOT_INITIALIZED: + errorMessage += "(1)"; + break; + case NETWORK_TIMEOUT: + errorMessage += "(2)"; + break; + case NOT_AVAILABLE_VERSION: + errorMessage += "(3)"; + break; + case SERVICE_UNDER_CONSTRUCTION: + errorMessage += "(4)"; + break; + case REQUIRE_PAYMENT: + errorMessage += "(5)"; + break; + case ACCESS_DENIED: + errorMessage += "(6)"; + break; + case UNKNOWN_ERROR: + errorMessage += "(7)"; + break; + case SUCCESS: + errorMessage=null; + + } + return errorMessage; + } +} 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 4eeba31a..0dad2d47 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 @@ -28,7 +28,13 @@ import android.widget.EditText; import android.widget.ImageView; import android.widget.TextView; +import com.gmeremit.online.gmeremittance_native.GmeApplication; import com.gmeremit.online.gmeremittance_native.R; +import com.gmeremit.online.gmeremittance_native.base.PrefKeys; +import com.gmeremit.online.gmeremittance_native.customer_support.view.CustomerSupportFragment; +import com.zoyi.channel.plugin.android.ChannelIO; +import com.zoyi.channel.plugin.android.ChannelPluginSettings; +import com.zoyi.channel.plugin.android.Profile; import java.io.ByteArrayOutputStream; @@ -71,37 +77,8 @@ public class Utils { return Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID); } -// @SuppressLint("RestrictedApi") -// public static void disableShiftMode(BottomNavigationView view) { -// BottomNavigationMenuView menuView = (BottomNavigationMenuView) view.getChildAt(0); -// try { -// Field shiftingMode = menuView.getClass().getDeclaredField("mShiftingMode"); -// shiftingMode.setAccessible(true); -// shiftingMode.setBoolean(menuView, false); -// shiftingMode.setAccessible(false); -// for (int i = 0; i < menuView.getChildCount(); i++) { -// BottomNavigationItemView item = (BottomNavigationItemView) menuView.getChildAt(i); -// //noinspection RestrictedApi -// item.setShiftingMode(false); -// // set once again checked value, so view will be updated -// //noinspection RestrictedApi -// item.setChecked(item.getItemData().isChecked()); -// } -// } catch (NoSuchFieldException e) { -// Log.e("BNVHelper", "Unable to get shift mode field", e); -// } catch (IllegalAccessException e) { -// Log.e("BNVHelper", "Unable to change value of shift mode", e); -// } -// } - /** - * TODO - */ - /* public static String getBaseAccessCode(PersistenceStorageManager persistenceStorageManager) { - String deviceId = Constants.DEVICEID; - String maincode = persistenceStorageManager.getAccessCode() + ":" + deviceId; - return toBase64(maincode); - }*/ + public static String getBaseAccessCode(String accessCode, Context context) { String deviceId = getDeviceID(context); String maincode = accessCode + ":" + deviceId; @@ -227,12 +204,7 @@ public class Utils { return returnedBitmap; } - /** - * Check editText in a bulk - * - * @param editTexts - * @return boolean - */ + public static boolean checkEmptyEditText(EditText[] editTexts, Context context) { for (int i = 0; i < editTexts.length; i++) { String text = editTexts[i].getText().toString().trim(); @@ -751,4 +723,6 @@ public class Utils { } + + } 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 a0ba8685..bc542f97 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 @@ -4,7 +4,6 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:paddingBottom="@dimen/_2sdp" android:fillViewport="true">