Handle app locking for threads too
This commit is contained in:
parent
ae2e480876
commit
8675de70c2
|
@ -445,6 +445,7 @@ class MainActivity : SimpleActivity() {
|
||||||
val conversation = any as Conversation
|
val conversation = any as Conversation
|
||||||
putExtra(THREAD_ID, conversation.threadId)
|
putExtra(THREAD_ID, conversation.threadId)
|
||||||
putExtra(THREAD_TITLE, conversation.title)
|
putExtra(THREAD_TITLE, conversation.title)
|
||||||
|
putExtra(WAS_PROTECTION_HANDLED, wasProtectionHandled)
|
||||||
startActivity(this)
|
startActivity(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,6 +101,7 @@ class ThreadActivity : SimpleActivity() {
|
||||||
private var loadingOlderMessages = false
|
private var loadingOlderMessages = false
|
||||||
private var allMessagesFetched = false
|
private var allMessagesFetched = false
|
||||||
private var oldestMessageDate = -1
|
private var oldestMessageDate = -1
|
||||||
|
private var wasProtectionHandled = false
|
||||||
|
|
||||||
private var isScheduledMessage: Boolean = false
|
private var isScheduledMessage: Boolean = false
|
||||||
private var scheduledMessage: Message? = null
|
private var scheduledMessage: Message? = null
|
||||||
|
@ -136,30 +137,25 @@ class ThreadActivity : SimpleActivity() {
|
||||||
intent.getStringExtra(THREAD_TITLE)?.let {
|
intent.getStringExtra(THREAD_TITLE)?.let {
|
||||||
thread_toolbar.title = it
|
thread_toolbar.title = it
|
||||||
}
|
}
|
||||||
|
wasProtectionHandled = intent.getBooleanExtra(WAS_PROTECTION_HANDLED, false)
|
||||||
|
|
||||||
bus = EventBus.getDefault()
|
bus = EventBus.getDefault()
|
||||||
bus!!.register(this)
|
bus!!.register(this)
|
||||||
handlePermission(PERMISSION_READ_PHONE_STATE) { granted ->
|
|
||||||
if (granted) {
|
|
||||||
setupButtons()
|
|
||||||
setupConversation()
|
|
||||||
setupCachedMessages {
|
|
||||||
val searchedMessageId = intent.getLongExtra(SEARCHED_MESSAGE_ID, -1L)
|
|
||||||
intent.removeExtra(SEARCHED_MESSAGE_ID)
|
|
||||||
if (searchedMessageId != -1L) {
|
|
||||||
val index = threadItems.indexOfFirst { (it as? Message)?.id == searchedMessageId }
|
|
||||||
if (index != -1) {
|
|
||||||
thread_messages_list.smoothScrollToPosition(index)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setupThread()
|
if (savedInstanceState == null) {
|
||||||
setupScrollFab()
|
if (!wasProtectionHandled) {
|
||||||
}
|
handleAppPasswordProtection {
|
||||||
|
wasProtectionHandled = it
|
||||||
|
if (it) {
|
||||||
|
loadConversation()
|
||||||
} else {
|
} else {
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
loadConversation()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setupAttachmentPickerView()
|
setupAttachmentPickerView()
|
||||||
setupKeyboardListener()
|
setupKeyboardListener()
|
||||||
|
@ -221,6 +217,29 @@ class ThreadActivity : SimpleActivity() {
|
||||||
bus?.unregister(this)
|
bus?.unregister(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onSaveInstanceState(outState: Bundle) {
|
||||||
|
super.onSaveInstanceState(outState)
|
||||||
|
outState.putBoolean(WAS_PROTECTION_HANDLED, wasProtectionHandled)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onRestoreInstanceState(savedInstanceState: Bundle) {
|
||||||
|
super.onRestoreInstanceState(savedInstanceState)
|
||||||
|
wasProtectionHandled = savedInstanceState.getBoolean(WAS_PROTECTION_HANDLED, false)
|
||||||
|
|
||||||
|
if (!wasProtectionHandled) {
|
||||||
|
handleAppPasswordProtection {
|
||||||
|
wasProtectionHandled = it
|
||||||
|
if (it) {
|
||||||
|
loadConversation()
|
||||||
|
} else {
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
loadConversation()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun refreshMenuItems() {
|
private fun refreshMenuItems() {
|
||||||
val firstPhoneNumber = participants.firstOrNull()?.phoneNumbers?.firstOrNull()?.value
|
val firstPhoneNumber = participants.firstOrNull()?.phoneNumbers?.firstOrNull()?.value
|
||||||
thread_toolbar.menu.apply {
|
thread_toolbar.menu.apply {
|
||||||
|
@ -546,6 +565,30 @@ class ThreadActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun loadConversation() {
|
||||||
|
handlePermission(PERMISSION_READ_PHONE_STATE) { granted ->
|
||||||
|
if (granted) {
|
||||||
|
setupButtons()
|
||||||
|
setupConversation()
|
||||||
|
setupCachedMessages {
|
||||||
|
val searchedMessageId = intent.getLongExtra(SEARCHED_MESSAGE_ID, -1L)
|
||||||
|
intent.removeExtra(SEARCHED_MESSAGE_ID)
|
||||||
|
if (searchedMessageId != -1L) {
|
||||||
|
val index = threadItems.indexOfFirst { (it as? Message)?.id == searchedMessageId }
|
||||||
|
if (index != -1) {
|
||||||
|
thread_messages_list.smoothScrollToPosition(index)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setupThread()
|
||||||
|
setupScrollFab()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun setupConversation() {
|
private fun setupConversation() {
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
conversation = conversationsDB.getConversationWithThreadId(threadId)
|
conversation = conversationsDB.getConversationWithThreadId(threadId)
|
||||||
|
|
Loading…
Reference in New Issue