diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index 3729932d..52a09eaf 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -15,6 +15,7 @@ | `:core:core-database` | Realm Kotlin 모델(`model/*`, `TokizModels`, `RecentCall`), `WorkersDb`, `CustMigration` | `io.realm.kotlin` api 노출 | | `:core:core-network` | 공용 `OkHttpClient` 싱글톤(`NetworkClient`) | OkHttp3 커넥션 풀 공유 | | `:feature:feature-torrent` | `TorrentService`/`TorrentTask` 및 `jlibtorrent` JAR 격리 모듈 | `:core:core-common` 의존 | +| `:feature:feature-wallpaper` | `MyWallpaperService`/`NativeRenderer` 라이브 월페이퍼 모듈 | `:core:core-common`, `:core:core-database` 의존 | | `:gdrive` | Google Drive `appDataFolder` 기반 로그인 및 백업 모듈 | `:app`에서 `implementation(project(":gdrive"))`로 참조 | | `:lun_launcher` | Wear OS 컴패니언 앱 (`bums.lunatic.launcher`, `minSdk 30`, `compileSdk 36`) | Compose for Wear OS, Tile, Complication, 제스처 전송(`MessageClient`) | diff --git a/TODO.md b/TODO.md index a83a9aa3..e1cf1807 100644 --- a/TODO.md +++ b/TODO.md @@ -183,6 +183,6 @@ lunar_launcher/ #### 단계별 모듈화 실행 순서 - [x] **6-1. `:core:common`, `:core:network`, `:core:database` 분리** (`:core:core-common`, `:core:core-database`, `:core:core-network` 모두 분리 완료) -- [x] **6-2. 독립 기능 우선 분리 (`:feature:torrent`, `:feature:wallpaper`)** (`:feature:feature-torrent` 분리 및 `jlibtorrent` JAR 격리 완료; `:feature:wallpaper`는 후속 진행) +- [x] **6-2. 독립 기능 우선 분리 (`:feature:torrent`, `:feature:wallpaper`)** (`:feature:feature-torrent`, `:feature:feature-wallpaper` 모두 분리 완료) - [ ] **6-3. 뷰어/리더 분리 (`:feature:player`, `:feature:reader`)**: `PlayerActivity`/`NativePlayer`(+ `PlayerEngine.cpp`)와 `DocumentViewerActivity`/`ImageViewerActivity`, `TokiFragment`/`WebReaderActivity`를 분리. - [ ] **6-4. 피드/수집기 분리 (`:feature:feeds`)**: `RssHome`, `NeoRssActivity`, `TaskAggregator`, `*Getter`군을 분리하고 `:app`은 런처 홈과 서비스 진입점만 유지. diff --git a/app/build.gradle.kts b/app/build.gradle.kts index fed6e78a..2c89a9f2 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -139,6 +139,7 @@ dependencies { implementation(project(":core:core-database")) implementation(project(":core:core-network")) implementation(project(":feature:feature-torrent")) + implementation(project(":feature:feature-wallpaper")) implementation(project(":gdrive")) implementation("com.google.android.gms:play-services-wearable:19.0.0") val kotlinVersion: String? by extra diff --git a/app/src/main/kotlin/bums/lunatic/launcher/LunaticLauncher.kt b/app/src/main/kotlin/bums/lunatic/launcher/LunaticLauncher.kt index 159ebb21..aeafa971 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/LunaticLauncher.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/LunaticLauncher.kt @@ -118,6 +118,27 @@ prefs: PrefHelper.initialize(this) bums.lunatic.launcher.model.RssDataType.enabledChecker = { key -> PrefHelper.getBoolean(key, false) } bums.lunatic.launcher.workers.WorkersDb.schemaVersion = BuildConfig.BuildDateTime + bums.lunatic.launcher.wall.MyWallpaperService.weatherSummaryProvider = { + bums.lunatic.launcher.workers.LocationUpdateService.lastWeather + } + bums.lunatic.launcher.wall.MyWallpaperService.symbolFontResId = R.font.material_symbols + bums.lunatic.launcher.wall.MyWallpaperService.wallpaperFontResIds = listOf( + R.font.cafe24ohsquareair, R.font.cafe24oneprettynight, R.font.cafe24ssukssukregular, + R.font.dovemayo, R.font.ebs_r, R.font.gabia_solmee, R.font.godomaum, + R.font.jsarirang_hon, R.font.jsarirang_ppuri, R.font.jsdongkang_regular, + R.font.kcc_kimhoon, R.font.kcc_sonkeechung, R.font.kccahnjunggeun, + R.font.kotra_bold, R.font.kotra_songeulssi, R.font.kyobo_handwriting_2019, + R.font.kyobo_handwriting_2021sjy, R.font.kyobohandwriting2024psw, + R.font.mapoagape, R.font.mapobackpacking, R.font.mapodacapo, R.font.mapodpp, + R.font.mapodpp_2, R.font.mapoflowerisland, R.font.mapogoldenpier, R.font.mapomaponaru, + R.font.mapopeacefull, R.font.material_symbols, R.font.nnsgc_brhp, R.font.nnsgc_gd_an_gd, + R.font.nnsgc_md, R.font.nnsgc_wsjidyp, R.font.nnsgc_yjc, R.font.on_jsuhl, R.font.on_jsuhr, + R.font.on_sbsjl, R.font.on_sbsjr, R.font.on_treeususimgul, R.font.on_treeususimgul_r, + R.font.on_wibsr, R.font.on_wisbl, R.font.on_ychyuhl, R.font.on_ychyuhr, + R.font.ssshinb7, R.font.taebaek_milkyway, R.font.taefont_tsthlml, + R.font.tvn_jguiyg_light, R.font.tvn_jguiyg_medium, R.font.wandohoper, + R.font.ylee_mortal_heart_immortal_memory + ) Base64ImageCache.init(this) val dir = try { val externalDir = File("/storage/emulated/0/bums_ob/BUM'S PACED /scraped/logs") diff --git a/feature/feature-wallpaper/build.gradle.kts b/feature/feature-wallpaper/build.gradle.kts new file mode 100644 index 00000000..00c10fac --- /dev/null +++ b/feature/feature-wallpaper/build.gradle.kts @@ -0,0 +1,30 @@ +plugins { + id("com.android.library") + id("kotlin-android") +} + +android { + namespace = "bums.lunatic.launcher.feature.wallpaper" + compileSdk = 35 + + defaultConfig { + minSdk = 26 + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = "1.8" + } +} + +dependencies { + implementation(project(":core:core-common")) + implementation(project(":core:core-database")) + implementation("androidx.core:core-ktx:1.15.0") + implementation("com.google.code.gson:gson:2.13.1") + implementation("com.google.guava:guava:33.2.1-jre") +} diff --git a/feature/feature-wallpaper/src/main/AndroidManifest.xml b/feature/feature-wallpaper/src/main/AndroidManifest.xml new file mode 100644 index 00000000..8072ee00 --- /dev/null +++ b/feature/feature-wallpaper/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ + + diff --git a/app/src/main/kotlin/bums/lunatic/launcher/wall/MyWallpaperService.kt b/feature/feature-wallpaper/src/main/kotlin/bums/lunatic/launcher/wall/MyWallpaperService.kt similarity index 94% rename from app/src/main/kotlin/bums/lunatic/launcher/wall/MyWallpaperService.kt rename to feature/feature-wallpaper/src/main/kotlin/bums/lunatic/launcher/wall/MyWallpaperService.kt index 02d1b6e2..c4e89a2e 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/wall/MyWallpaperService.kt +++ b/feature/feature-wallpaper/src/main/kotlin/bums/lunatic/launcher/wall/MyWallpaperService.kt @@ -36,12 +36,10 @@ import android.view.ViewGroup import android.widget.LinearLayout import android.widget.TextView import androidx.core.graphics.alpha -import bums.lunatic.launcher.R import bums.lunatic.launcher.model.QuoteItem import bums.lunatic.launcher.model.Translation import bums.lunatic.launcher.model.WallContentGroup import bums.lunatic.launcher.utils.Blog -import bums.lunatic.launcher.workers.LocationUpdateService import bums.lunatic.launcher.workers.WorkersDb import com.google.common.reflect.TypeToken import com.google.gson.Gson @@ -52,7 +50,11 @@ import java.util.Locale class MyWallpaperService : WallpaperService() { - + companion object { + var weatherSummaryProvider: () -> List = { emptyList() } + var symbolFontResId: Int = 0 + var wallpaperFontResIds: List = emptyList() + } private val TAG = "MyWallpaperService" @@ -416,7 +418,7 @@ class MyWallpaperService : WallpaperService() { } private val materialIconFont: Typeface by lazy { - resources.getFont(R.font.material_symbols) + if (symbolFontResId != 0) resources.getFont(symbolFontResId) else Typeface.DEFAULT } // 날씨 텍스트를 분석하여 Material Symbol 아이콘 문자열로 변환하는 함수 @@ -488,63 +490,15 @@ class MyWallpaperService : WallpaperService() { else -> condition } } - val fontz = arrayListOf( - R.font.cafe24ohsquareair, - R.font.cafe24oneprettynight, - R.font.cafe24ssukssukregular, - R.font.dovemayo, - R.font.ebs_r, - R.font.gabia_solmee, - R.font.godomaum, - R.font.jsarirang_hon, - R.font.jsarirang_ppuri, - R.font.jsdongkang_regular, - R.font.kcc_kimhoon, - R.font.kcc_sonkeechung, - R.font.kccahnjunggeun, - R.font.kotra_bold, - R.font.kotra_songeulssi, - R.font.kyobo_handwriting_2019, - R.font.kyobo_handwriting_2021sjy, - R.font.kyobohandwriting2024psw, - R.font.mapoagape, - R.font.mapobackpacking, - R.font.mapodacapo, - R.font.mapodpp, - R.font.mapodpp_2, - R.font.mapoflowerisland, - R.font.mapogoldenpier, - R.font.mapomaponaru, - R.font.mapopeacefull, - R.font.material_symbols, - R.font.nnsgc_brhp, - R.font.nnsgc_gd_an_gd, - R.font.nnsgc_md, - R.font.nnsgc_wsjidyp, - R.font.nnsgc_yjc, - R.font.on_jsuhl, - R.font.on_jsuhr, - R.font.on_sbsjl, - R.font.on_sbsjr, - R.font.on_treeususimgul, - R.font.on_treeususimgul_r, - R.font.on_wibsr, - R.font.on_wisbl, - R.font.on_ychyuhl, - R.font.on_ychyuhr, - R.font.ssshinb7, - R.font.taebaek_milkyway, - R.font.taefont_tsthlml, - R.font.tvn_jguiyg_light, - R.font.tvn_jguiyg_medium, - R.font.wandohoper, - R.font.ylee_mortal_heart_immortal_memory, - ) + private fun randomFontOrDefault(): Typeface { + val id = wallpaperFontResIds.randomOrNull() ?: return Typeface.DEFAULT + return try { resources.getFont(id) } catch (_: Exception) { Typeface.DEFAULT } + } - var monoBold = resources.getFont(fontz.random()) - var quote = resources.getFont(fontz.random()) - var local = resources.getFont(fontz.random()) - var numbers = resources.getFont(fontz.random()) + var monoBold = randomFontOrDefault() + var quote = randomFontOrDefault() + var local = randomFontOrDefault() + var numbers = randomFontOrDefault() private fun drawBitmapFromText(weatherLines: List, isCharging: Boolean = false): Bitmap? { // 💡 1. 원의 크기와 내부 여백 계산 @@ -759,7 +713,7 @@ class MyWallpaperService : WallpaperService() { } // 비트맵 생성 및 전달 - val weather = LocationUpdateService.lastWeather + val weather = weatherSummaryProvider() val bitmap = drawBitmapFromText(weather,isCharging) bitmap?.let { nativeRenderer?.setWeatherBitmap(it) @@ -794,10 +748,10 @@ class MyWallpaperService : WallpaperService() { val realm = WorkersDb.getRealm() val quotes = realm.query(QuoteItem::class).find().shuffled() randomQuote = if (quotes.isNotEmpty()) quotes.random() else null - monoBold = resources.getFont(fontz.random()) - quote = resources.getFont(fontz.random()) - local = resources.getFont(fontz.random()) - numbers = resources.getFont(fontz.random()) + monoBold = randomFontOrDefault() + quote = randomFontOrDefault() + local = randomFontOrDefault() + numbers = randomFontOrDefault() getFdFromPath(nextFile.absolutePath)?.let { fd -> nativeRenderer?.startNextPreload(fd) @@ -808,7 +762,7 @@ class MyWallpaperService : WallpaperService() { val (batteryLevel, isCharging) = getBatteryStatus() if (batteryLevel >= 70 || isCharging) { - val bitmap = drawBitmapFromText(LocationUpdateService.lastWeather) + val bitmap = drawBitmapFromText(weatherSummaryProvider()) bitmap?.let { nativeRenderer?.setWeatherBitmap(it) } nativeRenderer?.setImageRenderFrame(55) Log.d(TAG, "Battery Low: Weather updated only on media change.") diff --git a/app/src/main/kotlin/bums/lunatic/launcher/wall/NativeRenderer.kt b/feature/feature-wallpaper/src/main/kotlin/bums/lunatic/launcher/wall/NativeRenderer.kt similarity index 100% rename from app/src/main/kotlin/bums/lunatic/launcher/wall/NativeRenderer.kt rename to feature/feature-wallpaper/src/main/kotlin/bums/lunatic/launcher/wall/NativeRenderer.kt diff --git a/settings.gradle.kts b/settings.gradle.kts index dff28a15..ddeb7247 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -27,5 +27,6 @@ include(":core:core-common") include(":core:core-database") include(":core:core-network") include(":feature:feature-torrent") +include(":feature:feature-wallpaper") include(":gdrive") include(":lun_launcher")