Skip to content
forked from whataa/pandora

an android library for debugging what we care about directly in app.

License

Notifications You must be signed in to change notification settings

miaoyanrssq/pandora

 
 

Repository files navigation

an android library for debugging what we care about directly in app.

[点击查看中文版]

Pandora API platform License Build Status

Pandora is a tool box that allows you to inspect and modify what includes networks, databases, UIs, etc. directly in your application. It is suitable for rapid position of various problems in the development and testing stages.

Feature

  • Inspect the detailed log of each network request, such as headers, response, etc.

  • View the internal storage system of own app;

  • View all databases, and support ADD, DELETE, UPDATE, QUERY operations;

  • View and edit all Shared Preference;

  • Preview the current view Hierarchy, and can view/modify the properties of widgets;

  • Measure the distance between the views and detect whether the alignment is correct

  • You can select any view on the Activity to move the position, get the size of itself, display the relative relationship;

  • More features look forward to you exploring;

Some of the effects are as follows:

The display pictures are: network, database, UI, file

image image

image image

Set-up

  1. Add the JitPack repository to your root build file:
allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
  1. Add the dependency to your app build.gradle (please use the latest version):
dependencies {
    ...
    debugImplementation 'com.github.whataa:pandora:${RELEASE}'
    releaseImplementation 'com.github.whataa:pandora-no-op:${RELEASE}'
}  

the latest version name, Please check the RELEASE for specific updates.

library name release version
pandora Release
pandora-no-op Release

Usage

Now, without adding any code, you can start using it directly in the app by shaking the device.

Pandora will display the function panel in the form of a floating window, so it needs the "floating window" permission, please open it manually.

By default, Pandora is opened with a "shake", if this feature conflicts with your application, you can turn it off in the settings of the panel and then implement your own trigger method invoking the following code to open the function panel:

Pandora.get().open();

If your project uses OKHttp as the underlying network library, you can add the following interceptor to enable the function of the network debugging module:

Note: Please use Pandora as the last interceptor to prevent request-headers and request-params from getting;

new OkHttpClient.Builder()
    ...
    .addInterceptor(xxx)
    .addInterceptor(Pandora.get().getInterceptor())
    .build()

Extended features

Inspect the View property

Pandora supports viewing and partially modifying the properties of View, ViewGroup, and common TextView and ImageView by default. If you want to inspect more view attributes, you can expand them in the following ways:

  1. implement tech.linjiang.pandora.inspector.attribute.IParser interface and specify the type of View that you are interested in. Here is an example of an already implemented ImageView:
public class ImageViewParser implements IParser<ImageView> {

    @Override
    public List<Attribute> getAttrs(ImageView view) {
        List<Attribute> attributes = new ArrayList<>();
        // Add the property of interest and return
        Attribute scaleTypeAttribute = new Attribute("scaleType", scaleTypeToStr(view.getScaleType()), Attribute.Edit.SCALE_TYPE);
        attributes.add(scaleTypeAttribute);
        return attributes;
    }
    ...
}
  1. Add new Parser to Pandora:
Pandora.get().getAttrFactory().addParser(new ImageViewParser());

After this, every time you click on the ImageView, the property list will automatically enumerate the values of the properties we are interested in.。

Inspect Shared Preference

Pandora reads by default the XML file in the default SP path in the application(data/data/<package-name>/shared_prefs/),If there exist other SP files that are not in the default path, they can be extended in the following ways:

  1. implement tech.linjiang.pandora.preference.protocol.IProvider interface,and return the corresponding file list:

(Specific details can refer to the default implementation in the librarySharedPrefProvider)

  1. Add new Provider to Pandora:
Pandora.get().getSharedPref().addProvider(new XXProvider());

Limit

  • Minimum supported Android SDK version is 14

  • Network debugging module: only supports the network library with OKHttp 3.x as the underlying network library;

  • Database debugging module: Only SQLite-based databases are supported, and viewing encrypted databases is temporarily not supported;

  • others;

Thanks

Pandora was developed on the shoulders of giants. Thanks to the following open source projects:

  • Inspired by Flipboard's open source iOS platform debugging tool FLEX

  • Project database module ideas and part of the source code from Facebook's open source project stetho

  • The idea of selecting views in the UI module of the project and part of the source code from eleme's open source project UETool

  • The request API in the Demo module comes from jgilfelt's open source project chuck

License

Apache-2.0

About

an android library for debugging what we care about directly in app.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%