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
fdb07b69
Commit
fdb07b69
authored
Dec 03, 2025
by
zhangchengbo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:添加PopWindow短信推送悬浮窗与通知栏推送展示(通讯录如果有备注则优先展示备注,其次手机号)
parent
2238abd0
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
15 deletions
+21
-15
SmsReceiver.kt
...src/main/kotlin/com/secspace/sms/receivers/SmsReceiver.kt
+21
-15
No files found.
app/src/main/kotlin/com/secspace/sms/receivers/SmsReceiver.kt
View file @
fdb07b69
...
...
@@ -74,14 +74,12 @@ class SmsReceiver : BroadcastReceiver() {
if
(
exists
)
{
handleMessage
(
context
,
address
,
subject
,
body
,
date
,
read
,
threadId
,
type
,
subscriptionId
,
status
,
phoneNumberResult
)
{
badgeTotalNumber
(
context
)
// sendNotification(phoneNumberResult, body)
}
}
}
}
else
{
handleMessage
(
context
,
address
,
subject
,
body
,
date
,
read
,
threadId
,
type
,
subscriptionId
,
status
,
phoneNumberResult
)
{
badgeTotalNumber
(
context
)
// sendNotification(phoneNumberResult, body)
}
}
}
...
...
@@ -117,7 +115,7 @@ class SmsReceiver : BroadcastReceiver() {
Log.d(TAG, "SmsReceiver 短信内容相等 = ${it.threadId == threadId && it.isSFNumber }")
it.threadId == threadId && it.isSFNumber
}
android.util.
Log.d(TAG, "findConversationWithPhoneNumber listConversation = $listConversation")
Log.d(TAG, "findConversationWithPhoneNumber listConversation = $listConversation")
if (listConversation.isNotEmpty()) {
lastNumber = listConversation.first().title
}
...
...
@@ -184,14 +182,21 @@ class SmsReceiver : BroadcastReceiver() {
}
val
photoUri
=
SimpleContactsHelper
(
context
).
getPhotoUriFromPhoneNumber
(
address
)
val
bitmap
=
context
.
getNotificationBitmap
(
photoUri
)
var
notificationUserName
=
""
//通讯录如果有备注则优先展示备注,其次手机号
Handler
(
Looper
.
getMainLooper
()).
post
{
//最新消息会话
val
conversation
:
Conversation
=
context
.
getConversations
(
threadId
).
firstOrNull
()
?:
return
@post
Log
.
d
(
TAG
,
"handleMessage: conversation toJson = ${Gson().toJson(conversation)} "
)
if
(!
PhoneFromUtil
.
isNumeric
(
conversation
.
userName
)){
notificationUserName
=
conversation
.
userName
}
if
(!
context
.
isNumberBlocked
(
address
))
{
val
privateCursor
=
context
.
getMyContactsCursor
(
favoritesOnly
=
false
,
withPhoneNumbersOnly
=
true
)
ensureBackgroundThread
{
val
newMessageId
:
Long
=
context
.
insertNewSMS
(
address
,
subject
,
body
,
date
,
read
,
threadId
,
type
,
subscriptionId
)
//最新消息会话
val
conversation
:
Conversation
=
context
.
getConversations
(
threadId
).
firstOrNull
()
?:
return
@ensureBackgroundThread
Log
.
d
(
TAG
,
"handleMessage: toJson = ${Gson().toJson(conversation)}"
)
if
(
aesPhoneNumber
.
isNotBlank
()
||
body
.
contains
(
"\u200B"
))
{
conversation
.
title
=
aesPhoneNumber
conversation
.
isSFNumber
=
true
...
...
@@ -205,11 +210,6 @@ class SmsReceiver : BroadcastReceiver() {
val
senderName
=
context
.
getNameFromAddress
(
address
,
privateCursor
)
val
phoneNumber
=
PhoneNumber
(
address
,
0
,
""
,
address
)
/*if (aesPhoneNumber.isNotBlank()) {
senderName = context.getNameFromAddress(aesPhoneNumber, privateCursor)
phoneNumber = PhoneNumber(aesPhoneNumber, 0, "", aesPhoneNumber)
}*/
val
participant
=
SimpleContact
(
0
,
0
,
senderName
,
photoUri
,
arrayListOf
(
phoneNumber
),
ArrayList
(),
ArrayList
())
val
participants
=
arrayListOf
(
participant
)
val
messageDate
=
(
date
/
1000
).
toInt
()
...
...
@@ -238,17 +238,23 @@ class SmsReceiver : BroadcastReceiver() {
context
.
updateConversationArchivedStatus
(
threadId
,
false
)
}
refreshMessages
()
if
(
aesPhoneNumber
.
isNotBlank
())
{
Log
.
d
(
TAG
,
"handleMessage: notificationUserName = $notificationUserName aesPhoneNumber = $aesPhoneNumber address = $address"
)
if
(
notificationUserName
.
isNotEmpty
()){
context
.
showReceivedMessageNotification
(
newMessageId
,
notificationUserName
,
body
,
threadId
,
bitmap
)
}
else
if
(
aesPhoneNumber
.
isNotBlank
())
{
context
.
showReceivedMessageNotification
(
newMessageId
,
aesPhoneNumber
,
body
,
threadId
,
bitmap
)
}
else
{
context
.
showReceivedMessageNotification
(
newMessageId
,
address
,
body
,
threadId
,
bitmap
)
}
}
}
Log
.
d
(
TAG
,
"SmsReceiver aesPhoneNumber 手机号是否加密 :${aesPhoneNumber}"
)
if
(
aesPhoneNumber
.
isNotBlank
())
{
Log
.
d
(
TAG
,
"SmsReceiver: notificationUserName = $notificationUserName aesPhoneNumber = $aesPhoneNumber address = $address"
)
if
(
notificationUserName
.
isNotEmpty
()){
val
tipPopup
=
MyPushWindow
(
context
,
notificationUserName
,
body
)
tipPopup
.
show
()
}
else
if
(
aesPhoneNumber
.
isNotBlank
())
{
val
tipPopup
=
MyPushWindow
(
context
,
aesPhoneNumber
,
body
)
tipPopup
.
show
()
}
else
{
...
...
@@ -331,7 +337,7 @@ class SmsReceiver : BroadcastReceiver() {
val
buildNotification
=
builder
.
build
()
notificationManager
.
notify
(
CALL_NOTIFICATION_ID
,
buildNotification
)
android
.
util
.
Log
.
d
(
TAG
,
"sendNotification: 发送通知栏消息推送"
)
Log
.
d
(
TAG
,
"sendNotification: 发送通知栏消息推送"
)
}
}
...
...
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