|
|
@ -5,11 +5,15 @@ import android.os.Bundle |
|
|
|
import android.view.LayoutInflater |
|
|
|
import android.view.View |
|
|
|
import android.view.ViewGroup |
|
|
|
import android.widget.CompoundButton |
|
|
|
import androidx.appcompat.app.AppCompatActivity |
|
|
|
import androidx.appcompat.widget.SwitchCompat |
|
|
|
import androidx.lifecycle.ViewModelProvider |
|
|
|
import com.remit.jmecustomer.R |
|
|
|
import com.remit.jmecustomer.base.BaseFragment |
|
|
|
import com.remit.jmecustomer.common.customwidgets.common.GenericPromptDialog |
|
|
|
import com.remit.jmecustomer.common.customwidgets.common.GenericPromptDialog.GenericDialogPromptListener |
|
|
|
import com.remit.jmecustomer.common.customwidgets.common.GenericPromptDialogSingleButton |
|
|
|
import com.remit.jmecustomer.databinding.FragmentProfileBinding |
|
|
|
import com.remit.jmecustomer.features.aboutscreen.view.AboutJMERemit |
|
|
|
import com.remit.jmecustomer.features.changetxnpin.view.ChangeTxnPinActivity |
|
|
@ -18,21 +22,44 @@ import com.remit.jmecustomer.features.depositinfo.view.DepositInfo |
|
|
|
import com.remit.jmecustomer.features.homeV3.view.HomeActivityV3 |
|
|
|
import com.remit.jmecustomer.features.loyaltypoints.view.LoyaltyPointsActivity |
|
|
|
import com.remit.jmecustomer.features.mynotifications.view.MyNotificationActivity |
|
|
|
import com.remit.jmecustomer.features.security.RemitAuthManager |
|
|
|
import com.remit.jmecustomer.features.security.RemitAuthManager1 |
|
|
|
import com.remit.jmecustomer.features.security.RemitAuthManagerGateway |
|
|
|
import com.remit.jmecustomer.features.security.model.RemitAuthFailedResult |
|
|
|
import com.remit.jmecustomer.features.security.model.RemitAuthSuccessResult |
|
|
|
import com.remit.jmecustomer.features.settings.gateway.LanguageSelectionGateway |
|
|
|
import com.remit.jmecustomer.features.settings.gateway.LanguageSelectionGatewayInterface |
|
|
|
import com.remit.jmecustomer.features.settings.view.FingerSetUpPasswordFragment |
|
|
|
import com.remit.jmecustomer.features.settings.view.FingerSetUpPasswordFragment.RemitSucessFailureCallBack |
|
|
|
import com.remit.jmecustomer.features.settings.view.LanguageSelectionListingDialog |
|
|
|
import com.remit.jmecustomer.features.settings.view.SettingsView |
|
|
|
import com.remit.jmecustomer.features.splashscreen.model.LanguageModel |
|
|
|
import com.remit.jmecustomer.features.userprofile.UserProfileViewModelFactory |
|
|
|
import com.remit.jmecustomer.features.userprofile.model.UserProfile |
|
|
|
import com.remit.jmecustomer.features.userprofile.presenter.UserProfilePresenterInterface |
|
|
|
import com.remit.jmecustomer.features.userprofile.presenter.UserProfilePresenterV2 |
|
|
|
import com.remit.jmecustomer.features.walletstatement.view.WalletStatementV2Activity |
|
|
|
import com.remit.jmecustomer.utils.Constants |
|
|
|
import com.remit.jmecustomer.utils.other.Utility |
|
|
|
import java.util.* |
|
|
|
import io.reactivex.disposables.Disposable |
|
|
|
|
|
|
|
class ProfileFragment : BaseFragment(), View.OnClickListener, |
|
|
|
UserProfilePresenterInterface.UserProfileContractInterface { |
|
|
|
UserProfilePresenterInterface.UserProfileContractInterface, RemitSucessFailureCallBack, |
|
|
|
CompoundButton.OnCheckedChangeListener { |
|
|
|
private var _binding: FragmentProfileBinding? = null |
|
|
|
private val binding get() = _binding!! |
|
|
|
private var viewModel: UserProfilePresenterV2? = null |
|
|
|
|
|
|
|
var languageSelectionGatewayInterface: LanguageSelectionGatewayInterface? = null |
|
|
|
|
|
|
|
var viewFingerPrint: SwitchCompat? = null |
|
|
|
|
|
|
|
var fingerPrintAuthEnableSubs: Disposable? = null |
|
|
|
var fingerSetUpPasswordFragment: FingerSetUpPasswordFragment? = null |
|
|
|
var remitAuthManager: RemitAuthManager? = null |
|
|
|
var remitAuthManager1: RemitAuthManager1? = null |
|
|
|
var remitAuthManagerGateway: RemitAuthManagerGateway? = null |
|
|
|
|
|
|
|
|
|
|
|
override fun onCreateView( |
|
|
|
inflater: LayoutInflater, |
|
|
@ -45,6 +72,8 @@ class ProfileFragment : BaseFragment(), View.OnClickListener, |
|
|
|
} |
|
|
|
|
|
|
|
fun init() { |
|
|
|
viewFingerPrint = binding.enableFingerPrint |
|
|
|
remitAuthManagerGateway = RemitAuthManagerGateway() |
|
|
|
viewModel = ViewModelProvider(this, UserProfileViewModelFactory(this)).get( |
|
|
|
UserProfilePresenterV2::class.java |
|
|
|
) |
|
|
@ -53,6 +82,7 @@ class ProfileFragment : BaseFragment(), View.OnClickListener, |
|
|
|
binding.llFaqLayout.setOnClickListener(this) |
|
|
|
binding.rlLogout.setOnClickListener(this) |
|
|
|
binding.llChangePin.setOnClickListener(this) |
|
|
|
binding.llLanguage.setOnClickListener(this) |
|
|
|
viewModel!!.subscribeToUserProfileInfoFetchEvent().observe( |
|
|
|
this |
|
|
|
) { body: UserProfile? -> |
|
|
@ -60,6 +90,21 @@ class ProfileFragment : BaseFragment(), View.OnClickListener, |
|
|
|
body!! |
|
|
|
) |
|
|
|
} |
|
|
|
remitAuthManager = |
|
|
|
RemitAuthManager.getGmeAuthManager(requireActivity() as AppCompatActivity?) |
|
|
|
remitAuthManager1 = RemitAuthManager1(requireActivity() as AppCompatActivity?) |
|
|
|
if (remitAuthManager1!!.bioMetricCanAuthenticates() == Constants.BIOMETRIC_ERROR_NO_HARDWARE || remitAuthManager1!!.bioMetricCanAuthenticates() == Constants.BIOMETRIC_ERROR_HW_UNAVAILABLE) { |
|
|
|
viewFingerPrint?.visibility = View.GONE |
|
|
|
} else { |
|
|
|
viewFingerPrint?.isChecked = remitAuthManagerGateway!!.isFingerPrintLoginEnabled |
|
|
|
} |
|
|
|
languageSelectionGatewayInterface = LanguageSelectionGateway() |
|
|
|
/* if (!remitAuthManager.isBiometricSupportedByDevice()) { |
|
|
|
view_fingerprint.setVisibility(View.GONE); |
|
|
|
view_fingerprint_divider.setVisibility(View.GONE); |
|
|
|
} else { |
|
|
|
view_fingerprint.setChecked(remitAuthManager.isBiometricEnabledOnTheApp()); |
|
|
|
}*/ |
|
|
|
} |
|
|
|
|
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
|
|
@ -78,7 +123,12 @@ class ProfileFragment : BaseFragment(), View.OnClickListener, |
|
|
|
AboutJMERemit::class.java |
|
|
|
) |
|
|
|
) |
|
|
|
R.id.ll_change_pin -> startActivity(Intent(requireActivity(), ChangeTxnPinActivity::class.java)) |
|
|
|
R.id.ll_change_pin -> startActivity( |
|
|
|
Intent( |
|
|
|
requireActivity(), |
|
|
|
ChangeTxnPinActivity::class.java |
|
|
|
) |
|
|
|
) |
|
|
|
R.id.view_setting -> startActivity(Intent(requireActivity(), SettingsView::class.java)) |
|
|
|
R.id.rl_logout -> { |
|
|
|
showLogoutConfirmationDialog() |
|
|
@ -107,6 +157,8 @@ class ProfileFragment : BaseFragment(), View.OnClickListener, |
|
|
|
LoyaltyPointsActivity::class.java |
|
|
|
) |
|
|
|
) |
|
|
|
R.id.ll_language -> |
|
|
|
promptLanguageSelectionDialog() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -151,4 +203,207 @@ class ProfileFragment : BaseFragment(), View.OnClickListener, |
|
|
|
// tv_referral.setText(String.format("%s\n%s", referralCodeTitle, referralCode)); |
|
|
|
// tv_referral.setText(Html.fromHtml(referralCodeTitle + "<b><font color='#0C2169'> <br>" + referralCode + "</font></b>")); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onStart() { |
|
|
|
super.onStart() |
|
|
|
viewFingerPrint?.setOnCheckedChangeListener(this) |
|
|
|
} |
|
|
|
|
|
|
|
override fun onStop() { |
|
|
|
super.onStop() |
|
|
|
viewFingerPrint?.setOnCheckedChangeListener(null) |
|
|
|
} |
|
|
|
|
|
|
|
private fun promptLanguageSelectionDialog() { |
|
|
|
val languageSelectionDialog = LanguageSelectionListingDialog() |
|
|
|
languageSelectionDialog.setLanguageData(languageSelectionGatewayInterface?.getRelatedLanguageData()) |
|
|
|
languageSelectionDialog.hideSearchView(false) |
|
|
|
languageSelectionDialog.setListener { languageModel -> |
|
|
|
languageSelectionDialog.dismiss() |
|
|
|
changeLocale(languageModel) |
|
|
|
} |
|
|
|
if (!languageSelectionDialog.isAdded) languageSelectionDialog.show( |
|
|
|
requireActivity().supportFragmentManager, |
|
|
|
"GenericTextListingDialog" |
|
|
|
) |
|
|
|
} |
|
|
|
|
|
|
|
private fun changeLocale(lang: LanguageModel) { |
|
|
|
languageSelectionGatewayInterface?.updatePreferredLocaleToStorage(lang.localeCode) |
|
|
|
languageSelectionGatewayInterface?.updatePreferredLanguageToStorage(lang.countryName) |
|
|
|
languageSelectionGatewayInterface?.updatePreferredCountryToStorage(lang.countryCode) |
|
|
|
restartApp() |
|
|
|
} |
|
|
|
|
|
|
|
fun restartApp() { |
|
|
|
val i: Intent? = requireContext().packageManager |
|
|
|
.getLaunchIntentForPackage(requireContext().packageName) |
|
|
|
i?.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_CLEAR_TASK) |
|
|
|
startActivity(i) |
|
|
|
} |
|
|
|
|
|
|
|
override fun onDestroy() { |
|
|
|
super.onDestroy() |
|
|
|
if (fingerPrintAuthEnableSubs != null && !fingerPrintAuthEnableSubs!!.isDisposed) fingerPrintAuthEnableSubs!!.dispose() |
|
|
|
} |
|
|
|
|
|
|
|
/* @Override |
|
|
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { |
|
|
|
switch (buttonView.getId()) { |
|
|
|
case R.id.view_fingerprint: |
|
|
|
|
|
|
|
|
|
|
|
view_fingerprint.setOnCheckedChangeListener(null); |
|
|
|
view_fingerprint.setChecked(!isChecked); |
|
|
|
view_fingerprint.setOnCheckedChangeListener(this); |
|
|
|
|
|
|
|
if (remitAuthManager.isBiometricDataAvailable()) { |
|
|
|
|
|
|
|
remitAuthManager.requestBiometricAuth().setListener(new RemitAuthManager.RemitAuthListener() { |
|
|
|
@Override |
|
|
|
public void onRemitAuthSuccess(RemitAuthSuccessResult result) { |
|
|
|
remitAuthManager.turnOfBiometric(!isChecked); |
|
|
|
view_fingerprint.setOnCheckedChangeListener(null); |
|
|
|
view_fingerprint.setChecked(isChecked); |
|
|
|
view_fingerprint.setOnCheckedChangeListener(SettingsView.this); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onRemitAuthFailed(RemitAuthFailedResult failedResult) { |
|
|
|
showToastMessage(failedResult.getFailedReason()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onRemitAuthCancelled() { |
|
|
|
|
|
|
|
} |
|
|
|
}).prompt(); |
|
|
|
|
|
|
|
} else { |
|
|
|
showPopUpMessage(getString(R.string.fingerprint_changed_externally), CustomAlertDialog.AlertType.ALERT, |
|
|
|
alert -> { |
|
|
|
RemitApplication.getStorage().edit().clear().apply(); |
|
|
|
logout(); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
}*/ |
|
|
|
|
|
|
|
/* @Override |
|
|
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { |
|
|
|
switch (buttonView.getId()) { |
|
|
|
case R.id.view_fingerprint: |
|
|
|
|
|
|
|
|
|
|
|
view_fingerprint.setOnCheckedChangeListener(null); |
|
|
|
view_fingerprint.setChecked(!isChecked); |
|
|
|
view_fingerprint.setOnCheckedChangeListener(this); |
|
|
|
|
|
|
|
if (remitAuthManager.isBiometricDataAvailable()) { |
|
|
|
|
|
|
|
remitAuthManager.requestBiometricAuth().setListener(new RemitAuthManager.RemitAuthListener() { |
|
|
|
@Override |
|
|
|
public void onRemitAuthSuccess(RemitAuthSuccessResult result) { |
|
|
|
remitAuthManager.turnOfBiometric(!isChecked); |
|
|
|
view_fingerprint.setOnCheckedChangeListener(null); |
|
|
|
view_fingerprint.setChecked(isChecked); |
|
|
|
view_fingerprint.setOnCheckedChangeListener(SettingsView.this); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onRemitAuthFailed(RemitAuthFailedResult failedResult) { |
|
|
|
showToastMessage(failedResult.getFailedReason()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onRemitAuthCancelled() { |
|
|
|
|
|
|
|
} |
|
|
|
}).prompt(); |
|
|
|
|
|
|
|
} else { |
|
|
|
showPopUpMessage(getString(R.string.fingerprint_changed_externally), CustomAlertDialog.AlertType.ALERT, |
|
|
|
alert -> { |
|
|
|
RemitApplication.getStorage().edit().clear().apply(); |
|
|
|
logout(); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
}*/ |
|
|
|
private fun switchOnOffPasswordBottomDialog(switchStatus: Boolean) { |
|
|
|
fingerSetUpPasswordFragment = FingerSetUpPasswordFragment(this, switchStatus) |
|
|
|
fingerSetUpPasswordFragment?.show( |
|
|
|
requireActivity().supportFragmentManager, |
|
|
|
FingerSetUpPasswordFragment.TAG |
|
|
|
) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun fingerSucessCallBack(successResult: RemitAuthSuccessResult?, data: ByteArray?) { |
|
|
|
remitAuthManagerGateway?.setFingerPrintLoginStatus(true) |
|
|
|
viewFingerPrint?.setOnCheckedChangeListener(null) |
|
|
|
fingerSetUpPasswordFragment?.dismiss() |
|
|
|
requireActivity().runOnUiThread(Runnable { viewFingerPrint?.setChecked(true) }) |
|
|
|
viewFingerPrint?.setOnCheckedChangeListener(this) |
|
|
|
} |
|
|
|
|
|
|
|
override fun fingerFailedCallBack(failedResult: RemitAuthFailedResult?) { |
|
|
|
viewFingerPrint?.setOnCheckedChangeListener(null) |
|
|
|
fingerSetUpPasswordFragment?.dismiss() |
|
|
|
requireActivity().runOnUiThread(Runnable { viewFingerPrint?.setChecked(false) }) |
|
|
|
viewFingerPrint?.setOnCheckedChangeListener(this) |
|
|
|
} |
|
|
|
|
|
|
|
override fun fingerOffSucessCallBack() { |
|
|
|
remitAuthManagerGateway?.setFingerPrintLoginStatus(false) |
|
|
|
viewFingerPrint?.setOnCheckedChangeListener(null) |
|
|
|
fingerSetUpPasswordFragment?.dismiss() |
|
|
|
viewFingerPrint?.setChecked(false) |
|
|
|
viewFingerPrint?.setOnCheckedChangeListener(this) |
|
|
|
} |
|
|
|
|
|
|
|
override fun fingerPrintCancelCallBack() { |
|
|
|
fingerSetUpPasswordFragment?.dismiss() |
|
|
|
} |
|
|
|
|
|
|
|
override fun onCheckedChanged(buttonView: CompoundButton?, isChecked: Boolean) { |
|
|
|
viewFingerPrint?.setOnCheckedChangeListener(null) |
|
|
|
if (remitAuthManagerGateway?.isFingerPrintLoginEnabled() == false) { |
|
|
|
viewFingerPrint?.setChecked(!isChecked) |
|
|
|
switchOnOffPasswordBottomDialog(isChecked) |
|
|
|
} else { |
|
|
|
if (isChecked) { |
|
|
|
viewFingerPrint?.setChecked(isChecked) |
|
|
|
} else { |
|
|
|
viewFingerPrint?.setChecked(!isChecked) |
|
|
|
switchOnOffPasswordBottomDialog(isChecked) |
|
|
|
} |
|
|
|
} |
|
|
|
viewFingerPrint?.setOnCheckedChangeListener(this@ProfileFragment) |
|
|
|
} |
|
|
|
|
|
|
|
fun showMessageAlertDialog(bodyMessage: String?) { |
|
|
|
this.fingerSetUpPasswordFragment?.dismiss() |
|
|
|
val genericPromptDialog = GenericPromptDialogSingleButton() |
|
|
|
genericPromptDialog.setTitleMessage(getString(R.string.info_text)) |
|
|
|
genericPromptDialog.setBodyMessage(bodyMessage) |
|
|
|
genericPromptDialog.setIconsRes(-1) |
|
|
|
genericPromptDialog.setCancellable(true) |
|
|
|
genericPromptDialog.setPositiveBtnString(getString(R.string.ok_text)) |
|
|
|
if (!genericPromptDialog.isAdded) genericPromptDialog.show( |
|
|
|
requireActivity().supportFragmentManager, |
|
|
|
"PROMPTAPIRESPONSE" |
|
|
|
) |
|
|
|
} |
|
|
|
} |