diff --git a/Doc/android_cn_guide.md b/Doc/android_cn_guide.md index 8b137891791fe96927ad78e64b0aad7bded08bdc..5a298e41ba143310af3c4df8dd4717fb9bf4ef5a 100644 --- a/Doc/android_cn_guide.md +++ b/Doc/android_cn_guide.md @@ -1 +1,86 @@ +## How To Use +### 1: Gradle依赖 + +``` +debugImplementation 'com.didichuxing.doraemonkit:doraemonkit:0.0.1' +``` + +Tip: 只在Debug环境中进行集成,不要带到线上。有一些hook操作会污染线上代码。 + +### 2: 使用DoraemonKit内置工具集的接入方式 + +在App启动的时候添加一下代码 + +``` +@Override +public void onCreate() { + DoraemonKit.install(application) + + // 需要H5任意门功能时 + DoraemonKit.setWebDoorCallback(new WebDoorManager.WebDoorCallback() { + @Override + public void overrideUrlLoading(String s) { + // 使用自己的H5容器打开这个链接 + } + ... +} +``` + +通过以上步骤你就可以使用DorameonKit所有的内置工具集合。如果你想把自己与业务相关的一些工具代码加入到DoraemonKit中做统一管理的话,你可以按照3的步骤来做。 + +### 3: 添加自定义测试模块到Doraemon面板中(非必要) + +比如我们要在Doraemon面板中添加一个环境切换的功能。 + +第一步:新建一个类,实现IKit的接口,该接口描述哆啦A梦面板中的一个组件。 + +比如以代驾司机端为例,点击按钮之后会进入环境切换页面。 + +``` +public class EnvSwitchKit implements IKit { + @Override + public int getCategory() { + return Category.BIZ; + } + + @Override + public int getName() { + return R.string.bh_env_switch; + } + + @Override + public int getIcon() { + return R.drawable.bh_roadbit; + } + + @Override + public void onClick(Context context) { + DebugService service = ServiceManager.getInstance().getService(context, DebugService.class); + PageManager.getInstance().startFragment(service.getContainer(), EnvSwitchFragment.class); + } + + @Override + public void onInit(Context context) { + + } +} +``` + +第二步: 在Doraemon初始化的地方添加第一步中添加的“环境切换”插件 + +``` +@Override +public void onCreate() { + kits.add(new EnvSwitchKit()); + DoraemonKit.install(application, kits); + } + ... +@Override +public void onCreate() { + List kits = new ArrayList<>(); + kits.add(new EnvSwitchKit()); + DoraemonKit.install(application, kits); + ... +} +``` \ No newline at end of file diff --git a/Doc/android_en_guide.md b/Doc/android_en_guide.md index 8b137891791fe96927ad78e64b0aad7bded08bdc..488f8075c3d4fde71edfe2b1c7aaf9f0a8c48b47 100644 --- a/Doc/android_en_guide.md +++ b/Doc/android_en_guide.md @@ -1 +1,86 @@ +## How To Use +### 1: Use Gradle to Get latest version of DoraemonKit + +``` +debugImplementation 'com.didichuxing.doraemonkit:doraemonkit:0.0.1' +``` + +Tip: Use DoraemonKit in debug model. + +### 2: Access method using DoraemonKit's built-in toolset + +Add code when the app starts. + +``` +@Override +public void onCreate() { + DoraemonKit.install(application) + + // If you need H5 debug + DoraemonKit.setWebDoorCallback(new WebDoorManager.WebDoorCallback() { + @Override + public void overrideUrlLoading(String s) { + // Open this link with your H5 container + } + ... +} +``` + + Through the above steps you can use all of the built-in tools of DorameonKit. If you want to add some of your customized tools, see chapter 3. + +### 3: Add a custom test module to the Doraemon panel (non-essential) + +For example, we want to add an environment switch module to the Doraemon panel. + +Step 1: create a new class, implement the interface IKit, this interface describes a test module on the panel. + +Taking our app as an example, after clicking the button, it will enter the environment switching page. + +``` +public class EnvSwitchKit implements IKit { + @Override + public int getCategory() { + return Category.BIZ; + } + + @Override + public int getName() { + return R.string.bh_env_switch; + } + + @Override + public int getIcon() { + return R.drawable.bh_roadbit; + } + + @Override + public void onClick(Context context) { + DebugService service = ServiceManager.getInstance().getService(context, DebugService.class); + PageManager.getInstance().startFragment(service.getContainer(), EnvSwitchFragment.class); + } + + @Override + public void onInit(Context context) { + + } +} +``` + +Step 2: Add the "Environment Switch" module in the step where Doraemon is installed. + +``` +@Override +public void onCreate() { + kits.add(new EnvSwitchKit()); + DoraemonKit.install(application, kits); + } + ... +@Override +public void onCreate() { + List kits = new ArrayList<>(); + kits.add(new EnvSwitchKit()); + DoraemonKit.install(application, kits); + ... +} +``` \ No newline at end of file