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
7882e1c5
Commit
7882e1c5
authored
Nov 18, 2024
by
zhangchengbo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:添加isSFNumber标识符,去除Shortcut快捷icon功能
parent
0098d5c1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
42 deletions
+42
-42
MainActivity.kt
...c/main/kotlin/com/secspace/sms/activities/MainActivity.kt
+42
-42
No files found.
app/src/main/kotlin/com/secspace/sms/activities/MainActivity.kt
View file @
7882e1c5
...
...
@@ -4,10 +4,6 @@ import android.annotation.SuppressLint
import
android.app.Activity
import
android.app.role.RoleManager
import
android.content.Intent
import
android.content.pm.ShortcutInfo
import
android.content.pm.ShortcutManager
import
android.graphics.drawable.Icon
import
android.graphics.drawable.LayerDrawable
import
android.os.Build
import
android.os.Bundle
import
android.provider.Telephony
...
...
@@ -15,7 +11,6 @@ import android.text.TextUtils
import
android.util.Log
import
androidx.annotation.RequiresApi
import
androidx.coordinatorlayout.widget.CoordinatorLayout
import
com.secspace.sms.BuildConfig
import
com.secspace.sms.R
import
com.secspace.sms.adapters.ConversationsAdapter
import
com.secspace.sms.adapters.SearchResultsAdapter
...
...
@@ -31,13 +26,13 @@ import com.secspace.sms.models.SearchResult
import
com.simplemobiletools.commons.dialogs.PermissionRequiredDialog
import
com.simplemobiletools.commons.extensions.*
import
com.simplemobiletools.commons.helpers.*
import
com.simplemobiletools.commons.models.FAQItem
import
com.simplemobiletools.commons.models.Release
import
com.simplemobiletools.commons.util.GsonUtil
import
org.greenrobot.eventbus.EventBus
import
org.greenrobot.eventbus.Subscribe
import
org.greenrobot.eventbus.ThreadMode
class
MainActivity
:
SimpleActivity
()
{
private
val
TAG
=
"shuju"
private
val
MAKE_DEFAULT_APP_REQUEST
=
1
private
var
storedTextColor
=
0
...
...
@@ -108,7 +103,7 @@ class MainActivity : SimpleActivity() {
binding
.
conversationsFastscroller
.
updateColors
(
properPrimaryColor
)
binding
.
conversationsProgressBar
.
setIndicatorColor
(
properPrimaryColor
)
binding
.
conversationsProgressBar
.
trackColor
=
properPrimaryColor
.
adjustAlpha
(
LOWER_ALPHA
)
checkShortcut
()
//
checkShortcut()
(
binding
.
conversationsFab
.
layoutParams
as
?
CoordinatorLayout
.
LayoutParams
)
?.
bottomMargin
=
navigationBarHeight
+
resources
.
getDimension
(
com
.
simplemobiletools
.
commons
.
R
.
dimen
.
activity_margin
).
toInt
()
}
...
...
@@ -305,7 +300,7 @@ class MainActivity : SimpleActivity() {
updateUnreadCountBadge
(
conversations
)
runOnUiThread
{
setupConversations
(
conversations
,
cached
=
true
)
//
setupConversations(conversations, cached = true)
getNewConversations
((
conversations
+
archived
).
toMutableList
()
as
ArrayList
<
Conversation
>)
}
conversations
.
forEach
{
...
...
@@ -318,8 +313,12 @@ class MainActivity : SimpleActivity() {
val
privateCursor
=
getMyContactsCursor
(
favoritesOnly
=
false
,
withPhoneNumbersOnly
=
true
)
ensureBackgroundThread
{
val
privateContacts
=
MyContactsContentProvider
.
getSimpleContacts
(
this
,
privateCursor
)
val
conversations
=
getConversations
(
privateContacts
=
privateContacts
)
// Log.e(TAG, " getNewConversations privateContacts:${GsonUtil.parseListToJson(privateContacts)}")
//获取系统SMS DB短信列表
val
conversations
:
java
.
util
.
ArrayList
<
Conversation
>
=
getConversations
(
privateContacts
=
privateContacts
)
// Log.e(TAG, " getNewConversations 获取系统SMS DB短信列表(脏数据) conversations:${GsonUtil.parseListToJson(conversations)}")
//通过DB数据与cache对比threadID
conversations
.
forEach
{
clonedConversation
->
val
threadIds
=
cachedConversations
.
map
{
it
.
threadId
}
if
(!
threadIds
.
contains
(
clonedConversation
.
threadId
))
{
...
...
@@ -337,7 +336,7 @@ class MainActivity : SimpleActivity() {
conversationsDB
.
deleteThreadId
(
threadId
)
}
val
newConversation
=
conversations
.
find
{
it
.
phoneNumber
==
cachedConversation
.
phoneNumber
}
val
newConversation
:
Conversation
?
=
conversations
.
find
{
it
.
phoneNumber
==
cachedConversation
.
phoneNumber
}
if
(
isTemporaryThread
&&
newConversation
!=
null
)
{
// delete the original temporary thread and move any scheduled messages to the new thread
conversationsDB
.
deleteThreadId
(
threadId
)
...
...
@@ -353,22 +352,29 @@ class MainActivity : SimpleActivity() {
val
conv
=
conversations
.
find
{
it
.
threadId
==
cachedConv
.
threadId
&&
!
Conversation
.
areContentsTheSame
(
cachedConv
,
it
)
}
if
(
conv
!=
null
)
{
// Log.e(TAG, " getNewConversations 对比后的结果(新数据)222 find conv:${GsonUtil.parseBeanToJson(conv)}")
if
(
conv
!=
null
&&
conv
.
isSFNumber
)
{
// Log.e(TAG, " conversations find it conv:${GsonUtil.parseBeanToJson(conv)}")
val
lastModified
=
maxOf
(
cachedConv
.
date
,
conv
.
date
)
val
conversation
=
conv
.
copy
(
date
=
lastModified
)
// Log.e(
// TAG,
// " getNewConversations 对比后的结果(新数据) isSFNumber=${conv.isSFNumber} find conversation:${GsonUtil.parseBeanToJson(conversation)}"
// )
insertOrUpdateConversation
(
conversation
)
}
}
val
allConversations
=
conversationsDB
.
getNonArchived
()
as
ArrayList
<
Conversation
>
// Log.e(TAG, "----MainActivity----handleMessage allConversations:${GsonUtil.parseListToJson(allConversations)}")
runOnUiThread
{
setupConversations
(
allConversations
)
}
// Log.e(TAG, "----MainActivity----handleMessage appRunCount:${config.appRunCount}")
if
(
config
.
appRunCount
==
1
)
{
conversations
.
map
{
it
.
threadId
}.
forEach
{
threadId
->
val
messages
=
getMessages
(
threadId
,
getImageResolutions
=
false
,
includeScheduledMessages
=
false
)
messages
.
chunked
(
30
).
forEach
{
currentMessages
->
messages
.
chunked
(
30
).
forEach
{
currentMessages
:
List
<
Message
>
->
messagesDB
.
insertMessages
(*
currentMessages
.
toTypedArray
())
}
}
...
...
@@ -409,6 +415,7 @@ class MainActivity : SimpleActivity() {
showOrHidePlaceholder
(
conversations
.
isEmpty
())
}
// Log.e(TAG, " MainActivity setupConversations() 显示短信列表数据 =: ${GsonUtil.parseListToJson(sortedConversations)}")
try
{
getOrCreateConversationsAdapter
().
apply
{
updateConversations
(
sortedConversations
)
{
...
...
@@ -455,7 +462,7 @@ class MainActivity : SimpleActivity() {
Intent
(
this
,
ThreadActivity
::
class
.
java
).
apply
{
val
conversation
=
any
as
Conversation
putExtra
(
THREAD_ID
,
conversation
.
threadId
)
putExtra
(
THREAD_TITLE
,
conversation
.
title
)
putExtra
(
THREAD_TITLE
,
conversation
.
phoneNumber
)
putExtra
(
WAS_PROTECTION_HANDLED
,
wasProtectionHandled
)
startActivity
(
this
)
}
...
...
@@ -468,7 +475,7 @@ class MainActivity : SimpleActivity() {
}
}
@SuppressLint
(
"NewApi"
)
/*
@SuppressLint("NewApi")
private fun checkShortcut() {
val appIconColor = config.appIconColor
if (isNougatMR1Plus() && config.lastHandledShortcutColor != appIconColor) {
...
...
@@ -481,24 +488,24 @@ class MainActivity : SimpleActivity() {
} catch (ignored: Exception) {
}
}
}
@SuppressLint
(
"NewApi"
)
private
fun
getCreateNewContactShortcut
(
appIconColor
:
Int
):
ShortcutInfo
{
val
newEvent
=
getString
(
R
.
string
.
new_conversation
)
val
drawable
=
resources
.
getDrawable
(
com
.
simplemobiletools
.
commons
.
R
.
drawable
.
shortcut_plus
)
(
drawable
as
LayerDrawable
).
findDrawableByLayerId
(
com
.
simplemobiletools
.
commons
.
R
.
id
.
shortcut_plus_background
).
applyColorFilter
(
appIconColor
)
val
bmp
=
drawable
.
convertToBitmap
()
val
intent
=
Intent
(
this
,
NewConversationActivity
::
class
.
java
)
intent
.
action
=
Intent
.
ACTION_VIEW
return
ShortcutInfo
.
Builder
(
this
,
"new_conversation"
)
.
setShortLabel
(
newEvent
)
.
setLongLabel
(
newEvent
)
.
setIcon
(
Icon
.
createWithBitmap
(
bmp
))
.
setIntent
(
intent
)
.
build
()
}
}
*/
/*
@SuppressLint("NewApi")
private fun getCreateNewContactShortcut(appIconColor: Int): ShortcutInfo {
val newEvent = getString(R.string.new_conversation)
val drawable = resources.getDrawable(com.simplemobiletools.commons.R.drawable.shortcut_plus)
(drawable as LayerDrawable).findDrawableByLayerId(com.simplemobiletools.commons.R.id.shortcut_plus_background).applyColorFilter(appIconColor)
val bmp = drawable.convertToBitmap()
val intent = Intent(this, NewConversationActivity::class.java)
intent.action = Intent.ACTION_VIEW
return ShortcutInfo.Builder(this, "new_conversation")
.setShortLabel(newEvent)
.setLongLabel(newEvent)
.setIcon(Icon.createWithBitmap(bmp))
.setIntent(intent)
.build()
}*/
private
fun
searchTextChanged
(
text
:
String
,
forceUpdate
:
Boolean
=
false
)
{
if
(!
binding
.
mainMenu
.
isSearchOpen
&&
!
forceUpdate
)
{
...
...
@@ -583,15 +590,8 @@ class MainActivity : SimpleActivity() {
@Subscribe
(
threadMode
=
ThreadMode
.
MAIN
)
fun
refreshMessages
(
event
:
Events
.
RefreshMessages
)
{
Log
.
e
(
"shuju"
,
"-----EventBus-----
"
)
Log
.
e
(
TAG
,
"----MainActivity----refreshMessages EventBus
"
)
initMessenger
()
}
private
fun
checkWhatsNewDialog
()
{
arrayListOf
<
Release
>().
apply
{
add
(
Release
(
48
,
R
.
string
.
release_48
))
add
(
Release
(
62
,
R
.
string
.
release_62
))
checkWhatsNew
(
this
,
com
.
secspace
.
sms
.
BuildConfig
.
VERSION_CODE
)
}
}
}
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