-
Notifications
You must be signed in to change notification settings - Fork 955
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/remove_demo_clipboard
- Loading branch information
Showing
170 changed files
with
4,139 additions
and
20,230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
<!-- docs/_sidebar.md --> | ||
* [Demo体验](development/demo.md) | ||
* [前端接入](development/web-integration.md) | ||
* [环境搭建](development/native-integration.md) | ||
* [3.0升级指引](development/3.0-upgrade-guidelines.md) | ||
* [自定义组件](development/native-component.md) | ||
* [自定义模块](development/native-module.md) | ||
* [事件](development/native-event.md) | ||
* [终端能力适配](development/native-adapter.md) | ||
* [数据类型映射](development/type-mapping.md) | ||
* [V8 API](development/v8-api.md) | ||
* [调试](development/debug.md) | ||
* [技术支持](development/support.md) | ||
* [隐私政策](development/privacy.md) | ||
- [Demo体验](development/demo.md) | ||
- 前端接入 | ||
- [Hippy React&Vue接入指引](development/react-vue-integration-guidelines.md) | ||
- [Hippy React&Vue 3.x升级指引](development/react-vue-3.0-upgrade-guidelines.md) | ||
- [Web同构接入指引](development/web-integration-guidelines.md) | ||
- 终端接入 | ||
- [Android 3.x SDK集成指引](development/android-3.0-integration-guidelines.md) | ||
- [Android 3.x SDK升级指引](development/android-3.0-upgrade-guidelines.md) | ||
- [iOS 3.x SDK集成指引](development/ios-3.0-integration-guidelines.md) | ||
- [iOS 3.x SDK升级指引](development/ios-3.0-upgrade-guidelines.md) | ||
- [Voltron/Flutter集成指引](development/voltron-flutter-integration-guidelines.md) | ||
- [自定义组件](development/native-component.md) | ||
- [自定义模块](development/native-module.md) | ||
- [事件](development/native-event.md) | ||
- [终端能力适配](development/native-adapter.md) | ||
- [数据类型映射](development/type-mapping.md) | ||
- [V8 API](development/v8-api.md) | ||
- [调试](development/debug.md) | ||
- [技术支持](development/support.md) | ||
- [隐私政策](development/privacy.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Hippy Android 3.x SDK集成指引 | ||
|
||
这篇教程,讲述了如何将 Hippy 3.x SDK 集成到一个现有的 Android 工程。 | ||
|
||
> 注:以下文档都是假设您已经具备一定的 Android 开发经验。 | ||
--- | ||
|
||
## 前期准备 | ||
|
||
- 已经安装了 JDK version>=1.7 并配置了环境变量 | ||
- 已经安装 Android Studio 最新版本 | ||
- 运行 Demo 工程前需要完成 NDK,CMAKE,gradle 与相关插件的安装 | ||
|
||
## Demo 体验 | ||
|
||
若想快速体验,可以直接基于我们的 [Android Demo](https://github.com/Tencent/Hippy/tree/v3.0-dev/framework/examples/android-demo) 来开发 | ||
|
||
## 快速接入 | ||
|
||
1. 创建一个 Android 工程 | ||
|
||
2. Maven 集成 | ||
|
||
- 查询 [Maven Central Hippy 版本](https://search.maven.org/search?q=com.tencent.hippy),其中 `hippy-release` 为 `release` 版本(不携带 `inspector`),`hippy-debug` 为 `debug` 版本 | ||
|
||
- 配置 build.gradle | ||
|
||
下面引用Hippy最新版本号可在上述链接中查询 | ||
|
||
```java | ||
// implementation 'com.tencent.hippy:hippy-debug:3.2.0-beta' | ||
implementation 'com.tencent.hippy:hippy-release:3.2.0-beta' | ||
implementation 'androidx.legacy:legacy-support-v4:1.0.0' | ||
implementation 'androidx.recyclerview:recyclerview:1.1.0' | ||
implementation 'androidx.viewpager:viewpager:1.0.0' | ||
``` | ||
|
||
3. 本地集成(可选) | ||
|
||
- [hippy-framework](https://github.com/Tencent/Hippy/tree/v3.0-dev/framework/android) 工程运行 Gradle Task `other => assembleRelease` 或者 `other => assembleDebug` 后会在 `framework/android/build/outputs/aar` 目录下生成 `release` 或者 `debug` 模式的`android-sdk.aar`,将 `android-sdk.aar` 拷贝到你项目的 `libs` 目录下。 | ||
|
||
!> 通过 `assembleRelease` task 生成的 AAR 默认不携带 `inspector` 模块,不能在前端通过 Devtools 对代码进行调试,若需要集成 `inspector`,请执行 `assembleDebug` task | ||
|
||
- 配置 build.gradle | ||
|
||
```java | ||
api (name:'android-sdk', ext:'aar') | ||
implementation 'androidx.legacy:legacy-support-v4:1.0.0' | ||
implementation 'androidx.recyclerview:recyclerview:1.1.0' | ||
implementation 'androidx.viewpager:viewpager:1.0.0' | ||
``` | ||
|
||
4. 在宿主 APP 工程中增加引擎初始化与 `hippyRootView` 挂载逻辑,具体可以参考 [Demo](https://github.com/Tencent/Hippy/tree/v3.0-dev/framework/examples/android-demo) 工程中 `HippyEngineWrapper` 实现 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
# Hippy Android 3.x SDK升级指引 | ||
|
||
> 这篇教程,主要介绍Hippy Android SDK 从2.x升级3.x版本如何进行适配以及2.x和3.x在使用上的一些差异化。 | ||
</br> | ||
--- | ||
|
||
# Maven依赖项变更 | ||
|
||
3.0 SDK集成依赖项相对2.0有所变更,开发者可以参照[Hippy Android 3.x SDK集成指引](development/android-3.0-integration-guidelines.md)更新自己工程中的依赖项。 | ||
</br> | ||
</br> | ||
|
||
# 升级基础适配项(required) | ||
|
||
1. 废弃引擎初始化参数HippyImageLoader | ||
|
||
HippyImageLoader在2.0中作为引擎初始化必设项是不合理的,在3.0中已经废弃,开发者需要在引擎初始化中移除HippyImageLoader相关的设置参数与实现。</br> | ||
3.0图片资源拉取会和其它所有IO相关的资源一样统一走VFS模块进行分发,远程网络资源请求最终会由VFS模块会分发到HttpAdapter进行处理,如果开发者需要将图片请求和其他资源请求进行区分处理,可以参照下面代码示例在自定义的HttpAdapter中Override fetch接口,通过请求参数来判断是否为图片资源的请求: | ||
|
||
```java | ||
@Override | ||
public void fetch(@NonNull final ResourceDataHolder holder, | ||
@Nullable HashMap<String, Object> nativeParams, | ||
@NonNull final VfsManager.ProcessorCallback callback) { | ||
HashMap<String, String> rp = holder.requestParams; | ||
if (rp != null && rp.containsKey(REQUEST_CONTENT_TYPE) | ||
&& rp.get(REQUEST_CONTENT_TYPE).equals(REQUEST_CONTENT_TYPE_IMAGE)) { | ||
// 这里处理图片资源请求 | ||
} else { | ||
// 这里处理其它资源的请求 | ||
} | ||
} | ||
``` | ||
|
||
2. 引擎初始化完成callback回调线程调整 | ||
|
||
2.0中initEngine初始化结果SDK内部会切换到UI线程再callback onInitialized给宿主,但我们发现在一些业务使用场景下,callback切UI线程执行可能具有很大的延迟,所以3.0中callback onInitialized直接在子线程回调并继续执行loadModule会有更好的效率。</br> | ||
在原2.0引擎初始化callback中如果有对hippyRootView挂载等相关的UI操作,需要开发者自己增加UI线程的切换逻辑来保证。 | ||
|
||
3. 引擎销毁调用方式与顺序调整 | ||
|
||
3.0中destroyModule增加了回调接口,destroyEngine需要等destroyModule执行完成回调以后才能调用,否则可能有CRASH的风险,开发者需要将2.0原有的引擎销毁逻辑按下面的代码示例进行变更: | ||
|
||
```java | ||
fun destroyEngine(hippyEngine: HippyEngine?, hippyRootView: ViewGroup?) { | ||
hippyEngine?.destroyModule(hippyRootView, | ||
Callback<Boolean> { result, e -> hippyEngine.destroyEngine() }) | ||
} | ||
``` | ||
|
||
4. HippyEngine中的接口不再直接引用HippyRootView | ||
|
||
destroyModule接口参数以及loadModule接口返回值均使用系统ViewGroup类型替代,尽量减少对SDK的耦合,开发者需要对loadModule接口返回值类型做相应的调整。 | ||
|
||
5. ModuleListener接口定义变更 | ||
开发者需要对loadModule接口参数ModuleListener做以下2点适配 | ||
- 我们发现之前2.0在onLoadCompleted回调接口中返回的root view参数其实在各多业务场景都不会去用到,所以在3.0中我们简化了这个接口,移除了root view参数的返回 | ||
- 增加onFirstViewAdded接口回调,返回第一view挂载到Hippy root view的回调时机 | ||
|
||
6. UI Component事件发送 | ||
Hippy终端事件的发送分为全局事件和UI Component事件2种,全局事件和2.0保持一致,使用HippyEngine中暴露的sendEvent接口发送,而UI Component事件的发送,开发者需要统一使用使用3.0新增工具类EventUtils中封装的事件发送接口: | ||
|
||
```java | ||
@MainThread | ||
public static void sendComponentEvent(@Nullable View view, | ||
@NonNull String eventName, | ||
@Nullable Object params); | ||
``` | ||
|
||
7. 废弃HippyInstanceContext定义及其相关实现 | ||
2.0中基于系统ContextWrapper封了Hippy自己的HippyInstanceContext,并将其作为所有Hippy view的初始化参数,随着3.0 framework和renderer两个子模块的解耦,我们发现HippyInstanceContext设计过于臃肿,已经不再适用于最新的3.0架构,所以我们在最新的3.0版本中废弃了HippyInstanceContext,改用更加轻量化的NativeRenderContext取代,所以开发者需要将自定义组件中使用到HippyInstanceContext的相关实现变更为NativeRenderContext。 | ||
</br> | ||
|
||
# 新增特性适配项(optional) | ||
|
||
1. 引擎初始化参数增加资源请求自定义processor的设置 | ||
|
||
```java | ||
public List<Processor> processors; | ||
``` | ||
|
||
关于VFS特性以及Processor接口使用的介绍可以详见 [VFS](feature/feature3.0/vfs.md)。 | ||
|
||
2. 引擎初始化参数增加ImageDecoderAdapter的设置 | ||
如果开发者有自定义格式图片的解码需求,可以在引擎初始化参数中设置ImageDecoderAdapter,ImageDecoderAdapter的具体接口描述如下: | ||
|
||
```java | ||
// 解码image原始数据,解码的结果可以通过 image data holder提供的setBitmap或者setDrawable接口 | ||
// 置到holder中,如果宿主decode adapter不处理,返回false由SDK走默认解码逻辑 | ||
boolean preDecode(@NonNull byte[] data, | ||
@Nullable Map<String, Object> initProps, | ||
@NonNull ImageDataHolder imageHolder, | ||
@NonNull BitmapFactory.Options options); | ||
|
||
// 解码结束后,宿主通过该接口回调还可以获得二次处理bitmap的机会,比如要对bitmap做高斯模糊。 | ||
void afterDecode(@Nullable Map<String, Object> initProps, | ||
@NonNull ImageDataHolder imageHolder, | ||
@NonNull BitmapFactory.Options options); | ||
|
||
// 引擎退出销毁时调用,释放adapter可能占用的资源 | ||
void destroyIfNeeded(); | ||
``` | ||
|
||
3. HippyEngine中新增render node缓存特性接口 | ||
2.0中我们支持了dom node缓存特性,但dom node缓存针对复杂页面场景性能还是存在一定的性能瓶颈,所有我们在3.0重新实现了性能更好的render node缓存特性,关于render node缓存特性与接口使用的介绍可以详见 [RenderNode Snapshot](feature/feature3.0/render-node-snapshot.md)。 | ||
|
||
4. 关于自定义UI组件的Controller中dispatchFunction参数说明 | ||
在2.0中dispatchFunction接收事件属性的参数类型为HippyArray类型,由于在2.0的后续版本中HippyMap和HippyArray就已经被标记为@Deprecated,所以在3.0的重构中,SDK内部也逐渐替换一些使用HippyMap或HippyArray类型参数的接口,所以针对Controller的dispatchFunction接口SDK内部默认替换成List类型参数 | ||
|
||
```java | ||
public void dispatchFunction(@NonNull T view, | ||
@NonNull String functionName, | ||
@NonNull List params); | ||
|
||
public void dispatchFunction(@NonNull T view, | ||
@NonNull String functionName, | ||
@NonNull List params, | ||
@NonNull Promise promise); | ||
``` | ||
|
||
为了减低3.0升级的成本原来使用HippyArray类型的接口还是保留,只是标记为@Deprecated,所以升级3.0对于原来定义的dispatchFunction接口不需要做任何修改,但建议后续升级到3.0版本定义新UI组件的时候,直接Override使用List参数类型的新接口。 |
Oops, something went wrong.