Skip to content

Commit

Permalink
v5.0.3发布,优化了Andriod端Demo。
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack Jiang committed Oct 16, 2020
1 parent 142cb73 commit 12d74f8
Show file tree
Hide file tree
Showing 37 changed files with 697 additions and 14 deletions.
Binary file modified demo_binary/TCP_Client/MobileIMSDKDemo-Android(TCP).apk
Binary file not shown.
Binary file modified demo_binary/UDP_Client/MobileIMSDKDemo-Andriod(UDP).apk
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion demo_src/TCP_Client/MobileIMSDK4aDemo_tcp/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ android {
minSdkVersion 14
targetSdkVersion 29
versionCode 104
versionName "v5.0b201015.3"
versionName "v5.0.3b201016.2"
//testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": 1,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "net.x52im.mobileimsdk.android.demo_tcp",
"variantName": "release",
"elements": [
{
"type": "SINGLE",
"filters": [],
"properties": [],
"versionCode": 104,
"versionName": "v5.0.3b201016.2",
"enabled": true,
"outputFile": "app-release.apk"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,23 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Observable;
import java.util.Observer;

import net.x52im.mobileimsdk.android.ClientCoreSDK;
import net.x52im.mobileimsdk.android.core.AutoReLoginDaemon;
import net.x52im.mobileimsdk.android.core.KeepAliveDaemon;
import net.x52im.mobileimsdk.android.core.LocalDataSender;
import net.x52im.mobileimsdk.android.core.QoS4ReciveDaemon;
import net.x52im.mobileimsdk.android.core.QoS4SendDaemon;
import net.x52im.mobileimsdk.android.demo.service.GeniusService;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.graphics.Color;
import android.graphics.drawable.AnimationDrawable;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.IBinder;
Expand All @@ -43,6 +50,7 @@
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
Expand All @@ -63,6 +71,7 @@ public class MainActivity extends AppCompatActivity
private EditText editId = null;
private EditText editContent = null;
private TextView viewStatus = null;
private ImageView imgStatus = null;
private TextView viewMyid = null;
private Button btnSend = null;

Expand All @@ -86,6 +95,19 @@ protected void onCreate(Bundle savedInstanceState)
// Andriod系统上进程保活和网络保活,此服务与SDK本身无关,也不是必须的)
doBindService();
}

/**
* Activity每次从后台回到前台时调用本方法。
*/
protected void onResume()
{
super.onResume();

// just for debug START
// Refresh MobileIMSDK background status to show
this.refreshMobileIKSDKThreadStatusForDEBUG();
// just for debug END
}

/**
* 捕获back键,实现调用 {@link #doExit()}方法.
Expand Down Expand Up @@ -123,6 +145,7 @@ private void initViews()
editId = (EditText)this.findViewById(R.id.id_editText);
editContent = (EditText)this.findViewById(R.id.content_editText);
viewStatus = (TextView)this.findViewById(R.id.status_view);
imgStatus = (ImageView)this.findViewById(R.id.status_iconView);
viewMyid = (TextView)this.findViewById(R.id.myid_view);

chatInfoListView = (ListView)this.findViewById(R.id.demo_main_activity_layout_listView);
Expand All @@ -132,6 +155,10 @@ private void initViews()
this.viewMyid.setText(ClientCoreSDK.getInstance().getInstance().getCurrentLoginUserId());

this.setTitle("MobileIMSDK TCP v5 Demo");

// just for debug START
this.initObserversForDEBUG();
// just for debug END
}

private void initListeners()
Expand Down Expand Up @@ -171,7 +198,16 @@ private void initOthers()
public void refreshMyid()
{
boolean connectedToServer = ClientCoreSDK.getInstance().isConnectedToServer();
this.viewStatus.setText(connectedToServer ? "通信正常":"连接断开");
if(connectedToServer) {
this.viewStatus.setText("通信正常");
this.viewStatus.setTextColor(getResources().getColor(R.color.common_light_green));
this.imgStatus.setImageResource(R.drawable.green);
}
else{
this.viewStatus.setText("连接断开");
this.viewStatus.setTextColor(getResources().getColor(R.color.common_light_red));
this.imgStatus.setImageResource(R.drawable.gray);
}
}

private void doSendMessage()
Expand Down Expand Up @@ -409,4 +445,60 @@ protected void doUnbindService()
}
}
//--------------------------------------------------------------- 前台服务相关代码 END

//--------------------------------------------------------------- just for debug START
/* 以下代码用于DEBUG时显示各种SDK里的线程状态状态 */

private void refreshMobileIKSDKThreadStatusForDEBUG()
{
this.showDebugStatusImage(AutoReLoginDaemon.getInstance().isAutoReLoginRunning()?1:0
, findViewById(R.id.demo_main_activity_layout_autoLoginFlagIV));
this.showDebugStatusImage(KeepAliveDaemon.getInstance().isKeepAliveRunning()?1:0
, findViewById(R.id.demo_main_activity_layout_keepAliveFlagIV));
this.showDebugStatusImage(QoS4SendDaemon.getInstance().isRunning()?1:0
, findViewById(R.id.demo_main_activity_layout_qosSendFlagIV));
this.showDebugStatusImage(QoS4ReciveDaemon.getInstance().isRunning()?1:0
, findViewById(R.id.demo_main_activity_layout_qosReceiveFlagIV));
}

private void initObserversForDEBUG()
{
AutoReLoginDaemon.getInstance().setDebugObserver(
createObserverCompletionForDEBUG(findViewById(R.id.demo_main_activity_layout_autoLoginFlagIV)));
KeepAliveDaemon.getInstance().setDebugObserver(
createObserverCompletionForDEBUG(findViewById(R.id.demo_main_activity_layout_keepAliveFlagIV)));
QoS4SendDaemon.getInstance().setDebugObserver(
createObserverCompletionForDEBUG(findViewById(R.id.demo_main_activity_layout_qosSendFlagIV)));
QoS4ReciveDaemon.getInstance().setDebugObserver(
createObserverCompletionForDEBUG(findViewById(R.id.demo_main_activity_layout_qosReceiveFlagIV)));
}

private Observer createObserverCompletionForDEBUG(ImageView iv)
{
return (o, arg) -> {
if(arg != null) {
int status = (int) arg;
showDebugStatusImage(status, iv);
}
};
}

private void showDebugStatusImage(int status , ImageView iv)
{
if(iv.getVisibility() == View.INVISIBLE || iv.getVisibility() == View.GONE)
iv.setVisibility(View.VISIBLE);

// 持续运行中
if(status == 1)
iv.setImageResource(R.drawable.green);
// 单次执行
else if(status == 2) {
iv.setImageResource(R.drawable.thread_live_anim);
((AnimationDrawable) iv.getDrawable()).start();
}
// 已停止
else
iv.setImageResource(R.drawable.gray);
}
//--------------------------------------------------------------- just for debug END
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void onLoginResponse(int errorCode)
if(this.mainGUI != null)
{
this.mainGUI.refreshMyid();
this.mainGUI.showIMInfo_green("IM服务器登录/重连成功,errorCode="+errorCode);
// this.mainGUI.showIMInfo_green("IM服务器登录/重连成功,errorCode="+errorCode);
}
}
else
Expand Down Expand Up @@ -95,7 +95,7 @@ public void onLinkClose(int errorCode)
if(this.mainGUI != null)
{
this.mainGUI.refreshMyid();
this.mainGUI.showIMInfo_red("与IM服务器的连接已断开, 自动登陆/重连将启动! ("+errorCode+")");
// this.mainGUI.showIMInfo_red("与IM服务器的连接已断开, 自动登陆/重连将启动! ("+errorCode+")");
}
}

Expand Down
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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:apk="http://schemas.android.com/apk/res/android" apk:oneshot="true">
<item apk:drawable="@drawable/green_light" apk:duration="250" />
<item apk:drawable="@drawable/green" apk:duration="250" />
</animation-list>
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:orientation="horizontal"
android:gravity="center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand All @@ -30,14 +31,23 @@
android:textColor="#666666"
android:textSize="14sp" />

<ImageView
android:id="@+id/status_iconView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/gray"
android:layout_marginRight="5dp"
/>

<TextView
android:id="@+id/status_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="未连接"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#ff00ff"
android:textColor="@color/common_light_red"
android:textSize="14sp" />

</LinearLayout>

<LinearLayout
Expand Down Expand Up @@ -166,6 +176,82 @@
android:scaleType="fitXY"
android:src="@drawable/dashed_line" />

<!-- 用于Debug的线程动态的各种指示图标 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
android:paddingLeft="5dp"
android:layout_marginBottom="5dp">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="线程动态:"
android:textColor="#007AFF"
android:textSize="12sp" />

<ImageView
android:id="@+id/demo_main_activity_layout_autoLoginFlagIV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/gray"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="重连线程"
android:textColor="#AAAAAA"
android:layout_marginLeft="2dp"
android:textSize="12sp" />

<ImageView
android:id="@+id/demo_main_activity_layout_keepAliveFlagIV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/gray"
android:layout_marginLeft="7dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="心跳线程"
android:textColor="#AAAAAA"
android:layout_marginLeft="2dp"
android:textSize="12sp" />

<ImageView
android:id="@+id/demo_main_activity_layout_qosSendFlagIV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/gray"
android:layout_marginLeft="7dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="送达保证(发)"
android:textColor="#AAAAAA"
android:layout_marginLeft="2dp"
android:textSize="12sp" />

<ImageView
android:id="@+id/demo_main_activity_layout_qosReceiveFlagIV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/gray"
android:layout_marginLeft="7dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="送达保证(收)"
android:textColor="#AAAAAA"
android:layout_marginLeft="2dp"
android:textSize="12sp" />
</LinearLayout>

<ListView
android:id="@+id/demo_main_activity_layout_listView"
android:layout_width="fill_parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@
<color name="colorText">#353535</color>
<color name="colorTextHint">#aaaaaa</color>

<color name="common_light_green">#42c958</color>
<color name="common_light_red">#FF00FF</color>

</resources>
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion demo_src/UDP_Client/MobileIMSDK4aDemo_udp/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ android {
minSdkVersion 14
targetSdkVersion 29
versionCode 105
versionName "v5.0b201015.1"
versionName "v5.0.3b201016.1"
//testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": 1,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "net.x52im.mobileimsdk.android.demo_udp",
"variantName": "release",
"elements": [
{
"type": "SINGLE",
"filters": [],
"properties": [],
"versionCode": 105,
"versionName": "v5.0.3b201016.1",
"enabled": true,
"outputFile": "app-release.apk"
}
]
}
Loading

0 comments on commit 12d74f8

Please sign in to comment.