Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
Simple-Sms
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhangchengbo
Simple-Sms
Commits
9cadb3d2
Commit
9cadb3d2
authored
Dec 10, 2025
by
zhangchengbo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:1.优先加载缓存数据,会话详情页标题优先取通讯录备注名称
2.点击跳转对DB操作 在子线程闭包执行
parent
480a52e2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
42 deletions
+56
-42
MainActivity.kt
...c/main/kotlin/com/secspace/sms/activities/MainActivity.kt
+56
-42
No files found.
app/src/main/kotlin/com/secspace/sms/activities/MainActivity.kt
View file @
9cadb3d2
...
...
@@ -340,10 +340,8 @@ class MainActivity : SimpleActivity() {
if
(
archived
.
isNotEmpty
())
Log
.
d
(
TAG
,
"getCachedConversations: archived = ${Gson().toJson(archived)}"
)
// runOnUiThread {
// setupConversations(conversations, cached = true)
setupConversations
(
conversations
,
cached
=
true
)
getNewConversations
((
conversations
+
archived
).
toMutableList
()
as
ArrayList
<
Conversation
>)
// }
conversations
.
forEach
{
clearExpiredScheduledMessages
(
it
.
threadId
)
}
...
...
@@ -358,7 +356,7 @@ class MainActivity : SimpleActivity() {
val
privateContacts
=
MyContactsContentProvider
.
getSimpleContacts
(
this
@MainActivity
,
privateCursor
)
Log
.
d
(
TAG
,
" getNewConversations privateContacts:${GsonUtil.parseListToJson(privateContacts)}"
)
//获取系统SMS DB短信列表
//获取系统SMS DB短信列表
,根据手机号检测通讯录备注名称
val
conversations
:
java
.
util
.
ArrayList
<
Conversation
>
=
getConversations
(
privateContacts
=
privateContacts
)
Log
.
d
(
TAG
,
" getNewConversations 获取系统SMS DB短信列表(脏数据) conversations:${GsonUtil.parseListToJson(conversations)}"
)
...
...
@@ -520,23 +518,27 @@ class MainActivity : SimpleActivity() {
compareByDescending
<
Conversation
>
{
config
.
pinnedConversations
.
contains
(
it
.
threadId
.
toString
())
}
.
thenByDescending
{
it
.
date
}
).
toMutableList
()
as
ArrayList
<
Conversation
>
Log
.
d
(
TAG
,
"setupConversations: sortedConversations = ${sortedConversations.size}"
)
setFirstConversationAndUpdateData
(
sortedConversations
)
//根据记录被删除的会话手机号,从会话列表中判断手机号是否一致,满足就脱敏手机号(为了解决荣耀云备份后恢复,手机号未脱敏的情况)
val
listMsgIdAll
:
String
?
=
Config
.
newInstance
(
this
@MainActivity
).
listDeleteMsgIdAllData
Log
.
d
(
TAG
,
"setupConversations 云备份 获取被删除的会话集合 listMsgIdAll 不等于空 = ${!listMsgIdAll.isNullOrEmpty()}"
)
if
(!
listMsgIdAll
.
isNullOrEmpty
())
{
val
listData
:
ArrayList
<
String
>
=
listMsgIdAll
.
split
(
","
).
toArrayList
()
Log
.
d
(
TAG
,
"setupConversations 云备份 split listData = ${listData}"
)
if
(
listData
.
isNotEmpty
())
{
val
listConversationData
:
List
<
Conversation
>
=
conversations
.
filter
{
listData
.
contains
(
it
.
phoneNumber
)
}
Log
.
d
(
TAG
,
"setupConversations 云备份 找到被删除的 ListConversation 会话 = ${Gson().toJson(listConversationData)}"
)
if
(
listConversationData
.
isNotEmpty
())
{
listConversationData
.
forEach
{
conversation
->
// Constant.listThreadData.remove(conversation.phoneNumber)
conversation
.
isSFNumber
=
true
conversationsDB
.
insertOrUpdate
(
conversation
)
Log
.
d
(
TAG
,
"setupConversations: sortedConversations = ${sortedConversations.size} toJson = ${Gson().toJson(sortedConversations)}"
)
//加载缓存数据不执行此处
if
(!
cached
)
{
//根据最新的短信 是否需要对手机号掩码及db bean修改
setFirstConversationAndUpdateData
(
sortedConversations
)
//根据记录被删除的会话手机号,从会话列表中判断手机号是否一致,满足就脱敏手机号(为了解决荣耀云备份后恢复,手机号未脱敏的情况)
val
listMsgIdAll
:
String
?
=
Config
.
newInstance
(
this
@MainActivity
).
listDeleteMsgIdAllData
Log
.
d
(
TAG
,
"setupConversations 云备份 获取被删除的会话集合 listMsgIdAll 不等于空 = ${!listMsgIdAll.isNullOrEmpty()}"
)
if
(!
listMsgIdAll
.
isNullOrEmpty
())
{
val
listData
:
ArrayList
<
String
>
=
listMsgIdAll
.
split
(
","
).
toArrayList
()
Log
.
d
(
TAG
,
"setupConversations 云备份 split listData = ${listData}"
)
if
(
listData
.
isNotEmpty
())
{
val
listConversationData
:
List
<
Conversation
>
=
conversations
.
filter
{
listData
.
contains
(
it
.
phoneNumber
)
}
Log
.
d
(
TAG
,
"setupConversations 云备份 找到被删除的 ListConversation 会话 = ${Gson().toJson(listConversationData)}"
)
if
(
listConversationData
.
isNotEmpty
())
{
listConversationData
.
forEach
{
conversation
->
conversation
.
isSFNumber
=
true
conversationsDB
.
insertOrUpdate
(
conversation
)
}
}
}
}
...
...
@@ -553,7 +555,7 @@ class MainActivity : SimpleActivity() {
try
{
getOrCreateConversationsAdapter
().
apply
{
Log
.
d
(
TAG
,
"setupConversations: 短信列表数量 = ${sortedConversations.size}"
)
Log
.
d
(
TAG
,
"setupConversations: 短信列表数量 = ${sortedConversations.size}
toJson = ${Gson().toJson(sortedConversations)}
"
)
updateConversations
(
sortedConversations
)
{
Log
.
d
(
TAG
,
"setupConversations: cached = ${!cached}"
)
if
(!
cached
)
{
...
...
@@ -602,31 +604,43 @@ class MainActivity : SimpleActivity() {
Log
.
d
(
TAG
,
"handleConversationClick: conversation = ${Gson().toJson(conversation)}"
)
val
userName
=
conversation
.
userName
Log
.
d
(
TAG
,
"handleConversationClick: 通讯录备注名称 = $userName 短信内容 = ${conversation.snippet} threadId = ${conversation.threadId}"
)
val
listMessageData
=
getMessages
(
conversation
.
threadId
,
false
)
Log
.
d
(
TAG
,
"handleConversationClick: listMessageData是否为空 = ${listMessageData.isNotEmpty()}"
)
if
(
listMessageData
.
isNotEmpty
())
{
val
listContains
:
List
<
Message
>
=
listMessageData
.
filter
{
msg
->
msg
.
body
.
contains
(
"\u200B"
)
}
Log
.
d
(
TAG
,
"handleConversationClick: 是否包含零宽度字符 = ${listContains.isNotEmpty()}"
)
if
(
listContains
.
isNotEmpty
()
||
conversation
.
isSFNumber
)
{
if
(
userName
.
isNotBlank
()
&&
!
PhoneFromUtil
.
isNumeric
(
userName
))
{
putExtra
(
THREAD_TITLE
,
userName
)
}
else
{
val
phoneNumber
=
conversation
.
title
if
(
phoneNumber
.
contains
(
"+86"
))
{
phoneNumber
.
replace
(
"+86"
,
""
)
ensureBackgroundThread
{
val
listMessageData
=
getMessages
(
conversation
.
threadId
,
false
)
Log
.
d
(
TAG
,
"handleConversationClick: listMessageData是否为空 = ${listMessageData.isNotEmpty()}"
)
if
(
listMessageData
.
isNotEmpty
())
{
val
listContains
:
List
<
Message
>
=
listMessageData
.
filter
{
msg
->
msg
.
body
.
contains
(
"\u200B"
)
}
Log
.
d
(
TAG
,
"handleConversationClick: 是否包含零宽度字符 = ${listContains.isNotEmpty()}"
)
if
(
listContains
.
isNotEmpty
()
||
conversation
.
isSFNumber
)
{
if
(
userName
.
isNotBlank
()
&&
!
PhoneFromUtil
.
isNumeric
(
userName
))
{
putExtra
(
THREAD_TITLE
,
userName
)
}
else
{
val
phoneNumber
=
conversation
.
title
if
(
phoneNumber
.
contains
(
"+86"
))
{
phoneNumber
.
replace
(
"+86"
,
""
)
}
PhoneUtils
.
phoneNumberFormat
(
phoneNumber
)
{
itNumber
->
putExtra
(
THREAD_TITLE
,
itNumber
)
}
}
PhoneUtils
.
phoneNumberFormat
(
phoneNumber
)
{
itNumber
->
putExtra
(
THREAD_TITLE
,
itNumber
)
}
else
{
if
(
userName
.
isNotBlank
())
{
putExtra
(
THREAD_TITLE
,
userName
)
}
else
{
putExtra
(
THREAD_TITLE
,
conversation
.
title
)
}
}
}
else
{
if
(
userName
.
isNotBlank
())
{
putExtra
(
THREAD_TITLE
,
userName
)
}
else
{
putExtra
(
THREAD_TITLE
,
conversation
.
title
)
}
}
}
else
{
putExtra
(
THREAD_TITLE
,
conversation
.
title
)
}
putExtra
(
THREAD_ID
,
conversation
.
threadId
)
putExtra
(
WAS_PROTECTION_HANDLED
,
wasProtectionHandled
)
startActivity
(
this
)
putExtra
(
THREAD_ID
,
conversation
.
threadId
)
putExtra
(
WAS_PROTECTION_HANDLED
,
wasProtectionHandled
)
startActivity
(
this
)
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment