new 124 version
This commit is contained in:
@@ -19,8 +19,8 @@ android {
|
||||
applicationId "in.sminnovations.hpostesting.iocl"
|
||||
minSdk 21
|
||||
targetSdk 34
|
||||
versionCode 124
|
||||
versionName "2.1.124"
|
||||
versionCode 125
|
||||
versionName "2.1.125"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
"type": "SINGLE",
|
||||
"filters": [],
|
||||
"attributes": [],
|
||||
"versionCode": 124,
|
||||
"versionName": "2.1.124",
|
||||
"versionCode": 125,
|
||||
"versionName": "2.1.125",
|
||||
"outputFile": "app-release.apk"
|
||||
}
|
||||
],
|
||||
|
||||
@@ -21,7 +21,7 @@ object Constants {
|
||||
const val DOCUMENT_ID_FOR_UPDATE ="2o71vBKLqdgEKYtFG8Lb"
|
||||
const val ABHA_APP_PACKAGE = "in.ndhm.phr"
|
||||
|
||||
const val MOLBIO_INTEGRATION = false
|
||||
const val MOLBIO_INTEGRATION = true
|
||||
const val deviceProvisionEmail = "HPOS_provisioner@bigtec.co.in"
|
||||
const val deviceProvisionPassword = "f2ab0e7f9d69"
|
||||
const val DEVICE_ID_API = "deviceIDAPI"
|
||||
|
||||
@@ -40,7 +40,9 @@ object DataHolder {
|
||||
var kitSerial: String = ""
|
||||
var centerName: String = ""
|
||||
var district: String = ""
|
||||
var quickCapture:Boolean = false
|
||||
var location: UserData.Location? = null
|
||||
var ipAddress: String =""
|
||||
var testExp: Boolean = true
|
||||
var hemocubeResult: Double? = null
|
||||
}
|
||||
@@ -134,7 +134,7 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
||||
}else{
|
||||
Constants.MAXIMUM_TEST_ALLOWED_BEFORE_REFERENCE10MM
|
||||
}
|
||||
if (DataHolder.sampleReadCounter <= maxTest && DataHolder.isToken) {
|
||||
if (DataHolder.sampleReadCounter <= maxTest) {
|
||||
DataHolder.selectedTest!!.kitSerial = DataHolder.kitSerial
|
||||
moveToNext()
|
||||
}
|
||||
|
||||
@@ -71,17 +71,24 @@ import com.google.firebase.perf.ktx.performance
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import `in`.sminnovations.hpostesting.R
|
||||
import `in`.sminnovations.hpostesting.databinding.FragmentHomeBinding
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import okhttp3.ResponseBody
|
||||
import org.json.JSONObject
|
||||
import java.io.BufferedOutputStream
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.io.FileOutputStream
|
||||
import java.net.HttpURLConnection
|
||||
import java.net.URL
|
||||
import java.nio.charset.Charset
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Calendar
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
import java.util.Scanner
|
||||
import java.util.zip.ZipEntry
|
||||
import java.util.zip.ZipInputStream
|
||||
import kotlin.properties.Delegates
|
||||
@@ -127,7 +134,7 @@ class HomeFragment : Fragment() {
|
||||
|
||||
getDeviceId()
|
||||
checkUnprocessedCSVData()
|
||||
checkForUpdate()
|
||||
//checkForUpdate()
|
||||
viewModel.allUserData.observe(viewLifecycleOwner) { userData ->
|
||||
deleteIncompleteRegistrations(userData)
|
||||
}
|
||||
@@ -225,6 +232,7 @@ class HomeFragment : Fragment() {
|
||||
// requireActivity().finish()
|
||||
}
|
||||
binding.btnQuickCapture.setOnClickListener {
|
||||
DataHolder.quickCapture = true
|
||||
DataHolder.hemoCubeTestData = HemoCubeTestData()
|
||||
|
||||
val i = Intent(
|
||||
@@ -364,7 +372,8 @@ class HomeFragment : Fragment() {
|
||||
Log.d("istoken", isTokenAvailable.toString())
|
||||
if (!isTokenAvailable) {
|
||||
Log.d("istoken1", isTokenAvailable.toString())
|
||||
hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
||||
callLogin(userID, password)
|
||||
// hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
||||
|
||||
//isTokenAvailable = true
|
||||
|
||||
@@ -372,7 +381,8 @@ class HomeFragment : Fragment() {
|
||||
Log.d("istoken7", isTokenAvailable.toString())
|
||||
if (isTokenExpired(accessToken)) {
|
||||
Log.d("istoken8", isTokenAvailable.toString())
|
||||
hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
||||
callLogin(userID, password)
|
||||
// hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
||||
//hemoCubeViewModel.startPeriodicCheckUpdate()
|
||||
}else{
|
||||
hemoCubeViewModel.checkUpdate(createCheckUpdateRequestData())
|
||||
@@ -392,12 +402,14 @@ class HomeFragment : Fragment() {
|
||||
password = credentials[1]
|
||||
Toast.makeText(context, "DECRYPTED: $credentials", Toast.LENGTH_SHORT).show()
|
||||
if (!isTokenAvailable) {
|
||||
hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
||||
callLogin(userID, password)
|
||||
//hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
||||
}
|
||||
else if (isTokenAvailable) {
|
||||
//hemoCubeViewModel.startPeriodicCheckUpdate()
|
||||
if (isTokenExpired(accessToken)) {
|
||||
hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
||||
callLogin(userID, password)
|
||||
//hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
||||
}else{
|
||||
hemoCubeViewModel.checkUpdate(createCheckUpdateRequestData())
|
||||
}
|
||||
@@ -655,7 +667,7 @@ class HomeFragment : Fragment() {
|
||||
val version = pInfo.versionName
|
||||
var labname = sharedPreference.getString(Constants.LABNAME,"")
|
||||
return LoginRequest(
|
||||
latitude = DataHolder.location!!.latitude.toString(), longitude = DataHolder.location!!.longitude.toString(), location = DataHolder.location.toString(), password = password, serialNumber = userID, username = userID, version = version, lab = labname
|
||||
latitude = DataHolder.location!!.latitude.toString(), longitude = DataHolder.location!!.longitude.toString(), location = DataHolder.ipAddress, password = password, serialNumber = userID, username = userID, version = version, lab = labname
|
||||
)
|
||||
}
|
||||
private fun createCheckUpdateRequestData(): CheckUpdateRequest {
|
||||
@@ -790,7 +802,8 @@ class HomeFragment : Fragment() {
|
||||
}
|
||||
if (!isTokenAvailable) {
|
||||
Log.d("istoken0", isTokenAvailable.toString())
|
||||
hemoCubeViewModel.login(createLoginRequestData(username, password))
|
||||
callLogin(username, password)
|
||||
//hemoCubeViewModel.login(createLoginRequestData(username, password))
|
||||
}
|
||||
|
||||
} ?: Log.e("fetchDeviceCredentials", "Failed to parse device data.")
|
||||
@@ -1485,6 +1498,49 @@ class HomeFragment : Fragment() {
|
||||
super.onDestroy()
|
||||
|
||||
}
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
private fun getPublicIpAddr(callback: (String) -> Unit) {
|
||||
try {
|
||||
GlobalScope.launch(Dispatchers.IO) {
|
||||
val url = URL("https://api.ipify.org")
|
||||
val conn = url.openConnection() as HttpURLConnection
|
||||
try {
|
||||
conn.connect()
|
||||
if (conn.responseCode == HttpURLConnection.HTTP_OK) {
|
||||
val scanner = Scanner(conn.inputStream)
|
||||
scanner.useDelimiter("\\A")
|
||||
if (scanner.hasNext()) {
|
||||
val ipAddress = scanner.next()
|
||||
Log.d("ipaddress",DataHolder.ipAddress)
|
||||
callback(ipAddress)
|
||||
}else{
|
||||
callback("fail")
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
conn.disconnect()
|
||||
}
|
||||
}
|
||||
}catch (e: Exception){
|
||||
Log.e("home",e.toString())
|
||||
callback("fail")
|
||||
}
|
||||
}
|
||||
|
||||
private fun callLogin(userID: String, password: String) {
|
||||
if(DataHolder.ipAddress == "0.0"){
|
||||
getPublicIpAddr { ipAddress ->
|
||||
if(ipAddress != "fail"){
|
||||
DataHolder.ipAddress = ipAddress
|
||||
}
|
||||
hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
||||
}
|
||||
}else{
|
||||
hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.location.Location
|
||||
import android.location.LocationListener
|
||||
import android.location.LocationManager
|
||||
import android.net.ConnectivityManager
|
||||
import android.net.NetworkCapabilities
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
@@ -38,6 +39,12 @@ import com.example.hpostesting.data.constant.DataHolder
|
||||
import com.example.hpostesting.util.AppInitializer
|
||||
import `in`.sminnovations.hpostesting.R
|
||||
import `in`.sminnovations.hpostesting.databinding.FragmentLoginBinding
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import java.net.HttpURLConnection
|
||||
import java.net.URL
|
||||
import java.util.Scanner
|
||||
|
||||
|
||||
class LoginFragment : Fragment() {
|
||||
@@ -68,7 +75,14 @@ class LoginFragment : Fragment() {
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
init()
|
||||
checkLocation()
|
||||
if(isInternetAvailable()){
|
||||
getPublicIpAddr { ipAddress ->
|
||||
DataHolder.ipAddress = ipAddress
|
||||
}
|
||||
Log.d("ipaddress",DataHolder.ipAddress)
|
||||
}
|
||||
|
||||
//checkLocation()
|
||||
}
|
||||
private fun init() {
|
||||
if (isUserLoggedIn()) {
|
||||
@@ -294,7 +308,38 @@ class LoginFragment : Fragment() {
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
private fun checkUserName(userName: String): Boolean {
|
||||
private fun getPublicIpAddr(callback: (String) -> Unit) {
|
||||
try {
|
||||
GlobalScope.launch(Dispatchers.IO) {
|
||||
val url = URL("https://api.ipify.org")
|
||||
val conn = url.openConnection() as HttpURLConnection
|
||||
try {
|
||||
conn.connect()
|
||||
if (conn.responseCode == HttpURLConnection.HTTP_OK) {
|
||||
val scanner = Scanner(conn.inputStream)
|
||||
scanner.useDelimiter("\\A")
|
||||
if (scanner.hasNext()) {
|
||||
val ipAddress = scanner.next()
|
||||
callback(ipAddress)
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
conn.disconnect()
|
||||
}
|
||||
}
|
||||
}catch (e: Exception){
|
||||
Log.e(TAG,e.toString())
|
||||
}
|
||||
}
|
||||
@SuppressLint("NewApi")
|
||||
private fun isInternetAvailable(): Boolean {
|
||||
val connectivityManager = requireActivity().getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||
val network = connectivityManager.activeNetwork ?: return false
|
||||
val networkCapabilities = connectivityManager.getNetworkCapabilities(network) ?: return false
|
||||
return networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
|
||||
}
|
||||
|
||||
private fun checkUserName(userName: String): Boolean {
|
||||
return userName.isNotEmpty() && userName.length >= 3
|
||||
}
|
||||
|
||||
|
||||
@@ -144,11 +144,15 @@ class HemoCubeFragment : Fragment() {
|
||||
setBackgroundColor(Color.GREEN) // Set button background color to green
|
||||
text = "Refresh Buffer" // Change button text to "Buffer Exists"
|
||||
}
|
||||
binding.btnSamplestart.isClickable = true
|
||||
binding.btnSamplestart.isEnabled = true
|
||||
}else{
|
||||
binding.btnPlacebuffer.apply {
|
||||
setBackgroundColor(Color.RED) // Set button background color to green
|
||||
text = "No Buffer" // Change button text to "Buffer Exists"
|
||||
}
|
||||
binding.btnSamplestart.isClickable = false
|
||||
binding.btnSamplestart.isEnabled = false
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user