Compare commits
1 Commits
dev-server
...
API-CALLS-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf2e904445 |
@@ -19,8 +19,8 @@ android {
|
|||||||
applicationId "in.sminnovations.hpostesting.quality"
|
applicationId "in.sminnovations.hpostesting.quality"
|
||||||
minSdk 21
|
minSdk 21
|
||||||
targetSdk 34
|
targetSdk 34
|
||||||
versionCode 99
|
versionCode 100
|
||||||
versionName "2.1.99"
|
versionName "2.1.100"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -253,7 +253,11 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
|||||||
//I'm doing mScannerInfoList.get(0) because there's only one scanner which will be at position 0.
|
//I'm doing mScannerInfoList.get(0) because there's only one scanner which will be at position 0.
|
||||||
|
|
||||||
//I'm doing mScannerInfoList.get(0) because there's only one scanner which will be at position 0.
|
//I'm doing mScannerInfoList.get(0) because there's only one scanner which will be at position 0.
|
||||||
|
if (mScannerInfoList.isNotEmpty()) {
|
||||||
sdkHandler!!.dcssdkEstablishCommunicationSession(mScannerInfoList[0].scannerID)
|
sdkHandler!!.dcssdkEstablishCommunicationSession(mScannerInfoList[0].scannerID)
|
||||||
|
} else {
|
||||||
|
Toast.makeText(this, "No scanner is Available", Toast.LENGTH_LONG).show()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun pullTrigger() {
|
fun pullTrigger() {
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ class NatsManager(datacollector: DashboardActivity) {
|
|||||||
fun connect() {
|
fun connect() {
|
||||||
Log.d(TAG, "TRY TO CONNECT")
|
Log.d(TAG, "TRY TO CONNECT")
|
||||||
Thread {
|
Thread {
|
||||||
|
|
||||||
val seedString = "SUAEB5PUWNS6C2HUV3MFI6HUDEAPGPFPBHMI73NHIQATCDD2BWALVEZXZ4"
|
val seedString = "SUAEB5PUWNS6C2HUV3MFI6HUDEAPGPFPBHMI73NHIQATCDD2BWALVEZXZ4"
|
||||||
val seedBytes = seedString.toCharArray()
|
val seedBytes = seedString.toCharArray()
|
||||||
|
|
||||||
|
|||||||
@@ -118,6 +118,8 @@ class HomeFragment : Fragment() {
|
|||||||
loadUserData()
|
loadUserData()
|
||||||
setSearch()
|
setSearch()
|
||||||
checkForLocalDBData()
|
checkForLocalDBData()
|
||||||
|
// This function could be called directly where you need to perform the login operation.
|
||||||
|
forceLogin()
|
||||||
checkForTokenAndUpdate()
|
checkForTokenAndUpdate()
|
||||||
} else {
|
} else {
|
||||||
binding.internetAvailableCL.visibility = View.GONE
|
binding.internetAvailableCL.visibility = View.GONE
|
||||||
@@ -188,11 +190,30 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private fun forceLogin() {
|
||||||
|
val password = sharedPreference.getString(Constants.DEVICE_PASSWORD_API, "").toString()
|
||||||
|
val userID = sharedPreference.getString(Constants.DEVICE_ID_API, "").toString()
|
||||||
|
if (userID.isNotEmpty() && password.isNotEmpty() ) {
|
||||||
|
// Directly call the login API without checking the access token
|
||||||
|
hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
||||||
|
} else {
|
||||||
|
Toast.makeText(
|
||||||
|
requireContext(),
|
||||||
|
"Contact Help and get your device provision done",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private fun checkForTokenAndUpdate() {
|
private fun checkForTokenAndUpdate() {
|
||||||
val accessToken = sharedPreference.getString(Constants.ACCESS_TOKEN, "").toString()
|
val accessToken = sharedPreference.getString(Constants.ACCESS_TOKEN, "").toString()
|
||||||
val password = sharedPreference.getString(Constants.DEVICE_PASSWORD_API, "").toString()
|
val password = sharedPreference.getString(Constants.DEVICE_PASSWORD_API, "").toString()
|
||||||
val userID = sharedPreference.getString(Constants.DEVICE_ID_API, "").toString()
|
val userID = sharedPreference.getString(Constants.DEVICE_ID_API, "").toString()
|
||||||
if (userID.isNotEmpty() && password.isNotEmpty()) {
|
|
||||||
if (accessToken.isEmpty()) {
|
if (accessToken.isEmpty()) {
|
||||||
hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
||||||
} else {
|
} else {
|
||||||
@@ -205,13 +226,6 @@ class HomeFragment : Fragment() {
|
|||||||
hemoCubeViewModel.startPeriodicCheckUpdate()
|
hemoCubeViewModel.startPeriodicCheckUpdate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
Toast.makeText(
|
|
||||||
requireContext(),
|
|
||||||
"Contact Help and get your device provision done",
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
}
|
|
||||||
hemoCubeViewModel.loginResponse.observe(viewLifecycleOwner) { response ->
|
hemoCubeViewModel.loginResponse.observe(viewLifecycleOwner) { response ->
|
||||||
when (response) {
|
when (response) {
|
||||||
is Result.Success -> {
|
is Result.Success -> {
|
||||||
|
|||||||
@@ -146,14 +146,40 @@ class DeviceProvisionFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// private fun handleUsbData() {
|
||||||
|
// when {
|
||||||
|
// resultData.contains("SNE") -> {
|
||||||
|
// val pattern = Regex("HPP1-\\d{4}")
|
||||||
|
// val matchResult = pattern.find(resultData)
|
||||||
|
// val hardwareId = matchResult?.value
|
||||||
|
//
|
||||||
|
// if (hardwareId.toString().length == 9) {
|
||||||
|
// with(sharedPreferences.edit()) {
|
||||||
|
// putString(Constants.DEVICE_ID, hardwareId)
|
||||||
|
// apply()
|
||||||
|
// }
|
||||||
|
// activity?.runOnUiThread {
|
||||||
|
// binding.btnSubmit.visibility = View.VISIBLE
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
private fun handleUsbData() {
|
private fun handleUsbData() {
|
||||||
when {
|
when {
|
||||||
resultData.contains("SNE") -> {
|
resultData.contains("SNE") -> {
|
||||||
val pattern = Regex("HPP1-\\d{4}")
|
// Updated pattern to match all specified formats
|
||||||
|
val pattern = Regex("HPP1-\\d{4}|HPP1-\\d{3}-\\d{4}|HCV-\\d{3}-\\d{4}")
|
||||||
val matchResult = pattern.find(resultData)
|
val matchResult = pattern.find(resultData)
|
||||||
val hardwareId = matchResult?.value
|
val hardwareId = matchResult?.value
|
||||||
|
|
||||||
if (hardwareId.toString().length == 9) {
|
// Assuming hardwareId validation is based on matching the pattern,
|
||||||
|
// so no need to check length explicitly here.
|
||||||
|
// If there are more specific requirements for validation,
|
||||||
|
// they need to be implemented accordingly.
|
||||||
|
if (hardwareId != null) { // Check if hardwareId is not null instead
|
||||||
with(sharedPreferences.edit()) {
|
with(sharedPreferences.edit()) {
|
||||||
putString(Constants.DEVICE_ID, hardwareId)
|
putString(Constants.DEVICE_ID, hardwareId)
|
||||||
apply()
|
apply()
|
||||||
@@ -165,4 +191,5 @@ class DeviceProvisionFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user