diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 42482cc..cda90aa 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -4,11 +4,13 @@ + + Unit) { + val editor = this.edit() + operation(editor) + editor.apply() +} + +/** + * puts a key value pair in shared prefs if doesn't exists, otherwise updates value on given [key] + */ +private operator fun SharedPreferences.set(key: String, value: Any?) { + when (value) { + is String? -> edit { it.putString(key, value) } + is Int -> edit { it.putInt(key, value) } + is Boolean -> edit { it.putBoolean(key, value) } + is Float -> edit { it.putFloat(key, value) } + is Long -> edit { it.putLong(key, value) } + else -> throw UnsupportedOperationException("Not yet implemented") + } +} + +/** + * finds value on given key. + * [T] is the type of value + * @param defaultValue optional default value - will take null for strings, false for bool and -1 for numeric values if [defaultValue] is not specified + */ +private inline operator fun SharedPreferences.get( + key: String, + defaultValue: T? = null +): T? { + return when (T::class) { + String::class -> getString(key, defaultValue as? String) as T? + Int::class -> getInt(key, defaultValue as? Int ?: -1) as T? + Boolean::class -> getBoolean(key, defaultValue as? Boolean ?: false) as T? + Float::class -> getFloat(key, defaultValue as? Float ?: -1f) as T? + Long::class -> getLong(key, defaultValue as? Long ?: -1) as T? + else -> throw UnsupportedOperationException("Not yet implemented") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/niveshfd/interfaces/IPreferenceHelper.kt b/app/src/main/java/com/nivesh/production/niveshfd/interfaces/IPreferenceHelper.kt new file mode 100644 index 0000000..9f86f3c --- /dev/null +++ b/app/src/main/java/com/nivesh/production/niveshfd/interfaces/IPreferenceHelper.kt @@ -0,0 +1,30 @@ +package com.nivesh.production.niveshfd.interfaces + +interface IPreferenceHelper { + + fun getLoginPasswordHash(): String + fun setLoginPasswordHash(appName: String) + + fun getUserUid(): Int + fun setUserUid(appName: Int) + + fun getLoginRole(): Int + fun setLoginRole(appName: Int) + + fun getSubBrokerID(): String + fun setSubBrokerID(appName: String) + + fun getClientUmsID(): String + fun setClientUmsID(appName: String) + + fun getClientCode(): String + fun setClientCode(appName: String) + + fun setToken(appName: String) + fun getToken(): String + + fun setLanguage(appName: String) + fun getLanguage(): String + + fun clearPrefs() +} \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/niveshfd/model/FDInvestmentDetails.kt b/app/src/main/java/com/nivesh/production/niveshfd/model/FDInvestmentDetails.kt index d070554..0035226 100644 --- a/app/src/main/java/com/nivesh/production/niveshfd/model/FDInvestmentDetails.kt +++ b/app/src/main/java/com/nivesh/production/niveshfd/model/FDInvestmentDetails.kt @@ -13,6 +13,7 @@ data class FDInvestmentDetails( var Provider: String? = null, var Source: String? = null, var Tenure: Int? = 0, - var UniqueId: String? = "" + var UniqueId: String? = "", + var RenewOption : String = "" ) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/niveshfd/ui/activity/NiveshFdMainActivity.kt b/app/src/main/java/com/nivesh/production/niveshfd/ui/activity/NiveshFdMainActivity.kt index 6583c1f..74bc116 100644 --- a/app/src/main/java/com/nivesh/production/niveshfd/ui/activity/NiveshFdMainActivity.kt +++ b/app/src/main/java/com/nivesh/production/niveshfd/ui/activity/NiveshFdMainActivity.kt @@ -21,13 +21,13 @@ import com.nivesh.production.niveshfd.adapter.DisableAdapter import com.nivesh.production.niveshfd.adapter.SectionsPagerAdapter import com.nivesh.production.niveshfd.api.ApiClient import com.nivesh.production.niveshfd.databinding.ActivityNiveshFdBinding +import com.nivesh.production.niveshfd.db.PreferenceManager import com.nivesh.production.niveshfd.model.* import com.nivesh.production.niveshfd.repositories.MainRepository import com.nivesh.production.niveshfd.ui.fragment.* import com.nivesh.production.niveshfd.ui.providerfactory.* import com.nivesh.production.niveshfd.util.Common import com.nivesh.production.niveshfd.util.Common.Companion.defaultShape -import com.nivesh.production.niveshfd.util.Common.Companion.getDate import com.nivesh.production.niveshfd.util.Common.Companion.selectedShape import com.nivesh.production.niveshfd.util.Common.Companion.showDialogValidation import com.nivesh.production.niveshfd.util.Constants.Companion.token @@ -56,12 +56,13 @@ class NiveshFdMainActivity : BaseActivity() { var nomineeDetails: NomineeDetails = NomineeDetails() var nomineeGuardianDetails: NomineeGuardianDetails = NomineeGuardianDetails() var getClientDetailsResponse: getClientDetailsResponse = getClientDetailsResponse() - var uniqueId: String = "" - var stepCount: Int = 0 + private lateinit var sectionsPagerAdapter: SectionsPagerAdapter private lateinit var fragments: Array var dialogWebView: Dialog? = null var loginRole: Int = 0 + var stepCount: Int = 0 + var uniqueId: String = "" override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -79,6 +80,11 @@ class NiveshFdMainActivity : BaseActivity() { setContentView(this.root) } + // For Set Data + PreferenceManager(this@NiveshFdMainActivity).setSubBrokerID("") + // For Get Data + PreferenceManager(context = this@NiveshFdMainActivity).getSubBrokerID() + loginRole = 5 if (Common.isNetworkAvailable(this)) { getStepsCountApi() @@ -134,6 +140,10 @@ class NiveshFdMainActivity : BaseActivity() { is Resource.DataError -> { } + else -> { + showDialogValidation(this@NiveshFdMainActivity, response.message) + } + } } } @@ -179,11 +189,13 @@ class NiveshFdMainActivity : BaseActivity() { when (code) { 200 -> { setViewPager(stepsCount) - checkFDCKYCApi() } - // 650 -> refreshToken() + 650 -> "" else -> { - showDialogValidation(this@NiveshFdMainActivity, response.message) + showDialogValidation( + this@NiveshFdMainActivity, + response.message + ) } } } @@ -200,6 +212,9 @@ class NiveshFdMainActivity : BaseActivity() { is Resource.DataError -> { } + else -> { + showDialogValidation(this@NiveshFdMainActivity, response.message) + } } } } @@ -301,62 +316,6 @@ class NiveshFdMainActivity : BaseActivity() { } - private fun checkFDCKYCApi() { - if (Common.isNetworkAvailable(this@NiveshFdMainActivity)) { - if (getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CM_MOBILE?.isNotEmpty()!! && getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_DOB?.isNotEmpty()!! && getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_PAN?.isNotEmpty()!! && getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_CODE?.isNotEmpty()!!) { - val checkFDKYCRequest = CheckFDKYCRequest() - checkFDKYCRequest.Mobile = - getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CM_MOBILE - checkFDKYCRequest.DOB = - getDate(getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_DOB!!) - checkFDKYCRequest.PAN = - getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_PAN - checkFDKYCRequest.NiveshClientCode = - getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_CODE.toString() - viewModel.checkFDKYC(checkFDKYCRequest, token, this) - viewModel.getFDKYCMutableData.observe(this) { response -> - when (response) { - is Resource.Success -> { - Log.e("response", "-->${response.data.toString()}") - val getCodeResponse: GetCodeResponse = - Gson().fromJson( - response.data?.toString(), - GetCodeResponse::class.java - ) - getCodeResponse.Response.StatusCode.let { code -> - when (code) { - 200 -> { - - fdInvestmentDetails.CustomerType = "" - } - // 650 -> refreshToken() - else -> { - showDialogValidation( - this@NiveshFdMainActivity, - getCodeResponse.Response.Errors[0].ErrorMessage - ) - } - } - } - } - - is Resource.Error -> { - response.message?.let { message -> - showDialogValidation(this@NiveshFdMainActivity, message) - } - } - is Resource.Loading -> { - - } - is Resource.DataError -> { - - } - } - } - } - } - - } // set background for selected/ default step private fun setBackground( @@ -481,6 +440,9 @@ class NiveshFdMainActivity : BaseActivity() { is Resource.DataError -> { } + else -> { + showDialogValidation(this@NiveshFdMainActivity, response.message) + } } } } diff --git a/app/src/main/java/com/nivesh/production/niveshfd/ui/fragment/StepFiveNiveshFDFragment.kt b/app/src/main/java/com/nivesh/production/niveshfd/ui/fragment/StepFiveNiveshFDFragment.kt index 7aa9f5f..e82ee62 100644 --- a/app/src/main/java/com/nivesh/production/niveshfd/ui/fragment/StepFiveNiveshFDFragment.kt +++ b/app/src/main/java/com/nivesh/production/niveshfd/ui/fragment/StepFiveNiveshFDFragment.kt @@ -55,26 +55,25 @@ class StepFiveNiveshFDFragment : Fragment() { ) binding.tvSuccessMessage.text = arrOfStr[1] } + finalizeFDApi() + finalizeKYCApi() }else{ if (paymentReQueryResponse.Response.Message.isNotEmpty()) { if (paymentReQueryResponse.Response.Message.isNotEmpty()) { - val arrOfStr: List = - paymentReQueryResponse.Response.Message.split(" ", limit = 2) - binding.tvCongrats.text = arrOfStr[0] + binding.tvCongrats.text = paymentReQueryResponse.Response.Status binding.tvCongrats.setTextColor( ContextCompat.getColor( activity as NiveshFdMainActivity, R.color.red ) ) - binding.tvSuccessMessage.text = arrOfStr[1] + binding.tvSuccessMessage.text = paymentReQueryResponse.Response.Message } } binding.tvRetry.visibility = View.VISIBLE binding.btnViewOrder.visibility = View.GONE } - finalizeFDApi() - finalizeKYCApi() + } private fun finalizeFDApi() { diff --git a/app/src/main/java/com/nivesh/production/niveshfd/ui/fragment/StepFourNiveshFDFragment.kt b/app/src/main/java/com/nivesh/production/niveshfd/ui/fragment/StepFourNiveshFDFragment.kt index d03000e..48a6013 100644 --- a/app/src/main/java/com/nivesh/production/niveshfd/ui/fragment/StepFourNiveshFDFragment.kt +++ b/app/src/main/java/com/nivesh/production/niveshfd/ui/fragment/StepFourNiveshFDFragment.kt @@ -98,20 +98,20 @@ class StepFourNiveshFDFragment : Fragment() { } private fun validated(): Boolean { - if (selectedList.isEmpty()) { + return if (selectedList.isEmpty()) { showDialogValidation( activity as NiveshFdMainActivity, getString(R.string.validTermsCondition) ) - return false + false } else if (!binding.checkBox.isChecked) { showDialogValidation( activity as NiveshFdMainActivity, resources.getString(R.string.validTermsConditions) ) - return false + false } else { - return true + true } } diff --git a/app/src/main/java/com/nivesh/production/niveshfd/ui/fragment/StepOneNiveshFDFragment.kt b/app/src/main/java/com/nivesh/production/niveshfd/ui/fragment/StepOneNiveshFDFragment.kt index 830326f..b88d492 100644 --- a/app/src/main/java/com/nivesh/production/niveshfd/ui/fragment/StepOneNiveshFDFragment.kt +++ b/app/src/main/java/com/nivesh/production/niveshfd/ui/fragment/StepOneNiveshFDFragment.kt @@ -109,10 +109,15 @@ class StepOneNiveshFDFragment : Fragment() { } // Maturity Options - rgMaturity.text = getString(R.string.additionalDetailOne) + rgMaturity.text = getString(R.string.totalDeduction) binding.radioGroup.setOnCheckedChangeListener { group, checkedId -> rgMaturity = group.findViewById(checkedId) Log.e("Maturity", "-->" + rgMaturity.text) + if (rgMaturity.text.contains("credit")){ + rgMaturity.text = getString(R.string.totalDeduction) + }else{ + rgMaturity.text = getString(R.string.principalDeduction) + } } // Next Button @@ -146,6 +151,7 @@ class StepOneNiveshFDFragment : Fragment() { (activity as NiveshFdMainActivity).fdInvestmentDetails.CKYCNumber = "" (activity as NiveshFdMainActivity).fdInvestmentDetails.UniqueId = (activity as NiveshFdMainActivity).uniqueId + (activity as NiveshFdMainActivity).fdInvestmentDetails.RenewOption = rgMaturity.text.toString() (activity as NiveshFdMainActivity).createFDApplicantRequest.FDInvestmentDetails = (activity as NiveshFdMainActivity).fdInvestmentDetails @@ -252,11 +258,9 @@ class StepOneNiveshFDFragment : Fragment() { when (code) { 200 -> { listOfMinAmount = getCodeResponse.Response.GetCodesList - if (listOfMinAmount.isNotEmpty()) { - binding.txtMinAmount.text = getString(R.string.minAmount).plus( - listOfMinAmount[0].Value - ) - } +// if (listOfMinAmount.isNotEmpty()) { +// binding.txtMinAmount.text = getString(R.string.minAmount).plus(listOfMinAmount[0].Value) +// } maxAmountApi() } 650 -> "" @@ -432,7 +436,13 @@ class StepOneNiveshFDFragment : Fragment() { binding.tlDepositAmount, getString(R.string.validMinAmount) ) - } else if (binding.edtAmount.text.toString() + } else if (binding.edtAmount.text.toString().toInt() % 1000 != 0) { + commonErrorMethod( + binding.edtAmount, + binding.tlDepositAmount, + getString(R.string.validMultipleAmount) + ) + }else if (binding.edtAmount.text.toString() .toDouble() > listOfMaxAmount[0].Value.toDouble() ) { commonErrorMethod( diff --git a/app/src/main/java/com/nivesh/production/niveshfd/ui/fragment/StepTwoNiveshFDFragment.kt b/app/src/main/java/com/nivesh/production/niveshfd/ui/fragment/StepTwoNiveshFDFragment.kt index c550aa4..b1df440 100644 --- a/app/src/main/java/com/nivesh/production/niveshfd/ui/fragment/StepTwoNiveshFDFragment.kt +++ b/app/src/main/java/com/nivesh/production/niveshfd/ui/fragment/StepTwoNiveshFDFragment.kt @@ -31,6 +31,7 @@ import com.nivesh.production.niveshfd.adapter.RecommendedBankListAdapter import com.nivesh.production.niveshfd.databinding.FragmentNiveshfdStepTwoBinding import com.nivesh.production.niveshfd.model.* import com.nivesh.production.niveshfd.ui.activity.NiveshFdMainActivity +import com.nivesh.production.niveshfd.util.Common import com.nivesh.production.niveshfd.util.Common.Companion.commonErrorAutoCompleteMethod import com.nivesh.production.niveshfd.util.Common.Companion.commonErrorMethod import com.nivesh.production.niveshfd.util.Common.Companion.commonSpinnerErrorMethod @@ -38,6 +39,7 @@ import com.nivesh.production.niveshfd.util.Common.Companion.getDate import com.nivesh.production.niveshfd.util.Common.Companion.isIndianMobileNo import com.nivesh.production.niveshfd.util.Common.Companion.isMinor import com.nivesh.production.niveshfd.util.Common.Companion.isValidEmail +import com.nivesh.production.niveshfd.util.Common.Companion.isValidIndividualPan import com.nivesh.production.niveshfd.util.Common.Companion.isValidName import com.nivesh.production.niveshfd.util.Common.Companion.isValidPan import com.nivesh.production.niveshfd.util.Common.Companion.removeError @@ -139,7 +141,7 @@ class StepTwoNiveshFDFragment : Fragment() { override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) { removeError(binding.tlPanNumber) if (s.toString().trim().length == 10) { - panCheckApi() + checkFDCKYCApi() } } }) @@ -563,10 +565,10 @@ class StepTwoNiveshFDFragment : Fragment() { } } binding.tvBankDetails.setOnClickListener { - if (binding.llBankDetails.visibility == View.VISIBLE) { - binding.llBankDetails.visibility = View.GONE + if (binding.llBank.visibility == View.VISIBLE) { + binding.llBank.visibility = View.GONE } else { - binding.llBankDetails.visibility = View.VISIBLE + binding.llBank.visibility = View.VISIBLE } } @@ -715,6 +717,55 @@ class StepTwoNiveshFDFragment : Fragment() { } + private fun checkFDCKYCApi() { + if ((activity as NiveshFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CM_MOBILE?.isNotEmpty()!! && (activity as NiveshFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_DOB?.isNotEmpty()!! && binding.edtPANNumber.text.toString().isNotEmpty() && (activity as NiveshFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_CODE?.isNotEmpty()!!) { + val checkFDKYCRequest = CheckFDKYCRequest() + checkFDKYCRequest.Mobile = binding.edtMobileNumber.text.toString() + checkFDKYCRequest.DOB = binding.edtDOB.text.toString() + checkFDKYCRequest.PAN = binding.edtPANNumber.text.toString() + checkFDKYCRequest.NiveshClientCode = (activity as NiveshFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_CODE.toString() + (activity as NiveshFdMainActivity).viewModel.checkFDKYC(checkFDKYCRequest, token, activity as NiveshFdMainActivity) + (activity as NiveshFdMainActivity).viewModel.getFDKYCMutableData.observe(this) { response -> + when (response) { + is Resource.Success -> { + Log.e("response", "-->${response.data.toString()}") + val getCodeResponse: GetCodeResponse = + Gson().fromJson( + response.data?.toString(), + GetCodeResponse::class.java + ) + getCodeResponse.Response.StatusCode.let { code -> + when (code) { + 200 -> { + // fdInvestmentDetails.CustomerType = "" + } + 650 -> "" + else -> { + showDialogValidation( + activity as NiveshFdMainActivity, + getCodeResponse.Response.Errors[0].ErrorMessage + ) + } + } + } + } + + is Resource.Error -> { + response.message?.let { message -> + showDialogValidation(activity as NiveshFdMainActivity, message) + } + } + is Resource.Loading -> { + + } + is Resource.DataError -> { + + } + } + } + } + } + private fun createFDApi(data: CreateFDRequest) { ProgressUtil.showLoading(activity as NiveshFdMainActivity) (activity as NiveshFdMainActivity).viewModel.createFDApi(data, token, activity as NiveshFdMainActivity) @@ -1046,67 +1097,6 @@ class StepTwoNiveshFDFragment : Fragment() { } - private fun panCheckApi() { - val panCheck = PanCheckRequest() - panCheck.clientCode = - (activity as NiveshFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_CODE - panCheck.subBrokerCode = - (activity as NiveshFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.sub_broker_code - panCheck.panNumber = binding.edtPANNumber.text.toString() - panCheck.mobileNumber = "" - (activity as NiveshFdMainActivity).viewModel.panCheck(panCheck, token, activity as NiveshFdMainActivity) - (activity as NiveshFdMainActivity).viewModel.getPanCheckMutableData.observe(viewLifecycleOwner) { response -> - when (response) { - is Resource.Success -> { - Log.e("panCheckApi ", " response -->$response") - val panCheckResponse = - Gson().fromJson( - response.data?.toString(), - PanCheckResponse::class.java - ) - panCheckResponse.response.status_code.let { code -> - if (binding.tvPANVerify.visibility == View.GONE) { - binding.tvPANVerify.visibility = View.VISIBLE - } - when (code) { - 200 -> { - binding.tvPANVerify.text = getString(R.string.verifiedText) - binding.tvPANVerify.setTextColor( - ContextCompat.getColor( - activity as NiveshFdMainActivity, - R.color.green - ) - ) - } - // 650 -> refreshToken() - else -> { - binding.tvPANVerify.text = getString(R.string.notVerifiedText) - binding.tvPANVerify.setTextColor( - ContextCompat.getColor( - activity as NiveshFdMainActivity, - R.color.red - ) - ) - } - } - } - } - - is Resource.Error -> { - response.message?.let { message -> - showDialogValidation(activity as NiveshFdMainActivity, message) - } - } - is Resource.Loading -> { - - } - is Resource.DataError -> { - - } - } - } - } - private fun titleApi() { val getCodeRequest = GetCodeRequest() getCodeRequest.ProductName = getString(R.string.bajajFD) @@ -1498,10 +1488,22 @@ class StepTwoNiveshFDFragment : Fragment() { listOfOccupation ) binding.spOccupation.setAdapter(adapter) - binding.spOccupation.setText( - adapter.getItem(0)?.Label, - false - ) + + val occupationCode = (activity as NiveshFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_OCCUPATION_CODE + if (occupationCode.isNullOrEmpty()) { + + binding.spOccupation.setText( + adapter.getItem(0)?.Label, + false + ) + }else{ + for (title in listOfOccupation) { + if (title.Value == occupationCode) { + binding.spOccupation.setText(title.Label, false) + break + } + } + } } } // 650 -> refreshToken() @@ -1834,7 +1836,10 @@ class StepTwoNiveshFDFragment : Fragment() { ) } else if (binding.edtDOB.text.toString().isEmpty()) { // EditText commonErrorMethod(binding.edtDOB, binding.tlDOB, getString(R.string.emptyDOB)) - } else if (binding.edtPANNumber.text.toString().isEmpty()) { // EditText + }else if (isMinor(binding.edtDOB.text.toString())) { // EditText + commonErrorMethod(binding.edtDOB, binding.tlDOB, getString(R.string.minorApplicant)) + } + else if (binding.edtPANNumber.text.toString().isEmpty()) { // EditText commonErrorMethod( binding.edtPANNumber, binding.tlPanNumber, @@ -1846,6 +1851,12 @@ class StepTwoNiveshFDFragment : Fragment() { binding.tlPanNumber, getString(R.string.invalidPAN) ) + } else if (!isValidIndividualPan(binding.edtPANNumber.text.toString())) { // EditText + commonErrorMethod( + binding.edtPANNumber, + binding.tlPanNumber, + getString(R.string.invalidIndividualPAN) + ) } else if (binding.spTitle.text.isEmpty()) { // Spinner commonSpinnerErrorMethod( binding.spTitle, diff --git a/app/src/main/java/com/nivesh/production/niveshfd/util/Common.kt b/app/src/main/java/com/nivesh/production/niveshfd/util/Common.kt index 4754f9e..f1ca97b 100644 --- a/app/src/main/java/com/nivesh/production/niveshfd/util/Common.kt +++ b/app/src/main/java/com/nivesh/production/niveshfd/util/Common.kt @@ -1,9 +1,12 @@ package com.nivesh.production.niveshfd.util +import android.Manifest +import android.annotation.SuppressLint import android.app.Activity import android.app.AlertDialog import android.content.Context import android.content.Intent +import android.content.pm.PackageManager import android.graphics.Color import android.graphics.drawable.GradientDrawable import android.net.ConnectivityManager @@ -11,14 +14,18 @@ import android.net.NetworkCapabilities import android.net.Uri import android.os.Build import android.provider.Settings +import android.telephony.TelephonyManager +import android.text.TextUtils import android.text.format.DateFormat import android.util.Log import android.util.Patterns +import androidx.core.app.ActivityCompat import com.google.android.material.textfield.MaterialAutoCompleteTextView import com.google.android.material.textfield.TextInputEditText import com.google.android.material.textfield.TextInputLayout import com.google.gson.JsonObject import com.nivesh.production.niveshfd.R +import com.nivesh.production.niveshfd.model.DeviceInfo import com.nivesh.production.niveshfd.ui.activity.NiveshFdMainActivity import kotlinx.coroutines.CoroutineExceptionHandler import org.json.JSONObject @@ -90,6 +97,12 @@ class Common { return mMatcher.matches() } + fun isValidIndividualPan(pan: String?): Boolean { + val mPattern = Pattern.compile("[A-Z]{3}[P][A-Z][0-9]{4}[A-Z]") + val mMatcher = mPattern.matcher(pan.toString()) + return mMatcher.matches() + } + //is Indian mobile Number fun isIndianMobileNo(mobileNumber: String?): Boolean { //(0/91): number starts with (0/91) @@ -131,7 +144,11 @@ class Common { builder.setPositiveButton(activity.getString(R.string.Ok)) { dialogInterface, _ -> val intent = Intent( Settings.ACTION_APPLICATION_DETAILS_SETTINGS, - Uri.fromParts("package", (activity as NiveshFdMainActivity).packageName, null) + Uri.fromParts( + "package", + (activity as NiveshFdMainActivity).packageName, + null + ) ) intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) activity.startActivity(intent) @@ -208,20 +225,20 @@ class Common { return Resource.Error(response.message()) } - fun handleResponse1(response: Response): Resource { - if (response.isSuccessful && response.body() != null) { - return if (response.body().toString().isNotEmpty()) { - Log.e("response", "-->$response") - val str: String = response.body().toString().replace("\r\n", "") - Log.e("str", "-->$str") - val jsonObject = JSONObject(str) - Log.e("jsonObject", "-->$jsonObject") - Resource.Success(jsonObject.toString()) - }else { - Resource.Error(response.message()) - } - } - return Resource.Error(response.message()) + fun handleResponse1(response: Response): Resource { + if (response.isSuccessful && response.body() != null) { + return if (response.body().toString().isNotEmpty()) { + Log.e("response", "-->$response") + val str: String = response.body().toString().replace("\r\n", "") + Log.e("str", "-->$str") + val jsonObject = JSONObject(str) + Log.e("jsonObject", "-->$jsonObject") + Resource.Success(jsonObject.toString()) + } else { + Resource.Error(response.message()) + } + } + return Resource.Error(response.message()) } @@ -255,12 +272,11 @@ class Common { } /* this function is used for file size in readable format(End)*/ - fun getFileSizeInMB(length: Long): Double { - // Get length of file in bytes - val fileSizeInBytes = length.toDouble() - // Convert the bytes to Kilobytes (1 KB = 1024 Bytes) - val fileSizeInKB = fileSizeInBytes / 1024 - // Convert the KB to MegaBytes (1 MB = 1024 KBytes) + fun getFileSizeInMB(length: Long): Double { // Get length of file in bytes + val fileSizeInBytes = + length.toDouble() // Convert the bytes to Kilobytes (1 KB = 1024 Bytes) + val fileSizeInKB = + fileSizeInBytes / 1024 // Convert the KB to MegaBytes (1 MB = 1024 KBytes) return fileSizeInKB / 1024 } @@ -274,6 +290,87 @@ class Common { } + @SuppressLint("HardwareIds") + fun getDeviceInfo(mContext: Context): DeviceInfo { + val deviceInfo = DeviceInfo() + var deviceId: String? = "" + try { + val telephonyManager = + mContext.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager + deviceInfo.device_model = if (TextUtils.isEmpty(Build.DEVICE)) "" else Build.DEVICE + deviceInfo.device_os_version = + if (TextUtils.isEmpty(Build.VERSION.RELEASE)) "" else Build.VERSION.RELEASE + deviceInfo.device_name = if (TextUtils.isEmpty(Build.PRODUCT)) "" else Build.PRODUCT + deviceInfo.device_type = "Android" + + if ((deviceId == null) || deviceId.isEmpty() || deviceId.equals( + "unknown", + ignoreCase = true + ) + ) { + deviceId = if (TextUtils.isEmpty( + Settings.Secure.getString( + mContext.contentResolver, + Settings.Secure.ANDROID_ID + ) + ) + ) "" else Settings.Secure.getString( + mContext.contentResolver, + Settings.Secure.ANDROID_ID + ) + } + // deviceInfo.device_id = device_id + "#" + preferenceHelper.getAppName() + deviceInfo.device_id_for_UMSId = deviceId + // deviceInfo.sdk_version = com.nivesh.production.BuildConfig.VERSION_NAME + + if (ActivityCompat.checkSelfPermission( + mContext, + Manifest.permission.READ_PHONE_STATE + ) != PackageManager.PERMISSION_GRANTED + ) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + deviceId = telephonyManager.imei + if (deviceId == null) { + deviceId = + if (TextUtils.isEmpty(Build.getSerial())) "" else Build.getSerial() + } + } else { + deviceId = telephonyManager.deviceId + if (deviceId == null) { + deviceId = + if (TextUtils.isEmpty(Build.SERIAL)) "" else Build.SERIAL + } + } + } else { + deviceId = telephonyManager.deviceId + if (deviceId == null) { + deviceId = if (TextUtils.isEmpty(Build.SERIAL)) "" else Build.SERIAL + } + } + + } catch (e: Exception) { + e.printStackTrace() + if ((deviceId == null) || deviceId.isEmpty() || deviceId.equals( + "unknown", + ignoreCase = true + ) + ) { + deviceId = if (TextUtils.isEmpty( + Settings.Secure.getString( + mContext.contentResolver, + Settings.Secure.ANDROID_ID + ) + ) + ) "" else Settings.Secure.getString( + mContext.contentResolver, + Settings.Secure.ANDROID_ID + ) + } + // deviceInfo.deviceId = device_id + "#" + preferenceHelper.getAppName() + deviceInfo.device_id_for_UMSId = deviceId + } + return deviceInfo + } } } \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/niveshfd/viewModel/BajajFDViewModel.kt b/app/src/main/java/com/nivesh/production/niveshfd/viewModel/BajajFDViewModel.kt index bac1c46..22efdcc 100644 --- a/app/src/main/java/com/nivesh/production/niveshfd/viewModel/BajajFDViewModel.kt +++ b/app/src/main/java/com/nivesh/production/niveshfd/viewModel/BajajFDViewModel.kt @@ -41,14 +41,7 @@ open class BajajFDViewModel(private val mainRepository: MainRepository) : ViewMo } } - val getFDKYCMutableData: MutableLiveData> = MutableLiveData() - fun checkFDKYC(requestBody: CheckFDKYCRequest, token : String, activity: Activity) = viewModelScope.launch(handleError(activity)) { - if (Common.isNetworkAvailable(activity)) { - getFDKYCMutableData.postValue(Resource.Loading()) - val response = mainRepository.checkFDKYCRequest(requestBody, token) - getFDKYCMutableData.postValue(handleResponse(response)) - } - } + val getPaymentReQueryMutableData: MutableLiveData> = MutableLiveData() fun getPaymentReQuery(requestBody: PaymentReQueryRequest, token : String, activity: Activity) = viewModelScope.launch(handleError(activity)) { @@ -125,14 +118,12 @@ open class BajajFDViewModel(private val mainRepository: MainRepository) : ViewMo // Step 2 - val getPanCheckMutableData: MutableLiveData> = MutableLiveData() - fun panCheck(panCheck: PanCheckRequest, token: String, activity : Activity) = viewModelScope.launch( - handleError(activity) - ) { + val getFDKYCMutableData: MutableLiveData> = MutableLiveData() + fun checkFDKYC(requestBody: CheckFDKYCRequest, token : String, activity: Activity) = viewModelScope.launch(handleError(activity)) { if (Common.isNetworkAvailable(activity)) { - getPanCheckMutableData.postValue(Resource.Loading()) - val response = mainRepository.panCheck(panCheck, token) - getPanCheckMutableData.postValue(handleResponse(response)) + getFDKYCMutableData.postValue(Resource.Loading()) + val response = mainRepository.checkFDKYCRequest(requestBody, token) + getFDKYCMutableData.postValue(handleResponse(response)) } } diff --git a/app/src/main/res/layout/fragment_niveshfd_step_four.xml b/app/src/main/res/layout/fragment_niveshfd_step_four.xml index 50dc3fe..3c5a6d5 100644 --- a/app/src/main/res/layout/fragment_niveshfd_step_four.xml +++ b/app/src/main/res/layout/fragment_niveshfd_step_four.xml @@ -221,11 +221,7 @@ android:id="@+id/rvTerms" android:layout_width="match_parent" android:layout_height="match_parent" - tools:listitem="@layout/item_customer_list_preview" - - - /> - + tools:listitem="@layout/item_customer_list_preview" /> @@ -186,7 +188,7 @@ - - - - - + + + android:orientation="horizontal" /> - - + + + Min. 12 months, Max. 60 months MINAmount MAXAmount + Total + Principal Please enter amount Please enter amount first Entered amount should be greater than minimum amount - Entered amount should be less than 5 Cr. + Entered amount should be up to 5 Cr only + Entered Amount should be multiples of 1000 Please select Interest Payout Please select Investment Tenure @@ -137,9 +140,12 @@ Mobile number should have at least 10 digits Mobile number should start with 6,7,8 and 9 Please select date of birth + Primary Applicant should not be minor Please enter PAN number - Invalid PAN + Please enter valid PAN number + PAN Applicants should be individual + Account Verified @@ -209,6 +215,10 @@ Add Photo! Cancel Aadhar + You Need to Give Permission of Camera for uploading Image + You Need to Give Permission of Gallery for uploading Image + Permission Required ! + Permission\'s Required ! Make Payment @@ -231,6 +241,7 @@ Your transaction is unsuccessful. Sorry for the inconvenience please try again later Retry + @@ -246,11 +257,8 @@ Add New Account OK - You Need to Give Permission of Camera for uploading Image - You Need to Give Permission of Gallery for uploading Image - Permission Required ! - Permission\'s Required ! - + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e7a92ae..266b256 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -18,7 +18,7 @@ Select Investment Tenure Up to 0.25% p.a for Up to 0.25% p.a for Senior Citizens, 60+ - Maturity Instructions: + Maturity Instructions Automatically credit to my bank account Automatically renew principal amount Automatically renew both principal and interest amount @@ -44,13 +44,16 @@ Min. 12 months, Max. 60 months MINAmount MAXAmount + Total + Principal Please enter amount Please enter amount first Entered amount should be greater than minimum amount - Entered amount should be less than 5 Cr. + Entered amount should be up to 5 Cr only + Entered Amount should be multiples of 1000 Please select Interest Payout Please select Investment Tenure @@ -137,9 +140,12 @@ Mobile number should have at least 10 digits Mobile number should start with 6,7,8 and 9 Please select date of birth + Primary Applicant should not be minor Please enter PAN number - Invalid PAN + Please enter valid PAN number + PAN Applicants should be individual + Account Verified @@ -209,6 +215,10 @@ Add Photo! Cancel Aadhar + You Need to Give Permission of Camera for uploading Image + You Need to Give Permission of Gallery for uploading Image + Permission Required ! + Permission\'s Required ! Make Payment @@ -231,6 +241,7 @@ Your transaction is unsuccessful. Sorry for the inconvenience please try again later Retry + @@ -246,11 +257,8 @@ Add New Account OK - You Need to Give Permission of Camera for uploading Image - You Need to Give Permission of Gallery for uploading Image - Permission Required ! - Permission\'s Required ! - + + \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index cfa2984..a11320e 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -16,10 +16,10 @@