From b0dbaa50df96665774cf78cb46003f28000dac7d Mon Sep 17 00:00:00 2001 From: lunaticbum Date: Thu, 26 Mar 2026 15:01:11 +0900 Subject: [PATCH] .. --- .../launcher/helpers/ForeGroundService.kt | 52 +++++++++++++------ .../lunatic/launcher/home/NeoRssActivity.kt | 8 ++- .../launcher/home/tokiz/TokiFragment.kt | 4 -- app/src/main/res/layout/rss_activity.xml | 1 - 4 files changed, 41 insertions(+), 24 deletions(-) diff --git a/app/src/main/kotlin/bums/lunatic/launcher/helpers/ForeGroundService.kt b/app/src/main/kotlin/bums/lunatic/launcher/helpers/ForeGroundService.kt index dc1aa9d3..2e17e9c5 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/helpers/ForeGroundService.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/helpers/ForeGroundService.kt @@ -70,31 +70,49 @@ class WallpaperAutoChangeWorker(private val context: Context, params: WorkerPara val folderPath = inputData.getString("FOLDER_PATH") ?: return Result.failure() val folder = File(folderPath) - // 1. 이미지 파일 목록 가져오기 - val images = folder.listFiles { file -> - file.isFile && (file.extension.equals("jpg", true) || file.extension.equals("png", true) || file.extension.equals("jpeg", true)) + val wm = WallpaperManager.getInstance(context) + val minWidth = wm.desiredMinimumWidth + val minHeight = wm.desiredMinimumHeight + // 가로, 세로 중 더 큰 값을 기준으로 삼으려면 다음과 같이 정의합니다. + val requiredSize = Math.max(minWidth, minHeight) + + // 1. 이미지 파일 목록 가져오기 + 크기 조건 필터링 + val validImages = folder.listFiles { file -> + val isImage = file.isFile && (file.extension.equals("jpg", true) || + file.extension.equals("png", true) || + file.extension.equals("jpeg", true)) + + if (isImage) { + // 비트맵을 실제로 로드하지 않고 크기만 체크 (메모리 절약) + val options = BitmapFactory.Options().apply { inJustDecodeBounds = true } + BitmapFactory.decodeFile(file.absolutePath, options) + + // 조건: 이미지의 가로와 세로가 모두 기기 기준 해상도(requiredSize)보다 커야 함 + options.outWidth >= requiredSize && options.outHeight >= requiredSize + } else { + false + } } - if (images.isNullOrEmpty()) return Result.failure() + if (validImages.isNullOrEmpty()) { + // 조건에 맞는 이미지가 하나도 없을 경우 처리 + return Result.failure() + } - // 2. 랜덤 이미지 선택 및 비트맵 로드 - val randomImage = images.random() - val options = BitmapFactory.Options().apply { inJustDecodeBounds = false } - val originalBitmap = BitmapFactory.decodeFile(randomImage.absolutePath, options) ?: return Result.failure() + // 2. 필터링된 이미지 중 랜덤 선택 및 비트맵 로드 + val randomImage = validImages.random() + val originalBitmap = BitmapFactory.decodeFile(randomImage.absolutePath) ?: return Result.failure() return try { - val wm = WallpaperManager.getInstance(context) - val targetWidth = wm.desiredMinimumWidth - val targetHeight = wm.desiredMinimumHeight - - // 3. 비율 유지하며 Center Crop 처리 - val finalBitmap = Bitmap.createBitmap(targetWidth, targetHeight, Bitmap.Config.ARGB_8888) + // 3. 비율 유지하며 Center Crop 처리 (기존 로직 유지) + val finalBitmap = Bitmap.createBitmap(minWidth, minHeight, Bitmap.Config.ARGB_8888) val canvas = Canvas(finalBitmap) - val scale = Math.max(targetWidth.toFloat() / originalBitmap.width, targetHeight.toFloat() / originalBitmap.height) + + val scale = Math.max(minWidth.toFloat() / originalBitmap.width, minHeight.toFloat() / originalBitmap.height) val scaledWidth = scale * originalBitmap.width val scaledHeight = scale * originalBitmap.height - val left = (targetWidth - scaledWidth) / 2f - val top = (targetHeight - scaledHeight) / 2f + val left = (minWidth - scaledWidth) / 2f + val top = (minHeight - scaledHeight) / 2f canvas.drawBitmap(originalBitmap, null, RectF(left, top, left + scaledWidth, top + scaledHeight), Paint(Paint.FILTER_BITMAP_FLAG)) diff --git a/app/src/main/kotlin/bums/lunatic/launcher/home/NeoRssActivity.kt b/app/src/main/kotlin/bums/lunatic/launcher/home/NeoRssActivity.kt index 2efd26e3..a490dbb2 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/home/NeoRssActivity.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/home/NeoRssActivity.kt @@ -37,6 +37,7 @@ import androidx.core.view.ViewCompat import androidx.core.view.WindowCompat import androidx.core.view.WindowInsetsCompat import androidx.core.view.isVisible +import androidx.core.view.marginTop import androidx.fragment.app.Fragment import bums.lunatic.launcher.LunaticLauncher import bums.lunatic.launcher.R @@ -461,10 +462,13 @@ open class NeoRssActivity : CommonActivity() { setContentView(binding.root) HeadsetActionButtonReceiver.register(this) - ViewCompat.setOnApplyWindowInsetsListener(binding.root) { view, windowInsets -> +// ViewCompat.setOnApplyWindowInsetsListener(binding.root) { view, windowInsets -> +// WindowInsetsCompat.CONSUMED +// } + ViewCompat.setOnApplyWindowInsetsListener(binding.fragmentContainer) { view, windowInsets -> val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()) view.setPadding(insets.left, insets.top, insets.right, insets.bottom) - WindowInsetsCompat.CONSUMED + windowInsets } handleBackPress() diff --git a/app/src/main/kotlin/bums/lunatic/launcher/home/tokiz/TokiFragment.kt b/app/src/main/kotlin/bums/lunatic/launcher/home/tokiz/TokiFragment.kt index fb704961..27e16aa1 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/home/tokiz/TokiFragment.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/home/tokiz/TokiFragment.kt @@ -599,10 +599,6 @@ class TokiFragment : RemoteGestureFragment(), PagedTextViewInterface,KeyEventHan // 💡 1. Toki용 레이아웃 설정 binding.lunaticBrowser.setupForToki() - originalVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC) - - // 미디어 볼륨을 0으로 설정 (FLAG_SHOW_UI를 0으로 주면 볼륨 바가 뜨지 않음) - audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 0, 0) // 💡 2. GeckoWeb 접근 및 설정 val geckoWeb = binding.lunaticBrowser.geckoWeb diff --git a/app/src/main/res/layout/rss_activity.xml b/app/src/main/res/layout/rss_activity.xml index 2c1175de..43d161f6 100644 --- a/app/src/main/res/layout/rss_activity.xml +++ b/app/src/main/res/layout/rss_activity.xml @@ -16,7 +16,6 @@ android:layout_height="match_parent" android:clipChildren="false" android:visibility="visible" - android:layout_marginBottom="15dp" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent"