v1.0.8 - 시스템 권한 설정 토글 시 앱 자동 즉시 복귀, 달력 상단 근무 텍스트 컬러화 및 최신 버전 확인 아이콘 개편

This commit is contained in:
sanjeok77
2026-08-14 10:10:09 +09:00
parent eb6aad8527
commit aa63d86a10
9 changed files with 116 additions and 25 deletions
@@ -17,9 +17,42 @@ import androidx.activity.ComponentActivity
import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import kotlinx.coroutines.*
object AlarmPermissionUtil {
private var monitorJob: Job? = null
/**
* 시스템 설정 화면에서 사용자가 권한을 허용했을 때 뒤로가기를 누르지 않아도 앱으로 즉시 자동 복귀시킵니다.
*/
fun monitorAndAutoReturn(activity: Activity, isGrantedCheck: () -> Boolean) {
monitorJob?.cancel()
monitorJob = CoroutineScope(Dispatchers.Main).launch {
var count = 0
while (count < 150 && isActive) { // 최대 60초간 400ms 주기로 체크
delay(400)
count++
if (isGrantedCheck()) {
try {
val returnIntent = Intent(activity, SettingsActivity::class.java).apply {
flags = Intent.FLAG_ACTIVITY_REORDER_TO_FRONT or Intent.FLAG_ACTIVITY_SINGLE_TOP
}
activity.startActivity(returnIntent)
} catch (e: Exception) {
e.printStackTrace()
}
break
}
}
}
}
fun cancelAutoReturn() {
monitorJob?.cancel()
monitorJob = null
}
/**
* 전체 권한 상태를 확인하고 필요한 경우 통합 안내 다이얼로그를 표시합니다.
*/