EN | 中文
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.
-
Check the detailed logs of network requests, such as headers, body, error messages, and so on.
-
Support all network libraries based on OKHTTP and Android native HttpURLConnection, covering most network development situations.
-
View the app's private storage directory, and can export files to SDcard.
-
Supports browsing and editing SQLite databases, SharedPref files.
-
View and modify properties of any Widget, such as the widget's size, color, text content, and so on.
-
Grab and move any widget, view the boundaries and relative distance between widgets, detect alignment, layout and other issues.
-
View the hierarchy of any UI, support Activity, Dialog, PopupWindow, etc.
-
Show the current Activity in real time.
-
Supports recording crash, compatible with third-party Crash libraries.
-
You can add shortcut to Pandora.
-
You can open any Activity of your app.
-
You can view the lifecycle history of Activities.
-
Declare Jitpack repository and add dependencies:
// android-support debugImplementation 'com.github.whataa:pandora:v${RELEASE}' // or androidX debugImplementation 'com.github.whataa:pandora:androidx_v${RELEASE}' // No matter android-support or AndroidX releaseImplementation 'com.github.whataa:pandora-no-op:v${RELEASE}'
library version pandora pandora-no-op -
(Optional)If your project use OKHttp as a network library, add the following interceptor to support network logging:
Pandora.get().getInterceptor();
-
Grant permission to "Overlay Windows" and shake your device.
Usually, we may hide some debugging switches in some pages to "switch the development environment", "check the Crash log" and so on. If you have similar needs, you can add a shortcut by:
-
Implement
tech.linjiang.pandora.function.IFunc
, return the icon, name and the action:private IFunc customFunc = new IFunc() { @Override public int getIcon() { return R.drawable.ic_launcher_round; } @Override public String getName() { return getString(R.string.pandora_click_me); } @Override public boolean onClick() { toast("I am the custom Function."); return false; } };
-
Call
Pandora.get().addFunc()
to add it.
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:
- 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;
}
...
}
- 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.。
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:
- 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
)
- Add new Provider to Pandora:
Pandora.get().getSharedPref().addProvider(new XXProvider());
- Check to see if the Jitpack repository is declared.
- There exists a 'v' symbol in the start of version number.
It is recommended that the Pandora interceptor be added as the last of the OKHttp interceptors.
You can call
Pandora.get().disableShakeSwitch();
to disable it, and callPandora.get().open();
to open directly.
Due to the large number of Android phones, please manually go to the permission center to check whether the permission of "overlay window" is granted.
In cases where it's hard to open, you can change the trigger factor in the "config" modify the value that works best for your phone.
Even though it is recommended to use Pandora only in the dev and test stage, enable minify can be anywhere, so add the following rules if you need it:
-keep class tech.linjiang.pandora.cache.**{*;}
Which version to implementation depends on your project, The two versions have completely consistent logic and synchronized updates, except for different dependencies. Although AndroidX is the trend, if your project cannot be migrated to AndroidX, please use android-support.
Pandora was developed on the shoulders of giants. Thanks to the following open source projects or person:
-
Logo and Icon are produced by the designer Zularizal.
-
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 ;