|
|
@ -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<String>): Resource<String> { |
|
|
|
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<String>): Resource<String> { |
|
|
|
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 |
|
|
|
} |
|
|
|