mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 21:15:48 +00:00
Fix disabled input state for Release Notes Channel.
This commit is contained in:
@@ -1047,7 +1047,8 @@ class ConversationFragment :
|
||||
inputReadyState.isActiveGroup == false -> disabledInputView.showAsNoLongerAMember()
|
||||
inputReadyState.isRequestingMember == true -> disabledInputView.showAsRequestingMember()
|
||||
inputReadyState.isAnnouncementGroup == true && inputReadyState.isAdmin == false -> disabledInputView.showAsAnnouncementGroupAdminsOnly()
|
||||
!inputReadyState.conversationRecipient.isGroup && !inputReadyState.conversationRecipient.isRegistered -> disabledInputView.showAsInviteToSignal(requireContext(), inputReadyState.conversationRecipient)
|
||||
inputReadyState.conversationRecipient.isReleaseNotes -> disabledInputView.showAsReleaseNotesChannel(inputReadyState.conversationRecipient)
|
||||
inputReadyState.shouldShowInviteToSignal() -> disabledInputView.showAsInviteToSignal(requireContext(), inputReadyState.conversationRecipient)
|
||||
else -> inputDisabled = false
|
||||
}
|
||||
|
||||
@@ -3497,6 +3498,10 @@ class ConversationFragment :
|
||||
)
|
||||
}
|
||||
|
||||
override fun onUnmuteReleaseNotesChannel() {
|
||||
viewModel.muteConversation(0L)
|
||||
}
|
||||
|
||||
private fun Single<Result<Unit, GroupChangeFailureReason>>.subscribeWithShowProgress(logMessage: String): Disposable {
|
||||
return doOnSubscribe { binding.conversationDisabledInput.showBusy() }
|
||||
.doOnTerminate { binding.conversationDisabledInput.hideBusy() }
|
||||
|
||||
@@ -417,7 +417,7 @@ class ConversationViewModel(
|
||||
|
||||
fun getRequestReviewState(): Observable<RequestReviewState> {
|
||||
return _inputReadyState
|
||||
.flatMapSingle { (recipient, messageRequestState, group) -> repository.getRequestReviewState(recipient, group, messageRequestState) }
|
||||
.flatMapSingle { state -> repository.getRequestReviewState(state.conversationRecipient, state.groupRecord, state.messageRequestState) }
|
||||
.distinctUntilChanged()
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.thoughtcrime.securesms.messagerequests.MessageRequestViewModel
|
||||
import org.thoughtcrime.securesms.messagerequests.MessageRequestsBottomView
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.util.SpanUtil
|
||||
import org.thoughtcrime.securesms.util.visible
|
||||
|
||||
/**
|
||||
* A one-stop-view for all your conversation input disabled needs.
|
||||
@@ -45,6 +46,7 @@ class DisabledInputView @JvmOverloads constructor(
|
||||
private var requestingGroup: View? = null
|
||||
private var announcementGroupOnly: TextView? = null
|
||||
private var inviteToSignal: View? = null
|
||||
private var releaseNoteChannel: View? = null
|
||||
|
||||
private var currentView: View? = null
|
||||
|
||||
@@ -140,6 +142,21 @@ class DisabledInputView @JvmOverloads constructor(
|
||||
)
|
||||
}
|
||||
|
||||
fun showAsReleaseNotesChannel(recipient: Recipient) {
|
||||
releaseNoteChannel = show(
|
||||
existingView = releaseNoteChannel,
|
||||
create = { inflater.inflate(R.layout.conversation_activity_unmute, this, false) },
|
||||
bind = {
|
||||
if (recipient.isMuted) {
|
||||
visible = true
|
||||
findViewById<View>(R.id.conversation_activity_unmute_button).setOnClickListener { listener?.onUnmuteReleaseNotesChannel() }
|
||||
} else {
|
||||
visible = false
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun setWallpaperEnabled(wallpaperEnabled: Boolean) {
|
||||
color = ContextCompat.getColor(context, if (wallpaperEnabled) R.color.wallpaper_bubble_color else R.color.signal_colorBackground)
|
||||
setBackgroundColor(color)
|
||||
@@ -209,5 +226,6 @@ class DisabledInputView @JvmOverloads constructor(
|
||||
fun onUnblockClicked()
|
||||
fun onGroupV1MigrationClicked()
|
||||
fun onInviteToSignal(recipient: Recipient)
|
||||
fun onUnmuteReleaseNotesChannel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import org.thoughtcrime.securesms.recipients.Recipient
|
||||
/**
|
||||
* Information necessary for rendering compose input.
|
||||
*/
|
||||
data class InputReadyState(
|
||||
class InputReadyState(
|
||||
val conversationRecipient: Recipient,
|
||||
val messageRequestState: MessageRequestState,
|
||||
val groupRecord: GroupRecord?,
|
||||
@@ -26,4 +26,34 @@ data class InputReadyState(
|
||||
val isActiveGroup: Boolean? = if (selfMemberLevel == null) null else selfMemberLevel != GroupTable.MemberLevel.NOT_A_MEMBER
|
||||
val isAdmin: Boolean? = selfMemberLevel?.equals(GroupTable.MemberLevel.ADMINISTRATOR)
|
||||
val isRequestingMember: Boolean? = selfMemberLevel?.equals(GroupTable.MemberLevel.REQUESTING_MEMBER)
|
||||
|
||||
fun shouldShowInviteToSignal(): Boolean {
|
||||
return !conversationRecipient.isGroup &&
|
||||
!conversationRecipient.isRegistered &&
|
||||
!conversationRecipient.isReleaseNotes
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as InputReadyState
|
||||
|
||||
if (!conversationRecipient.hasSameContent(other.conversationRecipient)) return false
|
||||
if (messageRequestState != other.messageRequestState) return false
|
||||
if (groupRecord != other.groupRecord) return false
|
||||
if (isClientExpired != other.isClientExpired) return false
|
||||
if (isUnauthorized != other.isUnauthorized) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = conversationRecipient.hashCode()
|
||||
result = 31 * result + messageRequestState.hashCode()
|
||||
result = 31 * result + (groupRecord?.hashCode() ?: 0)
|
||||
result = 31 * result + isClientExpired.hashCode()
|
||||
result = 31 * result + isUnauthorized.hashCode()
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:viewBindingIgnore="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/signal_colorSurface2">
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/conversation_activity_unmute_button"
|
||||
|
||||
@@ -300,7 +300,7 @@
|
||||
android:alpha="1"
|
||||
android:background="@drawable/compose_divider_background"
|
||||
android:visibility="invisible"
|
||||
app:layout_constraintBottom_toTopOf="@id/conversation_input_panel"
|
||||
app:layout_constraintBottom_toTopOf="@id/conversation_bottom_panel_barrier"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
|
||||
Reference in New Issue
Block a user