Skip to content

Commit

Permalink
🎉Release 1.2,完善聊天剪贴板功能,修复遇到重复粘贴和特殊问题(BETA,仅数字验证码)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hny0305Lin committed Jul 2, 2024
1 parent 7a06583 commit 25fccbf
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,11 @@ private String CH34xProcessingForReadData(String string) {

//聊天进入剪贴板
if (ChatUtils.isClipMessages()) {
// 提取四位和六位数字
Pattern pattern = Pattern.compile("\\b\\d{4}\\b|\\b\\d{6}\\b");
// 清空 extractedNumbers 以确保每次都是最新的提取结果
extractedNumbers.setLength(0);

// 提取四位和六位数字,但排除年份相关的四位数字
Pattern pattern = Pattern.compile("\\b(?!19\\d{2}|20\\d{2})\\d{4}\\b|\\b\\d{6}\\b");
Matcher matcher = pattern.matcher(completeSecondData);
while (matcher.find()) {
String foundNumber = matcher.group();
Expand All @@ -462,7 +465,11 @@ private String CH34xProcessingForReadData(String string) {
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("extractedNumbers", extractedNumbers.toString().trim());
clipboard.setPrimaryClip(clip);
SnackBarToastForDebug("提取到疑似验证码,已复制到剪贴板!","推荐去粘贴",0,Snackbar.LENGTH_LONG);
SnackBarToastForDebug("提取到疑似验证码,已复制到剪贴板!","推荐去粘贴",0,Snackbar.LENGTH_INDEFINITE);

// 取消之前的清空任务并重新设置定时任务
HhandlerClipBoard.removeCallbacks(clipboardRunnable);
HhandlerClipBoard.postDelayed(clipboardRunnable, 30000); // 30秒后清空剪贴板
}
}
return completeSecondData;
Expand Down Expand Up @@ -544,6 +551,20 @@ private String CH34xProcessingForSendData(String string) {
return true;
});

/*
* 定义一个 Handler和Runnable,用于剪贴板功能
*/
private Handler HhandlerClipBoard = new Handler();
private Runnable clipboardRunnable = new Runnable() {
@Override
public void run() {
// 清空剪贴板内容
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("", "");
clipboard.setPrimaryClip(clip);
}
};

/**
*
* TextInformation()与HhandlerI配合,修改页面情况,并且显示在页面
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.2.69.2024.0702</string>
<string name="app_version">1.2.71.2024.0702</string>

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

0 comments on commit 25fccbf

Please sign in to comment.