mirror of
https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
synced 2025-02-17 04:00:35 +01:00
setup some thread info sooner, before getting real messages
This commit is contained in:
parent
f97e3b048c
commit
189e60ac32
@ -81,7 +81,10 @@ class ThreadActivity : SimpleActivity() {
|
|||||||
bus!!.register(this)
|
bus!!.register(this)
|
||||||
handlePermission(PERMISSION_READ_PHONE_STATE) {
|
handlePermission(PERMISSION_READ_PHONE_STATE) {
|
||||||
if (it) {
|
if (it) {
|
||||||
setupThread()
|
setupButtons()
|
||||||
|
setupCachedMessages {
|
||||||
|
setupThread()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
@ -102,11 +105,7 @@ class ThreadActivity : SimpleActivity() {
|
|||||||
val privateCursor = getMyContactsCursor()?.loadInBackground()
|
val privateCursor = getMyContactsCursor()?.loadInBackground()
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
messages = getMessages(threadId)
|
messages = getMessages(threadId)
|
||||||
participants = if (messages.isEmpty()) {
|
setupParticipants()
|
||||||
getThreadParticipants(threadId, null)
|
|
||||||
} else {
|
|
||||||
messages.first().participants
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if no participant came from a privately stored contact in Simple Contacts
|
// check if no participant came from a privately stored contact in Simple Contacts
|
||||||
privateContacts = MyContactsContentProvider.getSimpleContacts(this, privateCursor)
|
privateContacts = MyContactsContentProvider.getSimpleContacts(this, privateCursor)
|
||||||
@ -143,20 +142,9 @@ class ThreadActivity : SimpleActivity() {
|
|||||||
setupAttachmentSizes()
|
setupAttachmentSizes()
|
||||||
setupAdapter()
|
setupAdapter()
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
val threadTitle = participants.getThreadTitle()
|
setupThreadTitle()
|
||||||
if (threadTitle.isNotEmpty()) {
|
|
||||||
supportActionBar?.title = participants.getThreadTitle()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (messages.isEmpty()) {
|
|
||||||
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
|
||||||
thread_type_message.requestFocus()
|
|
||||||
}
|
|
||||||
|
|
||||||
setupSIMSelector()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setupButtons()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
@ -197,6 +185,25 @@ class ThreadActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun setupCachedMessages(callback: () -> Unit) {
|
||||||
|
ensureBackgroundThread {
|
||||||
|
messages = messagesDB.getThreadMessages(threadId).toMutableList() as ArrayList<Message>
|
||||||
|
setupParticipants()
|
||||||
|
setupAdapter()
|
||||||
|
|
||||||
|
runOnUiThread {
|
||||||
|
if (messages.isEmpty()) {
|
||||||
|
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
||||||
|
thread_type_message.requestFocus()
|
||||||
|
}
|
||||||
|
|
||||||
|
setupThreadTitle()
|
||||||
|
setupSIMSelector()
|
||||||
|
callback()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun setupAdapter() {
|
private fun setupAdapter() {
|
||||||
threadItems = getThreadItems()
|
threadItems = getThreadItems()
|
||||||
invalidateOptionsMenu()
|
invalidateOptionsMenu()
|
||||||
@ -318,6 +325,23 @@ class ThreadActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun setupParticipants() {
|
||||||
|
if (participants.isEmpty()) {
|
||||||
|
participants = if (messages.isEmpty()) {
|
||||||
|
getThreadParticipants(threadId, null)
|
||||||
|
} else {
|
||||||
|
messages.first().participants
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setupThreadTitle() {
|
||||||
|
val threadTitle = participants.getThreadTitle()
|
||||||
|
if (threadTitle.isNotEmpty()) {
|
||||||
|
supportActionBar?.title = participants.getThreadTitle()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressLint("MissingPermission")
|
@SuppressLint("MissingPermission")
|
||||||
private fun setupSIMSelector() {
|
private fun setupSIMSelector() {
|
||||||
val availableSIMs = SubscriptionManager.from(this).activeSubscriptionInfoList ?: return
|
val availableSIMs = SubscriptionManager.from(this).activeSubscriptionInfoList ?: return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user