diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml deleted file mode 100644 index c2eccbf..0000000 --- a/.github/workflows/linter.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Lint check - -on: - pull_request: - branches: [main, development] - -jobs: - build: - name: Run ktlint - runs-on: ubuntu-latest - - steps: - - name: Checkout Code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: ktlint - uses: github/super-linter/slim@v5 - env: - VALIDATE_ALL_CODEBASE: false - VALIDATE_KOTLIN: true - DEFAULT_BRANCH: main - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 6bcf000..40ae7d9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,10 +1,7 @@ -buildscript { - val compose_version by extra("1.6.4") - val wear_compose_version by extra("1.3.0") -} // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { - id("com.android.application") version "8.3.1" apply false - id("com.android.library") version "8.3.1" apply false - id("org.jetbrains.kotlin.android") version "1.9.23" apply false + alias(libs.plugins.androidApplication) apply false + alias(libs.plugins.androidLibrary) apply false + alias(libs.plugins.composePlugin) apply false + alias(libs.plugins.kotlinAndroid) apply false } diff --git a/composesensors/build.gradle.kts b/composesensors/build.gradle.kts index 80b5ea8..c858c9c 100644 --- a/composesensors/build.gradle.kts +++ b/composesensors/build.gradle.kts @@ -1,20 +1,18 @@ plugins { - id("com.android.library") - id("org.jetbrains.kotlin.android") - id("com.vanniktech.maven.publish") version "0.28.0" + alias(libs.plugins.androidLibrary) + alias(libs.plugins.composePlugin) + alias(libs.plugins.kotlinAndroid) + alias(libs.plugins.mavenPublish) } android { namespace = "com.mutualmobile.composesensors" - compileSdk = 34 - + compileSdk = libs.versions.targetSdk.get().toInt() defaultConfig { - minSdk = 21 - + minSdk = libs.versions.minSdk.get().toInt() testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles("consumer-rules.pro") } - buildTypes { release { isMinifyEnabled = false @@ -25,35 +23,27 @@ android { } } compileOptions { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = "11" + jvmTarget = libs.versions.jvmTarget.get() } buildFeatures { compose = true } - composeOptions { - kotlinCompilerExtensionVersion = "1.5.11" - } } dependencies { - val coreKtxVersion = "1.12.0" - val appCompatVersion = "1.6.1" - val materialVersion = "1.11.0" - val jUnitVersion = "4.13.2" - val androidJUnitVersion = "1.1.5" - val espressoVersion = "3.5.1" - val composeVersion = "1.6.4" - - implementation("androidx.compose.runtime:runtime:$composeVersion") - implementation("androidx.compose.ui:ui:$composeVersion") - implementation("androidx.core:core-ktx:$coreKtxVersion") - implementation("androidx.appcompat:appcompat:$appCompatVersion") - implementation("com.google.android.material:material:$materialVersion") - testImplementation("junit:junit:$jUnitVersion") - androidTestImplementation("androidx.test.ext:junit:$androidJUnitVersion") - androidTestImplementation("androidx.test.espresso:espresso-core:$espressoVersion") + androidTestImplementation(libs.espresso) + androidTestImplementation(libs.junit.android) + androidTestImplementation(platform(libs.compose.bom)) + implementation(libs.androidCore) + implementation(libs.appCompat) + implementation(libs.compose.runtime) + implementation(libs.compose.ui) + implementation(libs.material) + implementation(platform(libs.compose.bom)) + testImplementation(libs.junit) + testImplementation(platform(libs.compose.bom)) } diff --git a/composesensors/src/androidTest/java/com/mutualmobile/composesensors/ExampleInstrumentedTest.kt b/composesensors/src/androidTest/java/com/mutualmobile/composesensors/ExampleInstrumentedTest.kt deleted file mode 100644 index f444ba8..0000000 --- a/composesensors/src/androidTest/java/com/mutualmobile/composesensors/ExampleInstrumentedTest.kt +++ /dev/null @@ -1,24 +0,0 @@ -package com.mutualmobile.composesensors - -import androidx.test.platform.app.InstrumentationRegistry -import androidx.test.ext.junit.runners.AndroidJUnit4 - -import org.junit.Test -import org.junit.runner.RunWith - -import org.junit.Assert.* - -/** - * Instrumented test, which will execute on an Android device. - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -@RunWith(AndroidJUnit4::class) -class ExampleInstrumentedTest { - @Test - fun useAppContext() { - // Context of the app under test. - val appContext = InstrumentationRegistry.getInstrumentation().targetContext - assertEquals("com.mutualmobile.composesensors.test", appContext.packageName) - } -} \ No newline at end of file diff --git a/composesensors/src/test/java/com/mutualmobile/composesensors/ExampleUnitTest.kt b/composesensors/src/test/java/com/mutualmobile/composesensors/ExampleUnitTest.kt deleted file mode 100644 index 4cdf5d2..0000000 --- a/composesensors/src/test/java/com/mutualmobile/composesensors/ExampleUnitTest.kt +++ /dev/null @@ -1,17 +0,0 @@ -package com.mutualmobile.composesensors - -import org.junit.Test - -import org.junit.Assert.* - -/** - * Example local unit test, which will execute on the development machine (host). - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -class ExampleUnitTest { - @Test - fun addition_isCorrect() { - assertEquals(4, 2 + 2) - } -} \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..ff92fce --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,55 @@ +[versions] +agp = "8.7.1" +android-lifecycle-runtime = "2.8.6" +androidCore = "1.13.1" +appCompat = "1.7.0" +compose-wear = "1.4.0" +composeActivity = "1.9.3" +composeBom = "2024.10.00" +espresso = "3.6.1" +junit = "4.13.2" +junit-android = "1.2.1" +jvmTarget = "17" +kotlin = "2.0.21" +legacySupport = "1.0.0" +material = "1.12.0" +mavenPublish = "0.30.0" +minSdk = "21" +minSdkWear = "26" +percentLayout = "1.0.0" +playServicesWearable = "18.2.0" +splashScreen = "1.0.1" +targetSdk = "35" + +[libraries] +android-lifecycle-runtime = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "android-lifecycle-runtime" } +android-lifecycle-runtime-compose = { module = "androidx.lifecycle:lifecycle-runtime-compose", version.ref = "android-lifecycle-runtime" } +androidCore = { module = "androidx.core:core-ktx", version.ref = "androidCore" } +appCompat = { module = "androidx.appcompat:appcompat", version.ref = "appCompat" } +compose-activity = { module = "androidx.activity:activity-compose", version.ref = "composeActivity" } +compose-bom = { module = "androidx.compose:compose-bom", version.ref = "composeBom" } +compose-material3 = { module = "androidx.compose.material3:material3" } +compose-runtime = { module = "androidx.compose.runtime:runtime" } +compose-ui = { module = "androidx.compose.ui:ui" } +compose-ui-graphics = { module = "androidx.compose.ui:ui-graphics" } +compose-ui-testManifest = { module = "androidx.compose.ui:ui-test-manifest" } +compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" } +compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" } +compose-wear-foundation = { module = "androidx.wear.compose:compose-foundation", version.ref = "compose-wear" } +compose-wear-material = { module = "androidx.wear.compose:compose-material", version.ref = "compose-wear" } +espresso = { module = "androidx.test.espresso:espresso-core", version.ref = "espresso" } +junit = { module = "junit:junit", version.ref = "junit" } +junit-android = { module = "androidx.test.ext:junit", version.ref = "junit-android" } +junit-compose = { module = "androidx.compose.ui:ui-test-junit4" } +legacySupport = { module = "androidx.legacy:legacy-support-v4", version.ref = "legacySupport" } +material = { module = "com.google.android.material:material", version.ref = "material" } +percentLayout = { module = "androidx.percentlayout:percentlayout", version.ref = "percentLayout" } +playServicesWearable = { module = "com.google.android.gms:play-services-wearable", version.ref = "playServicesWearable" } +splashScreen = { module = "androidx.core:core-splashscreen", version.ref = "splashScreen" } + +[plugins] +androidApplication = { id = "com.android.application", version.ref = "agp" } +androidLibrary = { id = "com.android.library", version.ref = "agp" } +composePlugin = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } +kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } +mavenPublish = { id = "com.vanniktech.maven.publish", version.ref = "mavenPublish" } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e644113..a4b76b9 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b82aa23..df97d72 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 1aa94a4..f5feea6 100755 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,8 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum diff --git a/gradlew.bat b/gradlew.bat index 7101f8e..9b42019 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## diff --git a/sample/build.gradle.kts b/sample/build.gradle.kts index 1d471d4..63701ce 100644 --- a/sample/build.gradle.kts +++ b/sample/build.gradle.kts @@ -1,27 +1,25 @@ import java.util.Properties plugins { - id("com.android.application") - id("org.jetbrains.kotlin.android") + alias(libs.plugins.androidApplication) + alias(libs.plugins.composePlugin) + alias(libs.plugins.kotlinAndroid) } android { namespace = "com.mutualmobile.sample" - compileSdk = 34 - + compileSdk = libs.versions.targetSdk.get().toInt() defaultConfig { applicationId = "com.mutualmobile.sample" - minSdk = 21 - targetSdk = 34 + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() versionCode = 1 versionName = "1.0" - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" vectorDrawables { useSupportLibrary = true } } - signingConfigs { val propertiesFile = File("keystore.properties") if (propertiesFile.exists()) { @@ -37,7 +35,6 @@ android { } } } - buildTypes { release { isMinifyEnabled = false @@ -45,23 +42,23 @@ android { getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" ) - runCatching { signingConfigs.getByName("release") } - .onSuccess { safeConfig -> signingConfig = safeConfig } + runCatching { + signingConfigs.getByName("release") + }.onSuccess { config -> + signingConfig = config + } } } compileOptions { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = "11" + jvmTarget = libs.versions.jvmTarget.get() } buildFeatures { compose = true } - composeOptions { - kotlinCompilerExtensionVersion = "1.5.11" - } packaging { resources { excludes += "/META-INF/{AL2.0,LGPL2.1}" @@ -70,29 +67,22 @@ android { } dependencies { - val composeVersion = "1.6.4" - val material3Version = "1.2.1" - val lifecycleRuntimeKtxVersion = "2.7.0" - val coreKtxVersion = "1.12.0" - val activityComposeVersion = "1.8.2" - val jUnitVersion = "4.13.2" - val androidJUnitVersion = "1.1.5" - val espressoVersion = "3.5.1" - val splashScreenVersion = "1.0.1" - - implementation(project(mapOf("path" to ":composesensors"))) - implementation("androidx.core:core-ktx:$coreKtxVersion") - implementation("androidx.lifecycle:lifecycle-runtime-ktx:$lifecycleRuntimeKtxVersion") - implementation("androidx.activity:activity-compose:$activityComposeVersion") - implementation("androidx.compose.ui:ui:$composeVersion") - implementation("androidx.compose.ui:ui-graphics:$composeVersion") - implementation("androidx.compose.ui:ui-tooling-preview:$composeVersion") - implementation("androidx.compose.material3:material3:$material3Version") - testImplementation("junit:junit:$jUnitVersion") - androidTestImplementation("androidx.test.ext:junit:$androidJUnitVersion") - androidTestImplementation("androidx.test.espresso:espresso-core:$espressoVersion") - androidTestImplementation("androidx.compose.ui:ui-test-junit4:$composeVersion") - debugImplementation("androidx.compose.ui:ui-tooling:$composeVersion") - debugImplementation("androidx.compose.ui:ui-test-manifest:$composeVersion") - implementation("androidx.core:core-splashscreen:$splashScreenVersion") + androidTestImplementation(libs.espresso) + androidTestImplementation(libs.junit.android) + androidTestImplementation(libs.junit.compose) + androidTestImplementation(platform(libs.compose.bom)) + debugImplementation(libs.compose.ui.testManifest) + debugImplementation(libs.compose.ui.tooling) + implementation(libs.android.lifecycle.runtime) + implementation(libs.androidCore) + implementation(libs.compose.activity) + implementation(libs.compose.material3) + implementation(libs.compose.ui) + implementation(libs.compose.ui.graphics) + implementation(libs.compose.ui.tooling.preview) + implementation(libs.splashScreen) + implementation(platform(libs.compose.bom)) + implementation(project(":composesensors")) + testImplementation(libs.junit) + testImplementation(platform(libs.compose.bom)) } diff --git a/sample/src/androidTest/java/com/mutualmobile/composesensors/ExampleInstrumentedTest.kt b/sample/src/androidTest/java/com/mutualmobile/composesensors/ExampleInstrumentedTest.kt deleted file mode 100644 index 07f87b0..0000000 --- a/sample/src/androidTest/java/com/mutualmobile/composesensors/ExampleInstrumentedTest.kt +++ /dev/null @@ -1,24 +0,0 @@ -package com.mutualmobile.composesensors - -import androidx.test.platform.app.InstrumentationRegistry -import androidx.test.ext.junit.runners.AndroidJUnit4 - -import org.junit.Test -import org.junit.runner.RunWith - -import org.junit.Assert.* - -/** - * Instrumented test, which will execute on an Android device. - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -@RunWith(AndroidJUnit4::class) -class ExampleInstrumentedTest { - @Test - fun useAppContext() { - // Context of the app under test. - val appContext = InstrumentationRegistry.getInstrumentation().targetContext - assertEquals("com.mutualmobile.composesensors", appContext.packageName) - } -} \ No newline at end of file diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml index d6ab55b..7f87579 100644 --- a/sample/src/main/AndroidManifest.xml +++ b/sample/src/main/AndroidManifest.xml @@ -13,11 +13,11 @@ android:theme="@style/Theme.App.Starting" tools:targetApi="31"> + tools:ignore="DiscouragedApi,LockedOrientationActivity"> @@ -25,5 +25,4 @@ - - \ No newline at end of file + diff --git a/sample/src/main/ic_launcher-playstore.png b/sample/src/main/ic_launcher-playstore.png index 1c1d8dc..7e24010 100644 Binary files a/sample/src/main/ic_launcher-playstore.png and b/sample/src/main/ic_launcher-playstore.png differ diff --git a/sample/src/main/java/com/mutualmobile/sample/MainActivity.kt b/sample/src/main/java/com/mutualmobile/sample/MainActivity.kt index 67a6e0a..597c72d 100644 --- a/sample/src/main/java/com/mutualmobile/sample/MainActivity.kt +++ b/sample/src/main/java/com/mutualmobile/sample/MainActivity.kt @@ -9,8 +9,8 @@ import androidx.compose.material3.Surface import androidx.compose.ui.Modifier import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen import androidx.core.view.WindowCompat +import com.mutualmobile.sample.ui.ComposeSensorsTheme import com.mutualmobile.sample.ui.screens.sensorlist.SensorsListScreen -import com.mutualmobile.sample.ui.theme.ComposeSensorsTheme class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { diff --git a/sample/src/main/java/com/mutualmobile/sample/ui/theme/Theme.kt b/sample/src/main/java/com/mutualmobile/sample/ui/Theme.kt similarity index 63% rename from sample/src/main/java/com/mutualmobile/sample/ui/theme/Theme.kt rename to sample/src/main/java/com/mutualmobile/sample/ui/Theme.kt index 306c2fe..c993067 100644 --- a/sample/src/main/java/com/mutualmobile/sample/ui/theme/Theme.kt +++ b/sample/src/main/java/com/mutualmobile/sample/ui/Theme.kt @@ -1,10 +1,11 @@ -package com.mutualmobile.sample.ui.theme +package com.mutualmobile.sample.ui import android.app.Activity import android.graphics.Color import android.os.Build import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Typography import androidx.compose.material3.darkColorScheme import androidx.compose.material3.dynamicDarkColorScheme import androidx.compose.material3.dynamicLightColorScheme @@ -15,28 +16,6 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalView import androidx.core.view.WindowCompat -private val DarkColorScheme = darkColorScheme( - primary = Purple80, - secondary = PurpleGrey80, - tertiary = Pink80 -) - -private val LightColorScheme = lightColorScheme( - primary = Purple40, - secondary = PurpleGrey40, - tertiary = Pink40 - - /* Other default colors to override - background = Color(0xFFFFFBFE), - surface = Color(0xFFFFFBFE), - onPrimary = Color.White, - onSecondary = Color.White, - onTertiary = Color.White, - onBackground = Color(0xFF1C1B1F), - onSurface = Color(0xFF1C1B1F), - */ -) - @Composable fun ComposeSensorsTheme( darkTheme: Boolean = isSystemInDarkTheme(), @@ -50,16 +29,24 @@ fun ComposeSensorsTheme( if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) } - darkTheme -> DarkColorScheme - else -> LightColorScheme + darkTheme -> darkColorScheme() + else -> lightColorScheme() } val view = LocalView.current if (!view.isInEditMode) { SideEffect { val window = (view.context as Activity).window - window.statusBarColor = Color.TRANSPARENT - window.navigationBarColor = Color.TRANSPARENT - with(WindowCompat.getInsetsController(window, view)) { + + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.VANILLA_ICE_CREAM) { + @Suppress("DEPRECATION") + with(window) { + statusBarColor = Color.TRANSPARENT + navigationBarColor = Color.TRANSPARENT + } + } + + val insetsController = WindowCompat.getInsetsController(window, view) + with(insetsController) { isAppearanceLightStatusBars = !darkTheme isAppearanceLightNavigationBars = !darkTheme } @@ -68,7 +55,7 @@ fun ComposeSensorsTheme( MaterialTheme( colorScheme = colorScheme, - typography = Typography, + typography = Typography(), content = content ) } diff --git a/sample/src/main/java/com/mutualmobile/sample/ui/screens/sensorlist/SensorsListScreen.kt b/sample/src/main/java/com/mutualmobile/sample/ui/screens/sensorlist/SensorsListScreen.kt index a78e6b7..d6c0cb6 100644 --- a/sample/src/main/java/com/mutualmobile/sample/ui/screens/sensorlist/SensorsListScreen.kt +++ b/sample/src/main/java/com/mutualmobile/sample/ui/screens/sensorlist/SensorsListScreen.kt @@ -16,8 +16,8 @@ import androidx.compose.foundation.pager.HorizontalPager import androidx.compose.foundation.pager.PagerState import androidx.compose.foundation.pager.rememberPagerState import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.KeyboardArrowLeft -import androidx.compose.material.icons.filled.KeyboardArrowRight +import androidx.compose.material.icons.automirrored.filled.KeyboardArrowLeft +import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight import androidx.compose.material3.CenterAlignedTopAppBar import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.IconButton @@ -203,7 +203,7 @@ fun SensorsListScreen() { ) { CSButton( text = "Previous", - icon = Icons.Default.KeyboardArrowLeft, + icon = Icons.AutoMirrored.Default.KeyboardArrowLeft, onClick = { coroutineScope.launch { pagerState.animateScrollToPage( @@ -222,7 +222,7 @@ fun SensorsListScreen() { ) CSButton( text = "Next", - icon = Icons.Default.KeyboardArrowRight, + icon = Icons.AutoMirrored.Default.KeyboardArrowRight, onClick = { coroutineScope.launch { pagerState.animateScrollToPage( @@ -245,7 +245,7 @@ fun SensorsListScreen() { HorizontalPager( state = pagerState, contentPadding = PaddingValues(32.dp), - beyondBoundsPageCount = 1, + beyondViewportPageCount = 1, userScrollEnabled = false ) { index -> val scrollProgress = remember { diff --git a/sample/src/main/java/com/mutualmobile/sample/ui/screens/sensorlist/components/CSButton.kt b/sample/src/main/java/com/mutualmobile/sample/ui/screens/sensorlist/components/CSButton.kt index da97289..bbbdaf4 100644 --- a/sample/src/main/java/com/mutualmobile/sample/ui/screens/sensorlist/components/CSButton.kt +++ b/sample/src/main/java/com/mutualmobile/sample/ui/screens/sensorlist/components/CSButton.kt @@ -10,12 +10,12 @@ import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.defaultMinSize import androidx.compose.foundation.layout.padding -import androidx.compose.material.ripple.rememberRipple import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.material3.Text +import androidx.compose.material3.ripple import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Alignment @@ -53,7 +53,7 @@ fun CSButton( .combinedClickable( interactionSource = remember { MutableInteractionSource() }, indication = if (enabled) { - rememberRipple(color = MaterialTheme.colorScheme.onPrimary) + ripple(color = MaterialTheme.colorScheme.onPrimary) } else { null }, @@ -61,7 +61,8 @@ fun CSButton( onLongClick = { if (enabled) onLongClick() } ), color = animateColorAsState( - targetValue = MaterialTheme.colorScheme.primary.copy(alpha = if (enabled) 1f else 0.5f) + targetValue = MaterialTheme.colorScheme.primary.copy(alpha = if (enabled) 1f else 0.5f), + label = "Animated Color" ).value, contentColor = MaterialTheme.colorScheme.surface ) { diff --git a/sample/src/main/java/com/mutualmobile/sample/ui/screens/sensorlist/components/SensorValue.kt b/sample/src/main/java/com/mutualmobile/sample/ui/screens/sensorlist/components/SensorValue.kt index c28c2ae..14bcab6 100644 --- a/sample/src/main/java/com/mutualmobile/sample/ui/screens/sensorlist/components/SensorValue.kt +++ b/sample/src/main/java/com/mutualmobile/sample/ui/screens/sensorlist/components/SensorValue.kt @@ -5,7 +5,7 @@ import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.KeyboardArrowRight +import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text @@ -37,7 +37,7 @@ fun SensorValue( Spacer(modifier = Modifier.weight(scrollProgress.value.coerceAtLeast(0.01f))) repeat(3) { Icon( - imageVector = Icons.Default.KeyboardArrowRight, + imageVector = Icons.AutoMirrored.Default.KeyboardArrowRight, contentDescription = null, tint = dashedLineColor ) diff --git a/sample/src/main/java/com/mutualmobile/sample/ui/theme/Color.kt b/sample/src/main/java/com/mutualmobile/sample/ui/theme/Color.kt deleted file mode 100644 index 3ceb0d8..0000000 --- a/sample/src/main/java/com/mutualmobile/sample/ui/theme/Color.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.mutualmobile.sample.ui.theme - -import androidx.compose.ui.graphics.Color - -val Purple80 = Color(0xFFD0BCFF) -val PurpleGrey80 = Color(0xFFCCC2DC) -val Pink80 = Color(0xFFEFB8C8) - -val Purple40 = Color(0xFF6650a4) -val PurpleGrey40 = Color(0xFF625b71) -val Pink40 = Color(0xFF7D5260) \ No newline at end of file diff --git a/sample/src/main/java/com/mutualmobile/sample/ui/theme/Type.kt b/sample/src/main/java/com/mutualmobile/sample/ui/theme/Type.kt deleted file mode 100644 index 3ea34a1..0000000 --- a/sample/src/main/java/com/mutualmobile/sample/ui/theme/Type.kt +++ /dev/null @@ -1,34 +0,0 @@ -package com.mutualmobile.sample.ui.theme - -import androidx.compose.material3.Typography -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 - -// Set of Material typography styles to start with -val Typography = Typography( - bodyLarge = TextStyle( - fontFamily = FontFamily.Default, - fontWeight = FontWeight.Normal, - fontSize = 16.sp, - lineHeight = 24.sp, - letterSpacing = 0.5.sp - ) - /* Other default text styles to override - titleLarge = TextStyle( - fontFamily = FontFamily.Default, - fontWeight = FontWeight.Normal, - fontSize = 22.sp, - lineHeight = 28.sp, - letterSpacing = 0.sp - ), - labelSmall = TextStyle( - fontFamily = FontFamily.Default, - fontWeight = FontWeight.Medium, - fontSize = 11.sp, - lineHeight = 16.sp, - letterSpacing = 0.5.sp - ) - */ -) \ No newline at end of file diff --git a/sample/src/main/res/drawable-v24/ic_launcher_foreground.xml b/sample/src/main/res/drawable-v24/ic_launcher_foreground.xml index 18ff66f..b8f2c1e 100644 --- a/sample/src/main/res/drawable-v24/ic_launcher_foreground.xml +++ b/sample/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -4,10 +4,10 @@ android:height="108dp" android:viewportWidth="498" android:viewportHeight="538"> - + - #D0F1FF + #CDE6F5 \ No newline at end of file diff --git a/sample/src/test/java/com/mutualmobile/composesensors/ExampleUnitTest.kt b/sample/src/test/java/com/mutualmobile/composesensors/ExampleUnitTest.kt deleted file mode 100644 index 4cdf5d2..0000000 --- a/sample/src/test/java/com/mutualmobile/composesensors/ExampleUnitTest.kt +++ /dev/null @@ -1,17 +0,0 @@ -package com.mutualmobile.composesensors - -import org.junit.Test - -import org.junit.Assert.* - -/** - * Example local unit test, which will execute on the development machine (host). - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -class ExampleUnitTest { - @Test - fun addition_isCorrect() { - assertEquals(4, 2 + 2) - } -} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 5db7e5b..4c09925 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -15,6 +15,6 @@ dependencyResolutionManagement { } } rootProject.name = "ComposeSensors" -include(":sample") include(":composesensors") +include(":sample") include(":wearablesample") diff --git a/wearablesample/build.gradle.kts b/wearablesample/build.gradle.kts index 0cca2e9..2fa7c46 100644 --- a/wearablesample/build.gradle.kts +++ b/wearablesample/build.gradle.kts @@ -1,18 +1,19 @@ import java.util.Properties plugins { - id("com.android.application") - id("org.jetbrains.kotlin.android") + alias(libs.plugins.androidApplication) + alias(libs.plugins.composePlugin) + alias(libs.plugins.kotlinAndroid) } android { - namespace = "com.mutualmobile.wearablesample" - compileSdk = 34 + namespace = "com.mutualmobile.composesensors.wearablesample" + compileSdk = libs.versions.targetSdk.get().toInt() defaultConfig { - applicationId = "com.mutualmobile.wearablesample" - minSdk = 26 - targetSdk = 34 + applicationId = "com.mutualmobile.composesensors.wearablesample" + minSdk = libs.versions.minSdkWear.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() versionCode = 1 versionName = "1.0" vectorDrawables { @@ -48,18 +49,15 @@ android { } } compileOptions { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = "11" + jvmTarget = libs.versions.jvmTarget.get() } buildFeatures { compose = true } - composeOptions { - kotlinCompilerExtensionVersion = "1.5.11" - } packaging { resources { excludes += "/META-INF/{AL2.0,LGPL2.1}" @@ -68,19 +66,22 @@ android { } dependencies { - - implementation(project(mapOf("path" to ":composesensors"))) - implementation("androidx.core:core-ktx:1.12.0") - implementation("com.google.android.gms:play-services-wearable:18.1.0") - implementation("androidx.percentlayout:percentlayout:1.0.0") - implementation("androidx.legacy:legacy-support-v4:1.0.0") - implementation("androidx.compose.ui:ui:${rootProject.extra["compose_version"]}") - implementation("androidx.wear.compose:compose-material:${rootProject.extra["wear_compose_version"]}") - implementation("androidx.wear.compose:compose-foundation:${rootProject.extra["wear_compose_version"]}") - implementation("androidx.compose.ui:ui-tooling-preview:${rootProject.extra["compose_version"]}") - implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0") - implementation("androidx.activity:activity-compose:1.8.2") - androidTestImplementation("androidx.compose.ui:ui-test-junit4:${rootProject.extra["compose_version"]}") - debugImplementation("androidx.compose.ui:ui-tooling:${rootProject.extra["compose_version"]}") - debugImplementation("androidx.compose.ui:ui-test-manifest:${rootProject.extra["compose_version"]}") + androidTestImplementation(libs.junit.android) + androidTestImplementation(platform(libs.compose.bom)) + debugImplementation(libs.compose.ui.testManifest) + debugImplementation(libs.compose.ui.tooling) + implementation(libs.android.lifecycle.runtime) + implementation(libs.android.lifecycle.runtime.compose) + implementation(libs.androidCore) + implementation(libs.compose.activity) + implementation(libs.compose.ui) + implementation(libs.compose.ui.tooling.preview) + implementation(libs.compose.wear.foundation) + implementation(libs.compose.wear.material) + implementation(libs.legacySupport) + implementation(libs.percentLayout) + implementation(libs.playServicesWearable) + implementation(platform(libs.compose.bom)) + implementation(project(":composesensors")) + testImplementation(platform(libs.compose.bom)) } diff --git a/wearablesample/src/main/AndroidManifest.xml b/wearablesample/src/main/AndroidManifest.xml index 57d790e..799442b 100644 --- a/wearablesample/src/main/AndroidManifest.xml +++ b/wearablesample/src/main/AndroidManifest.xml @@ -27,6 +27,7 @@ @@ -36,4 +37,4 @@ - \ No newline at end of file + diff --git a/wearablesample/src/main/ic_launcher-playstore.png b/wearablesample/src/main/ic_launcher-playstore.png new file mode 100644 index 0000000..ad780c2 Binary files /dev/null and b/wearablesample/src/main/ic_launcher-playstore.png differ diff --git a/wearablesample/src/main/java/com/mutualmobile/wearablesample/presentation/MainActivity.kt b/wearablesample/src/main/java/com/mutualmobile/composesensors/wearablesample/presentation/MainActivity.kt similarity index 95% rename from wearablesample/src/main/java/com/mutualmobile/wearablesample/presentation/MainActivity.kt rename to wearablesample/src/main/java/com/mutualmobile/composesensors/wearablesample/presentation/MainActivity.kt index 7687ae2..5aeb4a4 100644 --- a/wearablesample/src/main/java/com/mutualmobile/wearablesample/presentation/MainActivity.kt +++ b/wearablesample/src/main/java/com/mutualmobile/composesensors/wearablesample/presentation/MainActivity.kt @@ -4,7 +4,7 @@ * changes to the libraries and their usages. */ -package com.mutualmobile.wearablesample.presentation +package com.mutualmobile.composesensors.wearablesample.presentation import android.Manifest import android.app.Activity @@ -34,16 +34,15 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalLifecycleOwner import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleEventObserver +import androidx.lifecycle.compose.LocalLifecycleOwner import androidx.wear.compose.material.Button import androidx.wear.compose.material.MaterialTheme import androidx.wear.compose.material.Text import com.mutualmobile.composesensors.rememberHeartRateSensorState -import com.mutualmobile.wearablesample.presentation.theme.ComposeSensorsTheme class MainActivity : ComponentActivity() { @@ -83,7 +82,8 @@ class MainActivity : ComponentActivity() { } AnimatedContent( - targetState = isPermissionGranted + targetState = isPermissionGranted, + label = "Permission Animation" ) { animatedIsGranted -> Column( horizontalAlignment = Alignment.CenterHorizontally diff --git a/wearablesample/src/main/java/com/mutualmobile/wearablesample/presentation/theme/Theme.kt b/wearablesample/src/main/java/com/mutualmobile/composesensors/wearablesample/presentation/Theme.kt similarity index 62% rename from wearablesample/src/main/java/com/mutualmobile/wearablesample/presentation/theme/Theme.kt rename to wearablesample/src/main/java/com/mutualmobile/composesensors/wearablesample/presentation/Theme.kt index 2e364a9..563eb51 100644 --- a/wearablesample/src/main/java/com/mutualmobile/wearablesample/presentation/theme/Theme.kt +++ b/wearablesample/src/main/java/com/mutualmobile/composesensors/wearablesample/presentation/Theme.kt @@ -1,15 +1,17 @@ -package com.mutualmobile.wearablesample.presentation.theme +package com.mutualmobile.composesensors.wearablesample.presentation import androidx.compose.runtime.Composable +import androidx.wear.compose.material.Colors import androidx.wear.compose.material.MaterialTheme +import androidx.wear.compose.material.Typography @Composable fun ComposeSensorsTheme( content: @Composable () -> Unit, ) { MaterialTheme( - colors = wearColorPalette, - typography = Typography, + colors = Colors(), + typography = Typography(), // For shapes, we generally recommend using the default Material Wear shapes which are // optimized for round and non-round devices. content = content, diff --git a/wearablesample/src/main/java/com/mutualmobile/wearablesample/presentation/theme/Color.kt b/wearablesample/src/main/java/com/mutualmobile/wearablesample/presentation/theme/Color.kt deleted file mode 100644 index cd5d94e..0000000 --- a/wearablesample/src/main/java/com/mutualmobile/wearablesample/presentation/theme/Color.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.mutualmobile.wearablesample.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, -) diff --git a/wearablesample/src/main/java/com/mutualmobile/wearablesample/presentation/theme/Type.kt b/wearablesample/src/main/java/com/mutualmobile/wearablesample/presentation/theme/Type.kt deleted file mode 100644 index b3fb98a..0000000 --- a/wearablesample/src/main/java/com/mutualmobile/wearablesample/presentation/theme/Type.kt +++ /dev/null @@ -1,28 +0,0 @@ -package com.mutualmobile.wearablesample.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 - ) - */ -) diff --git a/wearablesample/src/main/res/drawable/ic_launcher_foreground.xml b/wearablesample/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 0000000..b8f2c1e --- /dev/null +++ b/wearablesample/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,148 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wearablesample/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/wearablesample/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..7353dbd --- /dev/null +++ b/wearablesample/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/wearablesample/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/wearablesample/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..7353dbd --- /dev/null +++ b/wearablesample/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/wearablesample/src/main/res/mipmap-hdpi/ic_launcher.webp b/wearablesample/src/main/res/mipmap-hdpi/ic_launcher.webp index c209e78..16932e9 100644 Binary files a/wearablesample/src/main/res/mipmap-hdpi/ic_launcher.webp and b/wearablesample/src/main/res/mipmap-hdpi/ic_launcher.webp differ diff --git a/wearablesample/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/wearablesample/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..0c78a40 Binary files /dev/null and b/wearablesample/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ diff --git a/wearablesample/src/main/res/mipmap-mdpi/ic_launcher.webp b/wearablesample/src/main/res/mipmap-mdpi/ic_launcher.webp index 4f0f1d6..1296e47 100644 Binary files a/wearablesample/src/main/res/mipmap-mdpi/ic_launcher.webp and b/wearablesample/src/main/res/mipmap-mdpi/ic_launcher.webp differ diff --git a/wearablesample/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/wearablesample/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..4ade3fb Binary files /dev/null and b/wearablesample/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ diff --git a/wearablesample/src/main/res/mipmap-xhdpi/ic_launcher.webp b/wearablesample/src/main/res/mipmap-xhdpi/ic_launcher.webp index 948a307..f089bdd 100644 Binary files a/wearablesample/src/main/res/mipmap-xhdpi/ic_launcher.webp and b/wearablesample/src/main/res/mipmap-xhdpi/ic_launcher.webp differ diff --git a/wearablesample/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/wearablesample/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..05ff644 Binary files /dev/null and b/wearablesample/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ diff --git a/wearablesample/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/wearablesample/src/main/res/mipmap-xxhdpi/ic_launcher.webp index 28d4b77..36f78bb 100644 Binary files a/wearablesample/src/main/res/mipmap-xxhdpi/ic_launcher.webp and b/wearablesample/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ diff --git a/wearablesample/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/wearablesample/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..7fd9e09 Binary files /dev/null and b/wearablesample/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ diff --git a/wearablesample/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/wearablesample/src/main/res/mipmap-xxxhdpi/ic_launcher.webp index aa7d642..263672a 100644 Binary files a/wearablesample/src/main/res/mipmap-xxxhdpi/ic_launcher.webp and b/wearablesample/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ diff --git a/wearablesample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/wearablesample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b1c824d Binary files /dev/null and b/wearablesample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ diff --git a/wearablesample/src/main/res/values-round/strings.xml b/wearablesample/src/main/res/values-round/strings.xml deleted file mode 100644 index 42f1229..0000000 --- a/wearablesample/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/wearablesample/src/main/res/values/ic_launcher_background.xml b/wearablesample/src/main/res/values/ic_launcher_background.xml new file mode 100644 index 0000000..e5574bd --- /dev/null +++ b/wearablesample/src/main/res/values/ic_launcher_background.xml @@ -0,0 +1,4 @@ + + + #CDE6F5 + \ No newline at end of file diff --git a/wearablesample/src/main/res/values/strings.xml b/wearablesample/src/main/res/values/strings.xml index a09c157..4830841 100644 --- a/wearablesample/src/main/res/values/strings.xml +++ b/wearablesample/src/main/res/values/strings.xml @@ -1,8 +1,3 @@ Wear Sample - - From the Square world,\nHello, %1$s! - \ No newline at end of file +