현재 Activity와 Fragment의 클래스명을 화면에 오버레이로 표시해주는 디버그 라이브러리입니다.
ScreenNameViewer는 화면 위에 클래스명을 오버레이로 표시하여, 현재 표시 중인 화면을 즉시 확인할 수 있도록 도와줍니다.
이를 통해 원하는 화면의 코드를 빠르게 찾아 디버깅 및 개발 효율을 높일 수 있습니다.
- 실시간 클래스명 표시: Activity와 Fragment 클래스명을 화면에 실시간 표시
- 자동 생명주기 관리: Application 레벨에서 모든 Activity와 Fragment를 자동으로 추적
- 디버그 전용: Release 빌드에서는 자동으로 비활성화되어 안전
- UI 커스터마이징: 텍스트 크기, 색상, 위치 등 자유롭게 설정 가능
- 메모리 안전: WeakReference 사용으로 메모리 누수 방지
- 터치 상호작용: 오버레이 터치 시 Toast로 전체 클래스명 표시
프로젝트의 settings.gradle.kts에 Jitpack 저장소를 추가하세요:
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}모듈의 build.gradle.kts에 라이브러리를 추가하세요:
dependencies {
implementation 'com.github.DongLab-DevTools:ScreenNameViewer:latestVersion'
}- Android API 21 (Android 5.0) 이상
한 번만 설정하면 모든 Activity와 Fragment가 자동으로 추적됩니다:
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
initScreenNameViewer(this) {
settings {
debugModeCondition = BuildConfig.DEBUG
enableCondition = PreferenceManager.getDefaultSharedPreferences(this@MyApplication)
.getBoolean("debug_overlay_enabled", true)
}
config {
textStyle {
size = 12f
color = Color.WHITE
}
background {
color = Color.argb(128, 0, 0, 0)
padding = 16
}
position {
topMargin = 64
activity = Gravity.TOP or Gravity.START
fragment = Gravity.TOP or Gravity.END
composeRoute = Gravity.TOP or Gravity.END
}
}
}
}
}간단한 DSL(Domain Specific Language)을 사용하여 라이브러리를 설정할 수 있습니다:
initScreenNameViewer(this) {
settings {
debugModeCondition = BuildConfig.DEBUG
enableCondition = PreferenceManager
.getDefaultSharedPreferences(this@MyApplication)
.getBoolean("debug_overlay_enabled", true)
}
config {
textStyle {
size = 12f // Text size
color = Color.WHITE // Text color
}
background {
color = Color.argb(128, 0, 0, 0) // Background color
padding = 16 // Padding
}
position {
topMargin = 64 // Top margin
activity = Gravity.TOP or Gravity.START // Activity display position
fragment = Gravity.TOP or Gravity.END // Fragment display position
composeRoute = Gravity.TOP or Gravity.END // Compose Route display position
}
}
}-
settings: 활성화 조건 설정
debugMode: 디버그 모드 조건enabled: 오버레이 기능 활성화 조건
-
config: 오버레이 모양 커스터마이징
textStyle: 텍스트 크기와 색상background: 배경색과 패딩position: 여백과 각 컴포넌트의 표시 위치
|
Donghyeon Kim |
JUNWON LEE |
