diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt index 26d871c619..d25dc2842c 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt @@ -201,6 +201,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe setUpLinkPreviewObserver() scrollToFirstUnreadMessageIfNeeded() markAllAsRead() + showOrHideInputIfNeeded() } override fun onResume() { @@ -381,12 +382,25 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe } // endregion + // region Animation & Updating override fun onModified(recipient: Recipient) { runOnUiThread { if (thread.isContactRecipient) { blockedBanner.isVisible = thread.isBlocked } 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 } } diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/input_bar/InputBar.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/input_bar/InputBar.kt index 31be742776..b565f21766 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/input_bar/InputBar.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/input_bar/InputBar.kt @@ -31,6 +31,8 @@ class InputBar : RelativeLayout, InputBarEditTextDelegate, QuoteViewDelegate, Li var additionalContentHeight = 0 var quote: MessageRecord? = null var linkPreview: LinkPreview? = null + var showInput: Boolean = true + set(value) { field = value; showOrHideInputIfNeeded() } var text: String get() { return inputBarEditText.text.toString() } @@ -159,6 +161,19 @@ class InputBar : RelativeLayout, InputBarEditTextDelegate, QuoteViewDelegate, Li additionalContentHeight = 0 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 }