Compare commits

...

1 Commits

Author SHA1 Message Date
Mariya
cf2e904445 Added code for force login 2024-02-05 16:21:34 +05:30
5 changed files with 59 additions and 15 deletions

View File

@@ -19,8 +19,8 @@ android {
applicationId "in.sminnovations.hpostesting.quality"
minSdk 21
targetSdk 34
versionCode 99
versionName "2.1.99"
versionCode 100
versionName "2.1.100"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

View File

@@ -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.
sdkHandler!!.dcssdkEstablishCommunicationSession(mScannerInfoList[0].scannerID)
if (mScannerInfoList.isNotEmpty()) {
sdkHandler!!.dcssdkEstablishCommunicationSession(mScannerInfoList[0].scannerID)
} else {
Toast.makeText(this, "No scanner is Available", Toast.LENGTH_LONG).show()
}
}
fun pullTrigger() {

View File

@@ -23,7 +23,6 @@ class NatsManager(datacollector: DashboardActivity) {
fun connect() {
Log.d(TAG, "TRY TO CONNECT")
Thread {
val seedString = "SUAEB5PUWNS6C2HUV3MFI6HUDEAPGPFPBHMI73NHIQATCDD2BWALVEZXZ4"
val seedBytes = seedString.toCharArray()

View File

@@ -118,6 +118,8 @@ class HomeFragment : Fragment() {
loadUserData()
setSearch()
checkForLocalDBData()
// This function could be called directly where you need to perform the login operation.
forceLogin()
checkForTokenAndUpdate()
} else {
binding.internetAvailableCL.visibility = View.GONE
@@ -188,12 +190,31 @@ 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() {
val accessToken = sharedPreference.getString(Constants.ACCESS_TOKEN, "").toString()
val password = sharedPreference.getString(Constants.DEVICE_PASSWORD_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))
} else {
if (isTokenExpired(accessToken)) {
@@ -205,13 +226,6 @@ class HomeFragment : Fragment() {
hemoCubeViewModel.startPeriodicCheckUpdate()
}
}
} else {
Toast.makeText(
requireContext(),
"Contact Help and get your device provision done",
Toast.LENGTH_SHORT
).show()
}
hemoCubeViewModel.loginResponse.observe(viewLifecycleOwner) { response ->
when (response) {
is Result.Success -> {

View File

@@ -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() {
when {
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 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()) {
putString(Constants.DEVICE_ID, hardwareId)
apply()
@@ -165,4 +191,5 @@ class DeviceProvisionFragment : Fragment() {
}
}
}
}