Compare commits

..

No commits in common. "4b866aad8acb21918225eb4f770b8619b9fd58a7" and "81bfec5ac5d31073efeaace9c9fc3485d31c1e63" have entirely different histories.

4 changed files with 17 additions and 14 deletions

View File

@ -45,12 +45,11 @@ class HomeScreenControllerImpl(
.clearSpecialMission(missionId)
if (missionStatus.status == SpecialMission.Status.COMPLETED) {
val allItems = database.itemDao().getAllItems().first()
if (allItems.isEmpty()) {
onCleared(null, null)
return@launch
}
val randomItem = allItems.random()
val randomItem = database
.itemDao()
.getAllItems()
.first()
.random()
val randomItemAmount = (Random.nextFloat() * 5).roundToInt()

View File

@ -142,7 +142,7 @@ fun VBDiMHomeScreen(
ItemDisplay(
icon = R.drawable.baseline_swords_24,
textValue = when {
activeMon.currentPhaseBattlesWon + activeMon.currentPhaseBattlesLost == 0 -> "0.00 %"
activeMon.totalBattlesLost == 0 -> "0.00 %"
else -> {
val battleWinPercentage =
activeMon.currentPhaseBattlesWon.toFloat() / (activeMon.currentPhaseBattlesWon + activeMon.currentPhaseBattlesLost).toFloat()
@ -150,7 +150,7 @@ fun VBDiMHomeScreen(
Locale.getDefault(),
"%.2f",
battleWinPercentage * 100
) + " %"
) + " %" // Specify locale
}
},
definition = stringResource(R.string.home_vbdim_current_phase_win),
@ -193,9 +193,9 @@ fun VBDiMHomeScreen(
onClickMission = { missionId ->
selectedSpecialMissionId = missionId
},
onClickCollect = { missionId ->
onClickCollect = {
homeScreenController
.clearSpecialMission(missionId, onClickCollect)
.clearSpecialMission(selectedSpecialMissionId, onClickCollect)
}
)
}

View File

@ -44,8 +44,14 @@ fun ScanScreen(
val context = LocalContext.current
LaunchedEffect(characterId) {
LaunchedEffect(storageRepository) {
withContext(Dispatchers.IO) {
/*
First check if there is a character sent through the navigation system
If there is not, that means we got here through the home screen nfc button
If we got here through the home screen, it does not hurt to check if there is
an active character.
*/
if (characterId != null && nfcCharacter == null) {
nfcCharacter = scanScreenController.characterToNfc(characterId)
}

View File

@ -231,9 +231,7 @@ class ScanScreenControllerImpl(
val proto = VitalWearCharacterExporter(componentActivity, database).buildCharacterProto(characterId)
val client = VitalWearHceReaderClient(isoDep)
client.sendCharacterToWatch(proto)
database.userCharacterDao().deleteCharacterById(characterId)
pendingExportCharacterId = null
Log.i("NFC_WRITE", "Character sent to VitalWear and deleted from app (id=$characterId)")
Log.i("NFC_WRITE", "Character sent to VitalWear via HCE")
componentActivity.runOnUiThread {
Toast.makeText(componentActivity, componentActivity.getString(R.string.scan_sent_character_success), Toast.LENGTH_SHORT).show()
}