Hide input if the user isn't part of a group

This commit is contained in:
Niels Andriesse 2021-06-30 14:05:30 +10:00
parent 1fbb3d3dd5
commit 07de201fde
2 changed files with 29 additions and 0 deletions

View File

@ -201,6 +201,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
setUpLinkPreviewObserver() setUpLinkPreviewObserver()
scrollToFirstUnreadMessageIfNeeded() scrollToFirstUnreadMessageIfNeeded()
markAllAsRead() markAllAsRead()
showOrHideInputIfNeeded()
} }
override fun onResume() { override fun onResume() {
@ -381,12 +382,25 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
} }
// endregion // endregion
// region Animation & Updating
override fun onModified(recipient: Recipient) { override fun onModified(recipient: Recipient) {
runOnUiThread { runOnUiThread {
if (thread.isContactRecipient) { if (thread.isContactRecipient) {
blockedBanner.isVisible = thread.isBlocked blockedBanner.isVisible = thread.isBlocked
} }
updateSubtitle() updateSubtitle()
showOrHideInputIfNeeded()
}
}
private fun showOrHideInputIfNeeded() {
if (thread.isClosedGroupRecipient) {
val group = DatabaseFactory.getGroupDatabase(this).getGroup(thread.address.toGroupString()).orNull()
val isActive = (group?.isActive == true)
Log.d("Test", "isActive: $isActive")
inputBar.showInput = isActive
} else {
inputBar.showInput = true
} }
} }

View File

@ -31,6 +31,8 @@ class InputBar : RelativeLayout, InputBarEditTextDelegate, QuoteViewDelegate, Li
var additionalContentHeight = 0 var additionalContentHeight = 0
var quote: MessageRecord? = null var quote: MessageRecord? = null
var linkPreview: LinkPreview? = null var linkPreview: LinkPreview? = null
var showInput: Boolean = true
set(value) { field = value; showOrHideInputIfNeeded() }
var text: String var text: String
get() { return inputBarEditText.text.toString() } get() { return inputBarEditText.text.toString() }
@ -159,6 +161,19 @@ class InputBar : RelativeLayout, InputBarEditTextDelegate, QuoteViewDelegate, Li
additionalContentHeight = 0 additionalContentHeight = 0
setHeight(newHeight) setHeight(newHeight)
} }
private fun showOrHideInputIfNeeded() {
if (showInput) {
setOf( inputBarEditText, attachmentsButton ).forEach { it.isVisible = true }
microphoneButton.isVisible = text.isEmpty()
sendButton.isVisible = text.isNotEmpty()
} else {
cancelQuoteDraft()
cancelLinkPreviewDraft()
val views = setOf( inputBarEditText, attachmentsButton, microphoneButton, sendButton )
views.forEach { it.isVisible = false }
}
}
// endregion // endregion
} }