diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 42482cc..5c6d61c 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -4,6 +4,7 @@
+
diff --git a/app/src/main/java/com/nivesh/production/niveshfd/db/PreferenceManager.kt b/app/src/main/java/com/nivesh/production/niveshfd/db/PreferenceManager.kt
new file mode 100644
index 0000000..c2a7fea
--- /dev/null
+++ b/app/src/main/java/com/nivesh/production/niveshfd/db/PreferenceManager.kt
@@ -0,0 +1,137 @@
+package com.nivesh.production.niveshfd.db
+
+import android.content.Context
+import android.content.SharedPreferences
+import com.nivesh.production.niveshfd.interfaces.IPreferenceHelper
+
+open class PreferenceManager(context: Context) : IPreferenceHelper {
+ private val preferenceName = "NiveshFDSDK"
+ private var preferences: SharedPreferences = context.getSharedPreferences(preferenceName, Context.MODE_PRIVATE)
+
+ companion object {
+ const val KEY_USER_UID = "UserUid"
+ const val KEY_LOGIN_ROLE = "LoginRole"
+ const val KEY_SUB_BROKER_CODE = "SubBrokerCode"
+ const val KEY_LOGIN_PASSWORD = "LOGIN_PASSWORD"
+ const val KEY_CLIENT_UMS_ID = "UMS_Id"
+ const val KEY_CLIENT_CODE = "ClientCode"
+ const val KEY_GET_TOKEN = "GetToken"
+ const val CLIENT_LANGUAGE = "LANGUAGE"
+ }
+
+
+ override fun getLoginPasswordHash(): String {
+ return preferences[KEY_LOGIN_PASSWORD] ?: ""
+ }
+
+ override fun setLoginPasswordHash(appName: String) {
+ preferences[KEY_LOGIN_PASSWORD] = appName
+ }
+
+ override fun setUserUid(appName: Int) {
+ preferences[KEY_USER_UID] = appName
+ }
+
+ override fun getUserUid(): Int {
+ return preferences[KEY_USER_UID] ?: -1
+ }
+
+ override fun setLoginRole(appName: Int) {
+ preferences[KEY_LOGIN_ROLE] = appName
+ }
+
+ override fun getLoginRole(): Int {
+ return preferences[KEY_LOGIN_ROLE] ?: -1
+ }
+
+
+ override fun setSubBrokerID(appName: String) {
+ preferences[KEY_SUB_BROKER_CODE] = appName
+ }
+
+ override fun getSubBrokerID(): String {
+ return preferences[KEY_SUB_BROKER_CODE] ?: ""
+ }
+
+ override fun setClientUmsID(appName: String) {
+ preferences[KEY_CLIENT_UMS_ID] = appName
+ }
+
+ override fun getClientUmsID(): String {
+ return preferences[KEY_CLIENT_UMS_ID] ?: ""
+ }
+
+ override fun setClientCode(appName: String) {
+ preferences[KEY_CLIENT_CODE] = appName
+ }
+
+ override fun getClientCode(): String {
+ return preferences[KEY_CLIENT_CODE] ?: ""
+ }
+
+ override fun setToken(appName: String) {
+ preferences[KEY_GET_TOKEN] = appName
+ }
+
+ override fun getToken(): String {
+ return preferences[KEY_GET_TOKEN] ?: ""
+ }
+
+ override fun setLanguage(appName: String) {
+ preferences[CLIENT_LANGUAGE] = appName
+ }
+
+ override fun getLanguage(): String {
+ return preferences[CLIENT_LANGUAGE] ?: ""
+ }
+
+
+ override fun clearPrefs() {
+ preferences.edit().clear().apply()
+ }
+
+}
+
+
+/**
+ * SharedPreferences extension function, to listen the edit() and apply() fun calls
+ * on every SharedPreferences operation.
+ */
+private inline fun SharedPreferences.edit(operation: (SharedPreferences.Editor) -> 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 746215f..3722774 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,6 +21,7 @@ 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.*
@@ -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()
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 806f91a..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,6 +55,8 @@ class StepFiveNiveshFDFragment : Fragment() {
)
binding.tvSuccessMessage.text = arrOfStr[1]
}
+ finalizeFDApi()
+ finalizeKYCApi()
}else{
if (paymentReQueryResponse.Response.Message.isNotEmpty()) {
if (paymentReQueryResponse.Response.Message.isNotEmpty()) {
@@ -71,8 +73,7 @@ class StepFiveNiveshFDFragment : Fragment() {
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/StepOneNiveshFDFragment.kt b/app/src/main/java/com/nivesh/production/niveshfd/ui/fragment/StepOneNiveshFDFragment.kt
index 830326f..a897699 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 = "Total"
binding.radioGroup.setOnCheckedChangeListener { group, checkedId ->
rgMaturity = group.findViewById(checkedId)
Log.e("Maturity", "-->" + rgMaturity.text)
+ if (rgMaturity.text.contains("credit")){
+ rgMaturity.text = "Total"
+ }else{
+ rgMaturity.text = "Principal"
+ }
}
// 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
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 d240bb0..d7e418d 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
@@ -140,7 +140,6 @@ 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()
}
}
@@ -1097,67 +1096,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)
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..4ff6efa 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,20 @@ 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.db.PreferenceManager
+import com.nivesh.production.niveshfd.interfaces.IPreferenceHelper
+import com.nivesh.production.niveshfd.model.DeviceInfo
import com.nivesh.production.niveshfd.ui.activity.NiveshFdMainActivity
import kotlinx.coroutines.CoroutineExceptionHandler
import org.json.JSONObject
@@ -274,6 +283,83 @@ class Common {
}
+ @SuppressLint("HardwareIds")
+ fun getDeviceInfo(mContext: Context): DeviceInfo {
+ val preferenceHelper: IPreferenceHelper = PreferenceManager(mContext)
+ val deviceInfo = DeviceInfo()
+ var device_id: 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 (device_id == null || device_id.isEmpty() || device_id.equals(
+ "unknown",
+ ignoreCase = true
+ )
+ ) {
+ device_id = 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 = device_id
+ // 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) {
+ device_id = telephonyManager.imei
+ if (device_id == null) {
+ device_id =
+ if (TextUtils.isEmpty(Build.getSerial())) "" else Build.getSerial()
+ }
+ } else {
+ device_id = telephonyManager.deviceId
+ if (device_id == null) {
+ device_id =
+ if (TextUtils.isEmpty(Build.SERIAL)) "" else Build.SERIAL
+ }
+ }
+ } else {
+ device_id = telephonyManager.deviceId
+ if (device_id == null) {
+ device_id = if (TextUtils.isEmpty(Build.SERIAL)) "" else Build.SERIAL
+ }
+ }
+
+ } catch (e: Exception) {
+ e.printStackTrace()
+ if (device_id == null || device_id.isEmpty() || device_id.equals(
+ "unknown",
+ ignoreCase = true
+ )
+ ) {
+ device_id = 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 = device_id
+ }
+ 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 94d9eb1..669abd9 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
@@ -40,14 +40,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)) {
@@ -124,14 +117,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_one.xml b/app/src/main/res/layout/fragment_niveshfd_step_one.xml
index bb16ab1..09f13d0 100644
--- a/app/src/main/res/layout/fragment_niveshfd_step_one.xml
+++ b/app/src/main/res/layout/fragment_niveshfd_step_one.xml
@@ -222,15 +222,6 @@
android:text="@string/additionalDetailTwo"
android:textSize="@dimen/text_size_12" />
-
-
-