Updated package name from refactored app to -> hpos [working]

This commit is contained in:
vsuryakumar
2023-01-31 15:30:38 +05:30
parent 33ea79d773
commit 64607dcd6d
51 changed files with 196 additions and 220 deletions

2
.idea/.name generated
View File

@@ -1 +1 @@
Refactored App hpos

View File

@@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetDropDown">
<runningDeviceTargetSelectedWithDropDown>
<Target>
<type value="RUNNING_DEVICE_TARGET" />
<deviceKey>
<Key>
<type value="SERIAL_NUMBER" />
<value value="192.168.0.135:5555" />
</Key>
</deviceKey>
</Target>
</runningDeviceTargetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2023-01-30T07:49:19.748240Z" />
</component>
</project>

20
.idea/jarRepositories.xml generated Normal file
View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="MavenRepo" />
<option name="name" value="MavenRepo" />
<option name="url" value="https://repo.maven.apache.org/maven2/" />
</remote-repository>
</component>
</project>

View File

@@ -2,12 +2,13 @@ plugins {
id 'com.android.application' id 'com.android.application'
id 'org.jetbrains.kotlin.android' id 'org.jetbrains.kotlin.android'
} }
//apply plugin: 'kotlin-android'
android { android {
compileSdk 32 compileSdk 32
defaultConfig { defaultConfig {
applicationId "com.example.refactoredapp" applicationId "com.example.hpos"
minSdk 21 minSdk 21
targetSdk 32 targetSdk 32
versionCode 1 versionCode 1
@@ -44,8 +45,6 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
// androidTestImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.1'
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1" implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1"
implementation 'com.opencsv:opencsv:4.6' implementation 'com.opencsv:opencsv:4.6'
@@ -55,4 +54,11 @@ dependencies {
implementation 'com.opencsv:opencsv:4.6' implementation 'com.opencsv:opencsv:4.6'
} // implementation 'androidx.appcompat:appcompat:1.1.0'
// implementation "androidx.core:core-ktx:+"
// implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
//repositories {
// mavenCentral()
//}

View File

@@ -1,4 +1,4 @@
package com.example.refactoredapp package com.example.hpos
import androidx.test.platform.app.InstrumentationRegistry import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
package="com.example.refactoredapp"> package="com.example.hpos">
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
@@ -15,16 +15,16 @@
android:label="@string/app_name" android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.RefactoredApp" android:theme="@style/Theme.HPOS"
tools:targetApi="31"> tools:targetApi="31">
<service <service
android:name=".presentation.testRight.UsbService" android:name="com.example.hpos.presentation.testRight.UsbService"
android:enabled="true" android:enabled="true"
android:exported="false" /> android:exported="false" />
<activity <activity
android:name=".presentation.SplashActivity" android:name="com.example.hpos.presentation.SplashActivity"
android:exported="true" android:exported="true"
android:noHistory="true" android:noHistory="true"
android:theme="@style/AppTheme.NoActionBar"> android:theme="@style/AppTheme.NoActionBar">
@@ -35,7 +35,7 @@
</activity> </activity>
<activity <activity
android:name=".presentation.testRight.TestRightActivity" android:name="com.example.hpos.presentation.testRight.TestRightActivity"
android:exported="false" android:exported="false"
android:windowSoftInputMode="adjustPan"> android:windowSoftInputMode="adjustPan">
<!-- <intent-filter>--> <!-- <intent-filter>-->
@@ -47,7 +47,7 @@
<!-- android:resource="@xml/device_filter" />--> <!-- android:resource="@xml/device_filter" />-->
</activity> </activity>
<activity <activity
android:name=".presentation.MainActivity" android:name="com.example.hpos.presentation.MainActivity"
android:exported="true"> android:exported="true">
<intent-filter> <intent-filter>
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" /> <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />

View File

@@ -1,4 +1,4 @@
package com.example.refactoredapp package com.example.hpos
import android.app.Application import android.app.Application

View File

@@ -1,6 +1,6 @@
package com.example.refactoredapp.data package com.example.hpos.data
import com.example.refactoredapp.data.model.TestRightDeviceConstants import com.example.hpos.data.model.TestRightDeviceConstants
object DataHolder { object DataHolder {
var isStoragePermissionGranted = false var isStoragePermissionGranted = false

View File

@@ -0,0 +1,7 @@
package com.example.hpos.data
import com.example.hpos.data.model.TestInfo
interface Repository {
suspend fun saveToDatabase(info: TestInfo)
}

View File

@@ -1,6 +1,6 @@
package com.example.refactoredapp.data package com.example.hpos.data
import com.example.refactoredapp.data.model.TestInfo import com.example.hpos.data.model.TestInfo
class RepositoryImpl : Repository { class RepositoryImpl : Repository {

View File

@@ -1,4 +1,4 @@
package com.example.refactoredapp.data.constant package com.example.hpos.data.constant
object Constants { object Constants {
const val ACTION_USB_PERMISSION = "shanmukha.in.sickle_cell.USB_PERMISSION" const val ACTION_USB_PERMISSION = "shanmukha.in.sickle_cell.USB_PERMISSION"

View File

@@ -1,4 +1,4 @@
package com.example.refactoredapp.data.constant package com.example.hpos.data.constant
enum class TestRightCommands(val command: String) { enum class TestRightCommands(val command: String) {
led2Set50("led2 50\r"), led2Set50("led2 50\r"),
@@ -8,4 +8,5 @@ enum class TestRightCommands(val command: String) {
run("run\r"), run("run\r"),
printInRange("print 239 339\r"), printInRange("print 239 339\r"),
printAll("print\r"), printAll("print\r"),
testByEnter("\n\r")
} }

View File

@@ -1,4 +1,4 @@
package com.example.HPOS.data.model package com.example.hpos.data.model
data class CalculationVariableForTest( data class CalculationVariableForTest(
var pixelNo: Int, var pixelNo: Int,

View File

@@ -1,4 +1,4 @@
package com.example.refactoredapp.data.model package com.example.hpos.data.model
enum class DeviceType { enum class DeviceType {
Denovix, Denovix,

View File

@@ -1,4 +1,4 @@
package com.example.refactoredapp.data.model package com.example.hpos.data.model
data class PatientData( data class PatientData(
val name: String, val name: String,

View File

@@ -1,4 +1,4 @@
package com.example.refactoredapp.data.model package com.example.hpos.data.model
data class TestInfo( data class TestInfo(
val value: String, val value: String,

View File

@@ -1,4 +1,4 @@
package com.example.refactoredapp.data.model package com.example.hpos.data.model
data class TestRightCalculationData( data class TestRightCalculationData(
var absorbanceOne: Double?, var absorbanceOne: Double?,

View File

@@ -1,4 +1,4 @@
package com.example.refactoredapp.data.model package com.example.hpos.data.model
data class TestRightDeviceConstants( data class TestRightDeviceConstants(
var a: String, var a: String,

View File

@@ -1,4 +1,4 @@
package com.example.refactoredapp.data.model package com.example.hpos.data.model
enum class TestRightResultType { enum class TestRightResultType {
NORMAL, NORMAL,

View File

@@ -1,8 +1,8 @@
package com.example.refactoredapp.domain package com.example.hpos.domain
import com.example.refactoredapp.data.constant.Constants import com.example.hpos.data.constant.Constants
import com.example.refactoredapp.data.model.TestRightCalculationData import com.example.hpos.data.model.TestRightCalculationData
import com.example.refactoredapp.data.model.TestRightResultType import com.example.hpos.data.model.TestRightResultType
class ResultCalculationWithAvgImpl : TestRightResultCalculation { class ResultCalculationWithAvgImpl : TestRightResultCalculation {

View File

@@ -1,8 +1,8 @@
package com.example.refactoredapp.domain package com.example.hpos.domain
import android.util.Log import android.util.Log
import com.example.refactoredapp.data.constant.Constants import com.example.hpos.data.constant.Constants
import com.example.refactoredapp.data.model.TestRightResultType import com.example.hpos.data.model.TestRightResultType
import kotlin.math.log10 import kotlin.math.log10
class ResultCalculationWithFirstImpl { class ResultCalculationWithFirstImpl {

View File

@@ -1,8 +1,8 @@
package com.example.refactoredapp.domain package com.example.hpos.domain
import com.example.refactoredapp.data.constant.Constants import com.example.hpos.data.constant.Constants
import com.example.refactoredapp.data.model.TestRightCalculationData import com.example.hpos.data.model.TestRightCalculationData
import com.example.refactoredapp.data.model.TestRightResultType import com.example.hpos.data.model.TestRightResultType
class ResultCalculationWithMaxImpl : TestRightResultCalculation { class ResultCalculationWithMaxImpl : TestRightResultCalculation {

View File

@@ -1,6 +1,6 @@
package com.example.refactoredapp.domain package com.example.hpos.domain
import com.example.refactoredapp.data.model.TestRightCalculationData import com.example.hpos.data.model.TestRightCalculationData
import com.opencsv.CSVWriter import com.opencsv.CSVWriter
import java.io.File import java.io.File
import java.io.FileWriter import java.io.FileWriter

View File

@@ -1,6 +1,6 @@
package com.example.HPOS.domain package com.example.hpos.domain
import com.example.HPOS.data.model.CalculationVariableForTest import com.example.hpos.data.model.CalculationVariableForTest
import com.opencsv.CSVWriter import com.opencsv.CSVWriter
import java.io.File import java.io.File
import java.io.FileWriter import java.io.FileWriter

View File

@@ -0,0 +1,9 @@
package com.example.hpos.domain
import com.example.hpos.data.model.TestRightCalculationData
interface TestRightResultCalculation {
fun getResults(
wavelengthToAbsorbance: ArrayList<ArrayList<Double>>
): TestRightCalculationData
}

View File

@@ -1,13 +1,13 @@
package com.example.refactoredapp.presentation package com.example.hpos.presentation
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.widget.Toast import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import com.example.refactoredapp.databinding.ActivityMainBinding import com.example.hpos.databinding.ActivityMainBinding
import com.example.refactoredapp.presentation.testRight.TestRightActivity import com.example.hpos.presentation.testRight.TestRightActivity
import com.example.refactoredapp.util.MyViewModelFactory import com.example.hpos.util.MyViewModelFactory
class MainActivity : AppCompatActivity() class MainActivity : AppCompatActivity()
@@ -45,17 +45,4 @@ class MainActivity : AppCompatActivity()
} }
private fun setupObservers() {
// viewModel.isStoragePermission.observe(this) {
// if (it) {
// createFolder()
// }
// }
}
override fun onDestroy() {
super.onDestroy()
}
} }

View File

@@ -0,0 +1,7 @@
package com.example.hpos.presentation
import androidx.lifecycle.ViewModel
class MainViewModel : ViewModel() {
}

View File

@@ -1,11 +1,11 @@
package com.example.refactoredapp.presentation package com.example.hpos.presentation
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.example.refactoredapp.R import com.example.hpos.R
import com.example.refactoredapp.data.model.PatientData import com.example.hpos.data.model.PatientData
class RVAdapter : RecyclerView.Adapter<RVAdapter.ViewHolder>() { class RVAdapter : RecyclerView.Adapter<RVAdapter.ViewHolder>() {

View File

@@ -1,4 +1,4 @@
package com.example.refactoredapp.presentation package com.example.hpos.presentation
import android.Manifest import android.Manifest
import android.content.Intent import android.content.Intent
@@ -13,11 +13,9 @@ import androidx.activity.result.contract.ActivityResultContracts
import androidx.annotation.RequiresApi import androidx.annotation.RequiresApi
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import com.example.refactoredapp.R import com.example.hpos.data.DataHolder
import com.example.refactoredapp.data.DataHolder import com.example.hpos.databinding.ActivitySplashBinding
import com.example.refactoredapp.databinding.ActivitySplashBinding import com.example.hpos.util.MyUtils
import com.example.refactoredapp.util.MyUtils
import java.io.File
/** /**
* Splash Activity * Splash Activity

View File

@@ -1,4 +1,4 @@
package com.example.refactoredapp.presentation package com.example.hpos.presentation
interface UsbServiceListener { interface UsbServiceListener {
fun onUsbRead(data: ByteArray?) fun onUsbRead(data: ByteArray?)

View File

@@ -1,5 +1,6 @@
package com.example.refactoredapp.presentation.testRight package com.example.hpos.presentation.testRight
import android.R
import android.app.PendingIntent import android.app.PendingIntent
import android.content.* import android.content.*
import android.hardware.usb.UsbDevice import android.hardware.usb.UsbDevice
@@ -8,13 +9,16 @@ import android.hardware.usb.UsbManager
import android.os.Bundle import android.os.Bundle
import android.os.IBinder import android.os.IBinder
import android.util.Log import android.util.Log
import android.view.MenuItem
import android.view.View
import android.widget.Toast import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import com.example.refactoredapp.data.constant.Constants import com.example.hpos.data.DataHolder
import com.example.refactoredapp.data.DataHolder import com.example.hpos.data.constant.Constants
import com.example.refactoredapp.databinding.ActivityTestRightBinding import com.example.hpos.databinding.ActivityTestRightBinding
import com.example.refactoredapp.util.MyViewModelFactory import com.example.hpos.util.MyViewModelFactory
import com.google.android.material.snackbar.Snackbar
import com.hoho.android.usbserial.driver.UsbSerialDriver import com.hoho.android.usbserial.driver.UsbSerialDriver
import com.hoho.android.usbserial.driver.UsbSerialProber import com.hoho.android.usbserial.driver.UsbSerialProber

View File

@@ -1,23 +1,21 @@
package com.example.refactoredapp.presentation.testRight package com.example.hpos.presentation.testRight
import android.os.Bundle import android.os.Bundle
import android.os.Handler import android.os.Handler
import android.os.Looper import android.os.Looper
import android.util.Log import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.MotionEvent
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels import androidx.fragment.app.activityViewModels
import com.example.refactoredapp.R import com.example.hpos.R
import com.example.refactoredapp.data.DataHolder import com.example.hpos.data.DataHolder
import com.example.refactoredapp.data.constant.Constants import com.example.hpos.data.constant.TestRightCommands
import com.example.refactoredapp.data.constant.TestRightCommands import com.example.hpos.databinding.FragmentTestRightExpReferenceBinding
import com.example.refactoredapp.databinding.FragmentTestRightExpReferenceBinding import com.example.hpos.presentation.UsbServiceListener
import com.example.refactoredapp.presentation.UsbServiceListener import com.example.hpos.presentation.utils.MyDialogListener
import com.example.refactoredapp.presentation.utils.MyDialogListener import com.example.hpos.presentation.utils.UIUtils
import com.example.refactoredapp.presentation.utils.UIUtils
class TestRightExpReference : Fragment() { class TestRightExpReference : Fragment() {

View File

@@ -1,4 +1,4 @@
package com.example.refactoredapp.presentation.testRight package com.example.hpos.presentation.testRight
import android.os.Bundle import android.os.Bundle
import android.os.Handler import android.os.Handler
@@ -9,14 +9,12 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels import androidx.fragment.app.activityViewModels
import com.example.refactoredapp.R import com.example.hpos.R
import com.example.refactoredapp.data.DataHolder import com.example.hpos.data.constant.TestRightCommands
import com.example.refactoredapp.data.constant.Constants import com.example.hpos.data.model.PatientData
import com.example.refactoredapp.data.constant.TestRightCommands import com.example.hpos.data.model.TestRightResultType
import com.example.refactoredapp.data.model.PatientData import com.example.hpos.databinding.FragmentTestRightExpSampleBinding
import com.example.refactoredapp.data.model.TestRightResultType import com.example.hpos.presentation.UsbServiceListener
import com.example.refactoredapp.databinding.FragmentTestRightExpSampleBinding
import com.example.refactoredapp.presentation.UsbServiceListener
class TestRightExpSample : Fragment() { class TestRightExpSample : Fragment() {

View File

@@ -1,4 +1,4 @@
package com.example.refactoredapp.presentation.testRight package com.example.hpos.presentation.testRight
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
@@ -8,13 +8,13 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels import androidx.fragment.app.activityViewModels
import com.example.refactoredapp.R import com.example.hpos.R
import com.example.refactoredapp.data.DataHolder import com.example.hpos.data.DataHolder
import com.example.refactoredapp.data.constant.Constants import com.example.hpos.data.constant.Constants
import com.example.refactoredapp.data.model.TestRightResultType import com.example.hpos.data.model.TestRightResultType
import com.example.refactoredapp.databinding.FragmentTestRightResultsBinding import com.example.hpos.databinding.FragmentTestRightResultsBinding
import com.example.refactoredapp.presentation.MainActivity import com.example.hpos.presentation.MainActivity
import com.example.refactoredapp.util.MyUtils import com.example.hpos.util.MyUtils
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.* import java.util.*

View File

@@ -1,16 +1,18 @@
package com.example.refactoredapp.presentation.testRight package com.example.hpos.presentation.testRight
import android.util.Log import android.util.Log
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import com.example.refactoredapp.data.constant.Constants import com.example.hpos.data.constant.Constants
import com.example.refactoredapp.data.DataHolder import com.example.hpos.data.DataHolder
import com.example.refactoredapp.data.model.PatientData import com.example.hpos.data.model.CalculationVariableForTest
import com.example.refactoredapp.data.model.TestRightCalculationData import com.example.hpos.data.model.PatientData
import com.example.refactoredapp.data.model.TestRightDeviceConstants import com.example.hpos.data.model.TestRightCalculationData
import com.example.refactoredapp.domain.ResultCalculationWithMaxImpl import com.example.hpos.data.model.TestRightDeviceConstants
import com.example.refactoredapp.domain.SaveRawData import com.example.hpos.domain.ResultCalculationWithMaxImpl
import com.example.refactoredapp.domain.TestRightResultCalculation import com.example.hpos.domain.SaveRawData
import com.example.hpos.domain.SaveRawDataTest
import com.example.hpos.domain.TestRightResultCalculation
import java.lang.Exception import java.lang.Exception
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.* import java.util.*
@@ -41,7 +43,7 @@ class TestRightViewModel : ViewModel() {
// private val intensityReferenceArray = ArrayList<Double>() // private val intensityReferenceArray = ArrayList<Double>()
/* (For exp sample) Contains pixel no. -> Intensity of light falling on that pixel */ /* (For exp sample) Contains pixel no. -> Intensity of light falling on that pixel */
private val intensitySampleArray = ArrayList<Double>() val intensitySampleArray = ArrayList<Double>()
val wavelengthToAbsorbance = ArrayList<ArrayList<Double>>() val wavelengthToAbsorbance = ArrayList<ArrayList<Double>>()
@@ -186,7 +188,6 @@ class TestRightViewModel : ViewModel() {
// for ((index,wavelength) in wavelengthToPixelArray.withIndex()) { // for ((index,wavelength) in wavelengthToPixelArray.withIndex()) {
for (index in 0 until DataHolder.wavelengthToPixelArray.size) { for (index in 0 until DataHolder.wavelengthToPixelArray.size) {
// Todo: handle indexInIntensityArrays <0 // Todo: handle indexInIntensityArrays <0
val invertedPixelIndex = (Constants.TEST_RIGHT_TOTAL_PIXEL) - (index + 1) val invertedPixelIndex = (Constants.TEST_RIGHT_TOTAL_PIXEL) - (index + 1)

View File

@@ -1,4 +1,4 @@
package com.example.refactoredapp.presentation.testRight package com.example.hpos.presentation.testRight
import android.app.Service import android.app.Service
import android.content.Intent import android.content.Intent
@@ -6,9 +6,9 @@ import android.hardware.usb.UsbDeviceConnection
import android.os.Binder import android.os.Binder
import android.os.IBinder import android.os.IBinder
import android.util.Log import android.util.Log
import com.example.refactoredapp.data.constant.Constants import com.example.hpos.data.constant.Constants
import com.example.refactoredapp.data.constant.TestRightCommands import com.example.hpos.data.constant.TestRightCommands
import com.example.refactoredapp.presentation.UsbServiceListener import com.example.hpos.presentation.UsbServiceListener
import com.hoho.android.usbserial.driver.UsbSerialDriver import com.hoho.android.usbserial.driver.UsbSerialDriver
import com.hoho.android.usbserial.driver.UsbSerialPort import com.hoho.android.usbserial.driver.UsbSerialPort
import com.hoho.android.usbserial.util.SerialInputOutputManager import com.hoho.android.usbserial.util.SerialInputOutputManager

View File

@@ -1,4 +1,4 @@
package com.example.refactoredapp.presentation.utils package com.example.hpos.presentation.utils
interface MyDialogListener { interface MyDialogListener {
fun onClickBtnOne() fun onClickBtnOne()

View File

@@ -1,4 +1,4 @@
package com.example.refactoredapp.presentation.utils package com.example.hpos.presentation.utils
import android.content.Context import android.content.Context
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder

View File

@@ -1,11 +1,9 @@
package com.example.refactoredapp.util package com.example.hpos.util
import android.content.Context import android.content.Context
import android.os.Environment import android.os.Environment
import android.widget.Toast import com.example.hpos.R
import com.example.refactoredapp.R import com.example.hpos.data.model.DeviceType
import com.example.refactoredapp.data.DataHolder
import com.example.refactoredapp.data.model.DeviceType
import java.io.File import java.io.File
class MyUtils { class MyUtils {

View File

@@ -1,18 +1,16 @@
package com.example.refactoredapp.util package com.example.hpos.util
import android.content.Context import android.content.Context
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import com.example.refactoredapp.domain.ParseDenovixUseCase import com.example.hpos.presentation.MainViewModel
import com.example.refactoredapp.domain.ParseTestRightCSVUseCase import com.example.hpos.presentation.testRight.TestRightViewModel
import com.example.refactoredapp.presentation.MainViewModel
import com.example.refactoredapp.presentation.testRight.TestRightViewModel
class MyViewModelFactory(private val context: Context) : ViewModelProvider.Factory { class MyViewModelFactory(private val context: Context) : ViewModelProvider.Factory {
override fun <T : ViewModel> create(modelClass: Class<T>): T { override fun <T : ViewModel> create(modelClass: Class<T>): T {
if (modelClass.isAssignableFrom(MainViewModel::class.java)) if (modelClass.isAssignableFrom(MainViewModel::class.java))
return MainViewModel(ParseDenovixUseCase(), ParseTestRightCSVUseCase()) as T return MainViewModel() as T
else if (modelClass.isAssignableFrom(TestRightViewModel::class.java)) else if (modelClass.isAssignableFrom(TestRightViewModel::class.java))
return TestRightViewModel() as T return TestRightViewModel() as T
else else

View File

@@ -1,8 +0,0 @@
package com.example.refactoredapp.data
import com.example.refactoredapp.data.model.TestInfo
import java.io.File
interface Repository {
suspend fun saveToDatabase(info: TestInfo)
}

View File

@@ -1,10 +0,0 @@
package com.example.refactoredapp.domain
import com.example.refactoredapp.data.model.TestRightCalculationData
import com.example.refactoredapp.data.model.TestRightResultType
interface TestRightResultCalculation {
fun getResults(
wavelengthToAbsorbance: ArrayList<ArrayList<Double>>
): TestRightCalculationData
}

View File

@@ -1,24 +0,0 @@
package com.example.refactoredapp.presentation
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.example.refactoredapp.data.model.DeviceType
import com.example.refactoredapp.domain.ParseCSV
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import java.io.File
class MainViewModel(private val parseDenovix: ParseCSV, private val parseTestRight: ParseCSV) : ViewModel() {
var device = DeviceType.TestRight
var isStoragePermission = MutableLiveData<Boolean>(false)
// val resultsLiveData = MutableLiveData<ArrayList<DenovixData>>()
fun parseCSV(file: File){
viewModelScope.launch(Dispatchers.IO) {
parseDenovix.parseCSV(file)
}
}
}

View File

@@ -1,6 +1,7 @@
<resources xmlns:tools="http://schemas.android.com/tools"> <resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. --> <!-- Base application theme. -->
<style name="Theme.RefactoredApp" parent="Theme.MaterialComponents.Light.DarkActionBar"> <style name="Theme.HPOS" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- <style name="Theme.RefactoredApp" parent="Theme.MaterialComponents.Light.DarkActionBar">-->
<!-- Primary brand color. --> <!-- Primary brand color. -->
<!-- <item name="colorPrimary">@color/purple_200</item>--> <!-- <item name="colorPrimary">@color/purple_200</item>-->

View File

@@ -67,5 +67,6 @@
<string name="sicklecell_nconfirmatory">Sicklecell\nConfirmatory</string> <string name="sicklecell_nconfirmatory">Sicklecell\nConfirmatory</string>
<string name="sicklecell_screening">Sicklecell Screening</string> <string name="sicklecell_screening">Sicklecell Screening</string>
<string name="thalassemia">Thalassemia</string> <string name="thalassemia">Thalassemia</string>
<string name="usb_connection">USB Connection</string>
</resources> </resources>

View File

@@ -1,6 +1,7 @@
<resources xmlns:tools="http://schemas.android.com/tools"> <resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. --> <!-- Base application theme. -->
<style name="Theme.RefactoredApp" parent="Theme.MaterialComponents.Light.DarkActionBar"> <style name="Theme.HPOS" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- <style name="Theme.RefactoredApp" parent="Theme.MaterialComponents.Light.DarkActionBar">-->
<!-- Primary brand color. --> <!-- Primary brand color. -->
<item name="colorPrimary">@color/blue_app</item> <item name="colorPrimary">@color/blue_app</item>
<!-- <item name="colorPrimaryVariant">@color/purple_700</item>--> <!-- <item name="colorPrimaryVariant">@color/purple_700</item>-->

View File

@@ -1,4 +1,4 @@
package com.example.refactoredapp package com.example.hpos
import org.junit.Test import org.junit.Test

View File

@@ -1,4 +1,4 @@
package com.example.refactoredapp package com.example.hpos
class InputData { class InputData {
val inputRead = "0,1.69989422e-06,1.60642711e-01, 3.85754470e+02,0,0,1,0, FFF-EEEE-PPP-WW-YY-NNNN\nОК [01]" val inputRead = "0,1.69989422e-06,1.60642711e-01, 3.85754470e+02,0,0,1,0, FFF-EEEE-PPP-WW-YY-NNNN\nОК [01]"

View File

@@ -1,8 +1,10 @@
package com.example.refactoredapp package com.example.hpos
import com.example.refactoredapp.data.Constants import com.example.hpos.data.constant.Constants
import com.example.refactoredapp.data.model.PatientData import com.example.hpos.data.DataHolder
import com.example.refactoredapp.presentation.testRight.TestRightViewModel import com.example.hpos.data.model.PatientData
import com.example.hpos.data.model.TestRightResultType
import com.example.hpos.presentation.testRight.TestRightViewModel
import junit.framework.Assert.assertEquals import junit.framework.Assert.assertEquals
import org.junit.Test import org.junit.Test
@@ -13,10 +15,10 @@ class TestRightViewModelTest {
@Test @Test
fun testRightViewModel_mapDeviceConstants() { fun testRightViewModel_mapDeviceConstants() {
viewModel.mapDeviceConstants(data.inputRead) viewModel.mapDeviceConstants(data.inputRead)
assertEquals("0", viewModel.deviceConstant!!.a) assertEquals("0", DataHolder.deviceConstant!!.a)
assertEquals("1.69989422e-06", viewModel.deviceConstant!!.b) assertEquals("1.69989422e-06", DataHolder.deviceConstant!!.b)
assertEquals("1.60642711e-01", viewModel.deviceConstant!!.c) assertEquals("1.60642711e-01", DataHolder.deviceConstant!!.c)
assertEquals("3.85754470e+02", viewModel.deviceConstant!!.d) assertEquals("3.85754470e+02", DataHolder.deviceConstant!!.d)
} }
@Test @Test
@@ -24,13 +26,15 @@ class TestRightViewModelTest {
viewModel.mapDeviceConstants(data.inputRead) viewModel.mapDeviceConstants(data.inputRead)
viewModel.mapPixelNumberToWavelength() viewModel.mapPixelNumberToWavelength()
for (each in viewModel.wavelengthToPixelArray){ var i = 1
System.out.print(each[0]) for (each in DataHolder.wavelengthToPixelArray){
System.out.print(i)
System.out.print(" -> ") System.out.print(" -> ")
System.out.println(each[1]) System.out.println(each)
i++
} }
assertEquals(Constants.TEST_RIGHT_TOTAL_PIXEL, viewModel.wavelengthToPixelArray.size) assertEquals(Constants.TEST_RIGHT_TOTAL_PIXEL, DataHolder.wavelengthToPixelArray.size)
} }
@Test @Test
@@ -40,7 +44,7 @@ class TestRightViewModelTest {
viewModel.mapPixelNumberToWavelength() viewModel.mapPixelNumberToWavelength()
viewModel.mapIntensityValues(data.printForReference, true) viewModel.mapIntensityValues(data.printForReference, true)
viewModel.mapIntensityValues(data.printForSample, false) viewModel.mapIntensityValues(data.printForSample, false)
viewModel.patientDetails = PatientData("Surya", 2, "Male", null) viewModel.patientDetails = PatientData("Surya", 2, "Male", TestRightResultType.UNDEFINED)
viewModel.calculateResults() viewModel.calculateResults()
} }
@@ -55,27 +59,13 @@ class TestRightViewModelTest {
viewModel.mapIntensityValues(data.printForSample, false) viewModel.mapIntensityValues(data.printForSample, false)
// viewModel.patientDetails = PatientData("Surya", 2, "Male", null) // viewModel.patientDetails = PatientData("Surya", 2, "Male", null)
// viewModel.calculateResults() // viewModel.calculateResults()
viewModel.calculateDataForCSV() viewModel.mapWavelengthToAbsorbance()
for (each in viewModel.wavelengthToAbsorbance){ for (each in viewModel.wavelengthToAbsorbance){
println(each[0].toString() + " -> " + each[1]) println(each[0].toString() + " -> " + each[1])
} }
} }
// @Test
// fun testRightViewModel_mapIntensityValues() {
//
// viewModel.mapIntensityValues(data.fullStringPrint, true)
//
// for (each in viewModel.intensityReferenceArray){
// System.out.print(each[0])
// System.out.print(" -> ")
// System.out.println(each[1])
// }
//
// assertEquals(23, viewModel.intensityReferenceArray.size)
// }

View File

@@ -1,3 +1,13 @@
//buildscript {
// ext.kotlin_version = '1.6.21'
// dependencies {
// classpath 'com.android.tools.build:gradle:3.4.0'
// classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// }
// repositories {
// mavenCentral()
// }
//}
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
//buildscript { //buildscript {

View File

@@ -13,5 +13,5 @@ dependencyResolutionManagement {
maven { url 'https://jitpack.io' } maven { url 'https://jitpack.io' }
} }
} }
rootProject.name = "Refactored App" rootProject.name = "hpos"
include ':app' include ':app'