-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5d834c1
commit fe94350
Showing
32 changed files
with
681 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
plugins { | ||
alias(libs.plugins.kotlin.multiplatform) apply false | ||
alias(libs.plugins.kotlin.compose) apply false | ||
alias(libs.plugins.kotlin.android) apply false | ||
alias(libs.plugins.android.application) apply false | ||
alias(libs.plugins.compose) apply false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,4 +30,5 @@ dependencyResolutionManagement { | |
} | ||
} | ||
|
||
include(":composeApp") | ||
include(":composeApp") | ||
include(":wearApp") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
@file:OptIn(org.jetbrains.kotlin.gradle.ExperimentalWasmDsl::class) | ||
|
||
import org.apache.commons.io.output.ByteArrayOutputStream | ||
import java.nio.charset.Charset | ||
|
||
plugins { | ||
alias(libs.plugins.kotlin.serialization) | ||
alias(libs.plugins.kotlin.compose) | ||
alias(libs.plugins.kotlin.android) | ||
alias(libs.plugins.android.application) | ||
alias(libs.plugins.compose) | ||
} | ||
|
||
private val gitCommitsCount: Int by lazy { | ||
val stdout = ByteArrayOutputStream() | ||
rootProject.exec { | ||
commandLine("git", "rev-list", "--count", "HEAD") | ||
standardOutput = stdout | ||
} | ||
stdout.toString(Charset.defaultCharset()).trim().toInt() | ||
} | ||
|
||
kotlin { | ||
jvmToolchain(21) | ||
} | ||
|
||
android { | ||
namespace = "org.michaelbel.template" | ||
compileSdk = libs.versions.compile.sdk.get().toInt() | ||
|
||
defaultConfig { | ||
applicationId = "org.michaelbel.template" | ||
minSdk = libs.versions.min.sdk.get().toInt() | ||
targetSdk = libs.versions.target.sdk.get().toInt() | ||
versionName = "1.0.0" | ||
versionCode = gitCommitsCount | ||
} | ||
buildFeatures { | ||
compose = true | ||
} | ||
} | ||
|
||
base { | ||
archivesName.set("KmpTemplate-v${android.defaultConfig.versionName}(${android.defaultConfig.versionCode})") | ||
} | ||
|
||
dependencies { | ||
implementation(libs.androidx.core.splashscreen) | ||
implementation(libs.google.material) | ||
implementation(libs.google.horologist.compose.layout) | ||
implementation(libs.androidx.activity.compose) | ||
implementation(libs.androidx.wear.compose.foundation) | ||
implementation(libs.androidx.wear.compose.material) | ||
implementation(libs.androidx.wear.compose.navigation) | ||
} | ||
|
||
tasks.register("printVersionName") { | ||
doLast { | ||
println(android.defaultConfig.versionName) | ||
} | ||
} | ||
|
||
tasks.register("printVersionCode") { | ||
doLast { | ||
println(android.defaultConfig.versionCode.toString()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?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-feature android:name="android.hardware.type.watch" /> | ||
|
||
<application | ||
android:name=".WearApplication" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.App.Starting" | ||
tools:ignore="UnusedAttribute"> | ||
|
||
<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:exported="true" | ||
android:name="org.michaelbel.template.WearMainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
</application> | ||
|
||
</manifest> |
4 changes: 4 additions & 0 deletions
4
wearApp/src/main/java/org/michaelbel/template/Template.wearos.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package org.michaelbel.template | ||
|
||
val TemplateName: String | ||
get() = "WearOS Template" |
10 changes: 10 additions & 0 deletions
10
wearApp/src/main/java/org/michaelbel/template/WearApplication.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.michaelbel.template | ||
|
||
import android.app.Application | ||
|
||
class WearApplication: Application() { | ||
|
||
override fun onCreate() { | ||
super.onCreate() | ||
} | ||
} |
105 changes: 105 additions & 0 deletions
105
wearApp/src/main/java/org/michaelbel/template/WearMainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
@file:OptIn(ExperimentalHorologistApi::class) | ||
|
||
package org.michaelbel.template | ||
|
||
import android.os.Bundle | ||
import androidx.activity.compose.setContent | ||
import androidx.compose.runtime.Composable | ||
import androidx.activity.ComponentActivity | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.text.style.TextAlign | ||
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen | ||
import androidx.navigation.NavHostController | ||
import androidx.wear.compose.material.MaterialTheme | ||
import androidx.wear.compose.material.Text | ||
import androidx.wear.compose.navigation.SwipeDismissableNavHost | ||
import androidx.wear.compose.navigation.composable | ||
import androidx.wear.compose.navigation.rememberSwipeDismissableNavController | ||
import com.google.android.horologist.annotations.ExperimentalHorologistApi | ||
import com.google.android.horologist.compose.layout.AppScaffold | ||
import com.google.android.horologist.compose.layout.ScreenScaffold | ||
import com.google.android.horologist.compose.layout.rememberColumnState | ||
|
||
class WearMainActivity: ComponentActivity() { | ||
|
||
private lateinit var navController: NavHostController | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
installSplashScreen() | ||
super.onCreate(savedInstanceState) | ||
setContent { | ||
navController = rememberSwipeDismissableNavController() | ||
WearApp( | ||
navController = navController | ||
) | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
fun WearApp( | ||
navController: NavHostController | ||
) { | ||
AppScaffold { | ||
SwipeDismissableNavHost( | ||
navController = navController, | ||
startDestination = Screen.Home.route | ||
) { | ||
composable( | ||
route = Screen.Home.route | ||
) { | ||
val scrollState = rememberColumnState() | ||
ScreenScaffold( | ||
modifier = Modifier.fillMaxSize(), | ||
scrollState = scrollState | ||
) { | ||
|
||
Text( | ||
text = "Home", | ||
modifier = Modifier.fillMaxSize().align(Alignment.Center), | ||
style = MaterialTheme.typography.title1, | ||
textAlign = TextAlign.Center | ||
) | ||
} | ||
} | ||
composable( | ||
route = Screen.Chat.route | ||
) { | ||
val scrollState = rememberColumnState() | ||
ScreenScaffold( | ||
scrollState = scrollState | ||
) { | ||
Text( | ||
text = "Chat", | ||
style = MaterialTheme.typography.title1, | ||
textAlign = TextAlign.Center | ||
) | ||
} | ||
} | ||
composable( | ||
route = Screen.Settings.route | ||
) { | ||
val scrollState = rememberColumnState() | ||
ScreenScaffold( | ||
scrollState = scrollState | ||
) { | ||
Text( | ||
text = "Settings", | ||
style = MaterialTheme.typography.title1, | ||
textAlign = TextAlign.Center | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
sealed class Screen( | ||
val route: String | ||
) { | ||
data object Home: Screen("home") | ||
data object Chat: Screen("chat") | ||
data object Settings: Screen("settings") | ||
} |
30 changes: 30 additions & 0 deletions
30
wearApp/src/main/res/drawable-v24/ic_launcher_foreground.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:aapt="http://schemas.android.com/aapt" | ||
android:width="108dp" | ||
android:height="108dp" | ||
android:viewportWidth="108" | ||
android:viewportHeight="108"> | ||
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z"> | ||
<aapt:attr name="android:fillColor"> | ||
<gradient | ||
android:endX="85.84757" | ||
android:endY="92.4963" | ||
android:startX="42.9492" | ||
android:startY="49.59793" | ||
android:type="linear"> | ||
<item | ||
android:color="#44000000" | ||
android:offset="0.0" /> | ||
<item | ||
android:color="#00000000" | ||
android:offset="1.0" /> | ||
</gradient> | ||
</aapt:attr> | ||
</path> | ||
<path | ||
android:fillColor="#FFFFFF" | ||
android:fillType="nonZero" | ||
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z" | ||
android:strokeWidth="1" | ||
android:strokeColor="#00000000" /> | ||
</vector> |
Oops, something went wrong.