Skip to content

현재 화면의 Activity/Fragment의 클래스명을 화면에 오버레이로 표시해주는 디버그 라이브러리

License

Notifications You must be signed in to change notification settings

DongLab-DevTools/ScreenNameViewer

Repository files navigation

ScreenNameViewer

Hits Platform Min SDK

한국어 README

A debug library that overlays the class names of the current Activity and Fragment on the screen.

Overview

sample



ScreenNameViewer overlays class names directly on the screen, allowing you to instantly identify the currently visible Activity or Fragment.

This makes it easier to locate the corresponding code, speeding up debugging and improving development efficiency.


Features

  • 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

Installation

Step 1: Add GitHub Packages repository

Add the GitHub Packages repository to your project's settings.gradle.kts:

dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
		maven {
            url = uri("https://maven.pkg.github.com/DongLab-DevTools/ScreenNameViewer")

            credentials {
                username = props.getProperty("github_username")
                password = props.getProperty("github_token")
            }
        }
    }
}

Step 2: Add dependency

Add the library to your module's build.gradle.kts:

dependencies {
    implementation 'com.donglab.devtools:screennameviewer:latestVersion'
}

Step 3: Authentication

Create a gradle.properties file in your project root with your GitHub credentials:

github_username=YOUR_GITHUB_USERNAME
github_token=YOUR_GITHUB_PERSONAL_ACCESS_TOKEN

Note

You need a GitHub Personal Access Token with read:packages permission to download from GitHub Packages.


Requirements

  • Android API 21 (Android 5.0) or higher

Usage

Initialize in Application class

Set up once and all Activities and Fragments will be automatically tracked:

class MyApplication : Application() {

    override fun onCreate() {
        super.onCreate()

        initScreenNameViewer(this) {
            settings {
                debugMode { BuildConfig.DEBUG }
                enabled {
                    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
                }
            }
        }
    }
}

Configuration

DSL Configuration

You can configure the library using a simple DSL (Domain Specific Language):

initScreenNameViewer(this) {
    settings {
        debugMode { BuildConfig.DEBUG }
        enabled {
            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
        }
    }
}

Configuration Options

  • settings: Configure activation conditions

    • debugMode: Debug mode condition
    • enabled: Overlay feature activation condition
  • config: Customize overlay appearance

    • textStyle: Text size and color
    • background: Background color and padding
    • position: Margin and display positions for different components

Contributors

dongx0915
Donghyeon Kim
murjune
JUNWON LEE

About

현재 화면의 Activity/Fragment의 클래스명을 화면에 오버레이로 표시해주는 디버그 라이브러리

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages