Skip to content

Commit

Permalink
[WEAR] Add base for Wear OS
Browse files Browse the repository at this point in the history
  • Loading branch information
kamgurgul committed Dec 29, 2024
1 parent cb13ee6 commit 853908d
Show file tree
Hide file tree
Showing 34 changed files with 649 additions and 3 deletions.
5 changes: 4 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ composeAdaptive = "1.0.1"
composeUiTest = "1.7.6"
composeMultiplatform = "1.7.3"
dependencyUpdate = "0.51.0"
horologist = "0.7.8-alpha"
kermit = "2.0.5"
koin = "4.0.1"
kotlin = "2.1.0"
Expand Down Expand Up @@ -56,11 +57,13 @@ androidx-test-uiautomator = { group = "androidx.test.uiautomator", name = "uiaut
androidx-tv = { module = "androidx.tv:tv-material", version.ref = "androidxTv" }
androidx-wear-foundation = { module = "androidx.wear.compose:compose-foundation", version.ref = "androidxWear" }
androidx-wear-material = { module = "androidx.wear.compose:compose-material", version.ref = "androidxWear" }
androidx-wear-navigation = { module = "androidx.wear.compose:compose-navigation ń ", version.ref = "androidxWear" }
androidx-wear-navigation = { module = "androidx.wear.compose:compose-navigation", version.ref = "androidxWear" }
coil = { group = "io.coil-kt.coil3", name = "coil-compose", version.ref = "coil" }
compose-adaptive = { module = "org.jetbrains.compose.material3.adaptive:adaptive", version.ref = "composeAdaptive" }
compose-ui-test = { module = "androidx.compose.ui:ui-test-junit4", version.ref = "composeUiTest" }
compose-ui-testManifest = { module = "androidx.compose.ui:ui-test-manifest", version.ref = "composeUiTest" }
horologist-compose-layout = { module = "com.google.android.horologist:horologist-compose-layout", version.ref = "horologist" }
horologist-compose-material = { module = "com.google.android.horologist:horologist-compose-material", version.ref = "horologist" }
kermit-kermit = { module = "co.touchlab:kermit", version.ref = "kermit" }
koin-android = { module = "io.insert-koin:koin-android", version.ref = "koin" }
koin-compose-viewodel = { module = "io.insert-koin:koin-compose-viewmodel", version.ref = "koin" }
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ include(":androidApp")
include(":androidApp:baselineprofile")
include(":desktopApp")
include(":shared")
include(":wearOsApp")
include(":webApp")
2 changes: 0 additions & 2 deletions shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,6 @@ composeCompiler {
android {
compileSdk = AndroidVersions.COMPILE_SDK
namespace = "com.kgurgul.cpuinfo.shared"
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
sourceSets["main"].res.srcDirs("src/androidMain/res")

defaultConfig {
minSdk = AndroidVersions.MIN_SDK
Expand Down
1 change: 1 addition & 0 deletions wearOsApp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
101 changes: 101 additions & 0 deletions wearOsApp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
plugins {
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.android.application)
alias(libs.plugins.compose.compiler)
id("kotlin-parcelize")
}

kotlin {
androidTarget()
sourceSets {
val androidMain by getting {
dependencies {
implementation(project(":shared"))
}
}
}
}

android {
compileSdk = AndroidVersions.COMPILE_SDK

defaultConfig {
applicationId = "com.kgurgul.cpuinfo.wear"

minSdk = 26
targetSdk = AndroidVersions.TARGET_SDK
versionCode = AndroidVersions.VERSION_CODE
versionName = AndroidVersions.VERSION_NAME

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

namespace = "com.kgurgul.cpuinfo.wear"

signingConfigs {
getByName("debug") {
val debugSigningConfig = AndroidSigningConfig.getDebugProperties(rootProject.rootDir)
storeFile = file(debugSigningConfig.getProperty(AndroidSigningConfig.KEY_PATH))
keyAlias = debugSigningConfig.getProperty(AndroidSigningConfig.KEY_ALIAS)
keyPassword = debugSigningConfig.getProperty(AndroidSigningConfig.KEY_PASS)
storePassword = debugSigningConfig.getProperty(AndroidSigningConfig.KEY_PASS)
}
/* create("release") {
val releaseSigningConfig =
AndroidSigningConfig.getReleaseProperties(rootProject.rootDir)
storeFile = file(releaseSigningConfig.getProperty(AndroidSigningConfig.KEY_PATH))
keyAlias = releaseSigningConfig.getProperty(AndroidSigningConfig.KEY_ALIAS)
keyPassword = releaseSigningConfig.getProperty(AndroidSigningConfig.KEY_PASS)
storePassword = releaseSigningConfig.getProperty(AndroidSigningConfig.KEY_PASS)
}*/
}

buildTypes {
/* release {
signingConfig = signingConfigs.getByName("release")
isMinifyEnabled = true
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
}*/
debug {
signingConfig = signingConfigs.getByName("debug")
isMinifyEnabled = false
enableUnitTestCoverage = true
applicationIdSuffix = ".debug"
}
}

buildFeatures {
compose = true
buildConfig = true
}

testOptions {
unitTests {
isReturnDefaultValues = true
isIncludeAndroidResources = true
}
animationsDisabled = true
execution = "ANDROIDX_TEST_ORCHESTRATOR"
}

lint {
abortOnError = false
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
}

dependencies {
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.core.splashscreen)
implementation(libs.androidx.wear.foundation)
implementation(libs.androidx.wear.material)
implementation(libs.androidx.wear.navigation)
implementation(libs.horologist.compose.layout)
implementation(libs.horologist.compose.material)

implementation(libs.koin.android)
}
Binary file added wearOsApp/debug.keystore
Binary file not shown.
7 changes: 7 additions & 0 deletions wearOsApp/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Remove logs
-assumenosideeffects class co.touchlab.kermit.Logger {
public *** v(...);
public *** d(...);
public *** i(...);
public *** e(...);
}
47 changes: 47 additions & 0 deletions wearOsApp/src/androidMain/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.GET_PACKAGE_SIZE" />
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />
<uses-permission
android:name="android.permission.QUERY_ALL_PACKAGES"
tools:ignore="QueryAllPackagesPermission" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

<uses-feature android:name="android.hardware.type.watch" />

<application
android:name=".WearCpuInfoApp"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="false"
android:theme="@android:style/Theme.DeviceDefault">

<uses-library
android:name="com.google.android.wearable"
android:required="true" />

<meta-data
android:name="com.google.android.wearable.standalone"
android:value="true" />

<activity
android:name=".MainActivity"
android:exported="true"
android:taskAffinity=".main"
android:theme="@style/Theme.Launcher">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Loading

0 comments on commit 853908d

Please sign in to comment.