From 2ca69a685e296e906498ff18db80c8f7f7374757 Mon Sep 17 00:00:00 2001 From: lunaticbum Date: Mon, 16 Nov 2026 13:22:22 +0900 Subject: [PATCH] =?UTF-8?q?build:=20Task=2021=20=EC=99=84=EB=A3=8C=20-=20:?= =?UTF-8?q?core:core-database=20=EB=AA=A8=EB=93=88=20=EB=B6=84=EB=A6=AC=20?= =?UTF-8?q?=EB=B0=8F=20Realm=20=EB=AA=A8=EB=8D=B8/WorkersDb=20=EA=B2=A9?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - core/core-database 모듈 신규 생성 (namespace: bums.lunatic.launcher.core.database, io.realm.kotlin 플러그인/의존성 격리): * app/src/main/kotlin/.../model/* (UI 헬퍼 WeatherInfoManager, RssDataTypeUiExt 제외) 및 model/others/* 이동 * WorkersDb.kt, CustMigration, RecentCallGetter.kt 이동 및 BuildConfig.BuildDateTime 직접 참조를 WorkersDb.schemaVersion 프로퍼티로 디커플링 * HistoryManager.kt에서 Realm 모델 5종(LastInfo, HistoryItem, ReaderConfig, ContentsCollection, ContentsPageInfo)을 TokizModels.kt로 분리 이동 - RssDataInterface.kt 디커플링: * R.drawable 참조(getResId)를 :app의 RssDataTypeUiExt.kt로 분리 (RssItemAdapter.kt에 import 추가) * PrefHelper 직접 참조를 RssDataType.enabledChecker 람다 주입으로 분리하고 LunaticLauncher.onCreate()에서 바인딩 - settings.gradle.kts, app/build.gradle.kts, ARCHITECTURE.md, TODO.md 갱신 (6-1 완료) - 검증: ./gradlew :app:compileDebugKotlin 빌드 성공 확인 (7s, 85 actionable tasks) --- ARCHITECTURE.md | 3 +- TODO.md | 2 +- app/build.gradle.kts | 1 + .../bums/lunatic/launcher/LunaticLauncher.kt | 2 + .../launcher/home/adapters/RssItemAdapter.kt | 1 + .../launcher/home/tokiz/HistoryManager.kt | 268 ----------------- .../launcher/model/RssDataTypeUiExt.kt | 13 + core/core-database/build.gradle.kts | 30 ++ .../src/main/AndroidManifest.xml | 2 + .../launcher/home/tokiz/TokizModels.kt | 280 ++++++++++++++++++ .../bums/lunatic/launcher/model/Adults.kt | 0 .../bums/lunatic/launcher/model/AppInfo.kt | 0 .../lunatic/launcher/model/AppUsageLog.kt | 0 .../bums/lunatic/launcher/model/CiliMagnet.kt | 0 .../lunatic/launcher/model/CommunityData.kt | 0 .../lunatic/launcher/model/CurrentPlayItem.kt | 0 .../lunatic/launcher/model/LocationLog.kt | 0 .../bums/lunatic/launcher/model/NewsData.kt | 0 .../launcher/model/NotificationItem.kt | 0 .../bums/lunatic/launcher/model/QuoteItem.kt | 0 .../launcher/model/RssDataInterface.kt | 17 +- .../lunatic/launcher/model/SimpleContact.kt | 0 .../launcher/model/TelegramBotUpdate.kt | 0 .../lunatic/launcher/model/UserActionModel.kt | 0 .../lunatic/launcher/model/WallContent.kt | 0 .../lunatic/launcher/model/WeatherForcast.kt | 0 .../bums/lunatic/launcher/model/WidgetData.kt | 0 .../lunatic/launcher/model/others/Reddit.kt | 0 .../launcher/model/others/YoutubeData.kt | 0 .../launcher/workers/RecentCallGetter.kt | 1 - .../lunatic/launcher/workers/WorkersDb.kt | 3 +- settings.gradle.kts | 1 + 32 files changed, 336 insertions(+), 288 deletions(-) create mode 100644 app/src/main/kotlin/bums/lunatic/launcher/model/RssDataTypeUiExt.kt create mode 100644 core/core-database/build.gradle.kts create mode 100644 core/core-database/src/main/AndroidManifest.xml create mode 100644 core/core-database/src/main/kotlin/bums/lunatic/launcher/home/tokiz/TokizModels.kt rename {app => core/core-database}/src/main/kotlin/bums/lunatic/launcher/model/Adults.kt (100%) rename {app => core/core-database}/src/main/kotlin/bums/lunatic/launcher/model/AppInfo.kt (100%) rename {app => core/core-database}/src/main/kotlin/bums/lunatic/launcher/model/AppUsageLog.kt (100%) rename {app => core/core-database}/src/main/kotlin/bums/lunatic/launcher/model/CiliMagnet.kt (100%) rename {app => core/core-database}/src/main/kotlin/bums/lunatic/launcher/model/CommunityData.kt (100%) rename {app => core/core-database}/src/main/kotlin/bums/lunatic/launcher/model/CurrentPlayItem.kt (100%) rename {app => core/core-database}/src/main/kotlin/bums/lunatic/launcher/model/LocationLog.kt (100%) rename {app => core/core-database}/src/main/kotlin/bums/lunatic/launcher/model/NewsData.kt (100%) rename {app => core/core-database}/src/main/kotlin/bums/lunatic/launcher/model/NotificationItem.kt (100%) rename {app => core/core-database}/src/main/kotlin/bums/lunatic/launcher/model/QuoteItem.kt (100%) rename {app => core/core-database}/src/main/kotlin/bums/lunatic/launcher/model/RssDataInterface.kt (74%) rename {app => core/core-database}/src/main/kotlin/bums/lunatic/launcher/model/SimpleContact.kt (100%) rename {app => core/core-database}/src/main/kotlin/bums/lunatic/launcher/model/TelegramBotUpdate.kt (100%) rename {app => core/core-database}/src/main/kotlin/bums/lunatic/launcher/model/UserActionModel.kt (100%) rename {app => core/core-database}/src/main/kotlin/bums/lunatic/launcher/model/WallContent.kt (100%) rename {app => core/core-database}/src/main/kotlin/bums/lunatic/launcher/model/WeatherForcast.kt (100%) rename {app => core/core-database}/src/main/kotlin/bums/lunatic/launcher/model/WidgetData.kt (100%) rename {app => core/core-database}/src/main/kotlin/bums/lunatic/launcher/model/others/Reddit.kt (100%) rename {app => core/core-database}/src/main/kotlin/bums/lunatic/launcher/model/others/YoutubeData.kt (100%) rename {app => core/core-database}/src/main/kotlin/bums/lunatic/launcher/workers/RecentCallGetter.kt (99%) rename {app => core/core-database}/src/main/kotlin/bums/lunatic/launcher/workers/WorkersDb.kt (99%) diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index a60db39f..3729932d 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -11,7 +11,8 @@ | 모듈 | 역할 | 비고 | | :--- | :--- | :--- | | `:app` | 메인 Android 애플리케이션 (`bums.lunatic.launcher`) | `compileSdk 35`, `minSdk 26`, `arm64-v8a` 네이티브(C++/CMake) 포함 | -| `:core:core-common` | 공통 로거(`Blog`) 및 ML Kit 번역/언어감지 헬퍼(`MlKitTranslationHelper`) | `:app`, `:feature:*`에서 참조 | +| `:core:core-common` | 공통 로거(`Blog`), 유틸(`JamoUtils`, `DataUtils`), ML Kit 헬퍼(`MlKitTranslationHelper`) | `:app`, `:core:core-database`, `:feature:*`에서 참조 | +| `: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` 의존 | | `:gdrive` | Google Drive `appDataFolder` 기반 로그인 및 백업 모듈 | `:app`에서 `implementation(project(":gdrive"))`로 참조 | diff --git a/TODO.md b/TODO.md index 634bd75a..a83a9aa3 100644 --- a/TODO.md +++ b/TODO.md @@ -182,7 +182,7 @@ lunar_launcher/ ``` #### 단계별 모듈화 실행 순서 -- [x] **6-1. `:core:common`, `:core:network`, `:core:database` 분리** (`:core:core-common`, `:core:core-network` 생성 및 `NetworkClient`·`MlKitTranslationHelper` 이동 완료; `:core:database`는 후속 진행) +- [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`는 후속 진행) - [ ] **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 0736477a..fed6e78a 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -136,6 +136,7 @@ dependencies { "include" to listOf("*.aar", "*.jar"), ))) implementation(project(":core:core-common")) + implementation(project(":core:core-database")) implementation(project(":core:core-network")) implementation(project(":feature:feature-torrent")) implementation(project(":gdrive")) diff --git a/app/src/main/kotlin/bums/lunatic/launcher/LunaticLauncher.kt b/app/src/main/kotlin/bums/lunatic/launcher/LunaticLauncher.kt index 674178a3..159ebb21 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/LunaticLauncher.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/LunaticLauncher.kt @@ -116,6 +116,8 @@ prefs: appContext = this privateCompletedDir = File(getExternalFilesDir(null), "completed_torrents") PrefHelper.initialize(this) + bums.lunatic.launcher.model.RssDataType.enabledChecker = { key -> PrefHelper.getBoolean(key, false) } + bums.lunatic.launcher.workers.WorkersDb.schemaVersion = BuildConfig.BuildDateTime Base64ImageCache.init(this) val dir = try { val externalDir = File("/storage/emulated/0/bums_ob/BUM'S PACED /scraped/logs") diff --git a/app/src/main/kotlin/bums/lunatic/launcher/home/adapters/RssItemAdapter.kt b/app/src/main/kotlin/bums/lunatic/launcher/home/adapters/RssItemAdapter.kt index 96058557..f62dca68 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/home/adapters/RssItemAdapter.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/home/adapters/RssItemAdapter.kt @@ -33,6 +33,7 @@ import androidx.recyclerview.widget.RecyclerView import bums.lunatic.launcher.databinding.ListItemWithBinding import bums.lunatic.launcher.model.RssData import bums.lunatic.launcher.model.RssDataInterface +import bums.lunatic.launcher.model.getResId import bums.lunatic.launcher.utils.Blog import bums.lunatic.launcher.utils.SimpleFingerGestures import bums.lunatic.launcher.workers.WorkersDb diff --git a/app/src/main/kotlin/bums/lunatic/launcher/home/tokiz/HistoryManager.kt b/app/src/main/kotlin/bums/lunatic/launcher/home/tokiz/HistoryManager.kt index bc6d475e..056e3b3f 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/home/tokiz/HistoryManager.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/home/tokiz/HistoryManager.kt @@ -20,274 +20,6 @@ import java.text.SimpleDateFormat import java.util.Date import java.util.regex.Pattern -class LastInfo : RealmObject { - @PrimaryKey - var _id : String = "" - var pageUrl : String = "" - var title : String = "" - var chapter : Int = 0 - var pageIndex : Int = 0 - var contentsName : String = "" - var contentsType : String? = "" - set(value) { - _id = value ?: "" - field = value - } - var displayOrientation : Int = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT - - fun makeHistoryItem() : HistoryItem = HistoryItem().apply { - title = this@LastInfo.title - pageUrl = this@LastInfo.pageUrl - chapter = this@LastInfo.chapter - pageIndex = this@LastInfo.pageIndex - contentsName = this@LastInfo.contentsName - displayOrientation = this@LastInfo.displayOrientation - contentsType = this@LastInfo.contentsType - } -} -class HistoryItem : RealmObject { - @PrimaryKey - var title : String = "" - var pageUrl : String = "" - var chapter : Int = 0 - var pageIndex : Int = 0 - var contentsName : String = "" - var displayOrientation : Int = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT - var contentsType : String? = "" - - fun makeLastInfo() = LastInfo().apply{ - _id = "UniqLastId" - title = this@HistoryItem.title - pageUrl = this@HistoryItem.pageUrl - chapter = this@HistoryItem.chapter - pageIndex = this@HistoryItem.pageIndex - contentsName = this@HistoryItem.contentsName - displayOrientation = this@HistoryItem.displayOrientation - contentsType = this@HistoryItem.contentsType - } - fun putHistory(contentsPageInfo: ContentsPageInfo?, currentPath : String) : HistoryItem { - title = contentsPageInfo?.bookTitle ?: SimpleDateFormat("YY-mm-DD-HH:mm").format(Date()) - pageUrl = contentsPageInfo?.pathUrl ?: currentPath - chapter = contentsPageInfo?.chapterNum ?: 0 - pageIndex = contentsPageInfo?.lastPage ?: 0 - contentsName = contentsPageInfo?.chapterTitle ?: "" - contentsType = contentsPageInfo?.contentsType ?: "" - return this - } -} -class Bookmark() : RealmObject { - @PrimaryKey - var pageUrl : String = "" -} -class ReaderConfig : RealmObject { - @PrimaryKey - var id : String? = "ReaderConfig" - var textSize : Int? = 14 - var textColor : String? = "#FFFFFF" - var bgColor : String? = "#000000" - var style : Int? = 0 - var lineSpace : Int? = 1 - var letterSpace : Int? = 1 - var font : String? = "" - var padding : Int? = 5 -} -class PortMessage { - var type : String? = "" - var bookInfos : PageInfosJ? = null - var book : BookContents? = null - var msg : String? = null - var contents : String? = null - var privates : ArrayList? = null - var currentPage : String? = null - var cookies : String? = null - var urls : List = emptyList() - var imgSrc: String? = null - var base64Data: String? = null - var value : String? = null - var url : String? = null - var subTitles : List> = listOf() -} -class BookContents { - var chapterTitle : String? = null - var bookContents : String? = null -} - - -// PageInfoJ를 정렬하기 위한 Comparator 클래스 -class PageInfoComparator : Comparator { - - // 문자열에서 숫자 부분과 문자 부분을 분리하는 정규표현식 - private val pattern = Pattern.compile("(\\d+)|(\\D+)") - - override fun compare(p1: PageInfoJ?, p2: PageInfoJ?): Int { - // null 객체에 대한 안전장치 - if (p1 == null && p2 == null) return 0 - if (p1 == null) return -1 - if (p2 == null) return 1 - - // 비교할 문자열 추출 (여기서는 bookTitle을 기준으로 정렬) - // 만약 chapterTitle로 정렬하고 싶다면 이 부분을 수정하세요. - val s1 = p1.bookTitle ?: "" - val s2 = p2.bookTitle ?: "" - - val m1 = pattern.matcher(s1) - val m2 = pattern.matcher(s2) - - while (m1.find() && m2.find()) { - val part1 = m1.group() - val part2 = m2.group() - - // 각 부분이 숫자인지 확인 - val isPart1Numeric = part1.firstOrNull()?.isDigit() ?: false - val isPart2Numeric = part2.firstOrNull()?.isDigit() ?: false - - // 1. 둘 다 숫자인 경우: 숫자 값으로 비교 - if (isPart1Numeric && isPart2Numeric) { - val num1 = part1.toInt() - val num2 = part2.toInt() - if (num1 != num2) { - return num1.compareTo(num2) - } - } - // 2. 한쪽만 숫자인 경우: 숫자가 항상 앞으로 오도록 설정 - else if (isPart1Numeric) { - return -1 // s1(p1)이 숫자이므로 앞으로 - } else if (isPart2Numeric) { - return 1 // s2(p2)가 숫자이므로 s1(p1)이 뒤로 - } - // 3. 둘 다 문자인 경우: 사전 순으로 비교 - else { - val result = part1.compareTo(part2) - if (result != 0) { - return result - } - } - } - - // 모든 부분이 동일하면 전체 문자열 길이로 비교 (짧은 것이 앞으로) - return s1.compareTo(s2) - } -} - - -class PageInfosJ { - var bookTitle : String = "" - var bookPageUrl : String = "" - var contentsType : String? = "" - var pages : ArrayList = arrayListOf() - - fun sort() : PageInfosJ { - pages.sortWith(PageInfoComparator()) - return this - } - fun getTitleArray() : ArrayList { - var arrayList = ArrayList() - pages.forEach { arrayList.add(it.bookTitle ?: "") } - return arrayList - } - - fun getR() : ContentsCollection{ - var r = ContentsCollection() - r.bookTitle = this.bookTitle - r.bookPageUrl = this.bookPageUrl - r.contentsType = this.contentsType - return r - } -} -class PageInfoJ { - var chapterID : Int = 0 - var contents : String? = "" - var bookPageUrl : String? = "" - var chapterTitle : String? = "" - var bookTitle : String? = "" - var chapterNum : Int = 0 - var lastPage : Int? = 0 - var pathUrl : String? = "" - var contentsType : String? = "" - - fun getRealm() : ContentsPageInfo { - var r = ContentsPageInfo() - r.chapterID = this.chapterID - r.contents = this.contents - r.bookPageUrl = this.bookPageUrl ?: "" - r.chapterTitle = this.chapterTitle - r.bookTitle = this.bookTitle ?: "" - r.chapterNum = this.chapterNum - r.lastPage = this.lastPage - r.pathUrl = this.pathUrl?.replace("'","") - r.contentsType = this.contentsType - return r - } -} -class ContentsCollection : RealmObject { - - var bookTitle : String = "" - - @PrimaryKey - var bookPageUrl : String? = "" - var pages : RealmList = realmListOf() - var contentsType : String? = "" - - fun getTitleArray() : ArrayList { - var arrayList = ArrayList() - pages.forEach { - arrayList.add(it.getTitleItem())} - return arrayList - } - - fun sort() { - val comparator : Comparator = compareBy { it.chapterID } - pages.sortWith(comparator) - } - - fun hasItem(item: ContentsPageInfo) : Boolean { - var hasItem = false - for (c in pages) { - if (!hasItem) { - hasItem = c.pathUrl.equals(item.pathUrl) - } - } - return hasItem - } - - -} -class ContentsPageInfo : RealmObject { - - var chapterID : Int = 0 - var contents : String? = "" - - var bookPageUrl : String? = "" - var chapterTitle : String? = "" - var bookTitle : String? = "" - var chapterNum : Int = 0 - var lastPage : Int? = 0 - var contentsType : String? = "" - - fun isValidBook() = (pathUrl?.length ?: 0) > 1 - - @PrimaryKey - var pathUrl : String? = "" - - fun getTitleItem() : String { - var result = StringBuilder() - result.append(if ((contents?.length ?: 0) > 10) { - "S:[0] " - } else { - "[X] " - }) - - result.append(chapterTitle?: "") - - result.append(if ((lastPage ?: 0) > 0) { - " [0] " - } else { - " [X] " - }) - - return result.toString() - } -} object HistoryManager { diff --git a/app/src/main/kotlin/bums/lunatic/launcher/model/RssDataTypeUiExt.kt b/app/src/main/kotlin/bums/lunatic/launcher/model/RssDataTypeUiExt.kt new file mode 100644 index 00000000..2ceff4d4 --- /dev/null +++ b/app/src/main/kotlin/bums/lunatic/launcher/model/RssDataTypeUiExt.kt @@ -0,0 +1,13 @@ +package bums.lunatic.launcher.model + +import bums.lunatic.launcher.R + +fun RssDataType.getResId() = when (this) { + RssDataType.YOUTUBE -> R.drawable.youtube + RssDataType.REDDIT, RssDataType.REDDIT_NSFW -> R.drawable.reddit + RssDataType.DOTAX -> R.drawable.daum + RssDataType.FMKORAE -> R.drawable.fmk + RssDataType.DCINSIDE -> R.drawable.dcinside + RssDataType.ARCA -> R.drawable.arca + else -> R.drawable.ic_news +} diff --git a/core/core-database/build.gradle.kts b/core/core-database/build.gradle.kts new file mode 100644 index 00000000..746fe98e --- /dev/null +++ b/core/core-database/build.gradle.kts @@ -0,0 +1,30 @@ +plugins { + id("com.android.library") + id("kotlin-android") + id("io.realm.kotlin") +} + +android { + namespace = "bums.lunatic.launcher.core.database" + 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")) + api("io.realm.kotlin:library-base:2.0.0") + implementation("org.jsoup:jsoup:1.21.2") + implementation("com.google.code.gson:gson:2.13.1") +} diff --git a/core/core-database/src/main/AndroidManifest.xml b/core/core-database/src/main/AndroidManifest.xml new file mode 100644 index 00000000..8072ee00 --- /dev/null +++ b/core/core-database/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ + + diff --git a/core/core-database/src/main/kotlin/bums/lunatic/launcher/home/tokiz/TokizModels.kt b/core/core-database/src/main/kotlin/bums/lunatic/launcher/home/tokiz/TokizModels.kt new file mode 100644 index 00000000..7cae76ab --- /dev/null +++ b/core/core-database/src/main/kotlin/bums/lunatic/launcher/home/tokiz/TokizModels.kt @@ -0,0 +1,280 @@ +package bums.lunatic.launcher.home.tokiz + +import android.content.pm.ActivityInfo +import bums.lunatic.launcher.model.RssData +import io.realm.kotlin.ext.realmListOf +import io.realm.kotlin.types.RealmList +import io.realm.kotlin.types.RealmObject +import io.realm.kotlin.types.annotations.PrimaryKey +import java.text.SimpleDateFormat +import java.util.Date +import java.util.regex.Pattern + +class LastInfo : RealmObject { + @PrimaryKey + var _id : String = "" + var pageUrl : String = "" + var title : String = "" + var chapter : Int = 0 + var pageIndex : Int = 0 + var contentsName : String = "" + var contentsType : String? = "" + set(value) { + _id = value ?: "" + field = value + } + var displayOrientation : Int = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT + + fun makeHistoryItem() : HistoryItem = HistoryItem().apply { + title = this@LastInfo.title + pageUrl = this@LastInfo.pageUrl + chapter = this@LastInfo.chapter + pageIndex = this@LastInfo.pageIndex + contentsName = this@LastInfo.contentsName + displayOrientation = this@LastInfo.displayOrientation + contentsType = this@LastInfo.contentsType + } +} +class HistoryItem : RealmObject { + @PrimaryKey + var title : String = "" + var pageUrl : String = "" + var chapter : Int = 0 + var pageIndex : Int = 0 + var contentsName : String = "" + var displayOrientation : Int = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT + var contentsType : String? = "" + + fun makeLastInfo() = LastInfo().apply{ + _id = "UniqLastId" + title = this@HistoryItem.title + pageUrl = this@HistoryItem.pageUrl + chapter = this@HistoryItem.chapter + pageIndex = this@HistoryItem.pageIndex + contentsName = this@HistoryItem.contentsName + displayOrientation = this@HistoryItem.displayOrientation + contentsType = this@HistoryItem.contentsType + } + fun putHistory(contentsPageInfo: ContentsPageInfo?, currentPath : String) : HistoryItem { + title = contentsPageInfo?.bookTitle ?: SimpleDateFormat("YY-mm-DD-HH:mm").format(Date()) + pageUrl = contentsPageInfo?.pathUrl ?: currentPath + chapter = contentsPageInfo?.chapterNum ?: 0 + pageIndex = contentsPageInfo?.lastPage ?: 0 + contentsName = contentsPageInfo?.chapterTitle ?: "" + contentsType = contentsPageInfo?.contentsType ?: "" + return this + } +} +class Bookmark() : RealmObject { + @PrimaryKey + var pageUrl : String = "" +} +class ReaderConfig : RealmObject { + @PrimaryKey + var id : String? = "ReaderConfig" + var textSize : Int? = 14 + var textColor : String? = "#FFFFFF" + var bgColor : String? = "#000000" + var style : Int? = 0 + var lineSpace : Int? = 1 + var letterSpace : Int? = 1 + var font : String? = "" + var padding : Int? = 5 +} +class PortMessage { + var type : String? = "" + var bookInfos : PageInfosJ? = null + var book : BookContents? = null + var msg : String? = null + var contents : String? = null + var privates : ArrayList? = null + var currentPage : String? = null + var cookies : String? = null + var urls : List = emptyList() + var imgSrc: String? = null + var base64Data: String? = null + var value : String? = null + var url : String? = null + var subTitles : List> = listOf() +} +class BookContents { + var chapterTitle : String? = null + var bookContents : String? = null +} + + +// PageInfoJ를 정렬하기 위한 Comparator 클래스 +class PageInfoComparator : Comparator { + + // 문자열에서 숫자 부분과 문자 부분을 분리하는 정규표현식 + private val pattern = Pattern.compile("(\\d+)|(\\D+)") + + override fun compare(p1: PageInfoJ?, p2: PageInfoJ?): Int { + // null 객체에 대한 안전장치 + if (p1 == null && p2 == null) return 0 + if (p1 == null) return -1 + if (p2 == null) return 1 + + // 비교할 문자열 추출 (여기서는 bookTitle을 기준으로 정렬) + // 만약 chapterTitle로 정렬하고 싶다면 이 부분을 수정하세요. + val s1 = p1.bookTitle ?: "" + val s2 = p2.bookTitle ?: "" + + val m1 = pattern.matcher(s1) + val m2 = pattern.matcher(s2) + + while (m1.find() && m2.find()) { + val part1 = m1.group() + val part2 = m2.group() + + // 각 부분이 숫자인지 확인 + val isPart1Numeric = part1.firstOrNull()?.isDigit() ?: false + val isPart2Numeric = part2.firstOrNull()?.isDigit() ?: false + + // 1. 둘 다 숫자인 경우: 숫자 값으로 비교 + if (isPart1Numeric && isPart2Numeric) { + val num1 = part1.toInt() + val num2 = part2.toInt() + if (num1 != num2) { + return num1.compareTo(num2) + } + } + // 2. 한쪽만 숫자인 경우: 숫자가 항상 앞으로 오도록 설정 + else if (isPart1Numeric) { + return -1 // s1(p1)이 숫자이므로 앞으로 + } else if (isPart2Numeric) { + return 1 // s2(p2)가 숫자이므로 s1(p1)이 뒤로 + } + // 3. 둘 다 문자인 경우: 사전 순으로 비교 + else { + val result = part1.compareTo(part2) + if (result != 0) { + return result + } + } + } + + // 모든 부분이 동일하면 전체 문자열 길이로 비교 (짧은 것이 앞으로) + return s1.compareTo(s2) + } +} + + +class PageInfosJ { + var bookTitle : String = "" + var bookPageUrl : String = "" + var contentsType : String? = "" + var pages : ArrayList = arrayListOf() + + fun sort() : PageInfosJ { + pages.sortWith(PageInfoComparator()) + return this + } + fun getTitleArray() : ArrayList { + var arrayList = ArrayList() + pages.forEach { arrayList.add(it.bookTitle ?: "") } + return arrayList + } + + fun getR() : ContentsCollection{ + var r = ContentsCollection() + r.bookTitle = this.bookTitle + r.bookPageUrl = this.bookPageUrl + r.contentsType = this.contentsType + return r + } +} +class PageInfoJ { + var chapterID : Int = 0 + var contents : String? = "" + var bookPageUrl : String? = "" + var chapterTitle : String? = "" + var bookTitle : String? = "" + var chapterNum : Int = 0 + var lastPage : Int? = 0 + var pathUrl : String? = "" + var contentsType : String? = "" + + fun getRealm() : ContentsPageInfo { + var r = ContentsPageInfo() + r.chapterID = this.chapterID + r.contents = this.contents + r.bookPageUrl = this.bookPageUrl ?: "" + r.chapterTitle = this.chapterTitle + r.bookTitle = this.bookTitle ?: "" + r.chapterNum = this.chapterNum + r.lastPage = this.lastPage + r.pathUrl = this.pathUrl?.replace("'","") + r.contentsType = this.contentsType + return r + } +} +class ContentsCollection : RealmObject { + + var bookTitle : String = "" + + @PrimaryKey + var bookPageUrl : String? = "" + var pages : RealmList = realmListOf() + var contentsType : String? = "" + + fun getTitleArray() : ArrayList { + var arrayList = ArrayList() + pages.forEach { + arrayList.add(it.getTitleItem())} + return arrayList + } + + fun sort() { + val comparator : Comparator = compareBy { it.chapterID } + pages.sortWith(comparator) + } + + fun hasItem(item: ContentsPageInfo) : Boolean { + var hasItem = false + for (c in pages) { + if (!hasItem) { + hasItem = c.pathUrl.equals(item.pathUrl) + } + } + return hasItem + } + + +} +class ContentsPageInfo : RealmObject { + + var chapterID : Int = 0 + var contents : String? = "" + + var bookPageUrl : String? = "" + var chapterTitle : String? = "" + var bookTitle : String? = "" + var chapterNum : Int = 0 + var lastPage : Int? = 0 + var contentsType : String? = "" + + fun isValidBook() = (pathUrl?.length ?: 0) > 1 + + @PrimaryKey + var pathUrl : String? = "" + + fun getTitleItem() : String { + var result = StringBuilder() + result.append(if ((contents?.length ?: 0) > 10) { + "S:[0] " + } else { + "[X] " + }) + + result.append(chapterTitle?: "") + + result.append(if ((lastPage ?: 0) > 0) { + " [0] " + } else { + " [X] " + }) + + return result.toString() + } +} diff --git a/app/src/main/kotlin/bums/lunatic/launcher/model/Adults.kt b/core/core-database/src/main/kotlin/bums/lunatic/launcher/model/Adults.kt similarity index 100% rename from app/src/main/kotlin/bums/lunatic/launcher/model/Adults.kt rename to core/core-database/src/main/kotlin/bums/lunatic/launcher/model/Adults.kt diff --git a/app/src/main/kotlin/bums/lunatic/launcher/model/AppInfo.kt b/core/core-database/src/main/kotlin/bums/lunatic/launcher/model/AppInfo.kt similarity index 100% rename from app/src/main/kotlin/bums/lunatic/launcher/model/AppInfo.kt rename to core/core-database/src/main/kotlin/bums/lunatic/launcher/model/AppInfo.kt diff --git a/app/src/main/kotlin/bums/lunatic/launcher/model/AppUsageLog.kt b/core/core-database/src/main/kotlin/bums/lunatic/launcher/model/AppUsageLog.kt similarity index 100% rename from app/src/main/kotlin/bums/lunatic/launcher/model/AppUsageLog.kt rename to core/core-database/src/main/kotlin/bums/lunatic/launcher/model/AppUsageLog.kt diff --git a/app/src/main/kotlin/bums/lunatic/launcher/model/CiliMagnet.kt b/core/core-database/src/main/kotlin/bums/lunatic/launcher/model/CiliMagnet.kt similarity index 100% rename from app/src/main/kotlin/bums/lunatic/launcher/model/CiliMagnet.kt rename to core/core-database/src/main/kotlin/bums/lunatic/launcher/model/CiliMagnet.kt diff --git a/app/src/main/kotlin/bums/lunatic/launcher/model/CommunityData.kt b/core/core-database/src/main/kotlin/bums/lunatic/launcher/model/CommunityData.kt similarity index 100% rename from app/src/main/kotlin/bums/lunatic/launcher/model/CommunityData.kt rename to core/core-database/src/main/kotlin/bums/lunatic/launcher/model/CommunityData.kt diff --git a/app/src/main/kotlin/bums/lunatic/launcher/model/CurrentPlayItem.kt b/core/core-database/src/main/kotlin/bums/lunatic/launcher/model/CurrentPlayItem.kt similarity index 100% rename from app/src/main/kotlin/bums/lunatic/launcher/model/CurrentPlayItem.kt rename to core/core-database/src/main/kotlin/bums/lunatic/launcher/model/CurrentPlayItem.kt diff --git a/app/src/main/kotlin/bums/lunatic/launcher/model/LocationLog.kt b/core/core-database/src/main/kotlin/bums/lunatic/launcher/model/LocationLog.kt similarity index 100% rename from app/src/main/kotlin/bums/lunatic/launcher/model/LocationLog.kt rename to core/core-database/src/main/kotlin/bums/lunatic/launcher/model/LocationLog.kt diff --git a/app/src/main/kotlin/bums/lunatic/launcher/model/NewsData.kt b/core/core-database/src/main/kotlin/bums/lunatic/launcher/model/NewsData.kt similarity index 100% rename from app/src/main/kotlin/bums/lunatic/launcher/model/NewsData.kt rename to core/core-database/src/main/kotlin/bums/lunatic/launcher/model/NewsData.kt diff --git a/app/src/main/kotlin/bums/lunatic/launcher/model/NotificationItem.kt b/core/core-database/src/main/kotlin/bums/lunatic/launcher/model/NotificationItem.kt similarity index 100% rename from app/src/main/kotlin/bums/lunatic/launcher/model/NotificationItem.kt rename to core/core-database/src/main/kotlin/bums/lunatic/launcher/model/NotificationItem.kt diff --git a/app/src/main/kotlin/bums/lunatic/launcher/model/QuoteItem.kt b/core/core-database/src/main/kotlin/bums/lunatic/launcher/model/QuoteItem.kt similarity index 100% rename from app/src/main/kotlin/bums/lunatic/launcher/model/QuoteItem.kt rename to core/core-database/src/main/kotlin/bums/lunatic/launcher/model/QuoteItem.kt diff --git a/app/src/main/kotlin/bums/lunatic/launcher/model/RssDataInterface.kt b/core/core-database/src/main/kotlin/bums/lunatic/launcher/model/RssDataInterface.kt similarity index 74% rename from app/src/main/kotlin/bums/lunatic/launcher/model/RssDataInterface.kt rename to core/core-database/src/main/kotlin/bums/lunatic/launcher/model/RssDataInterface.kt index 2804ad4e..1a077933 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/model/RssDataInterface.kt +++ b/core/core-database/src/main/kotlin/bums/lunatic/launcher/model/RssDataInterface.kt @@ -1,8 +1,6 @@ package bums.lunatic.launcher.model import android.view.View -import bums.lunatic.launcher.R -import bums.lunatic.launcher.helpers.PrefHelper enum class RssDataType { NO_DATA, @@ -26,18 +24,6 @@ enum class RssDataType { NAMU, ARCA; - fun getResId() = when (this) { - YOUTUBE -> R.drawable.youtube - REDDIT, REDDIT_NSFW -> R.drawable.reddit - DOTAX -> R.drawable.daum - FMKORAE -> R.drawable.fmk - DCINSIDE -> R.drawable.dcinside - ARCA -> R.drawable.arca - else -> { - R.drawable.ic_news - } - } - fun defaultImgSize() = when (this) { YOUTUBE -> 200 REDDIT_NSFW,PRIVATE -> 240 @@ -51,12 +37,13 @@ enum class RssDataType { } fun isOn(block : ()->Unit) { - if(PrefHelper.getBoolean(name,false)) { + if (enabledChecker?.invoke(name) == true) { block.invoke() } } companion object { + var enabledChecker: ((String) -> Boolean)? = null fun getExcAdt() = arrayListOf(NEWSFEED, REDDIT, DOTAX, FMKORAE, DCINSIDE, RULIWEB, CLIEN, THEQOO).map { it.name } fun getAdts() = arrayListOf( REDDIT_NSFW).map { it.name } fun getAll() = arrayListOf(YOUTUBE, NEWSFEED, REDDIT, DOTAX, FMKORAE, DCINSIDE, RULIWEB, CLIEN, THEQOO, PRIVATE,REDDIT_NSFW) diff --git a/app/src/main/kotlin/bums/lunatic/launcher/model/SimpleContact.kt b/core/core-database/src/main/kotlin/bums/lunatic/launcher/model/SimpleContact.kt similarity index 100% rename from app/src/main/kotlin/bums/lunatic/launcher/model/SimpleContact.kt rename to core/core-database/src/main/kotlin/bums/lunatic/launcher/model/SimpleContact.kt diff --git a/app/src/main/kotlin/bums/lunatic/launcher/model/TelegramBotUpdate.kt b/core/core-database/src/main/kotlin/bums/lunatic/launcher/model/TelegramBotUpdate.kt similarity index 100% rename from app/src/main/kotlin/bums/lunatic/launcher/model/TelegramBotUpdate.kt rename to core/core-database/src/main/kotlin/bums/lunatic/launcher/model/TelegramBotUpdate.kt diff --git a/app/src/main/kotlin/bums/lunatic/launcher/model/UserActionModel.kt b/core/core-database/src/main/kotlin/bums/lunatic/launcher/model/UserActionModel.kt similarity index 100% rename from app/src/main/kotlin/bums/lunatic/launcher/model/UserActionModel.kt rename to core/core-database/src/main/kotlin/bums/lunatic/launcher/model/UserActionModel.kt diff --git a/app/src/main/kotlin/bums/lunatic/launcher/model/WallContent.kt b/core/core-database/src/main/kotlin/bums/lunatic/launcher/model/WallContent.kt similarity index 100% rename from app/src/main/kotlin/bums/lunatic/launcher/model/WallContent.kt rename to core/core-database/src/main/kotlin/bums/lunatic/launcher/model/WallContent.kt diff --git a/app/src/main/kotlin/bums/lunatic/launcher/model/WeatherForcast.kt b/core/core-database/src/main/kotlin/bums/lunatic/launcher/model/WeatherForcast.kt similarity index 100% rename from app/src/main/kotlin/bums/lunatic/launcher/model/WeatherForcast.kt rename to core/core-database/src/main/kotlin/bums/lunatic/launcher/model/WeatherForcast.kt diff --git a/app/src/main/kotlin/bums/lunatic/launcher/model/WidgetData.kt b/core/core-database/src/main/kotlin/bums/lunatic/launcher/model/WidgetData.kt similarity index 100% rename from app/src/main/kotlin/bums/lunatic/launcher/model/WidgetData.kt rename to core/core-database/src/main/kotlin/bums/lunatic/launcher/model/WidgetData.kt diff --git a/app/src/main/kotlin/bums/lunatic/launcher/model/others/Reddit.kt b/core/core-database/src/main/kotlin/bums/lunatic/launcher/model/others/Reddit.kt similarity index 100% rename from app/src/main/kotlin/bums/lunatic/launcher/model/others/Reddit.kt rename to core/core-database/src/main/kotlin/bums/lunatic/launcher/model/others/Reddit.kt diff --git a/app/src/main/kotlin/bums/lunatic/launcher/model/others/YoutubeData.kt b/core/core-database/src/main/kotlin/bums/lunatic/launcher/model/others/YoutubeData.kt similarity index 100% rename from app/src/main/kotlin/bums/lunatic/launcher/model/others/YoutubeData.kt rename to core/core-database/src/main/kotlin/bums/lunatic/launcher/model/others/YoutubeData.kt diff --git a/app/src/main/kotlin/bums/lunatic/launcher/workers/RecentCallGetter.kt b/core/core-database/src/main/kotlin/bums/lunatic/launcher/workers/RecentCallGetter.kt similarity index 99% rename from app/src/main/kotlin/bums/lunatic/launcher/workers/RecentCallGetter.kt rename to core/core-database/src/main/kotlin/bums/lunatic/launcher/workers/RecentCallGetter.kt index 5bed964f..f3acbffc 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/workers/RecentCallGetter.kt +++ b/core/core-database/src/main/kotlin/bums/lunatic/launcher/workers/RecentCallGetter.kt @@ -3,7 +3,6 @@ package bums.lunatic.launcher.workers import android.annotation.SuppressLint import android.content.Context import android.provider.CallLog -import androidx.work.WorkerParameters import bums.lunatic.launcher.utils.beforeDay import bums.lunatic.launcher.utils.getContactId import com.google.gson.Gson diff --git a/app/src/main/kotlin/bums/lunatic/launcher/workers/WorkersDb.kt b/core/core-database/src/main/kotlin/bums/lunatic/launcher/workers/WorkersDb.kt similarity index 99% rename from app/src/main/kotlin/bums/lunatic/launcher/workers/WorkersDb.kt rename to core/core-database/src/main/kotlin/bums/lunatic/launcher/workers/WorkersDb.kt index 81ad9427..f5b8ebe8 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/workers/WorkersDb.kt +++ b/core/core-database/src/main/kotlin/bums/lunatic/launcher/workers/WorkersDb.kt @@ -2,7 +2,6 @@ package bums.lunatic.launcher.workers import android.app.usage.UsageStatsManager import android.content.Context -import bums.lunatic.launcher.BuildConfig import bums.lunatic.launcher.common.letTrue import bums.lunatic.launcher.model.AppInfo import bums.lunatic.launcher.model.AppUsageLog @@ -283,7 +282,7 @@ object WorkersDb { } } - val schemaVersion : Long = BuildConfig.BuildDateTime + var schemaVersion : Long = 202611160000L private var pRealm : Realm? = null fun getRealm() : Realm { diff --git a/settings.gradle.kts b/settings.gradle.kts index 16dfb377..dff28a15 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -24,6 +24,7 @@ dependencyResolutionManagement { rootProject.name = "LunarLauncher" include ("app") include(":core:core-common") +include(":core:core-database") include(":core:core-network") include(":feature:feature-torrent") include(":gdrive")