Skip to content

rosberry/Debuggerman2

Repository files navigation

Debuggerman 2

Service-based agent providing access to configurable testing menu for single-activity applications.

Features

  • Quick access to testing menu with notification
  • Dynamic elements addition in runtime
  • Stacktrace capturing in case of application crash

Requirements

  • Java 8+
  • Android API 21+

Setup

Add a dependency

implementation 'com.rosberry.android:debuggerman2:1.0.1'

Usage

Initialization

Declare a service in application manifest:

<manifest ... >
    <application ... >

        <service android:name="com.rosberry.android.debuggerman2.service.DebugAgentService"
            android:exported="false" />
    </application>
</manifest>

Initialize agent with DebuggermanDialog (or derived) parameter in activity onCreate method:

override fun onCreate(savedInstanceState: Bundle?) {
    DebuggermanAgent.init<DebuggermanDialog>(this)

    super.onCreate(savedInstanceState)
    
    /* ... */
}

Components customization

Extend DebuggermanItem with data class that will hold custom component and corresponding adapter delegate for the dialog:

data class DebuggermanSubtitle(
    val label: String,
    override val group: String? = null
) : DebuggermanItem(DebuggermanSubtitleDelegate::class)

class DebuggermanSubtitleDelegate : DebuggermanAdapterDelegate(R.layout.item_subtitle) {

    override fun createViewHolder(parent: ViewGroup) = object : RecyclerView.ViewHolder(inflate(parent)) {}

    override fun onBindViewHolder(holder: RecyclerView.ViewHolder, item: DebuggermanItem) {
        holder.itemView.findViewById<TextView>(R.id.label)?.text = (item as? DebuggermanSubtitle)?.label
    }
}

Dialog customization

Extend DebuggermanDialog with required implementation and overridden items collection for dialog with static set of components:

class DerivedDebugDialog : DebuggermanDialog() {

    override val items: MutableList<DebuggermanItem> = mutableListOf(
        /* ... */
    )
}

or add required components dynamically.

Dynamic components addition / removal

To add, remove or replace specific item within dialog component list, use corresponding static methods of DebuggermanAgent class:

val item: DebuggermanItem = /* ... */

DebuggermanAgent.add(item)

DebuggermanAgent.remove(item)

DebuggermanAgent.replace(target, item)

Note: Since in most cases code enclosed into component's lambda will be related to some scope, don't forget to remove added items when their scope is destroying to prevent memory leaks.

About

This project is owned and maintained by Rosberry. We build mobile apps for users worldwide 🌏.

Check out our open source projects, read our blog or give us a high-five on 🐦 @rosberryapps.

License

Product Name is available under the MIT license. See the LICENSE file for more info.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages