Pārlūkot izejas kodu

宿舍版本主机修改:
1.主界面增加版本号显示
2.再次确认,历史通话记录中去掉回拨功能
3.优化WiFi网络断开重连,若WiFi连接失败则等待30s后再次重连

weizhengliang 6 mēneši atpakaļ
vecāks
revīzija
692a95df0a

+ 1 - 3
android_host/src/main/java/com/wdkl/ncs/android/component/nursehome/activity/CallingHostActivationActivity.kt

@@ -135,9 +135,7 @@ class CallingHostActivationActivity : BaseActivity<DevicePresenter, CallinghostA
 
         //检查网络情况,如果当前打开wifi但是未连接wifi则尝试主动连接wifi(为了解决Android高版本在连接非internet网络时无法自动连接问题)
         if (BuildConfig.flag.equals(Constant.DEV_W_KAER)) {
-            Thread {
-                NetworkUtils.checkNetworkConnect(BaseApplication.appContext)
-            }.start()
+            NetworkUtils.checkNetworkConnect(BaseApplication.appContext)
         }
 
         showUI()

+ 4 - 7
android_host/src/main/java/com/wdkl/ncs/android/component/nursehome/activity/NurseHome2Activity.kt

@@ -288,6 +288,8 @@ class NurseHome2Activity  : BaseActivity<NurseHomeActivityPresenter, NurseMainDo
             title_layout_tv_hl_point.visibility = View.GONE
         }
 
+        tv_version_name.text = "V" + BuildConfig.VERSION_NAME
+
         Constant.offlineMap.clear()
 
 
@@ -2129,9 +2131,7 @@ class NurseHome2Activity  : BaseActivity<NurseHomeActivityPresenter, NurseMainDo
                 if (!Constant.TCP_CONNECTED) {
                     //tcp连接断开,判断是否因为wifi断开导致,如果是则尝试重连
                     if (BuildConfig.flag.equals(Constant.DEV_W_KAER)) {
-                        Thread {
-                            NetworkUtils.checkNetworkConnect(BaseApplication.appContext)
-                        }.start()
+                        NetworkUtils.checkNetworkConnect(BaseApplication.appContext)
                     }
                 }
             }
@@ -2226,10 +2226,7 @@ class NurseHome2Activity  : BaseActivity<NurseHomeActivityPresenter, NurseMainDo
             Constant.EVENT_WIFI_ENABLE -> {
                 //wifi打开时检查连接情况
                 if (BuildConfig.flag.equals(Constant.DEV_W_KAER)) {
-                    Thread {
-                        Thread.sleep(3000)
-                        NetworkUtils.checkNetworkConnect(BaseApplication.appContext)
-                    }.start()
+                    NetworkUtils.checkNetworkConnect(BaseApplication.appContext)
                 }
             }
 

+ 6 - 6
android_host/src/main/java/com/wdkl/ncs/android/component/nursehome/dorm/adapter/DormCallRecordsItemAdapter.kt

@@ -114,12 +114,12 @@ class DormCallRecordsItemAdapter(val activity: Activity, var data: ArrayList<Int
                             //呼出已接听
                             binding.imgCallType.setImageResource(R.drawable.ic_records_call)
                             binding.callRecordsItemTitle.text = "您邀请  " + roleName + "  语音通话,  已接听"
-                            binding.btnRecordsAction.text = "回拨"
+                            binding.btnRecordsAction.text = "通话"
                         } else {
                             //呼出未接听
                             binding.imgCallType.setImageResource(R.drawable.ic_records_miss_call)
                             binding.callRecordsItemTitle.text = "您邀请  " + roleName + "  语音通话,  未接听"
-                            binding.btnRecordsAction.text = "回拨"
+                            binding.btnRecordsAction.text = "通话"
                         }
                     } else {
                         //其他设备呼入记录
@@ -135,11 +135,11 @@ class DormCallRecordsItemAdapter(val activity: Activity, var data: ArrayList<Int
                         if (itemData.actionEnd != null && itemData.actionAccept != null) {
                             binding.imgCallType.setImageResource(R.drawable.ic_records_call)
                             binding.callRecordsItemTitle.text = roleName + "  邀请您  语音通话,  已接听"
-                            binding.btnRecordsAction.text = "回拨"
+                            binding.btnRecordsAction.text = "通话"
                         } else {
                             binding.imgCallType.setImageResource(R.drawable.ic_records_miss_call)
                             binding.callRecordsItemTitle.text = roleName + "  邀请您 语音通话,  未接听"
-                            binding.btnRecordsAction.text = "回拨"
+                            binding.btnRecordsAction.text = "通话"
                         }
                     }
 
@@ -208,7 +208,7 @@ class DormCallRecordsItemAdapter(val activity: Activity, var data: ArrayList<Int
                 binding.btnRecordsAction.setOnClickListener {
                     if (TcpType.VOICE.name == itemData.actionType || TcpType.VIDEO.name == itemData.actionType) {
                         //拨打语音
-                        if (itemData.fromDeviceId == Constant.DEVICE_ID) {
+                        /*if (itemData.fromDeviceId == Constant.DEVICE_ID) {
                             //自己呼出的,再次呼出
                             if (!TextUtils.isEmpty(itemData.data)) {
                                 val roleType = JSON.parseObject(itemData.data).getString("roleType")
@@ -225,7 +225,7 @@ class DormCallRecordsItemAdapter(val activity: Activity, var data: ArrayList<Int
                         } else {
                             //对方呼入,直接呼叫对方
                             actionClickListener?.onCallDevice(itemData.fromDeviceId)
-                        }
+                        }*/
                     } else if (TcpType.IM.name == itemData.actionType) {
                         showMessage("播放语音")
                         MediaPlayHelper.getInstance().stopMusic(false)

+ 50 - 26
android_host/src/main/java/com/wdkl/ncs/android/component/nursehome/util/NetworkUtils.java

@@ -12,9 +12,9 @@ import android.net.wifi.WifiInfo;
 import android.net.wifi.WifiManager;
 import android.util.Log;
 
-import com.wdkl.ncs.android.component.nursehome.settingconfig.SettingConfig;
-
 import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 
 @SuppressLint("NewApi")
 public class NetworkUtils {
@@ -69,6 +69,8 @@ public class NetworkUtils {
 
     private static boolean checkNetConnection = false;
 
+    private final static ExecutorService threadPool = Executors.newSingleThreadExecutor();
+
     /**
      * >= Android 10(Q版本)推荐
      *
@@ -256,7 +258,7 @@ public class NetworkUtils {
 
 
     //连接wifi,优先preferSSID
-    public static void connectWifi(Context context, String preferSSID) {
+    public static boolean connectWifi(Context context, String preferSSID) {
         try {
             WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
             //扫描wifi
@@ -290,7 +292,7 @@ public class NetworkUtils {
                             boolean connect = wifiManager.enableNetwork(wifiConfiguration.networkId, true);
                             Log.e(TAG, "connect wifi: " + connect);
                             if (connect) {
-                                return;
+                                return true;
                             }
                         }
                     }
@@ -299,31 +301,53 @@ public class NetworkUtils {
         } catch (Exception e) {
             e.printStackTrace();
         }
+
+        return false;
     }
 
-    public static void checkNetworkConnect(Context context) {
-        if (checkNetConnection) {
-            Log.e(TAG, "正在检查网络连接...");
-            return;
-        }
+    public static void checkNetworkConnect(final Context context) {
+        threadPool.execute(() -> {
+            if (checkNetConnection) {
+                Log.e(TAG, "正在检查网络连接状态...");
+            } else {
+                checkNetConnection = true;
+                boolean connected = false;
+                if (NetworkUtils.isNetConnection(context)) {
+                    //网络连接正常,返回
+                    connected = true;
+                    Log.e(TAG, "network available...");
+                    /*if (NetworkUtils.getNetworkInfoType(context) == ConnectivityManager.TYPE_WIFI) {
+                        String wifiSSID = NetworkUtils.getConnectWifi(context);
+                        SettingConfig.setWifiSSID(context, wifiSSID);
+                    }*/
+                } else {
+                    //无网络连接,判断是否开启了wifi,如开启了则尝试自动连接
+                    boolean wifiState = NetworkUtils.getWifiStatus(context);
+                    if (wifiState) {
+                        //wifi扫描需要时间,延迟3s后再连接
+                        try {
+                            Thread.sleep(3000);
+                        } catch (Exception e) {
+                            //
+                        }
+                        connected = NetworkUtils.connectWifi(context, "");
+                    }
+                    Log.e(TAG, "network unavailable...wifiState: " + wifiState + ", connected: " + connected);
+                }
 
-        checkNetConnection = true;
-        if (NetworkUtils.isNetConnection(context)) {
-            //网络连接正常,返回
-            Log.e(TAG, "network available...");
-            /*if (NetworkUtils.getNetworkInfoType(context) == ConnectivityManager.TYPE_WIFI) {
-                String wifiSSID = NetworkUtils.getConnectWifi(context);
-                SettingConfig.setWifiSSID(context, wifiSSID);
-            }*/
-        } else {
-            //无网络连接,判断是否开启了wifi,如开启了则尝试自动连接
-            boolean wifiState = NetworkUtils.getWifiStatus(context);
-            Log.e(TAG, "network unavailable..." + wifiState);
-            if (wifiState) {
-                NetworkUtils.connectWifi(context, "");
-            }
-        }
+                checkNetConnection = false;
 
-        checkNetConnection = false;
+                if (!connected) {
+                    Log.e(TAG, "wifi not connect, wait 30s try again...");
+                    try {
+                        Thread.sleep(30000);
+                    } catch (Exception e) {
+                        //
+                    }
+
+                    checkNetworkConnect(context);
+                }
+            }
+        });
     }
 }

+ 16 - 5
android_host/src/main/res/layout/nurse_main_dorm.xml

@@ -27,7 +27,7 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_above="@+id/dorm_iot_but"
-                android:layout_centerInParent="true"
+                android:layout_centerHorizontal="true"
                 android:layout_marginBottom="@dimen/d30"
                 android:background="@mipmap/d_main_dial" />
 
@@ -36,7 +36,7 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_above="@+id/dorm_menu_but"
-                android:layout_centerInParent="true"
+                android:layout_centerHorizontal="true"
                 android:layout_marginBottom="@dimen/d30"
                 android:background="@mipmap/d_main_br" />
 
@@ -44,11 +44,22 @@
                 android:id="@+id/dorm_menu_but"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:layout_alignParentBottom="true"
-                android:layout_centerInParent="true"
-                android:layout_marginBottom="@dimen/d30"
+                android:layout_centerHorizontal="true"
+                android:layout_above="@+id/tv_version_name"
+                android:layout_marginBottom="@dimen/d10"
                 android:background="@mipmap/d_main_menu" />
 
+            <TextView
+                android:id="@+id/tv_version_name"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_alignParentBottom="true"
+                android:layout_marginBottom="10dp"
+                android:gravity="center"
+                android:text="V--"
+                android:textColor="@color/white"
+                android:textSize="@dimen/font_size_20" />
+
         </RelativeLayout>