From ffcf069378226fba46c1d1277fce5846c1fc00e4 Mon Sep 17 00:00:00 2001 From: BlazeCodeDev Date: Fri, 14 Oct 2022 12:42:52 +0200 Subject: [PATCH 01/25] Update gradle --- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index daa34ae..dc8074b 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,7 @@ buildscript { maven { url 'https://plugins.gradle.org/m2/'} } dependencies { - classpath 'com.android.tools.build:gradle:7.2.2' + classpath 'com.android.tools.build:gradle:7.3.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10" //ABOUT LIBRARIES diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e680620..ba91ea9 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -6,7 +6,7 @@ #Thu Dec 02 15:53:30 CET 2021 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME From 1e4192027221041c3611d2ea8fb7b689fee72c1f Mon Sep 17 00:00:00 2001 From: BlazeCodeDev Date: Fri, 14 Oct 2022 12:49:42 +0200 Subject: [PATCH 02/25] Add WearOS module --- build.gradle | 2 + settings.gradle | 1 + wearos/.gitignore | 1 + wearos/build.gradle | 64 ++++++++++++++++ wearos/proguard-rules.pro | 21 ++++++ wearos/src/main/AndroidManifest.xml | 49 +++++++++++++ .../tsviewer/presentation/MainActivity.kt | 69 ++++++++++++++++++ .../tsviewer/presentation/theme/Color.kt | 21 ++++++ .../tsviewer/presentation/theme/Theme.kt | 17 +++++ .../tsviewer/presentation/theme/Type.kt | 28 +++++++ .../src/main/res/mipmap-hdpi/ic_launcher.webp | Bin 0 -> 1404 bytes .../src/main/res/mipmap-mdpi/ic_launcher.webp | Bin 0 -> 982 bytes .../main/res/mipmap-xhdpi/ic_launcher.webp | Bin 0 -> 1900 bytes .../main/res/mipmap-xxhdpi/ic_launcher.webp | Bin 0 -> 2884 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.webp | Bin 0 -> 3844 bytes wearos/src/main/res/values-round/strings.xml | 3 + wearos/src/main/res/values/strings.xml | 14 ++++ 17 files changed, 290 insertions(+) create mode 100644 wearos/.gitignore create mode 100644 wearos/build.gradle create mode 100644 wearos/proguard-rules.pro create mode 100644 wearos/src/main/AndroidManifest.xml create mode 100644 wearos/src/main/java/com/blazecode/tsviewer/presentation/MainActivity.kt create mode 100644 wearos/src/main/java/com/blazecode/tsviewer/presentation/theme/Color.kt create mode 100644 wearos/src/main/java/com/blazecode/tsviewer/presentation/theme/Theme.kt create mode 100644 wearos/src/main/java/com/blazecode/tsviewer/presentation/theme/Type.kt create mode 100644 wearos/src/main/res/mipmap-hdpi/ic_launcher.webp create mode 100644 wearos/src/main/res/mipmap-mdpi/ic_launcher.webp create mode 100644 wearos/src/main/res/mipmap-xhdpi/ic_launcher.webp create mode 100644 wearos/src/main/res/mipmap-xxhdpi/ic_launcher.webp create mode 100644 wearos/src/main/res/mipmap-xxxhdpi/ic_launcher.webp create mode 100644 wearos/src/main/res/values-round/strings.xml create mode 100644 wearos/src/main/res/values/strings.xml diff --git a/build.gradle b/build.gradle index dc8074b..39f2485 100644 --- a/build.gradle +++ b/build.gradle @@ -8,6 +8,8 @@ buildscript { ext { ABOUT_LIBRARIES_VERSION = "10.4.0" + compose_version = '1.2.0-alpha05' + wear_compose_version = '1.0.0-alpha18' } repositories { google() diff --git a/settings.gradle b/settings.gradle index f8594a4..6295788 100644 --- a/settings.gradle +++ b/settings.gradle @@ -15,3 +15,4 @@ dependencyResolutionManagement { } rootProject.name = "TSViewer" include ':app' +include ':wearos' diff --git a/wearos/.gitignore b/wearos/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/wearos/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/wearos/build.gradle b/wearos/build.gradle new file mode 100644 index 0000000..b754ae2 --- /dev/null +++ b/wearos/build.gradle @@ -0,0 +1,64 @@ +plugins { + id 'com.android.application' + id 'org.jetbrains.kotlin.android' +} + +android { + namespace 'com.blazecode.tsviewer' + compileSdkPreview "TiramisuPrivacySandbox" + + defaultConfig { + applicationId "com.blazecode.tsviewer" + minSdkPreview "TiramisuPrivacySandbox" + targetSdkPreview "TiramisuPrivacySandbox" + versionCode 1 + versionName "1.0" + vectorDrawables { + useSupportLibrary true + } + + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = '1.8' + } + buildFeatures { + compose true + } + composeOptions { + kotlinCompilerExtensionVersion '1.1.1' + } + packagingOptions { + resources { + excludes += '/META-INF/{AL2.0,LGPL2.1}' + } + } +} + +dependencies { + + implementation 'androidx.core:core-ktx:1.7.0' + implementation 'com.google.android.gms:play-services-wearable:17.1.0' + implementation 'androidx.percentlayout:percentlayout:1.0.0' + implementation 'androidx.legacy:legacy-support-v4:1.0.0' + implementation 'androidx.recyclerview:recyclerview:1.2.1' + implementation "androidx.compose.ui:ui:$compose_version" + implementation "androidx.wear.compose:compose-material:$wear_compose_version" + implementation "androidx.wear.compose:compose-foundation:$wear_compose_version" + implementation "androidx.compose.ui:ui-tooling-preview:$compose_version" + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1' + implementation 'androidx.activity:activity-compose:1.3.1' + androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version" + debugImplementation "androidx.compose.ui:ui-tooling:$compose_version" + debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version" +} \ No newline at end of file diff --git a/wearos/proguard-rules.pro b/wearos/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/wearos/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/wearos/src/main/AndroidManifest.xml b/wearos/src/main/AndroidManifest.xml new file mode 100644 index 0000000..e02ce1a --- /dev/null +++ b/wearos/src/main/AndroidManifest.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/wearos/src/main/java/com/blazecode/tsviewer/presentation/MainActivity.kt b/wearos/src/main/java/com/blazecode/tsviewer/presentation/MainActivity.kt new file mode 100644 index 0000000..588e5b7 --- /dev/null +++ b/wearos/src/main/java/com/blazecode/tsviewer/presentation/MainActivity.kt @@ -0,0 +1,69 @@ +/* While this template provides a good starting point for using Wear Compose, you can always + * take a look at https://github.com/android/wear-os-samples/tree/main/ComposeStarter and + * https://github.com/android/wear-os-samples/tree/main/ComposeAdvanced to find the most up to date + * changes to the libraries and their usages. + */ + +package com.blazecode.tsviewer.presentation + +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.tooling.preview.Devices +import androidx.compose.ui.tooling.preview.Preview +import androidx.wear.compose.material.MaterialTheme +import androidx.wear.compose.material.Text +import com.blazecode.tsviewer.R +import com.blazecode.tsviewer.presentation.theme.TSViewerTheme + +class MainActivity : ComponentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContent { + WearApp("Android") + } + } +} + +@Composable +fun WearApp(greetingName: String) { + TSViewerTheme { + /* If you have enough items in your list, use [ScalingLazyColumn] which is an optimized + * version of LazyColumn for wear devices with some added features. For more information, + * see d.android.com/wear/compose. + */ + Column( + modifier = Modifier + .fillMaxSize() + .background(MaterialTheme.colors.background), + verticalArrangement = Arrangement.Center + ) { + Greeting(greetingName = greetingName) + } + } +} + +@Composable +fun Greeting(greetingName: String) { + Text( + modifier = Modifier.fillMaxWidth(), + textAlign = TextAlign.Center, + color = MaterialTheme.colors.primary, + text = stringResource(R.string.hello_world, greetingName) + ) +} + +@Preview(device = Devices.WEAR_OS_SMALL_ROUND, showSystemUi = true) +@Composable +fun DefaultPreview() { + WearApp("Preview Android") +} \ No newline at end of file diff --git a/wearos/src/main/java/com/blazecode/tsviewer/presentation/theme/Color.kt b/wearos/src/main/java/com/blazecode/tsviewer/presentation/theme/Color.kt new file mode 100644 index 0000000..34fd180 --- /dev/null +++ b/wearos/src/main/java/com/blazecode/tsviewer/presentation/theme/Color.kt @@ -0,0 +1,21 @@ +package com.blazecode.tsviewer.presentation.theme + +import androidx.compose.ui.graphics.Color +import androidx.wear.compose.material.Colors + +val Purple200 = Color(0xFFBB86FC) +val Purple500 = Color(0xFF6200EE) +val Purple700 = Color(0xFF3700B3) +val Teal200 = Color(0xFF03DAC5) +val Red400 = Color(0xFFCF6679) + +internal val wearColorPalette: Colors = Colors( + primary = Purple200, + primaryVariant = Purple700, + secondary = Teal200, + secondaryVariant = Teal200, + error = Red400, + onPrimary = Color.Black, + onSecondary = Color.Black, + onError = Color.Black +) \ No newline at end of file diff --git a/wearos/src/main/java/com/blazecode/tsviewer/presentation/theme/Theme.kt b/wearos/src/main/java/com/blazecode/tsviewer/presentation/theme/Theme.kt new file mode 100644 index 0000000..3bf5889 --- /dev/null +++ b/wearos/src/main/java/com/blazecode/tsviewer/presentation/theme/Theme.kt @@ -0,0 +1,17 @@ +package com.blazecode.tsviewer.presentation.theme + +import androidx.compose.runtime.Composable +import androidx.wear.compose.material.MaterialTheme + +@Composable +fun TSViewerTheme( + content: @Composable () -> Unit +) { + MaterialTheme( + colors = wearColorPalette, + typography = Typography, + // For shapes, we generally recommend using the default Material Wear shapes which are + // optimized for round and non-round devices. + content = content + ) +} \ No newline at end of file diff --git a/wearos/src/main/java/com/blazecode/tsviewer/presentation/theme/Type.kt b/wearos/src/main/java/com/blazecode/tsviewer/presentation/theme/Type.kt new file mode 100644 index 0000000..4e69af3 --- /dev/null +++ b/wearos/src/main/java/com/blazecode/tsviewer/presentation/theme/Type.kt @@ -0,0 +1,28 @@ +package com.blazecode.tsviewer.presentation.theme + +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.sp +import androidx.wear.compose.material.Typography + +// Set of Material typography styles to start with +val Typography = Typography( + body1 = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 16.sp + ) + /* Other default text styles to override + button = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.W500, + fontSize = 14.sp + ), + caption = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 12.sp + ) + */ +) \ No newline at end of file diff --git a/wearos/src/main/res/mipmap-hdpi/ic_launcher.webp b/wearos/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000000000000000000000000000000000000..c209e78ecd372343283f4157dcfd918ec5165bb3 GIT binary patch literal 1404 zcmV-?1%vuhNk&F=1pok7MM6+kP&il$0000G0000-002h-06|PpNX!5L00Dqw+t%{r zzW2vH!KF=w&cMnnN@{whkTw+#mAh0SV?YL=)3MimFYCWp#fpdtz~8$hD5VPuQgtcN zXl<@<#Cme5f5yr2h%@8TWh?)bSK`O z^Z@d={gn7J{iyxL_y_%J|L>ep{dUxUP8a{byupH&!UNR*OutO~0{*T4q5R6@ApLF! z5{w?Z150gC7#>(VHFJZ-^6O@PYp{t!jH(_Z*nzTK4 zkc{fLE4Q3|mA2`CWQ3{8;gxGizgM!zccbdQoOLZc8hThi-IhN90RFT|zlxh3Ty&VG z?Fe{#9RrRnxzsu|Lg2ddugg7k%>0JeD+{XZ7>Z~{=|M+sh1MF7~ zz>To~`~LVQe1nNoR-gEzkpe{Ak^7{{ZBk2i_<+`Bq<^GB!RYG+z)h;Y3+<{zlMUYd zrd*W4w&jZ0%kBuDZ1EW&KLpyR7r2=}fF2%0VwHM4pUs}ZI2egi#DRMYZPek*^H9YK zay4Iy3WXFG(F14xYsoDA|KXgGc5%2DhmQ1gFCkrgHBm!lXG8I5h*uf{rn48Z!_@ z4Bk6TJAB2CKYqPjiX&mWoW>OPFGd$wqroa($ne7EUK;#3VYkXaew%Kh^3OrMhtjYN?XEoY`tRPQsAkH-DSL^QqyN0>^ zmC>{#F14jz4GeW{pJoRpLFa_*GI{?T93^rX7SPQgT@LbLqpNA}<@2wH;q493)G=1Y z#-sCiRNX~qf3KgiFzB3I>4Z%AfS(3$`-aMIBU+6?gbgDb!)L~A)je+;fR0jWLL-Fu z4)P{c7{B4Hp91&%??2$v9iRSFnuckHUm}or9seH6 z>%NbT+5*@L5(I9j@06@(!{ZI?U0=pKn8uwIg&L{JV14+8s2hnvbRrU|hZCd}IJu7*;;ECgO%8_*W Kmw_-CKmY()leWbG literal 0 HcmV?d00001 diff --git a/wearos/src/main/res/mipmap-mdpi/ic_launcher.webp b/wearos/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000000000000000000000000000000000000..4f0f1d64e58ba64d180ce43ee13bf9a17835fbca GIT binary patch literal 982 zcmV;{11bDcNk&G_0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NhxxUpgP%XTLmO zcjaFva^}dP3$&sfFTIR_jC=2pHh9kpI@2(6V*GQo7Ws)`j)hd+tr@P~gR*2gO@+1? zG<`_tB+LJuF|SZ9tIec;h%}}6WClT`L>HSW?E{Hp1h^+mlbf_$9zA>!ug>NALJsO{ mU%z=YwVD?}XMya)Bp;vlyE5&E_6!fzx9pwrdz474!~g(M6R?N? literal 0 HcmV?d00001 diff --git a/wearos/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/wearos/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 0000000000000000000000000000000000000000..28d4b77f9f036a47549d47db79c16788749dca10 GIT binary patch literal 2884 zcmV-K3%m4ENk&FI3jhFDMM6+kP&il$0000G0001w0055w06|PpNY()W00EFA*|uso z=UmW3;Ri7@GcyiBW{ey$jes55b5S`|ZVZ{(x$xch{z?D+^{yErVgleVwa9qvGt40r z42;MG=7<0QySlzE=Ig6%01!FBK^$Fsxe@Hfe6aCy?Wh2r0~}@_lQAF90oTUi0FhEr z#(*;kTC(r!tQk6;gxj4h%FdHAt(^M3YvYj(!tOeN)+Hvj6+< zzyJRG?^lZfWuR#t!tUKP&(?%3v&Zd$R2YN>lB(Lq`OInY48%4%yTv2 zYe1{G`3)(PDEio5Y@-I5tUf`c%%OCJMtSW56g3iEg%3`$7XSJJHyA z<|7&N)5Xrlgv~%BO24eFd;Hd;uiK%D`EdK|quUeRZDqbh9l)%j%J#0lfrZumvA<_w zu&=AVvdChf6}eqh(bUz`(`Ue*p01{fBAcTgKyDYLs_I+YyJEk+rM@avU~>fB$n)HS zM7pfJydu`i%gfS<{PF94kZDv$t>06sAkheDzu40NJ$5CMW%n^Lls?8^p^QGWURbKu3ZduZQZ((s2? zzE`}<{;Zt7<$C|9R8A~DJ~@%x>TfP zF>TX8)@v|t)q4GjRt<}5s6hLHwRel7>V@&r-O|Av(yh;Q1A{E>Ir>p+%dHD|=l+lT zpr(Dg&>#Nu=!)6bCLr-ZS%|;h)Ij$+e@r8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=86*- zcO+0mywg*j + From the Round world,\nHello, %1$s! + \ No newline at end of file diff --git a/wearos/src/main/res/values/strings.xml b/wearos/src/main/res/values/strings.xml new file mode 100644 index 0000000..e9b440f --- /dev/null +++ b/wearos/src/main/res/values/strings.xml @@ -0,0 +1,14 @@ + + + + TSViewer + + From the Square world,\nHello, %1$s! + \ No newline at end of file From fb4fd7f56996c533c0b6fb4b4b3b1e3d371b9513 Mon Sep 17 00:00:00 2001 From: BlazeCodeDev Date: Fri, 14 Oct 2022 13:04:17 +0200 Subject: [PATCH 03/25] Update Gradle --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 39f2485..8d0ab38 100644 --- a/build.gradle +++ b/build.gradle @@ -20,7 +20,7 @@ buildscript { maven { url 'https://plugins.gradle.org/m2/'} } dependencies { - classpath 'com.android.tools.build:gradle:7.3.0' + classpath 'com.android.tools.build:gradle:7.3.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10" //ABOUT LIBRARIES From 8bf4d28b690b2e789cd024d23078b3a33f5038d1 Mon Sep 17 00:00:00 2001 From: BlazeCodeDev Date: Fri, 14 Oct 2022 13:14:31 +0200 Subject: [PATCH 04/25] Update Kotlin --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 8d0ab38..cb72448 100644 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,7 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:7.3.1' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10" + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20" //ABOUT LIBRARIES classpath "com.mikepenz.aboutlibraries.plugin:aboutlibraries-plugin:$ABOUT_LIBRARIES_VERSION" From 70e2a0029daa8c09556f740ed0c0bcc685988e36 Mon Sep 17 00:00:00 2001 From: BlazeCodeDev Date: Fri, 14 Oct 2022 13:16:00 +0200 Subject: [PATCH 05/25] Update Dependencies --- build.gradle | 4 ++-- wearos/build.gradle | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index cb72448..14abc42 100644 --- a/build.gradle +++ b/build.gradle @@ -8,8 +8,8 @@ buildscript { ext { ABOUT_LIBRARIES_VERSION = "10.4.0" - compose_version = '1.2.0-alpha05' - wear_compose_version = '1.0.0-alpha18' + compose_version = '1.3.0-rc01' + wear_compose_version = '1.1.0-alpha07' } repositories { google() diff --git a/wearos/build.gradle b/wearos/build.gradle index b754ae2..6d21d73 100644 --- a/wearos/build.gradle +++ b/wearos/build.gradle @@ -9,7 +9,7 @@ android { defaultConfig { applicationId "com.blazecode.tsviewer" - minSdkPreview "TiramisuPrivacySandbox" + minSdkVersion 30 targetSdkPreview "TiramisuPrivacySandbox" versionCode 1 versionName "1.0" @@ -47,8 +47,8 @@ android { dependencies { - implementation 'androidx.core:core-ktx:1.7.0' - implementation 'com.google.android.gms:play-services-wearable:17.1.0' + implementation 'androidx.core:core-ktx:1.9.0' + implementation 'com.google.android.gms:play-services-wearable:18.0.0' implementation 'androidx.percentlayout:percentlayout:1.0.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.recyclerview:recyclerview:1.2.1' @@ -56,8 +56,8 @@ dependencies { implementation "androidx.wear.compose:compose-material:$wear_compose_version" implementation "androidx.wear.compose:compose-foundation:$wear_compose_version" implementation "androidx.compose.ui:ui-tooling-preview:$compose_version" - implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1' - implementation 'androidx.activity:activity-compose:1.3.1' + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1' + implementation 'androidx.activity:activity-compose:1.6.0' androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version" debugImplementation "androidx.compose.ui:ui-tooling:$compose_version" debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version" From 2ae67a0647761e0629da9117d6a6ce3b195ea59e Mon Sep 17 00:00:00 2001 From: BlazeCodeDev Date: Fri, 14 Oct 2022 14:30:16 +0200 Subject: [PATCH 06/25] Update Gradle Settings for compose --- build.gradle | 2 +- wearos/build.gradle | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 14abc42..922bd94 100644 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,7 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:7.3.1' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20" + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10" //ABOUT LIBRARIES classpath "com.mikepenz.aboutlibraries.plugin:aboutlibraries-plugin:$ABOUT_LIBRARIES_VERSION" diff --git a/wearos/build.gradle b/wearos/build.gradle index 6d21d73..764d92d 100644 --- a/wearos/build.gradle +++ b/wearos/build.gradle @@ -5,12 +5,12 @@ plugins { android { namespace 'com.blazecode.tsviewer' - compileSdkPreview "TiramisuPrivacySandbox" + compileSdkVersion 33 defaultConfig { applicationId "com.blazecode.tsviewer" - minSdkVersion 30 - targetSdkPreview "TiramisuPrivacySandbox" + minSdkVersion 25 + targetSdkVersion 33 versionCode 1 versionName "1.0" vectorDrawables { From 3fc20263bcc231a95c17aef5263d071db52ec28b Mon Sep 17 00:00:00 2001 From: BlazeCodeDev Date: Fri, 14 Oct 2022 21:55:55 +0200 Subject: [PATCH 07/25] Rename Module --- settings.gradle | 2 +- {wearos => wear}/.gitignore | 0 {wearos => wear}/build.gradle | 0 {wearos => wear}/proguard-rules.pro | 0 {wearos => wear}/src/main/AndroidManifest.xml | 2 +- .../com/blazecode/tsviewer/wear}/MainActivity.kt | 4 ++-- .../com/blazecode/tsviewer/wear}/theme/Color.kt | 2 +- .../com/blazecode/tsviewer/wear}/theme/Theme.kt | 2 +- .../java/com/blazecode/tsviewer/wear}/theme/Type.kt | 2 +- .../src/main/res/mipmap-hdpi/ic_launcher.webp | Bin .../src/main/res/mipmap-mdpi/ic_launcher.webp | Bin .../src/main/res/mipmap-xhdpi/ic_launcher.webp | Bin .../src/main/res/mipmap-xxhdpi/ic_launcher.webp | Bin .../src/main/res/mipmap-xxxhdpi/ic_launcher.webp | Bin .../src/main/res/values-round/strings.xml | 0 {wearos => wear}/src/main/res/values/strings.xml | 0 16 files changed, 7 insertions(+), 7 deletions(-) rename {wearos => wear}/.gitignore (100%) rename {wearos => wear}/build.gradle (100%) rename {wearos => wear}/proguard-rules.pro (100%) rename {wearos => wear}/src/main/AndroidManifest.xml (96%) rename {wearos/src/main/java/com/blazecode/tsviewer/presentation => wear/src/main/java/com/blazecode/tsviewer/wear}/MainActivity.kt (95%) rename {wearos/src/main/java/com/blazecode/tsviewer/presentation => wear/src/main/java/com/blazecode/tsviewer/wear}/theme/Color.kt (91%) rename {wearos/src/main/java/com/blazecode/tsviewer/presentation => wear/src/main/java/com/blazecode/tsviewer/wear}/theme/Theme.kt (89%) rename {wearos/src/main/java/com/blazecode/tsviewer/presentation => wear/src/main/java/com/blazecode/tsviewer/wear}/theme/Type.kt (93%) rename {wearos => wear}/src/main/res/mipmap-hdpi/ic_launcher.webp (100%) rename {wearos => wear}/src/main/res/mipmap-mdpi/ic_launcher.webp (100%) rename {wearos => wear}/src/main/res/mipmap-xhdpi/ic_launcher.webp (100%) rename {wearos => wear}/src/main/res/mipmap-xxhdpi/ic_launcher.webp (100%) rename {wearos => wear}/src/main/res/mipmap-xxxhdpi/ic_launcher.webp (100%) rename {wearos => wear}/src/main/res/values-round/strings.xml (100%) rename {wearos => wear}/src/main/res/values/strings.xml (100%) diff --git a/settings.gradle b/settings.gradle index 6295788..3160e20 100644 --- a/settings.gradle +++ b/settings.gradle @@ -15,4 +15,4 @@ dependencyResolutionManagement { } rootProject.name = "TSViewer" include ':app' -include ':wearos' +include ':wear' diff --git a/wearos/.gitignore b/wear/.gitignore similarity index 100% rename from wearos/.gitignore rename to wear/.gitignore diff --git a/wearos/build.gradle b/wear/build.gradle similarity index 100% rename from wearos/build.gradle rename to wear/build.gradle diff --git a/wearos/proguard-rules.pro b/wear/proguard-rules.pro similarity index 100% rename from wearos/proguard-rules.pro rename to wear/proguard-rules.pro diff --git a/wearos/src/main/AndroidManifest.xml b/wear/src/main/AndroidManifest.xml similarity index 96% rename from wearos/src/main/AndroidManifest.xml rename to wear/src/main/AndroidManifest.xml index e02ce1a..3e3b126 100644 --- a/wearos/src/main/AndroidManifest.xml +++ b/wear/src/main/AndroidManifest.xml @@ -30,7 +30,7 @@ android:value="true" /> diff --git a/wearos/src/main/java/com/blazecode/tsviewer/presentation/MainActivity.kt b/wear/src/main/java/com/blazecode/tsviewer/wear/MainActivity.kt similarity index 95% rename from wearos/src/main/java/com/blazecode/tsviewer/presentation/MainActivity.kt rename to wear/src/main/java/com/blazecode/tsviewer/wear/MainActivity.kt index 588e5b7..7f5d57c 100644 --- a/wearos/src/main/java/com/blazecode/tsviewer/presentation/MainActivity.kt +++ b/wear/src/main/java/com/blazecode/tsviewer/wear/MainActivity.kt @@ -4,7 +4,7 @@ * changes to the libraries and their usages. */ -package com.blazecode.tsviewer.presentation +package com.blazecode.tsviewer.wear import android.os.Bundle import androidx.activity.ComponentActivity @@ -23,7 +23,7 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.wear.compose.material.MaterialTheme import androidx.wear.compose.material.Text import com.blazecode.tsviewer.R -import com.blazecode.tsviewer.presentation.theme.TSViewerTheme +import com.blazecode.tsviewer.wear.theme.TSViewerTheme class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { diff --git a/wearos/src/main/java/com/blazecode/tsviewer/presentation/theme/Color.kt b/wear/src/main/java/com/blazecode/tsviewer/wear/theme/Color.kt similarity index 91% rename from wearos/src/main/java/com/blazecode/tsviewer/presentation/theme/Color.kt rename to wear/src/main/java/com/blazecode/tsviewer/wear/theme/Color.kt index 34fd180..87c8a08 100644 --- a/wearos/src/main/java/com/blazecode/tsviewer/presentation/theme/Color.kt +++ b/wear/src/main/java/com/blazecode/tsviewer/wear/theme/Color.kt @@ -1,4 +1,4 @@ -package com.blazecode.tsviewer.presentation.theme +package com.blazecode.tsviewer.wear.theme import androidx.compose.ui.graphics.Color import androidx.wear.compose.material.Colors diff --git a/wearos/src/main/java/com/blazecode/tsviewer/presentation/theme/Theme.kt b/wear/src/main/java/com/blazecode/tsviewer/wear/theme/Theme.kt similarity index 89% rename from wearos/src/main/java/com/blazecode/tsviewer/presentation/theme/Theme.kt rename to wear/src/main/java/com/blazecode/tsviewer/wear/theme/Theme.kt index 3bf5889..d38c03c 100644 --- a/wearos/src/main/java/com/blazecode/tsviewer/presentation/theme/Theme.kt +++ b/wear/src/main/java/com/blazecode/tsviewer/wear/theme/Theme.kt @@ -1,4 +1,4 @@ -package com.blazecode.tsviewer.presentation.theme +package com.blazecode.tsviewer.wear.theme import androidx.compose.runtime.Composable import androidx.wear.compose.material.MaterialTheme diff --git a/wearos/src/main/java/com/blazecode/tsviewer/presentation/theme/Type.kt b/wear/src/main/java/com/blazecode/tsviewer/wear/theme/Type.kt similarity index 93% rename from wearos/src/main/java/com/blazecode/tsviewer/presentation/theme/Type.kt rename to wear/src/main/java/com/blazecode/tsviewer/wear/theme/Type.kt index 4e69af3..798068f 100644 --- a/wearos/src/main/java/com/blazecode/tsviewer/presentation/theme/Type.kt +++ b/wear/src/main/java/com/blazecode/tsviewer/wear/theme/Type.kt @@ -1,4 +1,4 @@ -package com.blazecode.tsviewer.presentation.theme +package com.blazecode.tsviewer.wear.theme import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.FontFamily diff --git a/wearos/src/main/res/mipmap-hdpi/ic_launcher.webp b/wear/src/main/res/mipmap-hdpi/ic_launcher.webp similarity index 100% rename from wearos/src/main/res/mipmap-hdpi/ic_launcher.webp rename to wear/src/main/res/mipmap-hdpi/ic_launcher.webp diff --git a/wearos/src/main/res/mipmap-mdpi/ic_launcher.webp b/wear/src/main/res/mipmap-mdpi/ic_launcher.webp similarity index 100% rename from wearos/src/main/res/mipmap-mdpi/ic_launcher.webp rename to wear/src/main/res/mipmap-mdpi/ic_launcher.webp diff --git a/wearos/src/main/res/mipmap-xhdpi/ic_launcher.webp b/wear/src/main/res/mipmap-xhdpi/ic_launcher.webp similarity index 100% rename from wearos/src/main/res/mipmap-xhdpi/ic_launcher.webp rename to wear/src/main/res/mipmap-xhdpi/ic_launcher.webp diff --git a/wearos/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/wear/src/main/res/mipmap-xxhdpi/ic_launcher.webp similarity index 100% rename from wearos/src/main/res/mipmap-xxhdpi/ic_launcher.webp rename to wear/src/main/res/mipmap-xxhdpi/ic_launcher.webp diff --git a/wearos/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/wear/src/main/res/mipmap-xxxhdpi/ic_launcher.webp similarity index 100% rename from wearos/src/main/res/mipmap-xxxhdpi/ic_launcher.webp rename to wear/src/main/res/mipmap-xxxhdpi/ic_launcher.webp diff --git a/wearos/src/main/res/values-round/strings.xml b/wear/src/main/res/values-round/strings.xml similarity index 100% rename from wearos/src/main/res/values-round/strings.xml rename to wear/src/main/res/values-round/strings.xml diff --git a/wearos/src/main/res/values/strings.xml b/wear/src/main/res/values/strings.xml similarity index 100% rename from wearos/src/main/res/values/strings.xml rename to wear/src/main/res/values/strings.xml From 52079639dfa4f4f5246d10e95e906dc9cd64cc47 Mon Sep 17 00:00:00 2001 From: BlazeCodeDev Date: Sat, 19 Nov 2022 18:09:55 +0100 Subject: [PATCH 08/25] Add working complication --- wear/src/main/AndroidManifest.xml | 21 ++++++- .../wear/complication/Complication.kt | 12 ++++ .../complication/ComplicationArguments.kt | 18 ++++++ .../complication/ComplicationDataHolder.kt | 11 ++++ .../wear/complication/ComplicationProvider.kt | 62 +++++++++++++++++++ .../wear/complication/ComplicationReceiver.kt | 19 ++++++ 6 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 wear/src/main/java/com/blazecode/tsviewer/wear/complication/Complication.kt create mode 100644 wear/src/main/java/com/blazecode/tsviewer/wear/complication/ComplicationArguments.kt create mode 100644 wear/src/main/java/com/blazecode/tsviewer/wear/complication/ComplicationDataHolder.kt create mode 100644 wear/src/main/java/com/blazecode/tsviewer/wear/complication/ComplicationProvider.kt create mode 100644 wear/src/main/java/com/blazecode/tsviewer/wear/complication/ComplicationReceiver.kt diff --git a/wear/src/main/AndroidManifest.xml b/wear/src/main/AndroidManifest.xml index 3e3b126..c1c5897 100644 --- a/wear/src/main/AndroidManifest.xml +++ b/wear/src/main/AndroidManifest.xml @@ -27,7 +27,7 @@ --> + android:value="false" /> + + + + + + + + + + + \ No newline at end of file diff --git a/wear/src/main/java/com/blazecode/tsviewer/wear/complication/Complication.kt b/wear/src/main/java/com/blazecode/tsviewer/wear/complication/Complication.kt new file mode 100644 index 0000000..483998f --- /dev/null +++ b/wear/src/main/java/com/blazecode/tsviewer/wear/complication/Complication.kt @@ -0,0 +1,12 @@ +/* + * + * * Copyright (c) BlazeCode / Ralf Lehmann, 2022. + * + */ + +package com.blazecode.tsviewer.wear.complication + +enum class Complication(val key: String){ + ICON("Icon"), + LONG_TEXT("LongText") +} \ No newline at end of file diff --git a/wear/src/main/java/com/blazecode/tsviewer/wear/complication/ComplicationArguments.kt b/wear/src/main/java/com/blazecode/tsviewer/wear/complication/ComplicationArguments.kt new file mode 100644 index 0000000..06c5777 --- /dev/null +++ b/wear/src/main/java/com/blazecode/tsviewer/wear/complication/ComplicationArguments.kt @@ -0,0 +1,18 @@ +/* + * + * * Copyright (c) BlazeCode / Ralf Lehmann, 2022. + * + */ + +package com.blazecode.tsviewer.wear.complication + +import android.content.ComponentName +import android.os.Parcelable +import kotlinx.parcelize.Parcelize + +@Parcelize +data class ComplicationArguments( + val component: ComponentName, + val complication: Complication, + val complicationId: Int +) : Parcelable \ No newline at end of file diff --git a/wear/src/main/java/com/blazecode/tsviewer/wear/complication/ComplicationDataHolder.kt b/wear/src/main/java/com/blazecode/tsviewer/wear/complication/ComplicationDataHolder.kt new file mode 100644 index 0000000..2abd2ac --- /dev/null +++ b/wear/src/main/java/com/blazecode/tsviewer/wear/complication/ComplicationDataHolder.kt @@ -0,0 +1,11 @@ +/* + * + * * Copyright (c) BlazeCode / Ralf Lehmann, 2022. + * + */ + +package com.blazecode.tsviewer.wear.complication + +object ComplicationDataHolder { + var amount: Int = 0 +} \ No newline at end of file diff --git a/wear/src/main/java/com/blazecode/tsviewer/wear/complication/ComplicationProvider.kt b/wear/src/main/java/com/blazecode/tsviewer/wear/complication/ComplicationProvider.kt new file mode 100644 index 0000000..a115aab --- /dev/null +++ b/wear/src/main/java/com/blazecode/tsviewer/wear/complication/ComplicationProvider.kt @@ -0,0 +1,62 @@ +/* + * + * * Copyright (c) BlazeCode / Ralf Lehmann, 2022. + * + */ + +package com.blazecode.tsviewer.wear.complication + +import android.app.PendingIntent +import android.content.ComponentName +import android.content.Context +import android.content.Intent +import android.graphics.drawable.Icon +import androidx.wear.watchface.complications.data.* +import androidx.wear.watchface.complications.datasource.ComplicationDataSourceService +import androidx.wear.watchface.complications.datasource.ComplicationDataSourceUpdateRequester +import androidx.wear.watchface.complications.datasource.ComplicationRequest +import com.blazecode.tsviewer.R + + +// https://github.com/android/wear-os-samples/blob/main/WearComplicationDataSourcesTestSuite/Wearable/src/main/java/com/example/android/wearable/wear/wearcomplicationproviderstestsuite/LongTextDataSourceService.kt + +class ComplicationProvider: ComplicationDataSourceService() { + + val dataHolder = ComplicationDataHolder + + override fun getPreviewData(type: ComplicationType): ComplicationData? { + return getComplicationData(null) + } + + override fun onComplicationRequest(request: ComplicationRequest, listener: ComplicationRequestListener) { + val intent = Intent(this, ComplicationReceiver::class.java).apply { + putExtra("amount", dataHolder.amount) + } + val pendingIntent = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) + + listener.onComplicationData(getComplicationData(pendingIntent)) + } + + private fun getComplicationData(tapAction: PendingIntent?): ComplicationData{ + val icon = Icon.createWithResource(this, R.drawable.ic_icon) + + return ShortTextComplicationData.Builder( + text = PlainComplicationText.Builder( + text = dataHolder.amount.toString() + ).build(), + + contentDescription = PlainComplicationText.Builder( + text = "Shows client amount" + ).build(), + ) + .setMonochromaticImage(MonochromaticImage.Builder(icon).build()) + .setTapAction(tapAction).build() + } + + fun update(context: Context){ + ComplicationDataSourceUpdateRequester.create( + context, + complicationDataSourceComponent = ComponentName(context, ComplicationProvider::class.java) + ).requestUpdateAll() + } +} diff --git a/wear/src/main/java/com/blazecode/tsviewer/wear/complication/ComplicationReceiver.kt b/wear/src/main/java/com/blazecode/tsviewer/wear/complication/ComplicationReceiver.kt new file mode 100644 index 0000000..c23280b --- /dev/null +++ b/wear/src/main/java/com/blazecode/tsviewer/wear/complication/ComplicationReceiver.kt @@ -0,0 +1,19 @@ +/* + * + * * Copyright (c) BlazeCode / Ralf Lehmann, 2022. + * + */ + +package com.blazecode.tsviewer.wear.complication + +import android.content.BroadcastReceiver +import android.content.Context +import android.content.Intent +import android.util.Log + +class ComplicationReceiver: BroadcastReceiver() { + override fun onReceive(context: Context?, intent: Intent?) { + val amount = intent?.extras?.getInt("amount") + Log.d("test", amount.toString()) + } +} \ No newline at end of file From 3390846e18af6ae96ea507c3436fd38545524ef8 Mon Sep 17 00:00:00 2001 From: BlazeCodeDev Date: Sat, 19 Nov 2022 18:10:09 +0100 Subject: [PATCH 09/25] Update dependencies --- build.gradle | 4 ++-- wear/build.gradle | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 922bd94..f762721 100644 --- a/build.gradle +++ b/build.gradle @@ -8,8 +8,8 @@ buildscript { ext { ABOUT_LIBRARIES_VERSION = "10.4.0" - compose_version = '1.3.0-rc01' - wear_compose_version = '1.1.0-alpha07' + compose_version = '1.4.0-alpha02' + wear_compose_version = '1.1.0-rc01' } repositories { google() diff --git a/wear/build.gradle b/wear/build.gradle index 764d92d..1373033 100644 --- a/wear/build.gradle +++ b/wear/build.gradle @@ -1,6 +1,7 @@ plugins { id 'com.android.application' id 'org.jetbrains.kotlin.android' + id 'kotlin-parcelize' } android { @@ -9,7 +10,7 @@ android { defaultConfig { applicationId "com.blazecode.tsviewer" - minSdkVersion 25 + minSdkVersion 26 targetSdkVersion 33 versionCode 1 versionName "1.0" @@ -57,8 +58,14 @@ dependencies { implementation "androidx.wear.compose:compose-foundation:$wear_compose_version" implementation "androidx.compose.ui:ui-tooling-preview:$compose_version" implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1' - implementation 'androidx.activity:activity-compose:1.6.0' + implementation 'androidx.activity:activity-compose:1.6.1' androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version" debugImplementation "androidx.compose.ui:ui-tooling:$compose_version" debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version" + + // COMPLICATIONS + implementation "androidx.wear.watchface:watchface-complications-data-source-ktx:1.1.1" + + //DATA STORE + implementation("androidx.datastore:datastore-preferences:1.0.0") } \ No newline at end of file From a07c9a15b346e9279d2dc76153eb0c6c01ee08d5 Mon Sep 17 00:00:00 2001 From: BlazeCodeDev Date: Sat, 19 Nov 2022 18:10:21 +0100 Subject: [PATCH 10/25] Add icon --- wear/src/main/res/drawable/ic_icon.xml | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 wear/src/main/res/drawable/ic_icon.xml diff --git a/wear/src/main/res/drawable/ic_icon.xml b/wear/src/main/res/drawable/ic_icon.xml new file mode 100644 index 0000000..4ac759a --- /dev/null +++ b/wear/src/main/res/drawable/ic_icon.xml @@ -0,0 +1,28 @@ + + + + + + + + + + From 2cc75de67615c4ee2d6761f0fffcb1667e6865e5 Mon Sep 17 00:00:00 2001 From: BlazeCodeDev Date: Sat, 19 Nov 2022 18:10:30 +0100 Subject: [PATCH 11/25] Refactor screens --- .../blazecode/tsviewer/wear/MainActivity.kt | 59 ++++++------------- .../tsviewer/wear/screens/ClientList.kt | 14 +++++ .../blazecode/tsviewer/wear/screens/Home.kt | 39 ++++++++++++ 3 files changed, 70 insertions(+), 42 deletions(-) create mode 100644 wear/src/main/java/com/blazecode/tsviewer/wear/screens/ClientList.kt create mode 100644 wear/src/main/java/com/blazecode/tsviewer/wear/screens/Home.kt diff --git a/wear/src/main/java/com/blazecode/tsviewer/wear/MainActivity.kt b/wear/src/main/java/com/blazecode/tsviewer/wear/MainActivity.kt index 7f5d57c..273f52e 100644 --- a/wear/src/main/java/com/blazecode/tsviewer/wear/MainActivity.kt +++ b/wear/src/main/java/com/blazecode/tsviewer/wear/MainActivity.kt @@ -1,3 +1,9 @@ +/* + * + * * Copyright (c) BlazeCode / Ralf Lehmann, 2022. + * + */ + /* While this template provides a good starting point for using Wear Compose, you can always * take a look at https://github.com/android/wear-os-samples/tree/main/ComposeStarter and * https://github.com/android/wear-os-samples/tree/main/ComposeAdvanced to find the most up to date @@ -13,57 +19,26 @@ import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import androidx.compose.ui.res.stringResource -import androidx.compose.ui.text.style.TextAlign -import androidx.compose.ui.tooling.preview.Devices -import androidx.compose.ui.tooling.preview.Preview import androidx.wear.compose.material.MaterialTheme -import androidx.wear.compose.material.Text -import com.blazecode.tsviewer.R +import com.blazecode.tsviewer.wear.screens.Home import com.blazecode.tsviewer.wear.theme.TSViewerTheme class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { - WearApp("Android") - } - } -} -@Composable -fun WearApp(greetingName: String) { - TSViewerTheme { - /* If you have enough items in your list, use [ScalingLazyColumn] which is an optimized - * version of LazyColumn for wear devices with some added features. For more information, - * see d.android.com/wear/compose. - */ - Column( - modifier = Modifier - .fillMaxSize() - .background(MaterialTheme.colors.background), - verticalArrangement = Arrangement.Center - ) { - Greeting(greetingName = greetingName) + TSViewerTheme { + Column( + modifier = Modifier + .fillMaxSize() + .background(MaterialTheme.colors.surface), + verticalArrangement = Arrangement.Center + ) { + Home() + } + } } } -} - -@Composable -fun Greeting(greetingName: String) { - Text( - modifier = Modifier.fillMaxWidth(), - textAlign = TextAlign.Center, - color = MaterialTheme.colors.primary, - text = stringResource(R.string.hello_world, greetingName) - ) -} - -@Preview(device = Devices.WEAR_OS_SMALL_ROUND, showSystemUi = true) -@Composable -fun DefaultPreview() { - WearApp("Preview Android") } \ No newline at end of file diff --git a/wear/src/main/java/com/blazecode/tsviewer/wear/screens/ClientList.kt b/wear/src/main/java/com/blazecode/tsviewer/wear/screens/ClientList.kt new file mode 100644 index 0000000..236700d --- /dev/null +++ b/wear/src/main/java/com/blazecode/tsviewer/wear/screens/ClientList.kt @@ -0,0 +1,14 @@ +/* + * + * * Copyright (c) BlazeCode / Ralf Lehmann, 2022. + * + */ + +package com.blazecode.tsviewer.wear.screens + +import androidx.compose.runtime.Composable + +@Composable +fun ClientList(){ + +} \ No newline at end of file diff --git a/wear/src/main/java/com/blazecode/tsviewer/wear/screens/Home.kt b/wear/src/main/java/com/blazecode/tsviewer/wear/screens/Home.kt new file mode 100644 index 0000000..349775c --- /dev/null +++ b/wear/src/main/java/com/blazecode/tsviewer/wear/screens/Home.kt @@ -0,0 +1,39 @@ +/* + * + * * Copyright (c) BlazeCode / Ralf Lehmann, 2022. + * + */ + +package com.blazecode.tsviewer.wear.screens + +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.text.BasicTextField +import androidx.compose.foundation.text.KeyboardOptions +import androidx.compose.runtime.Composable +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.text.input.KeyboardType +import androidx.wear.compose.material.Button +import androidx.wear.compose.material.Text +import com.blazecode.tsviewer.wear.complication.ComplicationDataHolder +import com.blazecode.tsviewer.wear.complication.ComplicationProvider + +@Composable +fun Home() { + val text = remember { mutableStateOf("") } + val context = LocalContext.current + BasicTextField( + value = text.value, + onValueChange = { text.value = it }, + modifier = Modifier.fillMaxWidth().background(color = Color.White), + keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number) + ) + Button(onClick = { + ComplicationDataHolder.amount = text.value.toInt() + ComplicationProvider().update(context) + }, modifier = Modifier.fillMaxWidth()) { Text("Send") } +} \ No newline at end of file From e33b2adbae4bd14a7f63c6634e395171158436a4 Mon Sep 17 00:00:00 2001 From: BlazeCodeDev Date: Sat, 19 Nov 2022 18:33:40 +0100 Subject: [PATCH 12/25] Implement navigation --- wear/build.gradle | 4 +++ .../blazecode/tsviewer/wear/MainActivity.kt | 34 +++++++------------ .../tsviewer/wear/navigation/NavRoutes.kt | 12 +++++++ .../blazecode/tsviewer/wear/screens/Home.kt | 34 +++++++++++++------ 4 files changed, 51 insertions(+), 33 deletions(-) create mode 100644 wear/src/main/java/com/blazecode/tsviewer/wear/navigation/NavRoutes.kt diff --git a/wear/build.gradle b/wear/build.gradle index 1373033..5f4c106 100644 --- a/wear/build.gradle +++ b/wear/build.gradle @@ -68,4 +68,8 @@ dependencies { //DATA STORE implementation("androidx.datastore:datastore-preferences:1.0.0") + + // NAVIGATION + implementation("androidx.navigation:navigation-compose:2.5.3") + implementation "com.google.accompanist:accompanist-navigation-animation:0.27.0" } \ No newline at end of file diff --git a/wear/src/main/java/com/blazecode/tsviewer/wear/MainActivity.kt b/wear/src/main/java/com/blazecode/tsviewer/wear/MainActivity.kt index 273f52e..25d9185 100644 --- a/wear/src/main/java/com/blazecode/tsviewer/wear/MainActivity.kt +++ b/wear/src/main/java/com/blazecode/tsviewer/wear/MainActivity.kt @@ -4,41 +4,31 @@ * */ -/* While this template provides a good starting point for using Wear Compose, you can always - * take a look at https://github.com/android/wear-os-samples/tree/main/ComposeStarter and - * https://github.com/android/wear-os-samples/tree/main/ComposeAdvanced to find the most up to date - * changes to the libraries and their usages. - */ - package com.blazecode.tsviewer.wear import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.ui.Modifier -import androidx.wear.compose.material.MaterialTheme +import androidx.compose.animation.ExperimentalAnimationApi +import com.blazecode.tsviewer.wear.navigation.NavRoutes +import com.blazecode.tsviewer.wear.screens.ClientList import com.blazecode.tsviewer.wear.screens.Home -import com.blazecode.tsviewer.wear.theme.TSViewerTheme +import com.google.accompanist.navigation.animation.AnimatedNavHost +import com.google.accompanist.navigation.animation.composable +import com.google.accompanist.navigation.animation.rememberAnimatedNavController class MainActivity : ComponentActivity() { + @OptIn(ExperimentalAnimationApi::class) override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { - TSViewerTheme { - Column( - modifier = Modifier - .fillMaxSize() - .background(MaterialTheme.colors.surface), - verticalArrangement = Arrangement.Center - ) { - Home() - } + val navController = rememberAnimatedNavController() + AnimatedNavHost(navController = navController, startDestination = NavRoutes.Home.route){ + composable(NavRoutes.Home.route) { Home() } + composable(NavRoutes.ClientList.route) { ClientList() } } + } } } \ No newline at end of file diff --git a/wear/src/main/java/com/blazecode/tsviewer/wear/navigation/NavRoutes.kt b/wear/src/main/java/com/blazecode/tsviewer/wear/navigation/NavRoutes.kt new file mode 100644 index 0000000..9961450 --- /dev/null +++ b/wear/src/main/java/com/blazecode/tsviewer/wear/navigation/NavRoutes.kt @@ -0,0 +1,12 @@ +/* + * + * * Copyright (c) BlazeCode / Ralf Lehmann, 2022. + * + */ + +package com.blazecode.tsviewer.wear.navigation + +sealed class NavRoutes(val route: String) { + object Home: NavRoutes("home") + object ClientList: NavRoutes("clientList") +} \ No newline at end of file diff --git a/wear/src/main/java/com/blazecode/tsviewer/wear/screens/Home.kt b/wear/src/main/java/com/blazecode/tsviewer/wear/screens/Home.kt index 349775c..8224547 100644 --- a/wear/src/main/java/com/blazecode/tsviewer/wear/screens/Home.kt +++ b/wear/src/main/java/com/blazecode/tsviewer/wear/screens/Home.kt @@ -7,7 +7,7 @@ package com.blazecode.tsviewer.wear.screens import androidx.compose.foundation.background -import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.* import androidx.compose.foundation.text.BasicTextField import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.runtime.Composable @@ -21,19 +21,31 @@ import androidx.wear.compose.material.Button import androidx.wear.compose.material.Text import com.blazecode.tsviewer.wear.complication.ComplicationDataHolder import com.blazecode.tsviewer.wear.complication.ComplicationProvider +import com.blazecode.tsviewer.wear.theme.TSViewerTheme @Composable fun Home() { + TSViewerTheme { + MainLayout() + } +} + +@Composable +private fun MainLayout(){ val text = remember { mutableStateOf("") } val context = LocalContext.current - BasicTextField( - value = text.value, - onValueChange = { text.value = it }, - modifier = Modifier.fillMaxWidth().background(color = Color.White), - keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number) - ) - Button(onClick = { - ComplicationDataHolder.amount = text.value.toInt() - ComplicationProvider().update(context) - }, modifier = Modifier.fillMaxWidth()) { Text("Send") } + Box (modifier = Modifier.fillMaxSize()){ + Column (verticalArrangement = Arrangement.Center){ + BasicTextField( + value = text.value, + onValueChange = { text.value = it }, + modifier = Modifier.fillMaxWidth().background(color = Color.White), + keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number) + ) + Button(onClick = { + ComplicationDataHolder.amount = text.value.toInt() + ComplicationProvider().update(context) + }, modifier = Modifier.fillMaxWidth()) { Text("Send") } + } + } } \ No newline at end of file From 1933b89e6297680ef3831c9729ec81c5e714cbc9 Mon Sep 17 00:00:00 2001 From: BlazeCodeDev Date: Mon, 21 Nov 2022 15:07:21 +0100 Subject: [PATCH 13/25] Implement messageClient --- app/build.gradle | 4 ++ .../blazecode/tsviewer/util/ClientsWorker.kt | 3 + .../tsviewer/util/wear/WearMessageManager.kt | 55 +++++++++++++++++++ app/src/main/res/values/wear.xml | 11 ++++ .../blazecode/tsviewer/wear/MainActivity.kt | 14 ++++- .../communication/MessageReceivedListener.kt | 23 ++++++++ .../complication/ComplicationDataHolder.kt | 1 + .../wear/complication/ComplicationProvider.kt | 18 +++--- .../wear/complication/ComplicationReceiver.kt | 19 ------- .../tsviewer/wear/screens/ClientList.kt | 12 +++- .../blazecode/tsviewer/wear/screens/Home.kt | 3 +- 11 files changed, 131 insertions(+), 32 deletions(-) create mode 100644 app/src/main/java/com/blazecode/tsviewer/util/wear/WearMessageManager.kt create mode 100644 app/src/main/res/values/wear.xml create mode 100644 wear/src/main/java/com/blazecode/tsviewer/wear/communication/MessageReceivedListener.kt delete mode 100644 wear/src/main/java/com/blazecode/tsviewer/wear/complication/ComplicationReceiver.kt diff --git a/app/build.gradle b/app/build.gradle index e780f6e..f448dd6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -94,4 +94,8 @@ dependencies { //KLAXON FOR PARSING JSON implementation 'com.beust:klaxon:5.6' + + //WEAR INTEGRATION + wearApp project(':wear') + implementation 'com.google.android.gms:play-services-wearable:18.0.0' } \ No newline at end of file diff --git a/app/src/main/java/com/blazecode/tsviewer/util/ClientsWorker.kt b/app/src/main/java/com/blazecode/tsviewer/util/ClientsWorker.kt index 1431242..64d137b 100644 --- a/app/src/main/java/com/blazecode/tsviewer/util/ClientsWorker.kt +++ b/app/src/main/java/com/blazecode/tsviewer/util/ClientsWorker.kt @@ -24,6 +24,7 @@ import com.blazecode.tsviewer.util.database.UserCountDAO import com.blazecode.tsviewer.util.database.UserCountDatabase import com.blazecode.tsviewer.util.notification.ClientNotificationManager import com.blazecode.tsviewer.util.tile.TileManager +import com.blazecode.tsviewer.util.wear.WearMessageManager import com.github.theholywaffle.teamspeak3.api.wrapper.Client @@ -35,6 +36,7 @@ class ClientsWorker(private val context: Context, workerParameters: WorkerParame val connectionManager = ConnectionManager(context) val clientNotificationManager = ClientNotificationManager(context) val tileManager = TileManager(context) + val wearMessageManager = WearMessageManager(context) val errorHandler = ErrorHandler(context) lateinit var db: UserCountDatabase @@ -77,6 +79,7 @@ class ClientsWorker(private val context: Context, workerParameters: WorkerParame extractNames() clientNotificationManager.post(clientListNames) + wearMessageManager.sendMessage(clientListNames) writeClients(clientListNames) } diff --git a/app/src/main/java/com/blazecode/tsviewer/util/wear/WearMessageManager.kt b/app/src/main/java/com/blazecode/tsviewer/util/wear/WearMessageManager.kt new file mode 100644 index 0000000..d305be0 --- /dev/null +++ b/app/src/main/java/com/blazecode/tsviewer/util/wear/WearMessageManager.kt @@ -0,0 +1,55 @@ +/* + * + * * Copyright (c) BlazeCode / Ralf Lehmann, 2022. + * + */ + +package com.blazecode.tsviewer.util.wear + +import android.content.Context +import android.widget.Toast +import com.google.android.gms.tasks.Task +import com.google.android.gms.tasks.Tasks +import com.google.android.gms.wearable.CapabilityClient +import com.google.android.gms.wearable.CapabilityInfo +import com.google.android.gms.wearable.Node +import com.google.android.gms.wearable.Wearable + +class WearMessageManager(val context: Context) { + + private val CLIENT_SHARING_CAPABILITY = "client_sharing" + private val CLIENT_SHARING_CAPABILITY_PATH = "/client_sharing" + private var nodeId: String? = null + + fun setupClientSharing(){ + val capabilityInfo: CapabilityInfo = Tasks.await( + Wearable.getCapabilityClient(context) + .getCapability(CLIENT_SHARING_CAPABILITY, CapabilityClient.FILTER_REACHABLE) + ) + updateCapability(capabilityInfo) + } + + fun sendMessage(clientList: MutableList){ + setupClientSharing() + val string: String = "test" + nodeId?.also { nodeId -> + val sendTask: Task<*> = Wearable.getMessageClient(context).sendMessage( + nodeId, + CLIENT_SHARING_CAPABILITY_PATH, + string.toByteArray(Charsets.UTF_8) + ).apply { + addOnSuccessListener { Toast.makeText(context, "Sent", Toast.LENGTH_SHORT).show() } + addOnFailureListener { Toast.makeText(context, exception.toString(), Toast.LENGTH_SHORT).show() } + } + } + + } + + private fun updateCapability(capabilityInfo: CapabilityInfo){ + nodeId = bestNodeId(capabilityInfo.nodes) + } + + private fun bestNodeId(nodes: Set): String? { + return nodes.firstOrNull { it.isNearby }?.id ?: nodes.firstOrNull()?.id + } +} \ No newline at end of file diff --git a/app/src/main/res/values/wear.xml b/app/src/main/res/values/wear.xml new file mode 100644 index 0000000..950ea39 --- /dev/null +++ b/app/src/main/res/values/wear.xml @@ -0,0 +1,11 @@ + + + + + client_sharing + + \ No newline at end of file diff --git a/wear/src/main/java/com/blazecode/tsviewer/wear/MainActivity.kt b/wear/src/main/java/com/blazecode/tsviewer/wear/MainActivity.kt index 25d9185..b31488d 100644 --- a/wear/src/main/java/com/blazecode/tsviewer/wear/MainActivity.kt +++ b/wear/src/main/java/com/blazecode/tsviewer/wear/MainActivity.kt @@ -10,23 +10,31 @@ import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.compose.animation.ExperimentalAnimationApi +import com.blazecode.tsviewer.wear.communication.MessageReceivedListener import com.blazecode.tsviewer.wear.navigation.NavRoutes import com.blazecode.tsviewer.wear.screens.ClientList import com.blazecode.tsviewer.wear.screens.Home import com.google.accompanist.navigation.animation.AnimatedNavHost import com.google.accompanist.navigation.animation.composable import com.google.accompanist.navigation.animation.rememberAnimatedNavController +import com.google.android.gms.wearable.Wearable class MainActivity : ComponentActivity() { @OptIn(ExperimentalAnimationApi::class) override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + + Wearable.getMessageClient(this).addListener(MessageReceivedListener(this)) + setContent { + // CHECK IF COMPLICATION WAS TAPPED + val complicationTapped = intent.extras?.getBoolean("openClientScreen") + val startDestination = if(complicationTapped != null) NavRoutes.ClientList.route else NavRoutes.Home.route val navController = rememberAnimatedNavController() - AnimatedNavHost(navController = navController, startDestination = NavRoutes.Home.route){ - composable(NavRoutes.Home.route) { Home() } - composable(NavRoutes.ClientList.route) { ClientList() } + AnimatedNavHost(navController = navController, startDestination = startDestination){ + composable(NavRoutes.Home.route) { Home(navController) } + composable(NavRoutes.ClientList.route) { ClientList(navController) } } } diff --git a/wear/src/main/java/com/blazecode/tsviewer/wear/communication/MessageReceivedListener.kt b/wear/src/main/java/com/blazecode/tsviewer/wear/communication/MessageReceivedListener.kt new file mode 100644 index 0000000..55c133b --- /dev/null +++ b/wear/src/main/java/com/blazecode/tsviewer/wear/communication/MessageReceivedListener.kt @@ -0,0 +1,23 @@ +/* + * + * * Copyright (c) BlazeCode / Ralf Lehmann, 2022. + * + */ + +package com.blazecode.tsviewer.wear.communication + +import android.content.Context +import android.util.Log +import com.blazecode.tsviewer.wear.complication.ComplicationDataHolder +import com.blazecode.tsviewer.wear.complication.ComplicationProvider +import com.google.android.gms.wearable.MessageClient +import com.google.android.gms.wearable.MessageEvent + +class MessageReceivedListener(val context: Context): MessageClient.OnMessageReceivedListener { + + override fun onMessageReceived(messageEvent: MessageEvent) { + Log.d("messages", messageEvent.toString()) + ComplicationDataHolder.list = mutableListOf(messageEvent.toString()) + ComplicationProvider().update(context) + } +} \ No newline at end of file diff --git a/wear/src/main/java/com/blazecode/tsviewer/wear/complication/ComplicationDataHolder.kt b/wear/src/main/java/com/blazecode/tsviewer/wear/complication/ComplicationDataHolder.kt index 2abd2ac..de14793 100644 --- a/wear/src/main/java/com/blazecode/tsviewer/wear/complication/ComplicationDataHolder.kt +++ b/wear/src/main/java/com/blazecode/tsviewer/wear/complication/ComplicationDataHolder.kt @@ -8,4 +8,5 @@ package com.blazecode.tsviewer.wear.complication object ComplicationDataHolder { var amount: Int = 0 + var list: MutableList = mutableListOf() } \ No newline at end of file diff --git a/wear/src/main/java/com/blazecode/tsviewer/wear/complication/ComplicationProvider.kt b/wear/src/main/java/com/blazecode/tsviewer/wear/complication/ComplicationProvider.kt index a115aab..0ea3d7e 100644 --- a/wear/src/main/java/com/blazecode/tsviewer/wear/complication/ComplicationProvider.kt +++ b/wear/src/main/java/com/blazecode/tsviewer/wear/complication/ComplicationProvider.kt @@ -7,6 +7,7 @@ package com.blazecode.tsviewer.wear.complication import android.app.PendingIntent +import android.app.TaskStackBuilder import android.content.ComponentName import android.content.Context import android.content.Intent @@ -16,9 +17,7 @@ import androidx.wear.watchface.complications.datasource.ComplicationDataSourceSe import androidx.wear.watchface.complications.datasource.ComplicationDataSourceUpdateRequester import androidx.wear.watchface.complications.datasource.ComplicationRequest import com.blazecode.tsviewer.R - - -// https://github.com/android/wear-os-samples/blob/main/WearComplicationDataSourcesTestSuite/Wearable/src/main/java/com/example/android/wearable/wear/wearcomplicationproviderstestsuite/LongTextDataSourceService.kt +import com.blazecode.tsviewer.wear.MainActivity class ComplicationProvider: ComplicationDataSourceService() { @@ -29,12 +28,15 @@ class ComplicationProvider: ComplicationDataSourceService() { } override fun onComplicationRequest(request: ComplicationRequest, listener: ComplicationRequestListener) { - val intent = Intent(this, ComplicationReceiver::class.java).apply { - putExtra("amount", dataHolder.amount) + + val tapIntent = Intent(this, MainActivity::class.java) + .putExtra("openClientScreen", true) + val tapPendingIntent: PendingIntent? = TaskStackBuilder.create(this).run { + addNextIntentWithParentStack(tapIntent) + getPendingIntent(dataHolder.amount, PendingIntent.FLAG_IMMUTABLE) } - val pendingIntent = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) - listener.onComplicationData(getComplicationData(pendingIntent)) + listener.onComplicationData(getComplicationData(tapPendingIntent)) } private fun getComplicationData(tapAction: PendingIntent?): ComplicationData{ @@ -42,7 +44,7 @@ class ComplicationProvider: ComplicationDataSourceService() { return ShortTextComplicationData.Builder( text = PlainComplicationText.Builder( - text = dataHolder.amount.toString() + text = dataHolder.list.size.toString() ).build(), contentDescription = PlainComplicationText.Builder( diff --git a/wear/src/main/java/com/blazecode/tsviewer/wear/complication/ComplicationReceiver.kt b/wear/src/main/java/com/blazecode/tsviewer/wear/complication/ComplicationReceiver.kt deleted file mode 100644 index c23280b..0000000 --- a/wear/src/main/java/com/blazecode/tsviewer/wear/complication/ComplicationReceiver.kt +++ /dev/null @@ -1,19 +0,0 @@ -/* - * - * * Copyright (c) BlazeCode / Ralf Lehmann, 2022. - * - */ - -package com.blazecode.tsviewer.wear.complication - -import android.content.BroadcastReceiver -import android.content.Context -import android.content.Intent -import android.util.Log - -class ComplicationReceiver: BroadcastReceiver() { - override fun onReceive(context: Context?, intent: Intent?) { - val amount = intent?.extras?.getInt("amount") - Log.d("test", amount.toString()) - } -} \ No newline at end of file diff --git a/wear/src/main/java/com/blazecode/tsviewer/wear/screens/ClientList.kt b/wear/src/main/java/com/blazecode/tsviewer/wear/screens/ClientList.kt index 236700d..a9385e6 100644 --- a/wear/src/main/java/com/blazecode/tsviewer/wear/screens/ClientList.kt +++ b/wear/src/main/java/com/blazecode/tsviewer/wear/screens/ClientList.kt @@ -6,9 +6,19 @@ package com.blazecode.tsviewer.wear.screens +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.navigation.NavController +import androidx.wear.compose.material.Text +import com.blazecode.tsviewer.wear.complication.ComplicationDataHolder @Composable -fun ClientList(){ +fun ClientList(navController: NavController){ + Box(modifier = Modifier.fillMaxSize()){ + Text(modifier = Modifier.align(Alignment.Center), text = ComplicationDataHolder.list.joinToString()) + } } \ No newline at end of file diff --git a/wear/src/main/java/com/blazecode/tsviewer/wear/screens/Home.kt b/wear/src/main/java/com/blazecode/tsviewer/wear/screens/Home.kt index 8224547..4d17216 100644 --- a/wear/src/main/java/com/blazecode/tsviewer/wear/screens/Home.kt +++ b/wear/src/main/java/com/blazecode/tsviewer/wear/screens/Home.kt @@ -17,6 +17,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.text.input.KeyboardType +import androidx.navigation.NavController import androidx.wear.compose.material.Button import androidx.wear.compose.material.Text import com.blazecode.tsviewer.wear.complication.ComplicationDataHolder @@ -24,7 +25,7 @@ import com.blazecode.tsviewer.wear.complication.ComplicationProvider import com.blazecode.tsviewer.wear.theme.TSViewerTheme @Composable -fun Home() { +fun Home(navController: NavController) { TSViewerTheme { MainLayout() } From 61039fcdbe312d6af6468c4c4e35cdc61ee2729b Mon Sep 17 00:00:00 2001 From: BlazeCodeDev Date: Sat, 26 Nov 2022 19:38:16 +0100 Subject: [PATCH 14/25] Working data layer --- app/build.gradle | 6 +- wear/build.gradle | 5 +- wear/src/main/AndroidManifest.xml | 49 +++++++++-------- .../blazecode/tsviewer/wear/MainActivity.kt | 5 -- .../communication/MessageReceivedListener.kt | 23 -------- .../communication/WearableListenerService.kt | 55 +++++++++++++++++++ 6 files changed, 89 insertions(+), 54 deletions(-) delete mode 100644 wear/src/main/java/com/blazecode/tsviewer/wear/communication/MessageReceivedListener.kt create mode 100644 wear/src/main/java/com/blazecode/tsviewer/wear/communication/WearableListenerService.kt diff --git a/app/build.gradle b/app/build.gradle index f448dd6..b21e27f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -12,6 +12,7 @@ plugins { } android { + namespace 'com.blazecode.tsviewer' compileSdk 33 defaultConfig { @@ -29,6 +30,9 @@ android { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } + debug { + signingConfig signingConfigs.debug + } } compileOptions { sourceCompatibility JavaVersion.VERSION_11 @@ -40,7 +44,6 @@ android { buildFeatures { viewBinding true } - namespace 'com.blazecode.tsviewer' } dependencies { @@ -61,6 +64,7 @@ dependencies { //COROUTINES implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.6.4' //WORK MANAGER implementation 'androidx.work:work-runtime-ktx:2.7.1' diff --git a/wear/build.gradle b/wear/build.gradle index 5f4c106..eb8b0fe 100644 --- a/wear/build.gradle +++ b/wear/build.gradle @@ -11,7 +11,7 @@ android { defaultConfig { applicationId "com.blazecode.tsviewer" minSdkVersion 26 - targetSdkVersion 33 + targetSdkVersion 30 versionCode 1 versionName "1.0" vectorDrawables { @@ -25,6 +25,9 @@ android { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } + debug { + signingConfig signingConfigs.debug + } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 diff --git a/wear/src/main/AndroidManifest.xml b/wear/src/main/AndroidManifest.xml index c1c5897..6707e83 100644 --- a/wear/src/main/AndroidManifest.xml +++ b/wear/src/main/AndroidManifest.xml @@ -17,35 +17,14 @@ 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/java/com/blazecode/tsviewer/wear/MainActivity.kt b/wear/src/main/java/com/blazecode/tsviewer/wear/MainActivity.kt index b31488d..38788f8 100644 --- a/wear/src/main/java/com/blazecode/tsviewer/wear/MainActivity.kt +++ b/wear/src/main/java/com/blazecode/tsviewer/wear/MainActivity.kt @@ -10,22 +10,18 @@ import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.compose.animation.ExperimentalAnimationApi -import com.blazecode.tsviewer.wear.communication.MessageReceivedListener import com.blazecode.tsviewer.wear.navigation.NavRoutes import com.blazecode.tsviewer.wear.screens.ClientList import com.blazecode.tsviewer.wear.screens.Home import com.google.accompanist.navigation.animation.AnimatedNavHost import com.google.accompanist.navigation.animation.composable import com.google.accompanist.navigation.animation.rememberAnimatedNavController -import com.google.android.gms.wearable.Wearable class MainActivity : ComponentActivity() { @OptIn(ExperimentalAnimationApi::class) override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - Wearable.getMessageClient(this).addListener(MessageReceivedListener(this)) - setContent { // CHECK IF COMPLICATION WAS TAPPED val complicationTapped = intent.extras?.getBoolean("openClientScreen") @@ -36,7 +32,6 @@ class MainActivity : ComponentActivity() { composable(NavRoutes.Home.route) { Home(navController) } composable(NavRoutes.ClientList.route) { ClientList(navController) } } - } } } \ No newline at end of file diff --git a/wear/src/main/java/com/blazecode/tsviewer/wear/communication/MessageReceivedListener.kt b/wear/src/main/java/com/blazecode/tsviewer/wear/communication/MessageReceivedListener.kt deleted file mode 100644 index 55c133b..0000000 --- a/wear/src/main/java/com/blazecode/tsviewer/wear/communication/MessageReceivedListener.kt +++ /dev/null @@ -1,23 +0,0 @@ -/* - * - * * Copyright (c) BlazeCode / Ralf Lehmann, 2022. - * - */ - -package com.blazecode.tsviewer.wear.communication - -import android.content.Context -import android.util.Log -import com.blazecode.tsviewer.wear.complication.ComplicationDataHolder -import com.blazecode.tsviewer.wear.complication.ComplicationProvider -import com.google.android.gms.wearable.MessageClient -import com.google.android.gms.wearable.MessageEvent - -class MessageReceivedListener(val context: Context): MessageClient.OnMessageReceivedListener { - - override fun onMessageReceived(messageEvent: MessageEvent) { - Log.d("messages", messageEvent.toString()) - ComplicationDataHolder.list = mutableListOf(messageEvent.toString()) - ComplicationProvider().update(context) - } -} \ No newline at end of file diff --git a/wear/src/main/java/com/blazecode/tsviewer/wear/communication/WearableListenerService.kt b/wear/src/main/java/com/blazecode/tsviewer/wear/communication/WearableListenerService.kt new file mode 100644 index 0000000..5dbdf5c --- /dev/null +++ b/wear/src/main/java/com/blazecode/tsviewer/wear/communication/WearableListenerService.kt @@ -0,0 +1,55 @@ +/* + * + * * Copyright (c) BlazeCode / Ralf Lehmann, 2022. + * + */ + +package com.blazecode.tsviewer.wear.communication + +import com.blazecode.tsviewer.wear.complication.ComplicationDataHolder +import com.blazecode.tsviewer.wear.complication.ComplicationProvider +import com.google.android.gms.wearable.DataEventBuffer +import com.google.android.gms.wearable.DataMapItem +import com.google.android.gms.wearable.WearableListenerService +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.cancel + +class WearableListenerService: WearableListenerService() { + + companion object { + const val CLIENTS_PATH = "/clients" + private const val CLIENT_LIST_KEY = "clientlist" + } + + private val scope = CoroutineScope(SupervisorJob() + Dispatchers.Main) + + override fun onDataChanged(dataEvents: DataEventBuffer) { + super.onDataChanged(dataEvents) + + dataEvents.forEach { event -> + event.dataItem.also { item -> + if (item.uri.path!!.compareTo(CLIENTS_PATH) == 0) { + DataMapItem.fromDataItem(item).dataMap.apply { + val clientList = getStringArray(CLIENT_LIST_KEY) + + if(!clientList.isNullOrEmpty()){ + ComplicationDataHolder.list = clientList.toMutableList() + ComplicationProvider().update(this@WearableListenerService) + } else { + ComplicationDataHolder.list = mutableListOf() + ComplicationProvider().update(this@WearableListenerService) + } + + } + } + } + } + } + + override fun onDestroy() { + super.onDestroy() + scope.cancel() + } +} \ No newline at end of file From 10bebe322a05945adab02b6379c64f7037f055f3 Mon Sep 17 00:00:00 2001 From: BlazeCodeDev Date: Sat, 26 Nov 2022 19:39:08 +0100 Subject: [PATCH 15/25] Working data layer --- .../com/blazecode/tsviewer/MainActivity.kt | 1 + .../blazecode/tsviewer/util/ClientsWorker.kt | 6 +- .../tsviewer/util/wear/WearDataManager.kt | 36 ++++++++++++ .../tsviewer/util/wear/WearMessageManager.kt | 55 ------------------- 4 files changed, 40 insertions(+), 58 deletions(-) create mode 100644 app/src/main/java/com/blazecode/tsviewer/util/wear/WearDataManager.kt delete mode 100644 app/src/main/java/com/blazecode/tsviewer/util/wear/WearMessageManager.kt diff --git a/app/src/main/java/com/blazecode/tsviewer/MainActivity.kt b/app/src/main/java/com/blazecode/tsviewer/MainActivity.kt index 4a18425..bd31afa 100644 --- a/app/src/main/java/com/blazecode/tsviewer/MainActivity.kt +++ b/app/src/main/java/com/blazecode/tsviewer/MainActivity.kt @@ -40,6 +40,7 @@ import com.blazecode.tsviewer.util.updater.GitHubUpdater import com.blazecode.tsviewer.util.updater.UpdateCheckWorker import com.google.android.material.snackbar.Snackbar import com.mikepenz.aboutlibraries.LibsBuilder +import kotlinx.coroutines.* import timber.log.Timber import java.util.concurrent.TimeUnit import kotlin.coroutines.EmptyCoroutineContext diff --git a/app/src/main/java/com/blazecode/tsviewer/util/ClientsWorker.kt b/app/src/main/java/com/blazecode/tsviewer/util/ClientsWorker.kt index 64d137b..812a433 100644 --- a/app/src/main/java/com/blazecode/tsviewer/util/ClientsWorker.kt +++ b/app/src/main/java/com/blazecode/tsviewer/util/ClientsWorker.kt @@ -24,7 +24,7 @@ import com.blazecode.tsviewer.util.database.UserCountDAO import com.blazecode.tsviewer.util.database.UserCountDatabase import com.blazecode.tsviewer.util.notification.ClientNotificationManager import com.blazecode.tsviewer.util.tile.TileManager -import com.blazecode.tsviewer.util.wear.WearMessageManager +import com.blazecode.tsviewer.util.wear.WearDataManager import com.github.theholywaffle.teamspeak3.api.wrapper.Client @@ -36,7 +36,7 @@ class ClientsWorker(private val context: Context, workerParameters: WorkerParame val connectionManager = ConnectionManager(context) val clientNotificationManager = ClientNotificationManager(context) val tileManager = TileManager(context) - val wearMessageManager = WearMessageManager(context) + val wearDataManager = WearDataManager(context) val errorHandler = ErrorHandler(context) lateinit var db: UserCountDatabase @@ -79,7 +79,7 @@ class ClientsWorker(private val context: Context, workerParameters: WorkerParame extractNames() clientNotificationManager.post(clientListNames) - wearMessageManager.sendMessage(clientListNames) + wearDataManager.sendClientList(clientListNames) writeClients(clientListNames) } diff --git a/app/src/main/java/com/blazecode/tsviewer/util/wear/WearDataManager.kt b/app/src/main/java/com/blazecode/tsviewer/util/wear/WearDataManager.kt new file mode 100644 index 0000000..018d25e --- /dev/null +++ b/app/src/main/java/com/blazecode/tsviewer/util/wear/WearDataManager.kt @@ -0,0 +1,36 @@ +/* + * + * * Copyright (c) BlazeCode / Ralf Lehmann, 2022. + * + */ + +package com.blazecode.tsviewer.util.wear + +import android.content.Context +import com.google.android.gms.wearable.PutDataMapRequest +import com.google.android.gms.wearable.Wearable + +class WearDataManager(val context: Context) { + + private val dataClient by lazy { Wearable.getDataClient(context) } + + companion object { + private const val CLIENTS_PATH = "/clients" + private const val CLIENT_LIST_KEY = "clientlist" + } + + fun sendClientList(clientList: MutableList) { + var clientArray: Array = arrayOf() + for (client in clientList) { + clientArray += client + } + + val request = PutDataMapRequest.create(CLIENTS_PATH).apply { + dataMap.putStringArray(CLIENT_LIST_KEY, clientArray) + } + .asPutDataRequest() + .setUrgent() + + val result = dataClient.putDataItem(request) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/blazecode/tsviewer/util/wear/WearMessageManager.kt b/app/src/main/java/com/blazecode/tsviewer/util/wear/WearMessageManager.kt deleted file mode 100644 index d305be0..0000000 --- a/app/src/main/java/com/blazecode/tsviewer/util/wear/WearMessageManager.kt +++ /dev/null @@ -1,55 +0,0 @@ -/* - * - * * Copyright (c) BlazeCode / Ralf Lehmann, 2022. - * - */ - -package com.blazecode.tsviewer.util.wear - -import android.content.Context -import android.widget.Toast -import com.google.android.gms.tasks.Task -import com.google.android.gms.tasks.Tasks -import com.google.android.gms.wearable.CapabilityClient -import com.google.android.gms.wearable.CapabilityInfo -import com.google.android.gms.wearable.Node -import com.google.android.gms.wearable.Wearable - -class WearMessageManager(val context: Context) { - - private val CLIENT_SHARING_CAPABILITY = "client_sharing" - private val CLIENT_SHARING_CAPABILITY_PATH = "/client_sharing" - private var nodeId: String? = null - - fun setupClientSharing(){ - val capabilityInfo: CapabilityInfo = Tasks.await( - Wearable.getCapabilityClient(context) - .getCapability(CLIENT_SHARING_CAPABILITY, CapabilityClient.FILTER_REACHABLE) - ) - updateCapability(capabilityInfo) - } - - fun sendMessage(clientList: MutableList){ - setupClientSharing() - val string: String = "test" - nodeId?.also { nodeId -> - val sendTask: Task<*> = Wearable.getMessageClient(context).sendMessage( - nodeId, - CLIENT_SHARING_CAPABILITY_PATH, - string.toByteArray(Charsets.UTF_8) - ).apply { - addOnSuccessListener { Toast.makeText(context, "Sent", Toast.LENGTH_SHORT).show() } - addOnFailureListener { Toast.makeText(context, exception.toString(), Toast.LENGTH_SHORT).show() } - } - } - - } - - private fun updateCapability(capabilityInfo: CapabilityInfo){ - nodeId = bestNodeId(capabilityInfo.nodes) - } - - private fun bestNodeId(nodes: Set): String? { - return nodes.firstOrNull { it.isNearby }?.id ?: nodes.firstOrNull()?.id - } -} \ No newline at end of file From b370c71246c7580289f16341ae5c5213cd499644 Mon Sep 17 00:00:00 2001 From: BlazeCodeDev Date: Sun, 27 Nov 2022 12:12:27 +0100 Subject: [PATCH 16/25] Finish ClientList screen --- .../blazecode/tsviewer/wear/MainActivity.kt | 2 +- .../communication/WearableListenerService.kt | 1 + .../complication/ComplicationDataHolder.kt | 2 +- .../wear/complication/ComplicationProvider.kt | 2 +- .../tsviewer/wear/screens/ClientList.kt | 63 ++++++++++++++++--- .../blazecode/tsviewer/wear/screens/Home.kt | 25 ++------ wear/src/main/res/values-round/strings.xml | 3 - wear/src/main/res/values/dimen.xml | 12 ++++ wear/src/main/res/values/strings.xml | 5 +- 9 files changed, 81 insertions(+), 34 deletions(-) delete mode 100644 wear/src/main/res/values-round/strings.xml create mode 100644 wear/src/main/res/values/dimen.xml diff --git a/wear/src/main/java/com/blazecode/tsviewer/wear/MainActivity.kt b/wear/src/main/java/com/blazecode/tsviewer/wear/MainActivity.kt index 38788f8..202022a 100644 --- a/wear/src/main/java/com/blazecode/tsviewer/wear/MainActivity.kt +++ b/wear/src/main/java/com/blazecode/tsviewer/wear/MainActivity.kt @@ -30,7 +30,7 @@ class MainActivity : ComponentActivity() { val navController = rememberAnimatedNavController() AnimatedNavHost(navController = navController, startDestination = startDestination){ composable(NavRoutes.Home.route) { Home(navController) } - composable(NavRoutes.ClientList.route) { ClientList(navController) } + composable(NavRoutes.ClientList.route) { ClientList() } } } } diff --git a/wear/src/main/java/com/blazecode/tsviewer/wear/communication/WearableListenerService.kt b/wear/src/main/java/com/blazecode/tsviewer/wear/communication/WearableListenerService.kt index 5dbdf5c..76d4c2e 100644 --- a/wear/src/main/java/com/blazecode/tsviewer/wear/communication/WearableListenerService.kt +++ b/wear/src/main/java/com/blazecode/tsviewer/wear/communication/WearableListenerService.kt @@ -33,6 +33,7 @@ class WearableListenerService: WearableListenerService() { if (item.uri.path!!.compareTo(CLIENTS_PATH) == 0) { DataMapItem.fromDataItem(item).dataMap.apply { val clientList = getStringArray(CLIENT_LIST_KEY) + ComplicationDataHolder.time = System.currentTimeMillis() if(!clientList.isNullOrEmpty()){ ComplicationDataHolder.list = clientList.toMutableList() diff --git a/wear/src/main/java/com/blazecode/tsviewer/wear/complication/ComplicationDataHolder.kt b/wear/src/main/java/com/blazecode/tsviewer/wear/complication/ComplicationDataHolder.kt index de14793..5b97488 100644 --- a/wear/src/main/java/com/blazecode/tsviewer/wear/complication/ComplicationDataHolder.kt +++ b/wear/src/main/java/com/blazecode/tsviewer/wear/complication/ComplicationDataHolder.kt @@ -7,6 +7,6 @@ package com.blazecode.tsviewer.wear.complication object ComplicationDataHolder { - var amount: Int = 0 var list: MutableList = mutableListOf() + var time: Long = 0 } \ No newline at end of file diff --git a/wear/src/main/java/com/blazecode/tsviewer/wear/complication/ComplicationProvider.kt b/wear/src/main/java/com/blazecode/tsviewer/wear/complication/ComplicationProvider.kt index 0ea3d7e..7178023 100644 --- a/wear/src/main/java/com/blazecode/tsviewer/wear/complication/ComplicationProvider.kt +++ b/wear/src/main/java/com/blazecode/tsviewer/wear/complication/ComplicationProvider.kt @@ -33,7 +33,7 @@ class ComplicationProvider: ComplicationDataSourceService() { .putExtra("openClientScreen", true) val tapPendingIntent: PendingIntent? = TaskStackBuilder.create(this).run { addNextIntentWithParentStack(tapIntent) - getPendingIntent(dataHolder.amount, PendingIntent.FLAG_IMMUTABLE) + getPendingIntent(dataHolder.list.size, PendingIntent.FLAG_IMMUTABLE) } listener.onComplicationData(getComplicationData(tapPendingIntent)) diff --git a/wear/src/main/java/com/blazecode/tsviewer/wear/screens/ClientList.kt b/wear/src/main/java/com/blazecode/tsviewer/wear/screens/ClientList.kt index a9385e6..3d363c6 100644 --- a/wear/src/main/java/com/blazecode/tsviewer/wear/screens/ClientList.kt +++ b/wear/src/main/java/com/blazecode/tsviewer/wear/screens/ClientList.kt @@ -6,19 +6,68 @@ package com.blazecode.tsviewer.wear.screens -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.focusable +import androidx.compose.foundation.gestures.animateScrollBy +import androidx.compose.foundation.gestures.scrollBy +import androidx.compose.foundation.layout.* import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier -import androidx.navigation.NavController +import androidx.compose.ui.draw.alpha +import androidx.compose.ui.focus.FocusRequester +import androidx.compose.ui.focus.focusRequester +import androidx.compose.ui.input.rotary.onPreRotaryScrollEvent +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import androidx.wear.compose.material.ScalingLazyColumn import androidx.wear.compose.material.Text +import androidx.wear.compose.material.rememberScalingLazyListState +import com.blazecode.tsviewer.R import com.blazecode.tsviewer.wear.complication.ComplicationDataHolder +import kotlinx.coroutines.launch +@OptIn(ExperimentalComposeUiApi::class) +@Preview @Composable -fun ClientList(navController: NavController){ +fun ClientList(){ - Box(modifier = Modifier.fillMaxSize()){ - Text(modifier = Modifier.align(Alignment.Center), text = ComplicationDataHolder.list.joinToString()) + val title = if(ComplicationDataHolder.list.size == 1) + stringResource(R.string.client_connected, 1) + else stringResource(R.string.clients_connected, ComplicationDataHolder.list.size) + + var timeAgo: String = ((System.currentTimeMillis() - ComplicationDataHolder.time) / 1000 / 60).toString() + if(ComplicationDataHolder.time.equals(0)) timeAgo = "N/A" + + val scrollState = rememberScalingLazyListState() + val scope = rememberCoroutineScope() + val focusRequester = remember { FocusRequester() } + LaunchedEffect(Unit) { + focusRequester.requestFocus() + } + + ScalingLazyColumn (modifier = Modifier + .onPreRotaryScrollEvent { + scope.launch { + scrollState.scrollBy(it.verticalScrollPixels) + scrollState.animateScrollBy(0f) + } + true + } + .focusRequester(focusRequester) + .focusable() + .fillMaxSize(), + state = scrollState + ){ + + item { Text(text = title, fontSize = 16.sp) } + item { Text(text = stringResource(R.string.time_ago, timeAgo), modifier = Modifier.alpha(.7f)) } + item { Spacer(modifier = Modifier.size(16.dp)) } + item { Text(text = ComplicationDataHolder.list.joinToString(), textAlign = TextAlign.Center) } } } \ No newline at end of file diff --git a/wear/src/main/java/com/blazecode/tsviewer/wear/screens/Home.kt b/wear/src/main/java/com/blazecode/tsviewer/wear/screens/Home.kt index 4d17216..02d304d 100644 --- a/wear/src/main/java/com/blazecode/tsviewer/wear/screens/Home.kt +++ b/wear/src/main/java/com/blazecode/tsviewer/wear/screens/Home.kt @@ -6,22 +6,16 @@ package com.blazecode.tsviewer.wear.screens -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.* -import androidx.compose.foundation.text.BasicTextField -import androidx.compose.foundation.text.KeyboardOptions +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.runtime.Composable import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.text.input.KeyboardType import androidx.navigation.NavController -import androidx.wear.compose.material.Button -import androidx.wear.compose.material.Text -import com.blazecode.tsviewer.wear.complication.ComplicationDataHolder -import com.blazecode.tsviewer.wear.complication.ComplicationProvider import com.blazecode.tsviewer.wear.theme.TSViewerTheme @Composable @@ -37,16 +31,7 @@ private fun MainLayout(){ val context = LocalContext.current Box (modifier = Modifier.fillMaxSize()){ Column (verticalArrangement = Arrangement.Center){ - BasicTextField( - value = text.value, - onValueChange = { text.value = it }, - modifier = Modifier.fillMaxWidth().background(color = Color.White), - keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number) - ) - Button(onClick = { - ComplicationDataHolder.amount = text.value.toInt() - ComplicationProvider().update(context) - }, modifier = Modifier.fillMaxWidth()) { Text("Send") } + } } } \ No newline at end of file diff --git a/wear/src/main/res/values-round/strings.xml b/wear/src/main/res/values-round/strings.xml deleted file mode 100644 index 42f1229..0000000 --- a/wear/src/main/res/values-round/strings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - From the Round world,\nHello, %1$s! - \ No newline at end of file diff --git a/wear/src/main/res/values/dimen.xml b/wear/src/main/res/values/dimen.xml new file mode 100644 index 0000000..c60817b --- /dev/null +++ b/wear/src/main/res/values/dimen.xml @@ -0,0 +1,12 @@ + + + + + 8dp + 16dp + 24dp + \ No newline at end of file diff --git a/wear/src/main/res/values/strings.xml b/wear/src/main/res/values/strings.xml index e9b440f..3069c74 100644 --- a/wear/src/main/res/values/strings.xml +++ b/wear/src/main/res/values/strings.xml @@ -10,5 +10,8 @@ This string is used for square devices and overridden by hello_world in values-round/strings.xml for round devices. --> - From the Square world,\nHello, %1$s! + Client List + %s Client connected + %s Clients connected + %s min ago \ No newline at end of file From 92b16e08c7ed1412e61a56232a496d7aee79e7a1 Mon Sep 17 00:00:00 2001 From: BlazeCodeDev Date: Sun, 27 Nov 2022 13:57:01 +0100 Subject: [PATCH 17/25] Add proper home screen --- .../blazecode/tsviewer/wear/screens/Home.kt | 85 +++++++++++++++---- .../com/blazecode/tsviewer/wear/theme/Type.kt | 12 +++ wear/src/main/res/drawable/ic_clients.xml | 16 ++++ wear/src/main/res/drawable/ic_open.xml | 16 ++++ wear/src/main/res/values/colors.xml | 22 +++++ wear/src/main/res/values/strings.xml | 4 +- 6 files changed, 139 insertions(+), 16 deletions(-) create mode 100644 wear/src/main/res/drawable/ic_clients.xml create mode 100644 wear/src/main/res/drawable/ic_open.xml create mode 100644 wear/src/main/res/values/colors.xml diff --git a/wear/src/main/java/com/blazecode/tsviewer/wear/screens/Home.kt b/wear/src/main/java/com/blazecode/tsviewer/wear/screens/Home.kt index 02d304d..0ab64f2 100644 --- a/wear/src/main/java/com/blazecode/tsviewer/wear/screens/Home.kt +++ b/wear/src/main/java/com/blazecode/tsviewer/wear/screens/Home.kt @@ -6,32 +6,87 @@ package com.blazecode.tsviewer.wear.screens -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.runtime.Composable -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember +import androidx.compose.foundation.focusable +import androidx.compose.foundation.gestures.animateScrollBy +import androidx.compose.foundation.gestures.scrollBy +import androidx.compose.foundation.layout.* +import androidx.compose.runtime.* +import androidx.compose.ui.Alignment +import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.draw.alpha +import androidx.compose.ui.focus.FocusRequester +import androidx.compose.ui.focus.focusRequester +import androidx.compose.ui.input.rotary.onPreRotaryScrollEvent +import androidx.compose.ui.res.colorResource +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp import androidx.navigation.NavController +import androidx.wear.compose.material.* +import com.blazecode.tsviewer.BuildConfig +import com.blazecode.tsviewer.R +import com.blazecode.tsviewer.wear.navigation.NavRoutes import com.blazecode.tsviewer.wear.theme.TSViewerTheme +import kotlinx.coroutines.launch @Composable fun Home(navController: NavController) { TSViewerTheme { - MainLayout() + MainLayout(navController) } } +@OptIn(ExperimentalComposeUiApi::class) @Composable -private fun MainLayout(){ - val text = remember { mutableStateOf("") } - val context = LocalContext.current - Box (modifier = Modifier.fillMaxSize()){ - Column (verticalArrangement = Arrangement.Center){ +private fun MainLayout(navController: NavController){ + val scrollState = rememberScalingLazyListState() + val scope = rememberCoroutineScope() + val focusRequester = remember { FocusRequester() } + LaunchedEffect(Unit) { + focusRequester.requestFocus() + } + + ScalingLazyColumn (modifier = Modifier + .onPreRotaryScrollEvent { + scope.launch { + scrollState.scrollBy(it.verticalScrollPixels) + scrollState.animateScrollBy(0f) + } + true } + .focusRequester(focusRequester) + .focusable() + .fillMaxSize(), + state = scrollState + ){ + + item { + Row (verticalAlignment = Alignment.CenterVertically){ + Icon(painterResource(R.drawable.ic_icon), contentDescription = null) + Spacer(modifier = Modifier.width(16.dp)) + Text(text = stringResource(R.string.app_name), fontSize = 20.sp) } + } + item { Spacer(modifier = Modifier.size(8.dp)) } + item { + Chip(onClick = { navController.navigate(NavRoutes.ClientList.route) }, + label = { Text(stringResource(R.string.open_client_screen)) }, + icon = { Icon(painterResource(R.drawable.ic_clients), contentDescription = null) }, + colors = ChipDefaults.chipColors(backgroundColor = colorResource(R.color.background), iconColor = colorResource(R.color.primary))) } + item { + Chip(onClick = { launchAppOnPhone() }, + label = { Text(stringResource(R.string.launch_app_on_phone)) }, + icon = { Icon(painterResource(R.drawable.ic_open), contentDescription = null) }, + colors = ChipDefaults.chipColors(backgroundColor = colorResource(R.color.background), iconColor = colorResource(R.color.primary))) } + + item { Spacer(modifier = Modifier.size(8.dp)) } + item { Text(text = "Version: ${BuildConfig.VERSION_NAME}", textAlign = TextAlign.Center, modifier = Modifier.alpha(.7f)) } } -} \ No newline at end of file +} + +private fun launchAppOnPhone(){ + +} diff --git a/wear/src/main/java/com/blazecode/tsviewer/wear/theme/Type.kt b/wear/src/main/java/com/blazecode/tsviewer/wear/theme/Type.kt index 798068f..c76d3ed 100644 --- a/wear/src/main/java/com/blazecode/tsviewer/wear/theme/Type.kt +++ b/wear/src/main/java/com/blazecode/tsviewer/wear/theme/Type.kt @@ -1,3 +1,9 @@ +/* + * + * * Copyright (c) BlazeCode / Ralf Lehmann, 2022. + * + */ + package com.blazecode.tsviewer.wear.theme import androidx.compose.ui.text.TextStyle @@ -12,7 +18,13 @@ val Typography = Typography( fontFamily = FontFamily.Default, fontWeight = FontWeight.Normal, fontSize = 16.sp + ), + body2 = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Bold, + fontSize = 16.sp ) + /* Other default text styles to override button = TextStyle( fontFamily = FontFamily.Default, diff --git a/wear/src/main/res/drawable/ic_clients.xml b/wear/src/main/res/drawable/ic_clients.xml new file mode 100644 index 0000000..4ec0534 --- /dev/null +++ b/wear/src/main/res/drawable/ic_clients.xml @@ -0,0 +1,16 @@ + + + + + diff --git a/wear/src/main/res/drawable/ic_open.xml b/wear/src/main/res/drawable/ic_open.xml new file mode 100644 index 0000000..d4c3205 --- /dev/null +++ b/wear/src/main/res/drawable/ic_open.xml @@ -0,0 +1,16 @@ + + + + + diff --git a/wear/src/main/res/values/colors.xml b/wear/src/main/res/values/colors.xml new file mode 100644 index 0000000..2c43ced --- /dev/null +++ b/wear/src/main/res/values/colors.xml @@ -0,0 +1,22 @@ + + + + + + + #181A20 + #F2F4FF + #BFC6FF + #686FAA + #184378 + #ffffff + #6169AC + #4E569A + #184378 + #3F467E + + \ No newline at end of file diff --git a/wear/src/main/res/values/strings.xml b/wear/src/main/res/values/strings.xml index 3069c74..9f8bc16 100644 --- a/wear/src/main/res/values/strings.xml +++ b/wear/src/main/res/values/strings.xml @@ -10,8 +10,10 @@ This string is used for square devices and overridden by hello_world in values-round/strings.xml for round devices. --> - Client List %s Client connected %s Clients connected %s min ago + + Clients + Launch app \ No newline at end of file From 856a7b491e43892a7042697c69650cc75f955e8d Mon Sep 17 00:00:00 2001 From: BlazeCodeDev Date: Sun, 27 Nov 2022 14:01:18 +0100 Subject: [PATCH 18/25] Fix timestamp not being sent --- .../com/blazecode/tsviewer/util/wear/WearDataManager.kt | 2 ++ .../tsviewer/wear/communication/WearableListenerService.kt | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/blazecode/tsviewer/util/wear/WearDataManager.kt b/app/src/main/java/com/blazecode/tsviewer/util/wear/WearDataManager.kt index 018d25e..7d4cda9 100644 --- a/app/src/main/java/com/blazecode/tsviewer/util/wear/WearDataManager.kt +++ b/app/src/main/java/com/blazecode/tsviewer/util/wear/WearDataManager.kt @@ -17,6 +17,7 @@ class WearDataManager(val context: Context) { companion object { private const val CLIENTS_PATH = "/clients" private const val CLIENT_LIST_KEY = "clientlist" + private const val TIME_MILLIS = "timeMillis" } fun sendClientList(clientList: MutableList) { @@ -27,6 +28,7 @@ class WearDataManager(val context: Context) { val request = PutDataMapRequest.create(CLIENTS_PATH).apply { dataMap.putStringArray(CLIENT_LIST_KEY, clientArray) + dataMap.putLong(TIME_MILLIS, System.currentTimeMillis()) } .asPutDataRequest() .setUrgent() diff --git a/wear/src/main/java/com/blazecode/tsviewer/wear/communication/WearableListenerService.kt b/wear/src/main/java/com/blazecode/tsviewer/wear/communication/WearableListenerService.kt index 76d4c2e..a2c61e4 100644 --- a/wear/src/main/java/com/blazecode/tsviewer/wear/communication/WearableListenerService.kt +++ b/wear/src/main/java/com/blazecode/tsviewer/wear/communication/WearableListenerService.kt @@ -21,6 +21,7 @@ class WearableListenerService: WearableListenerService() { companion object { const val CLIENTS_PATH = "/clients" private const val CLIENT_LIST_KEY = "clientlist" + private const val TIME_MILLIS = "timeMillis" } private val scope = CoroutineScope(SupervisorJob() + Dispatchers.Main) @@ -32,8 +33,9 @@ class WearableListenerService: WearableListenerService() { event.dataItem.also { item -> if (item.uri.path!!.compareTo(CLIENTS_PATH) == 0) { DataMapItem.fromDataItem(item).dataMap.apply { + + // CLIENT LIST val clientList = getStringArray(CLIENT_LIST_KEY) - ComplicationDataHolder.time = System.currentTimeMillis() if(!clientList.isNullOrEmpty()){ ComplicationDataHolder.list = clientList.toMutableList() @@ -43,6 +45,9 @@ class WearableListenerService: WearableListenerService() { ComplicationProvider().update(this@WearableListenerService) } + // TIME STAMP + val timeMillis = getLong(TIME_MILLIS) + ComplicationDataHolder.time = timeMillis } } } From db8748f6952dc2ec977e3ec079debf7c2ff409df Mon Sep 17 00:00:00 2001 From: BlazeCodeDev Date: Sun, 27 Nov 2022 15:28:00 +0100 Subject: [PATCH 19/25] Implement working "Launch App" button --- app/src/main/AndroidManifest.xml | 13 +++++++ .../util/wear/WearableListenerService.kt | 39 +++++++++++++++++++ app/src/main/res/values/wear.xml | 11 ------ wear/src/main/AndroidManifest.xml | 6 +++ .../wear/communication/WearDataManager.kt | 31 +++++++++++++++ .../communication/WearableListenerService.kt | 11 ------ .../blazecode/tsviewer/wear/screens/Home.kt | 10 ++--- 7 files changed, 94 insertions(+), 27 deletions(-) create mode 100644 app/src/main/java/com/blazecode/tsviewer/util/wear/WearableListenerService.kt delete mode 100644 app/src/main/res/values/wear.xml create mode 100644 wear/src/main/java/com/blazecode/tsviewer/wear/communication/WearDataManager.kt diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 0d38e32..97073bb 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -24,6 +24,7 @@ @@ -33,6 +34,18 @@ + + + + + + + + + event.dataItem.also { item -> + if (item.uri.path!!.compareTo(LAUNCH_PATH) == 0) { + DataMapItem.fromDataItem(item).dataMap.apply { + + this@WearableListenerService.startActivity( + Intent(this@WearableListenerService, MainActivity::class.java) + .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + ) + } + } + } + } + } +} \ No newline at end of file diff --git a/app/src/main/res/values/wear.xml b/app/src/main/res/values/wear.xml deleted file mode 100644 index 950ea39..0000000 --- a/app/src/main/res/values/wear.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - client_sharing - - \ No newline at end of file diff --git a/wear/src/main/AndroidManifest.xml b/wear/src/main/AndroidManifest.xml index 6707e83..ba3525d 100644 --- a/wear/src/main/AndroidManifest.xml +++ b/wear/src/main/AndroidManifest.xml @@ -7,10 +7,13 @@ + + + + + @@ -54,6 +59,7 @@ + Date: Sun, 27 Nov 2022 15:33:40 +0100 Subject: [PATCH 20/25] Add icon --- .../res/drawable/ic_launcher_background.xml | 26 +++++++++++++++ .../res/drawable/ic_launcher_foreground.xml | 30 ++++++++++++++++++ .../src/main/res/mipmap-hdpi/ic_launcher.webp | Bin 1404 -> 0 bytes .../src/main/res/mipmap-mdpi/ic_launcher.webp | Bin 982 -> 0 bytes .../main/res/mipmap-xhdpi/ic_launcher.webp | Bin 1900 -> 0 bytes .../main/res/mipmap-xxhdpi/ic_launcher.webp | Bin 2884 -> 0 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.webp | Bin 3844 -> 0 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.xml | 11 +++++++ 8 files changed, 67 insertions(+) create mode 100644 wear/src/main/res/drawable/ic_launcher_background.xml create mode 100644 wear/src/main/res/drawable/ic_launcher_foreground.xml delete mode 100644 wear/src/main/res/mipmap-hdpi/ic_launcher.webp delete mode 100644 wear/src/main/res/mipmap-mdpi/ic_launcher.webp delete mode 100644 wear/src/main/res/mipmap-xhdpi/ic_launcher.webp delete mode 100644 wear/src/main/res/mipmap-xxhdpi/ic_launcher.webp delete mode 100644 wear/src/main/res/mipmap-xxxhdpi/ic_launcher.webp create mode 100644 wear/src/main/res/mipmap-xxxhdpi/ic_launcher.xml diff --git a/wear/src/main/res/drawable/ic_launcher_background.xml b/wear/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..e90cfa3 --- /dev/null +++ b/wear/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + diff --git a/wear/src/main/res/drawable/ic_launcher_foreground.xml b/wear/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 0000000..32d7ab7 --- /dev/null +++ b/wear/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + diff --git a/wear/src/main/res/mipmap-hdpi/ic_launcher.webp b/wear/src/main/res/mipmap-hdpi/ic_launcher.webp deleted file mode 100644 index c209e78ecd372343283f4157dcfd918ec5165bb3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1404 zcmV-?1%vuhNk&F=1pok7MM6+kP&il$0000G0000-002h-06|PpNX!5L00Dqw+t%{r zzW2vH!KF=w&cMnnN@{whkTw+#mAh0SV?YL=)3MimFYCWp#fpdtz~8$hD5VPuQgtcN zXl<@<#Cme5f5yr2h%@8TWh?)bSK`O z^Z@d={gn7J{iyxL_y_%J|L>ep{dUxUP8a{byupH&!UNR*OutO~0{*T4q5R6@ApLF! z5{w?Z150gC7#>(VHFJZ-^6O@PYp{t!jH(_Z*nzTK4 zkc{fLE4Q3|mA2`CWQ3{8;gxGizgM!zccbdQoOLZc8hThi-IhN90RFT|zlxh3Ty&VG z?Fe{#9RrRnxzsu|Lg2ddugg7k%>0JeD+{XZ7>Z~{=|M+sh1MF7~ zz>To~`~LVQe1nNoR-gEzkpe{Ak^7{{ZBk2i_<+`Bq<^GB!RYG+z)h;Y3+<{zlMUYd zrd*W4w&jZ0%kBuDZ1EW&KLpyR7r2=}fF2%0VwHM4pUs}ZI2egi#DRMYZPek*^H9YK zay4Iy3WXFG(F14xYsoDA|KXgGc5%2DhmQ1gFCkrgHBm!lXG8I5h*uf{rn48Z!_@ z4Bk6TJAB2CKYqPjiX&mWoW>OPFGd$wqroa($ne7EUK;#3VYkXaew%Kh^3OrMhtjYN?XEoY`tRPQsAkH-DSL^QqyN0>^ zmC>{#F14jz4GeW{pJoRpLFa_*GI{?T93^rX7SPQgT@LbLqpNA}<@2wH;q493)G=1Y z#-sCiRNX~qf3KgiFzB3I>4Z%AfS(3$`-aMIBU+6?gbgDb!)L~A)je+;fR0jWLL-Fu z4)P{c7{B4Hp91&%??2$v9iRSFnuckHUm}or9seH6 z>%NbT+5*@L5(I9j@06@(!{ZI?U0=pKn8uwIg&L{JV14+8s2hnvbRrU|hZCd}IJu7*;;ECgO%8_*W Kmw_-CKmY()leWbG diff --git a/wear/src/main/res/mipmap-mdpi/ic_launcher.webp b/wear/src/main/res/mipmap-mdpi/ic_launcher.webp deleted file mode 100644 index 4f0f1d64e58ba64d180ce43ee13bf9a17835fbca..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 982 zcmV;{11bDcNk&G_0{{S5MM6+kP&il$0000G0000l001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}dP3$&sfFTIR_jC=2pHh9kpI@2(6V*GQo7Ws)`j)hd+tr@P~gR*2gO@+1? zG<`_tB+LJuF|SZ9tIec;h%}}6WClT`L>HSW?E{Hp1h^+mlbf_$9zA>!ug>NALJsO{ mU%z=YwVD?}XMya)Bp;vlyE5&E_6!fzx9pwrdz474!~g(M6R?N? diff --git a/wear/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/wear/src/main/res/mipmap-xxhdpi/ic_launcher.webp deleted file mode 100644 index 28d4b77f9f036a47549d47db79c16788749dca10..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2884 zcmV-K3%m4ENk&FI3jhFDMM6+kP&il$0000G0001w0055w06|PpNY()W00EFA*|uso z=UmW3;Ri7@GcyiBW{ey$jes55b5S`|ZVZ{(x$xch{z?D+^{yErVgleVwa9qvGt40r z42;MG=7<0QySlzE=Ig6%01!FBK^$Fsxe@Hfe6aCy?Wh2r0~}@_lQAF90oTUi0FhEr z#(*;kTC(r!tQk6;gxj4h%FdHAt(^M3YvYj(!tOeN)+Hvj6+< zzyJRG?^lZfWuR#t!tUKP&(?%3v&Zd$R2YN>lB(Lq`OInY48%4%yTv2 zYe1{G`3)(PDEio5Y@-I5tUf`c%%OCJMtSW56g3iEg%3`$7XSJJHyA z<|7&N)5Xrlgv~%BO24eFd;Hd;uiK%D`EdK|quUeRZDqbh9l)%j%J#0lfrZumvA<_w zu&=AVvdChf6}eqh(bUz`(`Ue*p01{fBAcTgKyDYLs_I+YyJEk+rM@avU~>fB$n)HS zM7pfJydu`i%gfS<{PF94kZDv$t>06sAkheDzu40NJ$5CMW%n^Lls?8^p^QGWURbKu3ZduZQZ((s2? zzE`}<{;Zt7<$C|9R8A~DJ~@%x>TfP zF>TX8)@v|t)q4GjRt<}5s6hLHwRel7>V@&r-O|Av(yh;Q1A{E>Ir>p+%dHD|=l+lT zpr(Dg&>#Nu=!)6bCLr-ZS%|;h)Ij$+e@r8_{qO19QvDe=&1tmpY*0lcA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 No newline at end of file From dfa19b34c3c175dcdb4ae347c04af838c7852709 Mon Sep 17 00:00:00 2001 From: BlazeCodeDev Date: Sun, 27 Nov 2022 15:39:20 +0100 Subject: [PATCH 21/25] Fix numbers bug --- .../main/java/com/blazecode/tsviewer/wear/screens/ClientList.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wear/src/main/java/com/blazecode/tsviewer/wear/screens/ClientList.kt b/wear/src/main/java/com/blazecode/tsviewer/wear/screens/ClientList.kt index 3d363c6..e348caa 100644 --- a/wear/src/main/java/com/blazecode/tsviewer/wear/screens/ClientList.kt +++ b/wear/src/main/java/com/blazecode/tsviewer/wear/screens/ClientList.kt @@ -42,7 +42,7 @@ fun ClientList(){ else stringResource(R.string.clients_connected, ComplicationDataHolder.list.size) var timeAgo: String = ((System.currentTimeMillis() - ComplicationDataHolder.time) / 1000 / 60).toString() - if(ComplicationDataHolder.time.equals(0)) timeAgo = "N/A" + if(ComplicationDataHolder.time == 0L) timeAgo = "N/A" val scrollState = rememberScalingLazyListState() val scope = rememberCoroutineScope() From 119cfb9cc30f88eb70b2becfe29734395d764432 Mon Sep 17 00:00:00 2001 From: BlazeCodeDev Date: Sun, 27 Nov 2022 15:41:56 +0100 Subject: [PATCH 22/25] Change no value indicator --- .../main/java/com/blazecode/tsviewer/wear/screens/ClientList.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wear/src/main/java/com/blazecode/tsviewer/wear/screens/ClientList.kt b/wear/src/main/java/com/blazecode/tsviewer/wear/screens/ClientList.kt index e348caa..81cc153 100644 --- a/wear/src/main/java/com/blazecode/tsviewer/wear/screens/ClientList.kt +++ b/wear/src/main/java/com/blazecode/tsviewer/wear/screens/ClientList.kt @@ -42,7 +42,7 @@ fun ClientList(){ else stringResource(R.string.clients_connected, ComplicationDataHolder.list.size) var timeAgo: String = ((System.currentTimeMillis() - ComplicationDataHolder.time) / 1000 / 60).toString() - if(ComplicationDataHolder.time == 0L) timeAgo = "N/A" + if(ComplicationDataHolder.time == 0L) timeAgo = "-" val scrollState = rememberScalingLazyListState() val scope = rememberCoroutineScope() From acf474fcb4e66cdb42240deecf657919b4848355 Mon Sep 17 00:00:00 2001 From: BlazeCodeDev Date: Sun, 27 Nov 2022 16:04:17 +0100 Subject: [PATCH 23/25] Release V1.0 --- wear/build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/wear/build.gradle b/wear/build.gradle index eb8b0fe..123f9e6 100644 --- a/wear/build.gradle +++ b/wear/build.gradle @@ -17,7 +17,6 @@ android { vectorDrawables { useSupportLibrary true } - } buildTypes { From 13e2a9cd9ad23920bc9fc7a06b6d69e81b8474ea Mon Sep 17 00:00:00 2001 From: BlazeCodeDev Date: Sun, 27 Nov 2022 16:04:34 +0100 Subject: [PATCH 24/25] Add switch for sync wearable --- .../java/com/blazecode/tsviewer/MainActivity.kt | 16 ++++++++++++++++ .../com/blazecode/tsviewer/util/ClientsWorker.kt | 4 +++- app/src/main/res/menu/menu_main.xml | 5 +++++ app/src/main/res/values/strings.xml | 1 + 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/blazecode/tsviewer/MainActivity.kt b/app/src/main/java/com/blazecode/tsviewer/MainActivity.kt index bd31afa..4c32261 100644 --- a/app/src/main/java/com/blazecode/tsviewer/MainActivity.kt +++ b/app/src/main/java/com/blazecode/tsviewer/MainActivity.kt @@ -80,6 +80,10 @@ class MainActivity : AppCompatActivity() { val autoUpdateMenuItem = binding.toolbar.menu.findItem(R.id.action_update_check) autoUpdateMenuItem.isChecked = preferences.getBoolean("autoUpdateCheck", true) + // SYNC WITH WEARABLE + val syncWearableMenuItem = binding.toolbar.menu.findItem(R.id.action_sync_wearable) + syncWearableMenuItem.isChecked = preferences.getBoolean("syncWearable", false) + // DEBUG AUTO UPDATE CHECK val debugAutoUpdateMenuItem = binding.toolbar.menu.findItem(R.id.action_update_check_debug) debugAutoUpdateMenuItem.isChecked = preferences.getBoolean("debugUpdateCheck", false) @@ -126,6 +130,12 @@ class MainActivity : AppCompatActivity() { return@setOnMenuItemClickListener true } + R.id.action_sync_wearable -> { + syncWearableMenuItem.isChecked = !syncWearableMenuItem.isChecked + setSyncWearable(syncWearableMenuItem.isChecked) + return@setOnMenuItemClickListener true + } + R.id.action_update_check_debug -> { debugAutoUpdateMenuItem.isChecked = !debugAutoUpdateMenuItem.isChecked setDebugUpdateCheck(debugAutoUpdateMenuItem.isChecked) @@ -277,6 +287,12 @@ class MainActivity : AppCompatActivity() { editor.commit() } + private fun setSyncWearable(isEnabled: Boolean){ + val editor : SharedPreferences.Editor = preferences.edit() + editor.putBoolean("syncWearable", isEnabled) + editor.commit() + } + private fun setDebugUpdateCheck(isEnabled: Boolean) { val editor : SharedPreferences.Editor = preferences.edit() editor.putBoolean("debugUpdateCheck", isEnabled) diff --git a/app/src/main/java/com/blazecode/tsviewer/util/ClientsWorker.kt b/app/src/main/java/com/blazecode/tsviewer/util/ClientsWorker.kt index 812a433..ccde246 100644 --- a/app/src/main/java/com/blazecode/tsviewer/util/ClientsWorker.kt +++ b/app/src/main/java/com/blazecode/tsviewer/util/ClientsWorker.kt @@ -50,6 +50,7 @@ class ClientsWorker(private val context: Context, workerParameters: WorkerParame private var PORT : Int = 0 private var RUN_ONLY_WIFI : Boolean = true private var DEMO_MODE : Boolean = false + private var SYNC_WEARABLE : Boolean = false private var clientList = mutableListOf() private var clientListNames = mutableListOf() @@ -78,8 +79,8 @@ class ClientsWorker(private val context: Context, workerParameters: WorkerParame else extractNames() + if(SYNC_WEARABLE) wearDataManager.sendClientList(clientListNames) clientNotificationManager.post(clientListNames) - wearDataManager.sendClientList(clientListNames) writeClients(clientListNames) } @@ -157,6 +158,7 @@ class ClientsWorker(private val context: Context, workerParameters: WorkerParame INCLUDE_QUERY_CLIENTS = preferences.getBoolean("includeQuery", false) RUN_ONLY_WIFI = preferences.getBoolean("run_only_wifi", true) DEMO_MODE = preferences.getBoolean("demoMode", false) + SYNC_WEARABLE = preferences.getBoolean("syncWearable", false) loadEncryptedPreferences() } diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml index eba1608..8e8cc1a 100644 --- a/app/src/main/res/menu/menu_main.xml +++ b/app/src/main/res/menu/menu_main.xml @@ -25,6 +25,11 @@ android:title="@string/check_updates" android:checkable="true"/> + + Open Source Licenses Send E-Mail Auto check for updates + Sync with Wearable Not enough data collected From a107ba89737c02568127df5277fd682b35a61a3d Mon Sep 17 00:00:00 2001 From: BlazeCodeDev Date: Sun, 27 Nov 2022 16:09:02 +0100 Subject: [PATCH 25/25] Release V1.4 --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index b21e27f..4431ad0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -19,8 +19,8 @@ android { applicationId "com.blazecode.tsviewer" minSdk 26 targetSdk 33 - versionCode 6 - versionName "1.3" + versionCode 7 + versionName "1.4" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" }