diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index 9c3bdf7..814ed65 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -46,6 +46,7 @@ dependencies {
ksp(libs.androidx.room.compiler)
annotationProcessor(libs.androidx.room.compiler)
implementation(libs.androidx.core.ktx)
+ implementation("androidx.room:room-ktx:2.6.1")
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.activity.compose)
implementation(platform(libs.androidx.compose.bom))
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 2492ae6..d3a5163 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -6,6 +6,7 @@
+ private var nfcCharacter = MutableStateFlow(null)
+
// EXTRACTED DIRECTLY FROM EXAMPLE APP
override fun onCreate(savedInstanceState: Bundle?) {
deviceToCryptographicTransformers = getMapOfCryptographicTransformers()
@@ -32,24 +48,45 @@ class MainActivity : ComponentActivity() {
}
nfcAdapter = maybeNfcAdapter
-
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContent {
VBHelperTheme {
- AppNavigation()
+ MainApplication()
}
}
}
+ @Composable
+ private fun MainApplication() {
+ var isDoneReadingCharacter by remember { mutableStateOf(false) }
+ val application = LocalContext.current.applicationContext as VBHelper
+ val storageRepository = application.container.db
+ AppNavigation(
+ isDoneReadingCharacter = isDoneReadingCharacter,
+ onClickRead = {
+ handleTag {
+ val character = it.receiveCharacter()
+ nfcCharacter.value = character
+ addCharacterScannedIntoDatabase()
+ isDoneReadingCharacter = true
+ "Done reading character"
+ }
+ },
+ onClickScan = {
+ isDoneReadingCharacter = false
+ }
+ )
+ }
+
// EXTRACTED DIRECTLY FROM EXAMPLE APP
private fun getMapOfCryptographicTransformers(): Map {
return mapOf(
Pair(DeviceType.VitalBraceletBEDeviceType,
- CryptographicTransformer(readableHmacKey1 = resources.getString(com.github.cfogrady.vbnfc.R.string.password1),
- readableHmacKey2 = resources.getString(com.github.cfogrady.vbnfc.R.string.password2),
- aesKey = resources.getString(com.github.cfogrady.vbnfc.R.string.decryptionKey),
- substitutionCipher = resources.getIntArray(com.github.cfogrady.vbnfc.R.array.substitutionArray))),
+ CryptographicTransformer(readableHmacKey1 = resources.getString(R.string.password1),
+ readableHmacKey2 = resources.getString(R.string.password2),
+ aesKey = resources.getString(R.string.decryptionKey),
+ substitutionCipher = resources.getIntArray(R.array.substitutionArray))),
// Pair(DeviceType.VitalSeriesDeviceType,
// CryptographicTransformer(hmacKey1 = resources.getString(R.string.password1),
// hmacKey2 = resources.getString(R.string.password2),
@@ -110,4 +147,88 @@ class MainActivity : ComponentActivity() {
nfcAdapter.disableReaderMode(this)
}
}
+
+ //
+ /*
+ TODO:
+ - Make it able to detect the different model of watches
+ - Support for regular VB
+
+ The good news is that the theory behind inserting to the database should be working
+ now, it's a matter of implementing the functionality to parse dim/bem cards and use my
+ domain model.
+ */
+ private fun addCharacterScannedIntoDatabase() {
+ val beCharacter = nfcCharacter as MutableStateFlow
+ val temporaryCharacterData = TemporaryCharacterData(
+ dimId = nfcCharacter.value!!.dimId.toInt(),
+ charIndex = nfcCharacter.value!!.charIndex.toInt(),
+ stage = nfcCharacter.value!!.stage.toInt(),
+ attribute = nfcCharacter.value!!.attribute,
+ ageInDays = nfcCharacter.value!!.ageInDays.toInt(),
+ nextAdventureMissionStage = nfcCharacter.value!!.nextAdventureMissionStage.toInt(),
+ mood = nfcCharacter.value!!.mood.toInt(),
+ vitalPoints = nfcCharacter.value!!.vitalPoints.toInt(),
+ transformationCountdown = nfcCharacter.value!!.transformationCountdown.toInt(),
+ injuryStatus = nfcCharacter.value!!.injuryStatus,
+ trophies = nfcCharacter.value!!.trophies.toInt(),
+ currentPhaseBattlesWon = nfcCharacter.value!!.currentPhaseBattlesWon.toInt(),
+ currentPhaseBattlesLost = nfcCharacter.value!!.currentPhaseBattlesLost.toInt(),
+ totalBattlesWon = nfcCharacter.value!!.totalBattlesWon.toInt(),
+ totalBattlesLost = nfcCharacter.value!!.totalBattlesLost.toInt(),
+ activityLevel = nfcCharacter.value!!.activityLevel.toInt(),
+ heartRateCurrent = nfcCharacter.value!!.heartRateCurrent.toInt()
+ )
+
+ val application = applicationContext as VBHelper
+ val storageRepository = application.container.db
+ val characterId = storageRepository
+ .temporaryMonsterDao()
+ .insertCharacterData(temporaryCharacterData)
+
+ val temporaryBECharacterData = TemporaryBECharacterData(
+ id = characterId,
+ trainingHp = beCharacter.value!!.trainingHp.toInt(),
+ trainingAp = beCharacter.value!!.trainingAp.toInt(),
+ trainingBp = beCharacter.value!!.trainingBp.toInt(),
+ remainingTrainingTimeInMinutes = beCharacter.value!!.remainingTrainingTimeInMinutes.toInt(),
+ itemEffectActivityLevelValue = beCharacter.value!!.itemEffectActivityLevelValue.toInt(),
+ itemEffectMentalStateValue = beCharacter.value!!.itemEffectMentalStateValue.toInt(),
+ itemEffectMentalStateMinutesRemaining = beCharacter.value!!.itemEffectMentalStateMinutesRemaining.toInt(),
+ itemEffectActivityLevelMinutesRemaining = beCharacter.value!!.itemEffectActivityLevelMinutesRemaining.toInt(),
+ itemEffectVitalPointsChangeValue = beCharacter.value!!.itemEffectVitalPointsChangeValue.toInt(),
+ itemEffectVitalPointsChangeMinutesRemaining = beCharacter.value!!.itemEffectVitalPointsChangeMinutesRemaining.toInt(),
+ abilityRarity = beCharacter.value!!.abilityRarity,
+ abilityType = beCharacter.value!!.abilityType.toInt(),
+ abilityBranch = beCharacter.value!!.abilityBranch.toInt(),
+ abilityReset = beCharacter.value!!.abilityReset.toInt(),
+ rank = beCharacter.value!!.abilityReset.toInt(),
+ itemType = beCharacter.value!!.itemType.toInt(),
+ itemMultiplier = beCharacter.value!!.itemMultiplier.toInt(),
+ itemRemainingTime = beCharacter.value!!.itemRemainingTime.toInt(),
+ otp0 = "", //beCharacter.value!!.otp0.toString(),
+ otp1 = "", //beCharacter.value!!.otp1.toString(),
+ minorVersion = beCharacter.value!!.characterCreationFirmwareVersion.minorVersion.toInt(),
+ majorVersion = beCharacter.value!!.characterCreationFirmwareVersion.majorVersion.toInt(),
+ )
+
+ storageRepository
+ .temporaryMonsterDao()
+ .insertBECharacterData(temporaryBECharacterData)
+
+ val transformationHistoryWatch = beCharacter.value!!.transformationHistory
+ val domainTransformationHistory = transformationHistoryWatch.map { item ->
+ TemporaryTransformationHistory(
+ monId = characterId,
+ toCharIndex = item.toCharIndex.toInt(),
+ yearsSince1988 = item.yearsSince1988.toInt(),
+ month = item.month.toInt(),
+ day = item.day.toInt()
+ )
+ }
+
+ storageRepository
+ .temporaryMonsterDao()
+ .insertTransformationHistory(*domainTransformationHistory.toTypedArray())
+ }
}
diff --git a/app/src/main/java/com/github/nacabaro/vbhelper/daos/DiMDao.kt b/app/src/main/java/com/github/nacabaro/vbhelper/daos/DiMDao.kt
new file mode 100644
index 0000000..a2e7d84
--- /dev/null
+++ b/app/src/main/java/com/github/nacabaro/vbhelper/daos/DiMDao.kt
@@ -0,0 +1,16 @@
+package com.github.nacabaro.vbhelper.daos
+
+import androidx.room.Dao
+import androidx.room.Insert
+import androidx.room.Query
+import com.github.nacabaro.vbhelper.domain.Dim
+import kotlinx.coroutines.flow.Flow
+
+@Dao
+interface DiMDao {
+ @Insert
+ suspend fun insertNewDim(dim: Dim)
+
+ @Query("SELECT * FROM Dim")
+ fun getAllDims(): Flow>
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/github/nacabaro/vbhelper/daos/DiMProgressDao.kt b/app/src/main/java/com/github/nacabaro/vbhelper/daos/DiMProgressDao.kt
new file mode 100644
index 0000000..7f6c913
--- /dev/null
+++ b/app/src/main/java/com/github/nacabaro/vbhelper/daos/DiMProgressDao.kt
@@ -0,0 +1,11 @@
+package com.github.nacabaro.vbhelper.daos
+
+import androidx.room.Dao
+import androidx.room.Upsert
+import com.github.nacabaro.vbhelper.domain.DimProgress
+
+@Dao
+interface DiMProgressDao {
+ @Upsert
+ suspend fun updateDimProgress(vararg dimProgress: DimProgress)
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/github/nacabaro/vbhelper/daos/UserMonstersDao.kt b/app/src/main/java/com/github/nacabaro/vbhelper/daos/UserMonstersDao.kt
new file mode 100644
index 0000000..c98edfe
--- /dev/null
+++ b/app/src/main/java/com/github/nacabaro/vbhelper/daos/UserMonstersDao.kt
@@ -0,0 +1,15 @@
+package com.github.nacabaro.vbhelper.daos
+
+import androidx.room.Dao
+import androidx.room.Insert
+import androidx.room.Query
+import com.github.nacabaro.vbhelper.domain.UserMonsters
+
+@Dao
+interface UserMonstersDao {
+ @Insert
+ fun insertUserMonsters(userMonsters: UserMonsters)
+
+ @Query("SELECT * FROM UserMonsters WHERE userId = :userId")
+ fun getUserMonsters(userId: Int): List
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/github/nacabaro/vbhelper/daos/UserMonstersTransformationHistoryDao.kt b/app/src/main/java/com/github/nacabaro/vbhelper/daos/UserMonstersTransformationHistoryDao.kt
new file mode 100644
index 0000000..fff417d
--- /dev/null
+++ b/app/src/main/java/com/github/nacabaro/vbhelper/daos/UserMonstersTransformationHistoryDao.kt
@@ -0,0 +1,11 @@
+package com.github.nacabaro.vbhelper.daos
+
+import androidx.room.Dao
+import androidx.room.Insert
+import com.github.nacabaro.vbhelper.temporary_domain.TemporaryTransformationHistory
+
+@Dao
+interface UserMonstersTransformationHistoryDao {
+ @Insert
+ fun insertTransformations(vararg transformations: TemporaryTransformationHistory)
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/github/nacabaro/vbhelper/database/AppDatabase.kt b/app/src/main/java/com/github/nacabaro/vbhelper/database/AppDatabase.kt
new file mode 100644
index 0000000..c143009
--- /dev/null
+++ b/app/src/main/java/com/github/nacabaro/vbhelper/database/AppDatabase.kt
@@ -0,0 +1,21 @@
+package com.github.nacabaro.vbhelper.database
+
+import androidx.room.Database
+import androidx.room.RoomDatabase
+import com.github.nacabaro.vbhelper.temporary_daos.TemporaryMonsterDao
+import com.github.nacabaro.vbhelper.temporary_domain.TemporaryBECharacterData
+import com.github.nacabaro.vbhelper.temporary_domain.TemporaryCharacterData
+import com.github.nacabaro.vbhelper.temporary_domain.TemporaryTransformationHistory
+
+@Database(
+ version = 1,
+ entities = [
+ TemporaryCharacterData::class,
+ TemporaryBECharacterData::class,
+ TemporaryTransformationHistory::class
+ ]
+)
+abstract class AppDatabase : RoomDatabase() {
+ abstract fun temporaryMonsterDao(): TemporaryMonsterDao
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/github/nacabaro/vbhelper/di/AppContainer.kt b/app/src/main/java/com/github/nacabaro/vbhelper/di/AppContainer.kt
new file mode 100644
index 0000000..239b946
--- /dev/null
+++ b/app/src/main/java/com/github/nacabaro/vbhelper/di/AppContainer.kt
@@ -0,0 +1,7 @@
+package com.github.nacabaro.vbhelper.di
+
+import com.github.nacabaro.vbhelper.database.AppDatabase
+
+interface AppContainer {
+ val db: AppDatabase
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/github/nacabaro/vbhelper/di/DefaultAppContainer.kt b/app/src/main/java/com/github/nacabaro/vbhelper/di/DefaultAppContainer.kt
new file mode 100644
index 0000000..f83cfa8
--- /dev/null
+++ b/app/src/main/java/com/github/nacabaro/vbhelper/di/DefaultAppContainer.kt
@@ -0,0 +1,14 @@
+import android.content.Context
+import androidx.room.Room
+import com.github.nacabaro.vbhelper.database.AppDatabase
+import com.github.nacabaro.vbhelper.di.AppContainer
+
+class DefaultAppContainer(private val context: Context) : AppContainer {
+ override val db: AppDatabase by lazy {
+ Room.databaseBuilder(
+ context = context,
+ klass = AppDatabase::class.java,
+ "internalDb"
+ ).build()
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/github/nacabaro/vbhelper/di/VBHelper.kt b/app/src/main/java/com/github/nacabaro/vbhelper/di/VBHelper.kt
new file mode 100644
index 0000000..0c66c99
--- /dev/null
+++ b/app/src/main/java/com/github/nacabaro/vbhelper/di/VBHelper.kt
@@ -0,0 +1,13 @@
+package com.github.nacabaro.vbhelper.di
+
+import DefaultAppContainer
+import android.app.Application
+
+class VBHelper : Application() {
+ lateinit var container: DefaultAppContainer
+
+ override fun onCreate() {
+ super.onCreate()
+ container = DefaultAppContainer(applicationContext)
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/github/nacabaro/vbhelper/dtos/MonsterDataCombined.kt b/app/src/main/java/com/github/nacabaro/vbhelper/dtos/MonsterDataCombined.kt
new file mode 100644
index 0000000..cebf6f4
--- /dev/null
+++ b/app/src/main/java/com/github/nacabaro/vbhelper/dtos/MonsterDataCombined.kt
@@ -0,0 +1,4 @@
+package com.github.nacabaro.vbhelper.dtos
+
+class MonsterDataCombined {
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/github/nacabaro/vbhelper/navigation/AppNavigation.kt b/app/src/main/java/com/github/nacabaro/vbhelper/navigation/AppNavigation.kt
index cd2f9cc..828bfcc 100644
--- a/app/src/main/java/com/github/nacabaro/vbhelper/navigation/AppNavigation.kt
+++ b/app/src/main/java/com/github/nacabaro/vbhelper/navigation/AppNavigation.kt
@@ -14,7 +14,11 @@ import com.github.nacabaro.vbhelper.screens.ScanScreen
import com.github.nacabaro.vbhelper.screens.StorageScreen
@Composable
-fun AppNavigation() {
+fun AppNavigation(
+ onClickRead: () -> Unit,
+ onClickScan: () -> Unit,
+ isDoneReadingCharacter: Boolean
+) {
val navController = rememberNavController()
Scaffold(
@@ -38,7 +42,12 @@ fun AppNavigation() {
StorageScreen()
}
composable(BottomNavItem.Scan.route) {
- ScanScreen()
+ onClickScan()
+ ScanScreen(
+ navController = navController,
+ onClickRead = onClickRead,
+ isDoneReadingCharacter = isDoneReadingCharacter
+ )
}
composable(BottomNavItem.Dex.route) {
DexScreen()
diff --git a/app/src/main/java/com/github/nacabaro/vbhelper/screens/ScanScreen.kt b/app/src/main/java/com/github/nacabaro/vbhelper/screens/ScanScreen.kt
index 0f1d69b..98f5bba 100644
--- a/app/src/main/java/com/github/nacabaro/vbhelper/screens/ScanScreen.kt
+++ b/app/src/main/java/com/github/nacabaro/vbhelper/screens/ScanScreen.kt
@@ -10,17 +10,52 @@ import androidx.compose.material3.Button
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
+import androidx.navigation.NavController
+import androidx.navigation.compose.rememberNavController
import com.github.nacabaro.vbhelper.components.TopBanner
+import com.github.nacabaro.vbhelper.navigation.BottomNavItem
+import com.github.nacabaro.vbhelper.screens.scanScreen.ReadingCharacterScreen
@Composable
-fun ScanScreen() {
- Scaffold (
- topBar = { TopBanner(text = "Scan a Vital Bracelet") }
+fun ScanScreen(
+ navController: NavController,
+ onClickRead: () -> Unit,
+ isDoneReadingCharacter: Boolean
+) {
+ var readingScreen by remember { mutableStateOf(false) }
+
+ if (isDoneReadingCharacter) {
+ readingScreen = false
+ navController.navigate(BottomNavItem.Home.route)
+ }
+
+ if (readingScreen) {
+ ReadingCharacterScreen { readingScreen = false }
+ } else {
+ ChooseConnectOption(
+ onClickRead = {
+ readingScreen = true
+ onClickRead()
+ },
+ )
+ }
+}
+
+@Composable
+private fun ChooseConnectOption(
+ onClickRead: () -> Unit,
+) {
+ Scaffold(
+ topBar = { TopBanner(text = "Scan a Vital Bracelet") }
) { contentPadding ->
Column(
verticalArrangement = Arrangement.Center,
@@ -31,7 +66,7 @@ fun ScanScreen() {
) {
ScanButton(
text = "Vital Bracelet to App",
- onClick = {}
+ onClick = onClickRead
)
Spacer(modifier = Modifier.height(16.dp))
ScanButton(
@@ -42,6 +77,7 @@ fun ScanScreen() {
}
}
+
@Composable
fun ScanButton(
text: String,
@@ -64,5 +100,9 @@ fun ScanButton(
@Preview(showBackground = true)
@Composable
fun ScanScreenPreview() {
- ScanScreen()
+ ScanScreen(
+ navController = rememberNavController(),
+ onClickRead = { },
+ isDoneReadingCharacter = false
+ )
}
\ No newline at end of file
diff --git a/app/src/main/java/com/github/nacabaro/vbhelper/screens/StorageScreen.kt b/app/src/main/java/com/github/nacabaro/vbhelper/screens/StorageScreen.kt
index d0bc9b2..30e100b 100644
--- a/app/src/main/java/com/github/nacabaro/vbhelper/screens/StorageScreen.kt
+++ b/app/src/main/java/com/github/nacabaro/vbhelper/screens/StorageScreen.kt
@@ -1,5 +1,6 @@
package com.github.nacabaro.vbhelper.screens
+import android.util.Log
import androidx.compose.foundation.Image
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.gestures.scrollable
@@ -9,35 +10,75 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
+import androidx.compose.foundation.lazy.grid.items
import androidx.compose.foundation.rememberScrollState
import androidx.compose.material3.Card
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateListOf
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
+import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.github.nacabaro.vbhelper.R
import com.github.nacabaro.vbhelper.components.TopBanner
+import com.github.nacabaro.vbhelper.di.VBHelper
+import com.github.nacabaro.vbhelper.source.StorageRepository
+import com.github.nacabaro.vbhelper.temporary_domain.TemporaryCharacterData
+import kotlinx.coroutines.coroutineScope
+import kotlinx.coroutines.launch
+
@Composable
fun StorageScreen() {
+ val coroutineScope = rememberCoroutineScope()
+ val application = LocalContext.current.applicationContext as VBHelper
+ val storageRepository = StorageRepository(application.container.db)
+ val monList = remember { mutableStateListOf() }
+
+
+ LaunchedEffect(storageRepository) {
+ coroutineScope.launch {
+ monList.clear()
+ monList.addAll(storageRepository.getAllCharacters())
+ Log.d("StorageScreen", "Updated data: $monList")
+ }
+ }
+
+ Log.d("StorageScreen", "monList: $monList")
+
Scaffold (
topBar = { TopBanner(text = "My Digimon") }
) { contentPadding ->
+ if (monList.isEmpty()) {
+ Text(
+ text = "Nothing to see here",
+ modifier = Modifier
+ .padding(8.dp)
+ )
+ }
+
LazyVerticalGrid(
columns = GridCells.Fixed(3),
modifier = Modifier
.scrollable(state = rememberScrollState(), orientation = Orientation.Vertical)
.padding(top = contentPadding.calculateTopPadding())
) {
- items(100) { i ->
+ items(monList) { index ->
StorageEntry(
- name = "Digimon $i",
- icon = R.drawable.baseline_question_mark_24
+ name = index.dimId.toString() + " - " + index.charIndex.toString(),
+ icon = R.drawable.ic_launcher_foreground,
+ modifier = Modifier
+ .padding(8.dp)
)
}
}
diff --git a/app/src/main/java/com/github/nacabaro/vbhelper/screens/scanScreen/ReadingCharacter.kt b/app/src/main/java/com/github/nacabaro/vbhelper/screens/scanScreen/ReadingCharacter.kt
new file mode 100644
index 0000000..9c7a2dc
--- /dev/null
+++ b/app/src/main/java/com/github/nacabaro/vbhelper/screens/scanScreen/ReadingCharacter.kt
@@ -0,0 +1,41 @@
+package com.github.nacabaro.vbhelper.screens.scanScreen
+
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.padding
+import androidx.compose.material3.Button
+import androidx.compose.material3.Scaffold
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.unit.dp
+import com.github.nacabaro.vbhelper.components.TopBanner
+
+@Composable
+fun ReadingCharacterScreen(
+ onClickCancel: () -> Unit,
+) {
+ Scaffold (
+ topBar = {
+ TopBanner("Reading Character")
+ }
+ ) { innerPadding ->
+ Column (
+ horizontalAlignment = Alignment.CenterHorizontally,
+ verticalArrangement = Arrangement.Center,
+ modifier = Modifier
+ .padding(innerPadding)
+ .fillMaxSize()
+ ) {
+ Text("Place your Vital Bracelet near the reader...")
+ Button(
+ onClick = onClickCancel,
+ modifier = Modifier.padding(16.dp)
+ ) {
+ Text("Cancel")
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/github/nacabaro/vbhelper/source/StorageRepository.kt b/app/src/main/java/com/github/nacabaro/vbhelper/source/StorageRepository.kt
new file mode 100644
index 0000000..bf3e035
--- /dev/null
+++ b/app/src/main/java/com/github/nacabaro/vbhelper/source/StorageRepository.kt
@@ -0,0 +1,12 @@
+package com.github.nacabaro.vbhelper.source
+
+import com.github.nacabaro.vbhelper.database.AppDatabase
+import com.github.nacabaro.vbhelper.temporary_domain.TemporaryCharacterData
+
+class StorageRepository (
+ private val db: AppDatabase
+) {
+ suspend fun getAllCharacters(): List {
+ return db.temporaryMonsterDao().getAllCharacters()
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/github/nacabaro/vbhelper/temporary_daos/TemporaryMonsterDao.kt b/app/src/main/java/com/github/nacabaro/vbhelper/temporary_daos/TemporaryMonsterDao.kt
new file mode 100644
index 0000000..33283ab
--- /dev/null
+++ b/app/src/main/java/com/github/nacabaro/vbhelper/temporary_daos/TemporaryMonsterDao.kt
@@ -0,0 +1,27 @@
+package com.github.nacabaro.vbhelper.temporary_daos
+
+import androidx.room.Dao
+import androidx.room.Insert
+import androidx.room.OnConflictStrategy
+import androidx.room.Query
+import com.github.nacabaro.vbhelper.temporary_domain.TemporaryBECharacterData
+import com.github.nacabaro.vbhelper.temporary_domain.TemporaryCharacterData
+import com.github.nacabaro.vbhelper.temporary_domain.TemporaryTransformationHistory
+
+@Dao
+interface TemporaryMonsterDao {
+ @Insert
+ fun insertCharacterData(temporaryCharacterData: TemporaryCharacterData): Int
+
+ @Insert
+ fun insertBECharacterData(temporaryBECharacterData: TemporaryBECharacterData)
+
+ @Insert(onConflict = OnConflictStrategy.REPLACE)
+ fun insertTransformationHistory(vararg transformationHistory: TemporaryTransformationHistory)
+
+ @Query("SELECT * FROM TemporaryTransformationHistory WHERE monId = :monId")
+ fun getTransformationHistory(monId: Int): List
+
+ @Query("SELECT * FROM TemporaryCharacterData")
+ suspend fun getAllCharacters(): List
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/github/nacabaro/vbhelper/temporary_domain/TemporaryBECharacterData.kt b/app/src/main/java/com/github/nacabaro/vbhelper/temporary_domain/TemporaryBECharacterData.kt
new file mode 100644
index 0000000..f7e2674
--- /dev/null
+++ b/app/src/main/java/com/github/nacabaro/vbhelper/temporary_domain/TemporaryBECharacterData.kt
@@ -0,0 +1,44 @@
+package com.github.nacabaro.vbhelper.temporary_domain
+
+import androidx.room.Entity
+import androidx.room.ForeignKey
+import androidx.room.PrimaryKey
+import com.github.cfogrady.vbnfc.be.BENfcCharacter
+import com.github.cfogrady.vbnfc.be.FirmwareVersion
+import com.github.cfogrady.vbnfc.data.NfcCharacter
+
+@Entity(
+ foreignKeys = [
+ ForeignKey(
+ entity = TemporaryCharacterData::class,
+ parentColumns = ["id"],
+ childColumns = ["id"],
+ onDelete = ForeignKey.CASCADE
+ )
+ ]
+)
+data class TemporaryBECharacterData (
+ @PrimaryKey(autoGenerate = true) val id: Int,
+ val trainingHp: Int,
+ val trainingAp: Int,
+ val trainingBp: Int,
+ val remainingTrainingTimeInMinutes: Int,
+ val itemEffectMentalStateValue: Int,
+ val itemEffectMentalStateMinutesRemaining: Int,
+ val itemEffectActivityLevelValue: Int,
+ val itemEffectActivityLevelMinutesRemaining: Int,
+ val itemEffectVitalPointsChangeValue: Int,
+ val itemEffectVitalPointsChangeMinutesRemaining: Int,
+ val abilityRarity: NfcCharacter.AbilityRarity,
+ val abilityType: Int,
+ val abilityBranch: Int,
+ val abilityReset: Int,
+ val rank: Int,
+ val itemType: Int,
+ val itemMultiplier: Int,
+ val itemRemainingTime: Int,
+ val otp0: String,
+ val otp1: String,
+ val minorVersion: Int,
+ val majorVersion: Int,
+)
\ No newline at end of file
diff --git a/app/src/main/java/com/github/nacabaro/vbhelper/temporary_domain/TemporaryCharacterData.kt b/app/src/main/java/com/github/nacabaro/vbhelper/temporary_domain/TemporaryCharacterData.kt
new file mode 100644
index 0000000..e3cc6b6
--- /dev/null
+++ b/app/src/main/java/com/github/nacabaro/vbhelper/temporary_domain/TemporaryCharacterData.kt
@@ -0,0 +1,27 @@
+package com.github.nacabaro.vbhelper.temporary_domain
+
+import androidx.room.Entity
+import androidx.room.PrimaryKey
+import com.github.cfogrady.vbnfc.data.NfcCharacter
+
+@Entity
+data class TemporaryCharacterData (
+ @PrimaryKey(autoGenerate = true) val id: Int = 0,
+ val dimId: Int,
+ var charIndex: Int,
+ var stage: Int,
+ var attribute: NfcCharacter.Attribute,
+ var ageInDays: Int,
+ var nextAdventureMissionStage: Int, // next adventure mission stage on the character's dim
+ var mood: Int,
+ var vitalPoints: Int,
+ var transformationCountdown: Int,
+ var injuryStatus: NfcCharacter.InjuryStatus,
+ var trophies: Int,
+ var currentPhaseBattlesWon: Int,
+ var currentPhaseBattlesLost: Int,
+ var totalBattlesWon: Int,
+ var totalBattlesLost: Int,
+ var activityLevel: Int,
+ var heartRateCurrent: Int,
+)
\ No newline at end of file
diff --git a/app/src/main/java/com/github/nacabaro/vbhelper/temporary_domain/TemporaryTransformationHistory.kt b/app/src/main/java/com/github/nacabaro/vbhelper/temporary_domain/TemporaryTransformationHistory.kt
new file mode 100644
index 0000000..75ed5ca
--- /dev/null
+++ b/app/src/main/java/com/github/nacabaro/vbhelper/temporary_domain/TemporaryTransformationHistory.kt
@@ -0,0 +1,25 @@
+package com.github.nacabaro.vbhelper.temporary_domain
+
+import androidx.room.Entity
+import androidx.room.ForeignKey
+import androidx.room.PrimaryKey
+
+@Entity(
+ foreignKeys = [
+ ForeignKey(
+ entity = TemporaryCharacterData::class,
+ parentColumns = ["id"],
+ childColumns = ["monId"],
+ onDelete = ForeignKey.CASCADE
+ )
+ ]
+)
+// Bit lazy, will correct later...
+data class TemporaryTransformationHistory (
+ @PrimaryKey(autoGenerate = true) val id: Int = 0,
+ val monId: Int,
+ val toCharIndex: Int,
+ val yearsSince1988: Int,
+ val month: Int,
+ val day: Int
+)
diff --git a/app/src/main/java/com/github/nacabaro/vbhelper/vm/StorageViewModel.kt b/app/src/main/java/com/github/nacabaro/vbhelper/vm/StorageViewModel.kt
new file mode 100644
index 0000000..9b01721
--- /dev/null
+++ b/app/src/main/java/com/github/nacabaro/vbhelper/vm/StorageViewModel.kt
@@ -0,0 +1,2 @@
+package com.github.nacabaro.vbhelper.vm
+
diff --git a/vb-nfc-reader/src/main/java/com/github/cfogrady/vbnfc/TagCommunicator.kt b/vb-nfc-reader/src/main/java/com/github/cfogrady/vbnfc/TagCommunicator.kt
index 1e9860c..51c6ae9 100644
--- a/vb-nfc-reader/src/main/java/com/github/cfogrady/vbnfc/TagCommunicator.kt
+++ b/vb-nfc-reader/src/main/java/com/github/cfogrady/vbnfc/TagCommunicator.kt
@@ -69,8 +69,9 @@ class TagCommunicator(
checksumCalculator.checkChecksums(decryptedCharacterData)
val nfcCharacter = translator.parseNfcCharacter(decryptedCharacterData)
Log.i(TAG, "Known Character Stats: $nfcCharacter")
- Log.i(TAG, "Signaling operation complete")
- nfcData.transceive(translator.getOperationCommandBytes(header, OPERATION_TRANSFERRED_TO_APP))
+ // Not ready to lose any of my mons in this...
+ //Log.i(TAG, "Signaling operation complete")
+ //nfcData.transceive(translator.getOperationCommandBytes(header, OPERATION_TRANSFERRED_TO_APP))
return nfcCharacter
}