Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
ccim_sdk_android
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sheteng
ccim_sdk_android
Commits
a3d0a99c
Commit
a3d0a99c
authored
Oct 28, 2021
by
sheteng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
92ff0173
Changes
16
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
905 additions
and
130 deletions
+905
-130
.idea/gradle.xml
.idea/gradle.xml
+1
-1
.idea/runConfigurations.xml
.idea/runConfigurations.xml
+0
-10
app/build.gradle
app/build.gradle
+4
-1
app/src/main/java/com/ccwangluo/im/FirstFragment.java
app/src/main/java/com/ccwangluo/im/FirstFragment.java
+125
-25
app/src/main/res/layout/fragment_first.xml
app/src/main/res/layout/fragment_first.xml
+29
-26
ccim/proguard-rules.pro
ccim/proguard-rules.pro
+6
-1
ccim/src/main/java/com/ccwangluo/ccim/CCIMClient.java
ccim/src/main/java/com/ccwangluo/ccim/CCIMClient.java
+474
-0
ccim/src/main/java/com/ccwangluo/ccim/listener/MessageEventCallback.java
...ava/com/ccwangluo/ccim/listener/MessageEventCallback.java
+0
-9
ccim/src/main/java/com/ccwangluo/ccim/listener/MessageListener.java
...ain/java/com/ccwangluo/ccim/listener/MessageListener.java
+3
-0
ccim/src/main/java/com/ccwangluo/ccim/listener/ResultCallback.java
...main/java/com/ccwangluo/ccim/listener/ResultCallback.java
+6
-2
ccim/src/main/java/com/ccwangluo/ccim/listener/ResultEventCallback.java
...java/com/ccwangluo/ccim/listener/ResultEventCallback.java
+9
-0
ccim/src/main/java/com/ccwangluo/ccim/manage/CallBackManager.java
.../main/java/com/ccwangluo/ccim/manage/CallBackManager.java
+20
-6
ccim/src/main/java/com/ccwangluo/ccim/manage/SocketManageer.java
...c/main/java/com/ccwangluo/ccim/manage/SocketManageer.java
+111
-48
ccim/src/main/java/com/ccwangluo/ccim/modle/IrequestData.java
.../src/main/java/com/ccwangluo/ccim/modle/IrequestData.java
+1
-1
ccim/src/main/java/com/ccwangluo/ccim/util/MediaHelper.java
ccim/src/main/java/com/ccwangluo/ccim/util/MediaHelper.java
+114
-0
ccim/src/main/proto/chat.proto
ccim/src/main/proto/chat.proto
+2
-0
No files found.
.idea/gradle.xml
View file @
a3d0a99c
...
...
@@ -4,7 +4,7 @@
<component
name=
"GradleSettings"
>
<option
name=
"linkedExternalProjectsSettings"
>
<GradleProjectSettings>
<option
name=
"testRunner"
value=
"
PLATFORM
"
/>
<option
name=
"testRunner"
value=
"
GRADLE
"
/>
<option
name=
"distributionType"
value=
"DEFAULT_WRAPPED"
/>
<option
name=
"externalProjectPath"
value=
"$PROJECT_DIR$"
/>
<option
name=
"gradleHome"
value=
"$USER_HOME$/.gradle/wrapper/dists/gradle-3.5-all/exhrs6ca08n232b14ue48lbye/gradle-3.5"
/>
...
...
.idea/runConfigurations.xml
deleted
100644 → 0
View file @
92ff0173
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"RunConfigurationProducerService"
>
<option
name=
"ignoredProducers"
>
<set>
<option
value=
"com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer"
/>
</set>
</option>
</component>
</project>
\ No newline at end of file
app/build.gradle
View file @
a3d0a99c
...
...
@@ -7,7 +7,7 @@ android {
buildToolsVersion
"30.0.3"
defaultConfig
{
applicationId
"com.ccwangluo.
im
"
applicationId
"com.ccwangluo.
xiyuan22
"
minSdkVersion
16
targetSdkVersion
30
versionCode
1
...
...
@@ -43,4 +43,7 @@ dependencies {
testImplementation
'junit:junit:4.+'
androidTestImplementation
'androidx.test.ext:junit:1.1.2'
androidTestImplementation
'androidx.test.espresso:espresso-core:3.3.0'
compile
'com.google.protobuf:protobuf-java:3.5.1'
implementation
'com.google.protobuf:protobuf-java:3.8.0'
implementation
'com.google.protobuf:protobuf-java-util:3.8.0'
}
\ No newline at end of file
app/src/main/java/com/ccwangluo/im/FirstFragment.java
View file @
a3d0a99c
This diff is collapsed.
Click to expand it.
app/src/main/res/layout/fragment_first.xml
View file @
a3d0a99c
...
...
@@ -6,9 +6,15 @@
android:orientation=
"horizontal"
android:layout_height=
"match_parent"
tools:context=
".FirstFragment"
>
<ScrollView
android:layout_width=
"0dp"
android:layout_weight=
"1"
android:layout_height=
"match_parent"
>
<LinearLayout
android:layout_width=
"0dp"
android:layout_weight=
"1"
android:layout_width=
"match_parent"
android:orientation=
"vertical"
android:layout_height=
"match_parent"
>
...
...
@@ -18,15 +24,8 @@
android:id=
"@+id/button_login"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"
login
"
/>
android:text=
"
登录
"
/>
<Button
android:layout_marginTop=
"20dp"
android:layout_gravity=
"center_horizontal"
android:id=
"@+id/connectChatServer"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"connectChatServer"
/>
<Button
android:layout_marginTop=
"20dp"
...
...
@@ -34,7 +33,7 @@
android:id=
"@+id/getChatList"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"
getChatList
"
/>
android:text=
"
获取联系人列表
"
/>
<Button
android:layout_marginTop=
"20dp"
...
...
@@ -42,7 +41,7 @@
android:id=
"@+id/getOfflineMessage"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"
getOfflineMessage
"
/>
android:text=
"
同步离线消息
"
/>
<Button
android:layout_marginTop=
"20dp"
...
...
@@ -50,7 +49,7 @@
android:id=
"@+id/searchUser"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"
searchUser
"
/>
android:text=
"
查找好友
"
/>
<Button
android:layout_marginTop=
"20dp"
...
...
@@ -58,7 +57,7 @@
android:id=
"@+id/addUser"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"
addUser
"
/>
android:text=
"
添加好友
"
/>
...
...
@@ -68,7 +67,7 @@
android:id=
"@+id/getContactRequests"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"
getContactRequests
"
/>
android:text=
"
联系人申请列表
"
/>
<Button
android:layout_marginTop=
"20dp"
...
...
@@ -76,7 +75,7 @@
android:id=
"@+id/checkContactRequests"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"
checkContactRequests
"
/>
android:text=
"
验证联系人申请
"
/>
<Button
android:layout_marginTop=
"20dp"
...
...
@@ -84,7 +83,7 @@
android:id=
"@+id/sendTextMessage"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"
sendTextMessage
"
/>
android:text=
"
发送消息
"
/>
<Button
android:layout_marginTop=
"20dp"
...
...
@@ -92,12 +91,15 @@
android:id=
"@+id/createContactGroupRequest"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"
createContactGroup
"
/>
android:text=
"
创建联系人组
"
/>
</LinearLayout>
<
LinearLayout
</ScrollView>
<
ScrollView
android:layout_width=
"0dp"
android:layout_weight=
"1"
android:layout_height=
"match_parent"
>
<LinearLayout
android:layout_width=
"match_parent"
android:orientation=
"vertical"
android:layout_height=
"match_parent"
>
<EditText
...
...
@@ -124,7 +126,7 @@
android:id=
"@+id/moveContactGroupRequest"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"
moveContactGroup
"
/>
android:text=
"
移动联系人所在群组
"
/>
<Button
android:layout_marginTop=
"20dp"
...
...
@@ -132,7 +134,7 @@
android:id=
"@+id/deleteContact"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"
deleteContact
"
/>
android:text=
"
删除联系人
"
/>
<Button
android:layout_marginTop=
"20dp"
...
...
@@ -140,7 +142,7 @@
android:id=
"@+id/blockContact"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"
blockContact
"
/>
android:text=
"
拉黑联系人
"
/>
<Button
android:layout_marginTop=
"20dp"
...
...
@@ -148,7 +150,7 @@
android:id=
"@+id/reportIllegalUser"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"
reportIllegalUser
"
/>
android:text=
"
举报违规用户
"
/>
<Button
android:layout_marginTop=
"20dp"
...
...
@@ -156,7 +158,7 @@
android:id=
"@+id/sendGroupMessage"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"
sendGroupMessage
"
/>
android:text=
"
发送群组消息
"
/>
<Button
android:layout_marginTop=
"20dp"
...
...
@@ -164,9 +166,10 @@
android:id=
"@+id/sendChannelMessage"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"
sendChannelMessage
"
/>
android:text=
"
发送频道消息
"
/>
</LinearLayout>
</ScrollView>
</LinearLayout>
\ No newline at end of file
ccim/proguard-rules.pro
View file @
a3d0a99c
...
...
@@ -39,4 +39,9 @@
}
-
keep
class
com
.
xuhao
.
didi
.
socket
.
server
.
impl
.
OkServerOptions
$
*
{
*
;
}
\ No newline at end of file
}
-
keep
class
com
.
ccwangluo
.
ccim
.
CCClient
$
*
{
*
;
}
ccim/src/main/java/com/ccwangluo/ccim/CCClient.java
→
ccim/src/main/java/com/ccwangluo/ccim/CC
IM
Client.java
View file @
a3d0a99c
This diff is collapsed.
Click to expand it.
ccim/src/main/java/com/ccwangluo/ccim/listener/MessageEventCallback.java
deleted
100644 → 0
View file @
92ff0173
package
com.ccwangluo.ccim.listener
;
import
ccim.protocol.Chat
;
import
ccim.protocol.Push
;
public
interface
MessageEventCallback
{
// void onRecvMessage(Push)
}
ccim/src/main/java/com/ccwangluo/ccim/listener/MessageListener.java
View file @
a3d0a99c
...
...
@@ -3,5 +3,8 @@ package com.ccwangluo.ccim.listener;
import
com.xuhao.didi.core.pojo.OriginalData
;
public
interface
MessageListener
{
default
void
onServerConnect
(){
}
void
onMessageListener
(
OriginalData
data
);
}
ccim/src/main/java/com/ccwangluo/ccim/listener/ResultCallback.java
View file @
a3d0a99c
package
com.ccwangluo.ccim.listener
;
public
interface
ResultCallback
<
T
>
{
void
onSuccess
(
T
t
);
public
interface
ResultCallback
{
void
onSuccess
();
default
void
onFailed
(
int
errorCode
){
};
}
ccim/src/main/java/com/ccwangluo/ccim/listener/ResultEventCallback.java
0 → 100644
View file @
a3d0a99c
package
com.ccwangluo.ccim.listener
;
public
interface
ResultEventCallback
<
T
>
{
void
onSuccess
(
T
t
);
default
void
onFailed
(
int
errorCode
){
}
}
ccim/src/main/java/com/ccwangluo/ccim/manage/CallBackManager.java
View file @
a3d0a99c
package
com.ccwangluo.ccim.manage
;
import
com.ccwangluo.ccim.listener.ResultCallback
;
import
android.os.Handler
;
import
android.os.Looper
;
import
com.ccwangluo.ccim.listener.ResultEventCallback
;
import
java.util.HashMap
;
public
class
CallBackManager
<
T
>
{
private
HashMap
<
Integer
,
ResultCallback
<
T
>>
callbackHashMap
=
new
HashMap
<>();
private
final
HashMap
<
Integer
,
ResultEventCallback
<
T
>>
callbackHashMap
=
new
HashMap
<>();
private
final
int
time_out
=
60
*
1000
;
public
void
addCallBack
(
int
id
,
ResultCallback
<
T
>
resultCallback
)
{
callbackHashMap
.
put
(
id
,
resultCallback
);
public
synchronized
void
addCallBack
(
int
id
,
ResultEventCallback
<
T
>
resultEventCallback
)
{
callbackHashMap
.
put
(
id
,
resultEventCallback
);
//设置60秒超时
new
Handler
(
Looper
.
getMainLooper
()).
postDelayed
(()
->
{
ResultEventCallback
<
T
>
callBack
=
getCallBack
(
id
);
if
(
callBack
!=
null
){
removeCallBack
(
id
);
callBack
.
onFailed
(
999
);
}
},
time_out
);
}
public
Resul
tCallback
<
T
>
getCallBack
(
int
id
)
{
public
synchronized
ResultEven
tCallback
<
T
>
getCallBack
(
int
id
)
{
return
callbackHashMap
.
get
(
id
);
}
public
void
removeCallBack
(
int
id
)
{
public
synchronized
void
removeCallBack
(
int
id
)
{
callbackHashMap
.
remove
(
id
);
}
...
...
ccim/src/main/java/com/ccwangluo/ccim/manage/SocketManageer.java
View file @
a3d0a99c
This diff is collapsed.
Click to expand it.
ccim/src/main/java/com/ccwangluo/ccim/modle/IrequestData.java
View file @
a3d0a99c
...
...
@@ -7,7 +7,7 @@ import java.nio.ByteOrder;
public
class
IrequestData
implements
ISendable
{
private
byte
[]
body
;
private
final
byte
[]
body
;
public
IrequestData
(
byte
[]
body
){
this
.
body
=
body
;
...
...
ccim/src/main/java/com/ccwangluo/ccim/util/MediaHelper.java
0 → 100644
View file @
a3d0a99c
package
com.ccwangluo.ccim.util
;
import
android.media.MediaRecorder
;
import
android.os.Build
;
import
java.io.File
;
import
java.io.IOException
;
public
class
MediaHelper
{
private
MediaRecorder
mMediaRecorder
;
private
String
mPath
;
//文件夹
private
String
mFilePath
;
//文件
private
static
MediaHelper
mInstance
;
private
MediaHelper
(
String
path
)
{
mPath
=
path
;
}
/**
* 准备播放后的回调
* 这个时候文件夹里已经有文件生成了
* 如果不去释放资源将会一直进行录音
*/
public
interface
MediaStateListener
{
void
preparedDone
();
}
public
MediaStateListener
mMediaStateListener
;
public
void
setMediaStateListener
(
MediaStateListener
mediaStateListener
)
{
mMediaStateListener
=
mediaStateListener
;
}
/**
* 单例模式获取 MediaHelper
* 双检锁/双重校验锁
*
* @param path
* @return
*/
public
static
MediaHelper
getInstance
(
String
path
)
{
if
(
mInstance
==
null
)
{
synchronized
(
MediaHelper
.
class
)
{
if
(
mInstance
==
null
)
{
mInstance
=
new
MediaHelper
(
path
);
}
}
}
return
mInstance
;
}
/**
* 准备录音
*/
public
void
prepare
()
{
try
{
File
fileDir
=
new
File
(
mPath
);
boolean
b
=
!
fileDir
.
exists
();
if
(
b
)
{
fileDir
.
mkdirs
();
}
String
fileName
=
System
.
currentTimeMillis
()
+
".amr"
;
// 文件名字
File
file
=
new
File
(
fileDir
,
fileName
);
// 文件路径
mMediaRecorder
=
new
MediaRecorder
();
mFilePath
=
file
.
getAbsolutePath
();
//设置保存文件的路径
if
(
Build
.
VERSION
.
SDK_INT
<
26
)
{
//若api低于26,调用setOutputFile(String path)
mMediaRecorder
.
setOutputFile
(
file
.
getAbsolutePath
());
}
else
{
//若API高于26 使用setOutputFile(File path)
mMediaRecorder
.
setOutputFile
(
new
File
(
file
.
getAbsolutePath
()));
}
mMediaRecorder
.
setAudioSource
(
MediaRecorder
.
AudioSource
.
MIC
);
// 设置MediaRecorder的音频源为麦克风
mMediaRecorder
.
setOutputFormat
(
MediaRecorder
.
OutputFormat
.
AMR_NB
);
// 设置音频的格式
mMediaRecorder
.
setAudioEncoder
(
MediaRecorder
.
AudioEncoder
.
AMR_NB
);
// 设置音频的编码为AMR_NB
mMediaRecorder
.
prepare
();
mMediaRecorder
.
start
();
if
(
mMediaStateListener
!=
null
)
{
mMediaStateListener
.
preparedDone
();
}
}
catch
(
IllegalStateException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
/**
* 释放资源
*/
public
void
release
()
{
mMediaRecorder
.
stop
();
mMediaRecorder
.
release
();
mMediaRecorder
=
null
;
}
/**
* 取消
*/
public
void
cancel
()
{
release
();
//删除相应的录音
if
(
mFilePath
!=
null
)
{
File
file
=
new
File
(
mFilePath
);
if
(
file
.
exists
())
{
file
.
delete
();
}
mFilePath
=
null
;
}
}
//获取生成的文件路径
public
String
getFilePath
()
{
return
mFilePath
;
}
}
\ No newline at end of file
ccim/src/main/proto/chat.proto
View file @
a3d0a99c
...
...
@@ -133,6 +133,8 @@ message AddContactResponse {
SUCCESS
=
0
;
ALREADY_SENT
=
1
;
NO_AUTHORITY
=
2
;
ALREADY_CONTACT
=
3
;
ACCEPT_REQ
=
4
;
}
AddResult
result
=
1
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment