This commit is contained in:
lunaticbum 2026-03-30 14:28:54 +09:00
parent 57039939fd
commit 86f387b2fa
3 changed files with 29 additions and 24 deletions

View File

@ -53,6 +53,8 @@ import com.yausername.youtubedl_android.YoutubeDL
import com.yausername.youtubedl_android.YoutubeDLRequest import com.yausername.youtubedl_android.YoutubeDLRequest
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.cancelAndJoin
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import okhttp3.Request import okhttp3.Request
@ -252,7 +254,8 @@ open class GeckoWeb @JvmOverloads constructor(
} }
} }
fun checkIfDownloadable(firstUrl: String, forMusic: Boolean = false) { var checkIfDownloadableJob : Job? = null
suspend fun checkIfDownloadable(firstUrl: String, forMusic: Boolean = false) {
if (firstUrl.startsWith("about")) { if (firstUrl.startsWith("about")) {
return return
} }
@ -262,8 +265,8 @@ open class GeckoWeb @JvmOverloads constructor(
it.setOnClickListener {} it.setOnClickListener {}
it.visibility = GONE it.visibility = GONE
} }
checkIfDownloadableJob?.cancelAndJoin()
CoroutineScope(Dispatchers.IO).launch { checkIfDownloadableJob = CoroutineScope(Dispatchers.IO).launch {
try { try {
val request = YoutubeDLRequest(cleanUrl).apply { val request = YoutubeDLRequest(cleanUrl).apply {
// 1. yt-dlp 업데이트 강제 (가장 중요!) // 1. yt-dlp 업데이트 강제 (가장 중요!)
@ -618,8 +621,10 @@ open class GeckoWeb @JvmOverloads constructor(
CoroutineScope(Dispatchers.IO).launch { CoroutineScope(Dispatchers.IO).launch {
saveYoutubeCookiesToFile() saveYoutubeCookiesToFile()
} }
CoroutineScope(Dispatchers.IO).launch {
checkIfDownloadable(currentCookieUrlString) checkIfDownloadable(currentCookieUrlString)
} }
}
"SCROLL_STATE" -> { "SCROLL_STATE" -> {
// Blog.LOGE("${msg.type} : ${msg.value}") // Blog.LOGE("${msg.type} : ${msg.value}")
scrollState = msg.value?.toInt() ?: 0 scrollState = msg.value?.toInt() ?: 0

View File

@ -127,9 +127,8 @@ open class NeoRssActivity : CommonActivity() {
} }
override fun dispatchKeyEvent(ev: KeyEvent): Boolean { override fun dispatchKeyEvent(ev: KeyEvent): Boolean {
Blog.LOGE("keyEvent >>>>> ${ev?.device?.name}:dispatchKeyEvent >>> ${ev} ")
if (ev?.device?.name?.contains("JX-05") == true) { if (ev?.device?.name?.contains("JX-05") == true) {
// (ev.action?.equals(KeyEvent.ACTION_DOWN) == true || ev.action?.equals(KeyEvent.ACTION_UP) == true)
if (ev.action?.equals(KeyEvent.ACTION_UP) == true) { if (ev.action?.equals(KeyEvent.ACTION_UP) == true) {
when(ev.keyCode) { when(ev.keyCode) {
KEYCODE_MEDIA_PLAY_PAUSE->{ KEYCODE_MEDIA_PLAY_PAUSE->{
@ -150,7 +149,6 @@ open class NeoRssActivity : CommonActivity() {
if (ev?.device?.name?.contains("SM-031N Mouse") == true) { if (ev?.device?.name?.contains("SM-031N Mouse") == true) {
when(ev.action) { when(ev.action) {
ACTION_UP -> { ACTION_UP -> {
Blog.LOGE("dispatch dispatchKeyEvent>>> ${ev}")
when(ev.keyCode) { when(ev.keyCode) {
KEYCODE_BUTTON_Y->{ KEYCODE_BUTTON_Y->{
@ -265,7 +263,7 @@ open class NeoRssActivity : CommonActivity() {
private fun onRemoteKeyDetected(keyType: String, isDouble : Boolean = false) { private fun onRemoteKeyDetected(keyType: String, isDouble : Boolean = false) {
Blog.LOGE("Remote Mapping Success: $keyType") Blog.LOGE("Remote Mapping Success: $keyType")
val currentFragment = supportFragmentManager.fragments.find { it.isVisible } val currentFragment = targetFragment ?: supportFragmentManager.fragments.find { it.isVisible }
if (currentFragment is RemoteGestureFragment && currentFragment.isRemoteEnabled) { if (currentFragment is RemoteGestureFragment && currentFragment.isRemoteEnabled) {
when(keyType) { when(keyType) {
"UP_ARROW"->{currentFragment.onRemoteUp(isDouble)} "UP_ARROW"->{currentFragment.onRemoteUp(isDouble)}
@ -288,7 +286,7 @@ open class NeoRssActivity : CommonActivity() {
} }
override fun dispatchTouchEvent(ev: MotionEvent?): Boolean { override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
Blog.LOGE("keyEvent >>>>> dispatchTouchEvent ${ev}") // Blog.LOGE("keyEvent >>>>> dispatchTouchEvent ${ev}")
if (ev?.device?.name?.contains("JX-05") == true) { if (ev?.device?.name?.contains("JX-05") == true) {
// 리모컨 이벤트인 경우 제스처 디텍터에 위임 // 리모컨 이벤트인 경우 제스처 디텍터에 위임
if (remoteGestureDetector.onTouchEvent(ev)) { if (remoteGestureDetector.onTouchEvent(ev)) {
@ -507,22 +505,22 @@ open class NeoRssActivity : CommonActivity() {
private var lastTouchX = 0f private var lastTouchX = 0f
private var lastTouchY = 0f private var lastTouchY = 0f
var targetFragment : Fragment? = null
// private val fragmentMap = mutableMapOf<Int, Fragment>() // private val fragmentMap = mutableMapOf<Int, Fragment>()
fun showContents(id : Int) { fun showContents(id : Int) {
if (id == View.NO_ID) { if (id == View.NO_ID) {
Blog.LOGE("무효한 ID(-1) 호출로 인해 showContents를 취소합니다.") // Blog.LOGE("무효한 ID(-1) 호출로 인해 showContents를 취소합니다.")
return return
} }
Blog.LOGE("targetFragment id ${id}") // Blog.LOGE("targetFragment id ${id}")
// 1. 모든 관련 레이어 가시성 확보 // 1. 모든 관련 레이어 가시성 확보
binding.fragmentContainer.isVisible = true binding.fragmentContainer.isVisible = true
val transaction = supportFragmentManager.beginTransaction() val transaction = supportFragmentManager.beginTransaction()
val tagKey = "TAG_$id" val tagKey = "TAG_$id"
Blog.LOGE("targetFragment id ${id} tagKey ${tagKey}") // Blog.LOGE("targetFragment id ${id} tagKey ${tagKey}")
// 2. 매니저에 등록된 모든 프래그먼트를 찾아서 숨김 (중복 방지) // 2. 매니저에 등록된 모든 프래그먼트를 찾아서 숨김 (중복 방지)
val allFragments = supportFragmentManager.fragments val allFragments = supportFragmentManager.fragments
for (f in allFragments) { for (f in allFragments) {
@ -532,7 +530,7 @@ open class NeoRssActivity : CommonActivity() {
} }
// 3. 대상 프래그먼트 찾기 (findFragmentByTag 우선) // 3. 대상 프래그먼트 찾기 (findFragmentByTag 우선)
var targetFragment = supportFragmentManager.findFragmentByTag(tagKey) targetFragment = supportFragmentManager.findFragmentByTag(tagKey)
if (targetFragment == null) { if (targetFragment == null) {
// 처음 호출되는 메뉴라면 인스턴스 생성 및 추가 // 처음 호출되는 메뉴라면 인스턴스 생성 및 추가
@ -562,13 +560,16 @@ open class NeoRssActivity : CommonActivity() {
} }
targetFragment?.let { targetFragment?.let {
Blog.LOGE("targetFragment id ${id} key : ${tagKey}, instance ${targetFragment}") // Blog.LOGE("targetFragment id ${id} key : ${tagKey}, instance ${targetFragment}")
transaction.add(R.id.fragment_container, it, tagKey) transaction.add(R.id.fragment_container, it, tagKey)
} }
} else { } else {
Blog.LOGE("targetFragment id ${id} key : ${tagKey}, instance ${targetFragment}") // Blog.LOGE("targetFragment id ${id} key : ${tagKey}, instance ${targetFragment}")
// 이미 생성된 프래그먼트가 있다면 다시 보여줌 // 이미 생성된 프래그먼트가 있다면 다시 보여줌
transaction.show(targetFragment) targetFragment?.let {
transaction.show(it)
}
} }
transaction.commit() transaction.commit()
@ -625,7 +626,7 @@ open class NeoRssActivity : CommonActivity() {
onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) { onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() { override fun handleOnBackPressed() {
Blog.LOGE("handleBackPress") Blog.LOGE("handleBackPress")
val currentFragment = supportFragmentManager.findFragmentById(R.id.fragment_container) val currentFragment = targetFragment ?: supportFragmentManager.findFragmentById(R.id.fragment_container)
if (currentFragment == null) showContents(R.id.close) if (currentFragment == null) showContents(R.id.close)
when(currentFragment) { when(currentFragment) {
is RssHome ->{ is RssHome ->{

View File

@ -88,11 +88,11 @@ class NLService : NotificationListenerService() {
// 이름이 왔을 때 -> 주소록에서 번호 조회 // 이름이 왔을 때 -> 주소록에서 번호 조회
val foundNumber = getPhoneNumberByName(applicationContext, cleanTitle) val foundNumber = getPhoneNumberByName(applicationContext, cleanTitle)
if (foundNumber != null) { if (foundNumber != null) {
Blog.LOGE("이름($title)으로 번호($foundNumber) 조회 성공") // Blog.LOGE("이름($title)으로 번호($foundNumber) 조회 성공")
WorkersDb.logContactInteraction(foundNumber, UsageUpdateType.SMS) WorkersDb.logContactInteraction(foundNumber, UsageUpdateType.SMS)
} else { } else {
// 주소록에도 없는 이름일 경우 (이름 자체로 로그를 남기려면 WorkersDb 수정 필요) // 주소록에도 없는 이름일 경우 (이름 자체로 로그를 남기려면 WorkersDb 수정 필요)
Blog.LOGE("주소록에서 찾을 수 없는 이름: $title") // Blog.LOGE("주소록에서 찾을 수 없는 이름: $title")
} }
} }
} }
@ -159,7 +159,7 @@ class NLService : NotificationListenerService() {
val regex = Regex("[^가-힣ㄱ-ㅎ0-9a-zA-Z]") val regex = Regex("[^가-힣ㄱ-ㅎ0-9a-zA-Z]")
val cleaned = input.replace(regex, "").trim() val cleaned = input.replace(regex, "").trim()
Blog.LOGE("정제 전: [$input] -> 정제 후: [$cleaned]") // Blog.LOGE("정제 전: [$input] -> 정제 후: [$cleaned]")
return cleaned return cleaned
} }
@ -233,11 +233,10 @@ class NLService : NotificationListenerService() {
} }
override fun onNotificationRemoved(sbn: StatusBarNotification) { override fun onNotificationRemoved(sbn: StatusBarNotification) {
Blog.LOGE("onNotificationPosted ${sbn}") // Blog.LOGE("onNotificationRemoved ${sbn}")
if (sbn.packageName == "bums.lunatic.launcher" && sbn.id == 830721) { if (sbn.packageName == "bums.lunatic.launcher" && sbn.id == 830721) {
// 포그라운드 알림이 사라짐 감지 // 포그라운드 알림이 사라짐 감지
Blog.LOGE("NotificationListener", "포그라운드 알림 제거 감지") // Blog.LOGE("NotificationListener", "포그라운드 알림 제거 감지")
// 서비스 재시작 시도 // 서비스 재시작 시도
val intent = Intent(this, ForeGroundService::class.java) val intent = Intent(this, ForeGroundService::class.java)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {