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
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
7 deletions
+21
-7
MainActivity.kt
...c/main/kotlin/com/secspace/sms/activities/MainActivity.kt
+21
-7
No files found.
app/src/main/kotlin/com/secspace/sms/activities/MainActivity.kt
View file @
9cadb3d2
...
@@ -340,10 +340,8 @@ class MainActivity : SimpleActivity() {
...
@@ -340,10 +340,8 @@ class MainActivity : SimpleActivity() {
if
(
archived
.
isNotEmpty
())
if
(
archived
.
isNotEmpty
())
Log
.
d
(
TAG
,
"getCachedConversations: archived = ${Gson().toJson(archived)}"
)
Log
.
d
(
TAG
,
"getCachedConversations: archived = ${Gson().toJson(archived)}"
)
// runOnUiThread {
setupConversations
(
conversations
,
cached
=
true
)
// setupConversations(conversations, cached = true)
getNewConversations
((
conversations
+
archived
).
toMutableList
()
as
ArrayList
<
Conversation
>)
getNewConversations
((
conversations
+
archived
).
toMutableList
()
as
ArrayList
<
Conversation
>)
// }
conversations
.
forEach
{
conversations
.
forEach
{
clearExpiredScheduledMessages
(
it
.
threadId
)
clearExpiredScheduledMessages
(
it
.
threadId
)
}
}
...
@@ -358,7 +356,7 @@ class MainActivity : SimpleActivity() {
...
@@ -358,7 +356,7 @@ class MainActivity : SimpleActivity() {
val
privateContacts
=
MyContactsContentProvider
.
getSimpleContacts
(
this
@MainActivity
,
privateCursor
)
val
privateContacts
=
MyContactsContentProvider
.
getSimpleContacts
(
this
@MainActivity
,
privateCursor
)
Log
.
d
(
TAG
,
" getNewConversations privateContacts:${GsonUtil.parseListToJson(privateContacts)}"
)
Log
.
d
(
TAG
,
" getNewConversations privateContacts:${GsonUtil.parseListToJson(privateContacts)}"
)
//获取系统SMS DB短信列表
//获取系统SMS DB短信列表
,根据手机号检测通讯录备注名称
val
conversations
:
java
.
util
.
ArrayList
<
Conversation
>
=
getConversations
(
privateContacts
=
privateContacts
)
val
conversations
:
java
.
util
.
ArrayList
<
Conversation
>
=
getConversations
(
privateContacts
=
privateContacts
)
Log
.
d
(
TAG
,
" getNewConversations 获取系统SMS DB短信列表(脏数据) conversations:${GsonUtil.parseListToJson(conversations)}"
)
Log
.
d
(
TAG
,
" getNewConversations 获取系统SMS DB短信列表(脏数据) conversations:${GsonUtil.parseListToJson(conversations)}"
)
...
@@ -520,7 +518,11 @@ class MainActivity : SimpleActivity() {
...
@@ -520,7 +518,11 @@ class MainActivity : SimpleActivity() {
compareByDescending
<
Conversation
>
{
config
.
pinnedConversations
.
contains
(
it
.
threadId
.
toString
())
}
compareByDescending
<
Conversation
>
{
config
.
pinnedConversations
.
contains
(
it
.
threadId
.
toString
())
}
.
thenByDescending
{
it
.
date
}
.
thenByDescending
{
it
.
date
}
).
toMutableList
()
as
ArrayList
<
Conversation
>
).
toMutableList
()
as
ArrayList
<
Conversation
>
Log
.
d
(
TAG
,
"setupConversations: sortedConversations = ${sortedConversations.size}"
)
Log
.
d
(
TAG
,
"setupConversations: sortedConversations = ${sortedConversations.size} toJson = ${Gson().toJson(sortedConversations)}"
)
//加载缓存数据不执行此处
if
(!
cached
)
{
//根据最新的短信 是否需要对手机号掩码及db bean修改
setFirstConversationAndUpdateData
(
sortedConversations
)
setFirstConversationAndUpdateData
(
sortedConversations
)
//根据记录被删除的会话手机号,从会话列表中判断手机号是否一致,满足就脱敏手机号(为了解决荣耀云备份后恢复,手机号未脱敏的情况)
//根据记录被删除的会话手机号,从会话列表中判断手机号是否一致,满足就脱敏手机号(为了解决荣耀云备份后恢复,手机号未脱敏的情况)
...
@@ -534,13 +536,13 @@ class MainActivity : SimpleActivity() {
...
@@ -534,13 +536,13 @@ class MainActivity : SimpleActivity() {
Log
.
d
(
TAG
,
"setupConversations 云备份 找到被删除的 ListConversation 会话 = ${Gson().toJson(listConversationData)}"
)
Log
.
d
(
TAG
,
"setupConversations 云备份 找到被删除的 ListConversation 会话 = ${Gson().toJson(listConversationData)}"
)
if
(
listConversationData
.
isNotEmpty
())
{
if
(
listConversationData
.
isNotEmpty
())
{
listConversationData
.
forEach
{
conversation
->
listConversationData
.
forEach
{
conversation
->
// Constant.listThreadData.remove(conversation.phoneNumber)
conversation
.
isSFNumber
=
true
conversation
.
isSFNumber
=
true
conversationsDB
.
insertOrUpdate
(
conversation
)
conversationsDB
.
insertOrUpdate
(
conversation
)
}
}
}
}
}
}
}
}
}
lifecycleScope
.
launch
(
Dispatchers
.
Main
)
{
lifecycleScope
.
launch
(
Dispatchers
.
Main
)
{
if
(
cached
&&
config
.
appRunCount
==
1
)
{
if
(
cached
&&
config
.
appRunCount
==
1
)
{
...
@@ -553,7 +555,7 @@ class MainActivity : SimpleActivity() {
...
@@ -553,7 +555,7 @@ class MainActivity : SimpleActivity() {
try
{
try
{
getOrCreateConversationsAdapter
().
apply
{
getOrCreateConversationsAdapter
().
apply
{
Log
.
d
(
TAG
,
"setupConversations: 短信列表数量 = ${sortedConversations.size}"
)
Log
.
d
(
TAG
,
"setupConversations: 短信列表数量 = ${sortedConversations.size}
toJson = ${Gson().toJson(sortedConversations)}
"
)
updateConversations
(
sortedConversations
)
{
updateConversations
(
sortedConversations
)
{
Log
.
d
(
TAG
,
"setupConversations: cached = ${!cached}"
)
Log
.
d
(
TAG
,
"setupConversations: cached = ${!cached}"
)
if
(!
cached
)
{
if
(!
cached
)
{
...
@@ -602,6 +604,7 @@ class MainActivity : SimpleActivity() {
...
@@ -602,6 +604,7 @@ class MainActivity : SimpleActivity() {
Log
.
d
(
TAG
,
"handleConversationClick: conversation = ${Gson().toJson(conversation)}"
)
Log
.
d
(
TAG
,
"handleConversationClick: conversation = ${Gson().toJson(conversation)}"
)
val
userName
=
conversation
.
userName
val
userName
=
conversation
.
userName
Log
.
d
(
TAG
,
"handleConversationClick: 通讯录备注名称 = $userName 短信内容 = ${conversation.snippet} threadId = ${conversation.threadId}"
)
Log
.
d
(
TAG
,
"handleConversationClick: 通讯录备注名称 = $userName 短信内容 = ${conversation.snippet} threadId = ${conversation.threadId}"
)
ensureBackgroundThread
{
val
listMessageData
=
getMessages
(
conversation
.
threadId
,
false
)
val
listMessageData
=
getMessages
(
conversation
.
threadId
,
false
)
Log
.
d
(
TAG
,
"handleConversationClick: listMessageData是否为空 = ${listMessageData.isNotEmpty()}"
)
Log
.
d
(
TAG
,
"handleConversationClick: listMessageData是否为空 = ${listMessageData.isNotEmpty()}"
)
if
(
listMessageData
.
isNotEmpty
())
{
if
(
listMessageData
.
isNotEmpty
())
{
...
@@ -619,16 +622,27 @@ class MainActivity : SimpleActivity() {
...
@@ -619,16 +622,27 @@ class MainActivity : SimpleActivity() {
putExtra
(
THREAD_TITLE
,
itNumber
)
putExtra
(
THREAD_TITLE
,
itNumber
)
}
}
}
}
}
else
{
if
(
userName
.
isNotBlank
())
{
putExtra
(
THREAD_TITLE
,
userName
)
}
else
{
putExtra
(
THREAD_TITLE
,
conversation
.
title
)
}
}
}
}
else
{
}
else
{
if
(
userName
.
isNotBlank
())
{
putExtra
(
THREAD_TITLE
,
userName
)
}
else
{
putExtra
(
THREAD_TITLE
,
conversation
.
title
)
putExtra
(
THREAD_TITLE
,
conversation
.
title
)
}
}
}
putExtra
(
THREAD_ID
,
conversation
.
threadId
)
putExtra
(
THREAD_ID
,
conversation
.
threadId
)
putExtra
(
WAS_PROTECTION_HANDLED
,
wasProtectionHandled
)
putExtra
(
WAS_PROTECTION_HANDLED
,
wasProtectionHandled
)
startActivity
(
this
)
startActivity
(
this
)
}
}
}
}
}
private
fun
launchNewConversation
()
{
private
fun
launchNewConversation
()
{
hideKeyboard
()
hideKeyboard
()
...
...
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