diff --git a/app/build.gradle b/app/build.gradle index 2633906..014d0e0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -16,7 +16,7 @@ android { // prod - production, preprod - preproduction, quality - qc, dev - development defaultConfig { - applicationId "in.sminnovations.hpostesting.quality" + applicationId "in.sminnovations.hpostesting" minSdk 21 targetSdk 34 versionCode 93 diff --git a/app/google-services.json b/app/google-services.json index 7f4a67b..a73fe1e 100644 --- a/app/google-services.json +++ b/app/google-services.json @@ -1,45 +1,205 @@ { "project_info": { - "project_number": "1004619739289", - "project_id": "hpos-qa", - "storage_bucket": "hpos-qa.appspot.com" + "project_number": "650071678820", + "project_id": "hpos-af3cc", + "storage_bucket": "hpos-af3cc.appspot.com" }, "client": [ { "client_info": { - "mobilesdk_app_id": "1:1004619739289:android:f669b47552748433e5c808", + "mobilesdk_app_id": "1:650071678820:android:f1435a1c07f710036c6471", "android_client_info": { - "package_name": "in.sminnovations.hposregistration.quality" + "package_name": "com.example.hposconsentform" } }, - "oauth_client": [], + "oauth_client": [ + { + "client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com", + "client_type": 3 + } + ], "api_key": [ { - "current_key": "AIzaSyC4d4GhWHr_NMJAeBvnztQ_yQ3Qe9MAnLs" + "current_key": "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I" } ], "services": { "appinvite_service": { - "other_platform_oauth_client": [] + "other_platform_oauth_client": [ + { + "client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com", + "client_type": 3 + } + ] } } }, { "client_info": { - "mobilesdk_app_id": "1:1004619739289:android:8397cd1f0357bd89e5c808", + "mobilesdk_app_id": "1:650071678820:android:7865bef608cdee6f6c6471", "android_client_info": { - "package_name": "in.sminnovations.hpostesting.quality" + "package_name": "com.smi.counselling" } }, - "oauth_client": [], + "oauth_client": [ + { + "client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com", + "client_type": 3 + } + ], "api_key": [ { - "current_key": "AIzaSyC4d4GhWHr_NMJAeBvnztQ_yQ3Qe9MAnLs" + "current_key": "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I" } ], "services": { "appinvite_service": { - "other_platform_oauth_client": [] + "other_platform_oauth_client": [ + { + "client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com", + "client_type": 3 + } + ] + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:650071678820:android:2925e9ce3417d2386c6471", + "android_client_info": { + "package_name": "in.sminnovations.hemocube" + } + }, + "oauth_client": [ + { + "client_id": "650071678820-srhm9spm9hjn4frcd3r6o02gdhdbtd15.apps.googleusercontent.com", + "client_type": 1, + "android_info": { + "package_name": "in.sminnovations.hemocube", + "certificate_hash": "7714b9268a81d0cf0fb178b0af8dbb630f8fc70a" + } + }, + { + "client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com", + "client_type": 3 + } + ] + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:650071678820:android:7569c1cad4fc99916c6471", + "android_client_info": { + "package_name": "in.sminnovations.hposregistration" + } + }, + "oauth_client": [ + { + "client_id": "650071678820-70kp5jvjda4r5diqch2kn4lc40p4f42g.apps.googleusercontent.com", + "client_type": 1, + "android_info": { + "package_name": "in.sminnovations.hposregistration", + "certificate_hash": "7714b9268a81d0cf0fb178b0af8dbb630f8fc70a" + } + }, + { + "client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com", + "client_type": 3 + } + ] + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:650071678820:android:f96be19e5d43102b6c6471", + "android_client_info": { + "package_name": "in.sminnovations.hpostesting" + } + }, + "oauth_client": [ + { + "client_id": "650071678820-l87dnr0bdj95get0khgnvfv2an1k6ogq.apps.googleusercontent.com", + "client_type": 1, + "android_info": { + "package_name": "in.sminnovations.hpostesting", + "certificate_hash": "7714b9268a81d0cf0fb178b0af8dbb630f8fc70a" + } + }, + { + "client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com", + "client_type": 3 + } + ] + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:650071678820:android:a53292637abb7c0d6c6471", + "android_client_info": { + "package_name": "in.sminnovations.hpostesting.dev" + } + }, + "oauth_client": [ + { + "client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com", + "client_type": 3 + } + ] } } } diff --git a/app/src/main/java/com/example/hpostesting/presentation/dashboard/DashboardActivity.kt b/app/src/main/java/com/example/hpostesting/presentation/dashboard/DashboardActivity.kt index b65adad..d0d64a7 100644 --- a/app/src/main/java/com/example/hpostesting/presentation/dashboard/DashboardActivity.kt +++ b/app/src/main/java/com/example/hpostesting/presentation/dashboard/DashboardActivity.kt @@ -24,9 +24,6 @@ import com.example.hpostesting.data.constant.LanguageManager import com.example.hpostesting.presentation.NatsManager import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel import com.google.android.material.navigation.NavigationView -import com.google.android.material.progressindicator.LinearProgressIndicator -import com.google.android.play.core.appupdate.AppUpdateManager -import com.google.android.play.core.appupdate.AppUpdateManagerFactory import com.google.firebase.appdistribution.FirebaseAppDistribution import com.google.firebase.appdistribution.FirebaseAppDistributionException @@ -72,29 +69,33 @@ class DashboardActivity : AppCompatActivity(), IDataCollector { hemocubeViewModel.deviceUpdate.observe(this) { result -> when (result) { is Result.Success -> { - // Handle success val apkUrl = result.data // val apkUrl = "https://dl.dropboxusercontent.com/s/fi/1c3nn7t0co431hicl3hrt/app-debug.apk?rlkey=e4uf13ty1dpcked614vy1aaqp&dl=0" initiateUpdate(apkUrl.toString()) - Log.d("ApI", "APK URL: $apkUrl") + Log.d("ApI", "APK URL For App Update: $apkUrl") Toast.makeText( this, "APK UPLOAD ${result.data}", Toast.LENGTH_SHORT ).show() + // The APK URL LiveData will be updated automatically } is Result.Error -> { - result.exception.let { message -> - Toast.makeText(this, "An error occurred On Updating App: $message", Toast.LENGTH_LONG) - .show() + result.exception.let { message -> + Toast.makeText(this, "An error occurred On Updating App: $message", Toast.LENGTH_LONG) + .show() + } + } is Result.Loading -> { + } else -> { + } } } @@ -125,12 +126,11 @@ class DashboardActivity : AppCompatActivity(), IDataCollector { } private fun initiateUpdate(responseBody: String) { - val apkUrl = responseBody - if (!isValidHttpUrl(apkUrl)) { + if (!isValidHttpUrl(responseBody)) { return } - val request = DownloadManager.Request(Uri.parse(apkUrl)) + val request = DownloadManager.Request(Uri.parse(responseBody)) request.setTitle("App Update") request.setDescription("Downloading update...") request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED) @@ -189,41 +189,41 @@ class DashboardActivity : AppCompatActivity(), IDataCollector { override fun onResume() { super.onResume() - val firebaseAppDistribution = FirebaseAppDistribution.getInstance() - firebaseAppDistribution.updateIfNewReleaseAvailable() - .addOnProgressListener { updateProgress -> - - if (updateProgress.apkBytesDownloaded > 0) { - Toast.makeText( - this, - "${updateProgress.updateStatus}. ${updateProgress.apkBytesDownloaded / 1048576} /${updateProgress.apkFileTotalBytes / 1048576} MB", - Toast.LENGTH_SHORT - ).show() - } - } - .addOnFailureListener { e -> - // (Optional) Handle errors. - if (e is FirebaseAppDistributionException) { - when (e.errorCode) { - FirebaseAppDistributionException.Status.NOT_IMPLEMENTED -> { - // SDK did nothing. This is expected when building for Play. - } - - else -> { - // Handle other errors. - Toast.makeText( - this, - "AppDistribution error, status: ${e.errorCode}", - Toast.LENGTH_SHORT - ).show() - } - } - FirebaseCrashlytics.getInstance().recordException(e) - } - } - .addOnSuccessListener { -// Toast.makeText(this, "App Update: Success!", Toast.LENGTH_SHORT).show() - } +// val firebaseAppDistribution = FirebaseAppDistribution.getInstance() +// firebaseAppDistribution.updateIfNewReleaseAvailable() +// .addOnProgressListener { updateProgress -> +// +// if (updateProgress.apkBytesDownloaded > 0) { +// Toast.makeText( +// this, +// "${updateProgress.updateStatus}. ${updateProgress.apkBytesDownloaded / 1048576} /${updateProgress.apkFileTotalBytes / 1048576} MB", +// Toast.LENGTH_SHORT +// ).show() +// } +// } +// .addOnFailureListener { e -> +// // (Optional) Handle errors. +// if (e is FirebaseAppDistributionException) { +// when (e.errorCode) { +// FirebaseAppDistributionException.Status.NOT_IMPLEMENTED -> { +// // SDK did nothing. This is expected when building for Play. +// } +// +// else -> { +// // Handle other errors. +// Toast.makeText( +// this, +// "AppDistribution error, status: ${e.errorCode}", +// Toast.LENGTH_SHORT +// ).show() +// } +// } +// FirebaseCrashlytics.getInstance().recordException(e) +// } +// } +// .addOnSuccessListener { +//// Toast.makeText(this, "App Update: Success!", Toast.LENGTH_SHORT).show() +// } } override fun setConnect(connect: Boolean) { diff --git a/app/src/main/java/com/example/hpostesting/presentation/dashboard/HomeFragment.kt b/app/src/main/java/com/example/hpostesting/presentation/dashboard/HomeFragment.kt index 97d6094..ca5c31f 100644 --- a/app/src/main/java/com/example/hpostesting/presentation/dashboard/HomeFragment.kt +++ b/app/src/main/java/com/example/hpostesting/presentation/dashboard/HomeFragment.kt @@ -200,7 +200,9 @@ class HomeFragment : Fragment() { hemoCubeViewModel.login(createLoginRequestData(userID, password)) } else { isTokenAvailable = true - hemoCubeViewModel.deviceUpdate(createDeviceUpdateRequestData()) +// hemoCubeViewModel.deviceUpdate(createDeviceUpdateRequestData()) + + hemoCubeViewModel.deviceUpdate(createDeviceRequestData()) hemoCubeViewModel.uploadLogs() hemoCubeViewModel.startPeriodicCheckUpdate() } @@ -335,9 +337,10 @@ class HomeFragment : Fragment() { ) } - private fun createDeviceUpdateRequestData(): DeviceUpdateRequest { + private fun createDeviceRequestData(): DeviceUpdateRequest { return DeviceUpdateRequest( - serial_no = sharedPreference.getString(Constants.DEVICE_ID, "") + serial_no = Constants.DEVICE_ID + ) } diff --git a/app/src/main/java/com/example/hpostesting/presentation/deviceprovision/DeviceProvisionFragment.kt b/app/src/main/java/com/example/hpostesting/presentation/deviceprovision/DeviceProvisionFragment.kt index 5ebc428..bf71402 100644 --- a/app/src/main/java/com/example/hpostesting/presentation/deviceprovision/DeviceProvisionFragment.kt +++ b/app/src/main/java/com/example/hpostesting/presentation/deviceprovision/DeviceProvisionFragment.kt @@ -149,11 +149,11 @@ class DeviceProvisionFragment : Fragment() { private fun handleUsbData() { when { resultData.contains("SNE") -> { - val pattern = Regex("HPP1-\\d{4}") + val pattern = Regex("HCV-\\d{3}-\\d{4}") val matchResult = pattern.find(resultData) val hardwareId = matchResult?.value - if (hardwareId.toString().length == 9) { + if (hardwareId.toString().length == 12) { with(sharedPreferences.edit()) { putString(Constants.DEVICE_ID, hardwareId) apply() diff --git a/app/src/main/res/layout/fragment_gallery.xml b/app/src/main/res/layout/fragment_gallery.xml index fd82fc3..4c25528 100644 --- a/app/src/main/res/layout/fragment_gallery.xml +++ b/app/src/main/res/layout/fragment_gallery.xml @@ -83,7 +83,7 @@ android:id="@+id/btn_deviceProvision" android:layout_width="match_parent" android:layout_height="wrap_content" - android:visibility="gone" + android:visibility="visible" android:layout_marginHorizontal="16dp" android:layout_marginTop="24dp" android:clickable="false"