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 21, 2024
1 parent 609b988 commit ad5f682
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ public void updateTextView() {
} else if (isDebug) {
chatMessages.add(new ChatMessage(newMessage, isDebug, loglevel));
} else if (isHistoryUser) {
chatMessages.add(new ChatMessage(newMessage, "History User," + historyTime, true, 1));
chatMessages.add(new ChatMessage(newMessage, "History User,\n " + historyTime, true, 1));
} else if (isHistoryMe) {
chatMessages.add(new ChatMessage(newMessage, "History Me," + historyTime, true, 2));
chatMessages.add(new ChatMessage(newMessage, "History Me,\n " + historyTime, true, 2));
} else if (isHistoryDebug) {
chatMessages.add(new ChatMessage(newMessage, "", true, 3));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ public class ChatUtils {
private static boolean clipMessages = true; // 控制是否启用剪贴板功能
//这里设置的是数据库相关
private static boolean sqlitemanager = true; // 控制是否启用SQLite存储功能
private static boolean sqlitehistory = true; // 控制是否启用SQLite历史记录显示功能
private static boolean sqlitehistory = false; // 控制是否启用SQLite历史记录显示功能
private static boolean showsqlitehistory = true; // 控制是否启用SQLite历史记录显示,这里设置是没用的(因为不是Final)
private static final boolean sqlitehistorymanagerlog = false; // 控制是否启用SQLite保存存储、历史记录显示Logcat(开发者使用)
//这里设置的是跟C代码相关的,白名单获取聊天文本,当这些文本出现在串口通讯里面的时候,提取这String后者即可,期间过滤掉前者和大量串口log。
private static final String PREFIX_SERVER = " Let's start chatting, This is the content of the server:";
Expand Down Expand Up @@ -59,6 +60,10 @@ public class ChatUtils {
public static boolean isSqliteHistory() { return sqlitehistory; }

public static void setSqliteHistory(boolean sqlitehistory) { ChatUtils.sqlitehistory = sqlitehistory; }

public static boolean isShowSqliteHistory() { return showsqlitehistory; }

public static void setShowSqliteHistory(boolean showsqlitehistory) { ChatUtils.showsqlitehistory = showsqlitehistory; }
//控制是否启用SQLite保存存储、历史记录显示Logcat
public static boolean isSqlitehistorymanagerlog() { return sqlitehistorymanagerlog; }
//对方为星闪服务端(User)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,12 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
if (isChecked) {
ChatUtils.setSqliteHistory(true);
SnackBarToastForDebug(context,"您已开始展示您的聊天记录啦!","目前为" + ChatUtils.isSqliteHistory(),0,Snackbar.LENGTH_SHORT);
if (ChatUtils.isSqliteHistory() && ChatUtils.isShowSqliteHistory()) {
loadMessagesFromDatabase();
ChatUtils.setShowSqliteHistory(false); //已经显示一次了
} else if (!ChatUtils.isShowSqliteHistory()){
SnackBarToastForDebug(context,"您已经展示过了,请往上翻阅!", "推荐查阅!",0,Snackbar.LENGTH_SHORT);
}
} else {
if (ChatUIAlertDialog.showNormal(compoundButton.getContext(), "历史设备记录(SQLite)", "您确定要停止展示聊天数据在UI上吗?", compoundButton))
ChatUtils.setSqliteHistory(false);
Expand Down Expand Up @@ -538,7 +544,12 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
HhandlerI.sendEmptyMessage(31);

//如果SQLite有记录,可以显示在UI上
if (ChatUtils.isSqliteHistory()) loadMessagesFromDatabase();
if (ChatUtils.isSqliteHistory()) {
loadMessagesFromDatabase();

SettingsForHistory.setChecked(true);
ChatUtils.setShowSqliteHistory(false); //已经显示一次了
}

//背景处理
//注册图片选择器的启动器
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.300.2024.0720</string>
<string name="app_version">1.3.301.2024.0721</string>

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

0 comments on commit ad5f682

Please sign in to comment.