changes added when testing in device provision- and removed unwanted codes
This commit is contained in:
@@ -82,24 +82,19 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
"APK UPLOAD ${result.data}",
|
"APK UPLOAD ${result.data}",
|
||||||
Toast.LENGTH_SHORT
|
Toast.LENGTH_SHORT
|
||||||
).show()
|
).show()
|
||||||
// The APK URL LiveData will be updated automatically
|
|
||||||
}
|
}
|
||||||
|
|
||||||
is Result.Error -> {
|
is Result.Error -> {
|
||||||
result.exception.let { message ->
|
result.exception.let { message ->
|
||||||
Toast.makeText(this, "An error occurred On Updating App: $message", Toast.LENGTH_LONG)
|
Toast.makeText(this, "An error occurred On Updating App: $message", Toast.LENGTH_LONG)
|
||||||
.show()
|
.show()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
is Result.Loading -> {
|
is Result.Loading -> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,12 +125,8 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun initiateUpdate(responseBody: String) {
|
private fun initiateUpdate(responseBody: String) {
|
||||||
// Extract the URL from the ResponseBody
|
|
||||||
val apkUrl = responseBody
|
val apkUrl = responseBody
|
||||||
|
|
||||||
// Check if the extracted APK URL is valid
|
|
||||||
if (!isValidHttpUrl(apkUrl)) {
|
if (!isValidHttpUrl(apkUrl)) {
|
||||||
// Handle the case where the URL is not valid
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,20 +138,12 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
|
|
||||||
val downloadManager = getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
|
val downloadManager = getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
|
||||||
downloadId = downloadManager.enqueue(request)
|
downloadId = downloadManager.enqueue(request)
|
||||||
|
|
||||||
// Register a BroadcastReceiver to receive the download complete event
|
|
||||||
val filter = IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)
|
val filter = IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)
|
||||||
registerReceiver(downloadReceiver, filter)
|
registerReceiver(downloadReceiver, filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to check if a URL has a valid HTTP/HTTPS scheme
|
|
||||||
// Function to extract the APK URL from the ResponseBody
|
|
||||||
private fun extractApkUrl(responseBody: ResponseBody): String {
|
private fun extractApkUrl(responseBody: ResponseBody): String {
|
||||||
// Assuming your ResponseBody contains the APK URL as a string
|
|
||||||
return responseBody.string()
|
return responseBody.string()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to check if a URL has a valid HTTP/HTTPS scheme
|
|
||||||
private fun isValidHttpUrl(url: String): Boolean {
|
private fun isValidHttpUrl(url: String): Boolean {
|
||||||
return url.startsWith("http://") || url.startsWith("https://")
|
return url.startsWith("http://") || url.startsWith("https://")
|
||||||
}
|
}
|
||||||
@@ -168,7 +151,6 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
override fun onReceive(context: Context?, intent: Intent?) {
|
override fun onReceive(context: Context?, intent: Intent?) {
|
||||||
val id = intent?.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1)
|
val id = intent?.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1)
|
||||||
if (id == downloadId) {
|
if (id == downloadId) {
|
||||||
// Install the downloaded APK
|
|
||||||
installApk()
|
installApk()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -204,9 +186,6 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
unregisterReceiver(downloadReceiver)
|
unregisterReceiver(downloadReceiver)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
|
|
||||||
|
|||||||
@@ -237,34 +237,6 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hemoCubeViewModel.deviceUpdate.observe(viewLifecycleOwner) { response ->
|
|
||||||
when (response) {
|
|
||||||
is Result.Success -> {
|
|
||||||
Toast.makeText(
|
|
||||||
requireContext(), response.data.toString(), Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
is Result.Error -> {
|
|
||||||
response.exception.let { message ->
|
|
||||||
Toast.makeText(
|
|
||||||
activity,
|
|
||||||
"An error occurred check update: $message",
|
|
||||||
Toast.LENGTH_LONG
|
|
||||||
)
|
|
||||||
.show()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
is Result.Loading -> {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
hemoCubeViewModel.uploadLogs.observe(viewLifecycleOwner) { response ->
|
hemoCubeViewModel.uploadLogs.observe(viewLifecycleOwner) { response ->
|
||||||
when (response) {
|
when (response) {
|
||||||
is Result.Success -> {
|
is Result.Success -> {
|
||||||
|
|||||||
@@ -149,11 +149,11 @@ class DeviceProvisionFragment : Fragment() {
|
|||||||
private fun handleUsbData() {
|
private fun handleUsbData() {
|
||||||
when {
|
when {
|
||||||
resultData.contains("SNE") -> {
|
resultData.contains("SNE") -> {
|
||||||
val pattern = Regex("HCV-\\d{3}-\\d{4}")
|
val pattern = Regex("HPP1-\\d{4}")
|
||||||
val matchResult = pattern.find(resultData)
|
val matchResult = pattern.find(resultData)
|
||||||
val hardwareId = matchResult?.value
|
val hardwareId = matchResult?.value
|
||||||
|
|
||||||
if (hardwareId.toString().length == 12) {
|
if (hardwareId.toString().length == 9) {
|
||||||
with(sharedPreferences.edit()) {
|
with(sharedPreferences.edit()) {
|
||||||
putString(Constants.DEVICE_ID, hardwareId)
|
putString(Constants.DEVICE_ID, hardwareId)
|
||||||
apply()
|
apply()
|
||||||
|
|||||||
@@ -92,7 +92,7 @@
|
|||||||
app:cornerRadius="16dp"
|
app:cornerRadius="16dp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/btn_calibration" />
|
app:layout_constraintTop_toBottomOf="@id/btn_deviceInfo" />
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/btn_deviceInfo"
|
android:id="@+id/btn_deviceInfo"
|
||||||
|
|||||||
Reference in New Issue
Block a user