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.**{*;}
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.