Skip to content

Commit 211908e

Browse files
committed
update config
1 parent 5dcbb8a commit 211908e

File tree

2 files changed

+29
-32
lines changed

2 files changed

+29
-32
lines changed

chat/src/main/java/cn/wildfire/chat/app/MyApp.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,23 @@
1818

1919
public class MyApp extends BaseApp {
2020

21+
22+
// 一定记得替换为你们自己的,ID请从BUGLY官网申请。关于BUGLY,可以从BUGLY官网了解,或者百度。
23+
public static String BUGLY_ID = "34490ba79f";
24+
2125
@Override
2226
public void onCreate() {
2327
super.onCreate();
2428
Config.validateConfig();
2529

2630
// bugly,务必替换为你自己的!!!
2731
if ("wildfirechat.cn".equals(Config.IM_SERVER_HOST)) {
28-
CrashReport.initCrashReport(getApplicationContext(), Config.BUGLY_ID, false);
32+
CrashReport.initCrashReport(getApplicationContext(), BUGLY_ID, false);
2933
}
3034
// 只在主进程初始化,否则会导致重复收到消息
3135
if (getCurProcessName(this).equals(BuildConfig.APPLICATION_ID)) {
36+
// 如果uikit是以aar的方式引入 ,那么需要在此对Config里面的属性进行配置,如:
37+
// Config.IM_SERVER_HOST = "im.example.com";
3238
WfcUIKit wfcUIKit = WfcUIKit.getWfcUIKit();
3339
wfcUIKit.init(this);
3440
wfcUIKit.setAppServiceProvider(AppService.Instance());
@@ -62,10 +68,10 @@ public static String getCurProcessName(Context context) {
6268
int pid = android.os.Process.myPid();
6369

6470
ActivityManager activityManager = (ActivityManager) context
65-
.getSystemService(Context.ACTIVITY_SERVICE);
71+
.getSystemService(Context.ACTIVITY_SERVICE);
6672

6773
for (ActivityManager.RunningAppProcessInfo appProcess : activityManager
68-
.getRunningAppProcesses()) {
74+
.getRunningAppProcesses()) {
6975

7076
if (appProcess.pid == pid) {
7177
return appProcess.processName;

uikit/src/main/java/cn/wildfire/chat/kit/Config.java

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,48 @@
22

33
import android.os.Environment;
44
import android.text.TextUtils;
5-
import android.util.Log;
65

76
/**
87
* Created by heavyrain lee on 2017/11/24.
98
*/
109

11-
public interface Config {
10+
public class Config {
1211

1312
// 仅仅是host,没有http开头,不可配置为127.0.0.1 或者 192.168.0.1
1413
// 可以是IP,可以是域名,如果是域名的话只支持主域名或www域名或im的二级域名,其它二级域名不支持!建议使用域名。
1514
// 例如:example.com或www.example.com或im.example.com是支持的;xx.example.com或xx.yy.example.com是不支持的。
16-
String IM_SERVER_HOST = "wildfirechat.cn";
15+
public static String IM_SERVER_HOST = "wildfirechat.cn";
1716

1817
// App Server默认使用的是8888端口,替换为自己部署的服务时需要注意端口别填错了
1918
// 正式商用时,建议用https,确保token安全
20-
String APP_SERVER_ADDRESS = "http://wildfirechat.cn:8888";
19+
public static String APP_SERVER_ADDRESS = "http://wildfirechat.cn:8888";
2120

22-
String ICE_ADDRESS = "turn:turn.wildfirechat.cn:3478";
23-
String ICE_ADDRESS2 = "turn:117.51.153.82:3478";
24-
String ICE_USERNAME = "wfchat";
25-
String ICE_PASSWORD = "wfchat";
21+
public static String ICE_ADDRESS = "turn:turn.wildfirechat.cn:3478";
22+
public static String ICE_ADDRESS2 = "turn:117.51.153.82:3478";
23+
public static String ICE_USERNAME = "wfchat";
24+
public static String ICE_PASSWORD = "wfchat";
2625

27-
// 一定记得替换为你们自己的,ID请从BUGLY官网申请。关于BUGLY,可以从BUGLY官网了解,或者百度。
28-
String BUGLY_ID = "34490ba79f";
29-
30-
int DEFAULT_MAX_AUDIO_RECORD_TIME_SECOND = 120;
26+
public static int DEFAULT_MAX_AUDIO_RECORD_TIME_SECOND = 120;
3127

3228
// 支持多人音视频时有效
33-
int MAX_VIDEO_PARTICIPANT_COUNT = 4;
34-
int MAX_AUDIO_PARTICIPANT_COUNT = 9;
29+
public static int MAX_VIDEO_PARTICIPANT_COUNT = 4;
30+
public static int MAX_AUDIO_PARTICIPANT_COUNT = 9;
3531

36-
String VIDEO_SAVE_DIR = Environment.getExternalStorageDirectory().getPath() + "/wfc/video";
37-
String AUDIO_SAVE_DIR = Environment.getExternalStorageDirectory().getPath() + "/wfc/audio";
38-
String PHOTO_SAVE_DIR = Environment.getExternalStorageDirectory().getPath() + "/wfc/photo";
39-
String FILE_SAVE_DIR = Environment.getExternalStorageDirectory().getPath() + "/wfc/file";
32+
public static String VIDEO_SAVE_DIR = Environment.getExternalStorageDirectory().getPath() + "/wfc/video";
33+
public static String AUDIO_SAVE_DIR = Environment.getExternalStorageDirectory().getPath() + "/wfc/audio";
34+
public static String PHOTO_SAVE_DIR = Environment.getExternalStorageDirectory().getPath() + "/wfc/photo";
35+
public static String FILE_SAVE_DIR = Environment.getExternalStorageDirectory().getPath() + "/wfc/file";
4036

41-
static void validateConfig() {
37+
public static void validateConfig() {
4238
if (TextUtils.isEmpty(IM_SERVER_HOST)
43-
|| IM_SERVER_HOST.startsWith("http")
44-
|| TextUtils.isEmpty(APP_SERVER_ADDRESS)
45-
|| (!APP_SERVER_ADDRESS.startsWith("http") && !APP_SERVER_ADDRESS.startsWith("https"))
46-
|| IM_SERVER_HOST.equals("127.0.0.1")
47-
|| APP_SERVER_ADDRESS.contains("127.0.0.1")
39+
|| IM_SERVER_HOST.startsWith("http")
40+
|| TextUtils.isEmpty(APP_SERVER_ADDRESS)
41+
|| (!APP_SERVER_ADDRESS.startsWith("http") && !APP_SERVER_ADDRESS.startsWith("https"))
42+
|| IM_SERVER_HOST.equals("127.0.0.1")
43+
|| APP_SERVER_ADDRESS.contains("127.0.0.1")
4844
) {
4945
throw new IllegalStateException("im server host config error");
5046
}
5147

52-
if (!IM_SERVER_HOST.equals("wildfirechat.cn")) {
53-
if ("34490ba79f".equals(BUGLY_ID)) {
54-
Log.e("wfc config", "二次开发一定需要将buglyId替换为自己的!!!!1");
55-
}
56-
}
5748
}
5849
}

0 commit comments

Comments
 (0)