02 SDK集成
**SDK集成**
# 接入准备
- 下载最新的sdk demo包(**sdk的minSdkVersion 16, 仅支持arm64-v8a和armeabi-v7a平台**),
- Demo中已实现了签批的基本功能(安装运行前,请赋予app权限),
[下载地址1](https://wellsign-soft.oss-cn-beijing.aliyuncs.com/sdko/android/wellsign_sdk_offline_demo.zip) [下载地址2(androidx)](https://wellsign-soft.oss-cn-beijing.aliyuncs.com/sdko/android/wellsign_sdk_offline_demox.zip)
- 在搭建好并成功授权的[sdk控制台](doc:Bwib6juL)中,创建应用,获取应用id和应用secret[(sdk授权用)](doc:kd3qOl0o)
- 参照sdk demo将签字插件集成进自身项目
- 调用安卓sdk提供接口,自定义实现需要的功能
# 配置项目修改
## 1. jar包以及aar文件接入
将好签aar拷贝到 **项目\libs** 目录下。
## 2. build.gradle修改
须在gradle的dependencies项中加入以下依赖:
```
implementation 'com.android.support:support-vector-drawable:27.1.1'
implementation 'com.mylhyl:acp:1.1.7'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.34'
implementation 'com.githang:status-bar-compat:0.7'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:multidex:1.0.+'
//glide相关, sdk不包含glide包,可指定 ≧ 4.0.0
implementation 'com.github.bumptech.glide:glide:4.7.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
// 阿里json
implementation 'com.alibaba:fastjson:1.2.76'
implementation 'com.squareup.okhttp3:okhttp:3.2.0'
// 缩略图上拉刷新控件
implementation 'com.github.anzaizai:EasyRefreshLayout:1.3.1'
implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.1'
//sqlite 数据库相关
implementation 'net.zetetic:android-database-sqlcipher:4.4.3@aar'
implementation "androidx.sqlite:sqlite:2.0.1"
```
## 3. Manifest.xml文件
### 3.1 添加手机存储、相机资源访问权限:
```
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.CAMERA" />
```
### 3.2 添加FileProvider支持
将文件夹中xml目录拷贝到工程res文件夹下,并在AndroidManifest.xml文件中添加如下信息。
其中packagename为提供的包名。(如不设置,会导致好签SDK打开相册,相机失败)
```
<provider android:name="android.support.v4.content.FileProvider"
android:authorities="{packagename}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/filepaths" />
</provider>
```
须在代码中调用接口
```
WellSign.setHQFileProvider({packagename}.fileprovider);
```
## 4. 布局文件引入插件
在APP的界面的布局文件.xml 中引入好签的View
**代码示例:**
```
<!--展示pdf的view-->
<com.nj.wellsign.sdk.verticalScreen.hq.display.WSPDFView
android:id="@+id/pdfview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/ll_edit"
android:layout_below="@id/rl_title_hq">
//页码展示
<TextView
android:id="@+id/tv_page_number_view"
android:layout_width="wrap_content"
android:layout_height="@dimen/dp_18"
android:gravity="center"
android:layout_centerHorizontal="true"
android:layout_marginBottom="@dimen/dp_64"
android:layout_alignParentBottom="true"
android:textSize="@dimen/sp_13"
android:visibility="visible"
android:background="@mipmap/bg_page_number"/>
</com.nj.wellsign.sdk.verticalScreen.hq.display.WSPDFView>
```
## 5. APP打包
须在proguard混淆设置里**排除**好签SDK,参考以下设置:
```
-dontwarn com.nj.wellsign.sdk.**
-keep class com.nj.wellsign.sdk.** {*;}
```