Skip to content
This repository has been archived by the owner on Dec 31, 2021. It is now read-only.

Commit

Permalink
Merge pull request #25 from JoshuaYin/master
Browse files Browse the repository at this point in the history
1.3.0
  • Loading branch information
joshua.yin authored Jul 16, 2019
2 parents 6579213 + 88620f8 commit 4c213e0
Show file tree
Hide file tree
Showing 59 changed files with 2,085 additions and 855 deletions.
98 changes: 46 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,26 @@

## 运行环境
### Android
- Android系统版本:**2.3.3** (API 10) ~ **8.1** (API 27)

- Android系统版本:**4.1** (API 16)及以上

</br></br>

## 使用
### makeJar
*`SDK项目根目录`/UNetAnalysisLib/build.gradle 中有`makeJar``makeProguardJar`两个task,分别是编译普通jar和混淆后的jar
* 图解:

![avatar](http://esl-ipdd-res.cn-sh2.ufileos.com/WX20190306-155134.png)
![avatar](http://esl-ipdd-res.cn-sh2.ufileos.com/WX20190306-155422.png)

### Dependencies
NetAnalysis SDK依赖于Gson、Retrofit2.0
- 将NetAnalysisLib.jar放入项目app模块中的libs目录下,并在app模块的build.gradle的dependencies中建立依赖
- 在app模块的build.gradle的dependencies中添加

``` java
dependencies {
/**
* your other dependencies
*/
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
}
```

- 也可以下载第三方库Jar包集合:[netanalysissdk-3rd-part-jars.zip](http://ucloud-jar.cn-sh2.ufileos.com/netanalysissdk-3rd-part-jars.zip)

</br>



### 系统权限设置
以下是NetAnalysis SDK所需要的Android权限,请确保您的AndroidManifest.xml文件中已经配置了这些权限,否则,SDK将无法正常工作。
``` xml
Expand All @@ -55,18 +49,6 @@ NetAnalysis SDK依赖于Gson、Retrofit2.0
public <methods>;
}
# -------------------------------------------------------------
# Retrofit2
-keep class * extends retrofit2.Callback {
*;
}

# -------------------------------------------------------------
# Gson
-keep class com.google.gson.** {
*;
}

# -------------------------------------------------------------
# Also keep - Enumerations. Keep the special static methods that are required in
# enumeration classes.
Expand All @@ -84,6 +66,16 @@ NetAnalysis SDK依赖于Gson、Retrofit2.0
// 使用Application Context 构建UCNetAnalysisManager实例
String appKey = "UCloud为您的APP分配的APP_KEY";
String appSecret = "UCloud为您的APP分配的APP_SECRET";
/**
* 定义设置项
* new UCConfig() : 默认LogLevel.RELEASE
*/
UCConfig config = new UCConfig(UCConfig.LogLevel.DEBUG);
UCNetAnalysisManager manager = UCNetAnalysisManager.createManager(context.getApplicationContext(), appKey, appSecret, config);
// or: 使用默认new UCConfig(), Log级别RELEASE
UCNetAnalysisManager manager = UCNetAnalysisManager.createManager(context.getApplicationContext(), appKey, appSecret);
// SDK回调
Expand Down Expand Up @@ -165,7 +157,7 @@ protected void onDestroy(){
### UCNetAnalysisManager
> UNetAnalysisSDK的主要模块,你将多次使用UCNetAnalysisManager的单例对象进行SDK业务接口的操作
#### 创建UCNetAnalysisManager单例对象
#### 创建默认Config的UCNetAnalysisManager单例对象
``` java
public static UCNetAnalysisManager createManager(Context applicationContext, String appKey, String appSecret)
```
Expand All @@ -175,6 +167,17 @@ public static UCNetAnalysisManager createManager(Context applicationContext, Str
- appSecret: UCloud为您的APP分配的APP_SECRET
- **return**: UCNetAnalysisManager单例对象

#### 创建自定义Config的UCNetAnalysisManager单例对象
``` java
public static UCNetAnalysisManager createManager(Context applicationContext, String appKey, String appSecret, UCConfig config)
```
- **param**:
- applicationContext: application的context
- appKey: UCloud为您的APP分配的APP_KEY
- appSecret: UCloud为您的APP分配的APP_SECRET
- config: 设置选项,详情见**UCConfig**说明
- **return**: UCNetAnalysisManager单例对象

#### 获取UCNetAnalysisManager单例对象
``` java
public static UCNetAnalysisManager getManager()
Expand Down Expand Up @@ -377,35 +380,26 @@ public enum UCNetStatus {
```

</br></br>
### JLog
> Log打印工具
### UCConfig
> 设置选项
``` java
public class JLog {
public static boolean SHOW_DEBUG = false;
public static boolean SHOW_VERBOSE = true;
public static boolean SHOW_INFO = true;
public static boolean SHOW_WARN = true;
public static boolean SHOW_ERROR = true;

public static void D(String TAG, String info) {
// ...
}
public class UCConfig {

public static void V(String TAG, String info) {
// ...
public enum LogLevel {
TEST,
DEBUG,
RELEASE
}

public static void I(String TAG, String info) {
// ...
// 配置LogLevel
public UCConfig(UCConfig.LogLevel logLevel) {
// 构造方法
}

public static void W(String TAG, String info) {
// ...
}

public static void E(String TAG, String info) {
// ...

// 默认 LogLevel.RELEASE
public UCConfig() {
// 构造方法
}
}
```
Expand Down
13 changes: 5 additions & 8 deletions UNetAnalysisLib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import proguard.gradle.ProGuardTask
apply plugin: 'com.android.library'

android {
compileSdkVersion 26
compileSdkVersion 28

defaultConfig {
minSdkVersion 10
targetSdkVersion 26
versionCode 8
versionName "1.2.0"
targetSdkVersion 28
versionCode 9
versionName "1.3.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
Expand Down Expand Up @@ -39,13 +39,10 @@ android {

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
}


Expand Down
12 changes: 0 additions & 12 deletions UNetAnalysisLib/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,6 @@
public <methods>;
}

# -------------------------------------------------------------
# Retrofit2
-keep class * extends retrofit2.Callback {
*;
}

# -------------------------------------------------------------
# Gson
-keep class com.google.gson.** {
*;
}

# -------------------------------------------------------------
# Also keep - Enumerations. Keep the special static methods that are required in
# enumeration classes.
Expand Down
Loading

0 comments on commit 4c213e0

Please sign in to comment.