{"id":18389347,"url":"https://github.com/rightpoint/debugmodule","last_synced_at":"2025-12-17T22:54:35.935Z","repository":{"id":25291971,"uuid":"28718048","full_name":"Rightpoint/DebugModule","owner":"Rightpoint","description":null,"archived":false,"fork":false,"pushed_at":"2015-05-11T15:19:46.000Z","size":550,"stargazers_count":22,"open_issues_count":0,"forks_count":2,"subscribers_count":38,"default_branch":"master","last_synced_at":"2025-08-09T17:43:44.217Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Rightpoint.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-02T16:02:12.000Z","updated_at":"2023-08-13T11:34:24.000Z","dependencies_parsed_at":"2022-08-24T02:30:12.048Z","dependency_job_id":null,"html_url":"https://github.com/Rightpoint/DebugModule","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Rightpoint/DebugModule","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rightpoint%2FDebugModule","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rightpoint%2FDebugModule/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rightpoint%2FDebugModule/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rightpoint%2FDebugModule/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rightpoint","download_url":"https://codeload.github.com/Rightpoint/DebugModule/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rightpoint%2FDebugModule/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27787577,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-17T02:00:08.291Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T01:42:45.588Z","updated_at":"2025-12-17T22:54:35.910Z","avatar_url":"https://github.com/Rightpoint.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Raizlabs Repository](http://img.shields.io/badge/Raizlabs%20Repository-2.1.0-blue.svg?style=flat)](https://github.com/Raizlabs/maven-releases)\n\n# DebugModule\n\nA powerful debug module that is fully pluggable, extendable, and very useful. It enables you to create your own ```Critter``` that contain\nUI elements which enable you configure your application on the fly.\n\nIt also can inject a right-facing ```DrawerLayout``` into your activity on top of\nall other content, making it very unobtrusive and accessible from __everywhere within your application__.\n\n## Getting Started\n\nAdd the library to the project-level build.gradle, using the\n[Griddle](https://github.com/Raizlabs/Griddle) plugin to simplify your build.gradle and link sources:\n\n```groovy\n\n  apply plugin: 'com.raizlabs.griddle'\n\n  dependencies {\n    mod 'com.raizlabs.android:DebugModule:2.1.0', 'debugCompile`\n  }\n\n```\n\nor by standard Gradle use (without linking sources support):\n\n```groovy\n\n  dependencies {\n    debugCompile \"com.raizlabs.android:DebugModule:2.1.0\"\n  }\n\n```\n\n### Injection\n\nIn order to make this work as expected, this section will contain how to properly ensure interaction between the ```Debugger``` and\nthe application.\n\n#### Create A Common Interface or Abstract Class\n\nThe common abstract class or interface that you include in ```src/main/java``` will ensure that our completed implementations\ncan differ between ```release``` and ```debug``` as well as allow the implementation to be uniformly used.\n\nHere is an example of a provider with ```UrlCritter``` capabilities:\n\n```java\n\npublic abstract class AppOptionsProvider {\n\n    private static CompletedAppUrlProvider provider;\n\n    /**\n     * @return The static instance of the provider. Choosing debug vs. release will pick the correct\n     * provider to use.\n     */\n    public static CompletedAppUrlProvider getProvider() {\n        if (provider == null) {\n            provider = new CompletedAppUrlProvider();\n        }\n        return provider;\n    }\n\n    /**\n     * Called in the Application class. It will perform some\n     * setup here.\n     *\n     * @param context The application context.\n     */\n    public abstract void init(Context context);\n\n    /**\n     * Attaches the debug options to the activity if its in debug mode, otherwise we do nothing.\n     *\n     * @param activity The activity that the debugger is attached to\n     */\n    public void attach(FragmentActivity activity) {\n\n    }\n\n    /**\n     * @return The URL that the app uses\n     */\n    public abstract String getConfigUrl();\n\n    /**\n     * @param activity The activity that the debugger is attached to.\n     * @return true if the CompletedAppUrlProvider consumed the event.\n     */\n    public boolean onBackPressed(FragmentActivity activity) {\n        return false;\n    }\n}\n\n```\n\n#### Implement the Abstract Class or Interface in all variants\n\nFor this example, we are relying on the ```buildType``` to implement the abstract class properly. First we will show what the\n```release``` version is expected to do (in ```src/release/java```):\n\n```java\n\n/**\n * Description: Defines the implementation for an DebugOptionsProvider for release.\n * We only return the main app endpoint.\n */\npublic class CompletedDebugOptionsProvider extends AppOptionsProvider {\n\n    private String mUrl;\n\n    @Override\n    public void init(Context context) {\n        mUrl = context.getString(R.string.Endpoint_AppConfig);\n    }\n\n    @Override\n    public String getConfigUrl() {\n        return mUrl;\n    }\n}\n\n\n```\n\nIn this case an abstract class is an advantage, since we only need to implement methods that we intend to use. Using that,\nall other methods as part of ```AppOptionsProvider``` will do nothing.\n\nHere is the ```debug``` version of the implementation. Please note that the package name and class name **must** be the same.\n\n```java\n\n/**\n * Description: Defines the implementation for an {@link DebugOptionsProvider}\n * for debug. We use the debug module to show the menu.\n */\npublic class CompletedAppUrlProvider extends AppOptionsProvider {\n\n    public static final String CRITTER_URL_NAME = \"Select App Endpoint\";\n\n    public static final String CRITTER_APP_NAME = \"Build Information\";\n\n    @Override\n    public void init(Context context) {\n        UrlCritter urlCritter = new UrlCritter(context.getString(R.string.Endpoint_AppConfig), context);\n        urlCritter.addUrlTypedArray(R.array.AppConfig_Endpoints, context);\n        Debugger.getInstance().use(CRITTER_URL_NAME, urlCritter)\n                .use(CRITTER_APP_NAME, new AppInformationCritter(BuildConfig.FLAVOR, BuildConfig.BUILD_TYPE));\n\n        urlCritter.registerUrlChangeListener(mChangeListener);\n    }\n\n    @Override\n    public void attach(FragmentActivity fragmentActivity) {\n        Debugger.getInstance().attach(fragmentActivity);\n    }\n\n    @Override\n    public String getConfigUrl() {\n        return ((UrlCritter) Debugger.getInstance().getCritter(CRITTER_URL_NAME)).getCurrentUrl();\n    }\n\n    @Override\n    public boolean onBackPressed(FragmentActivity activity) {\n        return Debugger.getInstance().onBackPressed(activity);\n    }\n\n    /**\n     * Called when URL changes\n     */\n    private final UrlCritter.UrlChangeListener mChangeListener = new UrlCritter.UrlChangeListener() {\n        @Override\n        public void onUrlChanged(String url) {\n            // URL for the app changed, do something here\n        }\n    };\n}\n\n```\n\n#### Inject the AbstractClass/Interface methods\n\n\nSince we created the common interface, now we implement the methods where we intended them to be used:\n\nIn ```Application``` we initialize the provider:\n\n```java\n\npublic class ExampleApplication extends Application {\n\n    @Override\n    public void onCreate() {\n        super.onCreate();\n        DebugOptionsProvider.getProvider().init(this);\n    }\n}\n\n\n```\n\nCreate a ```BaseActivity``` so that all our activities get access to the debugger when running the ```debug``` build variant:\n\n```java\n\npublic abstract class BaseActivity extends FragmentActivity {\n\n    @Override\n    protected void onPostCreate(Bundle savedInstanceState) {\n        super.onPostCreate(savedInstanceState);\n        DebugOptionsProvider.getProvider().attach(this);\n    }\n\n    @Override\n    public void onBackPressed() {\n        if(!DebugOptionsProvider.getProvider().onBackPressed(this)) {\n            super.onBackPressed();\n        }\n    }\n}\n\n```\n\nAnd that's it. Now you have a debugger that is only added to the ```.apk``` when running in ```debug``` variant! The release version will not contain this module at all if done properly.\n\n## Critters\n\nA ```Critter``` is the main interface for constructing a debug submenu. It, at its base, only requires specifying a UI. That UI drives how the tester can change properties in an application during runtime.\n\nWe have provided a few default ```Critter``` for URL switching and app information display.\n\n```UrlCritter```: Displays a list of URLs that a tester can select from, providing callbacks for when those change. It also enables adding custom endpoints at runtime (which are persisted in app data).\n\n```AppInformationCritter```: Displays package name, build type, build variant, app version, and more.\n\n```PreferenceCritter```: Enables dynamic changes to preferences you provide while the app is running. Instead of having to clear app data and reopen the app, you can change it within the app very easily.\n\n```DatabaseCritter```: Viewing database tables (very basically) for an app without needing to pull the sqlite file off the device or using another machine.\n\nYou can create your own custom ```Critter``` fairly easily and it is flexible on what goes into it. It is up to your __imagination__ on what you can configure at runtime for your app.\n\n### Critters\n\nHow to register to the ```Debugger```:\n\n```java\n// we register our critters here and can use any number of ones but names must remain unique\nDebugger.getInstance().use(\"critterName\", new UrlCritter(\"http://www.google.com/\", this))\n    .use(\"anotherName\", new PreferenceCritter());\n\n```\n\nHow to retrieve from the ```Debugger```:\n\n```java\n\nUrlCritter urlCritter = Debugger.getInstance().getCritter(UrlCritter.class, \"critterName\");\n\n```\n\nCheck out the currently included ```Critter```:\n\n[UrlCritter](https://github.com/Raizlabs/DebugModule/blob/master/usage/UrlCritter.md)\n\n[App Information Critter](https://github.com/Raizlabs/DebugModule/blob/master/usage/AppInformationCritter.md)\n\n[Preference Critter](https://github.com/Raizlabs/DebugModule/blob/master/usage/PrefCritter.md)\n\n[Database Browser](https://github.com/Raizlabs/DebugModule/blob/master/usage/DatabaseCritter.md)\n\n# Maintainers\n\n[agrosner](https://github.com/agrosner)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frightpoint%2Fdebugmodule","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frightpoint%2Fdebugmodule","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frightpoint%2Fdebugmodule/lists"}