Skip to content

Commit bb67003

Browse files
committed
change[]: 修改android接入文档
1 parent 256a147 commit bb67003

3 files changed

Lines changed: 112 additions & 55 deletions

File tree

Doc/android-ReleaseNotes.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 1.0.5
2+
3+
1. 提供no-op版本
4+
2. 体验优化
5+
16
## 1.0.1
27

38
1. 修复资源冲突与覆盖导致的编译问题

Doc/android_cn_guide.md

Lines changed: 53 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,110 @@
1-
## How To Use
1+
## 接入方式
22

3-
### 1: Gradle依赖
3+
#### 1. Gradle依赖
44

55
```
6-
debugImplementation 'com.didichuxing.doraemonkit:doraemonkit:1.0.1'
6+
dependencies {
7+
...
8+
debugImplementation 'com.didichuxing.doraemonkit:kit:1.0.5'
9+
releaseImplementation 'com.didichuxing.doraemonkit:kit-no-op:1.0.5'
10+
...
11+
}
712
```
813

9-
Tip: 只在Debug环境中进行集成,不要带到线上。有一些hook操作会污染线上代码。
14+
最新版本参见[这里](android-ReleaseNotes)
15+
16+
1017

11-
### 2: 使用DoraemonKit内置工具集的接入方式
18+
#### 2. 初始化
1219

13-
在App启动的时候添加一下代码
20+
在App启动的时候进行初始化。
1421

1522
```
1623
@Override
1724
public void onCreate() {
25+
...
1826
DoraemonKit.install(application)
19-
20-
// 需要H5任意门功能时
27+
28+
// H5任意门功能需要,非必须
2129
DoraemonKit.setWebDoorCallback(new WebDoorManager.WebDoorCallback() {
2230
@Override
2331
public void overrideUrlLoading(String s) {
2432
// 使用自己的H5容器打开这个链接
2533
}
2634
...
35+
}
36+
```
37+
38+
39+
40+
#### 3. 流量监控功能(可选)
41+
42+
在项目的build.gradle中添加classpath。
43+
44+
```
45+
// Top-level build file where you can add configuration options common to all sub-projects/modules.
46+
47+
buildscript {
48+
dependencies {
49+
...
50+
classpath 'com.didichuxing.doraemonkit:compiler:1.0.0'
51+
...
52+
// NOTE: Do not place your application dependencies here; they belong
53+
// in the individual module build.gradle files
54+
}
2755
}
2856
```
2957

30-
通过以上步骤你就可以使用DorameonKit所有的内置工具集合。如果你想把自己与业务相关的一些工具代码加入到DoraemonKit中做统一管理的话,你可以按照3的步骤来做。
58+
在app的build.gradle中添加plugin。
59+
60+
```
61+
...
62+
apply plugin: 'com.doraemon.compiler.plugin'
63+
```
64+
3165

32-
### 3: 添加自定义测试模块到Doraemon面板中(非必要)
3366

34-
比如我们要在Doraemon面板中添加一个环境切换的功能。
67+
#### 4. 自定义功能组件(可选)
3568

36-
第一步:新建一个类,实现IKit的接口,该接口描述哆啦A梦面板中的一个组件
69+
自定义组件需要实现IKit接口,该接口对应哆啦A梦功能面板中的组件
3770

38-
比如以代驾司机端为例,点击按钮之后会进入环境切换页面
71+
以黑马乘客端为例,实现环境切换组件如下
3972

4073
```
4174
public class EnvSwitchKit implements IKit {
4275
@Override
4376
public int getCategory() {
4477
return Category.BIZ;
4578
}
46-
79+
4780
@Override
4881
public int getName() {
4982
return R.string.bh_env_switch;
5083
}
51-
84+
5285
@Override
5386
public int getIcon() {
5487
return R.drawable.bh_roadbit;
5588
}
56-
89+
5790
@Override
5891
public void onClick(Context context) {
5992
DebugService service = ServiceManager.getInstance().getService(context, DebugService.class);
6093
PageManager.getInstance().startFragment(service.getContainer(), EnvSwitchFragment.class);
6194
}
62-
95+
6396
@Override
64-
public void onInit(Context context) {
65-
97+
public void onAppInit(Context context) {
98+
6699
}
67100
}
68101
```
69102

70-
第二步: 在Doraemon初始化的地方添加第一步中添加的“环境切换”插件
103+
在初始化的时候注册自定义组件。
71104

72105
```
73106
@Override
74107
public void onCreate() {
75-
kits.add(new EnvSwitchKit());
76-
DoraemonKit.install(application, kits);
77-
}
78-
...
79-
@Override
80-
public void onCreate() {
81-
List<IKit> kits = new ArrayList<>();
82108
kits.add(new EnvSwitchKit());
83109
DoraemonKit.install(application, kits);
84110
...

Doc/android_en_guide.md

Lines changed: 54 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,110 @@
1-
## How To Use
1+
## Document
22

3-
### 1: Use Gradle to Get latest version of DoraemonKit
3+
#### 1. Dependency
44

55
```
6-
debugImplementation 'com.didichuxing.doraemonkit:doraemonkit:1.0.1'
6+
dependencies {
7+
...
8+
debugImplementation 'com.didichuxing.doraemonkit:kit:1.0.5'
9+
releaseImplementation 'com.didichuxing.doraemonkit:kit-no-op:1.0.5'
10+
...
11+
}
712
```
813

9-
Tip: Use DoraemonKit in debug model.
14+
Please use [the lastest release](android-ReleaseNotes)
15+
16+
1017

11-
### 2: Access method using DoraemonKit's built-in toolset
18+
#### 2. Install
1219

13-
Add code when the app starts.
20+
Install `DoraemonKit` in `Application::onCreate()`.
1421

1522
```
1623
@Override
1724
public void onCreate() {
25+
...
1826
DoraemonKit.install(application)
19-
20-
// If you need H5 debug
27+
28+
// for web container debug, optional
2129
DoraemonKit.setWebDoorCallback(new WebDoorManager.WebDoorCallback() {
2230
@Override
2331
public void overrideUrlLoading(String s) {
24-
// Open this link with your H5 container
32+
// use your web container open the link
2533
}
2634
...
35+
}
36+
```
37+
38+
39+
40+
#### 3. Network Monitor(Optional)
41+
42+
Add a dependency in `build.gradle` in root of host project as following.
43+
44+
```
45+
// Top-level build file where you can add configuration options common to all sub-projects/modules.
46+
47+
buildscript {
48+
dependencies {
49+
...
50+
classpath 'com.didichuxing.doraemonkit:compiler:1.0.0'
51+
...
52+
// NOTE: Do not place your application dependencies here; they belong
53+
// in the individual module build.gradle files
54+
}
2755
}
2856
```
2957

30-
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.
58+
Apply plugin in application module of `build.gradle`
59+
60+
```
61+
...
62+
apply plugin: 'com.doraemon.compiler.plugin'
63+
```
64+
3165

32-
### 3: Add a custom test module to the Doraemon panel (non-essential)
3366

34-
For example, we want to add an environment switch module to the Doraemon panel.
67+
#### 4. Custom Component(Optional)
3568

36-
Step 1: create a new class, implement the interface IKit, this interface describes a test module on the panel.
69+
Define a class implement the interface IKit,the interface describe a component in DoraemonKit panel.
3770

38-
Taking our app as an example, after clicking the button, it will enter the environment switching page.
71+
An environment switch component can be defined as following.
3972

4073
```
4174
public class EnvSwitchKit implements IKit {
4275
@Override
4376
public int getCategory() {
4477
return Category.BIZ;
4578
}
46-
79+
4780
@Override
4881
public int getName() {
4982
return R.string.bh_env_switch;
5083
}
51-
84+
5285
@Override
5386
public int getIcon() {
5487
return R.drawable.bh_roadbit;
5588
}
56-
89+
5790
@Override
5891
public void onClick(Context context) {
5992
DebugService service = ServiceManager.getInstance().getService(context, DebugService.class);
6093
PageManager.getInstance().startFragment(service.getContainer(), EnvSwitchFragment.class);
6194
}
62-
95+
6396
@Override
64-
public void onInit(Context context) {
65-
97+
public void onAppInit(Context context) {
98+
6699
}
67100
}
68101
```
69102

70-
Step 2: Add the "Environment Switch" module in the step where Doraemon is installed.
103+
Register the environment switch component when DoraemonKit installed.
71104

72105
```
73106
@Override
74107
public void onCreate() {
75-
kits.add(new EnvSwitchKit());
76-
DoraemonKit.install(application, kits);
77-
}
78-
...
79-
@Override
80-
public void onCreate() {
81-
List<IKit> kits = new ArrayList<>();
82108
kits.add(new EnvSwitchKit());
83109
DoraemonKit.install(application, kits);
84110
...

0 commit comments

Comments
 (0)