diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 99c898f..9959b40 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -4,8 +4,8 @@ plugins { alias(libs.plugins.android.application) alias(libs.plugins.kotlin.android) alias(libs.plugins.kotlin.compose) - id("com.google.devtools.ksp") version "2.3.0" - id("com.google.protobuf") + alias(libs.plugins.vksp) + alias(libs.plugins.vprotobuf) } android { @@ -17,7 +17,7 @@ android { minSdk = 28 targetSdk = 36 versionCode = 1 - versionName = "Alpha 0.6.3" + versionName = "Alpha 0.6.4" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } @@ -90,6 +90,11 @@ dependencies { implementation(libs.androidx.ui.tooling.preview) implementation(libs.androidx.material3) implementation(libs.androidx.compose.material.icons.extended) + implementation(libs.play.services.wearable) + implementation(libs.kotlinx.coroutines.play.services) + implementation(libs.timber) + implementation(libs.tinylog.api) + implementation(libs.tinylog.impl) debugImplementation(libs.androidx.ui.tooling) debugImplementation(libs.androidx.ui.test.manifest) @@ -104,18 +109,10 @@ dependencies { androidTestImplementation(platform(libs.androidx.compose.bom)) androidTestImplementation(libs.androidx.ui.test.junit4) - debugImplementation(libs.androidx.ui.tooling) - debugImplementation(libs.androidx.ui.test.manifest) - implementation("androidx.navigation:navigation-compose:2.7.0") - implementation("com.google.android.material:material:1.2.0") - implementation(libs.protobuf.javalite) - implementation("androidx.compose.material:material") - implementation("androidx.datastore:datastore-preferences:1.1.7") - - implementation("com.squareup.retrofit2:retrofit:2.9.0") - implementation("com.squareup.retrofit2:converter-gson:2.9.0") - implementation("com.google.code.gson:gson:2.10.1") + implementation(libs.retrofit) + implementation(libs.retrofit.converter.gson) + implementation(libs.gson) // HTTP request logging - implementation("com.squareup.okhttp3:logging-interceptor:4.11.0") -} \ No newline at end of file + implementation(libs.okhttp.logging.interceptor) +} diff --git a/app/src/main/java/com/github/nacabaro/vbhelper/daos/CardDao.kt b/app/src/main/java/com/github/nacabaro/vbhelper/daos/CardDao.kt index b2d61e0..3fbca2a 100644 --- a/app/src/main/java/com/github/nacabaro/vbhelper/daos/CardDao.kt +++ b/app/src/main/java/com/github/nacabaro/vbhelper/daos/CardDao.kt @@ -13,6 +13,9 @@ interface CardDao { @Insert(onConflict = OnConflictStrategy.IGNORE) suspend fun insertNewCard(card: Card): Long + @Query("SELECT * FROM Card") + fun getAllCards(): List + @Query("SELECT * FROM Card WHERE cardId = :id") fun getCardByCardId(id: Int): List diff --git a/app/src/main/java/com/github/nacabaro/vbhelper/daos/UserCharacterDao.kt b/app/src/main/java/com/github/nacabaro/vbhelper/daos/UserCharacterDao.kt index 284bca9..680c162 100644 --- a/app/src/main/java/com/github/nacabaro/vbhelper/daos/UserCharacterDao.kt +++ b/app/src/main/java/com/github/nacabaro/vbhelper/daos/UserCharacterDao.kt @@ -131,6 +131,9 @@ interface UserCharacterDao { @Query("SELECT * FROM VBCharacterData WHERE id = :id") fun getVbData(id: Long): Flow + @Query("SELECT * FROM VBCharacterData WHERE id = :id") + suspend fun getVbDataOrNull(id: Long): VBCharacterData? + @Query("SELECT * FROM SpecialMissions WHERE characterId = :id") fun getSpecialMissions(id: Long): Flow> 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 index 7aa784c..d66595a 100644 --- a/app/src/main/java/com/github/nacabaro/vbhelper/database/AppDatabase.kt +++ b/app/src/main/java/com/github/nacabaro/vbhelper/database/AppDatabase.kt @@ -13,6 +13,8 @@ import com.github.nacabaro.vbhelper.daos.ItemDao import com.github.nacabaro.vbhelper.daos.SpecialMissionDao import com.github.nacabaro.vbhelper.daos.SpriteDao import com.github.nacabaro.vbhelper.daos.UserCharacterDao +import com.github.nacabaro.vbhelper.companion.validation.ValidatedCardDao +import com.github.nacabaro.vbhelper.companion.validation.ValidatedCardEntity import com.github.nacabaro.vbhelper.domain.card.Background import com.github.nacabaro.vbhelper.domain.card.CardCharacter import com.github.nacabaro.vbhelper.domain.card.Card @@ -50,7 +52,8 @@ import com.github.nacabaro.vbhelper.domain.items.Items Items::class, Adventure::class, Background::class, - PossibleTransformations::class + PossibleTransformations::class, + ValidatedCardEntity::class ] ) abstract class AppDatabase : RoomDatabase() { @@ -65,4 +68,5 @@ abstract class AppDatabase : RoomDatabase() { abstract fun specialMissionDao(): SpecialMissionDao abstract fun cardAdventureDao(): CardAdventureDao abstract fun cardFusionsDao(): CardFusionsDao + abstract fun validatedCardDao(): ValidatedCardDao } \ 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 index 2d82b95..d6f7088 100644 --- a/app/src/main/java/com/github/nacabaro/vbhelper/di/AppContainer.kt +++ b/app/src/main/java/com/github/nacabaro/vbhelper/di/AppContainer.kt @@ -3,9 +3,13 @@ package com.github.nacabaro.vbhelper.di import com.github.nacabaro.vbhelper.database.AppDatabase import com.github.nacabaro.vbhelper.source.CurrencyRepository import com.github.nacabaro.vbhelper.source.DataStoreSecretsRepository +import com.github.nacabaro.vbhelper.companion.validation.ValidatedCardManager +import com.github.nacabaro.vbhelper.companion.logs.CompanionLogService interface AppContainer { val db: AppDatabase val dataStoreSecretsRepository: DataStoreSecretsRepository val currencyRepository: CurrencyRepository + val validatedCardManager: ValidatedCardManager + val companionLogService: CompanionLogService } \ 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 index 70305b2..c15848e 100644 --- a/app/src/main/java/com/github/nacabaro/vbhelper/di/DefaultAppContainer.kt +++ b/app/src/main/java/com/github/nacabaro/vbhelper/di/DefaultAppContainer.kt @@ -8,6 +8,8 @@ import com.github.nacabaro.vbhelper.database.AppDatabase import com.github.nacabaro.vbhelper.di.AppContainer import com.github.nacabaro.vbhelper.source.CurrencyRepository import com.github.nacabaro.vbhelper.source.DataStoreSecretsRepository +import com.github.nacabaro.vbhelper.companion.validation.ValidatedCardManager +import com.github.nacabaro.vbhelper.companion.logs.CompanionLogService import com.github.nacabaro.vbhelper.source.SecretsSerializer import com.github.nacabaro.vbhelper.source.proto.Secrets @@ -37,5 +39,11 @@ class DefaultAppContainer(private val context: Context) : AppContainer { override val dataStoreSecretsRepository = DataStoreSecretsRepository(context.secretsStore) override val currencyRepository = CurrencyRepository(context.currencyStore) + + override val validatedCardManager by lazy { + ValidatedCardManager(db.validatedCardDao()) + } + + override val companionLogService = CompanionLogService() } 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 index 0c66c99..8e7b59b 100644 --- a/app/src/main/java/com/github/nacabaro/vbhelper/di/VBHelper.kt +++ b/app/src/main/java/com/github/nacabaro/vbhelper/di/VBHelper.kt @@ -2,10 +2,18 @@ package com.github.nacabaro.vbhelper.di import DefaultAppContainer import android.app.Application +import com.github.nacabaro.vbhelper.companion.validation.ValidatedCardManager +import com.github.nacabaro.vbhelper.companion.logs.CompanionLogService class VBHelper : Application() { lateinit var container: DefaultAppContainer + val validatedCardManager: ValidatedCardManager + get() = container.validatedCardManager + + val companionLogService: CompanionLogService + get() = container.companionLogService + override fun onCreate() { super.onCreate() container = DefaultAppContainer(applicationContext) diff --git a/app/src/main/java/com/github/nacabaro/vbhelper/source/DeviceTypeConverter.kt b/app/src/main/java/com/github/nacabaro/vbhelper/source/DeviceTypeConverter.kt index 6a97062..8783175 100644 --- a/app/src/main/java/com/github/nacabaro/vbhelper/source/DeviceTypeConverter.kt +++ b/app/src/main/java/com/github/nacabaro/vbhelper/source/DeviceTypeConverter.kt @@ -5,6 +5,7 @@ import com.github.nacabaro.vbhelper.domain.device_data.VBCharacterData import com.github.nacabaro.vbhelper.utils.DeviceType import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext +import timber.log.Timber /** * Utility for converting character device types. @@ -31,7 +32,7 @@ class DeviceTypeConverter(private val database: AppDatabase) { true } catch (e: Exception) { // Log but don't crash - character can still be sent as-is - android.util.Log.e("DeviceTypeConverter", "Failed to convert character $characterId to VB type", e) + Timber.e(e, "Failed to convert character $characterId to VB type") false } } @@ -42,7 +43,7 @@ class DeviceTypeConverter(private val database: AppDatabase) { val vbCharacterData = VBCharacterData( id = characterId, generation = 0, - totalTrophies = 0 + totalTrophies = 0, ) database.userCharacterDao().insertVBCharacterData(vbCharacterData) } diff --git a/app/src/main/proto/com/github/cfogrady/vitalwear/protos/Character.proto b/app/src/main/proto/com/github/cfogrady/vitalwear/protos/Character.proto index 263b4d8..a37c25f 100644 --- a/app/src/main/proto/com/github/cfogrady/vitalwear/protos/Character.proto +++ b/app/src/main/proto/com/github/cfogrady/vitalwear/protos/Character.proto @@ -23,6 +23,13 @@ message Character { int32 total_wins = 13; int32 current_phase_wins = 14; int32 mood = 15; + + enum TransferDeviceType { + TRANSFER_DEVICE_TYPE_UNSPECIFIED = 0; + TRANSFER_DEVICE_TYPE_VB = 1; + TRANSFER_DEVICE_TYPE_BE = 2; + } + TransferDeviceType transfer_device_type = 16; } CharacterStats character_stats = 3; diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 67db0c1..bfdd6c4 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -48,9 +48,6 @@ アドベンチャーミッション %1$d / %2$d のキャラクターを取得しました。 編集 - 編集 - 編集 - 編集 削除 フェーズ勝率 % スペシャルミッション @@ -92,7 +89,6 @@ オンラインバトル %1$d クレジットを獲得しました。 閉じる - 閉じる 図鑑 バイタルブレス本体を近くに置いて下さい。 キャンセル @@ -100,7 +96,6 @@ キャラクターアイコン 名前 リバースエンジニアリング - リバースエンジニアリング アプリケーション開発 " ファームウェアの解析を行い、開発をサポートしてくれました。" " vb-lib-nfc開発およびアプリの開発に協力して頂きました。" diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ac8a85d..8db8873 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -219,4 +219,17 @@ Dismiss Remove + Import Card Image + Connect Vital Bracelet + Card imported successfully! + No watch found! + Insert card into Vital Bracelet + Validation successful! + Select firmware file + Firmware sent successfully! + Failed to receive logs + Failed to request logs + Warning: Log transfer might take a while + Send Watch Logs + Transfer is currently disabled diff --git a/build.gradle.kts b/build.gradle.kts index 1662ff3..28f9d73 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,10 +3,6 @@ plugins { alias(libs.plugins.android.application) apply false alias(libs.plugins.kotlin.android) apply false alias(libs.plugins.kotlin.compose) apply false + alias(libs.plugins.vksp) apply false + alias(libs.plugins.vprotobuf) apply false } - -buildscript { - dependencies { - classpath(libs.protobuf.gradle.plugin) - } -} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 20e2a01..4540b75 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,4 +20,14 @@ kotlin.code.style=official # Enables namespacing of each library's R class so that its R class includes only the # resources declared in the library itself and none from the library's dependencies, # thereby reducing the size of the R class for that library -android.nonTransitiveRClass=true \ No newline at end of file +android.nonTransitiveRClass=true +android.defaults.buildfeatures.resvalues=true +android.sdk.defaultTargetSdkToCompileSdkIfUnset=false +android.enableAppCompileTimeRClass=false +android.usesSdkInManifest.disallowed=false +android.uniquePackageNames=false +android.dependency.useConstraints=true +android.r8.strictFullModeForKeepRules=false +android.r8.optimizedResourceShrinking=false +android.builtInKotlin=false +android.newDsl=false \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7e4875e..aebc19f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -agp = "8.13.2" +agp = "9.2.1" datastore = "1.2.0" datastorePreferences = "1.2.0" kotlin = "2.3.0" @@ -17,6 +17,14 @@ protobufJavalite = "4.33.4" roomRuntime = "2.8.4" vbNfcReader = "0.2.0-SNAPSHOT" dimReader = "2.1.0" +playServicesWearable = "20.0.1" +kotlinxCoroutinesPlayServices = "1.11.0" +timber = "5.0.1" +tinylog = "2.7.0" +retrofit = "2.9.0" +gson = "2.10.1" +okhttp = "4.11.0" +ksp = "2.3.2" [libraries] androidx-compose-material = { module = "androidx.compose.material:material" } @@ -46,9 +54,20 @@ protobuf-gradle-plugin = { module = "com.google.protobuf:protobuf-gradle-plugin" protobuf-javalite = { module = "com.google.protobuf:protobuf-javalite", version.ref = "protobufJavalite" } vb-nfc-reader = { module = "com.github.cfogrady:vb-nfc-reader", version.ref = "vbNfcReader" } dim-reader = { module = "com.github.cfogrady:vb-dim-reader", version.ref = "dimReader" } +play-services-wearable = { group = "com.google.android.gms", name = "play-services-wearable", version.ref = "playServicesWearable" } +kotlinx-coroutines-play-services = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-play-services", version.ref = "kotlinxCoroutinesPlayServices" } +timber = { module = "com.jakewharton.timber:timber", version.ref = "timber" } +tinylog-api = { module = "org.tinylog:tinylog-api", version.ref = "tinylog" } +tinylog-impl = { module = "org.tinylog:tinylog-impl", version.ref = "tinylog" } +retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" } +retrofit-converter-gson = { module = "com.squareup.retrofit2:converter-gson", version.ref = "retrofit" } +gson = { module = "com.google.code.gson:gson", version.ref = "gson" } +okhttp-logging-interceptor = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "okhttp" } [plugins] android-application = { id = "com.android.application", version.ref = "agp" } kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } +vksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } +vprotobuf = { id = "com.google.protobuf", version.ref = "protobufGradlePlugin" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2c9b214..ebefeb4 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Tue Dec 24 10:55:57 UTC 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists