Skip to content

Commit

Permalink
🎉Release 1.3,阅后即焚2.2,阅后即焚最终版即将发布(双方阅后即焚等功能),表情Emoji接口即将发布。
Browse files Browse the repository at this point in the history
  • Loading branch information
Hny0305Lin committed Aug 5, 2024
1 parent cf10ac7 commit d5c1c5d
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

public class ChatUtilsForSettings {
//这里设置的是UI相关,是否做到消息滚动展示在UI上,而不是全部展示,全部展示会占用大量UI资源
private static boolean showUartLog = false; // 控制是否启用显示串口Log,这里设置是没用的(因为不是Final)
private static boolean showUartLog = false; // 控制是否启用显示串口Log
private static final boolean setDebugLog = true; // 控制是否启用显示串口Log,打印在UI上(开发者使用)
private static final boolean scrollingMessages = true; // 控制是否启用滚动消息功能
private static boolean clipMessages = true; // 控制是否启用剪贴板功能
Expand All @@ -16,7 +16,7 @@ public class ChatUtilsForSettings {
private static boolean burnmessage = false; // 控制是否启用阅后即焚聊天功能
private static final boolean burnshowword = false; // 控制是否启用阅后即焚文字显示(后续转为用户使用,false为不需要,true为需要点击显示3秒文字)
private static final boolean burnalertdialog = false; // 控制是否启用阅后即焚AliertDialog(开发者使用,false为长按消失消息,true为长按显示开发者信息)
private static final int burnwordshowtimer = 3000; // 控制阅后即焚阅读时间
private static final int burnwordshowtimer = 3000; // 控制阅后即焚阅读时间(推荐3秒钟)
private static final int burntimer = 120000; // 控制阅后即焚的时间(2分钟,120000.如为开发者推荐全局2秒钟,2000)
//这里设置的是跟C代码相关的,白名单获取聊天文本,当这些文本出现在串口通讯里面的时候,提取这String后者即可,期间过滤掉前者和大量串口log。
private static final String PREFIX_SERVER = " Let's start chatting, This is the content of the server:";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.haohanyh.linmengjia.nearlink.nlchat.fun.ChatCore.Emoji;

public class Emoji {
private String code;
private String shortUUID;

public Emoji(String code, String shortUUID) {
this.code = code;
this.shortUUID = shortUUID;
}

public String getCode() {
return code;
}

public void setCode(String code) {
this.code = code;
}

public String getShortUUID() {
return shortUUID;
}

public void setShortUUID(String shortUUID) {
this.shortUUID = shortUUID;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.haohanyh.linmengjia.nearlink.nlchat.fun.ChatCore.Emoji;

public class EmojiUtilsForCode {
private Emoji[] emojis;

public EmojiUtilsForCode() {
emojis = new Emoji[] {


new Emoji("U+1F600", "E00000"), // 😀

};
}

public Emoji[] getEmojis() {
return emojis;
}

public Emoji getEmojiByShortUUID(String shortUUID) {
for (Emoji emoji : emojis) {
if (emoji.getShortUUID().equals(shortUUID)) {
return emoji;
}
}
return null;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import android.provider.Settings;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.view.inputmethod.EditorInfo;
Expand Down Expand Up @@ -116,6 +117,9 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
private TextView APPRunResult,MobileUSBResult,UARTResult;
private EditText EditChatSendNewUI;

private long startTime;
private boolean isEmojiMode = false;
private static final int LONG_PRESS_TIME = 500; // 长按时间阈值,单位毫秒
private MaterialButton ButtonForSendData;

/* TODO 1.4版本前,务必把这个TextView未参与初始化和聊天核心内容,进行修改,目前是可以正常使用了。 */
Expand Down Expand Up @@ -447,7 +451,35 @@ public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent
EditChatSendNewUI = findViewById(id.editChatSendNewUI);
EditChatSendNewUI.setOnEditorActionListener(editorActionListenerForChatSend);

View.OnTouchListener touchListenerForSend = new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
switch (motionEvent.getAction()) {
case MotionEvent.ACTION_DOWN:
startTime = System.currentTimeMillis();
return true;
case MotionEvent.ACTION_UP:
long duration = System.currentTimeMillis() - startTime;
if (duration >= LONG_PRESS_TIME) {
isEmojiMode = true;
NearLinkChatSendEmoji(view);
} else {
if (isEmojiMode) {
isEmojiMode = false;
}
NearLinkChatSendData(view);
}
return true;
case MotionEvent.ACTION_CANCEL:
// 重置状态
startTime = 0;
return true;
}
return false;
}
};
ButtonForSendData = findViewById(id.sendDataBtn);
ButtonForSendData.setOnTouchListener(touchListenerForSend);

CheckBoxUartWarn = findViewById(id.cbUartWarn);
NearLinkUartWarnToast = CheckBoxUartWarn.isChecked();
Expand Down Expand Up @@ -1048,28 +1080,42 @@ private String CH34xProcessingForReadData(String string) {
}

public void NearLinkChatSendData(View view) {
HhandlerI.sendEmptyMessage(10);
//这里写的是用户是否使用新UI和旧UI。
//HhandlerI.sendEmptyMessage(10);
ButtonForSendData.setText(R.string.nearlinkChatSend);

byte[] to_send;
String messageSend;

//新UI处理发送,以字符串方式发送
messageSend = EditChatSendNewUI.getText().toString();
to_send = StringUtils.needProcess().toByteArrayII(EditChatSendNewUI.getText().toString());
if (!EditChatSendNewUI.getText().toString().isEmpty()) {
messageSend = EditChatSendNewUI.getText().toString();
to_send = StringUtils.needProcess().toByteArrayII(EditChatSendNewUI.getText().toString());

//byte[] to_send = StringUtils.needProcess().toByteArray(String.valueOf(EditChatSend.getText())); //以字符串方式发送
int retval = MainAPP.CH34X.writeData(to_send, to_send.length);//写数据,第一个参数为需要发送的字节数组,第二个参数为需要发送的字节长度,返回实际发送的字节长度
if (retval < 0) {
SnackBarToastForDebug(context,"向对方发送数据失败!","推荐重新配置",3,Snackbar.LENGTH_SHORT);
} else {
String TextOfClient = CH34xProcessingForSendData(messageSend);

// 使用ChatUIUpdater更新UI
chatUIUpdater.updateMeUI(TextOfClient);
runOnUiThread(() -> {
//发送完消息清空待发送文本
EditChatSendNewUI.setText("");
});
}
}
}

//byte[] to_send = StringUtils.needProcess().toByteArray(String.valueOf(EditChatSend.getText())); //以字符串方式发送
int retval = MainAPP.CH34X.writeData(to_send, to_send.length);//写数据,第一个参数为需要发送的字节数组,第二个参数为需要发送的字节长度,返回实际发送的字节长度
if (retval < 0) {
SnackBarToastForDebug(context,"向对方发送数据失败!","推荐重新配置",3,Snackbar.LENGTH_SHORT);
} else {
String TextOfClient = CH34xProcessingForSendData(messageSend);
public void NearLinkChatSendEmoji(View view) {
//HhandlerI.sendEmptyMessage(10);
ButtonForSendData.setText(R.string.nearlinkChatEmoji);

// 使用ChatUIUpdater更新UI
chatUIUpdater.updateMeUI(TextOfClient);
runOnUiThread(() -> {
//发送完消息清空待发送文本
EditChatSendNewUI.setText("");
});
//todo 目前这里先这么做,后续表情包喂上来了添加
//新UI处理发送,目前这里先这么做
if (!EditChatSendNewUI.getText().toString().isEmpty()) {
SnackBarToastForDebug(context,"表情相关功能正在制作,敬请期待!","推荐长按返回模式",3,Snackbar.LENGTH_SHORT);
}
}

Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:fontFamily="sans-serif-medium"
android:onClick="NearLinkChatSendData"
android:text="@string/nearlinkChatSend"
android:textColor="#FFFFFFFF"
app:backgroundTint="@color/Pink_is_fancy"
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout/activity_main_phone_landscape.xml
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:fontFamily="sans-serif-medium"
android:onClick="NearLinkChatSendData"
android:text="@string/nearlinkChatSend"
android:textColor="#FFFFFFFF"
app:backgroundTint="@color/Pink_is_fancy"
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout/activity_main_tablet_landscape.xml
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:fontFamily="sans-serif-medium"
android:onClick="NearLinkChatSendData"
android:text="@string/nearlinkChatSend"
android:textColor="#FFFFFFFF"
app:backgroundTint="@color/Pink_is_fancy"
Expand Down
4 changes: 3 additions & 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.352.2024.0803</string>
<string name="app_version">1.3.352.2024.0805</string>

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


<string name="nearlinkChatSend">发送消息</string>
<string name="nearlinkChatEmoji">发送Emoji</string>

<string name="uiNearLinkUartSettingWarn">星闪串口设置提示 </string>
<string name="uiNearLinkUartSettingWord">确认开启</string>
Expand Down Expand Up @@ -138,4 +139,5 @@
\n
该软件开源,二次创作等请署名\"浩瀚银河\"四字,请遵守我们公开的开源协议!
</string>

</resources>

0 comments on commit d5c1c5d

Please sign in to comment.