From 372489330aa676a789bb49f8f3089c9aa0c80dcc Mon Sep 17 00:00:00 2001 From: chandrashekhar reddy Date: Sat, 9 Mar 2024 15:20:49 +0530 Subject: [PATCH] Added new screen ActivitiesFragment to check upload pending list and added version name in DashboardActivity, so it will be easy to know which version currently in use --- .../hpostesting/data/dao/HemoCubeDao.kt | 4 +- .../dashboard/ActivitiesFragment.kt | 63 +++++++++++++++++++ .../dashboard/DashboardActivity.kt | 22 ++++++- .../hemocube/HemoCubeViewModel.kt | 8 +-- .../main/res/drawable/shows_activity_24.xml | 5 ++ app/src/main/res/layout/app_bar_dashboard.xml | 14 ++++- .../main/res/layout/fragment_activities.xml | 39 ++++++++++++ .../main/res/menu/activity_main_drawer.xml | 4 ++ .../res/navigation/dashboard_navigation.xml | 5 ++ app/src/main/res/values-hi/strings.xml | 1 + app/src/main/res/values-kn/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 12 files changed, 158 insertions(+), 9 deletions(-) create mode 100644 app/src/main/java/com/example/hpostesting/presentation/dashboard/ActivitiesFragment.kt create mode 100644 app/src/main/res/drawable/shows_activity_24.xml create mode 100644 app/src/main/res/layout/fragment_activities.xml diff --git a/app/src/main/java/com/example/hpostesting/data/dao/HemoCubeDao.kt b/app/src/main/java/com/example/hpostesting/data/dao/HemoCubeDao.kt index 3c278a2..fce2c6b 100644 --- a/app/src/main/java/com/example/hpostesting/data/dao/HemoCubeDao.kt +++ b/app/src/main/java/com/example/hpostesting/data/dao/HemoCubeDao.kt @@ -31,7 +31,7 @@ interface HemoCubeDao { @Query("UPDATE hemo_cube_test_table SET isCSVCreated = :newValue WHERE _id = :id") suspend fun updateCSVFieldById(id: String, newValue: Boolean) - @Query("SELECT * from hemo_cube_test_table WHERE molbioFlag = :status") - suspend fun getPendingUser(status: Boolean): List + @Query("SELECT * from hemo_cube_test_table WHERE localFlag = 0") + fun getPendingUser(): LiveData> } \ No newline at end of file diff --git a/app/src/main/java/com/example/hpostesting/presentation/dashboard/ActivitiesFragment.kt b/app/src/main/java/com/example/hpostesting/presentation/dashboard/ActivitiesFragment.kt new file mode 100644 index 0000000..ec936d7 --- /dev/null +++ b/app/src/main/java/com/example/hpostesting/presentation/dashboard/ActivitiesFragment.kt @@ -0,0 +1,63 @@ +package com.example.hpostesting.presentation.dashboard + +import android.content.Context +import android.content.SharedPreferences +import android.os.BatteryManager +import android.os.Bundle +import android.util.Log +import androidx.fragment.app.Fragment +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.activityViewModels +import com.example.hpostesting.data.constant.Constants +import com.example.hpostesting.data.constant.DataHolder +import com.example.hpostesting.data.model.patient.HemoCubeTestData +import com.example.hpostesting.presentation.adapter.OfflineUserListAdapter +import com.example.hpostesting.presentation.adapter.UserListAdapter +import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel +import com.example.hpostesting.presentation.testRight.TestRightViewModel +import `in`.sminnovations.hpostesting.R +import `in`.sminnovations.hpostesting.databinding.FragmentActivitiesBinding +import `in`.sminnovations.hpostesting.databinding.FragmentHomeBinding + +class ActivitiesFragment : Fragment() { + private lateinit var binding: FragmentActivitiesBinding + private val hemoCubeViewModel: HemoCubeViewModel by activityViewModels() + private lateinit var adapter: OfflineUserListAdapter + private lateinit var sharedPreference: SharedPreferences + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?, + ): View { + binding = FragmentActivitiesBinding.inflate(inflater, container, false) + + sharedPreference = requireContext().getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE) + DataHolder.selectedTest = null + + return binding.root + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + hemoCubeViewModel.allPendingUserToUpload.observe(viewLifecycleOwner) { userData -> + + if (userData.isNotEmpty()) { + binding.rvOrderOffline.visibility = View.VISIBLE + binding.noDataText.visibility = View.GONE + val bm = + requireContext().getSystemService(Context.BATTERY_SERVICE) as BatteryManager + val batLevel: Int = bm.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY) + adapter = OfflineUserListAdapter(binding.root, batLevel) + adapter.differ.submitList(userData) + binding.rvOrderOffline.adapter = adapter + }else{ + binding.rvOrderOffline.visibility = View.GONE + binding.noDataText.visibility = View.VISIBLE + Log.d("Activities","Nothing to show") + } + } + } + +} \ No newline at end of file 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 efd0bb4..9a3a8e2 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 @@ -4,6 +4,7 @@ import android.annotation.SuppressLint import android.content.Context import android.content.Intent import android.content.SharedPreferences +import android.content.pm.PackageManager import android.net.Uri import android.os.Build import android.os.Bundle @@ -83,6 +84,9 @@ class DashboardActivity : AppCompatActivity(), IDataCollector { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { nats.connect() } + val versionName = getAppVersion(this@DashboardActivity) + " [ " + getAppEnvironment(this@DashboardActivity) + " ]" + binding.appBarDashboard.versionName.text = versionName + val deviceId = sharedPreferences.getString(Constants.DEVICE_ID, "") @@ -133,7 +137,7 @@ class DashboardActivity : AppCompatActivity(), IDataCollector { appBarConfiguration = AppBarConfiguration( setOf( - R.id.nav_home, R.id.nav_profile, R.id.nav_settings + R.id.nav_home, R.id.nav_profile, R.id.nav_activity,R.id.nav_settings ), drawerLayout ) setupActionBarWithNavController(navController, appBarConfiguration) @@ -251,4 +255,20 @@ class DashboardActivity : AppCompatActivity(), IDataCollector { serial_no = sharedPreference.getString(Constants.DEVICE_ID, "") ) } + private fun getAppVersion(context: Context): String { + return try { + val pInfo = context.packageManager.getPackageInfo(context.packageName, 0) + pInfo.versionName + } catch (e: PackageManager.NameNotFoundException) { + "N/A" + } + } + private fun getAppEnvironment(context: Context): String { + return try { + val pInfo = context.packageManager.getPackageInfo(context.packageName, 0) + pInfo.packageName.substringAfterLast('.') + } catch (e: PackageManager.NameNotFoundException) { + "N/A" + } + } } \ No newline at end of file diff --git a/app/src/main/java/com/example/hpostesting/presentation/hemocube/HemoCubeViewModel.kt b/app/src/main/java/com/example/hpostesting/presentation/hemocube/HemoCubeViewModel.kt index 29f79b6..96b1550 100644 --- a/app/src/main/java/com/example/hpostesting/presentation/hemocube/HemoCubeViewModel.kt +++ b/app/src/main/java/com/example/hpostesting/presentation/hemocube/HemoCubeViewModel.kt @@ -89,7 +89,7 @@ class HemoCubeViewModel @Inject constructor( private val _networkStatusLiveData = NetworkStatusLiveData(context) val allUserData = hemoCubeDao.getAll() val allLocalData = hemoCubeDao.getAll() - val allPendingUserToUpload = MutableLiveData>() + val allPendingUserToUpload = hemoCubeDao.getPendingUser() val allKitTestData = hemoCubeBufferDao.getAll() val deviceData = MutableLiveData() @@ -196,9 +196,9 @@ class HemoCubeViewModel @Inject constructor( } } } - fun uploadPendingUser() = viewModelScope.launch { - allPendingUserToUpload.postValue(hemoCubeDao.getPendingUser(false)) - } +// fun getPendingUser() = viewModelScope.launch { +// allPendingUserToUpload.postValue(hemoCubeDao.getPendingUser(true)) +// } fun uploadHemoCubeResultToDatabaseForBufferCheck( isOnline: Boolean, diff --git a/app/src/main/res/drawable/shows_activity_24.xml b/app/src/main/res/drawable/shows_activity_24.xml new file mode 100644 index 0000000..30d5d26 --- /dev/null +++ b/app/src/main/res/drawable/shows_activity_24.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/layout/app_bar_dashboard.xml b/app/src/main/res/layout/app_bar_dashboard.xml index 9361fe9..3f06e6c 100644 --- a/app/src/main/res/layout/app_bar_dashboard.xml +++ b/app/src/main/res/layout/app_bar_dashboard.xml @@ -4,7 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - tools:context=".presentation.dashboard.DashboardActivity"> + > + app:popupTheme="@style/Theme.HPOS.PopupOverlay" > + + diff --git a/app/src/main/res/layout/fragment_activities.xml b/app/src/main/res/layout/fragment_activities.xml new file mode 100644 index 0000000..34bcdb1 --- /dev/null +++ b/app/src/main/res/layout/fragment_activities.xml @@ -0,0 +1,39 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/activity_main_drawer.xml b/app/src/main/res/menu/activity_main_drawer.xml index 67653c3..d283f02 100644 --- a/app/src/main/res/menu/activity_main_drawer.xml +++ b/app/src/main/res/menu/activity_main_drawer.xml @@ -12,6 +12,10 @@ android:id="@+id/nav_profile" android:icon="@drawable/control_panel" android:title="@string/profile" /> + + डिवाइस जानकारी सीएसवी डाउनलोड करें + Activities \ No newline at end of file diff --git a/app/src/main/res/values-kn/strings.xml b/app/src/main/res/values-kn/strings.xml index 4224009..4dc9455 100644 --- a/app/src/main/res/values-kn/strings.xml +++ b/app/src/main/res/values-kn/strings.xml @@ -270,6 +270,7 @@ ರಕ್ತ ಗುಂಡನ್ನು ಸೇರಿಸಿ ಸರಿ CSV ಡೌನ್ಲೋಡ್ ಮಾಡಿ + Activities \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 54b25d1..cea96e3 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -273,4 +273,5 @@ Select your preferred language App Language OK + Activities \ No newline at end of file