Debot


Source link: https://github.com/tomoima525/debot

Debot


A simple Android library for Debugging menu.

Debot offers a customizable debug menu for Android app development. It does not affect production code. Developers can easily add their own custom debugging features with simple steps.

How it works

If you are using an emulator, just press command + M. If you are running your dev app on a real device, shake it. The debug menu dialog will show up.

How it looks

By default, there are debug menus below.

  • Default debugging menu
  • Check Density
  • Check App ver
  • Show intent and Activity Info
  • Dev input (Automatically adds text to EditText field )

Setup

Download

Grab Debot from Gradle:

debugCompile 'com.tomoima.debot:debot:{
latest_version
}
' releaseCompile 'com.tomoima.debot:debot-no-op:{
latest_version
}
'

{ latest_version } is now :

Make sure you compile debot-no-op in the release build.

Initialization

  1. Call DebotConfigurator.configureWithDefault() at the Application's onCreate() class.
public class MyApplication extends Application {

  @Override
  public void onCreate() {

super.onCreate();

DebotConfigurator.configureWithDefault(this);

  
}
 
}
  1. Set below to any Activity you want to show the debugging menu.
public class MainActivity extends AppCompatActivity{

  Debot debot;
  @Override
  protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

debot = Debot.getInstance();

  
}

  @Override
  public boolean onKeyUp(int keyCode, KeyEvent event) {

if (keyCode == KeyEvent.KEYCODE_MENU) {

 debot.showDebugMenu(this);

}

return super.onKeyUp(keyCode, event);

  
}
  
}

 

It is preferred to put these code in your BaseActivity if you have one. That's it!

If you want the debug menu on a real device, add code below.

public class MainActivity extends AppCompatActivity{

  Debot debot;
  @Override
  protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

debot = Debot.getInstance();

debot.allowShake(getApplicationContext());
 //Make sure to use Application context, or it will leak memory
  
}

  @Override
  public boolean onKeyUp(int keyCode, KeyEvent event) {

if (keyCode == KeyEvent.KEYCODE_MENU) {

 debot.showDebugMenu(this);

}

return super.onKeyUp(keyCode, event);

  
}

@Override
  protected void onResume() {

super.onResume();

debot.startSensor(this);

  
}

@Override
  protected void onPause() {

super.onPause();

debot.stopSensor();

  
}
 
}

See the debot-sample project for more details.

Custom debugging plugins

You can create your own debugging feature by developing a class which inherits DebotStrategy.

public class MyDebotStrategy extends DebotStrategy{

  @Override
  public void startAction(@NonNull Activity activity) {

  // Do your things
  
}
 
}

Then, at the Application class, call Debot.configureWithCustomizeMenu()

public class MyApplication extends Application {

  @Override
  public void onCreate() {

super.onCreate();

DebotStrategyBuilder builder = new DebotStrategyBuilder.Builder()

  .registerMenu("My debug feature", new MyDebotStrategy())

  .build();

DebotConfigurator.configureWithCustomizeMenu(builder.getStrategyList());

  
}
 
}

Call a specific method from your Activity

If you want to call a specific method from your Activity, annotate the method with @DebotAnnotation

//Your Activity @DebotAnnotation("debugInput")  // A parameter for @DebotAnnotation should be same as the method's name public void debugInput() {

  // Do things 
}
 

Also, setup a custom debugging plugin with DebotCallActivityMethodStrategy

public class MyApplication extends Application {

  @Override
  public void onCreate() {

super.onCreate();

DebotStrategyBuilder builder = new DebotStrategyBuilder.Builder()

  .registerMenu("input", new DebotCallActivityMethodStrategy("debugInput"))

  .build();

DebotConfigurator.configureWithCustomizeMenu(this, builder.getStrategyList());

  
}
 
}
 

Usage with Kotlin project

You don't have to change any code with Kotlin project. However, you might see kotlin-stdlib error when you include Debot into your project.

Error:Conflict with dependency 'org.jetbrains.kotlin:kotlin-stdlib' in project ':app'. Resolved versions for app (1.0.2) and test app (1.1.2-4) differ. See http://g.co/androidstudio/app-test-app-conflict for  details. 

In that case, you should setup stdlib dependency explicitly. In your project's build.gradle file, add the line below:

 configurations.all {

resolutionStrategy {

 force 'org.jetbrains.kotlin:kotlin-stdlib:{
whatever the version of Kotlin you are using
}
'

}
  
}
 

See details here: https://github.com/nhaarman/mockito-kotlin/issues/146

Credit

seismic - Square, Inc.

License

Tomoaki Imai 2017 Licensed under the Apache License, Version 2.0 (the "License"). You may obtain a copy of the License at  http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.  You agree that all contributions to this repository, in the form of fixes,  pull-requests, new examples etc. follow the above-mentioned license. 

Resources

Lettrine is a library that let you display TextView with an initial first letter.

An Android time picker library.

CloudRail is a free software library which abstracts multiple APIs from different providers into a single and universal interface.

This library is a set of VIEWS (not Preferences) and is aimed to solve this problems:

  • Preferences look ugly on pre-lollipop.
  • Preferences are not flexible. For example, it can be problematic to embed them to another screen (especially for fragment-haters).
  • Preferences don't allow you to show custom selection dialogs.

A simple breadcrumb view based on the design support library's TabLayout.

A widget that can be used to confirm the user's action, unlocking the screen etc. by providing the desired pattern with specified configuration. Widget can be animated in and out.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes