ScreenNameViewer is a debugging tool that overlays the class name of the currently displayed screen.
It allows you to intuitively check which screen is active, and in a Compose environment, it can also display the screen route.
This allows you to quickly find and navigate to the code for the desired screen, improving both debugging and development efficiency.
- Real-time class name display: Shows Activity and Fragment class names on screen in real-time
- Automatic lifecycle management: Automatically tracks all Activities and Fragments at the Application level
- Debug-only: Automatically disabled in release builds for safety
- UI customization: Freely configure text size, color, position, etc.
- Memory safe: Prevents memory leaks using WeakReference
- Touch interaction: Touch overlay to show full class name in toast
Add the Jitpack repository to your project's settings.gradle.kts:
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}Add the library to your module's build.gradle.kts:
dependencies {
implementation 'com.github.DongLab-DevTools:ScreenNameViewer-For-Compose:latestVersion'
}- Android API 21 (Android 5.0) or higher
Set up once and all Activities and Fragments will be automatically tracked:
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
}
}
}
}
} ScreenNameTracker(navController) {
NavHost() { /*...*/ }
}You can configure the library using a simple 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: Configure activation conditions
debugModeCondition: Debug mode conditionenableCondition: Overlay feature activation condition
-
config: Customize overlay appearance
textStyle: Text size and colorbackground: Background color and paddingposition: Margin and display positions for different components
|
Donghyeon Kim |
JUNWON LEE |
