From cfbfd52594e4e689165bacc65220972f23c537f8 Mon Sep 17 00:00:00 2001 From: Hemant Khadase Date: Tue, 10 Jan 2023 20:05:01 +0530 Subject: [PATCH] added code --- app/src/main/AndroidManifest.xml | 1 + .../ui/activity/NiveshFdMainActivity.kt | 28 ++++-- .../ui/fragment/StepOneNiveshFDFragment.kt | 6 +- .../nivesh/production/niveshfd/util/Common.kt | 95 ++++++++++--------- app/src/main/res/values-hi-rIN/strings.xml | 14 ++- app/src/main/res/values/strings.xml | 14 ++- 6 files changed, 91 insertions(+), 67 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 5c6d61c..cda90aa 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -10,6 +10,7 @@ + var dialogWebView: Dialog? = null var loginRole: Int = 0 + var stepCount: Int = 0 + var uniqueId: String = "" override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -81,7 +81,7 @@ class NiveshFdMainActivity : BaseActivity() { } // For Set Data - PreferenceManager( this@NiveshFdMainActivity).setSubBrokerID("") + PreferenceManager(this@NiveshFdMainActivity).setSubBrokerID("") // For Get Data PreferenceManager(context = this@NiveshFdMainActivity).getSubBrokerID() @@ -140,7 +140,10 @@ class NiveshFdMainActivity : BaseActivity() { is Resource.DataError -> { } - else -> {} + else -> { + showDialogValidation(this@NiveshFdMainActivity, response.message) + } + } } } @@ -187,9 +190,12 @@ class NiveshFdMainActivity : BaseActivity() { 200 -> { setViewPager(stepsCount) } - 650 -> "" + 650 -> "" else -> { - showDialogValidation(this@NiveshFdMainActivity, response.message) + showDialogValidation( + this@NiveshFdMainActivity, + response.message + ) } } } @@ -206,7 +212,9 @@ class NiveshFdMainActivity : BaseActivity() { is Resource.DataError -> { } - else -> {} + else -> { + showDialogValidation(this@NiveshFdMainActivity, response.message) + } } } } @@ -432,7 +440,9 @@ class NiveshFdMainActivity : BaseActivity() { is Resource.DataError -> { } - else -> {} + else -> { + showDialogValidation(this@NiveshFdMainActivity, response.message) + } } } } 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 a897699..712c92f 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,14 +109,14 @@ class StepOneNiveshFDFragment : Fragment() { } // Maturity Options - rgMaturity.text = "Total" + 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 = "Total" + rgMaturity.text = getString(R.string.totalDeduction) }else{ - rgMaturity.text = "Principal" + rgMaturity.text = getString(R.string.principalDeduction) } } 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 4ff6efa..f575ad7 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 @@ -25,8 +25,6 @@ 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 @@ -140,7 +138,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) @@ -217,20 +219,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()) } @@ -264,12 +266,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 } @@ -285,32 +286,36 @@ class Common { @SuppressLint("HardwareIds") fun getDeviceInfo(mContext: Context): DeviceInfo { - val preferenceHelper: IPreferenceHelper = PreferenceManager(mContext) val deviceInfo = DeviceInfo() - var device_id: String? = "" + 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_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( + if ((deviceId == null) || deviceId.isEmpty() || deviceId.equals( "unknown", ignoreCase = true ) ) { - device_id = if (TextUtils.isEmpty(Settings.Secure.getString(mContext.contentResolver, Settings.Secure.ANDROID_ID)) + 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 = device_id - // deviceInfo.sdk_version = com.nivesh.production.BuildConfig.VERSION_NAME - + // 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, @@ -318,33 +323,33 @@ class Common { ) != PackageManager.PERMISSION_GRANTED ) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - device_id = telephonyManager.imei - if (device_id == null) { - device_id = + deviceId = telephonyManager.imei + if (deviceId == null) { + deviceId = if (TextUtils.isEmpty(Build.getSerial())) "" else Build.getSerial() } } else { - device_id = telephonyManager.deviceId - if (device_id == null) { - device_id = + deviceId = telephonyManager.deviceId + if (deviceId == null) { + deviceId = 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 + deviceId = telephonyManager.deviceId + if (deviceId == null) { + deviceId = if (TextUtils.isEmpty(Build.SERIAL)) "" else Build.SERIAL } } } catch (e: Exception) { e.printStackTrace() - if (device_id == null || device_id.isEmpty() || device_id.equals( + if ((deviceId == null) || deviceId.isEmpty() || deviceId.equals( "unknown", ignoreCase = true ) ) { - device_id = if (TextUtils.isEmpty( + deviceId = if (TextUtils.isEmpty( Settings.Secure.getString( mContext.contentResolver, Settings.Secure.ANDROID_ID @@ -355,8 +360,8 @@ class Common { Settings.Secure.ANDROID_ID ) } - // deviceInfo.deviceId = device_id + "#" + preferenceHelper.getAppName() - deviceInfo.device_id_for_UMSId = device_id + // deviceInfo.deviceId = device_id + "#" + preferenceHelper.getAppName() + deviceInfo.device_id_for_UMSId = deviceId } return deviceInfo } diff --git a/app/src/main/res/values-hi-rIN/strings.xml b/app/src/main/res/values-hi-rIN/strings.xml index 02fa1f2..b4507f2 100644 --- a/app/src/main/res/values-hi-rIN/strings.xml +++ b/app/src/main/res/values-hi-rIN/strings.xml @@ -44,6 +44,8 @@ Min. 12 months, Max. 60 months MINAmount MAXAmount + Total + Principal Please enter amount @@ -209,6 +211,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 +237,7 @@ Your transaction is unsuccessful. Sorry for the inconvenience please try again later Retry + @@ -246,11 +253,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/strings.xml b/app/src/main/res/values/strings.xml index 02fa1f2..b4507f2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -44,6 +44,8 @@ Min. 12 months, Max. 60 months MINAmount MAXAmount + Total + Principal Please enter amount @@ -209,6 +211,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 +237,7 @@ Your transaction is unsuccessful. Sorry for the inconvenience please try again later Retry + @@ -246,11 +253,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