diff --git a/mobile/build.gradle.kts b/mobile/build.gradle.kts
index 09f864a..99f9ba8 100644
--- a/mobile/build.gradle.kts
+++ b/mobile/build.gradle.kts
@@ -1,5 +1,6 @@
plugins {
alias(libs.plugins.android.application)
+ kotlin("plugin.serialization") version "2.2.20"
}
android {
@@ -47,4 +48,6 @@ dependencies {
androidTestImplementation(libs.androidx.junit)
implementation(libs.zxing.core)
implementation(libs.zxing.android)
+ implementation("com.google.android.gms:play-services-wearable:18.1.0")
+ implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.9.0")
}
\ No newline at end of file
diff --git a/mobile/src/main/ic_launcher-playstore.png b/mobile/src/main/ic_launcher-playstore.png
new file mode 100644
index 0000000..1042be9
Binary files /dev/null and b/mobile/src/main/ic_launcher-playstore.png differ
diff --git a/mobile/src/main/java/ru/omni_devel/cards/CardInfo.kt b/mobile/src/main/java/ru/omni_devel/cards/CardInfo.kt
index a8d9d64..6c2b210 100644
--- a/mobile/src/main/java/ru/omni_devel/cards/CardInfo.kt
+++ b/mobile/src/main/java/ru/omni_devel/cards/CardInfo.kt
@@ -1,7 +1,9 @@
package ru.omni_devel.cards
import com.google.zxing.BarcodeFormat
+import kotlinx.serialization.Serializable
+@Serializable
class CardInfo (
val id: Int,
val name: String,
diff --git a/mobile/src/main/java/ru/omni_devel/cards/MainActivity.kt b/mobile/src/main/java/ru/omni_devel/cards/MainActivity.kt
index 505c045..90c96f9 100644
--- a/mobile/src/main/java/ru/omni_devel/cards/MainActivity.kt
+++ b/mobile/src/main/java/ru/omni_devel/cards/MainActivity.kt
@@ -7,11 +7,13 @@ import android.widget.Button
import android.widget.LinearLayout
import android.widget.PopupMenu
import android.widget.TextView
+import android.widget.Toast
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.google.android.material.button.MaterialButton
+import kotlinx.serialization.json.Json
import org.w3c.dom.Text
class MainActivity : AppCompatActivity() {
@@ -32,9 +34,23 @@ class MainActivity : AppCompatActivity() {
cardsList = findViewById(R.id.cardsList)
val addCardButton: Button = findViewById(R.id.addCardButton)
+ val syncWithWearOSButton: Button = findViewById(R.id.syncWithWearOSButton)
+
addCardButton.setOnClickListener {
startActivity(Intent(this, AddCardActivity::class.java))
}
+
+ syncWithWearOSButton.setOnClickListener {
+ Toast.makeText(this, "Sync in progress...", Toast.LENGTH_SHORT).show()
+
+ val isSuccess = sendToWatch(this, "/updateCards", Json.encodeToString(db.getCards()))
+
+ if (isSuccess) {
+ Toast.makeText(this, "Synced!", Toast.LENGTH_SHORT).show()
+ } else {
+ Toast.makeText(this, "Sync failed! Please, check your connection", Toast.LENGTH_LONG).show()
+ }
+ }
}
override fun onResume() {
diff --git a/mobile/src/main/java/ru/omni_devel/cards/Utils.kt b/mobile/src/main/java/ru/omni_devel/cards/Utils.kt
index 52664af..2babdcd 100644
--- a/mobile/src/main/java/ru/omni_devel/cards/Utils.kt
+++ b/mobile/src/main/java/ru/omni_devel/cards/Utils.kt
@@ -1,6 +1,9 @@
package ru.omni_devel.cards
+import android.content.Context
import android.graphics.Bitmap
+import android.widget.Toast
+import com.google.android.gms.wearable.Wearable
import com.google.zxing.BarcodeFormat
import com.google.zxing.MultiFormatWriter
import com.journeyapps.barcodescanner.BarcodeEncoder
@@ -11,3 +14,29 @@ fun generateCode(value: String, format: BarcodeFormat): Bitmap {
return BarcodeEncoder().createBitmap(matrix)
}
+
+fun sendToWatch(context: Context, path: String, message: String): Boolean {
+ val nodeClient = Wearable.getNodeClient(context)
+
+ var isSuccess = false
+
+ nodeClient.connectedNodes.addOnSuccessListener { nodes ->
+ if (nodes.isEmpty()) {
+ Toast.makeText(context, "Watch is not connected", Toast.LENGTH_SHORT).show()
+
+ return@addOnSuccessListener
+ }
+
+ nodes.forEach { node ->
+ Wearable.getMessageClient(context).sendMessage(
+ node.id,
+ path,
+ message.toByteArray(Charsets.UTF_8)
+ ).addOnSuccessListener {
+ isSuccess = true
+ }
+ }
+ }
+
+ return isSuccess
+}
diff --git a/mobile/src/main/res/layout/activity_main.xml b/mobile/src/main/res/layout/activity_main.xml
index 9064420..65fb4fe 100644
--- a/mobile/src/main/res/layout/activity_main.xml
+++ b/mobile/src/main/res/layout/activity_main.xml
@@ -58,4 +58,16 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
+
+
\ No newline at end of file
diff --git a/mobile/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/mobile/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
new file mode 100644
index 0000000..2bf4f29
--- /dev/null
+++ b/mobile/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mobile/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/mobile/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
new file mode 100644
index 0000000..2bf4f29
--- /dev/null
+++ b/mobile/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mobile/src/main/res/mipmap-anydpi/ic_launcher.xml b/mobile/src/main/res/mipmap-anydpi/ic_launcher.xml
deleted file mode 100644
index 6f3b755..0000000
--- a/mobile/src/main/res/mipmap-anydpi/ic_launcher.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/mobile/src/main/res/mipmap-anydpi/ic_launcher_round.xml b/mobile/src/main/res/mipmap-anydpi/ic_launcher_round.xml
deleted file mode 100644
index 6f3b755..0000000
--- a/mobile/src/main/res/mipmap-anydpi/ic_launcher_round.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/mobile/src/main/res/mipmap-hdpi/ic_launcher.webp b/mobile/src/main/res/mipmap-hdpi/ic_launcher.webp
index c209e78..9420f7d 100644
Binary files a/mobile/src/main/res/mipmap-hdpi/ic_launcher.webp and b/mobile/src/main/res/mipmap-hdpi/ic_launcher.webp differ
diff --git a/mobile/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp b/mobile/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp
new file mode 100644
index 0000000..52fb884
Binary files /dev/null and b/mobile/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp differ
diff --git a/mobile/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/mobile/src/main/res/mipmap-hdpi/ic_launcher_round.webp
index b2dfe3d..e812e76 100644
Binary files a/mobile/src/main/res/mipmap-hdpi/ic_launcher_round.webp and b/mobile/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ
diff --git a/mobile/src/main/res/mipmap-mdpi/ic_launcher.webp b/mobile/src/main/res/mipmap-mdpi/ic_launcher.webp
index 4f0f1d6..7dedbe6 100644
Binary files a/mobile/src/main/res/mipmap-mdpi/ic_launcher.webp and b/mobile/src/main/res/mipmap-mdpi/ic_launcher.webp differ
diff --git a/mobile/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp b/mobile/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp
new file mode 100644
index 0000000..297a779
Binary files /dev/null and b/mobile/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp differ
diff --git a/mobile/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/mobile/src/main/res/mipmap-mdpi/ic_launcher_round.webp
index 62b611d..07042f6 100644
Binary files a/mobile/src/main/res/mipmap-mdpi/ic_launcher_round.webp and b/mobile/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ
diff --git a/mobile/src/main/res/mipmap-xhdpi/ic_launcher.webp b/mobile/src/main/res/mipmap-xhdpi/ic_launcher.webp
index 948a307..548131b 100644
Binary files a/mobile/src/main/res/mipmap-xhdpi/ic_launcher.webp and b/mobile/src/main/res/mipmap-xhdpi/ic_launcher.webp differ
diff --git a/mobile/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp b/mobile/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp
new file mode 100644
index 0000000..ee2b64e
Binary files /dev/null and b/mobile/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp differ
diff --git a/mobile/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/mobile/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
index 1b9a695..1c80664 100644
Binary files a/mobile/src/main/res/mipmap-xhdpi/ic_launcher_round.webp and b/mobile/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ
diff --git a/mobile/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/mobile/src/main/res/mipmap-xxhdpi/ic_launcher.webp
index 28d4b77..0010382 100644
Binary files a/mobile/src/main/res/mipmap-xxhdpi/ic_launcher.webp and b/mobile/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ
diff --git a/mobile/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp b/mobile/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp
new file mode 100644
index 0000000..763b7a3
Binary files /dev/null and b/mobile/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp differ
diff --git a/mobile/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/mobile/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
index 9287f50..f0bec8f 100644
Binary files a/mobile/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp and b/mobile/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ
diff --git a/mobile/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/mobile/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
index aa7d642..163c68f 100644
Binary files a/mobile/src/main/res/mipmap-xxxhdpi/ic_launcher.webp and b/mobile/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ
diff --git a/mobile/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp b/mobile/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp
new file mode 100644
index 0000000..df79fe5
Binary files /dev/null and b/mobile/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp differ
diff --git a/mobile/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/mobile/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
index 9126ae3..14408a0 100644
Binary files a/mobile/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp and b/mobile/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ
diff --git a/mobile/src/main/res/values/ic_launcher_background.xml b/mobile/src/main/res/values/ic_launcher_background.xml
new file mode 100644
index 0000000..1ce4d72
--- /dev/null
+++ b/mobile/src/main/res/values/ic_launcher_background.xml
@@ -0,0 +1,19 @@
+
+
+
+ #000000
+
\ No newline at end of file
diff --git a/wear/build.gradle.kts b/wear/build.gradle.kts
index c4527b6..196c5a9 100644
--- a/wear/build.gradle.kts
+++ b/wear/build.gradle.kts
@@ -1,6 +1,7 @@
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.compose)
+ kotlin("plugin.serialization") version "2.2.20"
}
android {
@@ -42,11 +43,14 @@ android {
dependencies {
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.activity.compose)
+ implementation(libs.androidx.activity.ktx)
+ implementation(libs.androidx.appcompat)
implementation(libs.androidx.compose.foundation)
implementation(libs.androidx.compose.material3)
implementation(libs.androidx.compose.ui)
implementation(libs.androidx.compose.ui.graphics)
implementation(libs.androidx.compose.ui.tooling.preview)
+ implementation(libs.androidx.constraintlayout)
implementation(libs.androidx.core.splashscreen)
implementation(libs.androidx.wear.tooling.preview)
implementation(libs.compose.ui.tooling)
@@ -57,4 +61,7 @@ dependencies {
debugImplementation(libs.androidx.compose.ui.tooling)
implementation(libs.zxing.core)
implementation(libs.zxing.android)
+ implementation(libs.material)
+ implementation("com.google.android.gms:play-services-wearable:18.1.0")
+ implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.9.0")
}
\ No newline at end of file
diff --git a/wear/src/main/AndroidManifest.xml b/wear/src/main/AndroidManifest.xml
index cc372df..fbb9802 100644
--- a/wear/src/main/AndroidManifest.xml
+++ b/wear/src/main/AndroidManifest.xml
@@ -11,13 +11,23 @@
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@android:style/Theme.DeviceDefault">
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
\ No newline at end of file
diff --git a/wear/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/wear/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
new file mode 100644
index 0000000..2bf4f29
--- /dev/null
+++ b/wear/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/wear/src/main/res/mipmap-anydpi/ic_launcher.xml b/wear/src/main/res/mipmap-anydpi/ic_launcher.xml
deleted file mode 100644
index 6f3b755..0000000
--- a/wear/src/main/res/mipmap-anydpi/ic_launcher.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/wear/src/main/res/mipmap-anydpi/ic_launcher_round.xml b/wear/src/main/res/mipmap-anydpi/ic_launcher_round.xml
deleted file mode 100644
index 6f3b755..0000000
--- a/wear/src/main/res/mipmap-anydpi/ic_launcher_round.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/wear/src/main/res/mipmap-hdpi/ic_launcher.webp b/wear/src/main/res/mipmap-hdpi/ic_launcher.webp
index c209e78..9420f7d 100644
Binary files a/wear/src/main/res/mipmap-hdpi/ic_launcher.webp and b/wear/src/main/res/mipmap-hdpi/ic_launcher.webp differ
diff --git a/wear/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp b/wear/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp
new file mode 100644
index 0000000..52fb884
Binary files /dev/null and b/wear/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp differ
diff --git a/wear/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/wear/src/main/res/mipmap-hdpi/ic_launcher_round.webp
index b2dfe3d..e812e76 100644
Binary files a/wear/src/main/res/mipmap-hdpi/ic_launcher_round.webp and b/wear/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ
diff --git a/wear/src/main/res/mipmap-mdpi/ic_launcher.webp b/wear/src/main/res/mipmap-mdpi/ic_launcher.webp
index 4f0f1d6..7dedbe6 100644
Binary files a/wear/src/main/res/mipmap-mdpi/ic_launcher.webp and b/wear/src/main/res/mipmap-mdpi/ic_launcher.webp differ
diff --git a/wear/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp b/wear/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp
new file mode 100644
index 0000000..297a779
Binary files /dev/null and b/wear/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp differ
diff --git a/wear/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/wear/src/main/res/mipmap-mdpi/ic_launcher_round.webp
index 62b611d..07042f6 100644
Binary files a/wear/src/main/res/mipmap-mdpi/ic_launcher_round.webp and b/wear/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ
diff --git a/wear/src/main/res/mipmap-xhdpi/ic_launcher.webp b/wear/src/main/res/mipmap-xhdpi/ic_launcher.webp
index 948a307..548131b 100644
Binary files a/wear/src/main/res/mipmap-xhdpi/ic_launcher.webp and b/wear/src/main/res/mipmap-xhdpi/ic_launcher.webp differ
diff --git a/wear/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp b/wear/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp
new file mode 100644
index 0000000..ee2b64e
Binary files /dev/null and b/wear/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp differ
diff --git a/wear/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/wear/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
index 1b9a695..1c80664 100644
Binary files a/wear/src/main/res/mipmap-xhdpi/ic_launcher_round.webp and b/wear/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ
diff --git a/wear/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/wear/src/main/res/mipmap-xxhdpi/ic_launcher.webp
index 28d4b77..0010382 100644
Binary files a/wear/src/main/res/mipmap-xxhdpi/ic_launcher.webp and b/wear/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ
diff --git a/wear/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp b/wear/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp
new file mode 100644
index 0000000..763b7a3
Binary files /dev/null and b/wear/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp differ
diff --git a/wear/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/wear/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
index 9287f50..f0bec8f 100644
Binary files a/wear/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp and b/wear/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ
diff --git a/wear/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/wear/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
index aa7d642..163c68f 100644
Binary files a/wear/src/main/res/mipmap-xxxhdpi/ic_launcher.webp and b/wear/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ
diff --git a/wear/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp b/wear/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp
new file mode 100644
index 0000000..df79fe5
Binary files /dev/null and b/wear/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp differ
diff --git a/wear/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/wear/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
index 9126ae3..14408a0 100644
Binary files a/wear/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp and b/wear/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ
diff --git a/wear/src/main/res/values/colors.xml b/wear/src/main/res/values/colors.xml
new file mode 100644
index 0000000..1d9d291
--- /dev/null
+++ b/wear/src/main/res/values/colors.xml
@@ -0,0 +1,33 @@
+
+
+
+ #0B0E17
+ #0E1118
+ #131726
+ #1A2235
+ #212B42
+
+
+ #152045
+ #2952C8
+ #3D6AE8
+ #6B90FF
+
+
+ #DCE3F5
+ #8A9BBC
+ #4E5E80
+
+
+ #1C2030
+ #1C2A42
+ #2A3D60
+
+
+ #0F3320
+ #2ECC71
+ #3D1515
+ #E05555
+ #3D2E00
+ #F0A500
+
\ No newline at end of file
diff --git a/wear/src/main/res/values/ic_launcher_background.xml b/wear/src/main/res/values/ic_launcher_background.xml
new file mode 100644
index 0000000..1ce4d72
--- /dev/null
+++ b/wear/src/main/res/values/ic_launcher_background.xml
@@ -0,0 +1,19 @@
+
+
+
+ #000000
+
\ No newline at end of file
diff --git a/wear/src/main/res/values/styles.xml b/wear/src/main/res/values/styles.xml
index dbf9c83..6cfb5c7 100644
--- a/wear/src/main/res/values/styles.xml
+++ b/wear/src/main/res/values/styles.xml
@@ -1,8 +1,10 @@
\ No newline at end of file