Skip to content

Commit

Permalink
🎉Release 1.3,对新UI页面出现串口内容添加设置项,调整代码结构和双锁机制
Browse files Browse the repository at this point in the history
  • Loading branch information
Hny0305Lin committed Jul 9, 2024
1 parent f349bb2 commit 76adb9b
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void updateUI(String processedString) {
// 如果需要存储到数据库中
if (ChatUtils.isSqlitemanager()) {
String timestamp = chatTimestamp.saveCurrentTimestamp();
if (ChatUtils.isShowUartLog()) {
if (ChatUtils.isShowUartLog() && ChatUtils.isSetDebugLog()) {
// 如果是debuglog,则分开存储
chatSaveMessageDatabaseManager.saveDebugMessageToDatabase(timestamp, processedString, "UserDebug");
} else {
Expand All @@ -53,7 +53,7 @@ public void updateUI(String processedString) {
}
// 如果需要UI滚动消息
if (ChatUtils.isScrollingMessages()) {
if (ChatUtils.isShowUartLog()) {
if (ChatUtils.isShowUartLog() && ChatUtils.isSetDebugLog()) {
if (serverDebugQueue.size() >= MAX_MESSAGES) {
serverDebugQueue.poll();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

public class ChatUtils {
//这里设置的是UI相关,是否做到消息滚动展示在UI上,而不是全部展示,全部展示会占用大量UI资源
private static boolean showUartLog = true; // 控制是否启用显示串口Log,打印在UI上(开发者使用)
private static boolean showUartLog = false; // 控制是否启用显示串口Log,这里设置是没用的(因为不是Final)
private static final boolean setDebugLog = true; // 控制是否启用显示串口Log,打印在UI上(开发者使用)
private static final boolean scrollingMessages = true; // 控制是否启用滚动消息功能
private static boolean clipMessages = true; // 控制是否启用剪贴板功能
private static final boolean uiNewOrOld = true; // 控制是否启用新UI(一般为True)
Expand All @@ -28,6 +29,8 @@ public class ChatUtils {
public static boolean isShowUartLog() { return showUartLog; }

public static void setShowUartLog(boolean showUartLog) { ChatUtils.showUartLog = showUartLog; }

public static boolean isSetDebugLog() { return setDebugLog;}
//控制是否启用滚动消息功能
public static boolean isScrollingMessages() { return scrollingMessages; }
//控制是否启用剪贴板功能和设置
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -628,11 +628,14 @@ private String CH34xProcessingForReadData(String string) {
ChatProcessorForExtract.processChat(context, completeSecondData);
}

ChatUtils.setShowUartLog(false);return completeSecondData;
ChatUtils.setShowUartLog(false);
if (!ChatUtils.isShowUartLog()) {
return completeSecondData;
}
} else if (completeFirstData.contains(ChatUtils.getPrefixLogNotConnectedServer())) {
Log.w(TAG, "串口Log内容:" + completeFirstData);
if (completeFirstData.startsWith(ChatUtils.getPrefixLogNotConnectedServer()))
if (ChatUtils.isShowUartLog())
if (ChatUtils.isSetDebugLog())
SnackBarToastForDebug(context,"发送失败!\n" + ChatUtils.getPrefixLogNotConnectedServer(),"推荐检查星闪网络",3,Snackbar.LENGTH_SHORT);
} else {
Log.d(TAG, "忽略的消息内容:" + completeFirstData);
Expand All @@ -642,33 +645,93 @@ private String CH34xProcessingForReadData(String string) {
if (completeFirstData.contains(ChatUtils.getPrefixLogConnected())) {
Log.d(TAG, "连接日志:" + completeFirstData);
// 处理连接日志
ChatUtils.setShowUartLog(true);return completeFirstData;

ChatUtils.setShowUartLog(true);
if (ChatUtils.isShowUartLog()) {
Log.d(TAG, "连接日志:" + completeFirstData + "是否显示?:" + true);
if (ChatUtils.isSetDebugLog()) {
Log.d(TAG, "连接日志:" + completeFirstData + "是否设置打开?:" + true);
return completeFirstData;
} else {
Log.d(TAG, "连接日志:" + completeFirstData + "是否设置打开?:" + false);
}
}
}
if (completeFirstData.contains(ChatUtils.getPrefixLogDisconnected())) {
Log.d(TAG, "断开连接日志:" + completeFirstData);
// 处理断开连接日志
ChatUtils.setShowUartLog(true);return completeFirstData;

ChatUtils.setShowUartLog(true);
if (ChatUtils.isShowUartLog()) {
Log.d(TAG, "断开连接日志:" + completeFirstData + "是否显示?:" + true);
if (ChatUtils.isSetDebugLog()) {
Log.d(TAG, "断开连接日志:" + completeFirstData + "是否设置打开?:" + true);
return completeFirstData;
} else {
Log.d(TAG, "断开连接日志:" + completeFirstData + "是否设置打开?:" + false);
}
}
}
if (completeFirstData.contains(ChatUtils.getPrefixLogAcore())) {
Log.d(TAG, "ACore日志:" + completeFirstData);
// 处理ACore日志
ChatUtils.setShowUartLog(true);return completeFirstData;

ChatUtils.setShowUartLog(true);
if (ChatUtils.isShowUartLog()) {
Log.d(TAG, "ACore日志:" + completeFirstData + "是否显示?:" + true);
if (ChatUtils.isSetDebugLog()) {
Log.d(TAG, "ACore日志:" + completeFirstData + "是否设置打开?:" + true);
return completeFirstData;
} else {
Log.d(TAG, "ACore日志:" + completeFirstData + "是否设置打开?:" + false);
}
}
}
//UART服务器日志,以下可以读取星闪日志
if (completeFirstData.contains(ChatUtils.getPrefixLogSleUartServer())) {
Log.d(TAG, "UART服务器日志:" + completeFirstData);
// 处理UART服务器日志
ChatUtils.setShowUartLog(true);return completeFirstData;

ChatUtils.setShowUartLog(true);
if (ChatUtils.isShowUartLog()) {
Log.d(TAG, "UART服务器日志:" + completeFirstData + "是否显示?:" + true);
if (ChatUtils.isSetDebugLog()) {
Log.d(TAG, "UART服务器日志:" + completeFirstData + "是否设置打开?:" + true);
return completeFirstData;
} else {
Log.d(TAG, "UART服务器日志:" + completeFirstData + "是否设置打开?:" + false);
}
}
}
if (completeFirstData.contains(ChatUtils.getPrefixLogConnectStateChanged())) {
Log.d(TAG, "连接状态改变日志:" + completeFirstData);
// 处理连接状态改变日志
ChatUtils.setShowUartLog(true);return completeFirstData;

ChatUtils.setShowUartLog(true);
if (ChatUtils.isShowUartLog()) {
Log.d(TAG, "连接状态改变日志:" + completeFirstData + "是否显示?:" + true);
if (ChatUtils.isSetDebugLog()) {
Log.d(TAG, "连接状态改变日志:" + completeFirstData + "是否设置打开?:" + true);
return completeFirstData;
} else {
Log.d(TAG, "连接状态改变日志:" + completeFirstData + "是否设置打开?:" + false);
}
}
}
if (completeFirstData.contains(ChatUtils.getPrefixLogPairComplete())) {
Log.d(TAG, "配对完成日志:" + completeFirstData);
// 处理配对完成日志
ChatUtils.setShowUartLog(true);return completeFirstData;

ChatUtils.setShowUartLog(true);
if (ChatUtils.isShowUartLog()) {
Log.d(TAG, "配对完成日志:" + completeFirstData + "是否显示?:" + true);
if (ChatUtils.isSetDebugLog()) {
Log.d(TAG, "配对完成日志:" + completeFirstData + "是否设置打开?:" + true);
return completeFirstData;
} else {
Log.d(TAG, "配对完成日志:" + completeFirstData + "是否设置打开?:" + false);
}
}
}
if (completeFirstData.contains(ChatUtils.getPrefixLogNearlinkDevicesAddr())) {
// 处理采集到星闪MAC地址完成日志
Expand All @@ -677,17 +740,47 @@ private String CH34xProcessingForReadData(String string) {
ChatProcessorForExtract.initializeHandler();
ChatProcessorForExtract.processChat(context, completeFirstData);
}
ChatUtils.setShowUartLog(true);return completeFirstData;

ChatUtils.setShowUartLog(true);
if (ChatUtils.isShowUartLog()) {
Log.d(TAG, "采集到星闪MAC地址日志:" + completeFirstData + "是否显示?:" + true);
if (ChatUtils.isSetDebugLog()) {
Log.d(TAG, "采集到星闪MAC地址日志:" + completeFirstData + "是否设置打开?:" + true);
return completeFirstData;
} else {
Log.d(TAG, "采集到星闪MAC地址日志:" + completeFirstData + "是否设置打开?:" + false);
}
}
}
if (completeFirstData.contains(ChatUtils.getPrefixLogSsapsMtuChanged())) {
Log.d(TAG, "MTU改变日志:" + completeFirstData);
// 处理MTU改变日志
ChatUtils.setShowUartLog(true);return completeFirstData;

ChatUtils.setShowUartLog(true);
if (ChatUtils.isShowUartLog()) {
Log.d(TAG, "MTU改变日志:" + completeFirstData + "是否显示?:" + true);
if (ChatUtils.isSetDebugLog()) {
Log.d(TAG, "MTU改变日志:" + completeFirstData + "是否设置打开?:" + true);
return completeFirstData;
} else {
Log.d(TAG, "MTU改变日志:" + completeFirstData + "是否设置打开?:" + false);
}
}
}
if (completeFirstData.contains(ChatUtils.getPrefixLogSleAnnounceEnableCallback())) {
Log.d(TAG, "启用回调日志:" + completeFirstData);
// 处理启用回调日志
ChatUtils.setShowUartLog(true);return completeFirstData;

ChatUtils.setShowUartLog(true);
if (ChatUtils.isShowUartLog()) {
Log.d(TAG, "启用回调日志:" + completeFirstData + "是否显示?:" + true);
if (ChatUtils.isSetDebugLog()) {
Log.d(TAG, "启用回调日志:" + completeFirstData + "是否设置打开?:" + true);
return completeFirstData;
} else {
Log.d(TAG, "启用回调日志:" + completeFirstData + "是否设置打开?:" + false);
}
}
}
}
return "";
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<resources>
<string name="app_name">NLChat</string>
<string name="app_package">com.haohanyh.linmengjia.nearlink.nlchat.fun</string>
<string name="app_version">1.3.169.2024.0709</string>
<string name="app_version">1.3.179.2024.0709</string>

<string name="appwarn">NLChat,浩瀚银河宗旨为用爱和魔法创造Android APP。</string>
<string name="thanks3q">友情感谢</string>
Expand Down

0 comments on commit 76adb9b

Please sign in to comment.