build: :core:core-utils 모듈 분리 및 유틸성 클래스 17종 이관
- core/core-utils 모듈 신규 생성 (namespace: bums.lunatic.launcher.core.utils): * AlphabetToChosungMap, APILevel, BitmapConverter, CategoryManualMapper, CommonUtils, CompressStringUtil, EnToKo, FileUtils, HashUtils, ImageUtils, JsoupUtils, KoreanTrans, MediaBitmapUtil, PlayCategory, PreferencesUtil, RssList, StringEscapeUtils 총 17종 이관 * (@GlideModule 어노테이션 프로세서 제약이 있는 CustomOkHttpGlideModule.kt만 :app에 유지) - settings.gradle.kts, app/build.gradle.kts, ARCHITECTURE.md 갱신 - 검증: ./gradlew :app:compileDebugKotlin 빌드 성공 확인 (11s, 133 actionable tasks)
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
plugins {
|
||||
id("com.android.library")
|
||||
id("kotlin-android")
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "bums.lunatic.launcher.core.utils"
|
||||
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-network"))
|
||||
implementation("androidx.appcompat:appcompat:1.7.1")
|
||||
implementation("androidx.core:core-ktx:1.15.0")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3")
|
||||
implementation("org.jsoup:jsoup:1.21.2")
|
||||
implementation("com.googlecode.juniversalchardet:juniversalchardet:1.0.3")
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest />
|
||||
@@ -0,0 +1,237 @@
|
||||
package bums.lunatic.launcher.utils
|
||||
|
||||
import android.os.Build
|
||||
|
||||
|
||||
/**
|
||||
* APILevel helps to check device API [Build.VERSION] conveniently.
|
||||
*
|
||||
* @author Marcos Trujillo, Leonardo Taehwan Kim
|
||||
*/
|
||||
object APILevel {
|
||||
/**
|
||||
* @param level minimum API level version that has to support the device
|
||||
* @return true when the caller API version is at least level
|
||||
*/
|
||||
fun require(level: Int): Boolean {
|
||||
return Build.VERSION.SDK_INT >= level
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true when the caller API version is at least Cupcake 3
|
||||
*/
|
||||
fun requireCupcake(): Boolean {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.CUPCAKE
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true when the caller API version is at least Donut 4
|
||||
*/
|
||||
fun requireDonut(): Boolean {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.DONUT
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true when the caller API version is at least Eclair 5
|
||||
*/
|
||||
fun requireEclair(): Boolean {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true when the caller API version is at least Froyo 8
|
||||
*/
|
||||
fun requireFroyo(): Boolean {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true when the caller API version is at least GingerBread 9
|
||||
*/
|
||||
fun requireGingerbread(): Boolean {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true when the caller API version is at least Honeycomb 11
|
||||
*/
|
||||
fun requireHoneycomb(): Boolean {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true when the caller API version is at least Honeycomb 3.2, 13
|
||||
*/
|
||||
fun requireHoneycombMR2(): Boolean {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true when the caller API version is at least ICS 14
|
||||
*/
|
||||
fun requireIceCreamSandwich(): Boolean {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true when the caller API version is at least JellyBean 16
|
||||
*/
|
||||
fun requireJellyBean(): Boolean {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true when the caller API version is at least JellyBean MR1 17
|
||||
*/
|
||||
fun requireJellyBeanMR1(): Boolean {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true when the caller API version is at least JellyBean MR2 18
|
||||
*/
|
||||
fun requireJellyBeanMR2(): Boolean {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true when the caller API version is at least Kitkat 19
|
||||
*/
|
||||
fun requireKitkat(): Boolean {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true when the caller API version is at least Lollipop 21
|
||||
*/
|
||||
fun requireLollipop(): Boolean {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true when the caller API version is at least Lollipop MR1 22
|
||||
*/
|
||||
fun requireLollipopMR1(): Boolean {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true when the caller API version is at least Marshmallow 23
|
||||
*/
|
||||
fun requireMarshmallow(): Boolean {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|
||||
}
|
||||
|
||||
/**
|
||||
* @param level API level version that specific method or variable has been deprecated
|
||||
* @return true when the caller API version is less than level
|
||||
*/
|
||||
fun deprecatedAt(level: Int): Boolean {
|
||||
return Build.VERSION.SDK_INT < level
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true when the caller API version is less than Cupcake 3
|
||||
*/
|
||||
fun deprecatedAtCupcake(): Boolean {
|
||||
return Build.VERSION.SDK_INT < Build.VERSION_CODES.CUPCAKE
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true when the caller API version is less than Donut 4
|
||||
*/
|
||||
fun deprecatedAtDonut(): Boolean {
|
||||
return Build.VERSION.SDK_INT < Build.VERSION_CODES.DONUT
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true when the caller API version is less than Eclair 5
|
||||
*/
|
||||
fun deprecatedAtEclair(): Boolean {
|
||||
return Build.VERSION.SDK_INT < Build.VERSION_CODES.ECLAIR
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true when the caller API version is less than Froyo 8
|
||||
*/
|
||||
fun deprecatedAtFroyo(): Boolean {
|
||||
return Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true when the caller API version is less than GingerBread 9
|
||||
*/
|
||||
fun deprecatedAtGingerbread(): Boolean {
|
||||
return Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true when the caller API version is less than Honeycomb 11
|
||||
*/
|
||||
fun deprecatedAtHoneycomb(): Boolean {
|
||||
return Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true when the caller API version is less than Honeycomb 3.2, 13
|
||||
*/
|
||||
fun deprecatedAtHoneycombMR2(): Boolean {
|
||||
return Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR2
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true when the caller API version is less than ICS 14
|
||||
*/
|
||||
fun deprecatedAtIceCreamSandwich(): Boolean {
|
||||
return Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true when the caller API version is less than JellyBean 16
|
||||
*/
|
||||
fun deprecatedAtJellyBean(): Boolean {
|
||||
return Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true when the caller API version is less than JellyBean MR1 17
|
||||
*/
|
||||
fun deprecatedAtJellyBeanMR1(): Boolean {
|
||||
return Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true when the caller API version is less than JellyBean MR2 18
|
||||
*/
|
||||
fun deprecatedAtJellyBeanMR2(): Boolean {
|
||||
return Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true when the caller API version is less than Kitkat 19
|
||||
*/
|
||||
fun deprecatedAtKitkat(): Boolean {
|
||||
return Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true when the caller API version is less than Lollipop 21
|
||||
*/
|
||||
fun deprecatedAtLollipop(): Boolean {
|
||||
return Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true when the caller API version is less than Lollipop MR1 22
|
||||
*/
|
||||
fun deprecatedAtLollipopMR1(): Boolean {
|
||||
return Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true when the caller API version is less than Marshmallow 23
|
||||
*/
|
||||
fun deprecatedAtMarshmallow(): Boolean {
|
||||
return Build.VERSION.SDK_INT < Build.VERSION_CODES.M
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package bums.lunatic.launcher.utils
|
||||
|
||||
object AlphabetToChosungMap {
|
||||
val map = hashMapOf<String,String>(
|
||||
Pair("a","o"),
|
||||
Pair("b","ㅂ"),
|
||||
Pair("c","ㅋㅅ"),
|
||||
Pair("d","ㄷ"),
|
||||
Pair("e","o"),
|
||||
Pair("f","ㅍ"),
|
||||
Pair("g","ㄱㅈ"),
|
||||
Pair("h","ㅎ"),
|
||||
Pair("i","o"),
|
||||
Pair("j","ㅈ"),
|
||||
Pair("k","ㅋ"),
|
||||
Pair("l","ㄹ"),
|
||||
Pair("m","ㅁ"),
|
||||
Pair("n","ㄴ"),
|
||||
Pair("o","o"),
|
||||
Pair("p","ㅍ"),
|
||||
Pair("q","ㅋ"),
|
||||
Pair("r","ㄹ"),
|
||||
Pair("s","ㅅ"),
|
||||
Pair("t","ㅌ"),
|
||||
Pair("u","o"),
|
||||
Pair("v","ㅂ"),
|
||||
Pair("w","o"),
|
||||
Pair("x","ㅋㅅㅈ"),
|
||||
Pair("y","이"),
|
||||
Pair("z","ㅈ"),
|
||||
Pair("10","ㅅㅌ"),
|
||||
Pair("0","ㅇㅈ"),
|
||||
Pair("9","ㄱㄴ"),
|
||||
Pair("8","ㅍㅇ"),
|
||||
Pair("7","ㅊㅅ"),
|
||||
Pair("6","ㅇㅅ"),
|
||||
Pair("5","ㅇㅍ"),
|
||||
Pair("4","ㅅㅍ"),
|
||||
Pair("3","ㅅㅆ"),
|
||||
Pair("2","ㅇㅌ"),
|
||||
Pair("1","ㅇ"),
|
||||
)
|
||||
|
||||
fun getCho(string : String) = string.split("").filter { it.length > 0 && map.containsKey(it.toLowerCase()) }.map { map.get(it) }.joinToString("")
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package bums.lunatic.launcher.utils
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
import android.util.Base64
|
||||
import java.io.ByteArrayOutputStream
|
||||
|
||||
|
||||
object BitmapConverter {
|
||||
/*
|
||||
* String형을 BitMap으로 변환시켜주는 함수
|
||||
* */
|
||||
fun StringToBitmap(encodedString: String?): Bitmap? {
|
||||
try {
|
||||
val encodeByte: ByteArray = Base64.decode(encodedString, Base64.DEFAULT)
|
||||
val bitmap = BitmapFactory.decodeByteArray(encodeByte, 0, encodeByte.size)
|
||||
return bitmap
|
||||
} catch (e: Exception) {
|
||||
e.message
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Bitmap을 String형으로 변환
|
||||
* */
|
||||
fun BitmapToString(bitmap: Bitmap?): String {
|
||||
if (bitmap == null) return ""
|
||||
val baos = ByteArrayOutputStream()
|
||||
bitmap?.compress(Bitmap.CompressFormat.PNG, 70, baos)
|
||||
val bytes = baos.toByteArray()
|
||||
val temp: String = Base64.encodeToString(bytes, Base64.DEFAULT)
|
||||
return temp
|
||||
}
|
||||
|
||||
/*
|
||||
* Bitmap을 byte배열로 변환
|
||||
* */
|
||||
fun BitmapToByteArray(bitmap: Bitmap): ByteArray {
|
||||
val baos = ByteArrayOutputStream()
|
||||
bitmap.compress(Bitmap.CompressFormat.JPEG, 70, baos)
|
||||
return baos.toByteArray()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
package bums.lunatic.launcher.utils
|
||||
|
||||
import android.content.pm.ApplicationInfo
|
||||
import java.util.Locale
|
||||
|
||||
/**
|
||||
* 로그 분석 및 키워드 기반 카테고리 자동 분류 유틸리티
|
||||
*/
|
||||
object CategoryManualMapper {
|
||||
val CATEGORY_MAP = mapOf(
|
||||
"전체" to "ALL",
|
||||
"게임" to "GAME",
|
||||
"생산성" to "PRODUCTIVITY",
|
||||
"소셜" to "SOCIAL",
|
||||
"오디오" to "MUSIC",
|
||||
"쇼핑" to "SHOPPING",
|
||||
"금융" to "FINANCE",
|
||||
"비디오" to "VIDEO",
|
||||
"이미지" to "IMAGE",
|
||||
"지도" to "MAPS",
|
||||
"뉴스" to "NEWS",
|
||||
"도구" to "TOOLS",
|
||||
"기타" to "UNDEFINED"
|
||||
)
|
||||
|
||||
// 1. 고정 패키지명 매핑 (가장 높은 우선순위)
|
||||
private val manualMapping = mapOf(
|
||||
"com.sec.android.app.myfiles" to "TOOLS", // 삼성 내 파일
|
||||
"com.google.android.apps.nbu.files" to "TOOLS", // 구글 Files
|
||||
// VIDEO 카테고리
|
||||
"com.netflix.mediaclient" to "VIDEO",
|
||||
"net.cj.cjhv.gs.tving" to "VIDEO",
|
||||
"com.google.android.youtube" to "VIDEO",
|
||||
"com.disney.disneyplus" to "VIDEO",
|
||||
"com.coupang.mobile.play" to "VIDEO",
|
||||
"kr.co.captv.pooqV2" to "VIDEO", // wavve
|
||||
"com.synology.dsvideo" to "VIDEO",
|
||||
"org.videolan.vlc" to "VIDEO",
|
||||
"com.mxtech.videoplayer.ad" to "VIDEO",
|
||||
"com.gretech.gomplayerko" to "VIDEO",
|
||||
"com.google.android.videos" to "VIDEO", // Google TV
|
||||
|
||||
// MAPS / TRAVEL 카테고리
|
||||
"com.nhn.android.nmap" to "MAPS",
|
||||
"net.daum.android.map" to "MAPS",
|
||||
"com.google.android.apps.maps" to "MAPS",
|
||||
"com.skt.tmap.ku" to "MAPS",
|
||||
"com.locnall.KimGiSa" to "MAPS", // 카카오내비
|
||||
"com.agoda.mobile.consumer" to "MAPS",
|
||||
"com.airbnb.android" to "MAPS",
|
||||
"com.mrt.ducati" to "MAPS", // 마이리얼트립
|
||||
|
||||
// FINANCE 카테고리
|
||||
"viva.republica.toss" to "FINANCE",
|
||||
"com.kakaobank.channel" to "FINANCE",
|
||||
"com.btckorea.bithumb" to "FINANCE",
|
||||
"com.dunamu.exchange" to "FINANCE", // 업비트
|
||||
"com.truefriend.ministock" to "FINANCE",
|
||||
"com.truefriend.neosmartarenewal" to "FINANCE",
|
||||
"com.hyundaicard.appcard" to "FINANCE",
|
||||
"kr.co.samsungcard.mpocket" to "FINANCE",
|
||||
"com.kbcard.cxh.appcard" to "FINANCE",
|
||||
"com.kbstar.kbbank" to "FINANCE",
|
||||
"nh.smart.banking" to "FINANCE",
|
||||
"com.kbankwith.smartbank" to "FINANCE",
|
||||
|
||||
// SHOPPING 카테고리
|
||||
"com.coupang.mobile" to "SHOPPING",
|
||||
"com.coupang.mobile.eats" to "SHOPPING",
|
||||
"com.ebay.kr.gmarket" to "SHOPPING",
|
||||
"com.ebay.kr.auction" to "SHOPPING",
|
||||
"com.elevenst" to "SHOPPING",
|
||||
"net.giosis.shopping.sg" to "SHOPPING", // Qoo10
|
||||
"com.alibaba.aliexpresshd" to "SHOPPING",
|
||||
"com.einnovation.temu" to "SHOPPING",
|
||||
|
||||
// GAME 카테고리
|
||||
"com.sundaytoz.mobile.anisachun.google.service" to "GAME",
|
||||
"com.gof.global" to "GAME", // 화이트아웃서바이벌
|
||||
"com.tap4fun.odin.kingdomguard" to "GAME",
|
||||
"com.dreamgames.royalmatch" to "GAME",
|
||||
"com.ragequitgames.tomorrow" to "GAME"
|
||||
)
|
||||
|
||||
// 2. 키워드 기반 카테고리 매핑 (두 번째 우선순위)
|
||||
private val keywordMapping = mapOf(
|
||||
"VIDEO" to listOf(
|
||||
"video", "player", "movie", "tv", "cinema", "streaming", "media", "netflix",
|
||||
"비디오", "플레이어", "영화", "티브이", "시네마", "스트리밍", "넷플릭스", "티빙", "유튜브"
|
||||
),
|
||||
"GAME" to listOf(
|
||||
"game", "vulkan", "unity", "unreal", "nexon", "netmarble", "lineage",
|
||||
"게임", "넥슨", "넷마블", "카카오게임", "애니팡", "전투", "전략", "퍼즐", "RPG"
|
||||
),
|
||||
"FINANCE" to listOf(
|
||||
"bank", "card", "finance", "pay", "stock", "invest", "kb", "shinhan", "woori", "hana",
|
||||
"은행", "카드", "금융", "페이", "증권", "주식", "투자", "뱅크", "뱅킹", "보험", "자산"
|
||||
),
|
||||
"MUSIC" to listOf(
|
||||
"music", "audio", "sound", "radio", "melody", "streaming", "melon", "bugs",
|
||||
"뮤직", "음악", "오디오", "사운드", "라디오", "멜로디", "멜론", "벅스", "지니"
|
||||
),
|
||||
"MAPS" to listOf(
|
||||
"map", "navi", "taxi", "transport", "bus", "subway", "metro", "navigation",
|
||||
"지도", "내비", "택시", "교통", "버스", "지하철", "네비", "길찾기"
|
||||
),
|
||||
"IMAGE" to listOf(
|
||||
"photo", "gallery", "image", "camera", "editor", "snap", "pic",
|
||||
"사진", "갤러리", "이미지", "카메라", "편집", "스냅", "뷰어"
|
||||
),
|
||||
"SOCIAL" to listOf(
|
||||
"talk", "messenger", "chat", "social", "sns", "community", "kakao", "telegram",
|
||||
"톡", "메신저", "채팅", "소셜", "커뮤니티", "카카오", "텔레그램", "밴드", "카페"
|
||||
),
|
||||
"SHOPPING" to listOf(
|
||||
"shop", "mall", "market", "delivery", "eats", "order", "commerce", "coupang",
|
||||
"쇼핑", "몰", "마켓", "배달", "이츠", "주문", "커머스", "쿠팡", "마트", "백화점"
|
||||
),
|
||||
"TOOLS" to listOf(
|
||||
"file", "manager", "explorer", "cleaner", "storage", "calculator", "clock", "calendar",
|
||||
"파일", "관리자", "탐색기", "클리너", "저장소", "계산기", "시계", "달력", "메모"
|
||||
),
|
||||
)
|
||||
|
||||
/**
|
||||
* 패키지명, 앱 이름, 시스템 카테고리를 종합하여 최적의 카테고리를 반환합니다.
|
||||
*/
|
||||
fun getFixedCategory(packageName: String?, appName: String?, systemCategory: Int): String {
|
||||
// ---------------------------------------------------------
|
||||
// [단계 1] 이전의 수동 맵(manualMapping) 확인
|
||||
// ---------------------------------------------------------
|
||||
manualMapping[packageName]?.let { return it }
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// [단계 2] 시스템 분류(systemCategory)가 명확한지 확인
|
||||
// ---------------------------------------------------------
|
||||
val systemType = when (systemCategory) {
|
||||
ApplicationInfo.CATEGORY_GAME -> "GAME"
|
||||
ApplicationInfo.CATEGORY_VIDEO -> "VIDEO"
|
||||
ApplicationInfo.CATEGORY_MAPS -> "MAPS"
|
||||
ApplicationInfo.CATEGORY_AUDIO -> "MUSIC"
|
||||
ApplicationInfo.CATEGORY_PRODUCTIVITY -> "PRODUCTIVITY"
|
||||
ApplicationInfo.CATEGORY_SOCIAL -> "SOCIAL"
|
||||
ApplicationInfo.CATEGORY_NEWS -> "NEWS"
|
||||
ApplicationInfo.CATEGORY_IMAGE -> "IMAGE"
|
||||
else -> null
|
||||
}
|
||||
if (systemType != null) return systemType
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// [단계 3] 시스템 분류가 없는 경우 키워드 매핑 수행
|
||||
// ---------------------------------------------------------
|
||||
val pkg = packageName?.lowercase(Locale.ROOT) ?: ""
|
||||
val name = appName?.lowercase(Locale.ROOT)?.replace(" ", "") ?: ""
|
||||
|
||||
for ((category, keywords) in keywordMapping) {
|
||||
for (keyword in keywords) {
|
||||
if (pkg.contains(keyword) || name.contains(keyword)) {
|
||||
return category
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "UNDEFINED"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
package bums.lunatic.launcher.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.webkit.MimeTypeMap
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.net.URLConnection
|
||||
import java.util.regex.Pattern
|
||||
|
||||
object CommonUtils {
|
||||
fun dpToPx(context: Context, dp: Float): Int {
|
||||
val scale: Float = context.getResources().getDisplayMetrics().density
|
||||
return Math.round(dp * scale)
|
||||
}
|
||||
|
||||
fun hasJellyBean(): Boolean {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN
|
||||
}
|
||||
|
||||
fun hasLollipop(): Boolean {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
|
||||
}
|
||||
|
||||
|
||||
|
||||
fun getFileTypeBySignature(file: File): String? {
|
||||
val buffer = ByteArray(12)
|
||||
val readBytes = file.inputStream().use { it.read(buffer, 0, buffer.size) }
|
||||
|
||||
// 1. 시그니처 검사 (기존 방식)
|
||||
if (readBytes >= 6) {
|
||||
val gifSignature1 = "GIF87a".toByteArray(Charsets.US_ASCII)
|
||||
val gifSignature2 = "GIF89a".toByteArray(Charsets.US_ASCII)
|
||||
if (buffer.copyOfRange(0, 6).contentEquals(gifSignature1)
|
||||
|| buffer.copyOfRange(0, 6).contentEquals(gifSignature2)
|
||||
) {
|
||||
return "gif"
|
||||
}
|
||||
}
|
||||
|
||||
if (readBytes >= 3 &&
|
||||
buffer[0] == 0xFF.toByte() && buffer[1] == 0xD8.toByte() && buffer[2] == 0xFF.toByte()
|
||||
) {
|
||||
return "jpg"
|
||||
}
|
||||
|
||||
if (readBytes >= 8 &&
|
||||
buffer.copyOfRange(0, 8).contentEquals(
|
||||
byteArrayOf(
|
||||
0x89.toByte(), 'P'.toByte(), 'N'.toByte(), 'G'.toByte(),
|
||||
0x0D, 0x0A, 0x1A, 0x0A
|
||||
)
|
||||
)
|
||||
) {
|
||||
return "png"
|
||||
}
|
||||
|
||||
if (readBytes >= 12 &&
|
||||
buffer.copyOfRange(4, 8).contentEquals("ftyp".toByteArray(Charsets.US_ASCII))
|
||||
) {
|
||||
return "mp4"
|
||||
}
|
||||
|
||||
if (readBytes >= 12 &&
|
||||
buffer.copyOfRange(0, 4).contentEquals("RIFF".toByteArray(Charsets.US_ASCII)) &&
|
||||
buffer.copyOfRange(8, 12).contentEquals("AVI ".toByteArray(Charsets.US_ASCII))
|
||||
) {
|
||||
return "avi"
|
||||
}
|
||||
|
||||
if (readBytes >= 4 &&
|
||||
buffer[0] == 0x1A.toByte() &&
|
||||
buffer[1] == 0x45.toByte() &&
|
||||
buffer[2] == 0xDF.toByte() &&
|
||||
buffer[3] == 0xA3.toByte()
|
||||
) {
|
||||
return "mkv"
|
||||
}
|
||||
|
||||
// 2. MIME 타입 검사 (Optional, 정확도 향상)
|
||||
val mimeType = URLConnection.guessContentTypeFromStream(file.inputStream())
|
||||
if (mimeType != null) {
|
||||
when {
|
||||
mimeType.equals("image/gif", ignoreCase = true) -> return "gif"
|
||||
mimeType.equals("image/jpeg", ignoreCase = true) -> return "jpg"
|
||||
mimeType.equals("image/png", ignoreCase = true) -> return "png"
|
||||
mimeType.startsWith("video/mp4", ignoreCase = true) -> return "mp4"
|
||||
mimeType.startsWith("video/x-msvideo", ignoreCase = true) -> return "avi"
|
||||
mimeType.startsWith("video/x-matroska", ignoreCase = true) -> return "mkv"
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 정규식 기반 시그니처 검사 (GIF 전용 예)
|
||||
if (readBytes >= 6) {
|
||||
val sigStr = String(buffer, 0, 6, Charsets.US_ASCII)
|
||||
val gifPattern = Pattern.compile("GIF8[79]a")
|
||||
if (gifPattern.matcher(sigStr).matches()) {
|
||||
return "gif"
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
fun downloadFileWithOkHttp(context: Context,refferer : Uri, fileUrl: String) {
|
||||
android.app.AlertDialog.Builder(context)
|
||||
.setTitle("파일 다운로드")
|
||||
.setMessage("해당 파일을 다운로드하시겠습니까?")
|
||||
.setPositiveButton("확인") { _, _ ->
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
val client = OkHttpClient()
|
||||
val request = Request.Builder().url(fileUrl).addHeader("Referer", refferer.toString())
|
||||
.addHeader("User-Agent", "Mozilla/5.0").build()
|
||||
|
||||
val dir = File(context.getExternalFilesDir(null), "completed_torrents")
|
||||
if (!dir.exists()) {
|
||||
dir.mkdirs()
|
||||
} else {
|
||||
// dir.listFiles().forEach { Blog.LOGE("child -> ${it.absolutePath}") }
|
||||
}
|
||||
client.newCall(request).execute().use { response ->
|
||||
if (!response.isSuccessful) {
|
||||
withContext(Dispatchers.Main) {
|
||||
android.widget.Toast.makeText(
|
||||
context,
|
||||
"다운로드 실패!\n${fileUrl}\n${response.message}",
|
||||
android.widget.Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
} else {
|
||||
// Content-Type에서 확장자 추출
|
||||
val contentType = response.header("Content-Type")
|
||||
Blog.LOGE("downloadFileWithOkHttp contentType $contentType")
|
||||
var extension = contentType?.let {
|
||||
MimeTypeMap.getSingleton().getExtensionFromMimeType(it)
|
||||
}
|
||||
// 확장자 없으면 URL에서 추출하거나 기본값 "dat" 사용
|
||||
if (extension.isNullOrBlank()) {
|
||||
extension = MimeTypeMap.getFileExtensionFromUrl(fileUrl)
|
||||
if (extension.isNullOrBlank()) {
|
||||
extension = "dat"
|
||||
}
|
||||
}
|
||||
Blog.LOGE("downloadFileWithOkHttp extension $extension")
|
||||
val fileName =
|
||||
"${
|
||||
refferer.host?.replace(
|
||||
",",
|
||||
"_"
|
||||
)
|
||||
}_${System.currentTimeMillis()}.$extension"
|
||||
val file = File(dir, fileName)
|
||||
|
||||
response.body?.byteStream()?.use { input ->
|
||||
FileOutputStream(file).use { output ->
|
||||
input.copyTo(output)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
val resultFile = if (extension in listOf("bin", "dat")) {
|
||||
val realExt = getFileTypeBySignature(file)
|
||||
Blog.LOGE("downloadFileWithOkHttp extension $realExt")
|
||||
when {
|
||||
realExt.isNullOrBlank() -> file
|
||||
realExt == extension -> file
|
||||
else -> {
|
||||
val newFile = File(dir, "${
|
||||
refferer.host?.replace(
|
||||
",",
|
||||
"_"
|
||||
)
|
||||
}_${System.currentTimeMillis()}.$realExt")
|
||||
if (file.renameTo(newFile)) newFile else file
|
||||
}
|
||||
}
|
||||
} else {
|
||||
file
|
||||
}
|
||||
|
||||
Blog.LOGE("downloadFileWithOkHttp File saved: ${resultFile.absolutePath}")
|
||||
withContext(Dispatchers.Main) {
|
||||
android.widget.Toast.makeText(
|
||||
context,
|
||||
"다운로드 완료!\n${resultFile.absolutePath}",
|
||||
android.widget.Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.setNegativeButton("취소", null)
|
||||
.show()
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
package bums.lunatic.launcher.utils
|
||||
|
||||
import java.io.ByteArrayInputStream
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
import java.io.OutputStream
|
||||
import java.io.UnsupportedEncodingException
|
||||
import java.util.zip.DeflaterOutputStream
|
||||
import java.util.zip.InflaterInputStream
|
||||
import kotlin.math.floor
|
||||
|
||||
|
||||
object CompressStringUtil {
|
||||
val charsetName: String = "UTF-8"
|
||||
|
||||
/**
|
||||
* String 객체를 압축하여 String 으로 리턴한다.
|
||||
* @param string
|
||||
* @return
|
||||
*/
|
||||
@Synchronized
|
||||
fun compressString(string: String): String? {
|
||||
return byteToString(compress(string))
|
||||
}
|
||||
|
||||
/**
|
||||
* 압축된 스트링을 복귀시켜서 String 으로 리턴한다.
|
||||
* @param compressed
|
||||
* @return
|
||||
*/
|
||||
@Synchronized
|
||||
fun decompressString(compressed: String?): String {
|
||||
return decompress(hexToByteArray(compressed))
|
||||
}
|
||||
|
||||
private fun byteToString(bytes: ByteArray?): String? {
|
||||
val sb = StringBuilder()
|
||||
try {
|
||||
for (b in bytes!!) {
|
||||
sb.append(String.format("%02X", b))
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
return null
|
||||
}
|
||||
|
||||
return sb.toString()
|
||||
}
|
||||
|
||||
private fun compress(text: String): ByteArray? {
|
||||
val baos = ByteArrayOutputStream()
|
||||
try {
|
||||
val out: OutputStream = DeflaterOutputStream(baos)
|
||||
out.write(text.toByteArray(charset(charsetName)))
|
||||
out.close()
|
||||
} catch (e: UnsupportedEncodingException) {
|
||||
e.printStackTrace()
|
||||
return null
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
return null
|
||||
}
|
||||
return baos.toByteArray()
|
||||
}
|
||||
|
||||
|
||||
private fun decompress(bytes: ByteArray): String {
|
||||
val `in`: InputStream = InflaterInputStream(ByteArrayInputStream(bytes))
|
||||
val baos = ByteArrayOutputStream()
|
||||
try {
|
||||
val buffer = ByteArray(8192)
|
||||
var len: Int
|
||||
while ((`in`.read(buffer).also { len = it }) > 0) baos.write(buffer, 0, len)
|
||||
return String(baos.toByteArray(), charset(charsetName))
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
throw AssertionError(e)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 16진 문자열을 byte 배열로 변환한다.
|
||||
*/
|
||||
private fun hexToByteArray(hex: String?): ByteArray {
|
||||
if (hex == null || hex.length % 2 != 0) {
|
||||
return byteArrayOf()
|
||||
}
|
||||
|
||||
val bytes = ByteArray(hex.length / 2)
|
||||
var i = 0
|
||||
while (i < hex.length) {
|
||||
val value = hex.substring(i, i + 2).toInt(16).toByte()
|
||||
bytes[floor((i / 2).toDouble()).toInt()] = value
|
||||
i += 2
|
||||
}
|
||||
return bytes
|
||||
}
|
||||
|
||||
}
|
||||
class NaturalOrderComparator : Comparator<File> {
|
||||
override fun compare(f1: File, f2: File): Int {
|
||||
// 숫자와 문자의 경계를 기준으로 문자열을 쪼개는 정규식
|
||||
val splitRegex = Regex("(?<=\\D)(?=\\d)|(?<=\\d)(?=\\D)")
|
||||
val parts1 = f1.name.split(splitRegex)
|
||||
val parts2 = f2.name.split(splitRegex)
|
||||
|
||||
val limit = minOf(parts1.size, parts2.size)
|
||||
for (i in 0 until limit) {
|
||||
val p1 = parts1[i]
|
||||
val p2 = parts2[i]
|
||||
|
||||
if (p1 == p2) continue
|
||||
|
||||
val isNum1 = p1.all { it.isDigit() }
|
||||
val isNum2 = p2.all { it.isDigit() }
|
||||
|
||||
if (isNum1 && isNum2) {
|
||||
// 둘 다 숫자면 앞의 0을 떼고 자리수 먼저 비교 후 문자열 비교
|
||||
val num1 = p1.trimStart('0')
|
||||
val num2 = p2.trimStart('0')
|
||||
val cmp = if (num1.length != num2.length) {
|
||||
num1.length.compareTo(num2.length)
|
||||
} else {
|
||||
num1.compareTo(num2)
|
||||
}
|
||||
if (cmp != 0) return cmp
|
||||
} else {
|
||||
// 숫자가 아니면 일반 문자열(대소문자 무시) 비교
|
||||
val strCmp = p1.compareTo(p2, ignoreCase = true)
|
||||
if (strCmp != 0) return strCmp
|
||||
}
|
||||
}
|
||||
return parts1.size.compareTo(parts2.size)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,235 @@
|
||||
package bums.lunatic.launcher.utils
|
||||
|
||||
|
||||
object EnToKo {
|
||||
var ignoreChars: String = "`1234567890-=[]\\;',./~!@#$%^&*()_+{}|:\"<>? "
|
||||
|
||||
/** * 영어를 한글로... */
|
||||
fun engToKor(eng: String): String {
|
||||
val sb = StringBuffer()
|
||||
var initialCode = 0
|
||||
var medialCode = 0
|
||||
var finalCode = 0
|
||||
var tempMedialCode: Int
|
||||
var tempFinalCode: Int
|
||||
var i = 0
|
||||
while (i < eng.length) {
|
||||
// 숫자특수문자 처리
|
||||
if (ignoreChars.indexOf(eng.substring(i, i + 1)) > -1) {
|
||||
sb.append(eng.substring(i, i + 1))
|
||||
i++
|
||||
continue
|
||||
}
|
||||
|
||||
// 초성코드 추출
|
||||
initialCode = getCode(CodeType.chosung, eng.substring(i, i + 1))
|
||||
i++
|
||||
|
||||
// 다음문자로
|
||||
// 중성코드 추출
|
||||
tempMedialCode = getDoubleMedial(i, eng)
|
||||
|
||||
// 두 자로 이루어진 중성코드 추출
|
||||
if (tempMedialCode != -1) {
|
||||
medialCode = tempMedialCode
|
||||
i += 2
|
||||
} else {
|
||||
// 없다면,
|
||||
medialCode = getSingleMedial(i, eng)
|
||||
|
||||
// 한 자로 이루어진 중성코드 추출
|
||||
i++
|
||||
}
|
||||
|
||||
// 종성코드 추출
|
||||
tempFinalCode = getDoubleFinal(i, eng)
|
||||
|
||||
// 두 자로 이루어진 종성코드 추출
|
||||
if (tempFinalCode != -1) {
|
||||
finalCode = tempFinalCode
|
||||
|
||||
// 그 다음의 중성 문자에 대한 코드를 추출한다.
|
||||
tempMedialCode = getSingleMedial(i + 2, eng)
|
||||
if (tempMedialCode != -1) {
|
||||
// 코드 값이 있을 경우
|
||||
finalCode = getSingleFinal(i, eng)
|
||||
|
||||
// 종성 코드 값을 저장한다.
|
||||
} else {
|
||||
i++
|
||||
}
|
||||
} else {
|
||||
// 코드 값이 없을 경우 ,
|
||||
tempMedialCode = getSingleMedial(i + 1, eng)
|
||||
|
||||
// 그 다음의 중성 문자에 대한 코드 추출.
|
||||
if (tempMedialCode != -1) {
|
||||
// 그 다음에 중성 문자가 존재할 경우,
|
||||
finalCode = 0 // 종성 문자는 없음.
|
||||
i--
|
||||
} else {
|
||||
finalCode = getSingleFinal(i, eng)
|
||||
|
||||
// 종성 문자 추출
|
||||
if (finalCode == -1) {
|
||||
finalCode = 0
|
||||
i--
|
||||
|
||||
// 초성,중성 + 숫자,특수문자,
|
||||
//기호가 나오는 경우 index를 줄임.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 추출한 초성 문자 코드,
|
||||
//중성 문자 코드, 종성 문자 코드를 합한 후 변환하여 스트링버퍼에 넘김
|
||||
sb.append((0xAC00 + initialCode + medialCode + finalCode).toChar())
|
||||
i++
|
||||
}
|
||||
return sb.toString()
|
||||
}
|
||||
|
||||
/** * 해당 문자에 따른 코드를 추출한다. * * @param type * 초성 : chosung, 중성 : jungsung, 종성 : jongsung 구분 * @param char 해당 문자 */
|
||||
private fun getCode(type: CodeType, c: String): Int {
|
||||
// 초성
|
||||
val init = "rRseEfaqQtTdwWczxvg"
|
||||
|
||||
// 중성
|
||||
val mid = arrayOf(
|
||||
"k",
|
||||
"o",
|
||||
"i",
|
||||
"O",
|
||||
"j",
|
||||
"p",
|
||||
"u",
|
||||
"P",
|
||||
"h",
|
||||
"hk",
|
||||
"ho",
|
||||
"hl",
|
||||
"y",
|
||||
"n",
|
||||
"nj",
|
||||
"np",
|
||||
"nl",
|
||||
"b",
|
||||
"m",
|
||||
"ml",
|
||||
"l"
|
||||
)
|
||||
|
||||
// 종성
|
||||
val fin = arrayOf(
|
||||
"r",
|
||||
"R",
|
||||
"rt",
|
||||
"s",
|
||||
"sw",
|
||||
"sg",
|
||||
"e",
|
||||
"f",
|
||||
"fr",
|
||||
"fa",
|
||||
"fq",
|
||||
"ft",
|
||||
"fx",
|
||||
"fv",
|
||||
"fg",
|
||||
"a",
|
||||
"q",
|
||||
"qt",
|
||||
"t",
|
||||
"T",
|
||||
"d",
|
||||
"w",
|
||||
"c",
|
||||
"z",
|
||||
"x",
|
||||
"v",
|
||||
"g"
|
||||
)
|
||||
when (type) {
|
||||
CodeType.chosung -> {
|
||||
val index = init.indexOf(c)
|
||||
if (index != -1) {
|
||||
return index * 21 * 28
|
||||
}
|
||||
}
|
||||
|
||||
CodeType.jungsung -> {
|
||||
var i = 0
|
||||
while (i < mid.size) {
|
||||
if (mid[i] == c) {
|
||||
return i * 28
|
||||
}
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
||||
CodeType.jongsung -> {
|
||||
var i = 0
|
||||
while (i < fin.size) {
|
||||
if (fin[i] == c) {
|
||||
return i + 1
|
||||
}
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
||||
else -> println("잘못된 타입 입니다")
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
// 한 자로 된 중성값을 리턴한다
|
||||
// 인덱스를 벗어낫다면 -1을 리턴
|
||||
private fun getSingleMedial(i: Int, eng: String): Int {
|
||||
return if ((i + 1) <= eng.length) {
|
||||
getCode(CodeType.jungsung, eng.substring(i, i + 1))
|
||||
} else {
|
||||
-1
|
||||
}
|
||||
}
|
||||
|
||||
// 두 자로 된 중성을 체크하고, 있다면 값을 리턴한다.
|
||||
// 없으면 리턴값은 -1
|
||||
private fun getDoubleMedial(i: Int, eng: String): Int {
|
||||
val result: Int
|
||||
if ((i + 2) > eng.length) {
|
||||
return -1
|
||||
} else {
|
||||
result = getCode(CodeType.jungsung, eng.substring(i, i + 2))
|
||||
return if (result != -1) {
|
||||
result
|
||||
} else {
|
||||
-1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 한 자로된 종성값을 리턴한다
|
||||
// 인덱스를 벗어낫다면 -1을 리턴
|
||||
private fun getSingleFinal(i: Int, eng: String): Int {
|
||||
return if ((i + 1) <= eng.length) {
|
||||
getCode(CodeType.jongsung, eng.substring(i, i + 1))
|
||||
} else {
|
||||
-1
|
||||
}
|
||||
}
|
||||
|
||||
// 두 자로된 종성을 체크하고, 있다면 값을 리턴한다.
|
||||
// 없으면 리턴값은 -1
|
||||
private fun getDoubleFinal(i: Int, eng: String): Int {
|
||||
return if ((i + 2) > eng.length) {
|
||||
-1
|
||||
} else {
|
||||
getCode(CodeType.jongsung, eng.substring(i, i + 2))
|
||||
}
|
||||
}
|
||||
|
||||
// 코드타입 - 초성, 중성, 종성
|
||||
internal enum class CodeType {
|
||||
chosung, jungsung, jongsung
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package bums.lunatic.launcher.utils
|
||||
|
||||
import org.mozilla.universalchardet.UniversalDetector
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.io.RandomAccessFile
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.charset.Charset
|
||||
import java.nio.charset.CodingErrorAction
|
||||
|
||||
object FileUtils {
|
||||
val charsets = listOf("UTF-8", "GB18030", "CP949", "BIG5", "Shift_JIS", "CP949", "Shift_JIS", "ISO-8859-1", "Windows-1252", "EUC-KR","GB2312","65001" )
|
||||
fun readTextWithEncoding(file: File): String {
|
||||
val bytes = file.readBytes()
|
||||
if (bytes.isEmpty()) return ""
|
||||
|
||||
// 1. BOM 체크는 가장 정확하므로 유지
|
||||
if (bytes.size >= 3 && bytes[0] == 0xEF.toByte() && bytes[1] == 0xBB.toByte() && bytes[2] == 0xBF.toByte()) {
|
||||
return String(bytes, 3, bytes.size - 3, Charsets.UTF_8)
|
||||
}
|
||||
|
||||
// 2. 인코딩 후보 순서 (이미지 같은 자막은 GB18030이 강력한 후보입니다)
|
||||
|
||||
|
||||
var bestText = ""
|
||||
|
||||
for (charsetName in charsets) {
|
||||
try {
|
||||
val decoder = java.nio.charset.Charset.forName(charsetName).newDecoder()
|
||||
// 💡 핵심: REPLACE 대신 REPORT를 사용해 엄격하게 검사합니다.
|
||||
.onMalformedInput(java.nio.charset.CodingErrorAction.REPORT)
|
||||
.onUnmappableCharacter(java.nio.charset.CodingErrorAction.REPORT)
|
||||
|
||||
// 인코딩이 조금이라도 어긋나면 여기서 Exception이 발생해 다음으로 넘어갑니다.
|
||||
val text = decoder.decode(java.nio.ByteBuffer.wrap(bytes)).toString()
|
||||
|
||||
// 💡 추가 검증: 특수 기호(Ã, Â) 비율이 너무 높으면 중국어/한국어일 확률이 큼
|
||||
if (isNaturalText(text)) {
|
||||
return text
|
||||
}
|
||||
bestText = text
|
||||
} catch (e: Exception) {
|
||||
continue // 다음 인코딩으로
|
||||
}
|
||||
}
|
||||
|
||||
return if (bestText.isNotEmpty()) bestText else String(bytes, Charsets.UTF_8)
|
||||
}
|
||||
|
||||
// 💡 텍스트가 깨진 외계어인지 확인하는 보조 함수
|
||||
private fun isNaturalText(text: String): Boolean {
|
||||
val garbageCount = text.count { it == 'Ã' || it == 'Â' || it == 'æ' }
|
||||
// 전체 텍스트에서 저런 문자가 3% 이상 섞여있다면 깨진 것으로 간주
|
||||
return garbageCount < (text.length / 30)
|
||||
}
|
||||
|
||||
|
||||
fun detectFileEncoding(file: File): String {
|
||||
val detector = UniversalDetector(null)
|
||||
FileInputStream(file).use { fis ->
|
||||
val buf = ByteArray(4096)
|
||||
var nread: Int
|
||||
while (fis.read(buf).also { nread = it } > 0 && !detector.isDone) {
|
||||
detector.handleData(buf, 0, nread)
|
||||
}
|
||||
detector.dataEnd()
|
||||
}
|
||||
|
||||
// 감지된 인코딩이 없으면 기본값으로 UTF-8 또는 CP949를 반환합니다.
|
||||
return detector.detectedCharset ?: "UTF-8"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,310 @@
|
||||
package bums.lunatic.launcher.utils
|
||||
|
||||
import java.lang.Long.toHexString
|
||||
|
||||
class Hashids(salt: String = defaultSalt, minHashLength: Int = defaultMinimalHashLength, alphabet: String = defaultAlphabet) {
|
||||
companion object {
|
||||
const val defaultSalt = ""
|
||||
const val defaultMinimalHashLength = 0
|
||||
const val defaultAlphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
|
||||
const val defaultSeparators = "cfhistuCFHISTU"
|
||||
const val minimalAlphabetLength = 16
|
||||
const val separatorDiv = 3.5
|
||||
const val guardDiv = 12
|
||||
|
||||
const val version = "1.1.0"
|
||||
|
||||
private const val emptyString = ""
|
||||
private const val space = " "
|
||||
private const val maxNumber = 9007199254740992
|
||||
}
|
||||
|
||||
private val finalSalt = whatSalt(salt)
|
||||
private val finalHashLength = whatHashLength(minHashLength)
|
||||
private val alphabetSeparatorsAndGuards = calculateAlphabetAndSeparators(alphabet)
|
||||
private val finalAlphabet = alphabetSeparatorsAndGuards.alphabet
|
||||
private val finalSeparators = alphabetSeparatorsAndGuards.separators
|
||||
private val finalGuards = alphabetSeparatorsAndGuards.guards
|
||||
|
||||
|
||||
/**
|
||||
* Encodes numbers to string
|
||||
*
|
||||
* @param numbers the numbers to encode
|
||||
* @return The encoded string
|
||||
*/
|
||||
fun encode(vararg numbers: Long): String = when {
|
||||
numbers.isEmpty() -> emptyString
|
||||
numbers.any { it > maxNumber } -> throw IllegalArgumentException("Number can not be greater than ${maxNumber}L")
|
||||
else -> {
|
||||
val numbersHash = numbers.indices
|
||||
.map { (numbers[it] % (it + 100)).toInt() }
|
||||
.sum()
|
||||
|
||||
val initialCharacter = finalAlphabet.toCharArray()[numbersHash % finalAlphabet.length]
|
||||
val (encodedString, encodingAlphabet) = initialEncode(numbers.asList(), finalSeparators.toCharArray(), initialCharacter.toString(), 0, finalAlphabet, initialCharacter.toString())
|
||||
val tempReturnString = addGuardsIfNecessary(encodedString, numbersHash)
|
||||
|
||||
val halfLength = finalAlphabet.length / 2
|
||||
ensureMinimalLength(halfLength, encodingAlphabet, tempReturnString)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes string to numbers
|
||||
*
|
||||
* @param hash the encoded string
|
||||
* @return Decoded numbers
|
||||
*/
|
||||
fun decode(hash: String): LongArray = when {
|
||||
hash.isEmpty() -> longArrayOf()
|
||||
else -> {
|
||||
val guardsRegex = "[$finalGuards]".toRegex()
|
||||
val hashWithSpacesInsteadOfGuards = hash.replace(guardsRegex, space)
|
||||
val initialSplit = hashWithSpacesInsteadOfGuards.split(space)
|
||||
|
||||
val (lottery, hashBreakdown) = extractLotteryCharAndHashArray(initialSplit)
|
||||
val returnValue = unhashSubHashes(hashBreakdown.iterator(), lottery, mutableListOf(), finalAlphabet)
|
||||
|
||||
when {
|
||||
encode(*returnValue) != hash -> longArrayOf()
|
||||
else -> returnValue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun guardIndex(numbersHash: Int, returnString: String, index: Int): Int = (numbersHash + returnString.toCharArray()[index].toInt()) % finalGuards.length
|
||||
|
||||
/**
|
||||
* Encoded hex string to string
|
||||
*
|
||||
* @param hex the hex string to encode
|
||||
* @return The encoded string
|
||||
*/
|
||||
fun encodeHex(hex: String): String = when {
|
||||
!hex.matches("^[0-9a-fA-F]+$".toRegex()) -> emptyString
|
||||
else -> {
|
||||
val toEncode = "[\\w\\W]{1,12}".toRegex().findAll(hex)
|
||||
.map { it.groupValues }
|
||||
.flatten()
|
||||
.map { it.toLong(16) }
|
||||
.toList()
|
||||
.toLongArray()
|
||||
encode(*toEncode)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes string to hex numbers string
|
||||
*
|
||||
* @param hash the encoded string
|
||||
* @return decoded hex numbers string
|
||||
*/
|
||||
fun decodeHex(hash: String): String = decode(hash)
|
||||
.map { toHexString(it).substring(1) }
|
||||
.toString()
|
||||
|
||||
private fun whatSalt(aSalt: String) = when {
|
||||
aSalt.isEmpty() -> defaultSalt
|
||||
else -> aSalt
|
||||
}
|
||||
|
||||
private fun whatHashLength(aLength: Int) = when {
|
||||
aLength > 0 -> aLength
|
||||
else -> defaultMinimalHashLength
|
||||
}
|
||||
|
||||
private fun calculateAlphabetAndSeparators(userAlphabet: String): AlphabetAndSeparators {
|
||||
val uniqueAlphabet = unique(userAlphabet)
|
||||
when {
|
||||
uniqueAlphabet.length < minimalAlphabetLength -> throw IllegalArgumentException("alphabet must contain at least $minimalAlphabetLength unique characters")
|
||||
uniqueAlphabet.contains(space) -> throw IllegalArgumentException("alphabet cannot contains spaces")
|
||||
else -> {
|
||||
val legalSeparators = defaultSeparators.toSet().intersect(uniqueAlphabet.toSet())
|
||||
val alphabetWithoutSeparators = uniqueAlphabet.toSet().minus(legalSeparators).joinToString(emptyString)
|
||||
val shuffledSeparators = consistentShuffle(legalSeparators.joinToString(emptyString), finalSalt)
|
||||
val (adjustedAlphabet, adjustedSeparators) = adjustAlphabetAndSeparators(alphabetWithoutSeparators, shuffledSeparators)
|
||||
|
||||
val guardCount = Math.ceil(adjustedAlphabet.length.toDouble() / guardDiv).toInt()
|
||||
return if (adjustedAlphabet.length < 3) {
|
||||
val guards = adjustedSeparators.substring(0, guardCount)
|
||||
val seps = adjustedSeparators.substring(guardCount)
|
||||
AlphabetAndSeparators(adjustedAlphabet, seps, guards)
|
||||
} else {
|
||||
val guards = adjustedAlphabet.substring(0, guardCount)
|
||||
val alphabet = adjustedAlphabet.substring(guardCount)
|
||||
AlphabetAndSeparators(alphabet, adjustedSeparators, guards)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun adjustAlphabetAndSeparators(alphabetWithoutSeparators: String, shuffledSeparators: String): AlphabetAndSeparators =
|
||||
if (shuffledSeparators.isEmpty() ||
|
||||
(alphabetWithoutSeparators.length / shuffledSeparators.length).toFloat() > separatorDiv) {
|
||||
|
||||
val sepsLength = calculateSeparatorsLength(alphabetWithoutSeparators)
|
||||
|
||||
if (sepsLength > shuffledSeparators.length) {
|
||||
val difference = sepsLength - shuffledSeparators.length
|
||||
val seps = shuffledSeparators + alphabetWithoutSeparators.substring(0, difference)
|
||||
val alpha = alphabetWithoutSeparators.substring(difference)
|
||||
AlphabetAndSeparators(consistentShuffle(alpha, finalSalt), seps)
|
||||
} else {
|
||||
val seps = shuffledSeparators.substring(0, sepsLength)
|
||||
AlphabetAndSeparators(consistentShuffle(alphabetWithoutSeparators, finalSalt), seps)
|
||||
}
|
||||
} else {
|
||||
AlphabetAndSeparators(consistentShuffle(alphabetWithoutSeparators, finalSalt), shuffledSeparators)
|
||||
}
|
||||
|
||||
private fun calculateSeparatorsLength(alphabet: String): Int = when (val s = Math.ceil(alphabet.length / separatorDiv).toInt()) {
|
||||
1 -> 2
|
||||
else -> s
|
||||
}
|
||||
|
||||
private fun unique(input: String) = input.toSet().joinToString(emptyString)
|
||||
|
||||
private fun addGuardsIfNecessary(encodedString: String, numbersHash: Int): String =
|
||||
if (encodedString.length < finalHashLength) {
|
||||
val guard0 = finalGuards.toCharArray()[guardIndex(numbersHash, encodedString, 0)]
|
||||
val retString = guard0 + encodedString
|
||||
|
||||
if (retString.length < finalHashLength) {
|
||||
val guard2 = finalGuards.toCharArray()[guardIndex(numbersHash, retString, 2)]
|
||||
retString + guard2
|
||||
} else {
|
||||
retString
|
||||
}
|
||||
} else {
|
||||
encodedString
|
||||
}
|
||||
|
||||
private fun extractLotteryCharAndHashArray(initialSplit: List<String>): Pair<Char, List<String>> {
|
||||
val separatorsRegex = "[$finalSeparators]".toRegex()
|
||||
val i = when {
|
||||
initialSplit.size == 2 || initialSplit.size == 3 -> 1
|
||||
else -> 0
|
||||
}
|
||||
val ithElementOfSplit = initialSplit[i]
|
||||
|
||||
val lotteryChar = ithElementOfSplit.first()
|
||||
val finalBreakdown = ithElementOfSplit
|
||||
.substring(1)
|
||||
.replace(separatorsRegex, space)
|
||||
.split(space)
|
||||
return Pair(lotteryChar, finalBreakdown)
|
||||
}
|
||||
|
||||
private tailrec fun unhashSubHashes(hashes: Iterator<String>, lottery: Char, currentReturn: MutableList<Long>, alphabet: String): LongArray {
|
||||
return when {
|
||||
hashes.hasNext() -> {
|
||||
val subHash = hashes.next()
|
||||
val buffer = "$lottery$finalSalt$alphabet"
|
||||
val newAlphabet = consistentShuffle(alphabet, buffer.substring(0, alphabet.length))
|
||||
currentReturn.add(unhash(subHash, newAlphabet))
|
||||
unhashSubHashes(hashes, lottery, currentReturn, newAlphabet)
|
||||
}
|
||||
else -> currentReturn.toLongArray()
|
||||
}
|
||||
}
|
||||
|
||||
private fun hash(input: Long, alphabet: String): String =
|
||||
doHash(input, alphabet.toCharArray(), HashData(emptyString, input)).hash
|
||||
|
||||
private tailrec fun doHash(number: Long, alphabet: CharArray, data: HashData): HashData = when {
|
||||
data.current > 0 -> {
|
||||
val newHashCharacter = alphabet[(data.current % alphabet.size.toLong()).toInt()]
|
||||
val newCurrent = data.current / alphabet.size
|
||||
doHash(number, alphabet, HashData("$newHashCharacter${data.hash}", newCurrent))
|
||||
}
|
||||
else -> data
|
||||
}
|
||||
|
||||
private fun unhash(input: String, alphabet: String): Long =
|
||||
doUnhash(input.toCharArray(), alphabet, alphabet.length.toDouble(), 0, 0)
|
||||
|
||||
private tailrec fun doUnhash(input: CharArray, alphabet: String, alphabetLengthDouble: Double, currentNumber: Long, currentIndex: Int): Long =
|
||||
when {
|
||||
currentIndex < input.size -> {
|
||||
val position = alphabet.indexOf(input[currentIndex])
|
||||
val newNumber = currentNumber + (position * alphabetLengthDouble.pow((input.size.toDouble() - currentIndex - 1))).toLong()
|
||||
doUnhash(input, alphabet, alphabetLengthDouble, newNumber, currentIndex + 1)
|
||||
}
|
||||
else -> currentNumber
|
||||
}
|
||||
|
||||
fun Double.pow(d : Double) : Double{
|
||||
return Math.pow(this,d)
|
||||
}
|
||||
|
||||
private fun consistentShuffle(alphabet: String, salt: String) = when {
|
||||
salt.isEmpty() -> alphabet
|
||||
else -> {
|
||||
val initial = ShuffleData(alphabet.toList(), salt, 0, 0)
|
||||
shuffle(initial, alphabet.length - 1, 1).alphabet.joinToString(emptyString)
|
||||
}
|
||||
}
|
||||
|
||||
private tailrec fun shuffle(data: ShuffleData, currentPosition: Int, limit: Int): ShuffleData = when {
|
||||
currentPosition < limit -> data
|
||||
else -> {
|
||||
val currentAlphabet = data.alphabet.toCharArray()
|
||||
val saltReminder = data.saltReminder % data.salt.length
|
||||
val asciiValue = data.salt[saltReminder].toInt()
|
||||
val cumulativeValue = data.cumulative + asciiValue
|
||||
val positionToSwap = (asciiValue + saltReminder + cumulativeValue) % currentPosition
|
||||
currentAlphabet[positionToSwap] = currentAlphabet[currentPosition].also {
|
||||
currentAlphabet[currentPosition] = currentAlphabet[positionToSwap]
|
||||
}
|
||||
shuffle(ShuffleData(currentAlphabet.toList(), data.salt, cumulativeValue, saltReminder + 1), currentPosition - 1, limit)
|
||||
}
|
||||
}
|
||||
|
||||
private tailrec fun initialEncode(numbers: List<Long>,
|
||||
separators: CharArray,
|
||||
bufferSeed: String,
|
||||
currentIndex: Int,
|
||||
alphabet: String,
|
||||
currentReturnString: String): Pair<String, String> = when {
|
||||
currentIndex < numbers.size -> {
|
||||
val currentNumber = numbers[currentIndex]
|
||||
val buffer = bufferSeed + finalSalt + alphabet
|
||||
val nextAlphabet = consistentShuffle(alphabet, buffer.substring(0, alphabet.length))
|
||||
val last = hash(currentNumber, nextAlphabet)
|
||||
|
||||
val newReturnString = if (currentIndex + 1 < numbers.size) {
|
||||
val nextNumber = currentNumber % (last.toCharArray()[0].toInt() + currentIndex)
|
||||
val sepsIndex = (nextNumber % separators.size).toInt()
|
||||
currentReturnString + last + separators[sepsIndex]
|
||||
} else {
|
||||
currentReturnString + last
|
||||
}
|
||||
initialEncode(numbers, separators, bufferSeed, currentIndex + 1, nextAlphabet, newReturnString)
|
||||
}
|
||||
else -> Pair(currentReturnString, alphabet)
|
||||
}
|
||||
|
||||
private tailrec fun ensureMinimalLength(halfLength: Int, alphabet: String, returnString: String): String = when {
|
||||
returnString.length < finalHashLength -> {
|
||||
val newAlphabet = consistentShuffle(alphabet, alphabet)
|
||||
val tempReturnString = newAlphabet.substring(halfLength) + returnString + newAlphabet.substring(0, halfLength)
|
||||
val excess = tempReturnString.length - finalHashLength
|
||||
val newReturnString = if (excess > 0) {
|
||||
val position = excess / 2
|
||||
tempReturnString.substring(position, position + finalHashLength)
|
||||
} else {
|
||||
tempReturnString
|
||||
}
|
||||
ensureMinimalLength(halfLength, newAlphabet, newReturnString)
|
||||
}
|
||||
else -> returnString
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private data class AlphabetAndSeparators(val alphabet: String, val separators: String, val guards: String = "")
|
||||
|
||||
private data class ShuffleData(val alphabet: List<Char>, val salt: String, val cumulative: Int, val saltReminder: Int)
|
||||
|
||||
private data class HashData(val hash: String, val current: Long)
|
||||
@@ -0,0 +1,31 @@
|
||||
package bums.lunatic.launcher.utils
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
import android.util.Base64
|
||||
import java.io.ByteArrayOutputStream
|
||||
|
||||
object ImageUtils {
|
||||
|
||||
fun bitmapToBase64String(resource : Bitmap) : String? {
|
||||
val baos = ByteArrayOutputStream()
|
||||
resource.compress(Bitmap.CompressFormat.PNG, 100, baos)
|
||||
val iconArray = baos.toByteArray()
|
||||
|
||||
return if (iconArray != null && iconArray.size > 0) {
|
||||
Base64.encodeToString(iconArray, Base64.DEFAULT)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
fun stringToBitmap(src : String) : Bitmap? {
|
||||
val iconArray = Base64.decode(src?.toByteArray(), Base64.DEFAULT)
|
||||
return if (iconArray != null && iconArray.size > 0) {
|
||||
BitmapFactory.decodeByteArray(iconArray, 0, iconArray.size)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package bums.lunatic.launcher.utils
|
||||
|
||||
import org.jsoup.Jsoup
|
||||
import org.jsoup.nodes.Document
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Base64
|
||||
|
||||
val USAGT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4 Safari/605.1.15"
|
||||
fun String.getJ() : Document {
|
||||
var doc = Document.createShell(this)
|
||||
try {
|
||||
doc = Jsoup.connect(this).userAgent(USAGT).get()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace();
|
||||
|
||||
} finally {
|
||||
|
||||
}
|
||||
return doc
|
||||
}
|
||||
object FeedParseManager {
|
||||
val parsers = listOf<SoInterface>(QVZTb2dpcmw,SkFWTW9zdA,Z2xvamF2)
|
||||
fun parse(doc : Document, consoleLog : (String)-> Unit) {
|
||||
consoleLog("FeedParseManager START")
|
||||
try {
|
||||
consoleLog(doc.title())
|
||||
parsers.filter { doc.title().contains(it.getName()) || doc.baseUri().contains(it.getName()) }.first()?.let {
|
||||
it.parse(doc,consoleLog)
|
||||
}
|
||||
} catch (e : Exception) {
|
||||
consoleLog(e.message ?: "Exception")
|
||||
e.printStackTrace()
|
||||
}
|
||||
consoleLog("FeedParseManager END")
|
||||
}
|
||||
}
|
||||
interface SoInterface{
|
||||
fun getName() : String
|
||||
fun parse(doc : Document, consoleLog : (String)-> Unit)
|
||||
}
|
||||
object Z2xvamF2 : SoInterface {
|
||||
override fun getName(): String {
|
||||
return String(Base64.getMimeDecoder().decode(this.javaClass.simpleName.toByteArray()))
|
||||
}
|
||||
override fun parse(doc : Document, consoleLog : (String)-> Unit) {
|
||||
consoleLog(doc.html())
|
||||
doc.getElementsByClass("group").forEach { group ->
|
||||
// consoleLog("ogirl group >>> ${group.html()}")
|
||||
consoleLog(group.getElementsByTag("img").attr("src"))
|
||||
consoleLog(group.getElementsByTag("a").get(0).attr("href"))
|
||||
consoleLog(group.getElementsByTag("a").get(0).attr("alt"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object QVZTb2dpcmw : SoInterface {
|
||||
override fun getName(): String {
|
||||
return String(Base64.getMimeDecoder().decode(this.javaClass.simpleName.plus("==").toByteArray()))
|
||||
}
|
||||
override fun parse(doc : Document, consoleLog : (String)-> Unit) {
|
||||
// doc.getElementsByTag("article").forEach { article ->
|
||||
// consoleLog("ogirl article >>> ${article.text()}")
|
||||
// val title = article.getElementsByTag("a").get(0).attr("title")
|
||||
// val href = article.getElementsByTag("a").get(0).attr("href")
|
||||
// val img = article.getElementsByTag("img").get(0).attr("data-src")
|
||||
// WorkersDb.getRealm().writeBlocking {
|
||||
// if (query<RssData>("originPage == $0", href).find().size == 0) {
|
||||
// RssData().apply {
|
||||
// this.originPage = href
|
||||
// this.title = title
|
||||
// this.description = "Sogirl"
|
||||
// this.thumbnail = img
|
||||
// this.pubDate = Date().time
|
||||
// this.category = RssDataType.GURU.name
|
||||
// this.chosung =
|
||||
// JamoUtils.split(title).joinToString("")
|
||||
// copyToRealm(this)
|
||||
// }
|
||||
// consoleLog("title $title | href $href | img $img" )
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
object SkFWTW9zdA : SoInterface {
|
||||
var dmy = SimpleDateFormat("dd-MM-yyyy")
|
||||
override fun getName(): String {
|
||||
return String(Base64.getMimeDecoder().decode(this.javaClass.simpleName.plus("==").toByteArray()))
|
||||
}
|
||||
override fun parse(doc: Document, consoleLog: (String) -> Unit) {
|
||||
// consoleLog("$lastedFinishedPageUrl >>> ${doc.title()}")
|
||||
// doc.getElementsByClass("card").forEach { card ->
|
||||
// var thumb = if(card.getElementsByTag("img").size > 0) card.getElementsByTag("img").get(0).attr("src") else ""
|
||||
// if (thumb.contains("No+Poster")) thumb = if(card.getElementsByTag("img").size > 0) card.getElementsByTag("img").get(0).attr("data-src") else thumb
|
||||
// var model = if(card.getElementsByTag("img").size > 0) card.getElementsByTag("img").get(0).attr("alt") else ""
|
||||
// if(card.getElementsByClass("card-block").size > 0) if(card.getElementsByClass("card-block").size > 0) {
|
||||
// val link = card.getElementsByClass("card-block").get(0).getElementsByTag("a").get(0).attr("href")
|
||||
// val title = card.getElementsByClass("card-block").get(0).getElementsByTag("a").get(0).attr("title")
|
||||
// val date = card.getElementsByTag("span").get(0).text()
|
||||
// MostItem().let { ms ->
|
||||
// ms.model = model
|
||||
// ms.image = thumb
|
||||
// ms.pageLink = link
|
||||
// ms.title = title
|
||||
// try {
|
||||
// ms.date = dmy.parse(date).time
|
||||
// consoleLog("dateFormat.format(Date(ms.date)) ${dateFormat.format(Date(ms.date))}")
|
||||
// }catch (e : Exception) {e.printStackTrace()}
|
||||
// if (ms.isValid()) {
|
||||
// WorkersDb.insertData(ms.getRssData())
|
||||
// }
|
||||
// }
|
||||
// consoleLog(" model >>>>> ${model}\n | thumb >>>>> ${thumb}\n | title >>>>> ${title}\n | date >>>>> ${date} | ")
|
||||
// }
|
||||
// }
|
||||
// consoleLog("excuted j req() ${WorkersDb.getRealm().query<RssData>("category == $0", RssDataType.GURU.name).find().size}")
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,33 @@
|
||||
package bums.lunatic.launcher.utils
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
import android.media.MediaMetadataRetriever
|
||||
import java.io.File
|
||||
|
||||
object MediaBitmapUtil {
|
||||
fun decodeImageFile(file: File): Bitmap? {
|
||||
return try {
|
||||
val options = BitmapFactory.Options().apply {
|
||||
inPreferredConfig = Bitmap.Config.RGB_565
|
||||
}
|
||||
BitmapFactory.decodeFile(file.absolutePath, options)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
fun decodeVideoFrame(file: File, frameTimeUs: Long = 0L): Bitmap? {
|
||||
return try {
|
||||
val retriever = MediaMetadataRetriever()
|
||||
retriever.setDataSource(file.absolutePath)
|
||||
val bitmap = retriever.getFrameAtTime(frameTimeUs)
|
||||
retriever.release()
|
||||
bitmap
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
package bums.lunatic.launcher.utils
|
||||
|
||||
|
||||
// PlayCategory.kt 내부에 추가하거나 하단에 작성
|
||||
|
||||
object CategoryGrouper {
|
||||
// 필터로 사용할 스코프 상수
|
||||
const val SCOPE_ALL = "ALL"
|
||||
const val SCOPE_GAME = "GAME"
|
||||
const val SCOPE_SOCIAL = "SOCIAL"
|
||||
const val SCOPE_MEDIA = "MEDIA"
|
||||
const val SCOPE_PRODUCTIVITY = "PROD"
|
||||
|
||||
// 게임 카테고리 목록 (PlayCategory 상수를 참조)
|
||||
private val GAME_CATEGORIES = setOf(
|
||||
// [수정] AppInfoGetter에서 저장하는 "GAME" 추가
|
||||
"GAME",
|
||||
|
||||
// 기존 상세 카테고리들 (Play Store 크롤링 등을 통해 상세 정보를 가져오는 경우를 대비해 유지)
|
||||
PlayCategory.GAME_ACTION, PlayCategory.GAME_ADVENTURE, PlayCategory.GAME_ARCADE,
|
||||
PlayCategory.GAME_BOARD, PlayCategory.GAME_CARD, PlayCategory.GAME_CASINO,
|
||||
PlayCategory.GAME_CASUAL, PlayCategory.GAME_EDUCATIONAL, PlayCategory.GAME_MUSIC,
|
||||
PlayCategory.GAME_PUZZLE, PlayCategory.GAME_RACING, PlayCategory.GAME_ROLE_PLAYING,
|
||||
PlayCategory.GAME_SIMULATION, PlayCategory.GAME_SPORTS, PlayCategory.GAME_STRATEGY,
|
||||
PlayCategory.GAME_TRIVIA, PlayCategory.GAME_WORD
|
||||
)
|
||||
|
||||
private val SOCIAL_CATEGORIES = setOf(
|
||||
// [수정] AppInfoGetter에서 저장하는 "SOCIAL" 추가
|
||||
"SOCIAL",
|
||||
|
||||
PlayCategory.SOCIAL, PlayCategory.COMMUNICATION, PlayCategory.DATING
|
||||
)
|
||||
|
||||
private val MEDIA_CATEGORIES = setOf(
|
||||
// [수정] AppInfoGetter에서 저장하는 값들 추가 ("AUDIO", "VIDEO", "IMAGE")
|
||||
"AUDIO", "VIDEO", "IMAGE",
|
||||
|
||||
PlayCategory.MUSIC_AND_AUDIO, PlayCategory.VIDEO_PLAYERS,
|
||||
PlayCategory.ENTERTAINMENT, PlayCategory.PHOTOGRAPHY
|
||||
)
|
||||
|
||||
// 앱의 카테고리가 현재 선택된 스코프에 속하는지 확인하는 함수
|
||||
fun isInScope(appCategory: String?, scope: String): Boolean {
|
||||
if (scope == SCOPE_ALL) return true
|
||||
if (appCategory == null) return false // 카테고리 정보 없으면 기타 처리
|
||||
|
||||
return when (scope) {
|
||||
SCOPE_GAME -> GAME_CATEGORIES.contains(appCategory)
|
||||
SCOPE_SOCIAL -> SOCIAL_CATEGORIES.contains(appCategory)
|
||||
SCOPE_MEDIA -> MEDIA_CATEGORIES.contains(appCategory)
|
||||
SCOPE_PRODUCTIVITY -> !GAME_CATEGORIES.contains(appCategory) &&
|
||||
!SOCIAL_CATEGORIES.contains(appCategory) &&
|
||||
!MEDIA_CATEGORIES.contains(appCategory) // 나머지를 생산성/기타로 취급 예시
|
||||
else -> true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
object PlayCategory {
|
||||
|
||||
// 앱(App) 카테고리
|
||||
const val ART_AND_DESIGN = "Art & Design"
|
||||
const val AUTO_AND_VEHICLES = "Auto & Vehicles"
|
||||
const val BEAUTY = "Beauty"
|
||||
const val BOOKS_AND_REFERENCE = "Books & Reference"
|
||||
const val BUSINESS = "Business"
|
||||
const val COMICS = "Comics"
|
||||
const val COMMUNICATION = "Communication"
|
||||
const val DATING = "Dating"
|
||||
const val DAYDREAM = "Daydream" // 일부 기기용
|
||||
const val EDUCATION = "Education"
|
||||
const val ENTERTAINMENT = "Entertainment"
|
||||
const val EVENTS = "Events"
|
||||
const val FINANCE = "Finance"
|
||||
const val FOOD_AND_DRINK = "Food & Drink"
|
||||
const val HEALTH_AND_FITNESS = "Health & Fitness"
|
||||
const val HOUSE_AND_HOME = "House & Home"
|
||||
const val LIBRARIES_AND_DEMO = "Libraries & Demo"
|
||||
const val LIFESTYLE = "Lifestyle"
|
||||
const val MAPS_AND_NAVIGATION = "Maps & Navigation"
|
||||
const val MEDICAL = "Medical"
|
||||
const val MUSIC_AND_AUDIO = "Music & Audio"
|
||||
const val NEWS_AND_MAGAZINES = "News & Magazines"
|
||||
const val PARENTING = "Parenting"
|
||||
const val PERSONALIZATION = "Personalization"
|
||||
const val PHOTOGRAPHY = "Photography"
|
||||
const val PRODUCTIVITY = "Productivity"
|
||||
const val SHOPPING = "Shopping"
|
||||
const val SOCIAL = "Social"
|
||||
const val SPORTS = "Sports"
|
||||
const val TOOLS = "Tools"
|
||||
const val TRAVEL_AND_LOCAL = "Travel & Local"
|
||||
const val VIDEO_PLAYERS = "Video Players & Editors"
|
||||
const val WEATHER = "Weather"
|
||||
|
||||
// 게임(Game) 카테고리
|
||||
const val GAME_ACTION = "Action"
|
||||
const val GAME_ADVENTURE = "Adventure"
|
||||
const val GAME_ARCADE = "Arcade"
|
||||
const val GAME_BOARD = "Board"
|
||||
const val GAME_CARD = "Card"
|
||||
const val GAME_CASINO = "Casino"
|
||||
const val GAME_CASUAL = "Casual"
|
||||
const val GAME_EDUCATIONAL = "Educational"
|
||||
const val GAME_MUSIC = "Music"
|
||||
const val GAME_PUZZLE = "Puzzle"
|
||||
const val GAME_RACING = "Racing"
|
||||
const val GAME_ROLE_PLAYING = "Role Playing"
|
||||
const val GAME_SIMULATION = "Simulation"
|
||||
const val GAME_SPORTS = "Sports"
|
||||
const val GAME_STRATEGY = "Strategy"
|
||||
const val GAME_TRIVIA = "Trivia"
|
||||
const val GAME_WORD = "Word"
|
||||
|
||||
// 전체 카테고리 리스트 (앱 + 게임)
|
||||
val ALL_CATEGORIES = listOf(
|
||||
ART_AND_DESIGN,
|
||||
AUTO_AND_VEHICLES,
|
||||
BEAUTY,
|
||||
BOOKS_AND_REFERENCE,
|
||||
BUSINESS,
|
||||
COMICS,
|
||||
COMMUNICATION,
|
||||
DATING,
|
||||
DAYDREAM,
|
||||
EDUCATION,
|
||||
ENTERTAINMENT,
|
||||
EVENTS,
|
||||
FINANCE,
|
||||
FOOD_AND_DRINK,
|
||||
HEALTH_AND_FITNESS,
|
||||
HOUSE_AND_HOME,
|
||||
LIBRARIES_AND_DEMO,
|
||||
LIFESTYLE,
|
||||
MAPS_AND_NAVIGATION,
|
||||
MEDICAL,
|
||||
MUSIC_AND_AUDIO,
|
||||
NEWS_AND_MAGAZINES,
|
||||
PARENTING,
|
||||
PERSONALIZATION,
|
||||
PHOTOGRAPHY,
|
||||
PRODUCTIVITY,
|
||||
SHOPPING,
|
||||
SOCIAL,
|
||||
SPORTS,
|
||||
TOOLS,
|
||||
TRAVEL_AND_LOCAL,
|
||||
VIDEO_PLAYERS,
|
||||
WEATHER,
|
||||
|
||||
GAME_ACTION,
|
||||
GAME_ADVENTURE,
|
||||
GAME_ARCADE,
|
||||
GAME_BOARD,
|
||||
GAME_CARD,
|
||||
GAME_CASINO,
|
||||
GAME_CASUAL,
|
||||
GAME_EDUCATIONAL,
|
||||
GAME_MUSIC,
|
||||
GAME_PUZZLE,
|
||||
GAME_RACING,
|
||||
GAME_ROLE_PLAYING,
|
||||
GAME_SIMULATION,
|
||||
GAME_SPORTS,
|
||||
GAME_STRATEGY,
|
||||
GAME_TRIVIA,
|
||||
GAME_WORD,
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,256 @@
|
||||
package bums.lunatic.launcher.utils
|
||||
|
||||
import android.annotation.TargetApi
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Build
|
||||
import android.util.Base64
|
||||
import java.io.ByteArrayInputStream
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.IOException
|
||||
import java.io.ObjectInputStream
|
||||
import java.io.ObjectOutputStream
|
||||
import java.io.Serializable
|
||||
|
||||
|
||||
|
||||
interface PrefKey<T> {
|
||||
fun getKey() : String
|
||||
fun set(value : T)
|
||||
fun get(def : T? = null) : T
|
||||
}
|
||||
interface PrefJsonConvert {
|
||||
fun initialize(context: Context)
|
||||
fun inject(SharedPreferences : SharedPreferences)
|
||||
fun getSettings() : Map<String,Any>
|
||||
fun putSetting(json : Map<String,Any>)
|
||||
}
|
||||
abstract class PreferencesHelper : PrefJsonConvert {
|
||||
|
||||
var sharedPreferences : SharedPreferences? = null
|
||||
open fun allPrefKeys() : ArrayList<String> =arrayListOf()
|
||||
open fun getBooleanPrefix() : String = getDefaultPrefix().plus(".BOOL.")
|
||||
open fun getStringPrefix() : String = getDefaultPrefix().plus(".STRING.")
|
||||
open fun getLongPrefix() : String = getDefaultPrefix().plus(".LONG.")
|
||||
open fun getDefaultPrefix() : String = PreferencesHelper::class.java.canonicalName
|
||||
abstract override fun getSettings() : Map<String,Any>
|
||||
abstract override fun putSetting(json : Map<String,Any>)
|
||||
|
||||
|
||||
|
||||
override fun initialize(context: Context) {
|
||||
inject(context.getSharedPreferences(getDefaultPrefix(), Context.MODE_PRIVATE))
|
||||
}
|
||||
|
||||
override fun inject(sharedPreferences : SharedPreferences) {
|
||||
this.sharedPreferences = sharedPreferences
|
||||
}
|
||||
|
||||
|
||||
fun get(key: String?, defValue: Boolean): Boolean {
|
||||
return get(getDefaultPrefix(), key, defValue)
|
||||
}
|
||||
|
||||
fun get(key: String?, defValue: Int): Int {
|
||||
return get(getDefaultPrefix(), key, defValue)
|
||||
}
|
||||
|
||||
fun get(key: String?, defValue: Float): Float {
|
||||
return get(getDefaultPrefix(), key, defValue)
|
||||
}
|
||||
|
||||
fun get(key: String?, defValue: Long): Long {
|
||||
return get(getDefaultPrefix(), key, defValue)
|
||||
}
|
||||
|
||||
fun get(key: String?, defValue: String?): String? {
|
||||
return get(getDefaultPrefix(), key, defValue)
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||
fun get(key: String?, defValue: Set<String?>?): Set<String>? {
|
||||
return get(getDefaultPrefix(), key, defValue)
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.FROYO)
|
||||
fun <C : Serializable?> get(key: String?, defValue: C): C {
|
||||
return get(getDefaultPrefix(), key, defValue)
|
||||
}
|
||||
|
||||
fun get(name: String, key: String?, defValue: Boolean): Boolean {
|
||||
return getPreferences()?.getBoolean(key, defValue) ?: false
|
||||
}
|
||||
|
||||
fun getPreferences(): SharedPreferences? {
|
||||
return this.sharedPreferences
|
||||
}
|
||||
|
||||
fun get(name: String, key: String?, defValue: Int): Int {
|
||||
return getPreferences()?.getInt(key, defValue) ?: 0
|
||||
}
|
||||
|
||||
fun get(name: String, key: String?, defValue: Float): Float {
|
||||
return getPreferences()?.getFloat(key, defValue) ?: 0f
|
||||
}
|
||||
|
||||
fun get(name: String, key: String?, defValue: Long): Long {
|
||||
return getPreferences()?.getLong(key, defValue) ?: 0L
|
||||
}
|
||||
|
||||
fun get(name: String, key: String?, defValue: String?): String? {
|
||||
return getPreferences()?.getString(key, defValue)
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||
fun get(name: String, key: String?, defValue: Set<String?>?): Set<String>? {
|
||||
return getPreferences()?.getStringSet(key, defValue)
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.FROYO)
|
||||
fun <C : Serializable?> get(name: String, key: String?, defValue: C): C {
|
||||
var bais: ByteArrayInputStream? = null
|
||||
var ois: ObjectInputStream? = null
|
||||
var result = defValue
|
||||
|
||||
val value = getPreferences()?.getString(key, null)
|
||||
if (value != null) {
|
||||
try {
|
||||
val decoded = Base64.decode(value.toByteArray(), Base64.DEFAULT)
|
||||
bais = ByteArrayInputStream(decoded)
|
||||
ois = ObjectInputStream(bais)
|
||||
result = ois.readObject() as C
|
||||
} catch (e: Exception) {
|
||||
// Blog.LOGE(e.printStackTrace())
|
||||
} finally {
|
||||
if (ois != null) {
|
||||
try {
|
||||
ois.close()
|
||||
} catch (e: IOException) {
|
||||
// LogHelper.e(e)
|
||||
}
|
||||
}
|
||||
if (bais != null) {
|
||||
try {
|
||||
bais.close()
|
||||
} catch (e: IOException) {
|
||||
// LogHelper.e(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
fun put(key: String?, value: Boolean) {
|
||||
put(getDefaultPrefix(), key, value)
|
||||
}
|
||||
|
||||
fun put(key: String?, value: Int) {
|
||||
put(getDefaultPrefix(), key, value)
|
||||
}
|
||||
|
||||
fun put(key: String?, value: Float) {
|
||||
put(getDefaultPrefix(), key, value)
|
||||
}
|
||||
|
||||
fun put(key: String?, value: Long) {
|
||||
put(getDefaultPrefix(), key, value)
|
||||
}
|
||||
|
||||
fun put(key: String?, value: String?) {
|
||||
put(getDefaultPrefix(), key, value)
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||
fun put(key: String?, value: Set<String?>?) {
|
||||
put(getDefaultPrefix(), key, value)
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.FROYO)
|
||||
fun <C : Serializable?> put(key: String?, value: C) {
|
||||
put(getDefaultPrefix(), key, value)
|
||||
}
|
||||
|
||||
fun put(name: String, key: String?, value: Boolean) {
|
||||
if (APILevel.require(9)) getPreferences()?.edit()?.putBoolean(key, value)?.apply()
|
||||
else getPreferences()?.edit()?.putBoolean(key, value)?.commit()
|
||||
}
|
||||
|
||||
fun put(name: String, key: String?, value: Int) {
|
||||
if (APILevel.require(9)) getPreferences()?.edit()?.putInt(key, value)?.apply()
|
||||
else getPreferences()?.edit()?.putInt(key, value)?.commit()
|
||||
}
|
||||
|
||||
fun put(name: String, key: String?, value: Float) {
|
||||
if (APILevel.require(9)) getPreferences()?.edit()?.putFloat(key, value)?.apply()
|
||||
else getPreferences()?.edit()?.putFloat(key, value)?.commit()
|
||||
}
|
||||
|
||||
fun put(name: String, key: String?, value: Long) {
|
||||
if (APILevel.require(9)) getPreferences()?.edit()?.putLong(key, value)?.apply()
|
||||
else getPreferences()?.edit()?.putLong(key, value)?.commit()
|
||||
}
|
||||
|
||||
fun put(name: String, key: String?, value: String?) {
|
||||
if (APILevel.require(9)) getPreferences()?.edit()?.putString(key, value)?.apply()
|
||||
else getPreferences()?.edit()?.putString(key, value)?.commit()
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||
fun put(name: String, key: String?, value: Set<String?>?) {
|
||||
if (APILevel.require(9)) getPreferences()?.edit()?.putStringSet(key, value)?.apply()
|
||||
else getPreferences()?.edit()?.putStringSet(key, value)?.commit()
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.FROYO)
|
||||
fun <C : Serializable?> put(name: String, key: String?, value: C) {
|
||||
var baos: ByteArrayOutputStream? = null
|
||||
var oos: ObjectOutputStream? = null
|
||||
|
||||
try {
|
||||
baos = ByteArrayOutputStream()
|
||||
oos = ObjectOutputStream(baos)
|
||||
oos.writeObject(value)
|
||||
val encoded = Base64.encode(baos.toByteArray(), Base64.DEFAULT)
|
||||
if (APILevel.require(9)) getPreferences()?.edit()?.putString(key, String(encoded))?.apply()
|
||||
else getPreferences()?.edit()?.putString(key, String(encoded))?.commit()
|
||||
} catch (e: IOException) {
|
||||
// LogHelper.e(e)
|
||||
throw RuntimeException(e)
|
||||
} finally {
|
||||
if (oos != null) {
|
||||
try {
|
||||
oos.close()
|
||||
} catch (e: IOException) {
|
||||
// LogHelper.e(e)
|
||||
}
|
||||
}
|
||||
if (baos != null) {
|
||||
try {
|
||||
baos.close()
|
||||
} catch (e: IOException) {
|
||||
// LogHelper.e(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun remove(key: String?) {
|
||||
remove(getDefaultPrefix(), key)
|
||||
}
|
||||
|
||||
fun remove(name: String, key: String?) {
|
||||
if (APILevel.require(9)) getPreferences()?.edit()?.remove(key)?.apply()
|
||||
else getPreferences()?.edit()?.remove(key)?.commit()
|
||||
}
|
||||
|
||||
|
||||
@JvmOverloads
|
||||
fun clear(name: String = getDefaultPrefix()) {
|
||||
if (APILevel.require(9)) getPreferences()?.edit()?.clear()?.apply()
|
||||
else getPreferences()?.edit()?.clear()?.commit()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package bums.lunatic.launcher.utils
|
||||
|
||||
import org.jsoup.nodes.Document
|
||||
import java.net.URLEncoder
|
||||
import java.util.Base64
|
||||
|
||||
object RssList {
|
||||
|
||||
val youtubeUrls = arrayListOf(
|
||||
"https://www.youtube.com/@zzanbro",
|
||||
"https://www.youtube.com/@sungsikyung",
|
||||
"https://www.youtube.com/@%EC%A7%80%EB%AC%B4%EB%B9%84",
|
||||
"https://www.youtube.com/@gyeomsonisnothing",
|
||||
"https://www.youtube.com/@ddeunddeun",
|
||||
"https://www.youtube.com/@fairyjaehyung",
|
||||
"https://www.youtube.com/@15ya_egg",
|
||||
"https://www.youtube.com/@%EC%A7%80%EB%AC%B4%EB%B9%84",
|
||||
// "https://www.youtube.com/"
|
||||
)
|
||||
val newsFeeds = arrayListOf(
|
||||
"https://news.google.com/rss?hl=ko&gl=KR&ceid=KR:ko",
|
||||
// "https://rss.nocutnews.co.kr/news/top.xml",
|
||||
"https://trends.google.co.kr/trending/rss?geo=KR",
|
||||
// "https://trends.google.co.kr/trends/trendingsearches/daily/rss?geo=KR"
|
||||
)
|
||||
|
||||
val feedJsons = arrayListOf(
|
||||
"https://www.reddit.com/r/Mogong/.json",
|
||||
)
|
||||
val feedJsons_nsfw = String(Base64.getMimeDecoder().decode("aHR0cHM6Ly93d3cucmVkZGl0LmNvbS9yL25zZncvLmpzb258aHR0cHM6Ly93d3cucmVkZGl0LmNvbS9yL25zZnc0MTEvLmpzb258aHR0cHM6Ly93d3cucmVkZGl0LmNvbS9yL25zZncyLy5qc29ufGh0dHBzOi8vd3d3LnJlZGRpdC5jb20vci9udWRlcy8uanNvbnxodHRwczovL3d3dy5yZWRkaXQuY29tL3IvY3Vja29sZC8uanNvbg==".toByteArray())).split("|")
|
||||
|
||||
fun getFeedUrls() = keyWords.map { "https://news.google.com/rss/search?q=${URLEncoder.encode(it)}=ko&gl=KR&ceid=KR%3Ako/" }
|
||||
|
||||
val keyWords = listOf(
|
||||
"IT",
|
||||
"날씨",
|
||||
"테크",
|
||||
"부동산",
|
||||
"과학",
|
||||
"당뇨",
|
||||
"신장",
|
||||
"여행",
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
object DocParserManager {
|
||||
fun parse(doc : Document) {}
|
||||
}
|
||||
interface DocParser { fun <T>parse(doc : Document) : T }
|
||||
|
||||
class JGuruMain {
|
||||
var maxDate : Long = Long.MIN_VALUE
|
||||
var minDate : Long = Long.MAX_VALUE
|
||||
}
|
||||
Reference in New Issue
Block a user