feat: 워치 페이스 푸시로 앱 설치 때 날씨각 스킨 같이 적용(Wear OS 6+), 앱 첫 장을 오늘 남은 시간→주변 축제 순으로
Play 스토어 심사에 낸 1(0.1) 빌드와 같은 코드 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ee46a101db
commit
e270261e32
9 files changed
+203
-87
No files matched your search
@@ -1,3 +1,15 @@
|
||||
import com.google.android.wearable.watchface.validator.client.DwfValidatorFactory
|
||||
|
||||
// 스킨 APK 검증·토큰 발급기 (Watch Face Push). 의존성 하나가 jitpack 에만 있다
|
||||
buildscript {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
maven("https://jitpack.io") { content { includeGroup("com.github.xgouchet") } }
|
||||
}
|
||||
dependencies { classpath("com.google.android.wearable.watchface.validator:validator-push:1.0.0-alpha09") }
|
||||
}
|
||||
|
||||
plugins {
|
||||
id("com.android.application")
|
||||
id("org.jetbrains.kotlin.plugin.compose")
|
||||
@@ -9,10 +21,13 @@ android {
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "kr.o2o.nalssigak"
|
||||
minSdk = 30
|
||||
targetSdk = 34
|
||||
// Wear OS 6+ 만. 앱 설치 때 스킨을 같이 깔고 시계 화면으로 바꾸는 Watch Face Push 가 API 36 부터다
|
||||
minSdk = 36
|
||||
targetSdk = 36
|
||||
versionCode = 1
|
||||
versionName = "0.1"
|
||||
// 앱에 실은 스킨 버전. 워치에 깔린 스킨이 이보다 낮으면 앱이 바꿔 끼운다 (MainActivity.useSkin)
|
||||
buildConfigField("int", "SKIN_VERSION", providers.gradleProperty("NALSSIGAK_SKIN_VERSION").get())
|
||||
}
|
||||
buildTypes {
|
||||
// 에뮬레이터에서 본 맥의 로컬 백엔드 (compose 포트 9810)
|
||||
@@ -38,4 +53,36 @@ dependencies {
|
||||
implementation("androidx.wear.tiles:tiles:1.6.2")
|
||||
implementation("androidx.concurrent:concurrent-futures:1.3.0")
|
||||
implementation("androidx.wear.watchface:watchface-complications-data-source-ktx:1.3.0")
|
||||
implementation("androidx.wear.watchfacepush:watchfacepush:1.0.0")
|
||||
}
|
||||
|
||||
// 앱을 깔면 스킨(:watchface)도 같이 깔리게 한다 (Wear OS 6+ 기본 워치 페이스).
|
||||
// 같은 빌드 타입의 스킨 APK 를 assets/default_watchface.apk 로 싣고, 검증 토큰을 문자열 리소스로 만든다
|
||||
androidComponents.onVariants { variant ->
|
||||
val name = variant.name.replaceFirstChar(Char::titlecase)
|
||||
val skinApks = project(":watchface").layout.buildDirectory.dir("outputs/apk/${variant.name}")
|
||||
val assetsDir = layout.buildDirectory.dir("generated/skinAssets/${variant.name}")
|
||||
val resDir = layout.buildDirectory.dir("generated/skinToken/${variant.name}")
|
||||
val appId = variant.applicationId
|
||||
variant.sources.assets?.addStaticSourceDirectory(assetsDir.get().asFile.path)
|
||||
variant.sources.res?.addStaticSourceDirectory(resDir.get().asFile.path)
|
||||
val bundle = tasks.register("bundleSkin$name") {
|
||||
dependsOn(":watchface:assemble$name")
|
||||
inputs.dir(skinApks)
|
||||
outputs.dirs(assetsDir, resDir)
|
||||
doLast {
|
||||
val apk = skinApks.get().asFile.listFiles { f -> f.extension == "apk" }!!.single()
|
||||
// 서명 없는 스킨은 워치가 설치를 거부한다. 업로드 키 설정은 루트 build.gradle.kts 참고
|
||||
if (apk.name.endsWith("-unsigned.apk")) throw GradleException("스킨 APK 가 서명되지 않았습니다. ~/.gradle/gradle.properties 에 NALSSIGAK_STORE_* 를 넣고 다시 빌드하세요")
|
||||
val result = DwfValidatorFactory.create().validate(apk, appId.get())
|
||||
if (result.failures().isNotEmpty()) throw GradleException("스킨 검증 실패: ${result.failures()}")
|
||||
apk.copyTo(assetsDir.get().file("default_watchface.apk").asFile, overwrite = true)
|
||||
resDir.get().file("values/skin_token.xml").asFile.apply { parentFile.mkdirs() }
|
||||
.writeText(
|
||||
"""<resources xmlns:tools="http://schemas.android.com/tools">""" +
|
||||
"""<string name="default_wf_token" translatable="false" tools:ignore="Typos">${result.validationToken()}</string></resources>""" + "\n"
|
||||
)
|
||||
}
|
||||
}
|
||||
afterEvaluate { tasks.named("pre${name}Build") { dependsOn(bundle) } }
|
||||
}
|
||||
Reference in new issue
Block a user